1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
/******************************************************
*
* zexy - implementation file
*
* copyleft (c) IOhannes m zmölnig
*
* 1999:forum::für::umläute:2004
*
* institute of electronic music and acoustics (iem)
*
******************************************************
*
* license: GNU General Public License v.2
******************************************************/
/* length :: get the length of a list */
#include "zexy.h"
#include <math.h>
static t_class *length_class;
typedef struct _length
{
t_object x_obj;
} t_length;
static void length_list(t_length *x, t_symbol *s, int argc, t_atom *argv)
{
outlet_float(x->x_obj.ob_outlet, (t_float)argc);
}
static void length_any(t_length *x, t_symbol *s, int argc, t_atom *argv)
{
outlet_float(x->x_obj.ob_outlet, (t_float)argc+1);
}
static void *length_new(void)
{
t_length *x = (t_length *)pd_new(length_class);
outlet_new(&x->x_obj, gensym("float"));
return (x);
}
void length_setup(void)
{
length_class = class_new(gensym("length"), (t_newmethod)length_new, 0,
sizeof(t_length), 0, A_DEFFLOAT, 0);
class_addlist(length_class, (t_method)length_list);
class_addanything(length_class, (t_method)length_any);
// class_addbang(length_class, (t_method)length_bang);
class_sethelpsymbol(length_class, gensym("zexy/length"));
zexy_register("length");
}
void z_length_setup(void)
{
length_setup();
}
|