[PD-dev] class_addmethod2

Miller Puckette mpuckett at imusic1.ucsd.edu
Thu Dec 15 18:49:37 CET 2005


How about calling this "class_addv" or, possibly, "class_vmess"?  I think
it's a much better design than class_addmethod and I should add it, once
we figure out the best name, to the "main" API.

cheers
Miller

On Sun, Nov 20, 2005 at 01:57:24PM -0500, Mathieu Bouchard wrote:
> 
> A few days ago I added class_addmethod2 to m_class.c and m_pd.h.
> 
> Its advantages over class_addmethod are:
> 
>   1. it doesn't use varargs and you don't need to remember to use A_NULL
>   2. the syntax is shorter so declarations can fit in one line
>   3. it's closer to how binbuf_addv works
> 
> basically, atom types are given letters:
> 
> f=A_FLOAT   F=A_DEFFLOAT
> s=A_SYMBOL  S=A_DEFSYMBOL
> p=A_POINTER
> *=A_GIMME
> !=A_CANT  (e.g. for dsp messages)
> 
> so instead of writing:
> 
>   class_addmethod(myclass, (t_method)myclass_mymethod, gensym("mymethod"), 
>     A_POINTER, A_FLOAT, A_FLOAT, A_SYMBOL, A_DEFFLOAT, A_DEFFLOAT, 
>     A_DEFSYMBOL, A_NULL);
> 
> you can write:
> 
>   class_addmethod2(myclass, (t_method)myclass_mymethod, gensym("mymethod"), 
>     "pffsFFS");
> 
> and class_addmethod3 is a macro in desire.c which further abbreviates it:
> 
>   class_addmethod3(myclass, myclass_mymethod, "mymethod", "pffsFFS");
> 
> ____________________________________________________________________
> Mathieu Bouchard - t?l:+1.514.383.3801 - http://artengine.ca/matju
> Freelance Digital Arts Engineer, Montr?al QC Canada
> 
> _______________________________________________
> PD-dev mailing list
> PD-dev at iem.at
> http://lists.puredata.info/listinfo/pd-dev




More information about the Pd-dev mailing list