aboutsummaryrefslogtreecommitdiff
path: root/src/unpack.c
diff options
context:
space:
mode:
authorIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2011-09-21 08:49:22 +0000
committerIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2011-09-21 08:49:22 +0000
commite8479343f6a6db1d28e362469dfafaccca378421 (patch)
tree1f3e175a64a53c17e98b82b9ecc26ba5468b5473 /src/unpack.c
parent4ef4a3097fbdf5f0a13d3f5b3e60cdbb02fe1671 (diff)
allow anythings for pack/unpack
svn path=/trunk/externals/zexy/; revision=15326
Diffstat (limited to 'src/unpack.c')
-rw-r--r--src/unpack.c56
1 files changed, 38 insertions, 18 deletions
diff --git a/src/unpack.c b/src/unpack.c
index 0ec3641..c18861c 100644
--- a/src/unpack.c
+++ b/src/unpack.c
@@ -1,21 +1,30 @@
-/******************************************************
+/*
+ * unpack: a type-agnostic version of [unpack]
*
- * zexy - implementation file
+ * (c) 2007-2011 IOhannes m zmölnig, forum::für::umläute, institute of electronic music and acoustics (iem)
*
- * copyleft (c) IOhannes m zmölnig
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+/*
+
+/*
+ * this version of [unpack] does not care about types, so the arguments are merely there for documentation reasons
+ * (and to determine the number of outlets)
+ * e.g. sending [symbol foo( to [zexy/unpack 0] will output [symbol foo(
*
- * 1999:forum::für::umläute:2004
- *
- * institute of electronic music and acoustics (iem)
- *
- ******************************************************
- *
- * license: GNU General Public License v.2
- *
- ******************************************************/
-
+ * for know this object is named [zexy/unpack], as there might be some issues with compatibility with the original [unpack]
+ */
-/* 2305:forum::für::umläute:2001 */
#include "zexy.h"
@@ -32,13 +41,23 @@ typedef struct _zunpack
t_int x_numouts;
} t_zunpack;
-static void zunpack_list(t_zunpack *x, t_symbol *s, int argc, t_atom *argv)
+static void zunpack_any(t_zunpack *x, t_symbol *s, int argc, t_atom *argv)
{
- int count=(argc<(x->x_numouts))?argc:x->x_numouts;
+ int offset=(s!=NULL)?1:0;
+ int count=((argc+offset)<(x->x_numouts))?(argc+offset):x->x_numouts;
- while(count--) {
- outlet_list(x->x_out[count], gensym("list"), 1, argv+count);
+ while(count-->offset) {
+ outlet_list(x->x_out[count], gensym("list"), 1, argv+count-offset);
}
+
+ if(s!=NULL) {
+ outlet_symbol(x->x_out[0], s);
+ }
+}
+
+static void zunpack_list(t_zunpack *x, t_symbol *s, int argc, t_atom *argv)
+{
+ zunpack_any(x, 0, argc, argv);
}
static void zunpack_bang(t_zunpack *x)
@@ -88,6 +107,7 @@ void zunpack_setup(void)
class_addbang(zunpack_class, zunpack_bang);
class_addlist(zunpack_class, zunpack_list);
+ class_addanything(zunpack_class, zunpack_any);
zexy_register("unpack");
}