Update of /cvsroot/pure-data/externals/clr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24368/clr
Modified Files: clr.cpp test-clr.pd Log Message: added inlet and outlet functions added send functions practically ready to work with!
Index: test-clr.pd =================================================================== RCS file: /cvsroot/pure-data/externals/clr/test-clr.pd,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** test-clr.pd 8 Mar 2006 01:59:24 -0000 1.10 --- test-clr.pd 8 Mar 2006 16:48:29 -0000 1.11 *************** *** 1,7 **** ! #N canvas 603 10 798 320 12; #X floatatom 125 51 5 0 0 0 - - -; #X symbolatom 320 81 10 0 0 0 - - -; #X msg 536 45 msg one 2 three; ! #X obj 240 276 Counter a b 5; #X obj 22 24 loadbang; #X floatatom 213 26 5 0 0 0 - - -; --- 1,7 ---- ! #N canvas 617 153 818 585 12; #X floatatom 125 51 5 0 0 0 - - -; #X symbolatom 320 81 10 0 0 0 - - -; #X msg 536 45 msg one 2 three; ! #X obj 151 443 Counter a b 5; #X obj 22 24 loadbang; #X floatatom 213 26 5 0 0 0 - - -; *************** *** 12,21 **** -1; #X msg 535 82 set 1 7 8; ! #X msg 541 167 list; ! #X msg 540 196 list 1; ! #X msg 541 225 list abc; #X connect 0 0 3 0; #X connect 1 0 3 0; #X connect 2 0 3 0; #X connect 4 0 9 0; #X connect 5 0 6 0; --- 12,32 ---- -1; #X msg 535 82 set 1 7 8; ! #X msg 533 135 list; ! #X msg 532 164 list 1; ! #X msg 533 193 list abc; ! #X msg 528 251 list s e c o n d; ! #X obj 152 495 print OUT; ! #X floatatom 530 321 5 0 0 0 - - -; ! #X floatatom 229 112 5 0 0 0 - - -; ! #X msg 228 136 send $1 b c; ! #X obj 407 497 print RECV1; ! #X obj 406 463 r receiver; ! #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; #X connect 2 0 3 0; + #X connect 3 0 15 0; #X connect 4 0 9 0; #X connect 5 0 6 0; *************** *** 28,29 **** --- 39,46 ---- #X connect 12 0 3 0; #X connect 13 0 3 0; + #X connect 14 0 3 1; + #X connect 16 0 3 2; + #X connect 17 0 18 0; + #X connect 18 0 3 0; + #X connect 20 0 19 0; + #X connect 21 0 22 0;
Index: clr.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/clr/clr.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** clr.cpp 8 Mar 2006 01:59:24 -0000 1.8 --- clr.cpp 8 Mar 2006 16:48:28 -0000 1.9 *************** *** 27,30 **** --- 27,31 ----
#include <map> + #include <vector>
#define CORELIB "PureData" *************** *** 40,44 **** static MonoProperty *clr_prop_method;
- struct AtomList { --- 41,44 ---- *************** *** 79,84 **** t_class *pd_class; MonoClass *mono_class; - MonoClassField *mono_obj_field; MonoMethod *mono_ctor; t_symbol *name; Delegate method_bang,method_float,method_symbol,method_pointer,method_list,method_anything; --- 79,84 ---- t_class *pd_class; MonoClass *mono_class; MonoMethod *mono_ctor; + MonoClassField *obj_field; // ptr field in PureData.External t_symbol *name; Delegate method_bang,method_float,method_symbol,method_pointer,method_list,method_anything; *************** *** 90,93 **** --- 90,95 ---- static ClrMap clr_map;
+ typedef std::vector<t_outlet *> OutletArr; + // this is the class to be setup (while we are in the CLR static Main method) static t_clr_class *clr_setup_class = NULL; *************** *** 99,102 **** --- 101,105 ---- t_clr_class *clr_clss; // pointer to our class structure MonoObject *mono_obj; // the mono class instance + OutletArr *outlets; };
*************** *** 177,181 **** }
- static void clr_method_list(t_clr *x,t_symbol *l, int argc, t_atom *argv) { --- 180,183 ---- *************** *** 331,334 **** --- 333,457 ----
+ 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); + assert(in); + } + + static void PD_AddInletFloat(t_clr *obj,float *f) + { + assert(obj); + t_inlet *in = floatinlet_new(&obj->pd_obj,f); + assert(in); + } + + static void PD_AddInletSymbol(t_clr *obj,t_symbol **s) + { + assert(obj); + t_inlet *in = symbolinlet_new(&obj->pd_obj,s); + assert(in); + } + + /* + static void PD_AddInletPointer(t_clr *obj,t_gpointer *p) + { + assert(obj); + t_inlet *in = pointerinlet_new(&obj->pd_obj,p); + assert(in); + } + */ + + static void PD_AddInletProxy(t_clr *obj) + { + assert(obj); + // TODO implement + } + + static void PD_AddOutlet(t_clr *obj,t_symbol *type) + { + assert(obj); + t_outlet *out = outlet_new(&obj->pd_obj,type); + assert(out); + if(!obj->outlets) obj->outlets = new OutletArr; + obj->outlets->push_back(out); + } + + static void PD_OutletBang(t_clr *obj,int n) + { + assert(obj); + assert(obj->outlets); + outlet_bang((*obj->outlets)[n]); + } + + static void PD_OutletFloat(t_clr *obj,int n,float f) + { + assert(obj); + assert(obj->outlets); + outlet_float((*obj->outlets)[n],f); + } + + static void PD_OutletSymbol(t_clr *obj,int n,t_symbol *s) + { + assert(obj); + assert(obj->outlets); + outlet_symbol((*obj->outlets)[n],s); + } + + static void PD_OutletPointer(t_clr *obj,int n,t_gpointer *p) + { + assert(obj); + assert(obj->outlets); + outlet_pointer((*obj->outlets)[n],p); + } + + static void PD_OutletAtom(t_clr *obj,int n,t_atom l) + { + assert(obj); + assert(obj->outlets); + t_outlet *out = (*obj->outlets)[n]; + switch(l.a_type) { + case A_FLOAT: outlet_float(out,l.a_w.w_float); break; + case A_SYMBOL: outlet_symbol(out,l.a_w.w_symbol); break; + case A_POINTER: outlet_pointer(out,l.a_w.w_gpointer); break; + default: + error("CLR - internal error in file " __FILE__ ", line %i",__LINE__); + } + } + + static void PD_OutletAnything(t_clr *obj,int n,t_symbol *s,AtomList l) + { + assert(obj); + assert(obj->outlets); + outlet_anything((*obj->outlets)[n],s,l.argc,l.argv); + } + + static void PD_OutletAnything2(t_clr *obj,int n,t_symbol *s,MonoArray *l) + { + assert(obj); + assert(obj->outlets); + // 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)); + } + + static void PD_SendAtom(t_symbol *dst,t_atom a) + { + void *cl = dst->s_thing; + if(cl) pd_forwardmess((t_class **)cl,1,&a); + } + + static void PD_SendAnything(t_symbol *dst,t_symbol *s,AtomList l) + { + void *cl = dst->s_thing; + if(cl) pd_typedmess((t_class **)cl,s,l.argc,l.argv); + } + + static void PD_SendAnything2(t_symbol *dst,t_symbol *s,MonoArray *l) + { + void *cl = dst->s_thing; + // assert(mono_object_get_class(&l->obj) == clr_atom); + if(cl) pd_typedmess((t_class **)cl,s,mono_array_length(l),mono_array_addr(l,t_atom,0)); + } + void *clr_new(t_symbol *classname, int argc, t_atom *argv) { *************** *** 356,360 ****
// store our object pointer in External::ptr member ! mono_field_set_value(x->mono_obj,clss->mono_obj_field,&x);
// ok, we have an object - look for constructor --- 479,485 ----
// store our object pointer in External::ptr member ! mono_field_set_value(x->mono_obj,clss->obj_field,x); ! ! x->outlets = NULL;
// ok, we have an object - look for constructor *************** *** 382,385 **** --- 507,511 ---- void clr_free(t_clr *x) { + if(x->outlets) delete x->outlets; }
*************** *** 403,410 ****
clr_class = (t_clr_class *)getbytes(sizeof(t_clr_class)); memset(clr_class,0,sizeof(*clr_class));
- // clr_class->methods = NULL; - // try to load assembly strcat(dirbuf,"/"); --- 529,535 ----
clr_class = (t_clr_class *)getbytes(sizeof(t_clr_class)); + // set all struct members to 0 memset(clr_class,0,sizeof(*clr_class));
// try to load assembly strcat(dirbuf,"/"); *************** *** 429,439 **** }
- clr_class->mono_obj_field = mono_class_get_field_from_name(clr_class->mono_class,"ptr"); - assert(clr_class->mono_obj_field); - // make new class (with classname) classsym = gensym(classname); clr_class->pd_class = class_new(classsym,(t_newmethod)clr_new,(t_method)clr_free, sizeof(t_clr), CLASS_DEFAULT, A_GIMME, 0);
// find static Main method
--- 554,564 ---- }
// make new class (with classname) classsym = gensym(classname); clr_class->pd_class = class_new(classsym,(t_newmethod)clr_new,(t_method)clr_free, sizeof(t_clr), CLASS_DEFAULT, A_GIMME, 0);
+ clr_class->obj_field = mono_class_get_field_from_name(clr_class->mono_class,"ptr"); + assert(clr_class->obj_field); + // find static Main method
*************** *** 450,455 ****
// store NULL in External::ptr member ! void *x = NULL; ! mono_field_set_value(obj,clr_class->mono_obj_field,&x);
// set current class --- 575,579 ----
// store NULL in External::ptr member ! mono_field_set_value(obj,clr_class->obj_field,NULL);
// set current class *************** *** 571,574 **** --- 695,721 ---- 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); + + mono_add_internal_call("PureData.Internal::AddOutlet(void*,PureData.Symbol)", (const void *)PD_AddOutlet); + + mono_add_internal_call("PureData.Internal::Outlet(void*,int)", (const void *)PD_OutletBang); + mono_add_internal_call("PureData.Internal::Outlet(void*,int,single)", (const void *)PD_OutletFloat); + mono_add_internal_call("PureData.Internal::Outlet(void*,int,PureData.Symbol)", (const void *)PD_OutletSymbol); + mono_add_internal_call("PureData.Internal::Outlet(void*,int,PureData.Pointer)", (const void *)PD_OutletPointer); + mono_add_internal_call("PureData.Internal::Outlet(void*,int,PureData.Atom)", (const void *)PD_OutletAtom); + mono_add_internal_call("PureData.Internal::Outlet(void*,int,PureData.Symbol,PureData.AtomList)", (const void *)PD_OutletAnything); + mono_add_internal_call("PureData.Internal::Outlet(void*,int,PureData.Symbol,PureData.Atom[])", (const void *)PD_OutletAnything2); + + // mono_add_internal_call("PureData.Internal::Bind(void*,PureData.Symbol)", (const void *)PD_Bind); + // mono_add_internal_call("PureData.Internal::Unbind(void*,PureData.Symbol)", (const void *)PD_Unbind); + + mono_add_internal_call("PureData.External::Send(PureData.Symbol,PureData.Atom)", (const void *)PD_SendAtom); + mono_add_internal_call("PureData.External::Send(PureData.Symbol,PureData.Symbol,PureData.AtomList)", (const void *)PD_SendAnything); + mono_add_internal_call("PureData.External::Send(PureData.Symbol,PureData.Symbol,PureData.Atom[])", (const void *)PD_SendAnything2); + // load important classes clr_symbol = mono_class_from_name(image,"PureData","Symbol");