[PD-cvs] externals/clr/external External.cs,1.4,1.5 pd.cs,1.4,1.5
dmorelli
morellid at users.sourceforge.net
Fri Jan 13 20:02:39 CET 2006
Update of /cvsroot/pure-data/externals/clr/external
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12601/external
Modified Files:
External.cs pd.cs
Log Message:
lists of atom working! still missing output
Index: External.cs
===================================================================
RCS file: /cvsroot/pure-data/externals/clr/external/External.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** External.cs 13 Jan 2006 13:02:22 -0000 1.4
--- External.cs 13 Jan 2006 19:02:37 -0000 1.5
***************
*** 31,37 ****
pd.AddSelector(x, "selFloat", "SelFloat", ParametersType.Float);
pd.AddSelector(x, "selString", "SelString", ParametersType.Symbol);
- pd.AddSelector(x, "selList", "SelList", ParametersType.List);
- pd.AddSelector(x, "selStringList", "SelStringList", ParametersType.List);
- pd.AddSelector(x, "selFloatList", "SelFloatList", ParametersType.List);
pd.AddSelector(x, "selGenericList", "SelGenericList", ParametersType.List);
Console.WriteLine("selectors set");
--- 31,34 ----
***************
*** 50,53 ****
--- 47,57 ----
{
pd.PostMessage("Sel2 invoked!");
+
+ // testing outlets
+ Atom[] atoms = new Atom[2];
+ atoms[0] = new Atom("ciao");
+ atoms[1] = new Atom(1.5f);
+ pd.ToOutlet(x, 0, atoms.Length, atoms);
+
}
***************
*** 55,127 ****
{
pd.PostMessage("SelFloat received " + f);
- }
- public void SelString(ref string s)
- {
- pd.PostMessage("SelString received " + s);
- }
-
- public void SelList(int [] list)
- {
- pd.PostMessage("SelList received " + list.Length + " elements");
- for (int i = 0; i<list.Length; i++)
- {
- pd.PostMessage("int " + i + " = " + list[i]);
- }
- }
- public void SelStringList(string [] list)
- {
- pd.PostMessage("SetStringList received a " + list.Length + " long list");
- for (int i = 0; i<list.Length; i++)
- {
- pd.PostMessage("string " + i + " = " + list[i]);
- }
}
! public void SelFloatList(float [] list)
{
! pd.PostMessage("SetStringList received a " + list.Length + " long list");
! for (int i = 0; i<list.Length; i++)
! {
! pd.PostMessage("float " + i + " = " + list[i]);
! }
}
-
- public void SelGenericList(Atom a)
- {
-
- Console.WriteLine("a is type " + a.type);
- Console.WriteLine("float = " + a.float_value);
- Console.WriteLine("stringa = " + a.string_value);
-
- }
-
-
- /*
public void SelGenericList(Atom [] list)
{
- pd.PostMessage("SetStringList received a " + list.Length + " long list");
for (int i = 0; i<list.Length; i++)
{
Atom a = (Atom) list[i];
! Console.WriteLine("a is type " + a.type);
! Console.WriteLine("float = " + a.float_value);
! Console.WriteLine("stringa = " + a.string_value);
! pd.PostMessage("a is type " + a.type);
! pd.PostMessage("float = " + a.float_value);
! pd.PostMessage("stringa = " + a.string_value);
}
}
- */
- public int test(int a)
- {
-
- Console.WriteLine("test("+a+")");
- return a+1;
- }
}
--- 59,98 ----
{
pd.PostMessage("SelFloat received " + f);
}
! public void SelString(ref string s)
{
! pd.PostMessage("SelString received " + s);
}
public void SelGenericList(Atom [] list)
{
for (int i = 0; i<list.Length; i++)
{
Atom a = (Atom) list[i];
! switch (a.type)
! {
! case (AtomType.Null):
! {
! pd.PostMessage("element null");
! break;
! }
! case (AtomType.Float):
! {
! pd.PostMessage("" + a.float_value);
! break;
! }
! case (AtomType.Symbol):
! {
! pd.PostMessage(a.string_value);
! break;
! }
! }
}
}
}
Index: pd.cs
===================================================================
RCS file: /cvsroot/pure-data/externals/clr/external/pd.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** pd.cs 13 Jan 2006 13:02:22 -0000 1.4
--- pd.cs 13 Jan 2006 19:02:37 -0000 1.5
***************
*** 21,25 ****
// send stuff to an outlet
[MethodImplAttribute (MethodImplOptions.InternalCall)]
! public extern static void ToOutlet (IntPtr x, int outlet, int type /*, ? array of values */);
// create an outlet
--- 21,29 ----
// send stuff to an outlet
[MethodImplAttribute (MethodImplOptions.InternalCall)]
! public extern static void ToOutlet (IntPtr x, int outlet, int atoms_length, [In, Out] Atom [] atoms);
! public static void SendToOutlet (IntPtr x, int outlet, [In, Out] Atom [] atoms)
! {
! ToOutlet (x, outlet, atoms.Length, atoms);
! }
// create an outlet
***************
*** 48,199 ****
}
-
- /*
- // simplyfied atom
- typedef struct atom_simple atom_simple;
- typedef enum
- {
- A_S_NULL=0,
- A_S_FLOAT=1,
- A_S_SYMBOL=2,
- } t_atomtype_simple;
- typedef struct atom_simple
- {
- t_atomtype_simple a_type;
- union{
- float float_value;
- MonoString *string_value;
- } stuff;
- };
- */
-
public enum AtomType {Null = 0, Float=1, Symbol=2, List=3};
!
! [StructLayout (LayoutKind.Explicit)]
! // [StructLayout (LayoutKind.Sequential)]
! public class Atom2
{
! //[FieldOffset (0)] AtomType type;
! //[FieldOffset (0)] public int type;
! [FieldOffset (0)]
! public int type;
!
! [FieldOffset (4)]
public float float_value;
-
- // [FieldOffset (4)]
- [FieldOffset (8)]
public string string_value;
!
!
! public Atom2()
{
! this.type = 0;
! this.float_value = 0;
! this.string_value = "";
}
!
! public Atom2(string string_value)
{
! this.type = 2;
this.float_value = 0;
! this.string_value = string_value;
! }
! public Atom2(float float_value)
! {
! this.type = 1;
! this.string_value = "";
! this.float_value = float_value;
}
}
-
-
-
- //[StructLayout (LayoutKind.Explicit)]
- [StructLayout (LayoutKind.Sequential)]
- public struct Atom
- {
- public int type;
- public float float_value;
- public string string_value;
- }
! /*
! typedef float t_floatarg;
!
! typedef struct _symbol
! {
! char *s_name;
! struct _class **s_thing;
! struct _symbol *s_next;
! } t_symbol;
! EXTERN_STRUCT _array;
! #define t_array struct _array
- #define GP_NONE 0
- #define GP_GLIST 1
- #define GP_ARRAY 2
! typedef struct _gstub
! {
! union
! {
! struct _glist *gs_glist;
! struct _array *gs_array;
! } gs_un;
! int gs_which;
! int gs_refcount;
! } t_gstub;
! typedef struct _gpointer
! {
! union
! {
! struct _scalar *gp_scalar;
! union word *gp_w;
! } gp_un;
! int gp_valid;
! t_gstub *gp_stub;
! } t_gpointer;
! typedef union word
{
! t_float w_float;
! t_symbol *w_symbol;
! t_gpointer *w_gpointer;
! t_array *w_array;
! struct _glist *w_list;
! int w_index;
! } t_word;
! typedef enum
! {
! A_NULL,
! A_FLOAT,
! A_SYMBOL,
! A_POINTER,
! A_SEMI,
! A_COMMA,
! A_DEFFLOAT,
! A_DEFSYM,
! A_DOLLAR,
! A_DOLLSYM,
! A_GIMME,
! A_CANT
! } t_atomtype;
! #define A_DEFSYMBOL A_DEFSYM
! typedef struct _atom
! {
! t_atomtype a_type;
! union word a_w;
! } t_atom;
! */
}
--- 52,172 ----
+ /*
+ // simplyfied atom
+ typedef struct atom_simple atom_simple;
+ typedef enum
+ {
+ A_S_NULL=0,
+ A_S_FLOAT=1,
+ A_S_SYMBOL=2,
+ } t_atomtype_simple;
+ typedef struct atom_simple
+ {
+ t_atomtype_simple a_type;
+ union{
+ float float_value;
+ MonoString *string_value;
+ } stuff;
+ };
+ */
}
public enum AtomType {Null = 0, Float=1, Symbol=2, List=3};
! //[StructLayout (LayoutKind.Explicit)]
! [StructLayout (LayoutKind.Sequential)]
! public struct Atom
{
! public AtomType type;
public float float_value;
public string string_value;
! public Atom(float f)
{
! this.type = AtomType.Float;
! this.float_value = f;
! this.string_value = "float";
}
! public Atom(string s)
{
! this.type = AtomType.Symbol;
this.float_value = 0;
! this.string_value = s;
}
}
! /*
! typedef float t_floatarg;
! typedef struct _symbol
! {
! char *s_name;
! struct _class **s_thing;
! struct _symbol *s_next;
! } t_symbol;
+ EXTERN_STRUCT _array;
+ #define t_array struct _array
! #define GP_NONE 0
! #define GP_GLIST 1
! #define GP_ARRAY 2
! typedef struct _gstub
! {
! union
! {
! struct _glist *gs_glist;
! struct _array *gs_array;
! } gs_un;
! int gs_which;
! int gs_refcount;
! } t_gstub;
! typedef struct _gpointer
{
! union
! {
! struct _scalar *gp_scalar;
! union word *gp_w;
! } gp_un;
! int gp_valid;
! t_gstub *gp_stub;
! } t_gpointer;
! typedef union word
! {
! t_float w_float;
! t_symbol *w_symbol;
! t_gpointer *w_gpointer;
! t_array *w_array;
! struct _glist *w_list;
! int w_index;
! } t_word;
! typedef enum
! {
! A_NULL,
! A_FLOAT,
! A_SYMBOL,
! A_POINTER,
! A_SEMI,
! A_COMMA,
! A_DEFFLOAT,
! A_DEFSYM,
! A_DOLLAR,
! A_DOLLSYM,
! A_GIMME,
! A_CANT
! } t_atomtype;
! #define A_DEFSYMBOL A_DEFSYM
!
! typedef struct _atom
! {
! t_atomtype a_type;
! union word a_w;
! } t_atom;
! */
}
More information about the Pd-cvs
mailing list