Update of /cvsroot/pure-data/externals/clr
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16855/clr
Modified Files:
clr.cpp test-clr.pd
Log Message:
implemented proxy objects and other stuff
cleaned up the code
Index: test-clr.pd
===================================================================
RCS file: /cvsroot/pure-data/externals/clr/test-clr.pd,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** test-clr.pd 8 Mar 2006 16:48:29 -0000 1.11
--- test-clr.pd 9 Mar 2006 01:48:21 -0000 1.12
***************
*** 1,3 ****
! #N canvas 617 153 818 585 12;
#X floatatom 125 51 5 0 0 0 - - -;
#X symbolatom 320 81 10 0 0 0 - - -;
--- 1,3 ----
! #N canvas 617 153 842 609 12;
#X floatatom 125 51 5 0 0 0 - - -;
#X symbolatom 320 81 10 0 0 0 - - -;
***************
*** 24,28 ****
#X obj 554 465 r receiver2;
#X obj 555 499 print RECV2;
! #X text 585 318 bang to see;
#X connect 0 0 3 0;
#X connect 1 0 3 0;
--- 24,35 ----
#X obj 554 465 r receiver2;
#X obj 555 499 print RECV2;
! #X floatatom 526 362 5 0 0 0 - - -;
! #X symbolatom 578 364 10 0 0 0 - - -;
! #X text 585 318 passive - bang to see;
! #X text 676 366 active;
! #X msg 526 386 1 2 3;
! #X floatatom 528 275 5 0 0 0 - - -;
! #X msg 589 386 turalu;
! #X msg 578 274 heyho;
#X connect 0 0 3 0;
#X connect 1 0 3 0;
***************
*** 45,46 ****
--- 52,59 ----
#X connect 20 0 19 0;
#X connect 21 0 22 0;
+ #X connect 23 0 3 3;
+ #X connect 24 0 3 3;
+ #X connect 27 0 3 3;
+ #X connect 28 0 3 1;
+ #X connect 29 0 3 3;
+ #X connect 30 0 3 1;
Index: clr.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/clr/clr.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** clr.cpp 8 Mar 2006 17:37:25 -0000 1.10
--- clr.cpp 9 Mar 2006 01:48:21 -0000 1.11
***************
*** 28,31 ****
--- 28,32 ----
#include <map>
#include <vector>
+ #include <list>
#define CORELIB "PureData"
***************
*** 52,57 ****
// temporary workspace items
! static MonoArray *clr_objarr_1,*clr_objarr_2;
! static MonoObject *clr_obj_single,*clr_obj_symbol,*clr_obj_pointer,*clr_obj_atomlist;
static float *clr_val_single;
static t_symbol **clr_val_symbol;
--- 53,59 ----
// temporary workspace items
! static MonoArray *clr_objarr_1,*clr_objarr_3;
! static MonoObject *clr_obj_int,*clr_obj_single,*clr_obj_symbol,*clr_obj_pointer,*clr_obj_atomlist;
! static int *clr_val_int;
static float *clr_val_single;
static t_symbol **clr_val_symbol;
***************
*** 60,74 ****
struct Delegate
{
! operator bool() const { return methodinfo != NULL; }
MonoObject *methodinfo;
MonoMethod *virtmethod;
};
typedef std::map<t_symbol *,Delegate> ClrMethodMap;
!
// this is the class structure
--- 62,137 ----
+ struct t_clr;
struct Delegate
{
! enum Kind { k_bang,k_float,k_symbol,k_pointer,k_list,k_anything };
!
! inline operator bool() const { return methodinfo != NULL; }
MonoObject *methodinfo;
MonoMethod *virtmethod;
+ Kind kind;
+
+ inline void init(MonoObject *method,Kind k)
+ {
+ methodinfo = mono_property_get_value(clr_prop_method,method,NULL,NULL);
+ virtmethod = mono_object_get_virtual_method(methodinfo,clr_meth_invoke);
+ kind = k;
+ }
+
+ inline MonoObject *operator()(MonoObject *obj,void *arg = NULL) const
+ {
+ gpointer args[2] = {obj,arg};
+ assert(methodinfo);
+ MonoObject *exc;
+ mono_runtime_invoke(virtmethod,methodinfo,args,&exc);
+ return exc;
+ }
+
+ inline MonoObject *invokeatom(MonoObject *obj,MonoObject *atom) const
+ {
+ mono_array_set(clr_objarr_1,void*,0,atom);
+ return operator()(obj,clr_objarr_1);
+ }
+
+ inline MonoObject *operator()(MonoObject *obj,float f) const
+ {
+ *clr_val_single = f;
+ return invokeatom(obj,clr_obj_single);
+ }
+
+ inline MonoObject *operator()(MonoObject *obj,t_symbol *s) const
+ {
+ *clr_val_symbol = s;
+ return invokeatom(obj,clr_obj_symbol);
+ }
+
+ inline MonoObject *operator()(MonoObject *obj,t_gpointer *p) const
+ {
+ *clr_val_pointer = p;
+ return invokeatom(obj,clr_obj_pointer);
+ }
+
+ inline MonoObject *operator()(MonoObject *obj,int argc,t_atom *argv) const
+ {
+ clr_val_atomlist->Set(argc,argv);
+ return invokeatom(obj,clr_obj_atomlist);
+ }
+
+ inline MonoObject *operator()(MonoObject *obj,int inlet,t_symbol *s,int argc,t_atom *argv) const
+ {
+ *clr_val_int = inlet;
+ *clr_val_symbol = s;
+ clr_val_atomlist->Set(argc,argv);
+ mono_array_set(clr_objarr_3,void*,0,clr_obj_int);
+ mono_array_set(clr_objarr_3,void*,1,clr_obj_symbol);
+ mono_array_set(clr_objarr_3,void*,2,clr_obj_atomlist);
+ return operator()(obj,clr_objarr_3);
+ }
};
typedef std::map<t_symbol *,Delegate> ClrMethodMap;
! typedef std::vector<ClrMethodMap *> ClrMethods;
// this is the class structure
***************
*** 83,87 ****
t_symbol *name;
Delegate method_bang,method_float,method_symbol,method_pointer,method_list,method_anything;
! ClrMethodMap *methods; // explicit method selectors
};
--- 146,159 ----
t_symbol *name;
Delegate method_bang,method_float,method_symbol,method_pointer,method_list,method_anything;
! ClrMethods *methods; // explicit method selectors
! };
!
! static t_class *proxy_class;
!
! struct t_proxy
! {
! t_object pd_obj; // myself
! t_clr *parent; // parent object
! int inlet;
};
***************
*** 91,98 ****
--- 163,174 ----
typedef std::vector<t_outlet *> OutletArr;
+ typedef std::list<t_proxy *> ProxyList;
// this is the class to be setup (while we are in the CLR static Main method)
static t_clr_class *clr_setup_class = NULL;
+ // inlet index... must start with 0 every time a new object is made
+ static int clr_inlet;
+
// this is the class instance object structure
struct t_clr
***************
*** 102,105 ****
--- 178,182 ----
MonoObject *mono_obj; // the mono class instance
OutletArr *outlets;
+ ProxyList *proxies;
};
***************
*** 122,132 ****
{
assert(x && x->clr_clss);
!
! const Delegate &d = x->clr_clss->method_bang;
! assert(d);
!
! gpointer args[2] = {x->mono_obj,NULL};
! MonoObject *exc;
! mono_runtime_invoke(d.virtmethod,d.methodinfo,args,&exc);
if(exc) error_exc("Exception raised",x->clr_clss->name->s_name,exc);
}
--- 199,203 ----
{
assert(x && x->clr_clss);
! MonoObject *exc = x->clr_clss->method_bang(x->mono_obj);
if(exc) error_exc("Exception raised",x->clr_clss->name->s_name,exc);
}
***************
*** 135,148 ****
{
assert(x && x->clr_clss);
!
! const Delegate &d = x->clr_clss->method_float;
! assert(d);
!
! *clr_val_single = f;
! mono_array_set(clr_objarr_1,void*,0,clr_obj_single);
!
! gpointer args[2] = {x->mono_obj,clr_objarr_1};
! MonoObject *exc;
! mono_runtime_invoke(d.virtmethod,d.methodinfo,args,&exc);
if(exc) error_exc("Exception raised",x->clr_clss->name->s_name,exc);
}
--- 206,210 ----
{
assert(x && x->clr_clss);
! MonoObject *exc = x->clr_clss->method_float(x->mono_obj,f);
if(exc) error_exc("Exception raised",x->clr_clss->name->s_name,exc);
}
***************
*** 151,164 ****
{
assert(x && x->clr_clss);
!
! const Delegate &d = x->clr_clss->method_symbol;
! assert(d);
!
! *clr_val_symbol = s;
! mono_array_set(clr_objarr_1,void*,0,clr_obj_symbol);
!
! gpointer args[2] = {x->mono_obj,clr_objarr_1};
! MonoObject *exc;
! mono_runtime_invoke(d.virtmethod,d.methodinfo,args,&exc);
if(exc) error_exc("Exception raised",x->clr_clss->name->s_name,exc);
}
--- 213,217 ----
{
assert(x && x->clr_clss);
! MonoObject *exc = x->clr_clss->method_symbol(x->mono_obj,s);
if(exc) error_exc("Exception raised",x->clr_clss->name->s_name,exc);
}
***************
*** 167,239 ****
{
assert(x && x->clr_clss);
!
! const Delegate &d = x->clr_clss->method_pointer;
! assert(d);
!
! *clr_val_pointer = p;
! mono_array_set(clr_objarr_1,void*,0,clr_obj_pointer);
!
! gpointer args[2] = {x->mono_obj,clr_objarr_1};
! MonoObject *exc;
! mono_runtime_invoke(d.virtmethod,d.methodinfo,args,&exc);
if(exc) error_exc("Exception raised",x->clr_clss->name->s_name,exc);
}
! static void clr_method_list(t_clr *x,t_symbol *l, int argc, t_atom *argv)
{
assert(x && x->clr_clss);
!
! const Delegate &d = x->clr_clss->method_list;
! assert(d);
!
! clr_val_atomlist->Set(argc,argv);
! mono_array_set(clr_objarr_1,void*,0,clr_obj_atomlist);
!
! gpointer args[2] = {x->mono_obj,clr_objarr_1};
! MonoObject *exc;
! mono_runtime_invoke(d.virtmethod,d.methodinfo,args,&exc);
if(exc) error_exc("Exception raised",x->clr_clss->name->s_name,exc);
}
! static void clr_method_anything(t_clr *x,t_symbol *s,int argc,t_atom *argv)
{
assert(x && x->clr_clss);
! const Delegate *d = NULL;
! ClrMethodMap *methods = x->clr_clss->methods;
! if(methods) {
! ClrMethodMap::iterator it = methods->find(s);
! if(it != methods->end()) d = &it->second;
! }
!
! gpointer args[2];
! args[0] = x->mono_obj;
! if(d) {
! // explicit selector
! clr_val_atomlist->Set(argc,argv);
! mono_array_set(clr_objarr_1,void*,0,clr_obj_atomlist);
! args[1] = clr_objarr_1;
}
- else {
- // general method
! d = &x->clr_clss->method_anything;
! assert(d);
! *clr_val_symbol = s;
! clr_val_atomlist->Set(argc,argv);
! mono_array_set(clr_objarr_2,void*,0,clr_obj_symbol);
! mono_array_set(clr_objarr_2,void*,1,clr_obj_atomlist);
! args[1] = clr_objarr_2;
! }
MonoObject *exc;
! mono_runtime_invoke(d->virtmethod,d->methodinfo,args,&exc);
if(exc) error_exc("Exception raised",x->clr_clss->name->s_name,exc);
}
! // this function is called by mono when it wants post messages to pd
static void PD_Post(MonoString *str)
{
--- 220,303 ----
{
assert(x && x->clr_clss);
! MonoObject *exc = x->clr_clss->method_pointer(x->mono_obj,p);
if(exc) error_exc("Exception raised",x->clr_clss->name->s_name,exc);
}
! static void clr_method_list(t_clr *x,t_symbol *,int argc,t_atom *argv)
{
assert(x && x->clr_clss);
! MonoObject *exc = x->clr_clss->method_symbol(x->mono_obj,argc,argv);
if(exc) error_exc("Exception raised",x->clr_clss->name->s_name,exc);
}
! static void call_anything(t_clr *x,int inlet,t_symbol *s,int argc,t_atom *argv)
{
assert(x && x->clr_clss);
! const Delegate *d;
! ClrMethods *methods = x->clr_clss->methods;
! if(methods && inlet < (int)methods->size()) {
! ClrMethodMap *methmap = (*methods)[inlet];
! if(methmap) {
! ClrMethodMap::iterator it = methmap->find(s);
! if(it != methmap->end()) {
! d = &it->second;
! goto found;
! }
! if(inlet) {
! // search for NULL symbol pointer
! it = methmap->find(NULL);
! if(it != methmap->end()) {
! d = &it->second;
! goto found;
! }
! }
! }
}
! // no selectors: general method
! d = &x->clr_clss->method_anything;
! found:
!
! // we must have found something....
! assert(d);
MonoObject *exc;
! switch(d->kind) {
! case Delegate::k_bang:
! assert(argc == 0);
! exc = (*d)(x->mono_obj);
! break;
! case Delegate::k_float:
! assert(argc == 1 && argv[0].a_type == A_FLOAT);
! exc = (*d)(x->mono_obj,argv[0].a_w.w_float);
! break;
! case Delegate::k_symbol:
! assert(argc == 1 && argv[0].a_type == A_SYMBOL);
! exc = (*d)(x->mono_obj,argv[0].a_w.w_symbol);
! break;
! case Delegate::k_pointer:
! assert(argc == 1 && argv[0].a_type == A_POINTER);
! exc = (*d)(x->mono_obj,argv[0].a_w.w_gpointer);
! break;
! case Delegate::k_list:
! exc = (*d)(x->mono_obj,argc,argv);
! break;
! case Delegate::k_anything:
! exc = (*d)(x->mono_obj,inlet,s,argc,argv);
! break;
! default:
! assert(false);
! }
!
if(exc) error_exc("Exception raised",x->clr_clss->name->s_name,exc);
}
! static void clr_method_anything(t_clr *x,t_symbol *s,int argc,t_atom *argv) { call_anything(x,0,s,argc,argv); }
! static void clr_method_proxy(t_proxy *x,t_symbol *s,int argc,t_atom *argv) { call_anything(x->parent,x->inlet,s,argc,argv); }
!
static void PD_Post(MonoString *str)
{
***************
*** 241,245 ****
}
- // this function is called by mono when it wants post messages to pd
static void PD_PostError(MonoString *str)
{
--- 305,308 ----
***************
*** 247,257 ****
}
- // this function is called by mono when it wants post messages to pd
- static void PD_PostBug(MonoString *str)
- {
- bug("%s",mono_string_to_utf8(str));
- }
-
- // this function is called by mono when it wants post messages to pd
static void PD_PostVerbose(int lvl,MonoString *str)
{
--- 310,313 ----
***************
*** 271,338 ****
}
! static void PD_AddBang(MonoObject *method)
{
assert(clr_setup_class);
! Delegate &d = clr_setup_class->method_bang;
d.methodinfo = mono_property_get_value(clr_prop_method,method,NULL,NULL);
d.virtmethod = mono_object_get_virtual_method(d.methodinfo,clr_meth_invoke);
}
! static void PD_AddFloat(MonoObject *method)
{
! assert(clr_setup_class);
! Delegate &d = clr_setup_class->method_float;
! d.methodinfo = mono_property_get_value(clr_prop_method,method,NULL,NULL);
! d.virtmethod = mono_object_get_virtual_method(d.methodinfo,clr_meth_invoke);
}
! static void PD_AddSymbol(MonoObject *method)
{
! assert(clr_setup_class);
! Delegate &d = clr_setup_class->method_symbol;
! d.methodinfo = mono_property_get_value(clr_prop_method,method,NULL,NULL);
! d.virtmethod = mono_object_get_virtual_method(d.methodinfo,clr_meth_invoke);
}
! static void PD_AddPointer(MonoObject *method)
{
! assert(clr_setup_class);
! Delegate &d = clr_setup_class->method_pointer;
! d.methodinfo = mono_property_get_value(clr_prop_method,method,NULL,NULL);
! d.virtmethod = mono_object_get_virtual_method(d.methodinfo,clr_meth_invoke);
}
! static void PD_AddList(MonoObject *method)
{
! assert(clr_setup_class);
! Delegate &d = clr_setup_class->method_list;
! d.methodinfo = mono_property_get_value(clr_prop_method,method,NULL,NULL);
! d.virtmethod = mono_object_get_virtual_method(d.methodinfo,clr_meth_invoke);
}
! static void PD_AddSelector(t_symbol *sym,MonoObject *method)
{
! assert(clr_setup_class);
! Delegate d;
! d.methodinfo = mono_property_get_value(clr_prop_method,method,NULL,NULL);
! d.virtmethod = mono_object_get_virtual_method(d.methodinfo,clr_meth_invoke);
! if(!clr_setup_class->methods)
! clr_setup_class->methods = new ClrMethodMap;
! // add tag to map
! (*clr_setup_class->methods)[sym] = d;
}
! static void PD_AddAnything(MonoObject *method)
{
! assert(clr_setup_class);
! Delegate &d = clr_setup_class->method_anything;
! d.methodinfo = mono_property_get_value(clr_prop_method,method,NULL,NULL);
! d.virtmethod = mono_object_get_virtual_method(d.methodinfo,clr_meth_invoke);
}
! static void PD_AddInlet(t_clr *obj,t_symbol *sel,t_symbol *to_sel)
{
assert(obj);
t_inlet *in = inlet_new(&obj->pd_obj,&obj->pd_obj.ob_pd,sel,to_sel);
--- 327,424 ----
}
! static void PD_AddMethodHandler(int inlet,t_symbol *sym,MonoObject *method,Delegate::Kind kind)
{
assert(clr_setup_class);
! Delegate d;
d.methodinfo = mono_property_get_value(clr_prop_method,method,NULL,NULL);
d.virtmethod = mono_object_get_virtual_method(d.methodinfo,clr_meth_invoke);
+ d.kind = kind;
+
+ ClrMethods *ms = clr_setup_class->methods;
+ if(!ms)
+ clr_setup_class->methods = ms = new ClrMethods;
+
+ ClrMethodMap *m;
+ if(inlet >= (int)ms->size()) {
+ ms->resize(inlet+1,NULL);
+ (*ms)[inlet] = m = new ClrMethodMap;
+ }
+ else
+ m = (*ms)[inlet];
+ assert(m);
+
+ // add tag to map
+ (*m)[sym] = d;
}
! static void PD_AddMethodSelector(int inlet,t_symbol *sym,MonoObject *method)
{
! PD_AddMethodHandler(inlet,sym,method,Delegate::k_anything);
}
! static void PD_AddMethodBang(int inlet,MonoObject *method)
{
! if(inlet)
! PD_AddMethodHandler(inlet,&s_bang,method,Delegate::k_bang);
! else {
! assert(clr_setup_class);
! clr_setup_class->method_bang.init(method,Delegate::k_bang);
! }
}
! static void PD_AddMethodFloat(int inlet,MonoObject *method)
{
! if(inlet)
! PD_AddMethodHandler(inlet,&s_float,method,Delegate::k_float);
! else {
! assert(clr_setup_class);
! clr_setup_class->method_float.init(method,Delegate::k_float);
! }
}
! static void PD_AddMethodSymbol(int inlet,MonoObject *method)
{
! if(inlet)
! PD_AddMethodHandler(inlet,&s_symbol,method,Delegate::k_symbol);
! else {
! assert(clr_setup_class);
! clr_setup_class->method_symbol.init(method,Delegate::k_symbol);
! }
}
! static void PD_AddMethodPointer(int inlet,MonoObject *method)
{
! if(inlet)
! PD_AddMethodHandler(inlet,&s_pointer,method,Delegate::k_pointer);
! else {
! assert(clr_setup_class);
! clr_setup_class->method_pointer.init(method,Delegate::k_pointer);
! }
! }
! static void PD_AddMethodList(int inlet,MonoObject *method)
! {
! if(inlet)
! PD_AddMethodHandler(inlet,&s_list,method,Delegate::k_list);
! else {
! assert(clr_setup_class);
! clr_setup_class->method_list.init(method,Delegate::k_list);
! }
}
! static void PD_AddMethodAnything(int inlet,MonoObject *method)
{
! if(inlet)
! PD_AddMethodHandler(inlet,NULL,method,Delegate::k_anything);
! else {
! assert(clr_setup_class);
! clr_setup_class->method_anything.init(method,Delegate::k_anything);
! }
}
! static void PD_AddInletAlias(t_clr *obj,t_symbol *sel,t_symbol *to_sel)
{
+ ++clr_inlet;
assert(obj);
t_inlet *in = inlet_new(&obj->pd_obj,&obj->pd_obj.ob_pd,sel,to_sel);
***************
*** 342,345 ****
--- 428,432 ----
static void PD_AddInletFloat(t_clr *obj,float *f)
{
+ ++clr_inlet;
assert(obj);
t_inlet *in = floatinlet_new(&obj->pd_obj,f);
***************
*** 349,352 ****
--- 436,440 ----
static void PD_AddInletSymbol(t_clr *obj,t_symbol **s)
{
+ ++clr_inlet;
assert(obj);
t_inlet *in = symbolinlet_new(&obj->pd_obj,s);
***************
*** 357,360 ****
--- 445,449 ----
static void PD_AddInletPointer(t_clr *obj,t_gpointer *p)
{
+ ++clr_inlet;
assert(obj);
t_inlet *in = pointerinlet_new(&obj->pd_obj,p);
***************
*** 363,372 ****
*/
! static void PD_AddInletProxy(t_clr *obj)
{
assert(obj);
! // TODO implement
}
static void PD_AddOutlet(t_clr *obj,t_symbol *type)
{
--- 452,470 ----
*/
! static void PD_AddInletProxyTyped(t_clr *obj,t_symbol *type)
{
assert(obj);
! t_proxy *p = (t_proxy *)pd_new(proxy_class);
! p->parent = obj;
! p->inlet = ++clr_inlet;
! if(!obj->proxies) obj->proxies = new ProxyList;
! obj->proxies->push_back(p);
! t_inlet *in = inlet_new(&obj->pd_obj,&p->pd_obj.ob_pd,type,type);
! assert(in);
}
+ static void PD_AddInletProxy(t_clr *obj) { PD_AddInletProxyTyped(obj,NULL); }
+
+
static void PD_AddOutlet(t_clr *obj,t_symbol *type)
{
***************
*** 382,386 ****
assert(obj);
assert(obj->outlets);
! assert(n >= 0 && n < obj->outlets->size());
outlet_bang((*obj->outlets)[n]);
}
--- 480,484 ----
assert(obj);
assert(obj->outlets);
! assert(n >= 0 && n < (int)obj->outlets->size());
outlet_bang((*obj->outlets)[n]);
}
***************
*** 390,394 ****
assert(obj);
assert(obj->outlets);
! assert(n >= 0 && n < obj->outlets->size());
outlet_float((*obj->outlets)[n],f);
}
--- 488,492 ----
assert(obj);
assert(obj->outlets);
! assert(n >= 0 && n < (int)obj->outlets->size());
outlet_float((*obj->outlets)[n],f);
}
***************
*** 398,402 ****
assert(obj);
assert(obj->outlets);
! assert(n >= 0 && n < obj->outlets->size());
outlet_symbol((*obj->outlets)[n],s);
}
--- 496,500 ----
assert(obj);
assert(obj->outlets);
! assert(n >= 0 && n < (int)obj->outlets->size());
outlet_symbol((*obj->outlets)[n],s);
}
***************
*** 406,410 ****
assert(obj);
assert(obj->outlets);
! assert(n >= 0 && n < obj->outlets->size());
outlet_pointer((*obj->outlets)[n],p);
}
--- 504,508 ----
assert(obj);
assert(obj->outlets);
! assert(n >= 0 && n < (int)obj->outlets->size());
outlet_pointer((*obj->outlets)[n],p);
}
***************
*** 414,418 ****
assert(obj);
assert(obj->outlets);
! assert(n >= 0 && n < obj->outlets->size());
t_outlet *out = (*obj->outlets)[n];
switch(l.a_type) {
--- 512,516 ----
assert(obj);
assert(obj->outlets);
! assert(n >= 0 && n < (int)obj->outlets->size());
t_outlet *out = (*obj->outlets)[n];
switch(l.a_type) {
***************
*** 429,433 ****
assert(obj);
assert(obj->outlets);
! assert(n >= 0 && n < obj->outlets->size());
outlet_anything((*obj->outlets)[n],s,l.argc,l.argv);
}
--- 527,531 ----
assert(obj);
assert(obj->outlets);
! assert(n >= 0 && n < (int)obj->outlets->size());
outlet_anything((*obj->outlets)[n],s,l.argc,l.argv);
}
***************
*** 437,441 ****
assert(obj);
assert(obj->outlets);
! assert(n >= 0 && n < obj->outlets->size());
// assert(mono_object_get_class(&l->obj) == clr_atom);
outlet_anything((*obj->outlets)[n],s,mono_array_length(l),mono_array_addr(l,t_atom,0));
--- 535,539 ----
assert(obj);
assert(obj->outlets);
! assert(n >= 0 && n < (int)obj->outlets->size());
// assert(mono_object_get_class(&l->obj) == clr_atom);
outlet_anything((*obj->outlets)[n],s,mono_array_length(l),mono_array_addr(l,t_atom,0));
***************
*** 464,467 ****
--- 562,566 ----
{
// find class name in map
+
ClrMap::iterator it = clr_map.find(classname);
if(it == clr_map.end()) {
***************
*** 489,496 ****
x->outlets = NULL;
// ok, we have an object - look for constructor
if(clss->mono_ctor) {
! AtomList al;
al.Set(argc,argv);
gpointer args = &al;
--- 588,599 ----
x->outlets = NULL;
+ x->proxies = NULL;
// ok, we have an object - look for constructor
if(clss->mono_ctor) {
! // reset inlet index
! clr_inlet = 0;
!
! AtomList al;
al.Set(argc,argv);
gpointer args = &al;
***************
*** 512,518 ****
}
! void clr_free(t_clr *x)
{
! if(x->outlets) delete x->outlets;
}
--- 615,626 ----
}
! void clr_free(t_clr *obj)
{
! if(obj->outlets) delete obj->outlets;
!
! if(obj->proxies) {
! for(ProxyList::iterator it = obj->proxies->begin(); it != obj->proxies->end(); ++it) pd_free((t_pd *)*it);
! delete obj->proxies;
! }
}
***************
*** 614,618 ****
clr_class->pd_class = class_new(classsym,(t_newmethod)clr_new,(t_method)clr_free, sizeof(t_clr), flags, A_GIMME, A_NULL);
! // find && register methods
if(clr_class->method_bang)
class_addbang(clr_class->pd_class,clr_method_bang);
--- 722,726 ----
clr_class->pd_class = class_new(classsym,(t_newmethod)clr_new,(t_method)clr_free, sizeof(t_clr), flags, A_GIMME, A_NULL);
! // register methods
if(clr_class->method_bang)
class_addbang(clr_class->pd_class,clr_method_bang);
***************
*** 699,717 ****
mono_add_internal_call("PureData.External::Post(string)",(const void *)PD_Post);
mono_add_internal_call("PureData.External::PostError(string)",(const void *)PD_PostError);
! mono_add_internal_call("PureData.External::PostBug(string)",(const void *)PD_PostBug);
! mono_add_internal_call("PureData.External::PostVerbose(string)",(const void *)PD_PostVerbose);
! mono_add_internal_call("PureData.External::Add(PureData.External/MethodBang)", (const void *)PD_AddBang);
! mono_add_internal_call("PureData.External::Add(PureData.External/MethodFloat)", (const void *)PD_AddFloat);
! mono_add_internal_call("PureData.External::Add(PureData.External/MethodSymbol)", (const void *)PD_AddSymbol);
! mono_add_internal_call("PureData.External::Add(PureData.External/MethodPointer)", (const void *)PD_AddPointer);
! mono_add_internal_call("PureData.External::Add(PureData.External/MethodList)", (const void *)PD_AddList);
! mono_add_internal_call("PureData.External::Add(PureData.Symbol,PureData.External/MethodList)", (const void *)PD_AddSelector);
! mono_add_internal_call("PureData.External::Add(PureData.External/MethodAnything)", (const void *)PD_AddAnything);
! mono_add_internal_call("PureData.Internal::AddInlet(void*,PureData.Symbol,PureData.Symbol)", (const void *)PD_AddInlet);
mono_add_internal_call("PureData.Internal::AddInlet(void*,single&)", (const void *)PD_AddInletFloat);
mono_add_internal_call("PureData.Internal::AddInlet(void*,PureData.Symbol&)", (const void *)PD_AddInletSymbol);
// mono_add_internal_call("PureData.Internal::AddInlet(void*,PureData.Pointer&)", (const void *)PD_AddInletPointer);
mono_add_internal_call("PureData.Internal::AddInlet(void*)", (const void *)PD_AddInletProxy);
--- 807,825 ----
mono_add_internal_call("PureData.External::Post(string)",(const void *)PD_Post);
mono_add_internal_call("PureData.External::PostError(string)",(const void *)PD_PostError);
! mono_add_internal_call("PureData.External::PostVerbose(int,string)",(const void *)PD_PostVerbose);
! mono_add_internal_call("PureData.External::AddMethod(int,PureData.External/MethodBang)", (const void *)PD_AddMethodBang);
! mono_add_internal_call("PureData.External::AddMethod(int,PureData.External/MethodFloat)", (const void *)PD_AddMethodFloat);
! mono_add_internal_call("PureData.External::AddMethod(int,PureData.External/MethodSymbol)", (const void *)PD_AddMethodSymbol);
! mono_add_internal_call("PureData.External::AddMethod(int,PureData.External/MethodPointer)", (const void *)PD_AddMethodPointer);
! mono_add_internal_call("PureData.External::AddMethod(int,PureData.External/MethodList)", (const void *)PD_AddMethodList);
! mono_add_internal_call("PureData.External::AddMethod(int,PureData.Symbol,PureData.External/MethodAnything)", (const void *)PD_AddMethodSelector);
! mono_add_internal_call("PureData.External::AddMethod(int,PureData.External/MethodAnything)", (const void *)PD_AddMethodAnything);
! mono_add_internal_call("PureData.Internal::AddInlet(void*,PureData.Symbol,PureData.Symbol)", (const void *)PD_AddInletAlias);
mono_add_internal_call("PureData.Internal::AddInlet(void*,single&)", (const void *)PD_AddInletFloat);
mono_add_internal_call("PureData.Internal::AddInlet(void*,PureData.Symbol&)", (const void *)PD_AddInletSymbol);
// mono_add_internal_call("PureData.Internal::AddInlet(void*,PureData.Pointer&)", (const void *)PD_AddInletPointer);
+ // mono_add_internal_call("PureData.Internal::AddInlet(void*,PureData.Symbol)", (const void *)PD_AddInletTyped);
mono_add_internal_call("PureData.Internal::AddInlet(void*)", (const void *)PD_AddInletProxy);
***************
*** 760,764 ****
// static objects to avoid allocation at method call time
clr_objarr_1 = mono_array_new(monodomain,mono_get_object_class(),1);
! clr_objarr_2 = mono_array_new(monodomain,mono_get_object_class(),2);
clr_obj_single = mono_object_new(monodomain,mono_get_single_class());
clr_obj_symbol = mono_object_new(monodomain,clr_symbol);
--- 868,873 ----
// static objects to avoid allocation at method call time
clr_objarr_1 = mono_array_new(monodomain,mono_get_object_class(),1);
! clr_objarr_3 = mono_array_new(monodomain,mono_get_object_class(),3);
! clr_obj_int = mono_object_new(monodomain,mono_get_int32_class());
clr_obj_single = mono_object_new(monodomain,mono_get_single_class());
clr_obj_symbol = mono_object_new(monodomain,clr_symbol);
***************
*** 766,769 ****
--- 875,879 ----
clr_obj_atomlist = mono_object_new(monodomain,clr_atomlist);
// unboxed addresses
+ clr_val_int = (int *)mono_object_unbox(clr_obj_int);
clr_val_single = (float *)mono_object_unbox(clr_obj_single);
clr_val_symbol = (t_symbol **)mono_object_unbox(clr_obj_symbol);
***************
*** 771,774 ****
--- 881,888 ----
clr_val_atomlist = (AtomList *)mono_object_unbox(clr_obj_atomlist);
+ // make proxy class
+ proxy_class = class_new(gensym("clr proxy"),NULL,NULL,sizeof(t_proxy),CLASS_PD|CLASS_NOINLET,A_NULL);
+ class_addanything(proxy_class,clr_method_proxy);
+
// install loader hook
sys_loader(classloader);