aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2006-03-09 14:34:33 +0000
committerThomas Grill <xovo@users.sourceforge.net>2006-03-09 14:34:33 +0000
commit450b54a7c21f1e7fa98249fe6b3ac4c98966f163 (patch)
treecf8cc4abbe85bc0285f957472cd5d59c5d0a9a3e
parent16aa9b1f769721380ce6dca3e52fa65bf92e84ad (diff)
adapted to PD version 0.40
better handler flexibility and argument checking added Zmolnigs counter example svn path=/trunk/externals/clr/; revision=4663
-rwxr-xr-xCounter/Counter.cs130
-rw-r--r--Counter/counter-help.pd24
-rw-r--r--PureData/PureData.cs38
-rwxr-xr-xclr.cpp189
-rw-r--r--test/AssemblyInfo.cs58
-rw-r--r--[-rwxr-xr-x]test/test-help.pd (renamed from test-clr.pd)54
-rw-r--r--test/test.cs93
-rw-r--r--test/test.csproj105
8 files changed, 556 insertions, 135 deletions
diff --git a/Counter/Counter.cs b/Counter/Counter.cs
index 4cd1564..416cb3b 100755
--- a/Counter/Counter.cs
+++ b/Counter/Counter.cs
@@ -6,104 +6,76 @@ using System;
public class Counter:
PureData.External
{
- PureData.Atom[] args;
-
- float farg;
+ int i_count,i_down,i_up;
+ float step;
public Counter(PureData.AtomList args)
{
- Post("Count.ctor "+args.ToString());
-
- // that's the way to store args (don't just copy an AtomList instance!!)
- this.args = (PureData.Atom[])args;
-
-// AddInlet(s_list,new PureData.Symbol("list2"));
- AddInlet();
- AddInlet(ref farg);
- AddInlet();
- AddOutletBang();
+ this.step = args.Count >= 3?(float)args[2]:1;
+
+ float f2 = args.Count >= 2?(float)args[1]:0;
+ float f1 = args.Count >= 1?(float)args[0]:0;
+
+ if(args.Count < 2) f2 = f1;
+
+ this.i_down = (int)((f1<f2)?f1:f2);
+ this.i_up = (int)((f1>f2)?f1:f2);
+
+ this.i_count = this.i_down;
+
+ AddInlet(_list,new PureData.Symbol("bound"));
+ AddInlet(ref step);
+
+ AddOutlet(_float);
+ AddOutlet(_bang);
}
// this function MUST exist
- // returns void or ClassType
- private static ClassType Setup(Counter obj)
+ private static void Setup(Counter obj)
{
- AddMethod(0,new MethodBang(obj.MyBang));
- AddMethod(0,new MethodFloat(obj.MyFloat));
- AddMethod(0,new MethodSymbol(obj.MySymbol));
- AddMethod(0,new MethodList(obj.MyList));
- AddMethod(0,"set",new MethodAnything(obj.MySet));
- AddMethod(0,"send",new MethodAnything(obj.MySend));
- AddMethod(0,new MethodAnything(obj.MyAnything));
- AddMethod(1,new MethodFloat(obj.MyFloat1));
- AddMethod(1,new MethodAnything(obj.MyAny1));
-
- Post("Count.Main");
- return ClassType.Default;
+ AddMethod(0,new Method(obj.Bang));
+ AddMethod(0,"reset",new Method(obj.Reset));
+ AddMethod(0,"set",new MethodFloat(obj.Set));
+ AddMethod(0,"bound",new MethodList(obj.Bound));
}
- protected virtual void MyBang()
- {
- Post("Count-BANG "+farg.ToString());
- Outlet(0);
- }
-
- protected virtual void MyFloat(float f)
- {
- Post("Count-FLOAT "+f.ToString());
+ protected void Bang()
+ {
+ float f = this.i_count;
+ int step = (int)this.step;
+ this.i_count += step;
+
+ if(this.i_down-this.i_up != 0) {
+ if(step > 0 && this.i_count > this.i_up) {
+ this.i_count = this.i_down;
+ Outlet(1);
+ }
+ else if(this.i_count < this.i_down) {
+ this.i_count = this.i_up;
+ Outlet(1);
+ }
+ }
+
Outlet(0,f);
}
- protected virtual void MyFloat1(float f)
- {
- Post("Count-FLOAT1 "+f.ToString());
- }
-
- protected virtual void MyAny1(int ix,PureData.Symbol s,PureData.AtomList l)
+ protected void Reset()
{
- Post(ix.ToString()+": Count-ANY1 "+l.ToString());
+ this.i_count = this.i_down;
}
- protected virtual void MySymbol(PureData.Symbol s)
+ protected void Set(float f)
{
- Post("Count-SYMBOL "+s.ToString());
- Outlet(0,s);
+ this.i_count = (int)f;
}
- protected virtual void MyList(PureData.AtomList l)
+ protected void Bound(PureData.AtomList args)
{
- Post("Count-LIST "+l.ToString());
- Outlet(0,l);
+ float f1 = (float)args[0];
+ float f2 = (float)args[1];
+
+ this.i_down = (int)((f1<f2)?f1:f2);
+ this.i_up = (int)((f1>f2)?f1:f2);
}
- protected virtual void MySet(int ix,PureData.Symbol s,PureData.AtomList l)
- {
- Post("Count-SET "+l.ToString());
- Outlet(0,new PureData.Symbol("set"),l);
- }
-
- protected virtual void MySend(int ix,PureData.Symbol s,PureData.AtomList l)
- {
- Send(new PureData.Symbol("receiver"),l);
- Send(new PureData.Symbol("receiver2"),(PureData.Atom[])l);
- }
-
- protected virtual void MyAnything(int ix,PureData.Symbol s,PureData.AtomList l)
- {
- Post(ix.ToString()+": Count-("+s.ToString()+") "+l.ToString());
- Outlet(0,s,l);
- }
- /*
- public void SendOut()
- {
- pd.SendToOutlet(x, 0, new Atom(curr));
- }
-
- public void Sum(float f)
- {
- curr += (int) f;
- pd.SendToOutlet(x, 0, new Atom(curr));
- }
-
-*/
}
diff --git a/Counter/counter-help.pd b/Counter/counter-help.pd
new file mode 100644
index 0000000..7648acc
--- /dev/null
+++ b/Counter/counter-help.pd
@@ -0,0 +1,24 @@
+#N canvas 0 0 458 308 12;
+#X obj 233 204 Counter;
+#X msg 306 91 2 7;
+#X floatatom 372 91 5 0 0 0 - - -;
+#X obj 284 241 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X floatatom 226 240 5 0 0 0 - - -;
+#X floatatom 90 55 5 0 0 0 - - -;
+#X msg 17 113 reset;
+#X obj 19 68 bng 25 250 50 0 empty empty empty 0 -6 0 8 -258699 -1
+-1;
+#X text 296 70 bounds;
+#X msg 164 80 bound 0 4;
+#X text 376 72 step;
+#X msg 90 79 set \$1;
+#X connect 0 0 4 0;
+#X connect 0 1 3 0;
+#X connect 1 0 0 1;
+#X connect 2 0 0 2;
+#X connect 5 0 11 0;
+#X connect 6 0 0 0;
+#X connect 7 0 0 0;
+#X connect 9 0 0 0;
+#X connect 11 0 0 0;
diff --git a/PureData/PureData.cs b/PureData/PureData.cs
index ea0042b..1d01f75 100644
--- a/PureData/PureData.cs
+++ b/PureData/PureData.cs
@@ -64,6 +64,9 @@ namespace PureData
[MethodImplAttribute (MethodImplOptions.InternalCall)]
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);
+
// --------------------------------------------------------------------------
[MethodImplAttribute (MethodImplOptions.InternalCall)]
@@ -120,17 +123,18 @@ namespace PureData
// --------------------------------------------------------------------------
- protected delegate void MethodBang();
+ protected delegate void Method();
protected delegate void MethodFloat(float f);
protected delegate void MethodSymbol(Symbol s);
protected delegate void MethodPointer(Pointer p);
protected delegate void MethodList(AtomList lst);
protected delegate void MethodAnything(int inlet,Symbol tag,AtomList lst);
+ protected delegate void MethodObject(int inlet,object o);
// --------------------------------------------------------------------------
[MethodImplAttribute (MethodImplOptions.InternalCall)]
- protected extern static void AddMethod(int inlet,MethodBang m);
+ protected extern static void AddMethod(int inlet,Method m);
[MethodImplAttribute (MethodImplOptions.InternalCall)]
protected extern static void AddMethod(int inlet,MethodFloat m);
@@ -145,12 +149,35 @@ namespace PureData
protected extern static void AddMethod(int inlet,MethodList m);
[MethodImplAttribute (MethodImplOptions.InternalCall)]
+ protected extern static void AddMethod(int inlet,MethodAnything m);
+
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ protected extern static void AddMethod(int inlet,Symbol sel,Method m);
+
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ protected extern static void AddMethod(int inlet,Symbol sel,MethodFloat m);
+
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ protected extern static void AddMethod(int inlet,Symbol sel,MethodSymbol m);
+
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ protected extern static void AddMethod(int inlet,Symbol sel,MethodPointer m);
+
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ protected extern static void AddMethod(int inlet,Symbol sel,MethodList m);
+
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
protected extern static void AddMethod(int inlet,Symbol sel,MethodAnything m);
+ protected static void AddMethod(int inlet,string sel,Method m) { AddMethod(inlet,new Symbol(sel),m); }
+ protected static void AddMethod(int inlet,string sel,MethodFloat m) { AddMethod(inlet,new Symbol(sel),m); }
+ protected static void AddMethod(int inlet,string sel,MethodSymbol m) { AddMethod(inlet,new Symbol(sel),m); }
+ protected static void AddMethod(int inlet,string sel,MethodPointer m) { AddMethod(inlet,new Symbol(sel),m); }
+ protected static void AddMethod(int inlet,string sel,MethodList m) { AddMethod(inlet,new Symbol(sel),m); }
protected static void AddMethod(int inlet,string sel,MethodAnything m) { AddMethod(inlet,new Symbol(sel),m); }
[MethodImplAttribute (MethodImplOptions.InternalCall)]
- protected extern static void AddMethod(int inlet,MethodAnything m);
+ protected extern static void AddMethod(int inlet,MethodObject m);
// --------------------------------------------------------------------------
@@ -184,6 +211,8 @@ 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); }
+
// --------------------------------------------------------------------------
// bind to symbol
@@ -206,5 +235,8 @@ namespace PureData
[MethodImplAttribute (MethodImplOptions.InternalCall)]
protected extern static void Send(Symbol sym,Symbol s,Atom[] l);
+
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ protected extern static void SendEx(Symbol sym,object o);
}
}
diff --git a/clr.cpp b/clr.cpp
index c8c435f..635be6b 100755
--- a/clr.cpp
+++ b/clr.cpp
@@ -41,6 +41,9 @@ static MonoMethodDesc *clr_desc_tostring,*clr_desc_ctor;
static MonoMethod *clr_meth_invoke;
static MonoProperty *clr_prop_method;
+static t_symbol *sym_object;
+
+
struct AtomList
{
int argc;
@@ -49,10 +52,50 @@ struct AtomList
void Set(int c,t_atom *v) { argc = c,argv = v; }
};
+// transforms a pointer (like MonoObject *) into a 3 element-list
+struct ObjectAtom
+{
+ enum { size = 3,bitshift = 22 };
+
+ // 64-bit safe...
+ t_atom msg[size];
+
+ ObjectAtom() {}
+
+ ObjectAtom(void *o)
+ {
+ size_t ptr = (size_t)o;
+ for(int i = 0; i < size; ++i) {
+ SETFLOAT(msg+i,(int)(ptr&((1<<bitshift)-1)));
+ ptr >>= bitshift;
+ }
+ }
+
+ static bool check(int argc,const t_atom *argv)
+ {
+ if(argc != size) return false;
+ for(int i = 0; i < size; ++i)
+ if(argv[i].a_type != A_FLOAT) return false;
+ return true;
+ }
+
+ static void *ptr(const t_atom *argv)
+ {
+ size_t ret = 0;
+ for(int i = size-1; i >= 0; --i)
+ ret = (ret<<bitshift)+(int)argv[i].a_w.w_float;
+ return (void *)ret;
+ }
+
+ template<class T> static T ptr(const t_atom *argv) { return (T)ptr(argv); }
+
+ operator t_atom *() { return msg; }
+};
+
// temporary workspace items
-static MonoArray *clr_objarr_1,*clr_objarr_3;
+static MonoArray *clr_objarr_1,*clr_objarr_2,*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;
@@ -65,7 +108,7 @@ struct t_clr;
struct Delegate
{
- enum Kind { k_bang,k_float,k_symbol,k_pointer,k_list,k_anything };
+ enum Kind { k_bang,k_float,k_symbol,k_pointer,k_list,k_anything,k_object };
inline operator bool() const { return methodinfo != NULL; }
@@ -80,7 +123,7 @@ struct Delegate
kind = k;
}
- inline MonoObject *operator()(MonoObject *obj,void *arg = NULL) const
+ inline MonoObject *invoke(MonoObject *obj,void *arg) const
{
gpointer args[2] = {obj,arg};
assert(methodinfo);
@@ -92,7 +135,12 @@ struct Delegate
inline MonoObject *invokeatom(MonoObject *obj,MonoObject *atom) const
{
mono_array_set(clr_objarr_1,void*,0,atom);
- return operator()(obj,clr_objarr_1);
+ return invoke(obj,clr_objarr_1);
+ }
+
+ inline MonoObject *operator()(MonoObject *obj) const
+ {
+ return invoke(obj,NULL);
}
inline MonoObject *operator()(MonoObject *obj,float f) const
@@ -127,7 +175,15 @@ struct Delegate
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);
+ return invoke(obj,clr_objarr_3);
+ }
+
+ inline MonoObject *operator()(MonoObject *obj,int inlet,MonoObject *clrobj) const
+ {
+ *clr_val_int = inlet;
+ mono_array_set(clr_objarr_2,void*,0,clr_obj_int);
+ mono_array_set(clr_objarr_2,void*,1,clrobj);
+ return invoke(obj,clr_objarr_2);
}
};
@@ -144,7 +200,7 @@ struct t_clr_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;
+ Delegate method_bang,method_float,method_symbol,method_pointer,method_list,method_anything,method_object;
ClrMethods *methods; // explicit method selectors
};
@@ -226,7 +282,7 @@ static void clr_method_pointer(t_clr *x,t_gpointer *p)
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);
+ MonoObject *exc = x->clr_clss->method_list(x->mono_obj,argc,argv);
if(exc) error_exc("Exception raised",x->clr_clss->name->s_name,exc);
}
@@ -268,19 +324,27 @@ static void call_anything(t_clr *x,int inlet,t_symbol *s,int argc,t_atom *argv)
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);
+ if(argc == 0 || argv[0].a_type != A_FLOAT) {
+ 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:
- assert(argc == 1 && argv[0].a_type == A_SYMBOL);
+ if(argc == 0 || argv[0].a_type != A_SYMBOL) {
+ 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:
- assert(argc == 1 && argv[0].a_type == A_POINTER);
+ if(argc == 0 || argv[0].a_type != A_POINTER) {
+ 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:
@@ -289,6 +353,13 @@ static void call_anything(t_clr *x,int inlet,t_symbol *s,int argc,t_atom *argv)
case Delegate::k_anything:
exc = (*d)(x->mono_obj,inlet,s,argc,argv);
break;
+ case Delegate::k_object:
+ if(s != sym_object || !ObjectAtom::check(argc,argv)) {
+ error("CLR - object handler: invalid arguments");
+ return;
+ }
+ exc = (*d)(x->mono_obj,inlet,ObjectAtom::ptr<MonoObject *>(argv));
+ break;
default:
assert(false);
}
@@ -351,11 +422,6 @@ static void PD_AddMethodHandler(int inlet,t_symbol *sym,MonoObject *method,Deleg
(*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)
@@ -416,6 +482,41 @@ static void PD_AddMethodAnything(int inlet,MonoObject *method)
}
}
+static void PD_AddMethodSelBang(int inlet,t_symbol *sym,MonoObject *method)
+{
+ PD_AddMethodHandler(inlet,sym,method,Delegate::k_bang);
+}
+
+static void PD_AddMethodSelFloat(int inlet,t_symbol *sym,MonoObject *method)
+{
+ PD_AddMethodHandler(inlet,sym,method,Delegate::k_float);
+}
+
+static void PD_AddMethodSelSymbol(int inlet,t_symbol *sym,MonoObject *method)
+{
+ PD_AddMethodHandler(inlet,sym,method,Delegate::k_symbol);
+}
+
+static void PD_AddMethodSelPointer(int inlet,t_symbol *sym,MonoObject *method)
+{
+ PD_AddMethodHandler(inlet,sym,method,Delegate::k_pointer);
+}
+
+static void PD_AddMethodSelList(int inlet,t_symbol *sym,MonoObject *method)
+{
+ PD_AddMethodHandler(inlet,sym,method,Delegate::k_list);
+}
+
+static void PD_AddMethodSelAnything(int inlet,t_symbol *sym,MonoObject *method)
+{
+ PD_AddMethodHandler(inlet,sym,method,Delegate::k_anything);
+}
+
+static void PD_AddMethodObject(int inlet,MonoObject *method)
+{
+ PD_AddMethodHandler(inlet,sym_object,method,Delegate::k_object);
+}
+
static void PD_AddInletAlias(t_clr *obj,t_symbol *sel,t_symbol *to_sel)
{
@@ -538,6 +639,17 @@ static void PD_OutletAnything2(t_clr *obj,int n,t_symbol *s,MonoArray *l)
outlet_anything((*obj->outlets)[n],s,mono_array_length(l),mono_array_addr(l,t_atom,0));
}
+
+static void PD_OutletObject(t_clr *obj,int n,MonoObject *o)
+{
+ assert(obj);
+ assert(obj->outlets);
+ assert(n >= 0 && n < (int)obj->outlets->size());
+ ObjectAtom oa(o);
+ outlet_anything((*obj->outlets)[n],sym_object,oa.size,oa);
+}
+
+
static void PD_SendAtom(t_symbol *dst,t_atom a)
{
void *cl = dst->s_thing;
@@ -557,6 +669,17 @@ static void PD_SendAnything2(t_symbol *dst,t_symbol *s,MonoArray *l)
if(cl) pd_typedmess((t_class **)cl,s,mono_array_length(l),mono_array_addr(l,t_atom,0));
}
+static void PD_SendObject(t_symbol *dst,MonoObject *o)
+{
+ void *cl = dst->s_thing;
+// assert(mono_object_get_class(&l->obj) == clr_atom);
+ if(cl) {
+ ObjectAtom oa(o);
+ pd_typedmess((t_class **)cl,sym_object,oa.size,oa);
+ }
+}
+
+
void *clr_new(t_symbol *classname, int argc, t_atom *argv)
{
// find class name in map
@@ -623,7 +746,7 @@ void clr_free(t_clr *obj)
}
}
-static int classloader(char *dirname, char *classname)
+static int classloader(char *dirname, char *classname, char *altname)
{
t_clr_class *clr_class = NULL;
t_symbol *classsym;
@@ -632,12 +755,14 @@ static int classloader(char *dirname, char *classname)
MonoMethod *method;
int flags = CLASS_DEFAULT;
+ char *realname;
char dirbuf[MAXPDSTRING],*nameptr;
// search for classname.dll in the PD path
int fd;
- if ((fd = open_via_path(dirname, classname, "." DLLEXT, dirbuf, &nameptr, MAXPDSTRING, 1)) < 0)
- // not found
- goto bailout;
+ if ((fd = open_via_path(dirname, realname = classname, "." DLLEXT, dirbuf, &nameptr, MAXPDSTRING, 1)) < 0)
+ if (!altname || (fd = open_via_path(dirname, realname = altname, "." DLLEXT, dirbuf, &nameptr, MAXPDSTRING, 1)) < 0)
+ // not found
+ goto bailout;
// found
close(fd);
@@ -648,7 +773,7 @@ static int classloader(char *dirname, char *classname)
// try to load assembly
strcat(dirbuf,"/");
- strcat(dirbuf,classname);
+ strcat(dirbuf,realname);
strcat(dirbuf,"." DLLEXT);
assembly = mono_domain_assembly_open(monodomain,dirbuf);
@@ -662,7 +787,7 @@ static int classloader(char *dirname, char *classname)
// try to find class
// "" means no namespace
- clr_class->mono_class = mono_class_from_name(image,"",classname);
+ clr_class->mono_class = mono_class_from_name(image,"",realname);
if(!clr_class->mono_class) {
error("Can't find %s class in %s\n",classname,mono_image_get_filename(image));
goto bailout;
@@ -779,7 +904,7 @@ void clr_setup(void)
if(monodomain) {
// try to find PureData.dll in the PD path
char dirbuf[MAXPDSTRING],*nameptr;
- // search for classname.dll in the PD path
+ // search in the PD path
int fd;
if ((fd = open_via_path("",CORELIB,"." DLLEXT,dirbuf,&nameptr,MAXPDSTRING,1)) >= 0) {
strcat(dirbuf,"/" CORELIB "." DLLEXT);
@@ -807,13 +932,19 @@ void clr_setup(void)
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/Method)", (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.External::AddMethod(int,PureData.Symbol,PureData.External/Method)", (const void *)PD_AddMethodSelBang);
+ mono_add_internal_call("PureData.External::AddMethod(int,PureData.Symbol,PureData.External/MethodFloat)", (const void *)PD_AddMethodSelFloat);
+ mono_add_internal_call("PureData.External::AddMethod(int,PureData.Symbol,PureData.External/MethodSymbol)", (const void *)PD_AddMethodSelSymbol);
+ mono_add_internal_call("PureData.External::AddMethod(int,PureData.Symbol,PureData.External/MethodPointer)", (const void *)PD_AddMethodSelPointer);
+ mono_add_internal_call("PureData.External::AddMethod(int,PureData.Symbol,PureData.External/MethodList)", (const void *)PD_AddMethodSelList);
+ mono_add_internal_call("PureData.External::AddMethod(int,PureData.Symbol,PureData.External/MethodAnything)", (const void *)PD_AddMethodSelAnything);
+ mono_add_internal_call("PureData.External::AddMethod(int,PureData.External/MethodObject)", (const void *)PD_AddMethodObject);
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);
@@ -831,6 +962,7 @@ void clr_setup(void)
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::OutletEx(void*,int,object)", (const void *)PD_OutletObject);
// 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);
@@ -838,6 +970,7 @@ void clr_setup(void)
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);
+ mono_add_internal_call("PureData.External::SendEx(PureData.Symbol,object)", (const void *)PD_SendObject);
// load important classes
clr_symbol = mono_class_from_name(image,"PureData","Symbol");
@@ -866,6 +999,7 @@ void clr_setup(void)
// 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_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());
@@ -883,8 +1017,11 @@ void clr_setup(void)
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);
+ // symbol for Mono object handling
+ sym_object = gensym("clr-object");
+
// install loader hook
- sys_loader(classloader);
+ sys_register_loader(classloader);
// ready!
post("CLR extension - (c)2006 Davide Morelli, Thomas Grill");
diff --git a/test/AssemblyInfo.cs b/test/AssemblyInfo.cs
new file mode 100644
index 0000000..8783853
--- /dev/null
+++ b/test/AssemblyInfo.cs
@@ -0,0 +1,58 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+//
+// Allgemeine Informationen über eine Assembly werden über folgende Attribute
+// gesteuert. Ändern Sie diese Attributswerte, um die Informationen zu modifizieren,
+// die mit einer Assembly verknüpft sind.
+//
+[assembly: AssemblyTitle("")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+//
+// Versionsinformationen für eine Assembly bestehen aus folgenden vier Werten:
+//
+// Hauptversion
+// Nebenversion
+// Buildnummer
+// Revision
+//
+// Sie können alle Werte oder die standardmäßige Revision und Buildnummer
+// mit '*' angeben:
+
+[assembly: AssemblyVersion("1.0.*")]
+
+//
+// Um die Assembly zu signieren, müssen Sie einen Schlüssel angeben. Weitere Informationen
+// über die Assemblysignierung finden Sie in der Microsoft .NET Framework-Dokumentation.
+//
+// Mit den folgenden Attributen können Sie festlegen, welcher Schlüssel für die Signierung verwendet wird.
+//
+// Hinweise:
+// (*) Wenn kein Schlüssel angegeben ist, wird die Assembly nicht signiert.
+// (*) KeyName verweist auf einen Schlüssel, der im CSP (Crypto Service
+// Provider) auf Ihrem Computer installiert wurde. KeyFile verweist auf eine Datei, die einen
+// Schlüssel enthält.
+// (*) Wenn die Werte für KeyFile und KeyName angegeben werden,
+// werden folgende Vorgänge ausgeführt:
+// (1) Wenn KeyName im CSP gefunden wird, wird dieser Schlüssel verwendet.
+// (2) Wenn KeyName nicht vorhanden ist und KeyFile vorhanden ist,
+// wird der Schlüssel in KeyFile im CSP installiert und verwendet.
+// (*) Um eine KeyFile zu erstellen, können Sie das Programm sn.exe (Strong Name) verwenden.
+// Wenn KeyFile angegeben wird, muss der Pfad von KeyFile
+// relativ zum Projektausgabeverzeichnis sein:
+// %Project Directory%\obj\<configuration>. Wenn sich KeyFile z.B.
+// im Projektverzeichnis befindet, geben Sie das AssemblyKeyFile-Attribut
+// wie folgt an: [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
+// (*) Das verzögern der Signierung ist eine erweiterte Option. Weitere Informationen finden Sie in der
+// Microsoft .NET Framework-Dokumentation.
+//
+[assembly: AssemblyDelaySign(false)]
+[assembly: AssemblyKeyFile("")]
+[assembly: AssemblyKeyName("")]
diff --git a/test-clr.pd b/test/test-help.pd
index 653f984..ca7d7eb 100755..100644
--- a/test-clr.pd
+++ b/test/test-help.pd
@@ -1,8 +1,7 @@
-#N canvas 617 153 842 609 12;
+#N canvas 617 153 850 617 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 - - -;
#X msg 213 52 1 \$1 3;
@@ -31,29 +30,30 @@
#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;
-#X connect 2 0 3 0;
-#X connect 3 0 15 0;
-#X connect 4 0 9 0;
-#X connect 5 0 6 0;
-#X connect 6 0 3 0;
+#X obj 151 443 test a b 5;
+#X connect 0 0 30 0;
+#X connect 1 0 30 0;
+#X connect 2 0 30 0;
+#X connect 3 0 8 0;
+#X connect 4 0 5 0;
+#X connect 5 0 30 0;
+#X connect 6 0 1 0;
#X connect 7 0 1 0;
-#X connect 8 0 1 0;
-#X connect 9 0 3 0;
-#X connect 10 0 3 0;
-#X connect 11 0 3 0;
-#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;
-#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;
+#X connect 8 0 30 0;
+#X connect 9 0 30 0;
+#X connect 10 0 30 0;
+#X connect 11 0 30 0;
+#X connect 12 0 30 0;
+#X connect 13 0 30 1;
+#X connect 15 0 30 2;
+#X connect 16 0 17 0;
+#X connect 17 0 30 0;
+#X connect 19 0 18 0;
+#X connect 20 0 21 0;
+#X connect 22 0 30 3;
+#X connect 23 0 30 3;
+#X connect 26 0 30 3;
+#X connect 27 0 30 1;
+#X connect 28 0 30 3;
+#X connect 29 0 30 1;
+#X connect 30 0 14 0;
diff --git a/test/test.cs b/test/test.cs
new file mode 100644
index 0000000..cfde7c6
--- /dev/null
+++ b/test/test.cs
@@ -0,0 +1,93 @@
+using System;
+
+public class test:
+ PureData.External
+{
+ PureData.Atom[] args;
+
+ float farg;
+
+ public test(PureData.AtomList args)
+ {
+ Post("Test.ctor "+args.ToString());
+
+ // that's the way to store args (don't just copy an AtomList instance!!)
+ this.args = (PureData.Atom[])args;
+
+ // AddInlet(s_list,new PureData.Symbol("list2"));
+ AddInlet();
+ AddInlet(ref farg);
+ AddInlet();
+ AddOutletBang();
+ }
+
+ // this function MUST exist
+ // returns void or ClassType
+ private static ClassType Setup(test obj)
+ {
+ AddMethod(0,new Method(obj.MyBang));
+ AddMethod(0,new MethodFloat(obj.MyFloat));
+ AddMethod(0,new MethodSymbol(obj.MySymbol));
+ AddMethod(0,new MethodList(obj.MyList));
+ AddMethod(0,"set",new MethodAnything(obj.MySet));
+ AddMethod(0,"send",new MethodAnything(obj.MySend));
+ AddMethod(0,new MethodAnything(obj.MyAnything));
+ AddMethod(1,new MethodFloat(obj.MyFloat1));
+ AddMethod(1,new MethodAnything(obj.MyAny1));
+
+ Post("Test.Main");
+ return ClassType.Default;
+ }
+
+ protected virtual void MyBang()
+ {
+ Post("Test-BANG "+farg.ToString());
+ Outlet(0);
+ }
+
+ protected virtual void MyFloat(float f)
+ {
+ Post("Test-FLOAT "+f.ToString());
+ Outlet(0,f);
+ }
+
+ protected virtual void MyFloat1(float f)
+ {
+ Post("Test-FLOAT1 "+f.ToString());
+ }
+
+ protected virtual void MyAny1(int ix,PureData.Symbol s,PureData.AtomList l)
+ {
+ Post(ix.ToString()+": Test-ANY1 "+l.ToString());
+ }
+
+ protected virtual void MySymbol(PureData.Symbol s)
+ {
+ Post("Test-SYMBOL "+s.ToString());
+ Outlet(0,s);
+ }
+
+ protected virtual void MyList(PureData.AtomList l)
+ {
+ Post("Test-LIST "+l.ToString());
+ Outlet(0,l);
+ }
+
+ protected virtual void MySet(int ix,PureData.Symbol s,PureData.AtomList l)
+ {
+ Post("Test-SET "+l.ToString());
+ Outlet(0,new PureData.Symbol("set"),l);
+ }
+
+ protected virtual void MySend(int ix,PureData.Symbol s,PureData.AtomList l)
+ {
+ Send(new PureData.Symbol("receiver"),l);
+ Send(new PureData.Symbol("receiver2"),(PureData.Atom[])l);
+ }
+
+ protected virtual void MyAnything(int ix,PureData.Symbol s,PureData.AtomList l)
+ {
+ Post(ix.ToString()+": Test-("+s.ToString()+") "+l.ToString());
+ Outlet(0,s,l);
+ }
+}
diff --git a/test/test.csproj b/test/test.csproj
new file mode 100644
index 0000000..d4f4e7d
--- /dev/null
+++ b/test/test.csproj
@@ -0,0 +1,105 @@
+<VisualStudioProject>
+ <CSHARP
+ ProjectType = "Local"
+ ProductVersion = "7.10.3077"
+ SchemaVersion = "2.0"
+ ProjectGuid = "{6CED2448-6407-4AF7-95B6-932D8118AF3D}"
+ >
+ <Build>
+ <Settings
+ ApplicationIcon = ""
+ AssemblyKeyContainerName = ""
+ AssemblyName = "Test"
+ AssemblyOriginatorKeyFile = ""
+ DefaultClientScript = "JScript"
+ DefaultHTMLPageLayout = "Grid"
+ DefaultTargetSchema = "IE50"
+ DelaySign = "false"
+ OutputType = "Library"
+ PreBuildEvent = ""
+ PostBuildEvent = ""
+ RootNamespace = "Test"
+ RunPostBuildEvent = "OnBuildSuccess"
+ StartupObject = ""
+ >
+ <Config
+ Name = "Debug"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "DEBUG;TRACE"
+ DocumentationFile = ""
+ DebugSymbols = "true"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = ""
+ Optimize = "false"
+ OutputPath = "bin\Debug\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "4"
+ />
+ <Config
+ Name = "Release"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "TRACE"
+ DocumentationFile = ""
+ DebugSymbols = "false"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = ""
+ Optimize = "true"
+ OutputPath = "bin\Release\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "4"
+ />
+ </Settings>
+ <References>
+ <Reference
+ Name = "System"
+ AssemblyName = "System"
+ HintPath = "..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll"
+ />
+ <Reference
+ Name = "System.Data"
+ AssemblyName = "System.Data"
+ HintPath = "..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Data.dll"
+ />
+ <Reference
+ Name = "System.XML"
+ AssemblyName = "System.XML"
+ HintPath = "..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll"
+ />
+ <Reference
+ Name = "PureData"
+ Project = "{0015D5E7-B0FB-4F06-B334-225447D1F992}"
+ Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
+ />
+ </References>
+ </Build>
+ <Files>
+ <Include>
+ <File
+ RelPath = "AssemblyInfo.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "test.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ </Include>
+ </Files>
+ </CSHARP>
+</VisualStudioProject>
+