Update of /cvsroot/pure-data/externals/clr/pd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2201/pd
Modified Files: Atom.cs pd.cs Log Message: now selectors take delegates instead of function names, lists without selectors ok, added the PureData.dll assembly to let people compile externals without having to compile the pd project
Index: pd.cs =================================================================== RCS file: /cvsroot/pure-data/externals/clr/pd/pd.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pd.cs 16 Jan 2006 12:44:45 -0000 1.2 --- pd.cs 16 Jan 2006 16:26:58 -0000 1.3 *************** *** 10,22 **** public class pd { [MethodImplAttribute (MethodImplOptions.InternalCall)] private extern static void RegisterSelector (IntPtr x, string sel, string met, int type); // function called by the user ! public static void AddSelector(IntPtr x, string sel, string met, ParametersType type) { ! RegisterSelector (x, sel, met, (int) type); }
- // TODO // send stuff to an outlet [MethodImplAttribute (MethodImplOptions.InternalCall)] --- 10,54 ---- public class pd { + public delegate void DelegateWithoutArguments(); + public delegate void DelegateFloat(float f); + public delegate void DelegateString(ref string s); + public delegate void DelegateArray(Atom [] atoms); + [MethodImplAttribute (MethodImplOptions.InternalCall)] private extern static void RegisterSelector (IntPtr x, string sel, string met, int type); // function called by the user ! public static void AddSelector(IntPtr x, string sel, DelegateWithoutArguments func) { ! RegisterSelector (x, sel, func.Method.Name, (int) ParametersType.None); ! } ! public static void AddSelector(IntPtr x, string sel, DelegateFloat func) ! { ! RegisterSelector (x, sel, func.Method.Name, (int) ParametersType.Float); ! } ! public static void AddSelector(IntPtr x, string sel, DelegateString func) ! { ! RegisterSelector (x, sel, func.Method.Name, (int) ParametersType.Symbol); ! } ! public static void AddSelector(IntPtr x, string sel, DelegateArray func) ! { ! RegisterSelector (x, sel, func.Method.Name, (int) ParametersType.List); ! } ! public static void AddSelector(IntPtr x, DelegateWithoutArguments func) ! { ! RegisterSelector (x, "", func.Method.Name, (int) ParametersType.None); ! } ! public static void AddSelector(IntPtr x, DelegateFloat func) ! { ! RegisterSelector (x, "", func.Method.Name, (int) ParametersType.Float); ! } ! public static void AddSelector(IntPtr x, DelegateString func) ! { ! RegisterSelector (x, "", func.Method.Name, (int) ParametersType.Symbol); ! } ! public static void AddSelector(IntPtr x, DelegateArray func) ! { ! RegisterSelector (x, "", func.Method.Name, (int) ParametersType.List); }
// send stuff to an outlet [MethodImplAttribute (MethodImplOptions.InternalCall)] *************** *** 32,35 **** --- 64,86 ---- ToOutlet (x, outlet, atoms.Length, atoms); } + public static void SendToOutlet (IntPtr x, int outlet, float f) + { + Atom [] atoms = new Atom[1]; + atoms[0] = new Atom(f); + ToOutlet (x, outlet, atoms.Length, atoms); + } + public static void SendToOutlet (IntPtr x, int outlet, int i) + { + Atom [] atoms = new Atom[1]; + atoms[0] = new Atom((float) i); + ToOutlet (x, outlet, atoms.Length, atoms); + } + public static void SendToOutlet (IntPtr x, int outlet, string s) + { + Atom [] atoms = new Atom[1]; + atoms[0] = new Atom(s); + ToOutlet (x, outlet, atoms.Length, atoms); + } + // create an outlet [MethodImplAttribute (MethodImplOptions.InternalCall)] *************** *** 56,156 **** public extern static void ErrorMessage (string message);
- - /* - // 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; - }; - */ }
! /* ! 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; ! */
} --- 107,114 ---- public extern static void ErrorMessage (string message);
}
!
}
Index: Atom.cs =================================================================== RCS file: /cvsroot/pure-data/externals/clr/pd/Atom.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Atom.cs 16 Jan 2006 12:44:45 -0000 1.2 --- Atom.cs 16 Jan 2006 16:26:58 -0000 1.3 *************** *** 32,34 **** } } ! } \ No newline at end of file --- 32,54 ---- } } ! // this struct is relative to this c struct, see clr.c ! ! /* ! // 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; ! }; ! */ ! }