aboutsummaryrefslogtreecommitdiff
path: root/pd/doc/6.externs/obj5.c
diff options
context:
space:
mode:
authorGuenter Geiger <ggeiger@users.sourceforge.net>2003-05-09 16:04:00 +0000
committerGuenter Geiger <ggeiger@users.sourceforge.net>2003-05-09 16:04:00 +0000
commit9c0e19a3be2288db79e2502e5fa450c3e20a668d (patch)
treeca97ce615e037a533304fc4660dcf372ca3b9cd6 /pd/doc/6.externs/obj5.c
parentef50dd62804d54af7da18d8bd8413c0dccd729b8 (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/obj5.c')
-rw-r--r--pd/doc/6.externs/obj5.c54
1 files changed, 54 insertions, 0 deletions
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);
+}
+