Commit 2d701084 authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

port e814c4d586c52fe9a6a39a58947df1870e04e986 from Pd-l2ork: updated...

port e814c4d586c52fe9a6a39a58947df1870e04e986 from Pd-l2ork: updated load/init/closebang to match the new spec
parent fc9f9cfb
......@@ -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>
......
......@@ -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);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment