aboutsummaryrefslogtreecommitdiff
path: root/external/pd.cs
blob: 4f057340ebb7e727b1b89f643efba9487e0fa260 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
using System;
using System.Runtime.CompilerServices; // for extern import
using System.Runtime.InteropServices; // for structures


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);


	}

/*
// 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;
*/

}