[PD-cvs] externals/clr/pd PureData.cs, NONE, 1.1 AssemblyInfo.cs, 1.1, 1.2 Atom.cs, 1.3, 1.4 pd.csproj, 1.1, 1.2 pd.cs, 1.3, NONE

Thomas Grill xovo at users.sourceforge.net
Fri Jan 27 23:50:03 CET 2006


Update of /cvsroot/pure-data/externals/clr/pd
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4091

Modified Files:
	AssemblyInfo.cs Atom.cs pd.csproj 
Added Files:
	PureData.cs 
Removed Files:
	pd.cs 
Log Message:
new interface to internal functions

--- pd.cs DELETED ---

Index: AssemblyInfo.cs
===================================================================
RCS file: /cvsroot/pure-data/externals/clr/pd/AssemblyInfo.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** AssemblyInfo.cs	14 Jan 2006 02:34:17 -0000	1.1
--- AssemblyInfo.cs	27 Jan 2006 22:50:00 -0000	1.2
***************
*** 12,16 ****
  [assembly: AssemblyCompany("")]
  [assembly: AssemblyProduct("")]
! [assembly: AssemblyCopyright("Davide Morelli")]
  [assembly: AssemblyTrademark("")]
  [assembly: AssemblyCulture("")]		
--- 12,16 ----
  [assembly: AssemblyCompany("")]
  [assembly: AssemblyProduct("")]
! [assembly: AssemblyCopyright("Davide Morelli, Thomas Grill")]
  [assembly: AssemblyTrademark("")]
  [assembly: AssemblyCulture("")]		

Index: pd.csproj
===================================================================
RCS file: /cvsroot/pure-data/externals/clr/pd/pd.csproj,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** pd.csproj	14 Jan 2006 02:34:17 -0000	1.1
--- pd.csproj	27 Jan 2006 22:50:00 -0000	1.2
***************
*** 37,41 ****
                      NoWarn = ""
                      Optimize = "false"
!                     OutputPath = "bin\Debug\"
                      RegisterForComInterop = "false"
                      RemoveIntegerChecks = "false"
--- 37,41 ----
                      NoWarn = ""
                      Optimize = "false"
!                     OutputPath = "..\"
                      RegisterForComInterop = "false"
                      RemoveIntegerChecks = "false"
***************
*** 95,99 ****
                  />
                  <File
!                     RelPath = "pd.cs"
                      SubType = "Code"
                      BuildAction = "Compile"
--- 95,99 ----
                  />
                  <File
!                     RelPath = "PureData.cs"
                      SubType = "Code"
                      BuildAction = "Compile"

Index: Atom.cs
===================================================================
RCS file: /cvsroot/pure-data/externals/clr/pd/Atom.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Atom.cs	16 Jan 2006 16:26:58 -0000	1.3
--- Atom.cs	27 Jan 2006 22:50:00 -0000	1.4
***************
*** 4,35 ****
  namespace PureData
  {
! 	public enum AtomType {Null = 0, Float=1, Symbol=2, List=3, Bang=4};
  
! 	//[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(int i)
  		{
! 			this.type = AtomType.Float;
! 			this.float_value = (float) i;
! 			this.string_value = "float";
! 		}
  		public Atom(string s)
  		{
! 			this.type = AtomType.Symbol;
! 			this.float_value = 0;
! 			this.string_value = s;
  		}
  	}
  	// this struct is relative to this c struct, see clr.c
  
--- 4,84 ----
  namespace PureData
  {
! 	public enum AtomType {Null = 0, Float = 1, Symbol = 2, Pointer = 3};
  
!     [StructLayout (LayoutKind.Sequential)]
!     sealed public class Symbol
!     {
!         // this should NOT be public
!         readonly private IntPtr ptr;
!         
!         public Symbol(IntPtr p)
!         {
!             ptr = p;
!         }
! 
!         public Symbol(Symbol s)
!         {
!             ptr = s.ptr;
!         }
! 
!         public Symbol(string s)
!         {
!             ptr = Core.GenSym(s);
!         }
!         
!         override public string ToString()
!         {
!             return Core.EvalSym(this);
!         }
!     }
! 
!     [StructLayout (LayoutKind.Sequential)]
!     sealed public class Pointer
!     {
!         public IntPtr ptr;
!     }
! 
!     [StructLayout (LayoutKind.Explicit)]
!     public struct Word
!     {
!         [FieldOffset(0)] public float w_float;
!         [FieldOffset(0)] public Symbol w_symbol;
!         [FieldOffset(0)] public Pointer w_pointer;
!     }
! 
!     //[StructLayout (LayoutKind.Explicit)]
  	[StructLayout (LayoutKind.Sequential)]
! 	sealed public class Atom 
  	{
+ 	
  		public AtomType type;
! 		public Word word;
! 		
  		public Atom(float f)
  		{
! 			type = AtomType.Float;
! 			word.w_float = f;
  		}
+ 
  		public Atom(int i)
  		{
!             type = AtomType.Float;
!             word.w_float = (float)i;
!         }
! 
!         public Atom(Symbol s)
!         {
!             type = AtomType.Symbol;
!             word.w_symbol = s;
!         }
!         
  		public Atom(string s)
  		{
!             type = AtomType.Symbol;
!             word.w_symbol = new Symbol(s);
  		}
  	}
+ 	
+ 	
  	// this struct is relative to this c struct, see clr.c
  
***************
*** 52,54 ****
  		};
  		*/
! }
--- 101,104 ----
  		};
  		*/
! 
! }
\ No newline at end of file

--- NEW FILE: PureData.cs ---
using System;
using System.Runtime.CompilerServices; // for extern import

namespace PureData
{
    // PD core functions
    public class Core 
    {
        [MethodImplAttribute (MethodImplOptions.InternalCall)]
        public extern static void Post(string message);        

        [MethodImplAttribute (MethodImplOptions.InternalCall)]
        public extern static void PostError(string message);        

        [MethodImplAttribute (MethodImplOptions.InternalCall)]
        public extern static void PostBug(string message);        

        [MethodImplAttribute (MethodImplOptions.InternalCall)]
        public extern static void PostVerbose(string message);        

        [MethodImplAttribute (MethodImplOptions.InternalCall)]
        public extern static IntPtr GenSym(string sym);        

        [MethodImplAttribute (MethodImplOptions.InternalCall)]
        public extern static string EvalSym(Symbol sym);        
    }
    
    // This is the base class for a PD/CLR external
    public class External
        : Core
    {
        private readonly IntPtr ptr;
        
        protected virtual void MethodBang() { Post("No bang handler"); }

        protected virtual void MethodFloat(float f) { Post("No float handler"); }

        protected virtual void MethodSymbol(Symbol s) { Post("No symbol handler"); }

        protected virtual void MethodPointer(Pointer p) { Post("No pointer handler");}

        protected virtual void MethodList(Atom[] lst) { Post("No list handler"); }

        protected virtual void MethodAnything(Atom[] lst) { Post("No list handler"); }
    }
}





More information about the Pd-cvs mailing list