1 /* code for the "obj5" pd class. This shows "gimme" arguments, which have
2 variable arguments parsed by the routines (both "new" and "rats".) */
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
)
17 post("rats: selector %s", selector
->s_name
);
18 for (i
= 0; i
< argcount
; i
++)
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
);
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
)
33 t_obj5
*x
= (t_obj5
*)pd_new(obj5_class
);
35 post("new: selector %s", selector
->s_name
);
36 for (i
= 0; i
< argcount
; i
++)
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
);
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);
This page took 1.082541 seconds and 4 git commands to generate.