Update of /cvsroot/pure-data/externals/clr/external In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20331
Added Files: External.cs external.csproj pd.cs Log Message: checking in the c sharp part
--- NEW FILE: External.cs --- 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<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(int [] list) { pd.PostMessage("SetStringList received a " + list.Length + " long list"); for (int i = 0; i<list.Length; i++) { pd.PostMessage("float " + i + " = " + list[0]); } }
public int test(int a) {
Console.WriteLine("test("+a+")"); return a+1; } }
}
--- NEW FILE: pd.cs --- 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);
} }
--- NEW FILE: external.csproj --- <VisualStudioProject> <CSHARP ProjectType = "Local" ProductVersion = "7.10.3077" SchemaVersion = "2.0" ProjectGuid = "{FFBC9D2E-1FB7-4E82-B5DC-46B31F8A58A2}" > <Build> <Settings ApplicationIcon = "" AssemblyKeyContainerName = "" AssemblyName = "PureData" AssemblyOriginatorKeyFile = "" DefaultClientScript = "JScript" DefaultHTMLPageLayout = "Grid" DefaultTargetSchema = "IE50" DelaySign = "false" OutputType = "Library" PreBuildEvent = "" PostBuildEvent = "" RootNamespace = "PureData" 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" /> </References> </Build> <Files> <Include> <File RelPath = "AssemblyInfo.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "External.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "pd.cs" SubType = "Code" BuildAction = "Compile" /> </Include> </Files> </CSHARP> </VisualStudioProject>