Skip to content
Snippets Groups Projects
Commit 49a66be1 authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

force all iemlib classes to create without args

parent dbb1f218
No related branches found
No related tags found
No related merge requests found
......@@ -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"));
}
......@@ -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"));
}
......@@ -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)
......
......@@ -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));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment