From 9c0e19a3be2288db79e2502e5fa450c3e20a668d Mon Sep 17 00:00:00 2001 From: Guenter Geiger Date: Fri, 9 May 2003 16:04:00 +0000 Subject: This commit was generated by cvs2svn to compensate for changes in r610, which included commits to RCS files with non-trunk default branches. svn path=/trunk/; revision=611 --- pd/doc/6.externs/makefile | 49 ++++++++++++++++++++++----------------- pd/doc/6.externs/obj1.c | 47 +++++++++++++++++++++++++++++++++++++ pd/doc/6.externs/obj2.c | 45 ++++++++++++++++++++++++++++++++++++ pd/doc/6.externs/obj3.c | 39 +++++++++++++++++++++++++++++++ pd/doc/6.externs/obj4.c | 47 +++++++++++++++++++++++++++++++++++++ pd/doc/6.externs/obj5.c | 54 +++++++++++++++++++++++++++++++++++++++++++ pd/doc/6.externs/test-obj1.pd | 6 +++++ pd/doc/6.externs/test-obj2.pd | 8 +++++++ pd/doc/6.externs/test-obj3.pd | 8 +++++++ pd/doc/6.externs/test-obj4.pd | 6 +++++ pd/doc/6.externs/test-obj5.pd | 4 ++++ 11 files changed, 292 insertions(+), 21 deletions(-) create mode 100644 pd/doc/6.externs/obj1.c create mode 100644 pd/doc/6.externs/obj2.c create mode 100644 pd/doc/6.externs/obj3.c create mode 100644 pd/doc/6.externs/obj4.c create mode 100644 pd/doc/6.externs/obj5.c create mode 100644 pd/doc/6.externs/test-obj1.pd create mode 100644 pd/doc/6.externs/test-obj2.pd create mode 100644 pd/doc/6.externs/test-obj3.pd create mode 100644 pd/doc/6.externs/test-obj4.pd create mode 100644 pd/doc/6.externs/test-obj5.pd (limited to 'pd/doc/6.externs') diff --git a/pd/doc/6.externs/makefile b/pd/doc/6.externs/makefile index f807ba0b..a4e9308c 100644 --- a/pd/doc/6.externs/makefile +++ b/pd/doc/6.externs/makefile @@ -5,28 +5,34 @@ clean: ; rm -f *.pd_linux *.o # ----------------------- NT ----------------------- -pd_nt: foo1.dll foo2.dll dspobj~.dll +pd_nt: obj1.dll obj2.dll obj3.dll obj4.dll obj5.dll dspobj~.dll -.SUFFIXES: .dll +.SUFFIXES: .obj .dll PDNTCFLAGS = /W3 /WX /DNT /DPD /nologo VC="C:\Program Files\Microsoft Visual Studio\Vc98" -PDNTINCLUDE = /I. /I\tcl\include /I\ftp\pd\src /I$(VC)\include +PDNTINCLUDE = /I. /I\tcl\include /I..\..\src /I$(VC)\include PDNTLDIR = $(VC)\lib PDNTLIB = $(PDNTLDIR)\libc.lib \ $(PDNTLDIR)\oldnames.lib \ $(PDNTLDIR)\kernel32.lib \ - \ftp\pd\bin\pd.lib + ..\..\bin\pd.lib .c.dll: cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c link /dll /export:$*_setup $*.obj $(PDNTLIB) +# override explicitly for tilde objects like this: +dspobj~.dll: dspobj~.c; + cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c + link /dll /export:dspobj_tilde_setup $*.obj $(PDNTLIB) + # ----------------------- IRIX 5.x ----------------------- -pd_irix5: foo1.pd_irix5 foo2.pd_irix5 dspobj~.pd_irix5 +pd_irix5: obj1.pd_irix5 obj2.pd_irix5 \ + obj3.pd_irix5 obj4.pd_irix5 obj5.pd_irix5 dspobj~.pd_irix5 .SUFFIXES: .pd_irix5 @@ -40,24 +46,10 @@ SGIINCLUDE = -I../../src/ ld -elf -shared -rdata_shared -o $*.pd_irix5 $*.o rm $*.o -# ----------------------- IRIX 6.x ----------------------- - -pd_irix6: foo1.pd_irix6 foo2.pd_irix6 dspobj~.pd_irix6 - -.SUFFIXES: .pd_irix6 - -SGICFLAGS6 = -n32 -DPD -DUNIX -DIRIX -DN32 -woff 1080,1064,1185 \ - -OPT:roundoff=3 -OPT:IEEE_arithmetic=3 -OPT:cray_ivdep=true \ - -Ofast=ip32 - -.c.pd_irix6: - cc $(SGICFLAGS6) $(SGIINCLUDE) -o $*.o -c $*.c - ld -IPA -n32 -shared -rdata_shared -o $*.pd_irix6 $*.o - rm $*.o - # ----------------------- LINUX i386 ----------------------- -pd_linux: foo1.pd_linux foo2.pd_linux dspobj~.pd_linux +pd_linux: obj1.pd_linux obj2.pd_linux obj3.pd_linux obj4.pd_linux \ + obj5.pd_linux dspobj~.pd_linux .SUFFIXES: .pd_linux @@ -73,3 +65,18 @@ LINUXINCLUDE = -I../../src strip --strip-unneeded $*.pd_linux rm $*.o +# ----------------------- Mac OSX ----------------------- + +pd_darwin: obj1.pd_darwin obj2.pd_darwin \ + obj3.pd_darwin obj4.pd_darwin obj5.pd_darwin dspobj~.pd_darwin + +.SUFFIXES: .pd_darwin + +DARWINCFLAGS = -DPD -O2 -Wall -W -Wshadow -Wstrict-prototypes \ + -Wno-unused -Wno-parentheses -Wno-switch + +.c.pd_darwin: + cc $(DARWINCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c + cc -bundle -undefined suppress -flat_namespace -o $*.pd_darwin $*.o + rm -f $*.o + diff --git a/pd/doc/6.externs/obj1.c b/pd/doc/6.externs/obj1.c new file mode 100644 index 00000000..0618d646 --- /dev/null +++ b/pd/doc/6.externs/obj1.c @@ -0,0 +1,47 @@ +/* code for "obj1" pd class. This takes two messages: floating-point +numbers, and "rats", and just prints something out for each message. */ + +#include "m_pd.h" + + /* the data structure for each copy of "obj1". In this case we + on;y need pd's obligatory header (of type t_object). */ +typedef struct obj1 +{ + t_object x_ob; +} t_obj1; + + /* this is called back when obj1 gets a "float" message (i.e., a + number.) */ +void obj1_float(t_obj1 *x, t_floatarg f) +{ + post("obj1: %f", f); +} + + /* this is called when obj1 gets the message, "rats". */ +void obj1_rats(t_obj1 *x) +{ + post("obj1: rats"); +} + + /* this is a pointer to the class for "obj1", which is created in the + "setup" routine below and used to create new ones in the "new" routine. */ +t_class *obj1_class; + + /* this is called when a new "obj1" object is created. */ +void *obj1_new(void) +{ + t_obj1 *x = (t_obj1 *)pd_new(obj1_class); + post("obj1_new"); + return (void *)x; +} + + /* this is called once at setup time, when this code is loaded into Pd. */ +void obj1_setup(void) +{ + post("obj1_setup"); + obj1_class = class_new(gensym("obj1"), (t_newmethod)obj1_new, 0, + sizeof(t_obj1), 0, 0); + class_addmethod(obj1_class, (t_method)obj1_rats, gensym("rats"), 0); + class_addfloat(obj1_class, obj1_float); +} + diff --git a/pd/doc/6.externs/obj2.c b/pd/doc/6.externs/obj2.c new file mode 100644 index 00000000..14cd134a --- /dev/null +++ b/pd/doc/6.externs/obj2.c @@ -0,0 +1,45 @@ +/* code for the "obj2" pd class. This one, in addition to the "obj1" +code, has an inlet taking numbers. */ + +#include "m_pd.h" + +typedef struct obj2 +{ + t_object x_ob; +} t_obj2; + +void obj2_float(t_obj2 *x, t_floatarg f) +{ + post("obj2: %f", f); +} + +void obj2_rats(t_obj2 *x) +{ + post("obj2: rats"); +} + +void obj2_ft1(t_obj2 *x, t_floatarg g) +{ + post("ft1: %f", g); +} + +t_class *obj2_class; + +void *obj2_new(void) +{ + t_obj2 *x = (t_obj2 *)pd_new(obj2_class); + inlet_new(&x->x_ob, &x->x_ob.ob_pd, gensym("float"), gensym("ft1")); + post("obj2_new"); + return (void *)x; +} + +void obj2_setup(void) +{ + post("obj2_setup"); + obj2_class = class_new(gensym("obj2"), (t_newmethod)obj2_new, + 0, sizeof(t_obj2), 0, 0); + class_addmethod(obj2_class, (t_method)obj2_rats, gensym("rats"), 0); + class_addmethod(obj2_class, (t_method)obj2_ft1, gensym("ft1"), A_FLOAT, 0); + class_addfloat(obj2_class, obj2_float); +} + diff --git a/pd/doc/6.externs/obj3.c b/pd/doc/6.externs/obj3.c new file mode 100644 index 00000000..434fbb95 --- /dev/null +++ b/pd/doc/6.externs/obj3.c @@ -0,0 +1,39 @@ +/* code for the "obj3" pd class. This adds an outlet and a state variable. */ + +#include "m_pd.h" + +typedef struct obj3 +{ + t_object x_ob; + t_outlet *x_outlet; + float x_value; +} t_obj3; + +void obj3_float(t_obj3 *x, t_floatarg f) +{ + outlet_float(x->x_outlet, f + x->x_value); +} + +void obj3_ft1(t_obj3 *x, t_floatarg g) +{ + x->x_value = g; +} + +t_class *obj3_class; + +void *obj3_new(void) +{ + t_obj3 *x = (t_obj3 *)pd_new(obj3_class); + inlet_new(&x->x_ob, &x->x_ob.ob_pd, gensym("float"), gensym("ft1")); + x->x_outlet = outlet_new(&x->x_ob, gensym("float")); + return (void *)x; +} + +void obj3_setup(void) +{ + obj3_class = class_new(gensym("obj3"), (t_newmethod)obj3_new, + 0, sizeof(t_obj3), 0, 0); + class_addmethod(obj3_class, (t_method)obj3_ft1, gensym("ft1"), A_FLOAT, 0); + class_addfloat(obj3_class, obj3_float); +} + diff --git a/pd/doc/6.externs/obj4.c b/pd/doc/6.externs/obj4.c new file mode 100644 index 00000000..3da2a84a --- /dev/null +++ b/pd/doc/6.externs/obj4.c @@ -0,0 +1,47 @@ +/* code for the "obj4" pd class. This adds a creation argument, of +type "float". */ + +#include "m_pd.h" + +typedef struct obj4 +{ + t_object x_ob; + t_outlet *x_outlet; + float x_value; +} t_obj4; + +void obj4_float(t_obj4 *x, t_floatarg f) +{ + outlet_float(x->x_outlet, x->x_value + f); +} + +void obj4_ft1(t_obj4 *x, t_floatarg g) +{ + x->x_value = g; +} + +t_class *obj4_class; + + /* as requested by the new invocation of "class_new" below, the new + routine will be called with a "float" argument. */ +void *obj4_new(t_floatarg f) +{ + t_obj4 *x = (t_obj4 *)pd_new(obj4_class); + inlet_new(&x->x_ob, &x->x_ob.ob_pd, gensym("float"), gensym("ft1")); + x->x_outlet = outlet_new(&x->x_ob, gensym("float")); + /* just stick the argument in the object structure for later. */ + x->x_value = f; + return (void *)x; +} + +void obj4_setup(void) +{ + /* here we add "A_DEFFLOAT" to the (zero-terminated) list of arg + types we declare for a new object. The value will be filled + in as 0 if not given in the object box. */ + obj4_class = class_new(gensym("obj4"), (t_newmethod)obj4_new, + 0, sizeof(t_obj4), 0, A_DEFFLOAT, 0); + class_addmethod(obj4_class, (t_method)obj4_ft1, gensym("ft1"), A_FLOAT, 0); + class_addfloat(obj4_class, obj4_float); +} + diff --git a/pd/doc/6.externs/obj5.c b/pd/doc/6.externs/obj5.c new file mode 100644 index 00000000..687c8e0a --- /dev/null +++ b/pd/doc/6.externs/obj5.c @@ -0,0 +1,54 @@ +/* code for the "obj5" pd class. This shows "gimme" arguments, which have +variable arguments parsed by the routines (both "new" and "rats".) */ + +#include "m_pd.h" + +typedef struct obj5 +{ + t_object x_ob; +} t_obj5; + + /* the "rats" method is called with the selector (just "rats" again) + and an array of the typed areguments, which are each either a number + or a symbol. We just print them out. */ +void obj5_rats(t_obj5 *x, t_symbol *selector, int argcount, t_atom *argvec) +{ + int i; + post("rats: selector %s", selector->s_name); + for (i = 0; i < argcount; i++) + { + if (argvec[i].a_type == A_FLOAT) + post("float: %f", argvec[i].a_w.w_float); + else if (argvec[i].a_type == A_SYMBOL) + post("symbol: %s", argvec[i].a_w.w_symbol->s_name); + } +} + +t_class *obj5_class; + + /* same for the "new" (creation) routine, except that we don't have + "x" as an argument since we have to create "x" in this routine. */ +void *obj5_new(t_symbol *selector, int argcount, t_atom *argvec) +{ + t_obj5 *x = (t_obj5 *)pd_new(obj5_class); + int i; + post("new: selector %s", selector->s_name); + for (i = 0; i < argcount; i++) + { + if (argvec[i].a_type == A_FLOAT) + post("float: %f", argvec[i].a_w.w_float); + else if (argvec[i].a_type == A_SYMBOL) + post("symbol: %s", argvec[i].a_w.w_symbol->s_name); + } + return (void *)x; +} + +void obj5_setup(void) +{ + /* We specify "A_GIMME" as creation argument for both the creation + routine and the method (callback) for the "rats" message. */ + obj5_class = class_new(gensym("obj5"), (t_newmethod)obj5_new, + 0, sizeof(t_obj5), 0, A_GIMME, 0); + class_addmethod(obj5_class, (t_method)obj5_rats, gensym("rats"), A_GIMME, 0); +} + diff --git a/pd/doc/6.externs/test-obj1.pd b/pd/doc/6.externs/test-obj1.pd new file mode 100644 index 00000000..f50ce449 --- /dev/null +++ b/pd/doc/6.externs/test-obj1.pd @@ -0,0 +1,6 @@ +#N canvas 68 38 317 151 12; +#X msg 68 52 5; +#X msg 100 52 rats; +#X obj 67 90 obj1; +#X connect 0 0 2 0; +#X connect 1 0 2 0; diff --git a/pd/doc/6.externs/test-obj2.pd b/pd/doc/6.externs/test-obj2.pd new file mode 100644 index 00000000..1d3fd191 --- /dev/null +++ b/pd/doc/6.externs/test-obj2.pd @@ -0,0 +1,8 @@ +#N canvas 62 333 310 157 12; +#X msg 109 51 rats; +#X msg 157 52 7; +#X msg 68 52 4; +#X obj 68 90 obj2; +#X connect 0 0 3 0; +#X connect 1 0 3 1; +#X connect 2 0 3 0; diff --git a/pd/doc/6.externs/test-obj3.pd b/pd/doc/6.externs/test-obj3.pd new file mode 100644 index 00000000..1072a4af --- /dev/null +++ b/pd/doc/6.externs/test-obj3.pd @@ -0,0 +1,8 @@ +#N canvas 128 288 310 157 12; +#X obj 68 91 obj3; +#X floatatom 67 61 3 0 0 0 - - -; +#X floatatom 108 59 3 0 0 0 - - -; +#X floatatom 70 118 3 0 0 0 - - -; +#X connect 0 0 3 0; +#X connect 1 0 0 0; +#X connect 2 0 0 1; diff --git a/pd/doc/6.externs/test-obj4.pd b/pd/doc/6.externs/test-obj4.pd new file mode 100644 index 00000000..619012f5 --- /dev/null +++ b/pd/doc/6.externs/test-obj4.pd @@ -0,0 +1,6 @@ +#N canvas 128 288 310 157 12; +#X floatatom 67 61 3 0 0 0 - - -; +#X floatatom 70 118 3 0 0 0 - - -; +#X obj 68 91 obj4 34; +#X connect 0 0 2 0; +#X connect 2 0 1 0; diff --git a/pd/doc/6.externs/test-obj5.pd b/pd/doc/6.externs/test-obj5.pd new file mode 100644 index 00000000..550f34a1 --- /dev/null +++ b/pd/doc/6.externs/test-obj5.pd @@ -0,0 +1,4 @@ +#N canvas 128 288 310 157 12; +#X obj 15 74 obj5 1 2 3 cis boom bah; +#X msg 15 30 rats 4 5 6 tara tara boum boum; +#X connect 1 0 0 0; -- cgit v1.2.1