[PD-cvs] pd/src m_class.c,1.3.4.7.2.22.2.3,1.3.4.7.2.22.2.4

Mathieu Bouchard matju at users.sourceforge.net
Fri Dec 8 06:13:04 CET 2006


Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20736

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.3
retrieving revision 1.3.4.7.2.22.2.4
diff -C2 -d -r1.3.4.7.2.22.2.3 -r1.3.4.7.2.22.2.4
*** m_class.c	8 Dec 2006 04:51:28 -0000	1.3.4.7.2.22.2.3
--- m_class.c	8 Dec 2006 05:13:02 -0000	1.3.4.7.2.22.2.4
***************
*** 41,96 ****
  }
  
! 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)
! {
!     if (*(*x)->c_listmethod != pd_defaultlist)
!     {
!         t_atom at;
!         SETPOINTER(&at, gp);
!         (*(*x)->c_listmethod)(x, 0, 1, &at);
!     }
!     else
!     {
!         t_atom at;
!         SETPOINTER(&at, gp);
!         (*(*x)->c_anymethod)(x, &s_pointer, 1, &at);
      }
  }
  
! static void pd_defaultfloat(t_pd *x, t_float f)
! {
!     if (*(*x)->c_listmethod != pd_defaultlist)
!     {
!         t_atom at;
!         SETFLOAT(&at, f);
!         (*(*x)->c_listmethod)(x, 0, 1, &at);
!     }
!     else
!     {
!         t_atom at;
!         SETFLOAT(&at, f);
!         (*(*x)->c_anymethod)(x, &s_float, 1, &at);
      }
  }
  
! static void pd_defaultsymbol(t_pd *x, t_symbol *s)
! {
!     if (*(*x)->c_listmethod != pd_defaultlist)
!     {
!         t_atom at;
!         SETSYMBOL(&at, s);
!         (*(*x)->c_listmethod)(x, 0, 1, &at);
!     }
!     else
!     {
!         t_atom at;
!         SETSYMBOL(&at, s);
!         (*(*x)->c_anymethod)(x, &s_symbol, 1, &at);
      }
  }
--- 41,74 ----
  }
  
! 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);
      }
  }
***************
*** 99,132 ****
  static void class_nosavefn(t_gobj *z, t_binbuf *b);
  
!     /* 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;
          }
!         else if (argv->a_type == A_SYMBOL &&
!             *(*x)->c_symbolmethod != pd_defaultsymbol)
!         {
!             (*(*x)->c_symbolmethod)(x, argv->a_w.w_symbol);
              return;
          }
!         else if (argv->a_type == A_POINTER &&
!             *(*x)->c_pointermethod != pd_defaultpointer)
!         {
!             (*(*x)->c_pointermethod)(x, argv->a_w.w_gpointer);
              return;
          }
--- 77,100 ----
  static void class_nosavefn(t_gobj *z, t_binbuf *b);
  
! /* 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;
          }
***************
*** 134,138 ****
          /* 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)
--- 102,106 ----
          /* 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)
***************
*** 320,324 ****
      else if (sel == &s_float)  {if (argtype!='f' || *fmt) goto phooey; class_doaddfloat(c,fn);}
      else if (sel == &s_symbol) {if (argtype!='s' || *fmt) goto phooey; class_addsymbol(c, fn);}
!     else if (sel == &s_list)   {if (argtype!='*') goto phooey; class_addlist(c, fn);}
      else if (sel == &s_anything) {if (argtype != A_GIMME) goto phooey; class_addanything(c, fn);}
      else {
--- 288,292 ----
      else if (sel == &s_float)  {if (argtype!='f' || *fmt) goto phooey; class_doaddfloat(c,fn);}
      else if (sel == &s_symbol) {if (argtype!='s' || *fmt) goto phooey; class_addsymbol(c, fn);}
!     else if (sel == &s_list)   {if (argtype!='*')         goto phooey; class_addlist(c, fn);}
      else if (sel == &s_anything) {if (argtype != A_GIMME) goto phooey; class_addanything(c, fn);}
      else {
***************
*** 326,330 ****
              c->c_nmethod * sizeof(*c->c_methods),
              (c->c_nmethod + 1) * sizeof(*c->c_methods));
!         m = c->c_methods +  c->c_nmethod;
          c->c_nmethod++;
          m->me_name = sel;
--- 294,298 ----
              c->c_nmethod * sizeof(*c->c_methods),
              (c->c_nmethod + 1) * sizeof(*c->c_methods));
!         m = c->c_methods + c->c_nmethod;
          c->c_nmethod++;
          m->me_name = sel;
***************
*** 334,348 ****
  	    t_atomtype t;
  	    switch(argtype) {
! 		case 'f': t=A_FLOAT;  break;    
! 		case 's': t=A_SYMBOL; break;    
! 		case 'p': t=A_POINTER; break;
! 		case ';': t=A_SEMI;  break;    
! 		case ',': t=A_COMMA; break;
! 		case 'F': t=A_DEFFLOAT;  break;    
! 		case 'S': t=A_DEFSYMBOL; break;
! 		case '$': t=A_DOLLAR; break;
! 		case '@': t=A_DOLLSYM; break;
! 		case '*': t=A_GIMME; break;
! 		case '!': t=A_CANT; break;
  		default: goto phooey;
  	    };
--- 302,316 ----
  	    t_atomtype t;
  	    switch(argtype) {
! 		case 'f': t=A_FLOAT;    break;
! 		case 's': t=A_SYMBOL;   break;
! 		case 'p': t=A_POINTER;  break;
! 		case ';': t=A_SEMI;     break;
! 		case ',': t=A_COMMA;    break;
! 		case 'F': t=A_DEFFLOAT; break;
! 		case 'S': t=A_DEFSYMBOL;break;
! 		case '$': t=A_DOLLAR;   break;
! 		case '@': t=A_DOLLSYM;  break;
! 		case '*': t=A_GIMME;    break;
! 		case '!': t=A_CANT;     break;
  		default: goto phooey;
  	    };
***************
*** 380,452 ****
  
      /* Instead of these, see the "class_addfloat", etc.,  macros in m_pd.h */
