diff options
author | mescalinum <mescalinum@users.sourceforge.net> | 2011-10-02 16:34:46 +0000 |
---|---|---|
committer | mescalinum <mescalinum@users.sourceforge.net> | 2011-10-02 16:34:46 +0000 |
commit | 5a38f01421e93db2cf5b5c05afe84fb73eb89425 (patch) | |
tree | 825f100374b98c48c0823e6478c0f456a792e715 /tcl_proxyinlet.c | |
parent | 6b6325b951082d49c6c355d59f808783e99738c2 (diff) |
mv *.cxx *.c
svn path=/trunk/externals/loaders/tclpd/; revision=15442
Diffstat (limited to 'tcl_proxyinlet.c')
-rw-r--r-- | tcl_proxyinlet.c | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/tcl_proxyinlet.c b/tcl_proxyinlet.c new file mode 100644 index 0000000..e1cdb48 --- /dev/null +++ b/tcl_proxyinlet.c @@ -0,0 +1,73 @@ +#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)); + } +} + +#define PROXYINLET_SEL_TO_LIST 0 // 0 or 1 + +void proxyinlet_anything(t_proxyinlet* x, t_symbol* s, int argc, t_atom* argv) { + proxyinlet_clear(x); + + if(!(x->argv = (t_atom*)getbytes((argc+PROXYINLET_SEL_TO_LIST) * sizeof(*x->argv)))) { + x->argc = 0; + error("proxyinlet: getbytes: out of memory"); + return; + } + + x->argc = argc + PROXYINLET_SEL_TO_LIST; + if(PROXYINLET_SEL_TO_LIST == 1) SETSYMBOL(&x->argv[0], s); + else x->sel = s; + + int i; + for(i = 0; i < argc; i++) { + x->argv[i+PROXYINLET_SEL_TO_LIST] = argv[i]; + } + + proxyinlet_trigger(x); +} + +void proxyinlet_trigger(t_proxyinlet* x) { + if(x->target != NULL && x->sel != gensym("none")) { + tclpd_inlet_anything(x->target, x->ninlet, 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_addanything(proxyinlet_class, proxyinlet_anything); +} |