From 2b60d55c919e7588f5aff15936e83c300b3660bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Tue, 22 Mar 2005 20:58:25 +0000 Subject: zexy-2.0: - use of abstractions for objects that allow it - some objects are build both as externals and abstractions (as slower fallbacks) - code-layout is now 1:1 c-file<->object (this should allow for building of zexy as a collection of externals instead as a big library) - matrix-objects have moved to iemmatrix !! svn path=/trunk/externals/zexy/; revision=2641 --- src/length.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/length.c (limited to 'src/length.c') diff --git a/src/length.c b/src/length.c new file mode 100644 index 0000000..9ed19e1 --- /dev/null +++ b/src/length.c @@ -0,0 +1,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 + +#ifdef MACOSX +#define sqrtf sqrt +#endif + + +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"); +} -- cgit v1.2.1