[PD-dev] getting the classname in an class

Mathieu Bouchard matju at artengine.ca
Tue Oct 30 16:35:29 CET 2007


On Mon, 29 Oct 2007, Hans-Christoph Steiner wrote:

> I ran into a problem applying this to the iemgui (footils/knob and
> moonlib/mknob both use the iemgui API).  Basically, in iemgui, the
> use  "t_iemgui x_gui" instead of "t_object x_obj".  x_gui then has
> "t_object x_obj".  That means adding an extra layer:
> atom_getsymbol(binbuf_getvec(x->x_gui.x_obj.te_binbuf)),

I always use pointer casts so that I don't have to think about the name of 
the magic prefixes used to access superclass fields. OTOH this makes it 
easier to make type mistakes, in theory, but I haven't seen that happening 
much in practice for this kind of cast.

Using a cast, you can take any subtype of t_object, and no matter how it 
decides to call its t_object part, and no matter how many levels of 
nestedness it takes, you always get to the t_object part by casting like 
(t_object *).

  _ _ __ ___ _____ ________ _____________ _____________________ ...
| Mathieu Bouchard - tél:+1.514.383.3801, Montréal QC Canada


More information about the Pd-dev mailing list