Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5437
Modified Files: Tag: devel_0_38 x_connective.c Log Message: avoid creating of zero / one element lists by route
Index: x_connective.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/x_connective.c,v retrieving revision 1.3.4.1 retrieving revision 1.3.4.2 diff -C2 -d -r1.3.4.1 -r1.3.4.2 *** x_connective.c 11 Nov 2004 22:30:43 -0000 1.3.4.1 --- x_connective.c 22 Jun 2005 18:45:20 -0000 1.3.4.2 *************** *** 492,496 **** 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; } --- 492,513 ---- outlet_anything(e->e_outlet, argv[0].a_w.w_symbol, argc-1, argv+1); ! else ! /* tb {: avoid 1 element lists */ ! { ! if (argc > 1) /* list */ ! outlet_list(e->e_outlet, 0, argc, argv); ! ! else if (argc == 0) /* bang */ ! outlet_bang(e->e_outlet); ! ! else /* argc == 1 */ ! if (argv[0].a_type == A_FLOAT) ! outlet_float(e->e_outlet, argv[0].a_w.w_float); ! else if (argv[0].a_type == A_SYMBOL) ! outlet_symbol(e->e_outlet, argv[0].a_w.w_symbol); ! else if (argv[0].a_type == A_POINTER) ! outlet_pointer(e->e_outlet, argv[0].a_w.w_gpointer); ! /* tb } */ ! } return; } *************** *** 506,510 **** { float f; ! if (!argc) return; f = atom_getfloat(argv); for (nelement = x->x_nelement, e = x->x_vec; nelement--; e++) --- 523,531 ---- { float f; ! if (!argc) { ! /* no args: treat as "bang" and thus reject */ ! outlet_bang(x->x_rejectout); ! return; ! } f = atom_getfloat(argv); for (nelement = x->x_nelement, e = x->x_vec; nelement--; e++) *************** *** 514,518 **** 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; } --- 535,558 ---- 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); */ ! /* tb {: avoid 1 element lists */ ! { ! argc -= 1, argv+=1; ! if (argc > 1) /* list */ ! outlet_list(e->e_outlet, 0, argc, argv); ! ! else if (argc == 0) /* bang */ ! outlet_bang(e->e_outlet); ! ! else /* argc == 1 */ ! if (argv[0].a_type == A_FLOAT) ! outlet_float(e->e_outlet, argv[0].a_w.w_float); ! else if (argv[0].a_type == A_SYMBOL) ! outlet_symbol(e->e_outlet, argv[0].a_w.w_symbol); ! else if (argv[0].a_type == A_POINTER) ! outlet_pointer(e->e_outlet, argv[0].a_w.w_gpointer); ! /* tb } */ ! } ! return; } *************** *** 591,594 **** --- 631,655 ---- x->x_type = argv[0].a_type; x->x_nelement = argc; + + /* type checking: arguments must bei either floats xor symbols */ + if (x->x_type == A_FLOAT) + { + for(n=0; n<argc; n++) + if (argv[n].a_type!=A_FLOAT) + { + pd_error(x, "route: cannot route floats and symbols at the same time"); + return 0; + } + } + else + { + for(n=0; n<argc; n++) + if(argv[n].a_type==A_FLOAT) + { + pd_error(x, "route: cannot route symbols and floats at the same time"); + return 0; + } + } + x->x_vec = (t_routeelement *)getbytes(argc * sizeof(*x->x_vec)); for (n = 0, e = x->x_vec; n < argc; n++, e++)