aboutsummaryrefslogtreecommitdiff
path: root/src/length.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/length.c')
-rw-r--r--src/length.c61
1 files changed, 61 insertions, 0 deletions
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 <math.h>
+
+#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");
+}