From 20854f57a1617b4f662516445d20778ddbd6552d Mon Sep 17 00:00:00 2001 From: Davide Morelli Date: Thu, 12 Jan 2006 09:24:23 +0000 Subject: checking in the c sharp part svn path=/trunk/externals/clr/; revision=4388 --- external/External.cs | 104 ++++++++++++++++++++++++++++++++++++++++++++++ external/external.csproj | 105 +++++++++++++++++++++++++++++++++++++++++++++++ external/pd.cs | 49 ++++++++++++++++++++++ 3 files changed, 258 insertions(+) create mode 100755 external/External.cs create mode 100755 external/external.csproj create mode 100755 external/pd.cs diff --git a/external/External.cs b/external/External.cs new file mode 100755 index 0000000..3923f06 --- /dev/null +++ b/external/External.cs @@ -0,0 +1,104 @@ +using System; + + +namespace PureData +{ + + + + public class External + { + private IntPtr x; + + public External() + { + x = IntPtr.Zero; + } + + + + // this function MUST exist + public void SetUp(IntPtr pdClass) + { + // you must assign pdclass to x ! + x = pdClass; + + // now you can do what you like... + Console.WriteLine("pointer set!"); + Console.WriteLine("setting selectors.."); + pd.AddSelector(x, "sel1", "Sel1", ParametersType.None); + pd.AddSelector(x, "sel2", "Sel2", ParametersType.None); + 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); + Console.WriteLine("selectors set"); + pd.AddOutlet(x, ParametersType.Float); + pd.AddInlet(x, "selFloat", ParametersType.Float); + } + + + + + public void Sel1() + { + pd.PostMessage("Sel1 invoked!"); + } + + public void Sel2() + { + pd.PostMessage("Sel2 invoked!"); + } + + public void SelFloat(float f) + { + 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 + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/pd.cs b/external/pd.cs new file mode 100755 index 0000000..c844195 --- /dev/null +++ b/external/pd.cs @@ -0,0 +1,49 @@ +using System; +using System.Runtime.CompilerServices; + +namespace PureData +{ + public enum ParametersType {None = 0, Float=1, Symbol=2, List=3}; + + 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)] + public extern static void ToOutlet (IntPtr x, int outlet, int type /*, ? array of values */); + + // create an outlet + [MethodImplAttribute (MethodImplOptions.InternalCall)] + private extern static void CreateOutlet (IntPtr x, int type); + // function called by the user + public static void AddOutlet(IntPtr x, ParametersType type) + { + CreateOutlet (x, (int) type); + } + + // create an inlet + [MethodImplAttribute (MethodImplOptions.InternalCall)] + private extern static void CreateInlet (IntPtr x, string selector, int type); + // function called by the user + public static void AddInlet(IntPtr x, string selector, ParametersType type) + { + CreateInlet (x, selector, (int) type); + } + + [MethodImplAttribute (MethodImplOptions.InternalCall)] + public extern static void PostMessage (string message); + + [MethodImplAttribute (MethodImplOptions.InternalCall)] + public extern static void ErrorMessage (string message); + + + } +} -- cgit v1.2.1