! void class_addbang(t_class *c, t_method fn)
! {
!     c->c_bangmethod = (t_bangmethod)fn;
! }
! 
! void class_addpointer(t_class *c, t_method fn)
! {
!     c->c_pointermethod = (t_pointermethod)fn;
! }
! 
! void class_doaddfloat(t_class *c, t_method fn)
! {
!     c->c_floatmethod = (t_floatmethod)fn;
! }
! 
! void class_addsymbol(t_class *c, t_method fn)
! {
!     c->c_symbolmethod = (t_symbolmethod)fn;
! }
! 
! void class_addlist(t_class *c, t_method fn)
! {
!     c->c_listmethod = (t_listmethod)fn;
! }
! 
! void class_addanything(t_class *c, t_method fn)
! {
!     c->c_anymethod = (t_anymethod)fn;
! }
! 
! void class_setparentwidget(t_class *c, t_parentwidgetbehavior *pw)
! {
!     c->c_pwb = pw;
! }
! 
! char *class_getname(t_class *c)
! {
!     return (c->c_name->s_name);
! }
! 
! char *class_gethelpname(t_class *c)
! {
!     return (c->c_helpname->s_name);
! }
! 
! void class_sethelpsymbol(t_class *c, t_symbol *s)
! {
!     c->c_helpname = s;
! }
! 
! t_parentwidgetbehavior *pd_getparentwidget(t_pd *x)
! {
!     return ((*x)->c_pwb);
! }
  
! void class_setdrawcommand(t_class *c)
! {
!     c->c_drawcommand = 1;
! }
  
! int class_isdrawcommand(t_class *c)
! {
!     return (c->c_drawcommand);
! }
  
! void class_setnotice(t_class *c, t_notice notice) 
! {
!     c->c_notice = notice;
! }
  
  static void pd_floatforsignal(t_pd *x, t_float f)
--- 348,368 ----
  
      /* Instead of these, see the "class_addfloat", etc.,  macros in m_pd.h */
! void class_addbang(    t_class *c, t_method fn) {   c->c_bangmethod = (t_bangmethod)fn;}
! void class_addpointer( t_class *c, t_method fn) {c->c_pointermethod = (t_pointermethod)fn;}
! void class_doaddfloat( t_class *c, t_method fn) {  c->c_floatmethod = (t_floatmethod)fn;}
! void class_addsymbol(  t_class *c, t_method fn)  {c->c_symbolmethod = (t_symbolmethod)fn;}
! void class_addlist(    t_class *c, t_method fn)    {c->c_listmethod = (t_listmethod)fn;}
! void class_addanything(t_class *c, t_method fn) {    c->c_anymethod = (t_anymethod)fn;}
  
! void class_setparentwidget(t_class *c, t_parentwidgetbehavior *pw) {c->c_pwb = pw;}
! char *class_getname(t_class *c)     {return c->c_name->s_name;}
! char *class_gethelpname(t_class *c) {return c->c_helpname->s_name;}
! void class_sethelpsymbol(t_class *c, t_symbol *s) {c->c_helpname = s;}
  
