Hi,
Just wanted to point out that this weekend I spent most of my Inkscape time doing a few passes of cleanup on the code, mainly getting rid of ancient C-style macros related to SPObject.
Among the other issues was that the SP_OBJECT() macro was being used many places that it was not needed. However the most important issue is that such C style macros have been hiding issues with const vs. non-const parameters and object. I cleaned up just a couple of these problem areas, and marked a few more with TODO tags. The bottom line, though, is that we should probably all keep an eye out for const issues and make sure we correct what we can.
For example, if a function takes a const parameter of some type such as
int foo( SPObject const *object );
And then down somewhere in the body of the function does
SPItem *item = SP_ITEM(object);
Things will compile correctly, and at runtime will *almost* behave correctly. The SP_ITEM() macro will do the proper GObject thing of ensuring a pointer to the proper C object type is present and the struct bookkeeping is intact, etc. *However* the C-style cast in the middle of the macro will throw away const and we'll have a mutable object when our function contract misleadingly promises that we will not modify it at all.
The macros also block method overloading, add introspection overhead that we'd prefer to avoid in inner loops and such, and cause a few other problems.
participants (1)
-
Jon Cruz