aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xCounter/Counter.cs4
-rwxr-xr-xPureData/Atom.cs2
-rw-r--r--PureData/PureData.cs3
-rwxr-xr-xclr.cpp19
4 files changed, 24 insertions, 4 deletions
diff --git a/Counter/Counter.cs b/Counter/Counter.cs
index b59945e..13688e5 100755
--- a/Counter/Counter.cs
+++ b/Counter/Counter.cs
@@ -23,7 +23,8 @@ public class Counter:
}
// this function MUST exist
- private static void Setup(Counter obj)
+ // returns void or ClassType
+ private static ClassType Setup(Counter obj)
{
Add(new MethodBang(obj.MyBang));
Add(new MethodFloat(obj.MyFloat));
@@ -34,6 +35,7 @@ public class Counter:
Add(new MethodAnything(obj.MyAnything));
Post("Count.Main");
+ return ClassType.Default;
}
protected virtual void MyBang()
diff --git a/PureData/Atom.cs b/PureData/Atom.cs
index 6a29483..6bad0b6 100755
--- a/PureData/Atom.cs
+++ b/PureData/Atom.cs
@@ -189,7 +189,7 @@ namespace PureData
// attention: this is dangerous, because we could do the following
// AtomList l2 = l;
- // with l also being an AtomList... the two private memebers will get copied, although atoms is only a temporary reference
+ // with l also being an AtomList... the two private members of the struct will get copied, although atoms is only a temporary reference
[StructLayout (LayoutKind.Sequential)]
unsafe public struct AtomList
diff --git a/PureData/PureData.cs b/PureData/PureData.cs
index ebbc319..8dbac5b 100644
--- a/PureData/PureData.cs
+++ b/PureData/PureData.cs
@@ -71,6 +71,9 @@ namespace PureData
// PD object pointer
private readonly void *ptr;
+ // to be returned by Setup function
+ protected enum ClassType { Default = 0,PD = 1,GObj = 2,Patchable = 3,NoInlet = 8 }
+
// --------------------------------------------------------------------------
protected readonly static Symbol s__ = new Symbol("");
diff --git a/clr.cpp b/clr.cpp
index 7a5af73..656a5f8 100755
--- a/clr.cpp
+++ b/clr.cpp
@@ -381,6 +381,7 @@ static void PD_OutletBang(t_clr *obj,int n)
{
assert(obj);
assert(obj->outlets);
+ assert(n >= 0 && n < obj->outlets->size());
outlet_bang((*obj->outlets)[n]);
}
@@ -388,6 +389,7 @@ static void PD_OutletFloat(t_clr *obj,int n,float f)
{
assert(obj);
assert(obj->outlets);
+ assert(n >= 0 && n < obj->outlets->size());
outlet_float((*obj->outlets)[n],f);
}
@@ -395,6 +397,7 @@ static void PD_OutletSymbol(t_clr *obj,int n,t_symbol *s)
{
assert(obj);
assert(obj->outlets);
+ assert(n >= 0 && n < obj->outlets->size());
outlet_symbol((*obj->outlets)[n],s);
}
@@ -402,6 +405,7 @@ static void PD_OutletPointer(t_clr *obj,int n,t_gpointer *p)
{
assert(obj);
assert(obj->outlets);
+ assert(n >= 0 && n < obj->outlets->size());
outlet_pointer((*obj->outlets)[n],p);
}
@@ -409,6 +413,7 @@ static void PD_OutletAtom(t_clr *obj,int n,t_atom l)
{
assert(obj);
assert(obj->outlets);
+ assert(n >= 0 && n < obj->outlets->size());
t_outlet *out = (*obj->outlets)[n];
switch(l.a_type) {
case A_FLOAT: outlet_float(out,l.a_w.w_float); break;
@@ -423,6 +428,7 @@ static void PD_OutletAnything(t_clr *obj,int n,t_symbol *s,AtomList l)
{
assert(obj);
assert(obj->outlets);
+ assert(n >= 0 && n < obj->outlets->size());
outlet_anything((*obj->outlets)[n],s,l.argc,l.argv);
}
@@ -430,6 +436,7 @@ static void PD_OutletAnything2(t_clr *obj,int n,t_symbol *s,MonoArray *l)
{
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));
}
@@ -555,7 +562,8 @@ static int classloader(char *dirname, char *classname)
// 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->pd_class = NULL;
+ int flags = CLASS_DEFAULT;
clr_class->obj_field = mono_class_get_field_from_name(clr_class->mono_class,"ptr");
assert(clr_class->obj_field);
@@ -582,7 +590,11 @@ static int classloader(char *dirname, char *classname)
// call static Main method
gpointer args = obj;
MonoObject *exc;
- mono_runtime_invoke(method,NULL,&args,&exc);
+ MonoObject *ret = mono_runtime_invoke(method,NULL,&args,&exc);
+ if(ret) {
+ // \TODO check return type
+ flags = *(int *)mono_object_unbox(ret);
+ }
// unset current class
clr_setup_class = NULL;
@@ -598,6 +610,9 @@ static int classloader(char *dirname, char *classname)
// find and save constructor
clr_class->mono_ctor = mono_method_desc_search_in_class(clr_desc_ctor,clr_class->mono_class);
+ // make pd class
+ 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);