diff --git a/pd/src/g_canvas.c b/pd/src/g_canvas.c index 627ebc1d49c7d22d97524646f69e733970751df3..c084861934302a0dcdc083cfd121ca5ef67bffb7 100644 --- a/pd/src/g_canvas.c +++ b/pd/src/g_canvas.c @@ -1159,33 +1159,27 @@ void canvas_loadbang(t_canvas *x) //fprintf(stderr,"%lx 2\n", x); } -/* JMZ: - * initbang is emitted after the canvas is done, but before the parent canvas is done - * therefore, initbangs cannot reach to the outlets - */ +/* JMZ/MSP: + * initbang is emitted after a canvas is read from a file, but before the + parent canvas is finished loading. This is apparently used so that + abstractions can create inlets/outlets as a function of creation arguments. + This practice is quite ugly but there's no other way to do it so far. +*/ void canvas_initbang(t_canvas *x) { t_gobj *y; - t_symbol *s = gensym("initbang"); + t_symbol *s = gensym("loadbang"); /* run "initbang" for all subpatches, but NOT for the child abstractions */ for (y = x->gl_list; y; y = y->g_next) - { - if (pd_class(&y->g_pd) == canvas_class) - { - if (!canvas_isabstraction((t_canvas *)y)) - canvas_initbang((t_canvas *)y); - } - } + if (!canvas_isabstraction((t_canvas *)y)) + canvas_initbang((t_canvas *)y); /* call the initbang()-method for objects that have one */ for (y = x->gl_list; y; y = y->g_next) - { if ((pd_class(&y->g_pd) != canvas_class) && zgetfn(&y->g_pd, s)) - { pd_vmess(&y->g_pd, s, "f", (t_floatarg)LB_INIT); - } - } } + /* JMZ: * closebang is emitted before the canvas is destroyed * and BEFORE subpatches/abstractions in this canvas are destroyed @@ -1193,19 +1187,15 @@ void canvas_initbang(t_canvas *x) void canvas_closebang(t_canvas *x) { t_gobj *y; - t_symbol *s = gensym("closebang"); + t_symbol *s = gensym("loadbang"); - /* call the closebang()-method for objects that have one + /* call the closebang()-method for objects that have one * but NOT for subpatches/abstractions: these are called separately * from g_graph:glist_delete() */ for (y = x->gl_list; y; y = y->g_next) - { if ((pd_class(&y->g_pd) != canvas_class) && zgetfn(&y->g_pd, s)) - { pd_vmess(&y->g_pd, s, "f", (t_floatarg)LB_CLOSE); - } - } } // we use this function to check if the canvas that has sent out the <config> diff --git a/pd/src/x_misc.c b/pd/src/x_misc.c index 349a97ba5cf8671a27e1189b3e3fe59f63981e55..3811db80a425bb7c715dd00851697f38e2cffc53 100644 --- a/pd/src/x_misc.c +++ b/pd/src/x_misc.c @@ -115,9 +115,9 @@ static void loadbang_click(t_loadbang *x, outlet_bang(x->x_obj.ob_outlet); } -static void loadbang_loadbang(t_loadbang *x) +static void loadbang_loadbang(t_loadbang *x, t_floatarg action) { - if (!sys_noloadbang) + if (!sys_noloadbang && action == LB_LOAD) outlet_bang(x->x_obj.ob_outlet); } @@ -126,7 +126,7 @@ static void loadbang_setup(void) loadbang_class = class_new(gensym("loadbang"), (t_newmethod)loadbang_new, 0, sizeof(t_loadbang), CLASS_NOINLET, 0); class_addmethod(loadbang_class, (t_method)loadbang_loadbang, - gensym("loadbang"), 0); + gensym("loadbang"), A_DEFFLOAT, 0); class_addmethod(loadbang_class, (t_method)loadbang_click, gensym("click"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); } @@ -147,9 +147,8 @@ static void *initbang_new(void) return (x); } -static void initbang_initbang(t_initbang *x) -{ - if (!sys_noloadbang) /* JMZ: hmm, not sure whether we should respect sys_noloadbang here... */ +static void initbang_loadbang(t_initbang *x, t_float type) { + if (LB_INIT == (int)type) outlet_bang(x->x_obj.ob_outlet); } @@ -157,8 +156,8 @@ static void initbang_setup(void) { initbang_class = class_new(gensym("initbang"), (t_newmethod)initbang_new, 0, sizeof(t_initbang), CLASS_NOINLET, 0); - class_addmethod(initbang_class, (t_method)initbang_initbang, - gensym("initbang"), 0); + class_addmethod(initbang_class, (t_method)initbang_loadbang, + gensym("loadbang"), A_DEFFLOAT, 0); class_addcreator((t_newmethod)initbang_new, gensym("iemguts/initbang"), 0); } @@ -177,9 +176,10 @@ static void *closebang_new(void) outlet_new(&x->x_obj, &s_bang); return (x); } -static void closebang_closebang(t_closebang *x) + +static void closebang_loadbang(t_closebang *x, t_float type) { - if (!sys_noloadbang) /* JMZ: hmm, not sure whether we should respect sys_noloadbang here... */ + if (LB_CLOSE == (int)type) outlet_bang(x->x_obj.ob_outlet); } @@ -188,8 +188,8 @@ static void closebang_setup(void) closebang_class = class_new(gensym("closebang"), (t_newmethod)closebang_new, 0, sizeof(t_closebang), CLASS_NOINLET, 0); - class_addmethod(closebang_class, (t_method)closebang_closebang, - gensym("closebang"), 0); + class_addmethod(closebang_class, (t_method)closebang_loadbang, + gensym("loadbang"), A_DEFFLOAT, 0); class_addcreator((t_newmethod)closebang_new, gensym("iemguts/closebang"), 0); }