Added experimental makepkg-update-checksums.sh
[mirrors/Programs.git] / puredata / 6.externs / obj5.c
1 /* code for the "obj5" pd class. This shows "gimme" arguments, which have
2 variable arguments parsed by the routines (both "new" and "rats".) */
3
4 #include "m_pd.h"
5
6 typedef struct obj5
7 {
8 t_object x_ob;
9 } t_obj5;
10
11 /* the "rats" method is called with the selector (just "rats" again)
12 and an array of the typed areguments, which are each either a number
13 or a symbol. We just print them out. */
14 void obj5_rats(t_obj5 *x, t_symbol *selector, int argcount, t_atom *argvec)
15 {
16 int i;
17 post("rats: selector %s", selector->s_name);
18 for (i = 0; i < argcount; i++)
19 {
20 if (argvec[i].a_type == A_FLOAT)
21 post("float: %f", argvec[i].a_w.w_float);
22 else if (argvec[i].a_type == A_SYMBOL)
23 post("symbol: %s", argvec[i].a_w.w_symbol->s_name);
24 }
25 }
26
27 t_class *obj5_class;
28
29 /* same for the "new" (creation) routine, except that we don't have
30 "x" as an argument since we have to create "x" in this routine. */
31 void *obj5_new(t_symbol *selector, int argcount, t_atom *argvec)
32 {
33 t_obj5 *x = (t_obj5 *)pd_new(obj5_class);
34 int i;
35 post("new: selector %s", selector->s_name);
36 for (i = 0; i < argcount; i++)
37 {
38 if (argvec[i].a_type == A_FLOAT)
39 post("float: %f", argvec[i].a_w.w_float);
40 else if (argvec[i].a_type == A_SYMBOL)
41 post("symbol: %s", argvec[i].a_w.w_symbol->s_name);
42 }
43 return (void *)x;
44 }
45
46 void obj5_setup(void)
47 {
48 /* We specify "A_GIMME" as creation argument for both the creation
49 routine and the method (callback) for the "rats" message. */
50 obj5_class = class_new(gensym("obj5"), (t_newmethod)obj5_new,
51 0, sizeof(t_obj5), 0, A_GIMME, 0);
52 class_addmethod(obj5_class, (t_method)obj5_rats, gensym("rats"), A_GIMME, 0);
53 }
54
This page took 1.082541 seconds and 4 git commands to generate.