From f3e255ddca6468b6adea0f10f30540c37cdde9ad Mon Sep 17 00:00:00 2001 From: "N.N." Date: Tue, 18 Sep 2007 17:19:03 +0000 Subject: first commit for tclpd external svn path=/trunk/externals/tclpd/; revision=8736 --- tcl_extras.cxx | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 tcl_extras.cxx (limited to 'tcl_extras.cxx') diff --git a/tcl_extras.cxx b/tcl_extras.cxx new file mode 100644 index 0000000..556546f --- /dev/null +++ b/tcl_extras.cxx @@ -0,0 +1,81 @@ +#include "tcl_extras.h" +#include +#include + +using namespace std; + +static long cereal=0; +map class_table; +map object_table; + +void poststring2 (const char *s) {post("%s",s);} + +static void *tclpd_init (t_symbol *classsym, int ac, t_atom *at) { + const char *name = classsym->s_name; + t_class *qlass = class_table[string(name)]; + t_tcl *self = (t_tcl *)pd_new(qlass); + char s[32]; + sprintf(s,"pd%06lx",cereal++); + self->self = Tcl_NewStringObj(s,strlen(s)); + object_table[string(s)] = (t_pd*)self; + Tcl_IncrRefCount(self->self); + Tcl_Obj *av[ac+2]; + av[0] = Tcl_NewStringObj(name,strlen(name)); + av[1] = self->self; + for(int i=0; io; +} + +t_pd* tclpd_get_object_pd(const char* cereal) { + t_object* o = tclpd_get_object(cereal); + return &o->ob_pd; +} + +static void tclpd_anything (t_tcl *self, t_symbol *s, int ac, t_atom *at) { + /* proxy method */ + Tcl_Obj *av[ac+2]; + av[0] = self->self; + av[1] = Tcl_NewIntObj(0); // TODO: 0 -> outlet_number + Tcl_AppendToObj(av[1],"_",1); + Tcl_AppendToObj(av[1],s->s_name,strlen(s->s_name)); // selector + for(int i=0; i