aboutsummaryrefslogtreecommitdiff
path: root/tcl_proxyinlet.cxx
diff options
context:
space:
mode:
authormescalinum <mescalinum@users.sourceforge.net>2009-08-30 17:47:51 +0000
committermescalinum <mescalinum@users.sourceforge.net>2009-08-30 17:47:51 +0000
commitc167e87a54010687abfdc2d5b09862cce3f0387b (patch)
tree13b954ace0518174288db1b4fc15c1973f94c170 /tcl_proxyinlet.cxx
parentd780c1e9b84d4710e80f952415dfdba48cdea6a3 (diff)
add of proxyinlet
svn path=/trunk/externals/tclpd/; revision=12145
Diffstat (limited to 'tcl_proxyinlet.cxx')
-rw-r--r--tcl_proxyinlet.cxx89
1 files changed, 89 insertions, 0 deletions
diff --git a/tcl_proxyinlet.cxx b/tcl_proxyinlet.cxx
new file mode 100644
index 0000000..de97ec0
--- /dev/null
+++ b/tcl_proxyinlet.cxx
@@ -0,0 +1,89 @@
+#include "tcl_extras.h"
+
+t_class* proxyinlet_class;
+
+void proxyinlet_init(t_proxyinlet* x) {
+ //x->pd = proxyinlet_class;
+ x->target = NULL;
+ x->sel = gensym("none");
+ x->argc = 0;
+ x->argv = NULL;
+}
+
+void proxyinlet_clear(t_proxyinlet* x) {
+ if(x->argv) {
+ freebytes(x->argv, x->argc * sizeof(*x->argv));
+ }
+}
+
+void proxyinlet_list(t_proxyinlet* x, t_symbol* s, int argc, t_atom* argv) {
+ proxyinlet_clear(x);
+
+ if(!(x->argv = (t_atom*)getbytes(argc * sizeof(*x->argv)))) {
+ x->argc = 0;
+ error("proxyinlet: getbytes: out of memory");
+ return;
+ }
+
+ x->argc = argc;
+ int i;
+ for(i = 0; i < argc; i++) {
+ x->argv[i] = argv[i];
+ }
+
+ proxyinlet_trigger(x);
+}
+
+void proxyinlet_anything(t_proxyinlet* x, t_symbol* s, int argc, t_atom* argv) {
+ proxyinlet_clear(x);
+
+ if(!(x->argv = (t_atom*)getbytes((argc+1) * sizeof(*x->argv)))) {
+ x->argc = 0;
+ error("proxyinlet: getbytes: out of memory");
+ return;
+ }
+
+ x->argc = argc + 1;
+ SETSYMBOL(&x->argv[0], s);
+
+ int i;
+ for(i = 0; i < argc; i++) {
+ x->argv[i+1] = argv[i];
+ }
+
+ proxyinlet_trigger(x);
+}
+
+void proxyinlet_trigger(t_proxyinlet* x) {
+ if(x->target != NULL && x->sel != gensym("none")) {
+ tclpd_anything(x->target, x->sel, x->argc, x->argv);
+ }
+}
+
+t_atom* proxyinlet_get_atoms(t_proxyinlet* x) {
+ return x->argv;
+}
+
+void proxyinlet_clone(t_proxyinlet* x, t_proxyinlet* y) {
+ y->target = x->target;
+ y->sel = x->sel;
+
+ y->argc = x->argc;
+ if(!(y->argv = (t_atom*)getbytes(y->argc * sizeof(*y->argv)))) {
+ y->argc = 0;
+ error("proxyinlet: getbytes: out of memory");
+ return;
+ }
+
+ int i;
+ for(i = 0; i < x->argc; i++) {
+ y->argv[i] = x->argv[i];
+ }
+}
+
+void proxyinlet_setup(void) {
+ proxyinlet_class = class_new(gensym("tclpd proxyinlet"),
+ 0, 0, sizeof(t_proxyinlet), 0, A_NULL);
+ class_addlist(proxyinlet_class, proxyinlet_list);
+ class_addanything(proxyinlet_class, proxyinlet_anything);
+}