[PD] question about getdir(Guenter Geiger)'s code

Hans-Christoph Steiner hans at eds.org
Thu Aug 30 00:01:26 CEST 2007


Hey,

I think Günter didn't want to depend on non-public headers like  
g_canvas.h, so included the glist struct from that header.   
Personally, I think makes more sense to include the g_canvas.h header.

[parentdollarzero] like a useful object, I am not usre what  
[getdollarzero] does beyond [float $0] or [$0].  Anyway, hopefully  
they make into Pd-extended.

.hc


On Aug 27, 2007, at 4:43 PM, Thomas O Fredericks wrote:

> Thanks to Han's help page (http://puredata.info/docs/developer/ 
> mingw) I was able to compile a test external on windows with mingw.
>
> I then started making a new external called getdollarzero based on  
> getdir (from ggee) and parentdollarzero (from iemlib2). I compiled  
> it and it works but I had to:
> 1) remove Guenter's hack from getdir's source code
> 2) and therefore include g_canvas.h
>
> My question is the following: why is there a hack in the first  
> place? If I do not use it will my code crash PD in some way (I  
> compiled against PD 0.4 and worked fine during testing)?
>
> As a reference, here is my code with the hack commented out :
>
>
> --------- getdollarzero  --------
>
> #include "m_pd.h"
> #include "g_canvas.h" //needed to include g_canvas.h once the hack  
> was commented out
>
>
> /* HACK
> struct _glist
> {
>     t_object gl_obj;            // header in case we're a glist
>     t_gobj *gl_list;            // the actual data
>     struct _gstub *gl_stub;     // safe pointer handler
>     int gl_valid;               // incremented when pointers might  
> be stale
>     struct _glist *gl_owner;    // parent glist, supercanvas, or 0  
> if none
> };
>
> END HACK
> */
>
> typedef struct getdollarzero
> {
>     t_object x_ob;
>     t_canvas * x_canvas;
>     t_outlet* x_outlet;
>     int x_level;
> } t_getdollarzero;
>
>
>
>
> static void getdollarzero_bang(t_getdollarzero *x)
> {
>     int i = x->x_level;
>     t_canvas* last = x->x_canvas;
>
>     while (i>0) {
>         i--;
>         if (last->gl_owner) last = last->gl_owner;
>     }
>     // code example taken from iemlib2's parentdollarzero:
>     // x->s_parent_unique = canvas_realizedollar((t_canvas *) 
> this_canvas->gl_owner, gensym("$0"));
>     // original get dir function:
>     //outlet_symbol(x->x_outlet,canvas_getdir(last));
>
>     outlet_symbol(x->x_outlet,canvas_realizedollar(last, gensym 
> ("$0")));
> }
>
> t_class *getdollarzero_class;
>
> static void *getdollarzero_new(t_floatarg level)
> {
>     t_getdollarzero *x = (t_getdollarzero *)pd_new 
> (getdollarzero_class);
>     x->x_canvas =  canvas_getcurrent();
>     x->x_outlet =  outlet_new(&x->x_ob, &s_);
>     x->x_level  =  level;
>     return (void *)x;
> }
>
> void getdollarzero_setup(void)
> {
>     getdollarzero_class = class_new(gensym("getdollarzero"),  
> (t_newmethod)getdollarzero_new, 0,
>         sizeof(t_getdollarzero), 0, A_DEFFLOAT,0);
>     class_addbang(getdollarzero_class, getdollarzero_bang);
> }
>
> --------- getdollarzero  end --------
>
> -- 
> thomas ouellet fredericks, tof at danslchamp.org, montreal, canada
> _______________________________________________
> PD-list at iem.at mailing list
> UNSUBSCRIBE and account-management -> http://lists.puredata.info/ 
> listinfo/pd-list



------------------------------------------------------------------------ 
----

Computer science is no more related to the computer than astronomy is  
related to the telescope.      -Edsger Dykstra


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20070829/8759c7e0/attachment.htm>


More information about the Pd-list mailing list