Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3461
Modified Files: Tag: desiredata builtins.c Log Message: [route] supports mixed floats and symbols
Index: builtins.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/builtins.c,v retrieving revision 1.1.2.39 retrieving revision 1.1.2.40 diff -C2 -d -r1.1.2.39 -r1.1.2.40 *** builtins.c 20 Jul 2007 04:11:53 -0000 1.1.2.39 --- builtins.c 20 Jul 2007 06:33:21 -0000 1.1.2.40 *************** *** 1375,1383 **** static t_class *route_class; struct t_routeelement { ! t_word e_w; t_outlet *out; }; struct t_route : t_object { - t_atomtype type; t_int n; t_routeelement *vec; --- 1375,1382 ---- static t_class *route_class; struct t_routeelement { ! t_atom a; t_outlet *out; }; struct t_route : t_object { t_int n; t_routeelement *vec; *************** *** 1385,1402 **** }; static void route_anything(t_route *x, t_symbol *sel, int argc, t_atom *argv) { ! if (x->type == A_SYMBOL) { ! t_routeelement *e = x->vec; ! for (int n = x->n; n--; e++) if (e->e_w.w_symbol == sel) { ! if (argc > 0 && argv[0].a_type == A_SYMBOL) ! outlet_anything(e->out, argv[0].a_symbol, argc-1, argv+1); ! else { /* tb {: avoid 1 element lists */ ! if (argc > 1) outlet_list(e->out, 0, argc, argv); ! else if (argc == 0) outlet_bang(e->out); ! else if (argv[0].a_type == A_FLOAT) outlet_float( e->out, argv[0].a_float); ! else if (argv[0].a_type == A_SYMBOL) outlet_symbol( e->out, argv[0].a_symbol); ! else if (argv[0].a_type == A_POINTER) outlet_pointer(e->out, argv[0].a_pointer); ! } /* tb } */ ! return; ! } } outlet_anything(x->rejectout, sel, argc, argv); --- 1384,1399 ---- }; static void route_anything(t_route *x, t_symbol *sel, int argc, t_atom *argv) { ! t_routeelement *e = x->vec; ! for (int n = x->n; n--; e++) if (e->a.a_type == A_SYMBOL) if (e->a.a_symbol == sel) { ! if (argc > 0 && argv[0].a_type == A_SYMBOL) ! outlet_anything(e->out, argv[0].a_symbol, argc-1, argv+1); ! else { /* tb {: avoid 1 element lists */ ! if (argc > 1) outlet_list(e->out, 0, argc, argv); ! else if (argc == 0) outlet_bang(e->out); ! else if (argv[0].a_type == A_FLOAT) outlet_float( e->out, argv[0].a_float); ! else if (argv[0].a_type == A_SYMBOL) outlet_symbol( e->out, argv[0].a_symbol); ! else if (argv[0].a_type == A_POINTER) outlet_pointer(e->out, argv[0].a_pointer); ! } /* tb } */ ! return; } outlet_anything(x->rejectout, sel, argc, argv); *************** *** 1405,1417 **** #define route_eachr(E,L) for (t_routeelement *E = L->vec;E;E=0) for (int ROUTEN = x->n; ROUTEN--; E++) static void route_list(t_route *x, t_symbol *sel, int argc, t_atom *argv) { ! if (x->type == A_FLOAT) { ! if (!argc) {outlet_bang(x->rejectout); return;} float f = atom_getfloat(argv); ! t_routeelement *e = x->vec; ! for (int n = x->n; n--; e++) if (e->e_w.w_float == f) { if (argc > 1 && argv[1].a_type == A_SYMBOL) outlet_anything(e->out, argv[1].a_symbol, argc-2, argv+2); ! else /* outlet_list(e->out, 0, argc-1, argv+1); */ { /* tb {: avoid 1 element lists */ ! argc -= 1, argv+=1; if (argc > 1) outlet_list(e->out, 0, argc, argv); else if (argc == 0) outlet_bang(e->out); --- 1402,1412 ---- #define route_eachr(E,L) for (t_routeelement *E = L->vec;E;E=0) for (int ROUTEN = x->n; ROUTEN--; E++) static void route_list(t_route *x, t_symbol *sel, int argc, t_atom *argv) { ! if (argc && argv->a_type == A_FLOAT) { float f = atom_getfloat(argv); ! route_eachr(e,x) if (e->a.a_float == f) { if (argc > 1 && argv[1].a_type == A_SYMBOL) outlet_anything(e->out, argv[1].a_symbol, argc-2, argv+2); ! else { ! argc--; argv++; if (argc > 1) outlet_list(e->out, 0, argc, argv); else if (argc == 0) outlet_bang(e->out); *************** *** 1419,1443 **** else if (argv[0].a_type == A_SYMBOL) outlet_symbol( e->out, argv[0].a_symbol); else if (argv[0].a_type == A_POINTER) outlet_pointer(e->out, argv[0].a_pointer); ! } /* tb } */ return; } } else { /* symbol arguments */ if (argc > 1) { /* 2 or more args: treat as "list" */ ! route_eachr(e,x) { ! if (e->e_w.w_symbol == &s_list) { ! if (argv[0].a_type==A_SYMBOL) outlet_anything(e->out, argv[0].a_symbol, argc-1, argv+1); ! else outlet_list(e->out, 0, argc, argv); ! return; ! } } ! } else if (argc == 0) { ! route_eachr(e,x) {if (e->e_w.w_symbol == &s_bang ) {outlet_bang(e->out); return;}} ! } else if (argv[0].a_type == A_FLOAT) { ! route_eachr(e,x) {if (e->e_w.w_symbol == &s_float ) {outlet_float(e->out, argv[0].a_float); return;}} ! } else { ! route_eachr(e,x) {if (e->e_w.w_symbol == &s_symbol) {outlet_symbol(e->out, argv[0].a_symbol); return;}} } } ! outlet_list(x->rejectout, 0, argc, argv); }
--- 1414,1433 ---- else if (argv[0].a_type == A_SYMBOL) outlet_symbol( e->out, argv[0].a_symbol); else if (argv[0].a_type == A_POINTER) outlet_pointer(e->out, argv[0].a_pointer); ! } return; } } else { /* symbol arguments */ if (argc > 1) { /* 2 or more args: treat as "list" */ ! route_eachr(e,x) if (e->a.a_symbol == &s_list) { ! if (argv[0].a_type==A_SYMBOL) outlet_anything(e->out, argv[0].a_symbol, argc-1, argv+1); ! else outlet_list(e->out, 0, argc, argv); ! return; } ! } else if (argc==0) { route_eachr(e,x) {if (e->a.a_symbol==&s_bang ) {outlet_bang( e->out ); return;}} ! } else if (argv[0].a_type==A_FLOAT) {route_eachr(e,x) {if (e->a.a_symbol==&s_float ) {outlet_float( e->out, argv[0].a_float ); return;}} ! } else {route_eachr(e,x) {if (e->a.a_symbol==&s_symbol) {outlet_symbol(e->out, argv[0].a_symbol); return;}} } } ! if (!argc) outlet_bang(x->rejectout); else outlet_list(x->rejectout, 0, argc, argv); }
*************** *** 1451,1455 **** argv = &a; } - x->type = argv[0].a_type; x->n = argc; x->vec = (t_routeelement *)getbytes(argc * sizeof(*x->vec)); --- 1441,1444 ---- *************** *** 1457,1462 **** for (int n = 0; n < argc; n++, e++) { e->out = outlet_new(x, &s_list); ! if (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->rejectout = outlet_new(x, &s_list); --- 1446,1450 ---- for (int n = 0; n < argc; n++, e++) { e->out = outlet_new(x, &s_list); ! e->a = argv[n]; } x->rejectout = outlet_new(x, &s_list);