From 398b2a07aa0d24600fa6b25a57ac7277af315b6e Mon Sep 17 00:00:00 2001 From: Jonathan Wilkes <jon.w.wilkes@gmail.com> Date: Wed, 22 Jul 2020 14:49:04 -0400 Subject: [PATCH] add bang methods to [scalar] and [array] --- pd/src/x_array.c | 19 ++++++++++++++++++- pd/src/x_scalar.c | 14 ++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/pd/src/x_array.c b/pd/src/x_array.c index 67471549d..5457bcb58 100644 --- a/pd/src/x_array.c +++ b/pd/src/x_array.c @@ -227,7 +227,23 @@ static void array_define_send(t_glist *x, t_symbol *s) pd_pointer(s->s_thing, &gp); gpointer_unset(&gp); } - else bug("array_define_anything"); + else bug("array_define_send"); +} + +static void array_define_bang(t_glist *x) +{ + t_glist *gl = (x->gl_list ? pd_checkglist(&x->gl_list->g_pd) : 0); + if (gl && gl->gl_list && pd_class(&gl->gl_list->g_pd) == garray_class) + { + t_gpointer gp; + gpointer_init(&gp); + gpointer_setglist(&gp, gl, + //garray_getscalar((t_garray *)gl->gl_list)); + (t_gobj *)gl->gl_list); + outlet_pointer(x->gl_obj.ob_outlet, &gp); + gpointer_unset(&gp); + } + else bug("array_define_bang"); } /* just forward any messages to the garray */ @@ -864,6 +880,7 @@ void x_array_setup(void ) canvas_add_for_class(array_define_class); class_addmethod(array_define_class, (t_method)array_define_send, gensym("send"), A_SYMBOL, 0); + class_addbang(array_define_class, array_define_bang); class_addanything(array_define_class, array_define_anything); class_sethelpsymbol(array_define_class, gensym("array-object")); class_setsavefn(array_define_class, array_define_save); diff --git a/pd/src/x_scalar.c b/pd/src/x_scalar.c index 61a6cf1f4..95187b700 100644 --- a/pd/src/x_scalar.c +++ b/pd/src/x_scalar.c @@ -111,6 +111,19 @@ static void scalar_define_send(t_glist *x, t_symbol *s) else bug("scalar_define_send"); } +static void scalar_define_bang(t_glist *x) +{ + if (x->gl_list && pd_class(&x->gl_list->g_pd) == scalar_class) + { + t_gpointer gp; + gpointer_init(&gp); + gpointer_setglist(&gp, x, (t_gobj *)&x->gl_list->g_pd); + outlet_pointer(x->gl_obj.ob_outlet, &gp); + gpointer_unset(&gp); + } + else bug("scalar_define_bang"); +} + /* set to a list, used to restore from scalar_define_save()s below */ static void scalar_define_set(t_glist *x, t_symbol *s, int argc, t_atom *argv) { @@ -180,6 +193,7 @@ void x_scalar_setup(void ) canvas_add_for_class(scalar_define_class); class_addmethod(scalar_define_class, (t_method)scalar_define_send, gensym("send"), A_SYMBOL, 0); + class_addbang(scalar_define_class, (t_method)scalar_define_bang); class_addmethod(scalar_define_class, (t_method)scalar_define_set, gensym("set"), A_GIMME, 0); class_sethelpsymbol(scalar_define_class, gensym("scalar-object")); -- GitLab