Patch: extra attributes in custom objects (new version)
From: "Marco Contenti" <m contenti libero it>
To: <dia-list gnome org>
Subject: Patch: extra attributes in custom objects (new version)
Date: Mon, 1 Dec 2003 12:12:53 +0100
Hello,
here is the new version of my patch which incorporates all Lars'
improvements and adds some more cleanup and new features.
Namely:
- As suggested by Lars, I created a function in the StdProp library which
returns the size of a data item (just the space occupied in the extended
Custom struct, not data pointed to), thus eliminating those ugly case-like
tests on property types. This function is called get_data_size() and is
mapped in the PropertyOps function table. Moreover, this makes the new
custom object code independent of property types, as long as they don't
require special treatment, so new types can be easily added (WARNING: right
now, get_data_size() is implemented only for the four supported types int,
bool, real, string, but supporting more types is really a snap).
- The code from parse_ext_attributes() is now merged into
custom_setup_properties(), so that extra attributes are handled in one place
and ext_attr_list is not needed anymore. Having the props table available
while parsing XML also makes it easier to handle extra data needed by enums
etc.
- I changed the <attribute> tag to <ext_attribute> (conflicts with XSLT) and
added a tag for description, which now defaults to name only when this tag
is not available. You can see this in the sample
shapes/Circuit/hresistor.shape I changed accordingly.
TIA for comments and suggestions.
Marco