Just a little glimpse of how C++ makes the code more readable. Note that
the generator idiom I use in the C++ implementation could be also
possible in modern C, at no loss in performance but with a bit more verbosity.

C++:

               for (splineiter spline; ((pathptr)thiselem)->values(spline); )
                     calcspline(spline);

C:
               for (pgen = ((pathptr)thiselem)->plist; pgen < 
((pathptr)thiselem)->plist
                                + ((pathptr)thiselem)->parts; pgen++)
                  if (ELEMENTTYPE(*pgen) == SPLINE)
                     calcspline((splineptr)*pgen);

modern C would look like:
               for (splineptr* spline = 0; 
((pathptr)thiselem)->spline_values(&spline); )
                     calcspline(*spline);

The code is full of those iterate-over-elements-of-one-type loops.

Right now I've got the code to a point where it mostly works (there's a 
regression with
library directory labels being misplaced that I have to debug) with all 
elements being
proper C++ classes, with constructors, destructors, copy-constructors, 
assignment and
comparison operators, etc. Also all memory management is done with new/delete.

I'm cleaning this up and checking it in step-by-step. There are a couple 
changes that
I'm not entirely happy with, that I'll further refactor. The goal is having all 
elements
cleanly implemented as C++ classes, with reasonable semantics, to be ported to
QGraphicsItem.

Those changes take a bit longer since one typically has to inspect  and adjust 
dozens
or even of sites in the code for almost every change. But I'm getting there.

Cheers, Kuba
_______________________________________________
Xcircuit-dev mailing list
[email protected]
http://www.opencircuitdesign.com/mailman/listinfo/xcircuit-dev

Reply via email to