[PD-dev] bug when redrawing gop within gop inside a closed sub-patch

Mathieu Bouchard matju at artengine.ca
Mon Nov 23 20:49:52 CET 2009


On Mon, 23 Nov 2009, Ivica Ico Bukvic wrote:

>> With what C++ provides for nesting structs, you can remove most 
>> typecasts from Pd's code, including all the disguised typecasts (every 
>> use of te_gobj, g_gobj, x_obj, x_gui, as well as many uses of g_pd).
> Good idea. I'll try to give it a shot next time I mess with Pd source.

Ok, I'll give you an example to be sure:

typedef struct _text {
     t_gobj te_g;
     t_binbuf *te_binbuf;
     t_outlet *te_outlet;
     t_inlet *te_inlet;
     short te_xpix, te_ypix, te_width;
     unsigned int te_type:2;
} t_text;

can become:

typedef struct _text : struct t_gobj {
     t_binbuf *te_binbuf;
     t_outlet *te_outlet;
     t_inlet *te_inlet;
     short te_xpix, te_ypix, te_width;
     unsigned int te_type:2;
} t_text;

so t_text (aka t_object) becomes a variant of t_gobj instead of just 
containing a t_gobj. This means you never need to cast from t_text* to 
t_gobj* anymore, and it means you never have to write te_g anymore, but it 
means you can't write te_g anymore, and that's a little downside. However 
it's normal that you still have to do explicit casts the other way around 
because even though in this case a t_text is a t_gobj, it doesn't mean a 
t_gobj is a t_text.

I use #ifdef to switch between the C and C++ versions of 
these structs, in binary-compatible ways.

I'm sorry for the repeated typo of writing te_gobj instead of te_g.

  _ _ __ ___ _____ ________ _____________ _____________________ ...
| Mathieu Bouchard, Montréal, Québec. téléphone: +1.514.383.3801


More information about the Pd-dev mailing list