! t_parentwidgetbehavior *pd_getparentwidget(t_pd *x) {return (*x)->c_pwb;}
  
! void class_setdrawcommand(t_class *c) {c->c_drawcommand = 1;}
! int  class_isdrawcommand( t_class *c) {return c->c_drawcommand;}
! void class_setnotice(t_class *c, t_notice notice) {c->c_notice = notice;}
  
  static void pd_floatforsignal(t_pd *x, t_float f)
***************
*** 472,499 ****
  }
  
! void class_set_extern_dir(t_symbol *s)
! {
!     class_extern_dir = s;
! }
! 
! char *class_gethelpdir(t_class *c)
! {
!     return (c->c_externdir->s_name);
! }
  
! static void class_nosavefn(t_gobj *z, t_binbuf *b)
! {
      bug("save function called but not defined");
  }
  
! void class_setsavefn(t_class *c, t_savefn f)
! {
!     c->c_savefn = f;
! }
! 
! t_savefn class_getsavefn(t_class *c)
! {
!     return (c->c_savefn);
! }
  
  /* ---------------- the symbol table ------------------------ */
--- 388,400 ----
  }
  
! void class_set_extern_dir(t_symbol *s) {class_extern_dir = s;}
! char *class_gethelpdir(t_class *c) {return c->c_externdir->s_name;}
  
! static void class_nosavefn(t_gobj *z, t_binbuf *b) {
      bug("save function called but not defined");
  }
  
! void class_setsavefn(t_class *c, t_savefn f) {c->c_savefn = f;}
! t_savefn class_getsavefn(t_class *c) {return  c->c_savefn;}
  
  /* ---------------- the symbol table ------------------------ */
***************
*** 716,733 ****
  typedef void(*t_messgimme)(t_pd *x, t_symbol *s, int argc, t_atom *argv);
  
! typedef t_pd *(*t_fun0)(
!     t_floatarg d1, t_floatarg d2, t_floatarg d3, t_floatarg d4, t_floatarg d5);
! typedef t_pd *(*t_fun1)(t_int i1,
!     t_floatarg d1, t_floatarg d2, t_floatarg d3, t_floatarg d4, t_floatarg d5);
! typedef t_pd *(*t_fun2)(t_int i1, t_int i2,
!     t_floatarg d1, t_floatarg d2, t_floatarg d3, t_floatarg d4, t_floatarg d5);
! typedef t_pd *(*t_fun3)(t_int i1, t_int i2, t_int i3,
!     t_floatarg d1, t_floatarg d2, t_floatarg d3, t_floatarg d4, t_floatarg d5);
! typedef t_pd *(*t_fun4)(t_int i1, t_int i2, t_int i3, t_int i4,
!     t_floatarg d1, t_floatarg d2, t_floatarg d3, t_floatarg d4, t_floatarg d5);
! typedef t_pd *(*t_fun5)(t_int i1, t_int i2, t_int i3, t_int i4, t_int i5,
!     t_floatarg d1, t_floatarg d2, t_floatarg d3, t_floatarg d4, t_floatarg d5);
! typedef t_pd *(*t_fun6)(t_int i1, t_int i2, t_int i3, t_int i4, t_int i5, t_int i6,
!     t_floatarg d1, t_floatarg d2, t_floatarg d3, t_floatarg d4, t_floatarg d5);
  
  void pd_typedmess(t_pd *x, t_symbol *s, int argc, t_atom *argv)
--- 617,629 ----
  typedef void(*t_messgimme)(t_pd *x, t_symbol *s, int argc, t_atom *argv);
  
! #define REST t_floatarg d1, t_floatarg d2, t_floatarg d3, t_floatarg d4, t_floatarg d5
! typedef t_pd *(*t_fun0)(REST);
! typedef t_pd *(*t_fun1)(t_int i1, REST);
! typedef t_pd *(*t_fun2)(t_int i1, t_int i2, REST);
! typedef t_pd *(*t_fun3)(t_int i1, t_int i2, t_int i3, REST);
! typedef t_pd *(*t_fun4)(t_int i1, t_int i2, t_int i3, t_int i4, REST);
! typedef t_pd *(*t_fun5)(t_int i1, t_int i2, t_int i3, t_int i4, t_int i5, REST);
! typedef t_pd *(*t_fun6)(t_int i1, t_int i2, t_int i3, t_int i4, t_int i5, t_int i6, REST);
! #undef REST
  
  void pd_typedmess(t_pd *x, t_symbol *s, int argc, t_atom *argv)





More information about the Pd-cvs mailing list