aboutsummaryrefslogtreecommitdiff
path: root/src/lister.c
diff options
context:
space:
mode:
authorIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2005-03-22 20:58:25 +0000
committerIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2005-03-22 20:58:25 +0000
commit2b60d55c919e7588f5aff15936e83c300b3660bb (patch)
tree14d860de7f28083d3756ad91b627de70f26788f6 /src/lister.c
parentc500bc542cb7cc78d6dac3f7da3bff626056b1aa (diff)
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
Diffstat (limited to 'src/lister.c')
-rw-r--r--src/lister.c84
1 files changed, 84 insertions, 0 deletions
diff --git a/src/lister.c b/src/lister.c
new file mode 100644
index 0000000..6e732ad
--- /dev/null
+++ b/src/lister.c
@@ -0,0 +1,84 @@
+/******************************************************
+ *
+ * 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
+ *
+ ******************************************************/
+
+/* 2305:forum::für::umläute:2001 */
+
+
+#include "zexy.h"
+
+/* ------------------------- list ------------------------------- */
+
+/* this is for packages, what "float" is for floats */
+
+static t_class *mypdlist_class;
+
+static void mypdlist_secondlist(t_mypdlist *x, t_symbol *s, int argc, t_atom *argv)
+{
+ if (argc) {
+ if (x->x_n != argc) {
+ freebytes(x->x_list, x->x_n * sizeof(t_atom));
+ x->x_n = argc;
+ x->x_list = copybytes(argv, argc * sizeof(t_atom));
+ } else memcpy(x->x_list, argv, argc * sizeof(t_atom));
+ }
+}
+
+static void mypdlist_list(t_mypdlist *x, t_symbol *s, int argc, t_atom *argv)
+{
+ if (x->x_n != argc) {
+ freebytes(x->x_list, x->x_n * sizeof(t_atom));
+ x->x_n = argc;
+ x->x_list = copybytes(argv, argc * sizeof(t_atom));
+ } else memcpy(x->x_list, argv, argc * sizeof(t_atom));
+
+ outlet_list(x->x_obj.ob_outlet, gensym("list"), x->x_n, x->x_list);
+}
+static void mypdlist_bang(t_mypdlist *x)
+{ outlet_list(x->x_obj.ob_outlet, gensym("list"), x->x_n, x->x_list);}
+
+static void mypdlist_free(t_mypdlist *x)
+{ freebytes(x->x_list, x->x_n * sizeof(t_atom)); }
+
+static void *mypdlist_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_mypdlist *x = (t_mypdlist *)pd_new(mypdlist_class);
+
+ outlet_new(&x->x_obj, 0);
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("list"), gensym("lst2"));
+
+ x->x_n = 0;
+ x->x_list = 0;
+
+ mypdlist_secondlist(x, gensym("list"), argc, argv);
+
+ return (x);
+}
+
+void lister_setup(void)
+{
+ mypdlist_class = class_new(gensym("lister"), (t_newmethod)mypdlist_new,
+ (t_method)mypdlist_free, sizeof(t_mypdlist), 0, A_GIMME, 0);
+ /* i don't know how to get this work with name=="list" !!! */
+
+ class_addcreator((t_newmethod)mypdlist_new, gensym("l"), A_GIMME, 0);
+
+ class_addbang (mypdlist_class, mypdlist_bang);
+ class_addlist (mypdlist_class, mypdlist_list);
+ class_addmethod (mypdlist_class, (t_method)mypdlist_secondlist, gensym("lst2"), A_GIMME, 0);
+
+ class_sethelpsymbol(mypdlist_class, gensym("zexy/lister"));
+ zexy_register("lister");
+}