aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arraysize.c53
-rw-r--r--arraysize.dllbin0 -> 36864 bytes
-rwxr-xr-xarraysize.pd_linuxbin0 -> 3592 bytes
-rw-r--r--makefile12
4 files changed, 65 insertions, 0 deletions
diff --git a/arraysize.c b/arraysize.c
new file mode 100644
index 0000000..2c5f5f6
--- /dev/null
+++ b/arraysize.c
@@ -0,0 +1,53 @@
+/* This code is too trivial to have a licence or copyright */
+
+/*
+ arraysize -- report the size of an array
+
+ usage: |arraysize <array name>|
+
+ methods: bang, set <array name>
+*/
+
+#include <m_pd.h>
+
+static t_class *arraysize_class;
+
+typedef struct _arraysize {
+ t_object x_obj;
+ t_symbol *array_name;
+} t_arraysize;
+
+void arraysize_set(t_arraysize *x, t_symbol *s)
+{
+ x->array_name = s;
+}
+
+void arraysize_bang(t_arraysize *x)
+{
+ t_garray *garray;
+
+ if(!(garray = (t_garray *)pd_findbyclass(x->array_name,garray_class))) {
+ pd_error(x, "%s: no such table", x->array_name->s_name);
+ } else {
+ outlet_float(x->x_obj.ob_outlet, garray_npoints(garray));
+ }
+}
+
+void *arraysize_new(t_symbol *s)
+{
+ t_arraysize *x = (t_arraysize *)pd_new(arraysize_class);
+
+ outlet_new(&x->x_obj, gensym("float"));
+
+ x->array_name = s;
+
+ return (void *)x;
+}
+
+void arraysize_setup(void)
+{
+ arraysize_class = class_new(gensym("arraysize"), (t_newmethod)arraysize_new, 0, sizeof(t_arraysize), CLASS_DEFAULT, A_DEFSYMBOL, 0);
+
+ class_addmethod(arraysize_class,arraysize_set,gensym("set"), A_DEFSYM, 0);
+ class_addbang(arraysize_class,arraysize_bang);
+}
diff --git a/arraysize.dll b/arraysize.dll
new file mode 100644
index 0000000..61c4ef2
--- /dev/null
+++ b/arraysize.dll
Binary files differ
diff --git a/arraysize.pd_linux b/arraysize.pd_linux
new file mode 100755
index 0000000..1e819ac
--- /dev/null
+++ b/arraysize.pd_linux
Binary files differ
diff --git a/makefile b/makefile
new file mode 100644
index 0000000..b284b4a
--- /dev/null
+++ b/makefile
@@ -0,0 +1,12 @@
+# just the build-commands
+
+I = -I../../../bin/pd/src
+
+all: linux
+
+linux:
+ cc -DPD -O2 -DUNIX $(I) -o arraysize.o -c arraysize.c
+ ld -shared -export_dynamic -o arraysize.pd_linux arraysize.o
+
+nt:
+ cl arraysize.c /DNT /DPD /LD /Gd /GD /Ox /link /export:arraysize_setup \system\pd\bin\pd.lib