Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27172
Modified Files:
Tag: devel_0_39
m_pd.h m_class.c
Log Message:
adding class_addmethod2 as shorthand
Index: m_class.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/m_class.c,v
retrieving revision 1.3.4.7.2.6
retrieving revision 1.3.4.7.2.7
diff -C2 -d -r1.3.4.7.2.6 -r1.3.4.7.2.7
*** m_class.c 28 Oct 2005 12:18:23 -0000 1.3.4.7.2.6
--- m_class.c 15 Nov 2005 23:30:59 -0000 1.3.4.7.2.7
***************
*** 304,317 ****
}
! void class_addmethod(t_class *c, t_method fn, t_symbol *sel,
! t_atomtype arg1, ...)
{
- va_list ap;
t_methodentry *m;
! t_atomtype argtype = arg1;
int nargs;
!
! va_start(ap, arg1);
! /* "signal" method specifies that we take audio signals but
that we don't want automatic float to signal conversion. This
is obsolete; you should now use the CLASS_MAINSIGNALIN macro. */
--- 304,313 ----
}
! void class_addmethod2(t_class *c, t_method fn, t_symbol *sel, const char *fmt)
{
t_methodentry *m;
! int argtype = *fmt++;
int nargs;
! /* "signal" method specifies that we take audio signals but
that we don't want automatic float to signal conversion. This
is obsolete; you should now use the CLASS_MAINSIGNALIN macro. */
***************
*** 324,354 ****
/* check for special cases. "Pointer" is missing here so that
pd_objectmaker's pointer method can be typechecked differently. */
! if (sel == &s_bang)
! {
! if (argtype) goto phooey;
! class_addbang(c, fn);
! }
! else if (sel == &s_float)
! {
! if (argtype != A_FLOAT || va_arg(ap, t_atomtype)) goto phooey;
! class_doaddfloat(c, fn);
! }
! else if (sel == &s_symbol)
! {
! if (argtype != A_SYMBOL || va_arg(ap, t_atomtype)) goto phooey;
! class_addsymbol(c, fn);
! }
! else if (sel == &s_list)
! {
! if (argtype != A_GIMME) goto phooey;
! class_addlist(c, fn);
! }
! else if (sel == &s_anything)
! {
! if (argtype != A_GIMME) goto phooey;
! class_addanything(c, fn);
! }
! else
! {
c->c_methods = (t_methodentry *)t_resizebytes(c->c_methods,
c->c_nmethod * sizeof(*c->c_methods),
--- 320,329 ----
/* check for special cases. "Pointer" is missing here so that
pd_objectmaker's pointer method can be typechecked differently. */
! if (sel == &s_bang) {if (argtype) goto phooey; class_addbang(c, fn);}
! 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 {
c->c_methods = (t_methodentry *)t_resizebytes(c->c_methods,
c->c_nmethod * sizeof(*c->c_methods),
***************
*** 359,375 ****
m->me_fun = (t_gotfn)fn;
nargs = 0;
! while (argtype != A_NULL && nargs < MAXPDARG)
! {
! m->me_arg[nargs++] = argtype;
! argtype = va_arg(ap, t_atomtype);
! if (argtype > A_CANT || argtype < 0) {
! error("%s_%s: unknown atom type %d", c->c_name->s_name, sel->s_name, argtype);
! return;
! }
}
if (argtype != A_NULL)
error("%s_%s: only 5 arguments are typecheckable; use A_GIMME",
c->c_name->s_name, sel->s_name);
- va_end(ap);
m->me_arg[nargs] = A_NULL;
}
--- 334,359 ----
m->me_fun = (t_gotfn)fn;
nargs = 0;
! while (argtype && nargs < MAXPDARG) {
! 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;
! };
! m->me_arg[nargs++] = t;
! argtype = *fmt++;
}
if (argtype != A_NULL)
error("%s_%s: only 5 arguments are typecheckable; use A_GIMME",
c->c_name->s_name, sel->s_name);
m->me_arg[nargs] = A_NULL;
}
***************
*** 380,383 ****
--- 364,383 ----
}
+ void class_addmethod(t_class *c, t_method fn, t_symbol *sel, t_atomtype arg1, ...) {
+ char fmt[42],*f=fmt;
+ va_list ap;
+ va_start(ap,arg1);
+ int t=arg1;
+ for(;;) {
+ if (!t) break;
+ if (t>A_CANT) {error("class_addmethod: ARRGH! t=%d",t); return;}
+ *f++ = " fsp;,FS$@*!"[t];
+ t=va_arg(ap, t_atomtype);
+ }
+ *f = 0;
+ va_end(ap);
+ class_addmethod2(c,fn,sel,fmt);
+ }
+
/* Instead of these, see the "class_addfloat", etc., macros in m_pd.h */
void class_addbang(t_class *c, t_method fn)
Index: m_pd.h
===================================================================
RCS file: /cvsroot/pure-data/pd/src/m_pd.h,v
retrieving revision 1.4.4.11.2.13
retrieving revision 1.4.4.11.2.14
diff -C2 -d -r1.4.4.11.2.13 -r1.4.4.11.2.14
*** m_pd.h 28 Oct 2005 23:13:21 -0000 1.4.4.11.2.13
--- m_pd.h 15 Nov 2005 23:30:59 -0000 1.4.4.11.2.14
***************
*** 267,271 ****
#define mess5(x, s, a,b,c,d,e) ((*getfn((x), (s)))((x), (a),(b),(c),(d),(e)))
EXTERN void obj_list(t_object *x, t_symbol *s, int argc, t_atom *argv);
! EXTERN t_pd *pd_newest(void);
/* --------------- memory management -------------------- */
--- 267,271 ----
#define mess5(x, s, a,b,c,d,e) ((*getfn((x), (s)))((x), (a),(b),(c),(d),(e)))
EXTERN void obj_list(t_object *x, t_symbol *s, int argc, t_atom *argv);
! EXTERN t_pd *pd_newest(void); /* multiclient race conditions? */
/* --------------- memory management -------------------- */
***************
*** 451,454 ****
--- 451,455 ----
EXTERN void class_addmethod(t_class *c, t_method fn, t_symbol *sel,
t_atomtypearg arg1, ...);
+ EXTERN void class_addmethod2(t_class *c, t_method fn, t_symbol *sel, const char *sig);
EXTERN void class_addbang(t_class *c, t_method fn);
EXTERN void class_addpointer(t_class *c, t_method fn);