> I think it is important that we preserve run-time checking of these casts (from parent to child). Would this be acceptable for now? :
>    #define SP_ITEM(obj)      ( SP_IS_ITEM(obj) ? (SPItem*)obj : NULL  )

> I'm afraid that otherwise, bad casts will be much harder to track down.

As far as I can see this won’t happen, at least not in the existing code. It always looks like this:

void *p …

if (SP_IS_RECT(p)) {

    SP_RECT(p)->doWhatever();

}

 

Every bad cast would have caused an error message on the console…

And for new code, well, be careful with your casts until there’s some more refactoring progress. If too many of these to-child-casts appear, it looks to me like a design error. There should probably be a virtual method then.

 

Regards,

Markus