Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26444
Modified Files: Tag: desiredata m_class.c Log Message: shorter code againĀ²
Index: m_class.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/m_class.c,v retrieving revision 1.3.4.7.2.22.2.4 retrieving revision 1.3.4.7.2.22.2.5 diff -C2 -d -r1.3.4.7.2.22.2.4 -r1.3.4.7.2.22.2.5 *** m_class.c 8 Dec 2006 05:13:02 -0000 1.3.4.7.2.22.2.4 --- m_class.c 8 Dec 2006 05:28:38 -0000 1.3.4.7.2.22.2.5 *************** *** 42,75 ****
static void pd_defaultbang(t_pd *x) { ! if ((*x)->c_listmethod != pd_defaultlist) ! (*x)->c_listmethod(x, 0, 0, 0); ! else (*x)->c_anymethod(x, &s_bang, 0, 0); }
static void pd_defaultpointer(t_pd *x, t_gpointer *gp) { ! t_atom at; SETPOINTER(&at, gp); ! if ((*x)->c_listmethod != pd_defaultlist) { ! (*x)->c_listmethod(x, 0, 1, &at); ! } else { ! (*x)->c_anymethod(x, &s_pointer, 1, &at); ! } }
static void pd_defaultfloat(t_pd *x, t_float f) { ! t_atom at; SETFLOAT(&at, f); ! if (*(*x)->c_listmethod != pd_defaultlist) { ! (*x)->c_listmethod(x, 0, 1, &at); ! } else { ! (*x)->c_anymethod(x, &s_float, 1, &at); ! } }
static void pd_defaultsymbol(t_pd *x, t_symbol *s) { ! t_atom at; SETSYMBOL(&at, s); ! if ((*x)->c_listmethod != pd_defaultlist) { ! (*x)->c_listmethod(x, 0, 1, &at); ! } else { ! (*x)->c_anymethod(x, &s_symbol, 1, &at); ! } }
--- 42,66 ----
static void pd_defaultbang(t_pd *x) { ! t_class *c = pd_class(x); ! if (c->c_listmethod != pd_defaultlist) c->c_listmethod(x,0,0,0); ! else c->c_anymethod(x,&s_bang,0,0); }
static void pd_defaultpointer(t_pd *x, t_gpointer *gp) { ! t_class *c = pd_class(x); t_atom at; SETPOINTER(&at, gp); ! if (c->c_listmethod != pd_defaultlist) c->c_listmethod(x,0,1,&at); ! else c->c_anymethod(x,&s_pointer,1,&at); }
static void pd_defaultfloat(t_pd *x, t_float f) { ! t_class *c = pd_class(x); t_atom at; SETFLOAT(&at, f); ! if (c->c_listmethod != pd_defaultlist) c->c_listmethod(x,0,1,&at); ! else c->c_anymethod(x,&s_float,1,&at); }
static void pd_defaultsymbol(t_pd *x, t_symbol *s) { ! t_class *c = pd_class(x); t_atom at; SETSYMBOL(&at, s); ! if (c->c_listmethod != pd_defaultlist) c->c_listmethod(x,0,1,&at); ! else c->c_anymethod(x,&s_symbol,1,&at); }
*************** *** 79,112 **** /* handle "list" messages to Pds without explicit list methods defined. */ static void pd_defaultlist(t_pd *x, t_symbol *s, int argc, t_atom *argv) { /* a list with no elements is handled by the 'bang' method if one exists. */ ! if (argc == 0 && *(*x)->c_bangmethod != pd_defaultbang) { ! (*x)->c_bangmethod(x); ! return; ! } /* a list with one element which is a number can be handled by a "float" method if any is defined; same for "symbol", "pointer". */ if (argc == 1) { ! if (argv->a_type == A_FLOAT && *(*x)->c_floatmethod != pd_defaultfloat) { ! (*x)->c_floatmethod(x, argv->a_w.w_float); ! return; ! } ! if (argv->a_type == A_SYMBOL && *(*x)->c_symbolmethod != pd_defaultsymbol) { ! (*x)->c_symbolmethod(x, argv->a_w.w_symbol); ! return; ! } ! if (argv->a_type == A_POINTER && *(*x)->c_pointermethod != pd_defaultpointer) { ! (*x)->c_pointermethod(x, argv->a_w.w_gpointer); ! return; ! } } ! /* Next try for an "anything" method */ ! if ((*x)->c_anymethod != pd_defaultanything) ! (*x)->c_anymethod(x, &s_list, argc, argv); ! ! /* if the object is patchable (i.e., can have proper inlets) ! send it on to obj_list which will unpack the list into the inlets */ ! else if ((*x)->c_patchable) ! obj_list((t_object *)x, s, argc, argv); ! /* otherwise gove up and complain. */ else pd_defaultanything(x, &s_list, argc, argv); } --- 70,89 ---- /* handle "list" messages to Pds without explicit list methods defined. */ static void pd_defaultlist(t_pd *x, t_symbol *s, int argc, t_atom *argv) { + t_class *c = pd_class(x); /* a list with no elements is handled by the 'bang' method if one exists. */ ! if (argc == 0 && c->c_bangmethod != pd_defaultbang) {c->c_bangmethod(x); return;} /* a list with one element which is a number can be handled by a "float" method if any is defined; same for "symbol", "pointer". */ if (argc == 1) { ! #define HANDLE(A,M,D,F) if (argv->a_type==A && c->M != D) {c->M(x, argv->a_w.F); return;} ! HANDLE(A_FLOAT ,c_floatmethod ,pd_defaultfloat ,w_float) ! HANDLE(A_SYMBOL ,c_symbolmethod ,pd_defaultsymbol ,w_symbol) ! HANDLE(A_POINTER,c_pointermethod,pd_defaultpointer,w_gpointer) } ! /* Next try for an "anything" method; if the object is patchable (i.e., ! can have proper inlets) send it on to obj_list which will unpack the ! list into the inlets. otherwise gove up and complain. */ ! if (c->c_anymethod != pd_defaultanything) c->c_anymethod(x,&s_list,argc,argv); ! else if (c->c_patchable) obj_list((t_object *)x, s, argc, argv); else pd_defaultanything(x, &s_list, argc, argv); }