diff options
author | Guenter Geiger <ggeiger@users.sourceforge.net> | 2003-05-09 16:04:00 +0000 |
---|---|---|
committer | Guenter Geiger <ggeiger@users.sourceforge.net> | 2003-05-09 16:04:00 +0000 |
commit | 9c0e19a3be2288db79e2502e5fa450c3e20a668d (patch) | |
tree | ca97ce615e037a533304fc4660dcf372ca3b9cd6 /pd/doc/6.externs/obj1.c | |
parent | ef50dd62804d54af7da18d8bd8413c0dccd729b8 (diff) |
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
Diffstat (limited to 'pd/doc/6.externs/obj1.c')
-rw-r--r-- | pd/doc/6.externs/obj1.c | 47 |
1 files changed, 47 insertions, 0 deletions
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); +} + |