diff options
author | Thomas Grill <xovo@users.sourceforge.net> | 2006-03-09 17:27:37 +0000 |
---|---|---|
committer | Thomas Grill <xovo@users.sourceforge.net> | 2006-03-09 17:27:37 +0000 |
commit | 2bd3c408f06b21c621c9471c45ef8be0b1487892 (patch) | |
tree | bc2331968ec5210e0d4f31694fba069cfce51d0e | |
parent | 450b54a7c21f1e7fa98249fe6b3ac4c98966f163 (diff) |
fixes for mono object passing
svn path=/trunk/externals/clr/; revision=4669
-rw-r--r-- | PureData/PureData.cs | 4 | ||||
-rwxr-xr-x | clr.cpp | 24 | ||||
-rwxr-xr-x | makefile | 24 | ||||
-rw-r--r-- | test/test-help.pd | 18 | ||||
-rw-r--r-- | test/test.cs | 14 |
5 files changed, 55 insertions, 29 deletions
diff --git a/PureData/PureData.cs b/PureData/PureData.cs index 1d01f75..4df716e 100644 --- a/PureData/PureData.cs +++ b/PureData/PureData.cs @@ -65,7 +65,7 @@ namespace PureData internal extern static void Outlet(void *obj,int n,Symbol s,Atom[] l); [MethodImplAttribute (MethodImplOptions.InternalCall)] - internal extern static void Outlet(void *obj,int n,object o); + internal extern static void OutletEx(void *obj,int n,object o); // -------------------------------------------------------------------------- @@ -211,7 +211,7 @@ namespace PureData protected void Outlet(int n,Symbol s,AtomList l) { Internal.Outlet(ptr,n,s,l); } protected void Outlet(int n,Symbol s,Atom[] l) { Internal.Outlet(ptr,n,s,l); } - protected void OutletEx(int n,object o) { Internal.Outlet(ptr,n,o); } + protected void OutletEx(int n,object o) { Internal.OutletEx(ptr,n,o); } // -------------------------------------------------------------------------- @@ -327,25 +327,28 @@ static void call_anything(t_clr *x,int inlet,t_symbol *s,int argc,t_atom *argv) exc = (*d)(x->mono_obj); break; case Delegate::k_float: - if(argc == 0 || argv[0].a_type != A_FLOAT) { + if((argc == 1 || (argc >= 1 && s == &s_list)) && argv[0].a_type == A_FLOAT) + exc = (*d)(x->mono_obj,argv[0].a_w.w_float); + else { error("%s - %s handler: float argument expected",x->clr_clss->name->s_name,s->s_name); return; } - exc = (*d)(x->mono_obj,argv[0].a_w.w_float); break; case Delegate::k_symbol: - if(argc == 0 || argv[0].a_type != A_SYMBOL) { + if((argc == 1 || (argc >= 1 && s == &s_list)) && argv[0].a_type == A_SYMBOL) + exc = (*d)(x->mono_obj,argv[0].a_w.w_symbol); + else { error("%s - %s handler: symbol argument expected",x->clr_clss->name->s_name,s->s_name); return; } - exc = (*d)(x->mono_obj,argv[0].a_w.w_symbol); break; case Delegate::k_pointer: - if(argc == 0 || argv[0].a_type != A_POINTER) { + if((argc == 1 || (argc >= 1 && s == &s_list)) && argv[0].a_type == A_POINTER) + exc = (*d)(x->mono_obj,argv[0].a_w.w_gpointer); + else { error("%s - %s handler: pointer argument expected",x->clr_clss->name->s_name,s->s_name); return; } - exc = (*d)(x->mono_obj,argv[0].a_w.w_gpointer); break; case Delegate::k_list: exc = (*d)(x->mono_obj,argc,argv); @@ -686,7 +689,7 @@ void *clr_new(t_symbol *classname, int argc, t_atom *argv) ClrMap::iterator it = clr_map.find(classname); if(it == clr_map.end()) { - error("CLR class %s not found",classname->s_name); + error("CLR - class %s not found",classname->s_name); return NULL; } @@ -697,7 +700,7 @@ void *clr_new(t_symbol *classname, int argc, t_atom *argv) x->mono_obj = mono_object_new (monodomain,clss->mono_class); if(!x->mono_obj) { pd_free((t_pd *)x); - error("CLR class %s could not be instantiated",classname->s_name); + error("CLR - class %s could not be instantiated",classname->s_name); return NULL; } @@ -800,8 +803,7 @@ static int classloader(char *dirname, char *classname, char *altname) clr_class->obj_field = mono_class_get_field_from_name(clr_class->mono_class,"ptr"); assert(clr_class->obj_field); - // find static Main method - + // find static Setup method MonoMethodDesc *clr_desc_main = mono_method_desc_new("::Setup",FALSE); assert(clr_desc_main); @@ -819,7 +821,7 @@ static int classloader(char *dirname, char *classname, char *altname) // set current class clr_setup_class = clr_class; - // call static Main method + // call static Setup method gpointer args = obj; MonoObject *exc; MonoObject *ret = mono_runtime_invoke(method,NULL,&args,&exc); @@ -11,22 +11,22 @@ cygwin: clr.dll # where are the PD header files? # leave it blank if it is a system directory (like /usr/local/include), # since gcc 3.2 complains about it -PDPATH=/home/Davide -LINUXCFLAGS = -DPD -O2 -mno-cygwin
-#LINUXCFLAGS = -DPD -O2 -funroll-loops -fomit-frame-pointer \
-# -Wall -W -Wshadow -Wstrict-prototypes -Werror \
-# -Wno-unused -Wno-parentheses -Wno-switch
+PDPATH=/cygdrive/c/data/pd/pd-cvs +MONOPATH=/cygdrive/c/programme/prog/mono + + +CFLAGS = -DPD -O2 -mno-cygwin
-LINUXINCLUDE = -I../../src -I$PDPATH
+PDINC= -I$(PDPATH)/src
+PDLIB= $(PDPATH)/bin/pd.dll -MONOSRC = -IC:/cygwin/tmp/build_deps/include -IC:/cygwin/tmp/build_deps/include/glib-2.0 -IC:/cygwin/tmp/build_deps/lib/glib-2.0/include -IC:/cygwin/home/Davide/mono/include
-MONOLIB = -LC:/cygwin/tmp/build_deps/lib -LC:/cygwin/home/Davide/mono/lib -lmono -lm -lgmodule-2.0 -lgthread-2.0 -lglib-2.0 -lintl -liconv
+MONOINC = -I$(MONOPATH)/include -I$(MONOPATH)/include/glib-2.0 -I$(MONOPATH)/lib/glib-2.0/include
+MONOLIB = -L$(MONOPATH)/lib -lmono.dll -lgmodule-2.0 -lgthread-2.0 -lglib-2.0 -lintl -liconv
-.c.dll:
-# gcc $(LINUXCFLAGS) $(LINUXINCLUDE) `pkg-config --cflags --libs mono` -lm -ID:/Davide/cygwin/home/Davide/mono/include -LD:/Davide/cygwin/home/Davide/mono/lib $*.c
- gcc $(LINUXCFLAGS) $(LINUXINCLUDE) $(MONOSRC) -o $*.o -c $*.c
- gcc -export_dynamic -shared -mno-cygwin $(MONOLIB) -o $*.dll $*.o -lm pd.dll libmono.dll.a
+.cpp.dll:
+ g++ $(CFLAGS) $(PDINC) $(MONOINC) -o $*.o -c $*.cpp
+ g++ -export_dynamic -shared -mno-cygwin $(PDLIB) $(MONOLIB) -o $*.dll $*.o -lm
# ld -export_dynamic $(MONOLIB) -o $*.dll $*.o -lm pd.dll
# strip --strip-unneeded $*.pd_linux
# rm $*.o
diff --git a/test/test-help.pd b/test/test-help.pd index ca7d7eb..26246c4 100644 --- a/test/test-help.pd +++ b/test/test-help.pd @@ -1,4 +1,4 @@ -#N canvas 617 153 850 617 12; +#N canvas 617 153 862 841 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; @@ -16,8 +16,8 @@ #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 floatatom 290 173 5 0 0 0 - - -; +#X msg 289 197 send \$1 b c; #X obj 407 497 print RECV1; #X obj 406 463 r receiver; #X obj 554 465 r receiver2; @@ -31,6 +31,13 @@ #X msg 589 386 turalu; #X msg 578 274 heyho; #X obj 151 443 test a b 5; +#X obj 655 388 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X obj 124 621 test; +#X obj 124 696 test; +#X obj 141 650 print A; +#X obj 138 725 print B; +#X msg 120 580 trigger; #X connect 0 0 30 0; #X connect 1 0 30 0; #X connect 2 0 30 0; @@ -57,3 +64,8 @@ #X connect 28 0 30 3; #X connect 29 0 30 1; #X connect 30 0 14 0; +#X connect 31 0 30 3; +#X connect 32 0 33 0; +#X connect 32 0 34 0; +#X connect 33 0 35 0; +#X connect 36 0 32 0; diff --git a/test/test.cs b/test/test.cs index cfde7c6..0171275 100644 --- a/test/test.cs +++ b/test/test.cs @@ -18,7 +18,7 @@ public class test: AddInlet(); AddInlet(ref farg); AddInlet(); - AddOutletBang(); + AddOutletAnything(); } // this function MUST exist @@ -31,6 +31,8 @@ public class test: AddMethod(0,new MethodList(obj.MyList)); AddMethod(0,"set",new MethodAnything(obj.MySet)); AddMethod(0,"send",new MethodAnything(obj.MySend)); + AddMethod(0,"trigger",new Method(obj.MyTrigger)); + AddMethod(0,new MethodObject(obj.MyObject)); AddMethod(0,new MethodAnything(obj.MyAnything)); AddMethod(1,new MethodFloat(obj.MyFloat1)); AddMethod(1,new MethodAnything(obj.MyAny1)); @@ -85,6 +87,16 @@ public class test: Send(new PureData.Symbol("receiver2"),(PureData.Atom[])l); } + protected virtual void MyTrigger() + { + OutletEx(0,"hey"); + } + + protected virtual void MyObject(int ix,object obj) + { + Post("OBJECT "+obj.ToString()); + } + protected virtual void MyAnything(int ix,PureData.Symbol s,PureData.AtomList l) { Post(ix.ToString()+": Test-("+s.ToString()+") "+l.ToString()); |