Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13347
Modified Files: Tag: desiredata m_class.c Log Message: shorter code
Index: m_class.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/m_class.c,v retrieving revision 1.3.4.7.2.22.2.2 retrieving revision 1.3.4.7.2.22.2.3 diff -C2 -d -r1.3.4.7.2.22.2.2 -r1.3.4.7.2.22.2.3 *** m_class.c 5 Dec 2006 23:38:22 -0000 1.3.4.7.2.22.2.2 --- m_class.c 8 Dec 2006 04:51:28 -0000 1.3.4.7.2.22.2.3 *************** *** 5,9 **** #define PD_CLASS_DEF #include "desire.h" - #include "m_imp.h" #include "s_stuff.h" #include <stdlib.h> --- 5,8 ---- *************** *** 743,800 **** int narg = 0; t_pd *bonzo; ! ! /* check for messages that are handled by fixed slots in the class ! structure. We don't catch "pointer" though so that sending "pointer" ! to pd_objectmaker doesn't require that we supply a pointer value. */ ! if (s == &s_float) ! { ! if (!argc) (*c->c_floatmethod)(x, 0.); ! else if (argv->a_type == A_FLOAT) ! (*c->c_floatmethod)(x, argv->a_w.w_float); else goto badarg; return; } ! if (s == &s_bang) ! { ! (*c->c_bangmethod)(x); return; } ! if (s == &s_list) ! { ! (*c->c_listmethod)(x, s, argc, argv); return; } ! if (s == &s_symbol) ! { ! if (argc && argv->a_type == A_SYMBOL) ! (*c->c_symbolmethod)(x, argv->a_w.w_symbol); ! else ! (*c->c_symbolmethod)(x, &s_); return; } ! for (i = c->c_nmethod, m = c->c_methods; i--; m++) ! if (m->me_name == s) ! { wp = m->me_arg; ! if (*wp == A_GIMME) ! { ! if (x == &pd_objectmaker) ! pd_set_newest(((t_newgimme)(m->me_fun))(s, argc, argv)); ! else (*((t_messgimme)(m->me_fun)))(x, s, argc, argv); return; } if (argc > MAXPDARG) argc = MAXPDARG; if (x != &pd_objectmaker) *(ap++) = (t_int)x, narg++; ! while (wanttype = *wp++) ! { ! switch (wanttype) ! { case A_POINTER: if (!argc) goto badarg; ! else ! { ! if (argv->a_type == A_POINTER) ! *ap = (t_int)(argv->a_w.w_gpointer); ! else goto badarg; argc--; argv++; --- 742,782 ---- int narg = 0; t_pd *bonzo; ! /* check for messages that are handled by fixed slots in the class ! structure. We don't catch "pointer" though so that sending "pointer" ! to pd_objectmaker doesn't require that we supply a pointer value. */ ! if (s == &s_float) { ! if (!argc) c->c_floatmethod(x, 0.); ! else if (argv->a_type == A_FLOAT) c->c_floatmethod(x, argv->a_w.w_float); else goto badarg; return; } ! if (s == &s_bang) { ! c->c_bangmethod(x); return; } ! if (s == &s_list) { ! c->c_listmethod(x, s, argc, argv); return; } ! if (s == &s_symbol) { ! c->c_symbolmethod(x, argc && argv->a_type==A_SYMBOL ? argv->a_w.w_symbol : &s_); return; } ! for (i = c->c_nmethod, m = c->c_methods; i--; m++) if (m->me_name == s) { wp = m->me_arg; ! if (*wp == A_GIMME) { ! if (x == &pd_objectmaker) pd_set_newest(((t_newgimme)(m->me_fun))(s, argc, argv)); ! else ((t_messgimme)(m->me_fun))(x, s, argc, argv); return; } if (argc > MAXPDARG) argc = MAXPDARG; if (x != &pd_objectmaker) *(ap++) = (t_int)x, narg++; ! while (wanttype = *wp++) { ! switch (wanttype) { case A_POINTER: if (!argc) goto badarg; ! else { ! if (argv->a_type!=A_POINTER) goto badarg; ! *ap = (t_int)(argv->a_w.w_gpointer); argc--; argv++; *************** *** 807,815 **** case A_DEFFLOAT: if (!argc) *dp = 0; ! else ! { ! if (argv->a_type == A_FLOAT) ! *dp = argv->a_w.w_float; ! else goto badarg; argc--; argv++; --- 789,795 ---- case A_DEFFLOAT: if (!argc) *dp = 0; ! else { ! if (argv->a_type!=A_FLOAT) goto badarg; ! *dp = argv->a_w.w_float; argc--; argv++; *************** *** 821,832 **** case A_DEFSYM: if (!argc) *ap = (t_int)(&s_); ! else ! { ! if (argv->a_type == A_SYMBOL) ! *ap = (t_int)(argv->a_w.w_symbol); ! /* if it's an unfilled "dollar" argument it appears ! as zero here; cheat and bash it to the null ! symbol. Unfortunately, this lets real zeros ! pass as symbols too, which seems wrong... */ else if (x == &pd_objectmaker && argv->a_type == A_FLOAT && argv->a_w.w_float == 0) --- 801,810 ---- case A_DEFSYM: if (!argc) *ap = (t_int)(&s_); ! else { ! if (argv->a_type == A_SYMBOL) *ap = (t_int)(argv->a_w.w_symbol); ! /* if it's an unfilled "dollar" argument it appears ! as zero here; cheat and bash it to the null ! symbol. Unfortunately, this lets real zeros ! pass as symbols too, which seems wrong... */ else if (x == &pd_objectmaker && argv->a_type == A_FLOAT && argv->a_w.w_float == 0) *************** *** 840,873 **** } } ! switch (narg) ! { ! case 0 : bonzo = (*(t_fun0)(m->me_fun)) ! (ad[0], ad[1], ad[2], ad[3], ad[4]); break; ! case 1 : bonzo = (*(t_fun1)(m->me_fun)) ! (ai[0], ad[0], ad[1], ad[2], ad[3], ad[4]); break; ! case 2 : bonzo = (*(t_fun2)(m->me_fun)) ! (ai[0], ai[1], ad[0], ad[1], ad[2], ad[3], ad[4]); break; ! case 3 : bonzo = (*(t_fun3)(m->me_fun)) ! (ai[0], ai[1], ai[2], ad[0], ad[1], ad[2], ad[3], ad[4]); break; ! case 4 : bonzo = (*(t_fun4)(m->me_fun)) ! (ai[0], ai[1], ai[2], ai[3], ! ad[0], ad[1], ad[2], ad[3], ad[4]); break; ! case 5 : bonzo = (*(t_fun5)(m->me_fun)) ! (ai[0], ai[1], ai[2], ai[3], ai[4], ! ad[0], ad[1], ad[2], ad[3], ad[4]); break; ! case 6 : bonzo = (*(t_fun6)(m->me_fun)) ! (ai[0], ai[1], ai[2], ai[3], ai[4], ai[5], ! ad[0], ad[1], ad[2], ad[3], ad[4]); break; default: bonzo = 0; } ! if (x == &pd_objectmaker) ! pd_set_newest(bonzo); return; } ! (*c->c_anymethod)(x, s, argc, argv); return; badarg: ! pd_error(x, "Bad arguments for message '%s' to object '%s'", ! s->s_name, c->c_name->s_name); }
--- 818,839 ---- } } ! switch (narg) { ! #define REST ad[0],ad[1],ad[2],ad[3],ad[4] ! case 0 : bonzo = ((t_fun0)(m->me_fun))( REST); break; ! case 1 : bonzo = ((t_fun1)(m->me_fun))(ai[0], REST); break; ! case 2 : bonzo = ((t_fun2)(m->me_fun))(ai[0],ai[1], REST); break; ! case 3 : bonzo = ((t_fun3)(m->me_fun))(ai[0],ai[1],ai[2], REST); break; ! case 4 : bonzo = ((t_fun4)(m->me_fun))(ai[0],ai[1],ai[2],ai[3], REST); break; ! case 5 : bonzo = ((t_fun5)(m->me_fun))(ai[0],ai[1],ai[2],ai[3],ai[4], REST); break; ! case 6 : bonzo = ((t_fun6)(m->me_fun))(ai[0],ai[1],ai[2],ai[3],ai[4],ai[5],REST); break; default: bonzo = 0; } ! if (x == &pd_objectmaker) pd_set_newest(bonzo); return; } ! c->c_anymethod(x, s, argc, argv); return; badarg: ! pd_error(x, "Bad arguments for message '%s' to object '%s'", s->s_name, c->c_name->s_name); }