From 7c697a69567e99603882176552c5abf0c66f39f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juha=20Vehvil=C3=A4inen?= Date: Thu, 20 Jun 2002 11:25:52 +0000 Subject: source import svn path=/trunk/externals/arraysize/; revision=16 --- arraysize.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ arraysize.dll | Bin 0 -> 36864 bytes arraysize.pd_linux | Bin 0 -> 3592 bytes makefile | 12 ++++++++++++ 4 files changed, 65 insertions(+) create mode 100644 arraysize.c create mode 100644 arraysize.dll create mode 100755 arraysize.pd_linux create mode 100644 makefile 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 | + + methods: bang, set +*/ + +#include + +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 Binary files /dev/null and b/arraysize.dll differ diff --git a/arraysize.pd_linux b/arraysize.pd_linux new file mode 100755 index 0000000..1e819ac Binary files /dev/null and b/arraysize.pd_linux 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 -- cgit v1.2.1