From ed932acb5860bf8b9296169676499562a55d139e Mon Sep 17 00:00:00 2001 From: Miller Puckette Date: Mon, 6 Sep 2004 20:20:36 +0000 Subject: checking in version 0.38test5. Oops, I realize I forgot some more nice files, will add them and re-commit. svn path=/trunk/; revision=2010 --- pd/src/x_connective.c | 626 +++++++++++++++++++++++++------------------------- 1 file changed, 313 insertions(+), 313 deletions(-) (limited to 'pd/src/x_connective.c') diff --git a/pd/src/x_connective.c b/pd/src/x_connective.c index f5173d6e..4dfacb90 100644 --- a/pd/src/x_connective.c +++ b/pd/src/x_connective.c @@ -41,7 +41,7 @@ static void pdint_float(t_pdint *x, t_float f) void pdint_setup(void) { pdint_class = class_new(gensym("int"), (t_newmethod)pdint_new, 0, - sizeof(t_pdint), 0, A_DEFFLOAT, 0); + sizeof(t_pdint), 0, A_DEFFLOAT, 0); class_addcreator((t_newmethod)pdint_new, gensym("i"), A_DEFFLOAT, 0); class_addbang(pdint_class, pdint_bang); class_addfloat(pdint_class, pdint_float); @@ -88,7 +88,7 @@ static void pdfloat_float(t_pdfloat *x, t_float f) void pdfloat_setup(void) { pdfloat_class = class_new(gensym("float"), (t_newmethod)pdfloat_new, 0, - sizeof(t_pdfloat), 0, A_FLOAT, 0); + sizeof(t_pdfloat), 0, A_FLOAT, 0); class_addcreator((t_newmethod)pdfloat_new2, gensym("f"), A_DEFFLOAT, 0); class_addbang(pdfloat_class, pdfloat_bang); class_addfloat(pdfloat_class, (t_method)pdfloat_float); @@ -138,16 +138,16 @@ static void pdsymbol_anything(t_pdsymbol *x, t_symbol *s, int ac, t_atom *av) static void pdsymbol_list(t_pdsymbol *x, t_symbol *s, int ac, t_atom *av) { if (!ac) - pdsymbol_bang(x); + pdsymbol_bang(x); else if (av->a_type == A_SYMBOL) - pdsymbol_symbol(x, av->a_w.w_symbol); + pdsymbol_symbol(x, av->a_w.w_symbol); else pdsymbol_anything(x, s, ac, av); } void pdsymbol_setup(void) { pdsymbol_class = class_new(gensym("symbol"), (t_newmethod)pdsymbol_new, 0, - sizeof(t_pdsymbol), 0, A_SYMBOL, 0); + sizeof(t_pdsymbol), 0, A_SYMBOL, 0); class_addbang(pdsymbol_class, pdsymbol_bang); class_addsymbol(pdsymbol_class, pdsymbol_symbol); class_addanything(pdsymbol_class, pdsymbol_anything); @@ -182,7 +182,7 @@ static void bang_bang(t_bang *x) void bang_setup(void) { bang_class = class_new(gensym("bang"), (t_newmethod)bang_new, 0, - sizeof(t_bang), 0, 0); + sizeof(t_bang), 0, 0); class_addcreator((t_newmethod)bang_new2, gensym("b"), 0); class_addbang(bang_class, bang_bang); class_addfloat(bang_class, bang_bang); @@ -241,7 +241,7 @@ static void *send_new(t_symbol *s) static void send_setup(void) { send_class = class_new(gensym("send"), (t_newmethod)send_new, 0, - sizeof(t_send), 0, A_DEFSYM, 0); + sizeof(t_send), 0, A_DEFSYM, 0); class_addcreator((t_newmethod)send_new, gensym("s"), A_DEFSYM, 0); class_addbang(send_class, send_bang); class_addfloat(send_class, send_float); @@ -307,7 +307,7 @@ static void receive_free(t_receive *x) static void receive_setup(void) { receive_class = class_new(gensym("receive"), (t_newmethod)receive_new, - (t_method)receive_free, sizeof(t_receive), CLASS_NOINLET, A_DEFSYM, 0); + (t_method)receive_free, sizeof(t_receive), CLASS_NOINLET, A_DEFSYM, 0); class_addcreator((t_newmethod)receive_new, gensym("r"), A_DEFSYM, 0); class_addbang(receive_class, receive_bang); class_addfloat(receive_class, (t_method)receive_float); @@ -332,14 +332,14 @@ typedef struct _sel1 static void sel1_float(t_sel1 *x, t_float f) { if (x->x_atom.a_type == A_FLOAT && f == x->x_atom.a_w.w_float) - outlet_bang(x->x_outlet1); + outlet_bang(x->x_outlet1); else outlet_float(x->x_outlet2, f); } static void sel1_symbol(t_sel1 *x, t_symbol *s) { if (x->x_atom.a_type == A_SYMBOL && s == x->x_atom.a_w.w_symbol) - outlet_bang(x->x_outlet1); + outlet_bang(x->x_outlet1); else outlet_symbol(x->x_outlet2, s); } @@ -366,12 +366,12 @@ static void sel2_float(t_sel2 *x, t_float f) int nelement; if (x->x_type == A_FLOAT) { - for (nelement = x->x_nelement, e = x->x_vec; nelement--; e++) - if (e->e_w.w_float == f) - { - outlet_bang(e->e_outlet); - return; - } + for (nelement = x->x_nelement, e = x->x_vec; nelement--; e++) + if (e->e_w.w_float == f) + { + outlet_bang(e->e_outlet); + return; + } } outlet_float(x->x_rejectout, f); } @@ -382,12 +382,12 @@ static void sel2_symbol(t_sel2 *x, t_symbol *s) int nelement; if (x->x_type == A_SYMBOL) { - for (nelement = x->x_nelement, e = x->x_vec; nelement--; e++) - if (e->e_w.w_symbol == s) - { - outlet_bang(e->e_outlet); - return; - } + for (nelement = x->x_nelement, e = x->x_vec; nelement--; e++) + if (e->e_w.w_symbol == s) + { + outlet_bang(e->e_outlet); + return; + } } outlet_symbol(x->x_rejectout, s); } @@ -402,44 +402,44 @@ static void *select_new(t_symbol *s, int argc, t_atom *argv) t_atom a; if (argc == 0) { - argc = 1; - SETFLOAT(&a, 0); - argv = &a; + argc = 1; + SETFLOAT(&a, 0); + argv = &a; } if (argc == 1) { - t_sel1 *x = (t_sel1 *)pd_new(sel1_class); - x->x_atom = *argv; - x->x_outlet1 = outlet_new(&x->x_obj, &s_bang); - if (argv->a_type == A_FLOAT) - { - floatinlet_new(&x->x_obj, &x->x_atom.a_w.w_float); - x->x_outlet2 = outlet_new(&x->x_obj, &s_float); - } - else - { - symbolinlet_new(&x->x_obj, &x->x_atom.a_w.w_symbol); - x->x_outlet2 = outlet_new(&x->x_obj, &s_symbol); - } - return (x); + t_sel1 *x = (t_sel1 *)pd_new(sel1_class); + x->x_atom = *argv; + x->x_outlet1 = outlet_new(&x->x_obj, &s_bang); + if (argv->a_type == A_FLOAT) + { + floatinlet_new(&x->x_obj, &x->x_atom.a_w.w_float); + x->x_outlet2 = outlet_new(&x->x_obj, &s_float); + } + else + { + symbolinlet_new(&x->x_obj, &x->x_atom.a_w.w_symbol); + x->x_outlet2 = outlet_new(&x->x_obj, &s_symbol); + } + return (x); } else { - int n; - t_selectelement *e; - t_sel2 *x = (t_sel2 *)pd_new(sel2_class); - x->x_nelement = argc; - x->x_vec = (t_selectelement *)getbytes(argc * sizeof(*x->x_vec)); - x->x_type = argv[0].a_type; - for (n = 0, e = x->x_vec; n < argc; n++, e++) - { - e->e_outlet = outlet_new(&x->x_obj, &s_bang); - if ((x->x_type = argv->a_type) == A_FLOAT) - e->e_w.w_float = atom_getfloatarg(n, argc, argv); - else e->e_w.w_symbol = atom_getsymbolarg(n, argc, argv); - } - x->x_rejectout = outlet_new(&x->x_obj, &s_float); - return (x); + int n; + t_selectelement *e; + t_sel2 *x = (t_sel2 *)pd_new(sel2_class); + x->x_nelement = argc; + x->x_vec = (t_selectelement *)getbytes(argc * sizeof(*x->x_vec)); + x->x_type = argv[0].a_type; + for (n = 0, e = x->x_vec; n < argc; n++, e++) + { + e->e_outlet = outlet_new(&x->x_obj, &s_bang); + if ((x->x_type = argv->a_type) == A_FLOAT) + e->e_w.w_float = atom_getfloatarg(n, argc, argv); + else e->e_w.w_symbol = atom_getsymbolarg(n, argc, argv); + } + x->x_rejectout = outlet_new(&x->x_obj, &s_float); + return (x); } } @@ -447,12 +447,12 @@ static void *select_new(t_symbol *s, int argc, t_atom *argv) void select_setup(void) { sel1_class = class_new(gensym("select"), 0, 0, - sizeof(t_sel1), 0, 0); + sizeof(t_sel1), 0, 0); class_addfloat(sel1_class, sel1_float); class_addsymbol(sel1_class, sel1_symbol); sel2_class = class_new(gensym("select"), 0, (t_method)sel2_free, - sizeof(t_sel2), 0, 0); + sizeof(t_sel2), 0, 0); class_addfloat(sel2_class, sel2_float); class_addsymbol(sel2_class, sel2_symbol); @@ -485,15 +485,15 @@ static void route_anything(t_route *x, t_symbol *sel, int argc, t_atom *argv) int nelement; if (x->x_type == A_SYMBOL) { - for (nelement = x->x_nelement, e = x->x_vec; nelement--; e++) - if (e->e_w.w_symbol == sel) - { - if (argc > 0 && argv[0].a_type == A_SYMBOL) - outlet_anything(e->e_outlet, argv[0].a_w.w_symbol, - argc-1, argv+1); - else outlet_list(e->e_outlet, 0, argc, argv); - return; - } + for (nelement = x->x_nelement, e = x->x_vec; nelement--; e++) + if (e->e_w.w_symbol == sel) + { + if (argc > 0 && argv[0].a_type == A_SYMBOL) + outlet_anything(e->e_outlet, argv[0].a_w.w_symbol, + argc-1, argv+1); + else outlet_list(e->e_outlet, 0, argc, argv); + return; + } } outlet_anything(x->x_rejectout, sel, argc, argv); } @@ -504,68 +504,68 @@ static void route_list(t_route *x, t_symbol *sel, int argc, t_atom *argv) int nelement; if (x->x_type == A_FLOAT) { - float f; - if (!argc) return; - f = atom_getfloat(argv); - for (nelement = x->x_nelement, e = x->x_vec; nelement--; e++) - if (e->e_w.w_float == f) - { - if (argc > 1 && argv[1].a_type == A_SYMBOL) - outlet_anything(e->e_outlet, argv[1].a_w.w_symbol, - argc-2, argv+2); - else outlet_list(e->e_outlet, 0, argc-1, argv+1); - return; - } + float f; + if (!argc) return; + f = atom_getfloat(argv); + for (nelement = x->x_nelement, e = x->x_vec; nelement--; e++) + if (e->e_w.w_float == f) + { + if (argc > 1 && argv[1].a_type == A_SYMBOL) + outlet_anything(e->e_outlet, argv[1].a_w.w_symbol, + argc-2, argv+2); + else outlet_list(e->e_outlet, 0, argc-1, argv+1); + return; + } } else /* symbol arguments */ { - if (argc > 1) /* 2 or more args: treat as "list" */ - { - for (nelement = x->x_nelement, e = x->x_vec; nelement--; e++) - { - if (e->e_w.w_symbol == &s_list) - { - if (argc > 0 && argv[0].a_type == A_SYMBOL) - outlet_anything(e->e_outlet, argv[0].a_w.w_symbol, - argc-1, argv+1); - else outlet_list(e->e_outlet, 0, argc, argv); - return; - } - } - } - else if (argc == 0) /* no args: treat as "bang" */ - { - for (nelement = x->x_nelement, e = x->x_vec; nelement--; e++) - { - if (e->e_w.w_symbol == &s_bang) - { - outlet_bang(e->e_outlet); - return; - } - } - } - else if (argv[0].a_type == A_FLOAT) /* one float arg */ - { - for (nelement = x->x_nelement, e = x->x_vec; nelement--; e++) - { - if (e->e_w.w_symbol == &s_float) - { - outlet_float(e->e_outlet, argv[0].a_w.w_float); - return; - } - } - } - else - { - for (nelement = x->x_nelement, e = x->x_vec; nelement--; e++) - { - if (e->e_w.w_symbol == &s_symbol) - { - outlet_symbol(e->e_outlet, argv[0].a_w.w_symbol); - return; - } - } - } + if (argc > 1) /* 2 or more args: treat as "list" */ + { + for (nelement = x->x_nelement, e = x->x_vec; nelement--; e++) + { + if (e->e_w.w_symbol == &s_list) + { + if (argc > 0 && argv[0].a_type == A_SYMBOL) + outlet_anything(e->e_outlet, argv[0].a_w.w_symbol, + argc-1, argv+1); + else outlet_list(e->e_outlet, 0, argc, argv); + return; + } + } + } + else if (argc == 0) /* no args: treat as "bang" */ + { + for (nelement = x->x_nelement, e = x->x_vec; nelement--; e++) + { + if (e->e_w.w_symbol == &s_bang) + { + outlet_bang(e->e_outlet); + return; + } + } + } + else if (argv[0].a_type == A_FLOAT) /* one float arg */ + { + for (nelement = x->x_nelement, e = x->x_vec; nelement--; e++) + { + if (e->e_w.w_symbol == &s_float) + { + outlet_float(e->e_outlet, argv[0].a_w.w_float); + return; + } + } + } + else + { + for (nelement = x->x_nelement, e = x->x_vec; nelement--; e++) + { + if (e->e_w.w_symbol == &s_symbol) + { + outlet_symbol(e->e_outlet, argv[0].a_w.w_symbol); + return; + } + } + } } outlet_list(x->x_rejectout, 0, argc, argv); } @@ -584,19 +584,19 @@ static void *route_new(t_symbol *s, int argc, t_atom *argv) t_atom a; if (argc == 0) { - argc = 1; - SETFLOAT(&a, 0); - argv = &a; + argc = 1; + SETFLOAT(&a, 0); + argv = &a; } x->x_type = argv[0].a_type; x->x_nelement = argc; x->x_vec = (t_routeelement *)getbytes(argc * sizeof(*x->x_vec)); for (n = 0, e = x->x_vec; n < argc; n++, e++) { - e->e_outlet = outlet_new(&x->x_obj, &s_list); - if (x->x_type == A_FLOAT) - e->e_w.w_float = atom_getfloatarg(n, argc, argv); - else e->e_w.w_symbol = atom_getsymbolarg(n, argc, argv); + e->e_outlet = outlet_new(&x->x_obj, &s_list); + if (x->x_type == A_FLOAT) + e->e_w.w_float = atom_getfloatarg(n, argc, argv); + else e->e_w.w_symbol = atom_getsymbolarg(n, argc, argv); } x->x_rejectout = outlet_new(&x->x_obj, &s_list); return (x); @@ -605,7 +605,7 @@ static void *route_new(t_symbol *s, int argc, t_atom *argv) void route_setup(void) { route_class = class_new(gensym("route"), (t_newmethod)route_new, - (t_method)route_free, sizeof(t_route), 0, A_GIMME, 0); + (t_method)route_free, sizeof(t_route), 0, A_GIMME, 0); class_addlist(route_class, route_list); class_addanything(route_class, route_anything); } @@ -617,11 +617,11 @@ static t_class *pack_class; typedef struct _pack { t_object x_obj; - t_int x_n; /* number of args */ - t_atom *x_vec; /* input values */ - t_int x_nptr; /* number of pointers */ + t_int x_n; /* number of args */ + t_atom *x_vec; /* input values */ + t_int x_nptr; /* number of pointers */ t_gpointer *x_gpointer; /* the pointers */ - t_atom *x_outvec; /* space for output values */ + t_atom *x_outvec; /* space for output values */ } t_pack; static void *pack_new(t_symbol *s, int argc, t_atom *argv) @@ -633,10 +633,10 @@ static void *pack_new(t_symbol *s, int argc, t_atom *argv) int i; if (!argc) { - argv = defarg; - argc = 2; - SETFLOAT(&defarg[0], 0); - SETFLOAT(&defarg[1], 0); + argv = defarg; + argc = 2; + SETFLOAT(&defarg[0], 0); + SETFLOAT(&defarg[1], 0); } x->x_n = argc; @@ -644,43 +644,43 @@ static void *pack_new(t_symbol *s, int argc, t_atom *argv) x->x_outvec = (t_atom *)getbytes(argc * sizeof(*x->x_outvec)); for (i = argc, ap = argv; i--; ap++) - if (ap->a_type == A_SYMBOL && *ap->a_w.w_symbol->s_name == 'p') - nptr++; + if (ap->a_type == A_SYMBOL && *ap->a_w.w_symbol->s_name == 'p') + nptr++; gp = x->x_gpointer = (t_gpointer *)t_getbytes(nptr * sizeof (*gp)); x->x_nptr = nptr; for (i = 0, vp = x->x_vec, ap = argv; i < argc; i++, ap++, vp++) { - if (ap->a_type == A_FLOAT) - { - *vp = *ap; - if (i) floatinlet_new(&x->x_obj, &vp->a_w.w_float); - } - else if (ap->a_type == A_SYMBOL) - { - char c = *ap->a_w.w_symbol->s_name; - if (c == 's') - { - SETSYMBOL(vp, &s_symbol); - if (i) symbolinlet_new(&x->x_obj, &vp->a_w.w_symbol); - } - else if (c == 'p') - { - vp->a_type = A_POINTER; - vp->a_w.w_gpointer = gp; - gpointer_init(gp); - if (i) pointerinlet_new(&x->x_obj, gp); - gp++; - } - else - { - if (c != 'f') pd_error(x, "pack: %s: bad type", - ap->a_w.w_symbol->s_name); - SETFLOAT(vp, 0); - if (i) floatinlet_new(&x->x_obj, &vp->a_w.w_float); - } - } + if (ap->a_type == A_FLOAT) + { + *vp = *ap; + if (i) floatinlet_new(&x->x_obj, &vp->a_w.w_float); + } + else if (ap->a_type == A_SYMBOL) + { + char c = *ap->a_w.w_symbol->s_name; + if (c == 's') + { + SETSYMBOL(vp, &s_symbol); + if (i) symbolinlet_new(&x->x_obj, &vp->a_w.w_symbol); + } + else if (c == 'p') + { + vp->a_type = A_POINTER; + vp->a_w.w_gpointer = gp; + gpointer_init(gp); + if (i) pointerinlet_new(&x->x_obj, gp); + gp++; + } + else + { + if (c != 'f') pd_error(x, "pack: %s: bad type", + ap->a_w.w_symbol->s_name); + SETFLOAT(vp, 0); + if (i) floatinlet_new(&x->x_obj, &vp->a_w.w_float); + } + } } outlet_new(&x->x_obj, &s_list); return (x); @@ -692,30 +692,30 @@ static void pack_bang(t_pack *x) t_gpointer *gp; t_atom *outvec; for (i = x->x_nptr, gp = x->x_gpointer; i--; gp++) - if (!gpointer_check(gp, 1)) + if (!gpointer_check(gp, 1)) { - pd_error(x, "pack: stale pointer"); - return; + pd_error(x, "pack: stale pointer"); + return; } - /* reentrancy protection. The first time through use the pre-allocated - x_outvec; if we're reentered we have to allocate new memory. */ + /* reentrancy protection. The first time through use the pre-allocated + x_outvec; if we're reentered we have to allocate new memory. */ if (!x->x_outvec) { - /* LATER figure out how to deal with reentrancy and pointers... */ - if (x->x_nptr) - post("pack_bang: warning: reentry with pointers unprotected"); - outvec = t_getbytes(size); - reentered = 1; + /* LATER figure out how to deal with reentrancy and pointers... */ + if (x->x_nptr) + post("pack_bang: warning: reentry with pointers unprotected"); + outvec = t_getbytes(size); + reentered = 1; } else { - outvec = x->x_outvec; - x->x_outvec = 0; + outvec = x->x_outvec; + x->x_outvec = 0; } memcpy(outvec, x->x_vec, size); outlet_list(x->x_obj.ob_outlet, &s_list, x->x_n, outvec); if (reentered) - t_freebytes(outvec, size); + t_freebytes(outvec, size); else x->x_outvec = outvec; } @@ -723,10 +723,10 @@ static void pack_pointer(t_pack *x, t_gpointer *gp) { if (x->x_vec->a_type == A_POINTER) { - gpointer_unset(x->x_gpointer); - *x->x_gpointer = *gp; - if (gp->gp_stub) gp->gp_stub->gs_refcount++; - pack_bang(x); + gpointer_unset(x->x_gpointer); + *x->x_gpointer = *gp; + if (gp->gp_stub) gp->gp_stub->gs_refcount++; + pack_bang(x); } else pd_error(x, "pack_pointer: wrong type"); } @@ -735,8 +735,8 @@ static void pack_float(t_pack *x, t_float f) { if (x->x_vec->a_type == A_FLOAT) { - x->x_vec->a_w.w_float = f; - pack_bang(x); + x->x_vec->a_w.w_float = f; + pack_bang(x); } else pd_error(x, "pack_float: wrong type"); } @@ -745,8 +745,8 @@ static void pack_symbol(t_pack *x, t_symbol *s) { if (x->x_vec->a_type == A_SYMBOL) { - x->x_vec->a_w.w_symbol = s; - pack_bang(x); + x->x_vec->a_w.w_symbol = s; + pack_bang(x); } else pd_error(x, "pack_symbol: wrong type"); } @@ -761,7 +761,7 @@ static void pack_anything(t_pack *x, t_symbol *s, int ac, t_atom *av) t_atom *av2 = (t_atom *)getbytes((ac + 1) * sizeof(t_atom)); int i; for (i = 0; i < ac; i++) - av2[i + 1] = av[i]; + av2[i + 1] = av[i]; SETSYMBOL(av2, s); obj_list(&x->x_obj, 0, ac+1, av2); freebytes(av2, (ac + 1) * sizeof(t_atom)); @@ -772,7 +772,7 @@ static void pack_free(t_pack *x) t_gpointer *gp; int i; for (gp = x->x_gpointer, i = x->x_nptr; i--; gp++) - gpointer_unset(gp); + gpointer_unset(gp); freebytes(x->x_vec, x->x_n * sizeof(*x->x_vec)); freebytes(x->x_outvec, x->x_n * sizeof(*x->x_outvec)); freebytes(x->x_gpointer, x->x_nptr * sizeof(*x->x_gpointer)); @@ -781,7 +781,7 @@ static void pack_free(t_pack *x) static void pack_setup(void) { pack_class = class_new(gensym("pack"), (t_newmethod)pack_new, - (t_method)pack_free, sizeof(t_pack), 0, A_GIMME, 0); + (t_method)pack_free, sizeof(t_pack), 0, A_GIMME, 0); class_addbang(pack_class, pack_bang); class_addpointer(pack_class, pack_pointer); class_addfloat(pack_class, pack_float); @@ -815,42 +815,42 @@ static void *unpack_new(t_symbol *s, int argc, t_atom *argv) int i; if (!argc) { - argv = defarg; - argc = 2; - SETFLOAT(&defarg[0], 0); - SETFLOAT(&defarg[1], 0); + argv = defarg; + argc = 2; + SETFLOAT(&defarg[0], 0); + SETFLOAT(&defarg[1], 0); } x->x_n = argc; x->x_vec = (t_unpackout *)getbytes(argc * sizeof(*x->x_vec)); for (i = 0, ap = argv, u = x->x_vec; i < argc; u++, ap++, i++) { - t_atomtype type = ap->a_type; - if (type == A_SYMBOL) - { - char c = *ap->a_w.w_symbol->s_name; - if (c == 's') - { - u->u_type = A_SYMBOL; - u->u_outlet = outlet_new(&x->x_obj, &s_symbol); - } - else if (c == 'p') - { - u->u_type = A_POINTER; - u->u_outlet = outlet_new(&x->x_obj, &s_pointer); - } - else - { - if (c != 'f') pd_error(x, "unpack: %s: bad type", - ap->a_w.w_symbol->s_name); - u->u_type = A_FLOAT; - u->u_outlet = outlet_new(&x->x_obj, &s_float); - } - } - else - { - u->u_type = A_FLOAT; - u->u_outlet = outlet_new(&x->x_obj, &s_float); - } + t_atomtype type = ap->a_type; + if (type == A_SYMBOL) + { + char c = *ap->a_w.w_symbol->s_name; + if (c == 's') + { + u->u_type = A_SYMBOL; + u->u_outlet = outlet_new(&x->x_obj, &s_symbol); + } + else if (c == 'p') + { + u->u_type = A_POINTER; + u->u_outlet = outlet_new(&x->x_obj, &s_pointer); + } + else + { + if (c != 'f') pd_error(x, "unpack: %s: bad type", + ap->a_w.w_symbol->s_name); + u->u_type = A_FLOAT; + u->u_outlet = outlet_new(&x->x_obj, &s_float); + } + } + else + { + u->u_type = A_FLOAT; + u->u_outlet = outlet_new(&x->x_obj, &s_float); + } } return (x); } @@ -863,14 +863,14 @@ static void unpack_list(t_unpack *x, t_symbol *s, int argc, t_atom *argv) if (argc > x->x_n) argc = x->x_n; for (i = argc, u = x->x_vec + i, ap = argv + i; u--, ap--, i--;) { - t_atomtype type = u->u_type; - if (type != ap->a_type) - pd_error(x, "unpack: type mismatch"); - else if (type == A_FLOAT) - outlet_float(u->u_outlet, ap->a_w.w_float); - else if (type == A_SYMBOL) - outlet_symbol(u->u_outlet, ap->a_w.w_symbol); - else outlet_pointer(u->u_outlet, ap->a_w.w_gpointer); + t_atomtype type = u->u_type; + if (type != ap->a_type) + pd_error(x, "unpack: type mismatch"); + else if (type == A_FLOAT) + outlet_float(u->u_outlet, ap->a_w.w_float); + else if (type == A_SYMBOL) + outlet_symbol(u->u_outlet, ap->a_w.w_symbol); + else outlet_pointer(u->u_outlet, ap->a_w.w_gpointer); } } @@ -879,7 +879,7 @@ static void unpack_anything(t_unpack *x, t_symbol *s, int ac, t_atom *av) t_atom *av2 = (t_atom *)getbytes((ac + 1) * sizeof(t_atom)); int i; for (i = 0; i < ac; i++) - av2[i + 1] = av[i]; + av2[i + 1] = av[i]; SETSYMBOL(av2, s); unpack_list(x, 0, ac+1, av2); freebytes(av2, (ac + 1) * sizeof(t_atom)); @@ -893,7 +893,7 @@ static void unpack_free(t_unpack *x) static void unpack_setup(void) { unpack_class = class_new(gensym("unpack"), (t_newmethod)unpack_new, - (t_method)unpack_free, sizeof(t_unpack), 0, A_GIMME, 0); + (t_method)unpack_free, sizeof(t_unpack), 0, A_GIMME, 0); class_addlist(unpack_class, unpack_list); class_addanything(unpack_class, unpack_anything); } @@ -910,7 +910,7 @@ static t_class *trigger_class; typedef struct triggerout { - int u_type; /* outlet type from above */ + int u_type; /* outlet type from above */ t_outlet *u_outlet; } t_triggerout; @@ -929,40 +929,40 @@ static void *trigger_new(t_symbol *s, int argc, t_atom *argv) int i; if (!argc) { - argv = defarg; - argc = 2; - SETSYMBOL(&defarg[0], &s_bang); - SETSYMBOL(&defarg[1], &s_bang); + argv = defarg; + argc = 2; + SETSYMBOL(&defarg[0], &s_bang); + SETSYMBOL(&defarg[1], &s_bang); } x->x_n = argc; x->x_vec = (t_triggerout *)getbytes(argc * sizeof(*x->x_vec)); for (i = 0, ap = argv, u = x->x_vec; i < argc; u++, ap++, i++) { - t_atomtype thistype = ap->a_type; - char c; - if (thistype == TR_SYMBOL) c = ap->a_w.w_symbol->s_name[0]; - else if (thistype == TR_FLOAT) c = 'f'; - else c = 0; - if (c == 'p') - u->u_type = TR_POINTER, - u->u_outlet = outlet_new(&x->x_obj, &s_pointer); - else if (c == 'f') - u->u_type = TR_FLOAT, u->u_outlet = outlet_new(&x->x_obj, &s_float); - else if (c == 'b') - u->u_type = TR_BANG, u->u_outlet = outlet_new(&x->x_obj, &s_bang); - else if (c == 'l') - u->u_type = TR_LIST, u->u_outlet = outlet_new(&x->x_obj, &s_list); - else if (c == 's') - u->u_type = TR_SYMBOL, - u->u_outlet = outlet_new(&x->x_obj, &s_symbol); - else if (c == 'a') - u->u_type = TR_ANYTHING, - u->u_outlet = outlet_new(&x->x_obj, &s_symbol); - else - { - pd_error(x, "trigger: %s: bad type", ap->a_w.w_symbol->s_name); - u->u_type = TR_FLOAT, u->u_outlet = outlet_new(&x->x_obj, &s_float); - } + t_atomtype thistype = ap->a_type; + char c; + if (thistype == TR_SYMBOL) c = ap->a_w.w_symbol->s_name[0]; + else if (thistype == TR_FLOAT) c = 'f'; + else c = 0; + if (c == 'p') + u->u_type = TR_POINTER, + u->u_outlet = outlet_new(&x->x_obj, &s_pointer); + else if (c == 'f') + u->u_type = TR_FLOAT, u->u_outlet = outlet_new(&x->x_obj, &s_float); + else if (c == 'b') + u->u_type = TR_BANG, u->u_outlet = outlet_new(&x->x_obj, &s_bang); + else if (c == 'l') + u->u_type = TR_LIST, u->u_outlet = outlet_new(&x->x_obj, &s_list); + else if (c == 's') + u->u_type = TR_SYMBOL, + u->u_outlet = outlet_new(&x->x_obj, &s_symbol); + else if (c == 'a') + u->u_type = TR_ANYTHING, + u->u_outlet = outlet_new(&x->x_obj, &s_symbol); + else + { + pd_error(x, "trigger: %s: bad type", ap->a_w.w_symbol->s_name); + u->u_type = TR_FLOAT, u->u_outlet = outlet_new(&x->x_obj, &s_float); + } } return (x); } @@ -974,25 +974,25 @@ static void trigger_list(t_trigger *x, t_symbol *s, int argc, t_atom *argv) t_atom at; if (!argc) { - argc = 1; - SETFLOAT(&at, 0); - argv = &at; + argc = 1; + SETFLOAT(&at, 0); + argv = &at; } for (i = x->x_n, u = x->x_vec + i; u--, i--;) { - if (u->u_type == TR_FLOAT) - outlet_float(u->u_outlet, atom_getfloat(argv)); - else if (u->u_type == TR_BANG) - outlet_bang(u->u_outlet); - else if (u->u_type == TR_SYMBOL) - outlet_symbol(u->u_outlet, atom_getsymbol(argv)); - else if (u->u_type == TR_POINTER) - { - if (argv->a_type != TR_POINTER) - pd_error(x, "unpack: bad pointer"); - else outlet_pointer(u->u_outlet, argv->a_w.w_gpointer); - } - else outlet_list(u->u_outlet, &s_list, argc, argv); + if (u->u_type == TR_FLOAT) + outlet_float(u->u_outlet, atom_getfloat(argv)); + else if (u->u_type == TR_BANG) + outlet_bang(u->u_outlet); + else if (u->u_type == TR_SYMBOL) + outlet_symbol(u->u_outlet, atom_getsymbol(argv)); + else if (u->u_type == TR_POINTER) + { + if (argv->a_type != TR_POINTER) + pd_error(x, "unpack: bad pointer"); + else outlet_pointer(u->u_outlet, argv->a_w.w_gpointer); + } + else outlet_list(u->u_outlet, &s_list, argc, argv); } } @@ -1002,12 +1002,12 @@ static void trigger_anything(t_trigger *x, t_symbol *s, int argc, t_atom *argv) int i; for (i = x->x_n, u = x->x_vec + i; u--, i--;) { - if (u->u_type == TR_BANG) - outlet_bang(u->u_outlet); - else if (u->u_type == TR_ANYTHING) - outlet_anything(u->u_outlet, s, argc, argv); - else pd_error(x, "trigger: can only convert 's' to 'b' or 'a'", - s->s_name); + if (u->u_type == TR_BANG) + outlet_bang(u->u_outlet); + else if (u->u_type == TR_ANYTHING) + outlet_anything(u->u_outlet, s, argc, argv); + else pd_error(x, "trigger: can only convert 's' to 'b' or 'a'", + s->s_name); } } @@ -1045,7 +1045,7 @@ static void trigger_free(t_trigger *x) static void trigger_setup(void) { trigger_class = class_new(gensym("trigger"), (t_newmethod)trigger_new, - (t_method)trigger_free, sizeof(t_trigger), 0, A_GIMME, 0); + (t_method)trigger_free, sizeof(t_trigger), 0, A_GIMME, 0); class_addcreator((t_newmethod)trigger_new, gensym("t"), A_GIMME, 0); class_addlist(trigger_class, trigger_list); class_addbang(trigger_class, trigger_bang); @@ -1106,7 +1106,7 @@ static void spigot_anything(t_spigot *x, t_symbol *s, int argc, t_atom *argv) static void spigot_setup(void) { spigot_class = class_new(gensym("spigot"), (t_newmethod)spigot_new, 0, - sizeof(t_spigot), 0, A_DEFSYM, 0); + sizeof(t_spigot), 0, A_DEFSYM, 0); class_addbang(spigot_class, spigot_bang); class_addpointer(spigot_class, spigot_pointer); class_addfloat(spigot_class, spigot_float); @@ -1144,7 +1144,7 @@ static void moses_float(t_moses *x, t_float f) static void moses_setup(void) { moses_class = class_new(gensym("moses"), (t_newmethod)moses_new, 0, - sizeof(t_moses), 0, A_DEFFLOAT, 0); + sizeof(t_moses), 0, A_DEFFLOAT, 0); class_addfloat(moses_class, moses_float); } @@ -1173,7 +1173,7 @@ static void until_bang(t_until *x) x->x_run = 1; x->x_count = -1; while (x->x_run && x->x_count) - x->x_count--, outlet_bang(x->x_obj.ob_outlet); + x->x_count--, outlet_bang(x->x_obj.ob_outlet); } static void until_float(t_until *x, t_float f) @@ -1181,7 +1181,7 @@ static void until_float(t_until *x, t_float f) x->x_run = 1; x->x_count = f; while (x->x_run && x->x_count) - x->x_count--, outlet_bang(x->x_obj.ob_outlet); + x->x_count--, outlet_bang(x->x_obj.ob_outlet); } static void until_bang2(t_until *x) @@ -1192,7 +1192,7 @@ static void until_bang2(t_until *x) static void until_setup(void) { until_class = class_new(gensym("until"), (t_newmethod)until_new, 0, - sizeof(t_until), 0, 0); + sizeof(t_until), 0, 0); class_addbang(until_class, until_bang); class_addfloat(until_class, until_float); class_addmethod(until_class, (t_method)until_bang2, gensym("bang2"), 0); @@ -1240,11 +1240,11 @@ static void makefilename_setup(void) { makefilename_class = class_new(gensym("makefilename"), (t_newmethod)makefilename_new, 0, - sizeof(t_makefilename), 0, A_DEFSYM, 0); + sizeof(t_makefilename), 0, A_DEFSYM, 0); class_addfloat(makefilename_class, makefilename_float); class_addsymbol(makefilename_class, makefilename_symbol); class_addmethod(makefilename_class, (t_method)makefilename_set, - gensym("set"), A_SYMBOL, 0); + gensym("set"), A_SYMBOL, 0); } /* -------------------------- swap ------------------------------ */ @@ -1284,7 +1284,7 @@ static void swap_float(t_swap *x, t_float f) void swap_setup(void) { swap_class = class_new(gensym("swap"), (t_newmethod)swap_new, 0, - sizeof(t_swap), 0, A_DEFFLOAT, 0); + sizeof(t_swap), 0, A_DEFFLOAT, 0); class_addcreator((t_newmethod)swap_new, gensym("fswap"), A_DEFFLOAT, 0); class_addbang(swap_class, swap_bang); class_addfloat(swap_class, swap_float); @@ -1316,8 +1316,8 @@ static void change_float(t_change *x, t_float f) { if (f != x->x_f) { - x->x_f = f; - outlet_float(x->x_obj.ob_outlet, x->x_f); + x->x_f = f; + outlet_float(x->x_obj.ob_outlet, x->x_f); } } @@ -1329,11 +1329,11 @@ static void change_set(t_change *x, t_float f) void change_setup(void) { change_class = class_new(gensym("change"), (t_newmethod)change_new, 0, - sizeof(t_change), 0, A_DEFFLOAT, 0); + sizeof(t_change), 0, A_DEFFLOAT, 0); class_addbang(change_class, change_bang); class_addfloat(change_class, change_float); class_addmethod(change_class, (t_method)change_set, gensym("set"), - A_DEFFLOAT, 0); + A_DEFFLOAT, 0); } /* -------------------- value ------------------------------ */ @@ -1361,10 +1361,10 @@ t_float *value_get(t_symbol *s) t_vcommon *c = (t_vcommon *)pd_findbyclass(s, vcommon_class); if (!c) { - c = (t_vcommon *)pd_new(vcommon_class); - c->c_f = 0; - c->c_refcount = 0; - pd_bind(&c->c_pd, s); + c = (t_vcommon *)pd_new(vcommon_class); + c->c_f = 0; + c->c_refcount = 0; + pd_bind(&c->c_pd, s); } c->c_refcount++; return (&c->c_f); @@ -1377,11 +1377,11 @@ void value_release(t_symbol *s) t_vcommon *c = (t_vcommon *)pd_findbyclass(s, vcommon_class); if (c) { - if (!--c->c_refcount) - { - pd_unbind(&c->c_pd, s); - pd_free(&c->c_pd); - } + if (!--c->c_refcount) + { + pd_unbind(&c->c_pd, s); + pd_free(&c->c_pd); + } } else bug("value_release"); } @@ -1441,13 +1441,13 @@ static void value_ff(t_value *x) static void value_setup(void) { value_class = class_new(gensym("value"), (t_newmethod)value_new, - (t_method)value_ff, - sizeof(t_value), 0, A_DEFSYM, 0); + (t_method)value_ff, + sizeof(t_value), 0, A_DEFSYM, 0); class_addcreator((t_newmethod)value_new, gensym("v"), A_DEFSYM, 0); class_addbang(value_class, value_bang); class_addfloat(value_class, value_float); vcommon_class = class_new(gensym("value"), 0, 0, - sizeof(t_vcommon), CLASS_PD, 0); + sizeof(t_vcommon), CLASS_PD, 0); } /* -------------- overall setup routine for this file ----------------- */ -- cgit v1.2.1