From 49a66be1d377dee6b89abff0b8160b6ab96e8bc3 Mon Sep 17 00:00:00 2001 From: Jonathan Wilkes <jon.w.wilkes@gmail.com> Date: Fri, 21 Jul 2017 19:53:12 -0400 Subject: [PATCH] force all iemlib classes to create without args --- externals/iemlib/iemlib2/src/iem_i_route.c | 49 ++++++++++--------- .../iemlib/iemlib2/src/parentdollarzero.c | 1 - externals/iemlib/iemlib2/src/prepend_ascii.c | 37 +++++++------- externals/iemlib/iemlib2/src/toggle_mess.c | 9 ++-- 4 files changed, 51 insertions(+), 45 deletions(-) diff --git a/externals/iemlib/iemlib2/src/iem_i_route.c b/externals/iemlib/iemlib2/src/iem_i_route.c index ca4ed71ea..938dc6a0f 100644 --- a/externals/iemlib/iemlib2/src/iem_i_route.c +++ b/externals/iemlib/iemlib2/src/iem_i_route.c @@ -68,38 +68,41 @@ static void iem_i_route_free(t_iem_i_route *x) static void *iem_i_route_new(t_symbol *s, int argc, t_atom *argv) { - int n, i; + int n, i, first, last, off; t_outlet **out; t_iem_i_route *x = (t_iem_i_route *)pd_new(iem_i_route_class); - - if((argc >= 2)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1)) + + if (argc) first = atom_getintarg(0, argc--, argv++); else first = 0; + if (argc) last = atom_getintarg(0, argc--, argv++); else last = 0; + if (argc) off = atom_getintarg(0, argc--, argv++); else off = 0; + + if (first > last) { - x->x_first_element = (int)atom_getintarg(0, argc, argv); - x->x_last_element = (int)atom_getintarg(1, argc, argv); - if((argc >= 3)&&IS_A_FLOAT(argv,2)) - { - i = (int)atom_getintarg(2, argc, argv); - x->x_first_element += i; - x->x_last_element += i; - } - x->x_out = (t_outlet **)getbytes((x->x_last_element-x->x_first_element+2) * sizeof(t_outlet *)); - n = x->x_last_element - x->x_first_element + 2; - for(i=0, out=x->x_out; i<n; i++, out++) - *out = outlet_new(&x->x_obj, &s_list); - return (x); + post("iem_i_route: warning: illegal range bashed to 0"); + first = last; } - else + if (last - first + 1 > 100) { - post("iem_i_route-ERROR: needs 3 floats!!"); - return(0); + post("iem_i_route: warning: only 100 outlets allowed. Setting last " + "match value to %d", (int)(first + 98)); + last = first + 98; } + x->x_first_element = first + off; + x->x_last_element = last + off; + x->x_out = (t_outlet **)getbytes((x->x_last_element-x->x_first_element+2) * sizeof(t_outlet *)); + n = x->x_last_element - x->x_first_element + 2; + for(i=0, out=x->x_out; i<n; i++, out++) + *out = outlet_new(&x->x_obj, &s_list); + return (x); } void iem_i_route_setup(void) { - iem_i_route_class = class_new(gensym("iem_i_route"), (t_newmethod)iem_i_route_new, - (t_method)iem_i_route_free, sizeof(t_iem_i_route), 0, A_GIMME, 0); - class_addcreator((t_newmethod)iem_i_route_new, gensym("iiroute"), A_GIMME, 0); + iem_i_route_class = class_new(gensym("iem_i_route"), + (t_newmethod)iem_i_route_new, (t_method)iem_i_route_free, + sizeof(t_iem_i_route), 0, A_GIMME, 0); + class_addcreator((t_newmethod)iem_i_route_new, gensym("iiroute"), + A_GIMME, 0); class_addlist(iem_i_route_class, iem_i_route_list); -// class_sethelpsymbol(iem_i_route_class, gensym("iemhelp/help-iem_i_route")); + //class_sethelpsymbol(iem_i_route_class, gensym("iemhelp/help-iem_i_route")); } diff --git a/externals/iemlib/iemlib2/src/parentdollarzero.c b/externals/iemlib/iemlib2/src/parentdollarzero.c index 3f209b11d..8e7b65899 100644 --- a/externals/iemlib/iemlib2/src/parentdollarzero.c +++ b/externals/iemlib/iemlib2/src/parentdollarzero.c @@ -54,7 +54,6 @@ void parentdollarzero_setup(void) { parentdollarzero_class = class_new(gensym("parentdollarzero"), (t_newmethod)parentdollarzero_new, 0, sizeof(t_parentdollarzero), 0, 0); - class_addcreator((t_newmethod)parentdollarzero_new, gensym("parent$0"), 0); class_addbang(parentdollarzero_class, (t_method)parentdollarzero_bang); // class_sethelpsymbol(parentdollarzero_class, gensym("iemhelp/help-parentdollarzero")); } diff --git a/externals/iemlib/iemlib2/src/prepend_ascii.c b/externals/iemlib/iemlib2/src/prepend_ascii.c index 5c5d647ed..5f9a34466 100644 --- a/externals/iemlib/iemlib2/src/prepend_ascii.c +++ b/externals/iemlib/iemlib2/src/prepend_ascii.c @@ -83,28 +83,29 @@ static void prepend_ascii_free(t_prepend_ascii *x) static void *prepend_ascii_new(t_symbol *s, int ac, t_atom *av) { + t_atom dummy; if((ac <= 0) || (!IS_A_FLOAT(av,0))) { - post("ERROR: prepend_ascii need a float between 1 and 255 as 1. arg. !!!"); - return(0); + post("WARNING: prepend_ascii need a float between 1 and 255 as " + "the 1st arg. Defaulting to 97 (a)"); + SETFLOAT(&dummy, 97.); + av = &dummy; + ac = 1; } - else - { - t_prepend_ascii *x = (t_prepend_ascii *)pd_new(prepend_ascii_class); - char str[2]; - int i; + t_prepend_ascii *x = (t_prepend_ascii *)pd_new(prepend_ascii_class); + char str[2]; + int i; - x->x_size = 10 + ac; - x->x_at = (t_atom *)getbytes(x->x_size * sizeof(t_atom)); - str[0] = (char)((int)(atom_getfloatarg(0,ac,av))&0xff); - str[1] = 0; - x->x_sym = gensym(str); - x->x_ac = ac - 1; - for(i=1; i<ac; i++) - x->x_at[i-1] = av[i]; - outlet_new(&x->x_obj, &s_list); - return (x); - } + x->x_size = 10 + ac; + x->x_at = (t_atom *)getbytes(x->x_size * sizeof(t_atom)); + str[0] = (char)((int)(atom_getfloatarg(0,ac,av))&0xff); + str[1] = 0; + x->x_sym = gensym(str); + x->x_ac = ac - 1; + for(i=1; i<ac; i++) + x->x_at[i-1] = av[i]; + outlet_new(&x->x_obj, &s_list); + return (x); } void prepend_ascii_setup(void) diff --git a/externals/iemlib/iemlib2/src/toggle_mess.c b/externals/iemlib/iemlib2/src/toggle_mess.c index b6ffb95a7..06c0f3e64 100644 --- a/externals/iemlib/iemlib2/src/toggle_mess.c +++ b/externals/iemlib/iemlib2/src/toggle_mess.c @@ -79,14 +79,17 @@ static void toggle_mess_free(t_toggle_mess *x) static void *toggle_mess_new(t_symbol *s, int ac, t_atom *av) { + t_atom dummy; t_toggle_mess *x = (t_toggle_mess *)pd_new(toggle_mess_class); int i; if(!ac) { - post("toggle_mess-ERROR: must have at least one argument!"); - x->x_at = (t_atom *)0; - return(0); + post("toggle_mess-WARNING: no arguments given. Defaulting to 0."); + //x->x_at = (t_atom *)0; + SETFLOAT(&dummy, 0.); + av = &dummy; + ac = 1; } x->x_ac = ac; x->x_at = (t_atom *)getbytes(ac * sizeof(t_atom)); -- GitLab