summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2017-11-23 21:49:22 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2017-11-29 15:56:57 -0300
commit80ab29824744de5b2e4f460a1c0756ea1e5a4d8c (patch)
tree347201c0104eb7a4b9d4ea78718f2a7437bb670c
parent42910df106420eb7c01ef2ad497eab1b61c6c669 (diff)
efl_mono: Adding support code for the C# binding
This is the C# manual code for the binding. Buildsystem integration will come in a future commit.
-rw-r--r--src/bindings/mono/ecore_evas_mono/ecore_evas.cs37
-rw-r--r--src/bindings/mono/efl_mono/.gitignore1
-rw-r--r--src/bindings/mono/efl_mono/efl_all.cs88
-rw-r--r--src/bindings/mono/efl_mono/efl_libs.cs.in22
-rw-r--r--src/bindings/mono/efl_mono/efl_libs.csv.in1
-rw-r--r--src/bindings/mono/eina_mono/eina_array.cs291
-rw-r--r--src/bindings/mono/eina_mono/eina_binbuf.cs210
-rw-r--r--src/bindings/mono/eina_mono/eina_common.cs132
-rw-r--r--src/bindings/mono/eina_mono/eina_config.cs62
-rw-r--r--src/bindings/mono/eina_mono/eina_container_common.cs683
-rw-r--r--src/bindings/mono/eina_mono/eina_error.cs92
-rw-r--r--src/bindings/mono/eina_mono/eina_hash.cs402
-rw-r--r--src/bindings/mono/eina_mono/eina_inarray.cs324
-rw-r--r--src/bindings/mono/eina_mono/eina_inlist.cs316
-rw-r--r--src/bindings/mono/eina_mono/eina_iterator.cs144
-rw-r--r--src/bindings/mono/eina_mono/eina_list.cs352
-rw-r--r--src/bindings/mono/eina_mono/eina_log.cs121
-rw-r--r--src/bindings/mono/eina_mono/eina_slice.cs85
-rw-r--r--src/bindings/mono/eina_mono/eina_stringshare.cs18
-rw-r--r--src/bindings/mono/eina_mono/eina_value.cs1590
-rw-r--r--src/bindings/mono/eldbus_mono/eldbus_common.cs561
-rw-r--r--src/bindings/mono/eldbus_mono/eldbus_config.cs24
-rw-r--r--src/bindings/mono/eldbus_mono/eldbus_connection.cs373
-rw-r--r--src/bindings/mono/eldbus_mono/eldbus_message.cs924
-rw-r--r--src/bindings/mono/eldbus_mono/eldbus_object.cs314
-rw-r--r--src/bindings/mono/eldbus_mono/eldbus_pending.cs109
-rw-r--r--src/bindings/mono/eldbus_mono/eldbus_proxy.cs218
-rw-r--r--src/bindings/mono/eldbus_mono/eldbus_service.cs66
-rw-r--r--src/bindings/mono/eo_mono/iwrapper.cs392
-rw-r--r--src/bindings/mono/eo_mono/object.cs10
-rw-r--r--src/bindings/mono/eo_mono/workaround.cs523
31 files changed, 8485 insertions, 0 deletions
diff --git a/src/bindings/mono/ecore_evas_mono/ecore_evas.cs b/src/bindings/mono/ecore_evas_mono/ecore_evas.cs
new file mode 100644
index 0000000000..a1c8a6dfe2
--- /dev/null
+++ b/src/bindings/mono/ecore_evas_mono/ecore_evas.cs
@@ -0,0 +1,37 @@
1
2using System;
3using System.Runtime.InteropServices;
4using System.Threading;
5
6public class EcoreEvas
7{
8 [DllImport(efl.Libs.EcoreEvas)] static extern void ecore_evas_init();
9 // [DllImport(efl.Libs.EcoreEvas)] static extern IntPtr ecore_evas_new([MarshalAs(UnmanagedType.LPStr)] String engine_name, int x, int y, int w, int h
10 // , [MarshalAs(UnmanagedType.LPStr)] String extra_options);
11 [DllImport(efl.Libs.EcoreEvas)] static extern IntPtr ecore_evas_new(IntPtr engine_name, int x, int y, int w, int h
12 , IntPtr extra_options);
13 [DllImport(efl.Libs.EcoreEvas)] static extern IntPtr ecore_evas_get(IntPtr ecore_evas);
14 [DllImport(efl.Libs.EcoreEvas)] static extern IntPtr ecore_evas_show(IntPtr ecore_evas);
15
16 IntPtr handle;
17 public EcoreEvas()
18 {
19#if WIN32 // Not a native define, we define it in our build system
20 // Ecore_Win32 uses OleInitialize, which requires single thread apartments
21 if (Thread.CurrentThread.GetApartmentState() != ApartmentState.STA)
22 throw new InvalidOperationException("UI Applications require STAThreadAttribute in Main()");
23#endif
24 ecore_evas_init();
25 handle = ecore_evas_new(IntPtr.Zero, 0, 0, 640, 480, IntPtr.Zero);
26 if(handle == IntPtr.Zero)
27 System.Console.WriteLine("Couldn't create a ecore evas");
28 ecore_evas_show(handle);
29 }
30
31 public efl.canvas.Object canvas
32 {
33 get { return new efl.canvas.ObjectConcrete(ecore_evas_get(handle)); }
34 }
35
36}
37
diff --git a/src/bindings/mono/efl_mono/.gitignore b/src/bindings/mono/efl_mono/.gitignore
new file mode 100644
index 0000000000..cc8a6c3119
--- /dev/null
+++ b/src/bindings/mono/efl_mono/.gitignore
@@ -0,0 +1 @@
/efl_libs.cs
diff --git a/src/bindings/mono/efl_mono/efl_all.cs b/src/bindings/mono/efl_mono/efl_all.cs
new file mode 100644
index 0000000000..697cdf2f94
--- /dev/null
+++ b/src/bindings/mono/efl_mono/efl_all.cs
@@ -0,0 +1,88 @@
1using System;
2using System.Runtime.InteropServices;
3using System.Threading;
4
5using static efl.UnsafeNativeMethods;
6
7namespace efl {
8
9static class UnsafeNativeMethods {
10 [DllImport(efl.Libs.Ecore)] public static extern void ecore_init();
11 [DllImport(efl.Libs.Ecore)] public static extern void ecore_shutdown();
12 [DllImport(efl.Libs.Evas)] public static extern void evas_init();
13 [DllImport(efl.Libs.Evas)] public static extern void evas_shutdown();
14 [DllImport(efl.Libs.Elementary)] public static extern int elm_init(int argc, IntPtr argv);
15 [DllImport(efl.Libs.Elementary)] public static extern void elm_policy_set(int policy, int policy_detail);
16 [DllImport(efl.Libs.Elementary)] public static extern void elm_shutdown();
17 [DllImport(efl.Libs.Elementary)] public static extern void elm_run();
18 [DllImport(efl.Libs.Elementary)] public static extern void elm_exit();
19}
20
21public enum Components {
22 Basic,
23 Ui
24}
25
26public static class All {
27 private static bool InitializedUi = false;
28
29 public static void Init(efl.Components components=Components.Basic) {
30 eina.Config.Init();
31 efl.eo.Config.Init();
32 ecore_init();
33 evas_init();
34 eldbus.Config.Init();
35
36 if (components == Components.Ui) {
37 efl.ui.Config.Init();
38 InitializedUi = true;
39 }
40 }
41
42 /// <summary>Shutdowns all EFL subsystems.</summary>
43 public static void Shutdown() {
44 // Try to cleanup everything before actually shutting down.
45 System.GC.Collect();
46 System.GC.WaitForPendingFinalizers();
47
48 if (InitializedUi)
49 efl.ui.Config.Shutdown();
50 eldbus.Config.Shutdown();
51 evas_shutdown();
52 ecore_shutdown();
53 efl.eo.Config.Shutdown();
54 eina.Config.Shutdown();
55 }
56}
57
58// Placeholder. Will move to elm_config.cs later
59namespace ui {
60
61public static class Config {
62 public static void Init() {
63 // TODO Support elm command line arguments
64#if WIN32 // Not a native define, we define it in our build system
65 // Ecore_Win32 uses OleInitialize, which requires single thread apartments
66 if (Thread.CurrentThread.GetApartmentState() != ApartmentState.STA)
67 throw new InvalidOperationException("UI Applications require STAThreadAttribute in Main()");
68#endif
69 elm_init(0, IntPtr.Zero);
70
71 elm_policy_set((int)elm.Policy.Quit, (int)elm.policy.Quit.Last_window_hidden);
72 }
73 public static void Shutdown() {
74 elm_shutdown();
75 }
76
77 public static void Run() {
78 elm_run();
79 }
80
81 public static void Exit() {
82 elm_exit();
83 }
84}
85
86}
87
88}
diff --git a/src/bindings/mono/efl_mono/efl_libs.cs.in b/src/bindings/mono/efl_mono/efl_libs.cs.in
new file mode 100644
index 0000000000..e1c7dc6aeb
--- /dev/null
+++ b/src/bindings/mono/efl_mono/efl_libs.cs.in
@@ -0,0 +1,22 @@
1
2namespace efl {
3
4/// <summary>
5/// Define the name of the libraries to be passed to DllImport statements.
6/// </summary>
7public class Libs {
8 public const string Efl = "@EFL_DL_MONO@";
9 public const string Ecore = "@ECORE_DL_MONO@";
10 public const string Eina = "@EINA_DL_MONO@";
11 public const string Eo = "@EO_DL_MONO@";
12 public const string Evas = "@EVAS_DL_MONO@";
13 public const string Evil = "@EVIL_DL_MONO@";
14 public const string EcoreEvas = "@ECORE_EVAS_DL_MONO@";
15 public const string Edje = "@EDJE_DL_MONO@";
16 public const string Elementary = "@ELEMENTARY_DL_MONO@";
17 public const string Eldbus = "@ELDBUS_DL_MONO@";
18
19 public const string CustomExports = "@CUSTOM_EXPORTS_MONO_DL_MONO@";
20}
21
22}
diff --git a/src/bindings/mono/efl_mono/efl_libs.csv.in b/src/bindings/mono/efl_mono/efl_libs.csv.in
new file mode 100644
index 0000000000..3e356fe607
--- /dev/null
+++ b/src/bindings/mono/efl_mono/efl_libs.csv.in
@@ -0,0 +1 @@
@EFL_MONO_LIBRARY_MAP@
diff --git a/src/bindings/mono/eina_mono/eina_array.cs b/src/bindings/mono/eina_mono/eina_array.cs
new file mode 100644
index 0000000000..98e43b88b8
--- /dev/null
+++ b/src/bindings/mono/eina_mono/eina_array.cs
@@ -0,0 +1,291 @@
1using System;
2using System.Runtime.InteropServices;
3using System.Collections.Generic;
4
5using static eina.TraitFunctions;
6using static eina.ArrayNativeFunctions;
7
8namespace eina {
9
10public static class ArrayNativeFunctions
11{
12 [DllImport(efl.Libs.Eina)] public static extern IntPtr
13 eina_array_new(uint step);
14 [DllImport(efl.Libs.Eina)] public static extern void
15 eina_array_free(IntPtr array);
16 [DllImport(efl.Libs.Eina)] public static extern void
17 eina_array_flush(IntPtr array);
18 [DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool
19 eina_array_remove(IntPtr array, IntPtr keep, IntPtr gdata);
20 [DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool
21 eina_array_push(IntPtr array, IntPtr data);
22
23 [DllImport(efl.Libs.Eina)] public static extern IntPtr
24 eina_array_iterator_new(IntPtr array);
25
26 [DllImport(efl.Libs.CustomExports)] public static extern void
27 eina_array_clean_custom_export_mono(IntPtr array);
28 [DllImport(efl.Libs.CustomExports)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool
29 eina_array_push_custom_export_mono(IntPtr array, IntPtr data);
30 [DllImport(efl.Libs.CustomExports)] public static extern IntPtr
31 eina_array_pop_custom_export_mono(IntPtr array);
32 [DllImport(efl.Libs.CustomExports)] public static extern IntPtr
33 eina_array_data_get_custom_export_mono(IntPtr array, uint idx);
34 [DllImport(efl.Libs.CustomExports)] public static extern void
35 eina_array_data_set_custom_export_mono(IntPtr array, uint idx, IntPtr data);
36 [DllImport(efl.Libs.CustomExports)] public static extern uint
37 eina_array_count_custom_export_mono(IntPtr array);
38
39 [DllImport(efl.Libs.CustomExports)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool
40 eina_array_foreach_custom_export_mono(IntPtr array, IntPtr cb, IntPtr fdata);
41}
42
43public class Array<T> : IEnumerable<T>, IDisposable
44{
45 public static uint DefaultStep = 32;
46
47 public IntPtr Handle {get;set;} = IntPtr.Zero;
48 public bool Own {get;set;}
49 public bool OwnContent {get;set;}
50
51 public int Length
52 {
53 get { return Count(); }
54 }
55
56
57 private void InitNew(uint step)
58 {
59 Handle = eina_array_new(step);
60 Own = true;
61 OwnContent = true;
62 if (Handle == IntPtr.Zero)
63 throw new SEHException("Could not alloc array");
64 }
65
66 internal bool InternalPush(IntPtr ele)
67 {
68 return eina_array_push_custom_export_mono(Handle, ele);
69 }
70
71 internal IntPtr InternalPop()
72 {
73 return eina_array_pop_custom_export_mono(Handle);
74 }
75
76 internal IntPtr InternalDataGet(int idx)
77 {
78 return eina_array_data_get_custom_export_mono(Handle, (uint)idx); // TODO: Check bounds ???
79 }
80
81 internal void InternalDataSet(int idx, IntPtr ele)
82 {
83 eina_array_data_set_custom_export_mono(Handle, (uint)idx, ele); // TODO: Check bounds ???
84 }
85
86 public Array()
87 {
88 InitNew(DefaultStep);
89 }
90
91 public Array(uint step)
92 {
93 InitNew(step);
94 }
95
96 public Array(IntPtr handle, bool own)
97 {
98 Handle = handle;
99 Own = own;
100 OwnContent = own;
101 }
102
103 public Array(IntPtr handle, bool own, bool ownContent)
104 {
105 Handle = handle;
106 Own = own;
107 OwnContent = ownContent;
108 }
109
110 ~Array()
111 {
112 Dispose(false);
113 }
114
115 protected virtual void Dispose(bool disposing)
116 {
117 IntPtr h = Handle;
118 Handle = IntPtr.Zero;
119 if (h == IntPtr.Zero)
120 return;
121
122 if (OwnContent)
123 {
124 int len = (int)eina_array_count_custom_export_mono(h);
125 for(int i = 0; i < len; ++i)
126 {
127 NativeFree<T>(eina_array_data_get_custom_export_mono(h, (uint)i));
128 }
129 }
130
131 if (Own)
132 eina_array_free(h);
133 }
134
135 public void Dispose()
136 {
137 Dispose(true);
138 GC.SuppressFinalize(this);
139 }
140
141 public void Free()
142 {
143 Dispose();
144 }
145
146 public IntPtr Release()
147 {
148 IntPtr h = Handle;
149 Handle = IntPtr.Zero;
150 return h;
151 }
152
153 private void FreeElementsIfOwned()
154 {
155 if (OwnContent)
156 {
157 int len = Length;
158 for(int i = 0; i < len; ++i)
159 {
160 NativeFree<T>(InternalDataGet(i));
161 }
162 }
163 }
164
165 public void Clean()
166 {
167 FreeElementsIfOwned();
168 eina_array_clean_custom_export_mono(Handle);
169 }
170
171 public void Flush()
172 {
173 FreeElementsIfOwned();
174 eina_array_flush(Handle);
175 }
176
177 public int Count()
178 {
179 return (int) eina_array_count_custom_export_mono(Handle);
180 }
181
182 public void SetOwnership(bool ownAll)
183 {
184 Own = ownAll;
185 OwnContent = ownAll;
186 }
187
188 public void SetOwnership(bool own, bool ownContent)
189 {
190 Own = own;
191 OwnContent = ownContent;
192 }
193
194 public bool Push(T val)
195 {
196 IntPtr ele = ManagedToNativeAlloc(val);
197 var r = InternalPush(ele);
198 if (!r)
199 NativeFree<T>(ele);
200 return r;
201 }
202
203// TODO ???
204// public void Add(T val)
205// {
206// if (!Push(val))
207// throw;
208// }
209
210 public T Pop()
211 {
212 IntPtr ele = InternalPop();
213 var r = NativeToManaged<T>(ele);
214 if (OwnContent && ele != IntPtr.Zero)
215 NativeFree<T>(ele);
216 return r;
217 }
218
219 public T DataGet(int idx)
220 {
221 IntPtr ele = InternalDataGet(idx);
222 return NativeToManaged<T>(ele);
223 }
224
225 public T At(int idx)
226 {
227 return DataGet(idx);
228 }
229
230 public void DataSet(int idx, T val)
231 {
232 IntPtr ele = InternalDataGet(idx); // TODO: check bondaries ??
233 if (OwnContent && ele != IntPtr.Zero)
234 NativeFree<T>(ele);
235 ele = ManagedToNativeAlloc(val);
236 InternalDataSet(idx, ele);
237 }
238
239 public T this[int idx]
240 {
241 get
242 {
243 return DataGet(idx);
244 }
245 set
246 {
247 DataSet(idx, value);
248 }
249 }
250
251 public T[] ToArray()
252 {
253 int len = Length;
254 var managed = new T[len];
255 for(int i = 0; i < len; ++i)
256 {
257 managed[i] = DataGet(i);
258 }
259 return managed;
260 }
261
262 public bool Append(T[] values)
263 {
264 foreach(T v in values)
265 if (!Push(v))
266 return false;
267 return true;
268 }
269
270
271 public eina.Iterator<T> GetIterator()
272 {
273 return new eina.Iterator<T>(eina_array_iterator_new(Handle), true, false);
274 }
275
276 public IEnumerator<T> GetEnumerator()
277 {
278 int len = Length;
279 for(int i = 0; i < len; ++i)
280 {
281 yield return DataGet(i);
282 }
283 }
284
285 System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
286 {
287 return this.GetEnumerator();
288 }
289}
290
291}
diff --git a/src/bindings/mono/eina_mono/eina_binbuf.cs b/src/bindings/mono/eina_mono/eina_binbuf.cs
new file mode 100644
index 0000000000..dd30ab1275
--- /dev/null
+++ b/src/bindings/mono/eina_mono/eina_binbuf.cs
@@ -0,0 +1,210 @@
1using System;
2using System.Runtime.InteropServices;
3
4namespace eina {
5
6public class Binbuf : IDisposable
7{
8 [DllImport(efl.Libs.Eina)] public static extern IntPtr
9 eina_binbuf_new();
10 [DllImport(efl.Libs.Eina)] public static extern void
11 eina_binbuf_free(IntPtr buf);
12 [DllImport(efl.Libs.Eina)] public static extern void
13 eina_binbuf_reset(IntPtr buf);
14 [DllImport(efl.Libs.Eina)] public static extern byte
15 eina_binbuf_append_length(IntPtr buf, byte[] str, UIntPtr length);
16 [DllImport(efl.Libs.Eina)] public static extern byte
17 eina_binbuf_append_slice(IntPtr buf, eina.Slice slice);
18 [DllImport(efl.Libs.Eina)] public static extern byte
19 eina_binbuf_append_buffer(IntPtr buf, IntPtr data);
20 [DllImport(efl.Libs.Eina)] public static extern byte
21 eina_binbuf_append_char(IntPtr buf, byte c);
22 [DllImport(efl.Libs.Eina)] public static extern byte
23 eina_binbuf_insert_length(IntPtr buf, byte[] str, UIntPtr length, UIntPtr pos);
24 [DllImport(efl.Libs.Eina)] public static extern byte
25 eina_binbuf_insert_slice(IntPtr buf, eina.Slice slice, UIntPtr pos);
26 [DllImport(efl.Libs.Eina)] public static extern byte
27 eina_binbuf_insert_char(IntPtr buf, byte c, UIntPtr pos);
28 [DllImport(efl.Libs.Eina)] public static extern byte
29 eina_binbuf_remove(IntPtr buf, UIntPtr start, UIntPtr end);
30 [DllImport(efl.Libs.Eina)] public static extern IntPtr
31 eina_binbuf_string_get(IntPtr buf);
32 [DllImport(efl.Libs.Eina)] public static extern void
33 eina_binbuf_string_free(IntPtr buf);
34 [DllImport(efl.Libs.Eina)] public static extern UIntPtr
35 eina_binbuf_length_get(IntPtr buf);
36 [DllImport(efl.Libs.Eina)] public static extern eina.Slice
37 eina_binbuf_slice_get(IntPtr buf);
38
39 public IntPtr Handle {get;set;} = IntPtr.Zero;
40 public bool Own {get;set;}
41
42 public int Length
43 {
44 get { return (int) GetLength(); }
45 }
46
47 private void InitNew()
48 {
49 Handle = eina_binbuf_new();
50 Own = true;
51 if (Handle == IntPtr.Zero)
52 throw new SEHException("Could not alloc binbuf");
53 }
54
55 public Binbuf()
56 {
57 InitNew();
58 }
59
60 public Binbuf(byte[] str, uint? length = null)
61 {
62 InitNew();
63
64 if (str != null)
65 {
66 if (!Append(str, (length != null ? length.Value : (uint)(str.Length))))
67 {
68 Dispose();
69 throw new SEHException("Could not append on binbuf");
70 }
71 }
72 }
73
74 public Binbuf(Binbuf bb)
75 {
76 InitNew();
77
78 if (bb != null)
79 {
80 Append(bb);
81 }
82 }
83
84 public Binbuf(IntPtr handle, bool own)
85 {
86 Handle = handle;
87 Own = own;
88 }
89
90 ~Binbuf()
91 {
92 Dispose(false);
93 }
94
95 protected virtual void Dispose(bool disposing)
96 {
97 IntPtr h = Handle;
98 Handle = IntPtr.Zero;
99 if (Own && h != IntPtr.Zero) {
100 eina_binbuf_free(Handle);
101 }
102 }
103
104 public void Dispose()
105 {
106 Dispose(true);
107 GC.SuppressFinalize(this);
108 }
109
110 public void Free()
111 {
112 Dispose();
113 }
114
115 public IntPtr Release()
116 {
117 IntPtr h = Handle;
118 Handle = IntPtr.Zero;
119 return h;
120 }
121
122 public void Reset()
123 {
124 eina_binbuf_reset(Handle);
125 }
126
127 public bool Append(byte[] str)
128 {
129 return 0 != eina_binbuf_append_length(Handle, str, (UIntPtr)(str.Length));
130 }
131
132 public bool Append(byte[] str, uint length)
133 {
134 return 0 != eina_binbuf_append_length(Handle, str, (UIntPtr)length);
135 }
136
137 public bool Append(Binbuf bb)
138 {
139 return 0 != eina_binbuf_append_buffer(Handle, bb.Handle);
140 }
141
142 public bool Append(byte c)
143 {
144 return 0 != eina_binbuf_append_char(Handle, c);
145 }
146
147 public bool Append(eina.Slice slice)
148 {
149 return 0 != eina_binbuf_append_slice(Handle, slice);
150 }
151
152 public bool Insert(byte[] str, uint pos)
153 {
154 return 0 != eina_binbuf_insert_length(Handle, str, (UIntPtr)(str.Length), (UIntPtr)pos);
155 }
156
157 public bool Insert(byte[] str, uint length, uint pos)
158 {
159 return 0 != eina_binbuf_insert_length(Handle, str, (UIntPtr)length, (UIntPtr)pos);
160 }
161
162 public bool Insert(byte c, uint pos)
163 {
164 return 0 != eina_binbuf_insert_char(Handle, c, (UIntPtr)pos);
165 }
166
167 public bool Insert(eina.Slice slice, uint pos)
168 {
169 return 0 != eina_binbuf_insert_slice(Handle, slice, (UIntPtr)pos);
170 }
171
172 public bool Remove(uint start, uint end)
173 {
174 return 0 != eina_binbuf_remove(Handle, (UIntPtr)start, (UIntPtr)end);
175 }
176
177 public byte[] GetBytes()
178 {
179 var ptr = eina_binbuf_string_get(Handle);
180 if (ptr == IntPtr.Zero)
181 return null;
182
183 var size = (int)(this.GetLength());
184 byte[] mArray = new byte[size];
185 Marshal.Copy(ptr, mArray, 0, size);
186 return mArray;
187 }
188
189 public IntPtr GetStringNative()
190 {
191 return eina_binbuf_string_get(Handle);
192 }
193
194 public void FreeString()
195 {
196 eina_binbuf_string_free(Handle);
197 }
198
199 public UIntPtr GetLength()
200 {
201 return eina_binbuf_length_get(Handle);
202 }
203
204 eina.Slice GetSlice()
205 {
206 return eina_binbuf_slice_get(Handle);
207 }
208}
209
210}
diff --git a/src/bindings/mono/eina_mono/eina_common.cs b/src/bindings/mono/eina_mono/eina_common.cs
new file mode 100644
index 0000000000..05a562595c
--- /dev/null
+++ b/src/bindings/mono/eina_mono/eina_common.cs
@@ -0,0 +1,132 @@
1using System;
2using System.Text;
3using System.Runtime.InteropServices;
4
5namespace eina
6{
7namespace Callbacks
8{
9
10public delegate int Eina_Compare_Cb(IntPtr data1, IntPtr data2);
11public delegate void Eina_Free_Cb(IntPtr data);
12
13}
14
15public static class NativeCustomExportFunctions
16{
17 [DllImport(efl.Libs.CustomExports)] public static extern void
18 efl_mono_native_free(IntPtr ptr);
19 [DllImport(efl.Libs.CustomExports)] public static extern void
20 efl_mono_native_free_ref(IntPtr ptr);
21 [DllImport(efl.Libs.CustomExports)] public static extern IntPtr
22 efl_mono_native_alloc(uint count);
23 [DllImport(efl.Libs.CustomExports)] public static extern IntPtr
24 efl_mono_native_alloc_copy(IntPtr val, uint size);
25 [DllImport(efl.Libs.CustomExports)] public static extern IntPtr
26 efl_mono_native_strdup(string str);
27
28 [DllImport(efl.Libs.CustomExports)] public static extern IntPtr
29 efl_mono_native_ptr_compare_addr_get();
30 [DllImport(efl.Libs.CustomExports)] public static extern IntPtr
31 efl_mono_native_str_compare_addr_get();
32
33 [DllImport(efl.Libs.CustomExports)] public static extern IntPtr
34 efl_mono_native_free_addr_get();
35 [DllImport(efl.Libs.CustomExports)] public static extern IntPtr
36 efl_mono_native_efl_unref_addr_get();
37}
38
39/// <summary>Wrapper around native memory DllImport'd functions</summary>
40public static class MemoryNative {
41 public static void Free(IntPtr ptr)
42 {
43 NativeCustomExportFunctions.efl_mono_native_free(ptr);
44 }
45
46 public static void FreeRef(IntPtr ptr)
47 {
48 NativeCustomExportFunctions.efl_mono_native_free_ref(ptr);
49 }
50
51 // This public api uses int as Marshal.SizeOf return an int instead of uint.
52 public static IntPtr Alloc(int count)
53 {
54 return NativeCustomExportFunctions.efl_mono_native_alloc(Convert.ToUInt32(count));
55 }
56
57 public static IntPtr AllocCopy(IntPtr ptr, int count)
58 {
59 return NativeCustomExportFunctions.efl_mono_native_alloc_copy(ptr, Convert.ToUInt32(count));
60 }
61
62 public static IntPtr StrDup(string str)
63 {
64 return NativeCustomExportFunctions.efl_mono_native_strdup(str);
65 }
66
67 // IntPtr's for some native functions
68 public static IntPtr PtrCompareFuncPtrGet()
69 {
70 return NativeCustomExportFunctions.efl_mono_native_ptr_compare_addr_get();
71 }
72
73 public static IntPtr StrCompareFuncPtrGet()
74 {
75 return NativeCustomExportFunctions.efl_mono_native_str_compare_addr_get();
76 }
77
78 public static IntPtr FreeFuncPtrGet()
79 {
80 return NativeCustomExportFunctions.efl_mono_native_free_addr_get();
81 }
82
83 public static IntPtr EflUnrefFuncPtrGet()
84 {
85 return NativeCustomExportFunctions.efl_mono_native_efl_unref_addr_get();
86 }
87}
88
89public static class StringConversion
90{
91 public static IntPtr ManagedStringToNativeUtf8Alloc(string managedString)
92 {
93 if (managedString == null)
94 return IntPtr.Zero;
95
96 byte[] strbuf = Encoding.UTF8.GetBytes(managedString);
97 IntPtr native = MemoryNative.Alloc(strbuf.Length + 1);
98 Marshal.Copy(strbuf, 0, native, strbuf.Length);
99 Marshal.WriteByte(native + strbuf.Length, 0); // write the terminating null
100 return native;
101 }
102
103 public static string NativeUtf8ToManagedString(IntPtr pNativeData)
104 {
105 if (pNativeData == IntPtr.Zero)
106 return null;
107
108 int len = 0;
109 while (Marshal.ReadByte(pNativeData, len) != 0)
110 ++len;
111
112 byte[] strbuf = new byte[len];
113 Marshal.Copy(pNativeData, strbuf, 0, strbuf.Length);
114 return Encoding.UTF8.GetString(strbuf);
115 }
116}
117
118public struct Unicode {
119 private uint val;
120
121 public static implicit operator Unicode(uint x)
122 {
123 return new Unicode{val=x};
124 }
125 public static implicit operator uint(Unicode x)
126 {
127 return x.val;
128 }
129}
130
131
132}
diff --git a/src/bindings/mono/eina_mono/eina_config.cs b/src/bindings/mono/eina_mono/eina_config.cs
new file mode 100644
index 0000000000..c33dd06601
--- /dev/null
+++ b/src/bindings/mono/eina_mono/eina_config.cs
@@ -0,0 +1,62 @@
1using System;
2using System.Runtime.InteropServices;
3
4namespace eina {
5
6public class Config {
7 [DllImport(efl.Libs.Eina)] private static extern int eina_init();
8 [DllImport(efl.Libs.Eina)] private static extern int eina_shutdown();
9
10 public static void Init() {
11 if (eina_init() == 0)
12 throw (new efl.EflException("Failed to initialize Eina"));
13
14 // Initialize the submodules here
15 eina.Log.Init();
16 eina.Error.Init();
17 }
18
19 public static int Shutdown() {
20 return eina_shutdown();
21 }
22
23}
24
25/// <summary>
26/// Wrapper class for pointers that need some cleanup afterwards
27/// like strings.
28/// </summary>
29public class DisposableIntPtr : IDisposable {
30
31 public IntPtr Handle { get; set; }
32 private bool ShouldFree;
33 private bool Disposed;
34
35 /// <summary>Wraps a new ptr what will be freed based on the
36 /// value of shouldFree</summary>
37 public DisposableIntPtr(IntPtr ptr, bool shouldFree=false)
38 {
39 Handle = ptr;
40 ShouldFree = shouldFree;
41 }
42
43 public void Dispose()
44 {
45 Dispose(true);
46 GC.SuppressFinalize(this);
47 }
48
49 protected virtual void Dispose(bool disposing)
50 {
51 if (!Disposed && ShouldFree) {
52 MemoryNative.Free(this.Handle);
53 }
54 Disposed = true;
55 }
56
57 ~DisposableIntPtr()
58 {
59 Dispose(false);
60 }
61}
62}
diff --git a/src/bindings/mono/eina_mono/eina_container_common.cs b/src/bindings/mono/eina_mono/eina_container_common.cs
new file mode 100644
index 0000000000..6cdafdc836
--- /dev/null
+++ b/src/bindings/mono/eina_mono/eina_container_common.cs
@@ -0,0 +1,683 @@
1using System;
2using System.Runtime.InteropServices;
3using System.Collections.Generic;
4
5using eina.Callbacks;
6using static eina.HashNativeFunctions;
7using static eina.InarrayNativeFunctions;
8using static eina.InlistNativeFunctions;
9using static eina.NativeCustomExportFunctions;
10using static eina.ContainerCommonData;
11
12namespace eina {
13
14public enum ElementType { NumericType, StringType, ObjectType };
15
16public static class ContainerCommonData
17{
18 public static IBaseElementTraits<IntPtr> intPtrTraits = null;
19}
20
21[StructLayout(LayoutKind.Sequential)]
22public struct ConvertWrapper<T>
23{
24 public T Val {get;set;}
25}
26
27[StructLayout(LayoutKind.Sequential)]
28public struct InlistMem
29{
30 public IntPtr next {get;set;}
31 public IntPtr prev {get;set;}
32 public IntPtr last {get;set;}
33}
34
35[StructLayout(LayoutKind.Sequential)]
36public struct InlistNode<T>
37{
38 public InlistMem __in_list {get;set;}
39 public T Val {get;set;}
40}
41
42
43public interface IBaseElementTraits<T>
44{
45 IntPtr ManagedToNativeAlloc(T man);
46 IntPtr ManagedToNativeAllocRef(T man, bool refs);
47 IntPtr ManagedToNativeAllocInlistNode(T man);
48 IntPtr ManagedToNativeAllocInplace(T man);
49 void NativeFree(IntPtr nat);
50 void NativeFreeRef(IntPtr nat, bool unrefs);
51 void NativeFreeInlistNodeElement(IntPtr nat);
52 void NativeFreeInlistNode(IntPtr nat, bool freeElement);
53 void NativeFreeInplace(IntPtr nat);
54 void ResidueFreeInplace(IntPtr nat);
55 T NativeToManaged(IntPtr nat);
56 T NativeToManagedRef(IntPtr nat);
57 T NativeToManagedInlistNode(IntPtr nat);
58 T NativeToManagedInplace(IntPtr nat);
59 IntPtr EinaCompareCb();
60 IntPtr EinaFreeCb();
61 IntPtr EinaHashNew();
62 IntPtr EinaInarrayNew(uint step);
63 IntPtr EinaHashIteratorKeyNew(IntPtr hash);
64}
65
66public class StringElementTraits<T> : IBaseElementTraits<T>
67{
68
69 public StringElementTraits()
70 {
71 if (intPtrTraits == null)
72 intPtrTraits = TraitFunctions.GetTypeTraits<IntPtr>();
73 }
74
75 public IntPtr ManagedToNativeAlloc(T man)
76 {
77 return MemoryNative.StrDup((string)(object)man);
78 }
79
80 public IntPtr ManagedToNativeAllocRef(T man, bool refs)
81 {
82 // Keep alloc on C# ?
83 return ManagedToNativeAlloc(man);
84 }
85
86 public IntPtr ManagedToNativeAllocInlistNode(T man)
87 {
88 var node = new InlistNode<IntPtr>();
89 node.Val = ManagedToNativeAlloc(man);
90 GCHandle pinnedData = GCHandle.Alloc(node, GCHandleType.Pinned);
91 IntPtr ptr = pinnedData.AddrOfPinnedObject();
92 IntPtr nat = MemoryNative.AllocCopy(ptr, Marshal.SizeOf<InlistNode<IntPtr> >());
93 pinnedData.Free();
94 return nat;
95 }
96
97 public IntPtr ManagedToNativeAllocInplace(T man)
98 {
99 return intPtrTraits.ManagedToNativeAlloc(ManagedToNativeAlloc(man));
100 }
101
102 public void NativeFree(IntPtr nat)
103 {
104 if (nat != IntPtr.Zero)
105 MemoryNative.Free(nat);
106 }
107
108 public void NativeFreeRef(IntPtr nat, bool unrefs)
109 {
110 NativeFree(nat);
111 }
112
113 public void NativeFreeInlistNodeElement(IntPtr nat)
114 {
115 if (nat == IntPtr.Zero)
116 return;
117 var node = Marshal.PtrToStructure< InlistNode<IntPtr> >(nat);
118 NativeFree(node.Val);
119 }
120
121 public void NativeFreeInlistNode(IntPtr nat, bool freeElement)
122 {
123 if (nat == IntPtr.Zero)
124 return;
125 if (freeElement)
126 NativeFreeInlistNodeElement(nat);
127 MemoryNative.Free(nat);
128 }
129
130 public void NativeFreeInplace(IntPtr nat)
131 {
132 MemoryNative.FreeRef(nat);
133 }
134
135 public void ResidueFreeInplace(IntPtr nat)
136 {
137 intPtrTraits.NativeFree(nat);
138 }
139
140 public T NativeToManaged(IntPtr nat)
141 {
142 if (nat == IntPtr.Zero)
143 return default(T);
144 return (T)(object)StringConversion.NativeUtf8ToManagedString(nat);
145 }
146
147 public T NativeToManagedRef(IntPtr nat)
148 {
149 return NativeToManaged(nat);
150 }
151
152 public T NativeToManagedInlistNode(IntPtr nat)
153 {
154 if (nat == IntPtr.Zero)
155 {
156 eina.Log.Error("Null pointer for Inlist node.");
157 return default(T);
158 }
159 var w = Marshal.PtrToStructure< InlistNode<IntPtr> >(nat);
160 return NativeToManaged(w.Val);
161 }
162
163 public T NativeToManagedInplace(IntPtr nat)
164 {
165 if (nat == IntPtr.Zero)
166 return default(T);
167 return NativeToManaged(intPtrTraits.NativeToManaged(nat));
168 }
169
170 public IntPtr EinaCompareCb()
171 {
172 return MemoryNative.StrCompareFuncPtrGet();
173 }
174
175 public IntPtr EinaFreeCb()
176 {
177 return MemoryNative.FreeFuncPtrGet();
178 }
179
180 public IntPtr EinaHashNew()
181 {
182 return eina_hash_string_superfast_new(IntPtr.Zero);
183 }
184
185 public IntPtr EinaInarrayNew(uint step)
186 {
187 return eina_inarray_new((uint)Marshal.SizeOf<IntPtr>(), step);
188 }
189
190 public IntPtr EinaHashIteratorKeyNew(IntPtr hash)
191 {
192 return eina_hash_iterator_key_new(hash);
193 }
194}
195
196public class EflObjectElementTraits<T> : IBaseElementTraits<T>
197{
198 private System.Type concreteType = null;
199
200 public EflObjectElementTraits(System.Type concrete)
201 {
202 if (intPtrTraits == null)
203 intPtrTraits = TraitFunctions.GetTypeTraits<IntPtr>();
204
205 concreteType = concrete;
206 }
207
208 public IntPtr ManagedToNativeAlloc(T man)
209 {
210 IntPtr h = ((efl.eo.IWrapper)man).raw_handle;
211 if (h == IntPtr.Zero)
212 return h;
213 return efl.eo.Globals.efl_ref(h);
214 }
215
216 public IntPtr ManagedToNativeAllocRef(T man, bool refs)
217 {
218 IntPtr h = refs ? ManagedToNativeAlloc(man) : ((efl.eo.IWrapper)man).raw_handle;
219 return intPtrTraits.ManagedToNativeAlloc(h);
220 }
221
222 public IntPtr ManagedToNativeAllocInlistNode(T man)
223 {
224 var node = new InlistNode<IntPtr>();
225 node.Val = ManagedToNativeAlloc(man);
226 GCHandle pinnedData = GCHandle.Alloc(node, GCHandleType.Pinned);
227 IntPtr ptr = pinnedData.AddrOfPinnedObject();
228 IntPtr nat = MemoryNative.AllocCopy(ptr, Marshal.SizeOf<InlistNode<IntPtr> >());
229 pinnedData.Free();
230 return nat;
231 }
232
233 public IntPtr ManagedToNativeAllocInplace(T man)
234 {
235 return intPtrTraits.ManagedToNativeAlloc(ManagedToNativeAlloc(man));
236 }
237
238 public void NativeFree(IntPtr nat)
239 {
240 if (nat != IntPtr.Zero)
241 efl.eo.Globals.efl_unref(nat);
242 }
243
244 public void NativeFreeRef(IntPtr nat, bool unrefs)
245 {
246 if (unrefs)
247 NativeFree(intPtrTraits.NativeToManaged(nat));
248 intPtrTraits.NativeFree(nat);
249 }
250
251 public void NativeFreeInlistNodeElement(IntPtr nat)
252 {
253 if (nat == IntPtr.Zero)
254 return;
255 var node = Marshal.PtrToStructure< InlistNode<IntPtr> >(nat);
256 NativeFree(node.Val);
257 }
258
259 public void NativeFreeInlistNode(IntPtr nat, bool freeElement)
260 {
261 if (nat == IntPtr.Zero)
262 return;
263 if (freeElement)
264 NativeFreeInlistNodeElement(nat);
265 MemoryNative.Free(nat);
266 }
267
268 public void NativeFreeInplace(IntPtr nat)
269 {
270 NativeFree(intPtrTraits.NativeToManaged(nat));
271 }
272
273 public void ResidueFreeInplace(IntPtr nat)
274 {
275 intPtrTraits.NativeFree(nat);
276 }
277
278 public T NativeToManaged(IntPtr nat)
279 {
280 if (nat == IntPtr.Zero)
281 return default(T);
282 return (T) Activator.CreateInstance(concreteType, efl.eo.Globals.efl_ref(nat));
283 }
284
285 public T NativeToManagedRef(IntPtr nat)
286 {
287 if (nat == IntPtr.Zero)
288 return default(T);
289 return NativeToManaged(intPtrTraits.NativeToManaged(nat));
290 }
291
292 public T NativeToManagedInlistNode(IntPtr nat)
293 {
294 if (nat == IntPtr.Zero)
295 {
296 eina.Log.Error("Null pointer for Inlist node.");
297 return default(T);
298 }
299 var w = Marshal.PtrToStructure< InlistNode<IntPtr> >(nat);
300 return NativeToManaged(w.Val);
301 }
302
303 public T NativeToManagedInplace(IntPtr nat)
304 {
305 if (nat == IntPtr.Zero)
306 return default(T);
307 return NativeToManaged(intPtrTraits.NativeToManaged(nat));
308 }
309
310 public IntPtr EinaCompareCb()
311 {
312 return MemoryNative.PtrCompareFuncPtrGet();
313 }
314
315 public IntPtr EinaFreeCb()
316 {
317 return MemoryNative.EflUnrefFuncPtrGet();
318 }
319
320 public IntPtr EinaHashNew()
321 {
322 return eina_hash_pointer_new(IntPtr.Zero);
323 }
324
325 public IntPtr EinaInarrayNew(uint step)
326 {
327 return eina_inarray_new((uint)Marshal.SizeOf<IntPtr>(), step);
328 }
329
330 public IntPtr EinaHashIteratorKeyNew(IntPtr hash)
331 {
332 return eina_hash_iterator_ptr_key_wrapper_new_custom_export_mono(hash);
333 }
334}
335
336public abstract class PrimitiveElementTraits<T>
337{
338 private Eina_Compare_Cb dlgt = null;
339
340 public IntPtr ManagedToNativeAlloc(T man)
341 {
342 GCHandle pinnedData = GCHandle.Alloc(man, GCHandleType.Pinned);
343 IntPtr ptr = pinnedData.AddrOfPinnedObject();
344 IntPtr nat = MemoryNative.AllocCopy(ptr, Marshal.SizeOf<T>());
345 pinnedData.Free();
346 return nat;
347 }
348
349 public IntPtr ManagedToNativeAllocInlistNode(T man)
350 {
351 var node = new InlistNode<T>();
352 node.Val = man;
353 GCHandle pinnedData = GCHandle.Alloc(node, GCHandleType.Pinned);
354 IntPtr ptr = pinnedData.AddrOfPinnedObject();
355 IntPtr nat = MemoryNative.AllocCopy(ptr, Marshal.SizeOf< InlistNode<T> >());
356 pinnedData.Free();
357 return nat;
358 }
359
360 public IntPtr ManagedToNativeAllocInplace(T man)
361 {
362 return ManagedToNativeAlloc(man);
363 }
364
365 public void NativeFree(IntPtr nat)
366 {
367 MemoryNative.Free(nat);
368 }
369
370 public void NativeFreeInlistNodeElement(IntPtr nat)
371 {
372 // Do nothing
373 }
374
375 public void NativeFreeInlistNode(IntPtr nat, bool freeElement)
376 {
377 MemoryNative.Free(nat);
378 }
379
380 public void NativeFreeInplace(IntPtr nat)
381 {
382 // Do nothing
383 }
384
385 public void ResidueFreeInplace(IntPtr nat)
386 {
387 NativeFree(nat);
388 }
389
390 public T NativeToManaged(IntPtr nat)
391 {
392 if (nat == IntPtr.Zero)
393 {
394 eina.Log.Error("Null pointer on primitive/struct container.");
395 return default(T);
396 }
397 var w = Marshal.PtrToStructure<eina.ConvertWrapper<T> >(nat);
398 return w.Val;
399 }
400
401 public T NativeToManagedRef(IntPtr nat)
402 {
403 return NativeToManaged(nat);
404 }
405
406 public T NativeToManagedInlistNode(IntPtr nat)
407 {
408 if (nat == IntPtr.Zero)
409 {
410 eina.Log.Error("Null pointer for Inlist node.");
411 return default(T);
412 }
413 var w = Marshal.PtrToStructure< InlistNode<T> >(nat);
414 return w.Val;
415 }
416
417 public T NativeToManagedInplace(IntPtr nat)
418 {
419 return NativeToManaged(nat);
420 }
421
422 private int PrimitiveCompareCb(IntPtr ptr1, IntPtr ptr2)
423 {
424 var m1 = (IComparable) NativeToManaged(ptr1);
425 var m2 = NativeToManaged(ptr2);
426 return m1.CompareTo(m2);
427 }
428
429 public IntPtr EinaCompareCb()
430 {
431 if (dlgt == null)
432 dlgt = new Eina_Compare_Cb(PrimitiveCompareCb);
433 return Marshal.GetFunctionPointerForDelegate(dlgt);
434 }
435
436 public IntPtr EinaFreeCb()
437 {
438 return MemoryNative.FreeFuncPtrGet();
439 }
440
441 public IntPtr EinaInarrayNew(uint step)
442 {
443 return eina_inarray_new((uint)Marshal.SizeOf<T>(), step);
444 }
445
446 public IntPtr EinaHashIteratorKeyNew(IntPtr hash)
447 {
448 return eina_hash_iterator_key_new(hash);
449 }
450}
451
452public class Primitive32ElementTraits<T> : PrimitiveElementTraits<T>, IBaseElementTraits<T>
453{
454 private static IBaseElementTraits<Int32> int32Traits = null;
455
456 public Primitive32ElementTraits()
457 {
458 if (int32Traits == null)
459 if (typeof(T) == typeof(Int32)) // avoid infinite recursion
460 int32Traits = (IBaseElementTraits<Int32>)this;
461 else
462 int32Traits = TraitFunctions.GetTypeTraits<Int32>();
463 }
464
465 public IntPtr ManagedToNativeAllocRef(T man, bool refs)
466 {
467 return int32Traits.ManagedToNativeAlloc(Convert.ToInt32((object)man));
468 }
469
470 public void NativeFreeRef(IntPtr nat, bool unrefs)
471 {
472 int32Traits.NativeFree(nat);
473 }
474
475 public IntPtr EinaHashNew()
476 {
477 return eina_hash_int32_new(IntPtr.Zero);
478 }
479}
480
481public class Primitive64ElementTraits<T> : PrimitiveElementTraits<T>, IBaseElementTraits<T>
482{
483 private static IBaseElementTraits<Int64> int64Traits = null;
484
485 public Primitive64ElementTraits()
486 {
487 if (int64Traits == null)
488 if (typeof(T) == typeof(Int64)) // avoid infinite recursion
489 int64Traits = (IBaseElementTraits<Int64>)this;
490 else
491 int64Traits = TraitFunctions.GetTypeTraits<Int64>();
492 }
493
494 public IntPtr ManagedToNativeAllocRef(T man, bool refs)
495 {
496 return int64Traits.ManagedToNativeAlloc(Convert.ToInt64((object)man));
497 }
498
499 public void NativeFreeRef(IntPtr nat, bool unrefs)
500 {
501 int64Traits.NativeFree(nat);
502 }
503
504 public IntPtr EinaHashNew()
505 {
506 return eina_hash_int64_new(IntPtr.Zero);
507 }
508}
509
510public static class TraitFunctions
511{
512 public static bool IsEflObject(System.Type type)
513 {
514 return typeof(efl.eo.IWrapper).IsAssignableFrom(type);
515 }
516
517 public static bool IsString(System.Type type)
518 {
519 return type == typeof(string);
520 }
521
522 public static eina.ElementType GetElementTypeCode(System.Type type)
523 {
524 if (IsEflObject(type))
525 return ElementType.ObjectType;
526 else if (IsString(type))
527 return ElementType.StringType;
528 else
529 return ElementType.NumericType;
530 }
531
532 private static IDictionary<System.Type, object> register = new Dictionary<System.Type, object>();
533
534 public static object RegisterTypeTraits<T>()
535 {
536 object traits;
537 var type = typeof(T);
538 if (IsEflObject(type))
539 {
540 System.Type concrete = type;
541 if (!type.Name.EndsWith("Concrete"))
542 {
543 var c = type.Assembly.GetType(type.FullName + "Concrete");
544 if (c != null && type.IsAssignableFrom(c))
545 concrete = c;
546 }
547 traits = new EflObjectElementTraits<T>(concrete);
548 }
549 else if (IsString(type))
550 traits = new StringElementTraits<T>();
551 else if (type.IsValueType)
552 {
553 if (Marshal.SizeOf<T>() <= 4)
554 traits = new Primitive32ElementTraits<T>();
555 else
556 traits = new Primitive64ElementTraits<T>();
557 }
558 else
559 throw new Exception("No traits registered for this type");
560
561 register[type] = traits;
562 return traits;
563 }
564
565 public static object RegisterTypeTraits<T>(IBaseElementTraits<T> traits)
566 {
567 register[typeof(T)] = traits;
568 return traits;
569 }
570
571 public static IBaseElementTraits<T> GetTypeTraits<T>()
572 {
573 object traits;
574 if (!register.TryGetValue(typeof(T), out traits))
575 traits = RegisterTypeTraits<T>();
576 return (IBaseElementTraits<T>) traits;
577 }
578
579 // //
580 // Traits functions //
581 // //
582
583 // Convertion functions //
584
585 public static IntPtr ManagedToNativeAlloc<T>(T man)
586 {
587 return GetTypeTraits<T>().ManagedToNativeAlloc(man);
588 }
589
590 public static IntPtr ManagedToNativeAllocRef<T>(T man, bool refs = false)
591 {
592 return GetTypeTraits<T>().ManagedToNativeAllocRef(man, refs);
593 }
594
595 public static IntPtr ManagedToNativeAllocInplace<T>(T man)
596 {
597 return GetTypeTraits<T>().ManagedToNativeAllocInplace(man);
598 }
599
600 public static IntPtr ManagedToNativeAllocInlistNode<T>(T man)
601 {
602 return GetTypeTraits<T>().ManagedToNativeAllocInlistNode(man);
603 }
604
605 public static void NativeFree<T>(IntPtr nat)
606 {
607 GetTypeTraits<T>().NativeFree(nat);
608 }
609
610 public static void NativeFreeRef<T>(IntPtr nat, bool unrefs = false)
611 {
612 GetTypeTraits<T>().NativeFreeRef(nat, unrefs);
613 }
614
615 public static void NativeFreeInlistNodeElement<T>(IntPtr nat)
616 {
617 GetTypeTraits<T>().NativeFreeInlistNodeElement(nat);
618 }
619
620 public static void NativeFreeInlistNode<T>(IntPtr nat, bool freeElement = true)
621 {
622 GetTypeTraits<T>().NativeFreeInlistNode(nat, freeElement);
623 }
624
625 public static void NativeFreeInplace<T>(IntPtr nat)
626 {
627 GetTypeTraits<T>().NativeFreeInplace(nat);
628 }
629
630 public static void ResidueFreeInplace<T>(IntPtr nat)
631 {
632 GetTypeTraits<T>().ResidueFreeInplace(nat);
633 }
634
635 public static T NativeToManaged<T>(IntPtr nat)
636 {
637 return GetTypeTraits<T>().NativeToManaged(nat);
638 }
639
640 public static T NativeToManagedRef<T>(IntPtr nat)
641 {
642 return GetTypeTraits<T>().NativeToManagedRef(nat);
643 }
644
645 public static T NativeToManagedInlistNode<T>(IntPtr nat)
646 {
647 return GetTypeTraits<T>().NativeToManagedInlistNode(nat);
648 }
649
650 public static T NativeToManagedInplace<T>(IntPtr nat)
651 {
652 return GetTypeTraits<T>().NativeToManagedInplace(nat);
653 }
654
655 // Misc //
656
657 public static IntPtr EinaCompareCb<T>()
658 {
659 return GetTypeTraits<T>().EinaCompareCb();
660 }
661
662 public static IntPtr EinaFreeCb<T>()
663 {
664 return GetTypeTraits<T>().EinaFreeCb();
665 }
666
667 public static IntPtr EinaHashNew<TKey>()
668 {
669 return GetTypeTraits<TKey>().EinaHashNew();
670 }
671
672 public static IntPtr EinaInarrayNew<T>(uint step)
673 {
674 return GetTypeTraits<T>().EinaInarrayNew(step);
675 }
676
677 public static IntPtr EinaHashIteratorKeyNew<T>(IntPtr hash)
678 {
679 return GetTypeTraits<T>().EinaHashIteratorKeyNew(hash);
680 }
681}
682
683}
diff --git a/src/bindings/mono/eina_mono/eina_error.cs b/src/bindings/mono/eina_mono/eina_error.cs
new file mode 100644
index 0000000000..7bd604ecc4
--- /dev/null
+++ b/src/bindings/mono/eina_mono/eina_error.cs
@@ -0,0 +1,92 @@
1using System;
2using System.Runtime.InteropServices;
3
4namespace eina {
5
6public struct Error : IComparable<Error>
7{
8 int code;
9
10 public string Message
11 {
12 get { return MsgGet(this); }
13 }
14
15 public static Error EFL_ERROR;
16
17 public static Error NO_ERROR = new Error(0);
18 public static Error EPERM = new Error(1);
19 public static Error ENOENT = new Error(2);
20
21 public Error(int value) { code = value; }
22 static public implicit operator Error(int val)
23 {
24 return new Error(val);
25 }
26 static public implicit operator int(Error error)
27 {
28 return error.code;
29 }
30 public int CompareTo(Error err)
31 {
32 return code.CompareTo(err.code);
33 }
34 public override string ToString()
35 {
36 return "eina.Error(" + code + ")";
37 }
38
39 public static void Init()
40 {
41 if (eina_init() == 0)
42 throw (new efl.EflException("Failed to init Eina"));
43
44 EFL_ERROR = eina_error_msg_register("Managed Code Error");
45 }
46
47 [DllImport(efl.Libs.Eina)] private static extern int eina_init();
48 [DllImport(efl.Libs.Eina)] static extern Error eina_error_msg_register(string msg);
49 [DllImport(efl.Libs.Eina)] static extern Error eina_error_get();
50 [DllImport(efl.Libs.Eina)] static extern void eina_error_set(Error error);
51 [DllImport(efl.Libs.Eina)] static extern IntPtr eina_error_msg_get(Error error);
52
53 public static void Set(Error error)
54 {
55 eina_error_set(error);
56 }
57
58 public static Error Get()
59 {
60 return eina_error_get();
61 }
62
63 public static String MsgGet(Error error)
64 {
65 IntPtr cstr = eina_error_msg_get(error);
66 return eina.StringConversion.NativeUtf8ToManagedString(cstr);
67 }
68
69 public static void RaiseIfOccurred()
70 {
71 Error e = Get();
72 Clear();
73 Raise(e);
74 }
75
76 public static void Raise(Error e)
77 {
78 if (e != 0)
79 throw (new efl.EflException(MsgGet(e)));
80 }
81
82 public static void Clear()
83 {
84 Set(0);
85 }
86
87 public static Error Register(string msg)
88 {
89 return eina_error_msg_register(msg);
90 }
91}
92}
diff --git a/src/bindings/mono/eina_mono/eina_hash.cs b/src/bindings/mono/eina_mono/eina_hash.cs
new file mode 100644
index 0000000000..045a9aed10
--- /dev/null
+++ b/src/bindings/mono/eina_mono/eina_hash.cs
@@ -0,0 +1,402 @@
1using System;
2using System.Runtime.InteropServices;
3using System.Collections.Generic;
4
5using static eina.TraitFunctions;
6using static eina.IteratorNativeFunctions;
7using static eina.HashNativeFunctions;
8using eina.Callbacks;
9
10namespace eina
11{
12
13[StructLayout(LayoutKind.Sequential)]
14public struct HashTupleNative
15{
16 public IntPtr key;
17 public IntPtr data;
18 public uint key_length;
19}
20
21public static class HashNativeFunctions
22{
23 [DllImport(efl.Libs.Eina)] public static extern IntPtr
24 eina_hash_new(IntPtr key_length_cb, IntPtr key_cmp_cb, IntPtr key_hash_cb, IntPtr data_free_cb, int buckets_power_size);
25
26 [DllImport(efl.Libs.Eina)] public static extern void
27 eina_hash_free_cb_set(IntPtr hash, IntPtr data_free_cb);
28
29 [DllImport(efl.Libs.Eina)] public static extern IntPtr
30 eina_hash_string_djb2_new(IntPtr data_free_cb);
31
32 [DllImport(efl.Libs.Eina)] public static extern IntPtr
33 eina_hash_string_superfast_new(IntPtr data_free_cb);
34
35 [DllImport(efl.Libs.Eina)] public static extern IntPtr
36 eina_hash_string_small_new(IntPtr data_free_cb);
37
38 [DllImport(efl.Libs.Eina)] public static extern IntPtr
39 eina_hash_int32_new(IntPtr data_free_cb);
40
41 [DllImport(efl.Libs.Eina)] public static extern IntPtr
42 eina_hash_int64_new(IntPtr data_free_cb);
43
44 [DllImport(efl.Libs.Eina)] public static extern IntPtr
45 eina_hash_pointer_new(IntPtr data_free_cb);
46
47 [DllImport(efl.Libs.Eina)] public static extern IntPtr
48 eina_hash_stringshared_new(IntPtr data_free_cb);
49
50 [DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool
51 eina_hash_add(IntPtr hash, IntPtr key, IntPtr data);
52
53 [DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool
54 eina_hash_direct_add(IntPtr hash, IntPtr key, IntPtr data);
55
56 [DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool
57 eina_hash_del(IntPtr hash, IntPtr key, IntPtr data);
58
59 [DllImport(efl.Libs.Eina)] public static extern IntPtr
60 eina_hash_find(IntPtr hash, IntPtr key);
61
62 [DllImport(efl.Libs.Eina)] public static extern IntPtr
63 eina_hash_modify(IntPtr hash, IntPtr key, IntPtr data);
64
65 [DllImport(efl.Libs.Eina)] public static extern IntPtr
66 eina_hash_set(IntPtr hash, IntPtr key, IntPtr data);
67
68 [DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool
69 eina_hash_move(IntPtr hash, IntPtr old_key, IntPtr new_key);
70
71 [DllImport(efl.Libs.Eina)] public static extern void
72 eina_hash_free(IntPtr hash);
73
74 [DllImport(efl.Libs.Eina)] public static extern void
75 eina_hash_free_buckets(IntPtr hash);
76
77 [DllImport(efl.Libs.Eina)] public static extern int
78 eina_hash_population(IntPtr hash);
79
80 [DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool
81 eina_hash_add_by_hash(IntPtr hash, IntPtr key, int key_length, int key_hash, IntPtr data);
82
83 [DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool
84 eina_hash_direct_add_by_hash(IntPtr hash, IntPtr key, int key_length, int key_hash, IntPtr data);
85
86 [DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool
87 eina_hash_del_by_key_hash(IntPtr hash, IntPtr key, int key_length, int key_hash);
88
89 [DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool
90 eina_hash_del_by_key(IntPtr hash, IntPtr key);
91
92 [DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool
93 eina_hash_del_by_data(IntPtr hash, IntPtr data);
94
95 [DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool
96 eina_hash_del_by_hash(IntPtr hash, IntPtr key, int key_length, int key_hash, IntPtr data);
97
98 [DllImport(efl.Libs.Eina)] public static extern IntPtr
99 eina_hash_find_by_hash(IntPtr hash, IntPtr key, int key_length, int key_hash);
100
101 [DllImport(efl.Libs.Eina)] public static extern IntPtr
102 eina_hash_modify_by_hash(IntPtr hash, IntPtr key, int key_length, int key_hash, IntPtr data);
103
104 [DllImport(efl.Libs.Eina)] public static extern IntPtr
105 eina_hash_iterator_key_new(IntPtr hash);
106
107 [DllImport(efl.Libs.Eina)] public static extern IntPtr
108 eina_hash_iterator_data_new(IntPtr hash);
109
110 [DllImport(efl.Libs.Eina)] public static extern IntPtr
111 eina_hash_iterator_tuple_new(IntPtr hash);
112
113 [DllImport(efl.Libs.Eina)] public static extern void
114 eina_hash_foreach(IntPtr hash, IntPtr func, IntPtr fdata);
115
116
117 [DllImport(efl.Libs.Eina)] public static extern void
118 eina_hash_list_append(IntPtr hash, IntPtr key, IntPtr data);
119 [DllImport(efl.Libs.Eina)] public static extern void
120 eina_hash_list_prepend(IntPtr hash, IntPtr key, IntPtr data);
121 [DllImport(efl.Libs.Eina)] public static extern void
122 eina_hash_list_remove(IntPtr hash, IntPtr key, IntPtr data);
123
124 [DllImport(efl.Libs.Eina)] public static extern int
125 eina_hash_superfast(string key, int len);
126
127 [DllImport(efl.Libs.CustomExports)] public static extern IntPtr
128 eina_hash_iterator_ptr_key_wrapper_new_custom_export_mono(IntPtr hash);
129}
130
131public class Hash<TKey, TValue> : IEnumerable<KeyValuePair<TKey, TValue>>, IDisposable
132{
133 public IntPtr Handle {get; set;} = IntPtr.Zero;
134 public bool Own {get; set;}
135 public bool OwnKey {get; set;}
136 public bool OwnValue {get; set;}
137
138 public int Count {
139 get {
140 return Population();
141 }
142 }
143
144
145 private void InitNew()
146 {
147 Handle = EinaHashNew<TKey>();
148 SetOwn(true);
149 SetOwnKey(true);
150 SetOwnValue(true);
151 }
152
153 public Hash()
154 {
155 InitNew();
156 }
157
158 public Hash(IntPtr handle, bool own)
159 {
160 Handle = handle;
161 SetOwnership(own);
162 }
163
164 public Hash(IntPtr handle, bool own, bool ownKey, bool ownValue)
165 {
166 Handle = handle;
167 SetOwnership(own, ownKey, ownValue);
168 }
169
170 ~Hash()
171 {
172 Dispose(false);
173 }
174
175 protected virtual void Dispose(bool disposing)
176 {
177 IntPtr h = Handle;
178 Handle = IntPtr.Zero;
179 if (h == IntPtr.Zero)
180 return;
181
182 if (Own)
183 eina_hash_free(h);
184 }
185
186 public void Dispose()
187 {
188 Dispose(true);
189 GC.SuppressFinalize(this);
190 }
191
192 public void Free()
193 {
194 Dispose();
195 }
196
197 public IntPtr Release()
198 {
199 IntPtr h = Handle;
200 Handle = IntPtr.Zero;
201 return h;
202 }
203
204 public void SetOwn(bool own)
205 {
206 Own = own;
207 }
208
209 public void SetOwnKey(bool ownKey)
210 {
211 OwnKey = ownKey;
212 }
213
214 public void SetOwnValue(bool ownValue)
215 {
216 OwnValue = ownValue;
217
218 if (ownValue)
219 eina_hash_free_cb_set(Handle, EinaFreeCb<TValue>());
220 }
221
222 public void SetOwnership(bool ownAll)
223 {
224 SetOwn(ownAll);
225 SetOwnKey(ownAll);
226 SetOwnValue(ownAll);
227 }
228
229 public void SetOwnership(bool own, bool ownKey, bool ownValue)
230 {
231 SetOwn(own);
232 SetOwnKey(ownKey);
233 SetOwnValue(ownValue);
234 }
235
236 public void UnSetFreeCb()
237 {
238 eina_hash_free_cb_set(Handle, IntPtr.Zero);
239 }
240
241 public bool AddNew(TKey key, TValue val)
242 {
243 var nk = ManagedToNativeAllocRef(key, true);
244 var nv = ManagedToNativeAlloc(val);
245 var r = eina_hash_add(Handle, nk, nv);
246 NativeFreeRef<TKey>(nk);
247 return r;
248 }
249
250 public void Add(TKey key, TValue val)
251 {
252 Set(key, val);
253 }
254
255 public bool DelByKey(TKey key)
256 {
257 var nk = ManagedToNativeAllocRef(key);
258 var r = eina_hash_del_by_key(Handle, nk);
259 NativeFreeRef<TKey>(nk, OwnKey && r);
260 return r;
261 }
262
263 public bool DelByValue(TValue val)
264 {
265 var nv = ManagedToNativeAlloc(val);
266 var r = eina_hash_del_by_data(Handle, nv);
267 NativeFree<TValue>(nv);
268 return r;
269 }
270
271 public void Remove(TKey key)
272 {
273 DelByKey(key);
274 }
275
276 public TValue Find(TKey key)
277 {
278 var nk = ManagedToNativeAllocRef(key);
279 var found = eina_hash_find(Handle, nk);
280 NativeFreeRef<TKey>(nk);
281 if (found == IntPtr.Zero)
282 throw new KeyNotFoundException();
283 return NativeToManaged<TValue>(found);
284 }
285
286 public bool TryGetValue(TKey key, out TValue val)
287 {
288 var nk = ManagedToNativeAllocRef(key);
289 var found = eina_hash_find(Handle, nk);
290 NativeFreeRef<TKey>(nk);
291 if (found == IntPtr.Zero)
292 {
293 val = default(TValue);
294 return false;
295 }
296 val = NativeToManaged<TValue>(found);
297 return true;
298 }
299
300 public bool ContainsKey(TKey key)
301 {
302 var nk = ManagedToNativeAllocRef(key);
303 var found = eina_hash_find(Handle, nk);
304 NativeFreeRef<TKey>(nk);
305 return found != IntPtr.Zero;
306 }
307
308 public bool Modify(TKey key, TValue val)
309 {
310 var nk = ManagedToNativeAllocRef(key);
311 var nv = ManagedToNativeAlloc(val);
312 var old = eina_hash_modify(Handle, nk, nv);
313 NativeFreeRef<TKey>(nk);
314 if (old == IntPtr.Zero)
315 {
316 NativeFree<TValue>(nv);
317 return false;
318 }
319 if (OwnValue)
320 NativeFree<TValue>(old);
321 return true;
322 }
323
324 public void Set(TKey key, TValue val)
325 {
326 var nk = ManagedToNativeAllocRef(key, true);
327 var nv = ManagedToNativeAlloc(val);
328 var old = eina_hash_set(Handle, nk, nv);
329 NativeFreeRef<TKey>(nk, old != IntPtr.Zero);
330 if (old != IntPtr.Zero && OwnValue)
331 NativeFree<TValue>(old);
332 }
333
334 public TValue this[TKey key]
335 {
336 get
337 {
338 return Find(key);
339 }
340 set
341 {
342 Set(key, value);
343 }
344 }
345
346 public bool Move(TKey key_old, TKey key_new)
347 {
348 var nk_old = ManagedToNativeAllocRef(key_old);
349 var nk_new = ManagedToNativeAllocRef(key_new, true);
350 var r = eina_hash_move(Handle, nk_old, nk_new);
351 NativeFreeRef<TKey>(nk_old, OwnKey && r);
352 NativeFreeRef<TKey>(nk_new, !r);
353 return r;
354 }
355
356 public void FreeBuckets()
357 {
358 eina_hash_free_buckets(Handle);
359 }
360
361 public int Population()
362 {
363 return eina_hash_population(Handle);
364 }
365
366 public eina.Iterator<TKey> Keys()
367 {
368 return new eina.Iterator<TKey>(EinaHashIteratorKeyNew<TKey>(Handle), true, false);
369 }
370
371 public eina.Iterator<TValue> Values()
372 {
373 return new eina.Iterator<TValue>(eina_hash_iterator_data_new(Handle), true, false);
374 }
375
376 public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
377 {
378 IntPtr itr = eina_hash_iterator_tuple_new(Handle);
379 try
380 {
381 for (IntPtr tuplePtr; eina_iterator_next(itr, out tuplePtr);)
382 {
383 var tuple = Marshal.PtrToStructure<eina.HashTupleNative>(tuplePtr);
384 var key = NativeToManagedRef<TKey>(tuple.key);
385 var val = NativeToManaged<TValue>(tuple.data);
386 yield return new KeyValuePair<TKey, TValue>(key, val);
387 }
388 }
389 finally
390 {
391 eina_iterator_free(itr);
392 }
393 }
394
395 System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
396 {
397 return this.GetEnumerator();
398 }
399}
400
401}
402
diff --git a/src/bindings/mono/eina_mono/eina_inarray.cs b/src/bindings/mono/eina_mono/eina_inarray.cs
new file mode 100644
index 0000000000..120a4b8820
--- /dev/null
+++ b/src/bindings/mono/eina_mono/eina_inarray.cs
@@ -0,0 +1,324 @@
1using System;
2using System.Runtime.InteropServices;
3using System.Collections.Generic;
4
5using static eina.TraitFunctions;
6using static eina.InarrayNativeFunctions;
7
8namespace eina {
9
10public static class InarrayNativeFunctions
11{
12 [DllImport(efl.Libs.Eina)] public static extern IntPtr
13 eina_inarray_new(uint member_size, uint step);
14 [DllImport(efl.Libs.Eina)] public static extern void
15 eina_inarray_free(IntPtr array);
16 [DllImport(efl.Libs.Eina)] public static extern void
17 eina_inarray_step_set(IntPtr array, uint sizeof_eina_inarray, uint member_size, uint step);
18 [DllImport(efl.Libs.Eina)] public static extern void
19 eina_inarray_flush(IntPtr array);
20 [DllImport(efl.Libs.Eina)] public static extern int
21 eina_inarray_push(IntPtr array, IntPtr data);
22 [DllImport(efl.Libs.Eina)] public static extern IntPtr
23 eina_inarray_grow(IntPtr array, uint size);
24 [DllImport(efl.Libs.Eina)] public static extern int
25 eina_inarray_insert(IntPtr array, IntPtr data, IntPtr compare);
26 [DllImport(efl.Libs.Eina)] public static extern int
27 eina_inarray_insert_sorted(IntPtr array, IntPtr data, IntPtr compare);
28 [DllImport(efl.Libs.Eina)] public static extern int
29 eina_inarray_remove(IntPtr array, IntPtr data);
30 [DllImport(efl.Libs.Eina)] public static extern IntPtr
31 eina_inarray_pop(IntPtr array);
32 [DllImport(efl.Libs.Eina)] public static extern IntPtr
33 eina_inarray_nth(IntPtr array, uint position);
34 [DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool
35 eina_inarray_insert_at(IntPtr array, uint position, IntPtr data);
36 [DllImport(efl.Libs.Eina)] public static extern IntPtr
37 eina_inarray_alloc_at(IntPtr array, uint position, uint member_count);
38 [DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool
39 eina_inarray_replace_at(IntPtr array, uint position, IntPtr data);
40 [DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool
41 eina_inarray_remove_at(IntPtr array, uint position);
42 [DllImport(efl.Libs.Eina)] public static extern void
43 eina_inarray_reverse(IntPtr array);
44 [DllImport(efl.Libs.Eina)] public static extern void
45 eina_inarray_sort(IntPtr array, IntPtr compare);
46 [DllImport(efl.Libs.Eina)] public static extern int
47 eina_inarray_search(IntPtr array, IntPtr data, IntPtr compare);
48 [DllImport(efl.Libs.Eina)] public static extern int
49 eina_inarray_search_sorted(IntPtr array, IntPtr data, IntPtr compare);
50 [DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool
51 eina_inarray_foreach(IntPtr array, IntPtr function, IntPtr user_data);
52 [DllImport(efl.Libs.Eina)] public static extern int
53 eina_inarray_foreach_remove(IntPtr array, IntPtr match, IntPtr user_data);
54 [DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool
55 eina_inarray_resize(IntPtr array, uint new_size);
56 [DllImport(efl.Libs.Eina)] public static extern uint
57 eina_inarray_count(IntPtr array);
58
59 [DllImport(efl.Libs.Eina)] public static extern IntPtr
60 eina_inarray_iterator_new(IntPtr array);
61 [DllImport(efl.Libs.Eina)] public static extern IntPtr
62 eina_inarray_iterator_reversed_new(IntPtr array);
63 [DllImport(efl.Libs.Eina)] public static extern IntPtr
64 eina_inarray_accessor_new(IntPtr array);
65}
66
67public class Inarray<T> : IEnumerable<T>, IDisposable
68{
69 public static uint DefaultStep = 0;
70
71 public IntPtr Handle {get;set;} = IntPtr.Zero;
72 public bool Own {get;set;}
73 public bool OwnContent {get;set;}
74
75 public int Length
76 {
77 get { return Count(); }
78 }
79
80
81 private void InitNew(uint step)
82 {
83 Handle = EinaInarrayNew<T>(step);
84 Own = true;
85 OwnContent = true;
86 if (Handle == IntPtr.Zero)
87 throw new SEHException("Could not alloc inarray");
88 }
89
90 public Inarray()
91 {
92 InitNew(DefaultStep);
93 }
94
95 public Inarray(uint step)
96 {
97 InitNew(step);
98 }
99
100 public Inarray(IntPtr handle, bool own)
101 {
102 Handle = handle;
103 Own = own;
104 OwnContent = own;
105 }
106
107 public Inarray(IntPtr handle, bool own, bool ownContent)
108 {
109 Handle = handle;
110 Own = own;
111 OwnContent = ownContent;
112 }
113
114 ~Inarray()
115 {
116 Dispose(false);
117 }
118
119 protected virtual void Dispose(bool disposing)
120 {
121 IntPtr h = Handle;
122 Handle = IntPtr.Zero;
123 if (h == IntPtr.Zero)
124 return;
125
126 if (OwnContent)
127 {
128 uint len = eina_inarray_count(h);
129 for(uint i = 0; i < len; ++i)
130 {
131 NativeFreeInplace<T>(eina_inarray_nth(h, i));
132 }
133 }
134
135 if (Own)
136 eina_inarray_free(h);
137 }
138
139 public void Dispose()
140 {
141 Dispose(true);
142 GC.SuppressFinalize(this);
143 }
144
145 public void Free()
146 {
147 Dispose();
148 }
149
150 public IntPtr Release()
151 {
152 IntPtr h = Handle;
153 Handle = IntPtr.Zero;
154 return h;
155 }
156
157 private void FreeElementsIfOwned()
158 {
159 if (OwnContent)
160 {
161 int len = Length;
162 for (int i = 0; i < len; ++i)
163 {
164 NativeFreeInplace<T>(eina_inarray_nth(Handle, (uint)i));
165 }
166 }
167 }
168
169 public void Flush()
170 {
171 FreeElementsIfOwned();
172 eina_inarray_flush(Handle);
173 }
174
175 public int Count()
176 {
177 return (int) eina_inarray_count(Handle);
178 }
179
180 public void SetOwnership(bool ownAll)
181 {
182 Own = ownAll;
183 OwnContent = ownAll;
184 }
185
186 public void SetOwnership(bool own, bool ownContent)
187 {
188 Own = own;
189 OwnContent = ownContent;
190 }
191
192 public int Push(T val)
193 {
194 IntPtr ele = ManagedToNativeAllocInplace(val);
195 var r = eina_inarray_push(Handle, ele);
196 if (r == -1)
197 NativeFreeInplace<T>(ele);
198 ResidueFreeInplace<T>(ele);
199 return r;
200 }
201
202// TODO ???
203// public void Add(T val)
204// {
205// if (!Push(val))
206// throw;
207// }
208
209 public T Pop()
210 {
211 IntPtr ele = eina_inarray_pop(Handle);
212 var r = NativeToManagedInplace<T>(ele);
213 if (OwnContent && ele != IntPtr.Zero)
214 NativeFreeInplace<T>(ele);
215 return r;
216 }
217
218 public T Nth(uint idx)
219 {
220 IntPtr ele = eina_inarray_nth(Handle, idx);
221 return NativeToManagedInplace<T>(ele);
222 }
223
224 public T At(int idx)
225 {
226 return Nth((uint)idx);
227 }
228
229 public bool InsertAt(uint idx, T val)
230 {
231 IntPtr ele = ManagedToNativeAllocInplace(val);
232 var r = eina_inarray_insert_at(Handle, idx, ele);
233 if (!r)
234 NativeFreeInplace<T>(ele);
235 ResidueFreeInplace<T>(ele);
236 return r;
237 }
238
239 public bool ReplaceAt(uint idx, T val)
240 {
241 var old = eina_inarray_nth(Handle, idx);
242 if (old == IntPtr.Zero)
243 return false;
244 if (OwnContent)
245 NativeFreeInplace<T>(old);
246 var ele = ManagedToNativeAllocInplace(val);
247 var r = eina_inarray_replace_at(Handle, idx, ele);
248 ResidueFreeInplace<T>(ele);
249 return r;
250 }
251
252 public T this[int idx]
253 {
254 get
255 {
256 return At(idx);
257 }
258 set
259 {
260 ReplaceAt((uint)idx, value);
261 }
262 }
263
264 public bool RemoveAt(uint idx)
265 {
266 IntPtr ele = eina_inarray_nth(Handle, idx);
267 if (ele == IntPtr.Zero)
268 return false;
269 if (OwnContent)
270 NativeFreeInplace<T>(ele);
271
272 return eina_inarray_remove_at(Handle, idx);
273 }
274
275 public void Reverse()
276 {
277 eina_inarray_reverse(Handle);
278 }
279
280 public T[] ToArray()
281 {
282 int len = Length;
283 var managed = new T[len];
284 for(int i = 0; i < len; ++i)
285 {
286 managed[i] = At(i);
287 }
288 return managed;
289 }
290
291 public bool Append(T[] values)
292 {
293 foreach(T v in values)
294 if (Push(v) == -1)
295 return false;
296 return true;
297 }
298
299 public eina.Iterator<T> GetIterator()
300 {
301 return new eina.Iterator<T>(eina_inarray_iterator_new(Handle), true, false);
302 }
303
304 public eina.Iterator<T> GetReversedIterator()
305 {
306 return new eina.Iterator<T>(eina_inarray_iterator_reversed_new(Handle), true, false);
307 }
308
309 public IEnumerator<T> GetEnumerator()
310 {
311 int len = Length;
312 for(int i = 0; i < len; ++i)
313 {
314 yield return At(i);
315 }
316 }
317
318 System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
319 {
320 return this.GetEnumerator();
321 }
322}
323
324}
diff --git a/src/bindings/mono/eina_mono/eina_inlist.cs b/src/bindings/mono/eina_mono/eina_inlist.cs
new file mode 100644
index 0000000000..8257c20593
--- /dev/null
+++ b/src/bindings/mono/eina_mono/eina_inlist.cs
@@ -0,0 +1,316 @@
1using System;
2using System.Runtime.InteropServices;
3using System.Collections.Generic;
4
5using static eina.TraitFunctions;
6using static eina.InlistNativeFunctions;
7using eina.Callbacks;
8
9namespace eina {
10
11public static class InlistNativeFunctions
12{
13 [DllImport(efl.Libs.Eina)] public static extern IntPtr
14 eina_inlist_append(IntPtr in_list, IntPtr in_item);
15
16 [DllImport(efl.Libs.Eina)] public static extern IntPtr
17 eina_inlist_prepend(IntPtr in_list, IntPtr in_item);
18
19 [DllImport(efl.Libs.Eina)] public static extern IntPtr
20 eina_inlist_append_relative(IntPtr in_list, IntPtr in_item, IntPtr in_relative);
21
22 [DllImport(efl.Libs.Eina)] public static extern IntPtr
23 eina_inlist_prepend_relative(IntPtr in_list, IntPtr in_item, IntPtr in_relative);
24
25 [DllImport(efl.Libs.Eina)] public static extern IntPtr
26 eina_inlist_remove(IntPtr in_list, IntPtr in_item);
27
28 [DllImport(efl.Libs.Eina)] public static extern IntPtr
29 eina_inlist_find(IntPtr in_list, IntPtr in_item);
30
31 [DllImport(efl.Libs.Eina)] public static extern IntPtr
32 eina_inlist_promote(IntPtr list, IntPtr item);
33
34 [DllImport(efl.Libs.Eina)] public static extern IntPtr
35 eina_inlist_demote(IntPtr list, IntPtr item);
36
37 [DllImport(efl.Libs.Eina)] public static extern uint
38 eina_inlist_count(IntPtr list);
39
40 [DllImport(efl.Libs.Eina)] public static extern IntPtr
41 eina_inlist_iterator_new(IntPtr in_list);
42
43 [DllImport(efl.Libs.Eina)] public static extern IntPtr
44 eina_inlist_accessor_new(IntPtr in_list);
45
46 [DllImport(efl.Libs.Eina)] public static extern IntPtr
47 eina_inlist_sorted_insert(IntPtr list, IntPtr item, IntPtr func);
48
49 [DllImport(efl.Libs.Eina)] public static extern IntPtr
50 eina_inlist_sorted_state_new();
51
52 [DllImport(efl.Libs.Eina)] public static extern int
53 eina_inlist_sorted_state_init(IntPtr state, IntPtr list);
54
55 [DllImport(efl.Libs.Eina)] public static extern void
56 eina_inlist_sorted_state_free(IntPtr state);
57
58 [DllImport(efl.Libs.Eina)] public static extern IntPtr
59 eina_inlist_sorted_state_insert(IntPtr list, IntPtr item, IntPtr func, IntPtr state);
60
61 [DllImport(efl.Libs.Eina)] public static extern IntPtr
62 eina_inlist_sort(IntPtr head, IntPtr func);
63
64
65 [DllImport(efl.Libs.CustomExports)] public static extern IntPtr
66 eina_inlist_first_custom_export_mono(IntPtr list);
67 [DllImport(efl.Libs.CustomExports)] public static extern IntPtr
68 eina_inlist_last_custom_export_mono(IntPtr list);
69
70
71 [DllImport(efl.Libs.CustomExports)] public static extern IntPtr
72 eina_inlist_next_custom_export_mono(IntPtr list);
73 [DllImport(efl.Libs.CustomExports)] public static extern IntPtr
74 eina_inlist_prev_custom_export_mono(IntPtr list);
75
76 [DllImport(efl.Libs.CustomExports)] public static extern IntPtr
77 eina_inlist_iterator_wrapper_new_custom_export_mono(IntPtr in_list);
78}
79
80public class Inlist<T> : IEnumerable<T>, IDisposable
81{
82 public IntPtr Handle {get;set;} = IntPtr.Zero;
83 public bool Own {get;set;}
84 public bool OwnContent {get;set;}
85
86 public int Length
87 {
88 get { return Count(); }
89 }
90
91
92 private void InitNew()
93 {
94 Handle = IntPtr.Zero;
95 Own = true;
96 OwnContent = true;
97 }
98
99 private IntPtr InternalFirst()
100 {
101 return eina_inlist_first_custom_export_mono(Handle);
102 }
103
104 private IntPtr InternalLast()
105 {
106 return eina_inlist_last_custom_export_mono(Handle);
107 }
108
109 private IntPtr InternalAt(int idx)
110 {
111 if (idx < 0)
112 return IntPtr.Zero;
113
114 IntPtr curr = Handle;
115 for (int n = 0; n != idx && curr != IntPtr.Zero; ++n)
116 curr = InternalNext(curr);
117 return curr;
118 }
119
120 private static IntPtr InternalNext(IntPtr inlist)
121 {
122 return eina_inlist_next_custom_export_mono(inlist);
123 }
124
125 private static IntPtr InternalPrev(IntPtr inlist)
126 {
127 return eina_inlist_prev_custom_export_mono(inlist);
128 }
129
130
131 public Inlist()
132 {
133 InitNew();
134 }
135
136 public Inlist(IntPtr handle, bool own)
137 {
138 Handle = handle;
139 Own = own;
140 OwnContent = own;
141 }
142
143 public Inlist(IntPtr handle, bool own, bool ownContent)
144 {
145 Handle = handle;
146 Own = own;
147 OwnContent = ownContent;
148 }
149
150 ~Inlist()
151 {
152 Dispose(false);
153 }
154
155 protected virtual void Dispose(bool disposing)
156 {
157 IntPtr h = Handle;
158 Handle = IntPtr.Zero;
159 if (h == IntPtr.Zero)
160 return;
161
162 if (OwnContent)
163 {
164 for(IntPtr curr = h; curr != IntPtr.Zero; curr = InternalNext(curr))
165 {
166 NativeFreeInlistNodeElement<T>(curr);
167 }
168 }
169
170 if (Own)
171 {
172 while (h != IntPtr.Zero)
173 {
174 var aux = h;
175 h = eina_inlist_remove(h, h);
176 NativeFreeInlistNode<T>(aux, false);
177 }
178 }
179 }
180
181 public void Dispose()
182 {
183 Dispose(true);
184 GC.SuppressFinalize(this);
185 }
186
187 public void Free()
188 {
189 Dispose();
190 }
191
192 public IntPtr Release()
193 {
194 IntPtr h = Handle;
195 Handle = IntPtr.Zero;
196 return h;
197 }
198
199 public void SetOwnership(bool ownAll)
200 {
201 Own = ownAll;
202 OwnContent = ownAll;
203 }
204
205 public void SetOwnership(bool own, bool ownContent)
206 {
207 Own = own;
208 OwnContent = ownContent;
209 }
210
211 public int Count()
212 {
213 return (int) eina_inlist_count(Handle);
214 }
215
216 public void Clean()
217 {
218 while (Handle != IntPtr.Zero)
219 {
220 var aux = Handle;
221 Handle = eina_inlist_remove(Handle, Handle);
222 NativeFreeInlistNode<T>(aux, OwnContent);
223 }
224 }
225
226 public void Append(T val)
227 {
228 IntPtr node = ManagedToNativeAllocInlistNode(val);
229 Handle = eina_inlist_append(Handle, node);
230 }
231
232 public void Prepend(T val)
233 {
234 IntPtr node = ManagedToNativeAllocInlistNode(val);
235 Handle = eina_inlist_prepend(Handle, node);
236 }
237
238 public void Remove(int idx)
239 {
240 IntPtr node = InternalAt(idx);
241 Handle = eina_inlist_remove(Handle, node);
242 NativeFreeInlistNode<T>(node, OwnContent);
243 }
244
245 public T At(int idx)
246 {
247 IntPtr node = InternalAt(idx);
248 if (node == IntPtr.Zero)
249 throw new IndexOutOfRangeException();
250 return NativeToManagedInlistNode<T>(node);
251 }
252
253 public void DataSet(int idx, T val)
254 {
255 IntPtr old = InternalAt(idx);
256 if (old == IntPtr.Zero)
257 throw new IndexOutOfRangeException();
258
259 IntPtr new_node = ManagedToNativeAllocInlistNode(val);
260
261 Handle = eina_inlist_append_relative(Handle, new_node, old);
262 Handle = eina_inlist_remove(Handle, old);
263
264 NativeFreeInlistNode<T>(old, OwnContent);
265 }
266
267 public T this[int idx]
268 {
269 get
270 {
271 return At(idx);
272 }
273 set
274 {
275 DataSet(idx, value);
276 }
277 }
278
279 public T[] ToArray()
280 {
281 var managed = new T[Count()];
282 int i = 0;
283 for(IntPtr curr = Handle; curr != IntPtr.Zero; ++i, curr = InternalNext(curr))
284 {
285 managed[i] = NativeToManagedInlistNode<T>(curr);
286 }
287 return managed;
288 }
289
290 public void AppendArray(T[] values)
291 {
292 foreach (T v in values)
293 Append(v);
294 }
295
296
297 public eina.Iterator<T> GetIterator()
298 {
299 return new eina.Iterator<T>(eina_inlist_iterator_wrapper_new_custom_export_mono(Handle), true, false);
300 }
301
302 public IEnumerator<T> GetEnumerator()
303 {
304 for(IntPtr curr = Handle; curr != IntPtr.Zero; curr = InternalNext(curr))
305 {
306 yield return NativeToManagedInlistNode<T>(curr);
307 }
308 }
309
310 System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
311 {
312 return this.GetEnumerator();
313 }
314}
315
316}
diff --git a/src/bindings/mono/eina_mono/eina_iterator.cs b/src/bindings/mono/eina_mono/eina_iterator.cs
new file mode 100644
index 0000000000..854a68c084
--- /dev/null
+++ b/src/bindings/mono/eina_mono/eina_iterator.cs
@@ -0,0 +1,144 @@
1using System;
2using System.Runtime.InteropServices;
3using System.Collections.Generic;
4
5using static eina.TraitFunctions;
6using static eina.IteratorNativeFunctions;
7
8namespace eina {
9
10public static class IteratorNativeFunctions
11{
12 [DllImport(efl.Libs.Eina)] public static extern void
13 eina_iterator_free(IntPtr iterator);
14 [DllImport(efl.Libs.Eina)] public static extern IntPtr
15 eina_iterator_container_get(IntPtr iterator);
16 [DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool
17 eina_iterator_next(IntPtr iterator, out IntPtr data);
18 [DllImport(efl.Libs.Eina)] public static extern void
19 eina_iterator_foreach(IntPtr iterator, IntPtr callback, IntPtr fdata);
20 [DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool
21 eina_iterator_lock(IntPtr iterator);
22 [DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool
23 eina_iterator_unlock(IntPtr iterator);
24
25 [DllImport(efl.Libs.Eina)] public static extern IntPtr
26 eina_carray_iterator_new(IntPtr array);
27}
28
29public class Iterator<T> : IEnumerable<T>, IDisposable
30{
31 public IntPtr Handle {get;set;} = IntPtr.Zero;
32 public bool Own {get;set;} = true;
33 public bool OwnContent {get;set;} = false;
34
35 public Iterator(IntPtr handle, bool own)
36 {
37 Handle = handle;
38 Own = own;
39 OwnContent = own;
40 }
41
42 public Iterator(IntPtr handle, bool own, bool ownContent)
43 {
44 Handle = handle;
45 Own = own;
46 OwnContent = ownContent;
47 }
48
49 ~Iterator()
50 {
51 Dispose(false);
52 }
53
54 protected virtual void Dispose(bool disposing)
55 {
56 var h = Handle;
57 Handle = IntPtr.Zero;
58 if (h == IntPtr.Zero)
59 return;
60
61 if (OwnContent)
62 {
63 for(IntPtr data; eina_iterator_next(h, out data);)
64 {
65 NativeFree<T>(data);
66 }
67 }
68
69 if (Own)
70 eina_iterator_free(h);
71 }
72
73 public void Dispose()
74 {
75 Dispose(true);
76 GC.SuppressFinalize(this);
77 }
78
79 public void Free()
80 {
81 Dispose();
82 }
83
84 public IntPtr Release()
85 {
86 IntPtr h = Handle;
87 Handle = IntPtr.Zero;
88 return h;
89 }
90
91 public void SetOwnership(bool ownAll)
92 {
93 Own = ownAll;
94 OwnContent = ownAll;
95 }
96
97 public void SetOwnership(bool own, bool ownContent)
98 {
99 Own = own;
100 OwnContent = ownContent;
101 }
102
103 public bool Next(out T res)
104 {
105 IntPtr data;
106 if (!eina_iterator_next(Handle, out data))
107 {
108 res = default(T);
109 return false;
110 }
111
112 res = NativeToManaged<T>(data);
113
114 if (OwnContent)
115 NativeFree<T>(data);
116
117 return true;
118 }
119
120 public bool Lock()
121 {
122 return eina_iterator_lock(Handle);
123 }
124
125 public bool Unlock()
126 {
127 return eina_iterator_unlock(Handle);
128 }
129
130 public IEnumerator<T> GetEnumerator()
131 {
132 for(T curr; Next(out curr);)
133 {
134 yield return curr;
135 }
136 }
137
138 System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
139 {
140 return this.GetEnumerator();
141 }
142}
143
144}
diff --git a/src/bindings/mono/eina_mono/eina_list.cs b/src/bindings/mono/eina_mono/eina_list.cs
new file mode 100644
index 0000000000..c972c82ed5
--- /dev/null
+++ b/src/bindings/mono/eina_mono/eina_list.cs
@@ -0,0 +1,352 @@
1using System;
2using System.Runtime.InteropServices;
3using System.Collections.Generic;
4
5using static eina.TraitFunctions;
6using static eina.ListNativeFunctions;
7using eina.Callbacks;
8
9namespace eina {
10
11public static class ListNativeFunctions
12{
13 [DllImport(efl.Libs.Eina)] public static extern IntPtr
14 eina_list_append(IntPtr list, IntPtr data);
15 [DllImport(efl.Libs.Eina)] public static extern IntPtr
16 eina_list_prepend(IntPtr list, IntPtr data);
17 [DllImport(efl.Libs.Eina)] public static extern IntPtr
18 eina_list_append_relative(IntPtr list, IntPtr data, IntPtr relative);
19 [DllImport(efl.Libs.Eina)] public static extern IntPtr
20 eina_list_append_relative_list(IntPtr list, IntPtr data, IntPtr relative);
21 [DllImport(efl.Libs.Eina)] public static extern IntPtr
22 eina_list_prepend_relative(IntPtr list, IntPtr data, IntPtr relative);
23 [DllImport(efl.Libs.Eina)] public static extern IntPtr
24 eina_list_prepend_relative_list(IntPtr list, IntPtr data, IntPtr relative);
25 [DllImport(efl.Libs.Eina)] public static extern IntPtr
26 eina_list_sorted_insert(IntPtr list, IntPtr func, IntPtr data);
27 [DllImport(efl.Libs.Eina)] public static extern IntPtr
28 eina_list_remove(IntPtr list, IntPtr data);
29 [DllImport(efl.Libs.Eina)] public static extern IntPtr
30 eina_list_remove_list(IntPtr list, IntPtr remove_list);
31 [DllImport(efl.Libs.Eina)] public static extern IntPtr
32 eina_list_promote_list(IntPtr list, IntPtr move_list);
33 [DllImport(efl.Libs.Eina)] public static extern IntPtr
34 eina_list_demote_list(IntPtr list, IntPtr move_list);
35 [DllImport(efl.Libs.Eina)] public static extern IntPtr
36 eina_list_data_find(IntPtr list, IntPtr data);
37 [DllImport(efl.Libs.Eina)] public static extern IntPtr
38 eina_list_data_find_list(IntPtr list, IntPtr data);
39 [DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool
40 eina_list_move(ref IntPtr to, ref IntPtr from, IntPtr data);
41 [DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool
42 eina_list_move_list(ref IntPtr to, ref IntPtr from, IntPtr data);
43 [DllImport(efl.Libs.Eina)] public static extern IntPtr
44 eina_list_free(IntPtr list);
45 [DllImport(efl.Libs.Eina)] public static extern IntPtr
46 eina_list_nth(IntPtr list, uint n);
47 [DllImport(efl.Libs.Eina)] public static extern IntPtr
48 eina_list_nth_list(IntPtr list, uint n);
49 [DllImport(efl.Libs.Eina)] public static extern IntPtr
50 eina_list_reverse(IntPtr list);
51 [DllImport(efl.Libs.Eina)] public static extern IntPtr
52 eina_list_reverse_clone(IntPtr list);
53 [DllImport(efl.Libs.Eina)] public static extern IntPtr
54 eina_list_clone(IntPtr list);
55 [DllImport(efl.Libs.Eina)] public static extern IntPtr
56 eina_list_sort(IntPtr list, uint limit, IntPtr func);
57 [DllImport(efl.Libs.Eina)] public static extern IntPtr
58 eina_list_shuffle(IntPtr list, IntPtr func);
59 [DllImport(efl.Libs.Eina)] public static extern IntPtr
60 eina_list_merge(IntPtr left, IntPtr right);
61 [DllImport(efl.Libs.Eina)] public static extern IntPtr
62 eina_list_sorted_merge(IntPtr left, IntPtr right, IntPtr func);
63 [DllImport(efl.Libs.Eina)] public static extern IntPtr
64 eina_list_split_list(IntPtr list, IntPtr relative, ref IntPtr right);
65 [DllImport(efl.Libs.Eina)] public static extern IntPtr
66 eina_list_search_sorted_near_list(IntPtr list, IntPtr func, IntPtr data, IntPtr result_cmp);
67 [DllImport(efl.Libs.Eina)] public static extern IntPtr
68 eina_list_search_sorted_list(IntPtr list, IntPtr func, IntPtr data);
69 [DllImport(efl.Libs.Eina)] public static extern IntPtr
70 eina_list_search_sorted(IntPtr list, IntPtr func, IntPtr data);
71 [DllImport(efl.Libs.Eina)] public static extern IntPtr
72 eina_list_search_unsorted_list(IntPtr list, IntPtr func, IntPtr data);
73 [DllImport(efl.Libs.Eina)] public static extern IntPtr
74 eina_list_search_unsorted(IntPtr list, IntPtr func, IntPtr data);
75
76 [DllImport(efl.Libs.Eina)] public static extern IntPtr
77 eina_list_iterator_new(IntPtr list);
78 [DllImport(efl.Libs.Eina)] public static extern IntPtr
79 eina_list_iterator_reversed_new(IntPtr list);
80 [DllImport(efl.Libs.Eina)] public static extern IntPtr
81 eina_list_accessor_new(IntPtr list);
82 [DllImport(efl.Libs.Eina)] public static extern int
83 eina_list_data_idx(IntPtr list, IntPtr data);
84
85
86 [DllImport(efl.Libs.CustomExports)] public static extern IntPtr
87 eina_list_last_custom_export_mono(IntPtr list);
88 [DllImport(efl.Libs.CustomExports)] public static extern IntPtr
89 eina_list_next_custom_export_mono(IntPtr list);
90 [DllImport(efl.Libs.CustomExports)] public static extern IntPtr
91 eina_list_prev_custom_export_mono(IntPtr list);
92 [DllImport(efl.Libs.CustomExports)] public static extern IntPtr
93 eina_list_data_get_custom_export_mono(IntPtr list);
94 [DllImport(efl.Libs.CustomExports)] public static extern IntPtr
95 eina_list_data_set_custom_export_mono(IntPtr list, IntPtr data);
96 [DllImport(efl.Libs.CustomExports)] public static extern uint
97 eina_list_count_custom_export_mono(IntPtr list);
98 [DllImport(efl.Libs.CustomExports)] public static extern IntPtr
99 eina_list_last_data_get_custom_export_mono(IntPtr list);
100}
101
102public class List<T> : IEnumerable<T>, IDisposable
103{
104 public IntPtr Handle {get;set;} = IntPtr.Zero;
105 public bool Own {get;set;}
106 public bool OwnContent {get;set;}
107
108 public int Length
109 {
110 get { return Count(); }
111 }
112
113
114 private void InitNew()
115 {
116 Handle = IntPtr.Zero;
117 Own = true;
118 OwnContent = true;
119 }
120
121 private IntPtr InternalLast()
122 {
123 return eina_list_last_custom_export_mono(Handle);
124 }
125
126 private static IntPtr InternalNext(IntPtr list)
127 {
128 return eina_list_next_custom_export_mono(list);
129 }
130
131 private static IntPtr InternalPrev(IntPtr list)
132 {
133 return eina_list_prev_custom_export_mono(list);
134 }
135
136 private static IntPtr InternalDataGet(IntPtr list)
137 {
138 return eina_list_data_get_custom_export_mono(list);
139 }
140
141 private static IntPtr InternalDataSet(IntPtr list, IntPtr data)
142 {
143 return eina_list_data_set_custom_export_mono(list, data);
144 }
145
146
147 public List()
148 {
149 InitNew();
150 }
151
152 public List(IntPtr handle, bool own)
153 {
154 Handle = handle;
155 Own = own;
156 OwnContent = own;
157 }
158
159 public List(IntPtr handle, bool own, bool ownContent)
160 {
161 Handle = handle;
162 Own = own;
163 OwnContent = ownContent;
164 }
165
166 ~List()
167 {
168 Dispose(false);
169 }
170
171 protected virtual void Dispose(bool disposing)
172 {
173 IntPtr h = Handle;
174 Handle = IntPtr.Zero;
175 if (h == IntPtr.Zero)
176 return;
177
178 if (OwnContent)
179 {
180 for(IntPtr curr = h; curr != IntPtr.Zero; curr = InternalNext(curr))
181 {
182 NativeFree<T>(InternalDataGet(curr));
183 }
184 }
185
186 if (Own)
187 eina_list_free(h);
188 }
189
190 public void Dispose()
191 {
192 Dispose(true);
193 GC.SuppressFinalize(this);
194 }
195
196 public void Free()
197 {
198 Dispose();
199 }
200
201 public IntPtr Release()
202 {
203 IntPtr h = Handle;
204 Handle = IntPtr.Zero;
205 return h;
206 }
207
208 public void SetOwnership(bool ownAll)
209 {
210 Own = ownAll;
211 OwnContent = ownAll;
212 }
213
214 public void SetOwnership(bool own, bool ownContent)
215 {
216 Own = own;
217 OwnContent = ownContent;
218 }
219
220 public int Count()
221 {
222 return (int) eina_list_count_custom_export_mono(Handle);
223 }
224
225 public void Append(T val)
226 {
227 IntPtr ele = ManagedToNativeAlloc(val);
228 Handle = eina_list_append(Handle, ele);
229 }
230
231 public void Prepend(T val)
232 {
233 IntPtr ele = ManagedToNativeAlloc(val);
234 Handle = eina_list_prepend(Handle, ele);
235 }
236
237 public void SortedInsert(T val)
238 {
239 IntPtr ele = ManagedToNativeAlloc(val);
240 Handle = eina_list_sorted_insert(Handle, EinaCompareCb<T>(), ele);
241 }
242
243 public void SortedInsert(Eina_Compare_Cb compareCb, T val)
244 {
245 IntPtr ele = ManagedToNativeAlloc(val);
246 Handle = eina_list_sorted_insert(Handle, Marshal.GetFunctionPointerForDelegate(compareCb), ele);
247 }
248
249 public void Sort(int limit = 0)
250 {
251 Handle = eina_list_sort(Handle, (uint)limit, EinaCompareCb<T>());
252 }
253
254 public void Sort(Eina_Compare_Cb compareCb)
255 {
256 Handle = eina_list_sort(Handle, 0, Marshal.GetFunctionPointerForDelegate(compareCb));
257 }
258
259 public void Sort(int limit, Eina_Compare_Cb compareCb)
260 {
261 Handle = eina_list_sort(Handle, (uint)limit, Marshal.GetFunctionPointerForDelegate(compareCb));
262 }
263
264 public T Nth(int n)
265 {
266 // TODO: check bounds ???
267 IntPtr ele = eina_list_nth(Handle, (uint)n);
268 return NativeToManaged<T>(ele);
269 }
270
271 public void DataSet(int idx, T val)
272 {
273 IntPtr pos = eina_list_nth_list(Handle, (uint)idx);
274 if (pos == IntPtr.Zero)
275 throw new IndexOutOfRangeException();
276 if (OwnContent)
277 NativeFree<T>(InternalDataGet(pos));
278 IntPtr ele = ManagedToNativeAlloc(val);
279 InternalDataSet(pos, ele);
280 }
281
282 public T this[int idx]
283 {
284 get
285 {
286 return Nth(idx);
287 }
288 set
289 {
290 DataSet(idx, value);
291 }
292 }
293
294 public T LastDataGet()
295 {
296 IntPtr ele = eina_list_last_data_get_custom_export_mono(Handle);
297 return NativeToManaged<T>(ele);
298 }
299
300 public void Reverse()
301 {
302 Handle = eina_list_reverse(Handle);
303 }
304
305 public void Shuffle()
306 {
307 Handle = eina_list_shuffle(Handle, IntPtr.Zero);
308 }
309
310 public T[] ToArray()
311 {
312 var managed = new T[Count()];
313 int i = 0;
314 for(IntPtr curr = Handle; curr != IntPtr.Zero; curr = InternalNext(curr), ++i)
315 {
316 managed[i] = NativeToManaged<T>(InternalDataGet(curr));
317 }
318 return managed;
319 }
320
321 public void AppendArray(T[] values)
322 {
323 foreach (T v in values)
324 Append(v);
325 }
326
327
328 public eina.Iterator<T> GetIterator()
329 {
330 return new eina.Iterator<T>(eina_list_iterator_new(Handle), true, false);
331 }
332
333 public eina.Iterator<T> GetReversedIterator()
334 {
335 return new eina.Iterator<T>(eina_list_iterator_reversed_new(Handle), true, false);
336 }
337
338 public IEnumerator<T> GetEnumerator()
339 {
340 for(IntPtr curr = Handle; curr != IntPtr.Zero; curr = InternalNext(curr))
341 {
342 yield return NativeToManaged<T>(InternalDataGet(curr));
343 }
344 }
345
346 System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
347 {
348 return this.GetEnumerator();
349 }
350}
351
352}
diff --git a/src/bindings/mono/eina_mono/eina_log.cs b/src/bindings/mono/eina_mono/eina_log.cs
new file mode 100644
index 0000000000..a2a1e45927
--- /dev/null
+++ b/src/bindings/mono/eina_mono/eina_log.cs
@@ -0,0 +1,121 @@
1using System;
2using System.Runtime.InteropServices;
3using System.Runtime.CompilerServices;
4using System.Diagnostics.Contracts;
5
6namespace eina { // Manual wrappers around eina functions
7
8public class Log
9{
10 [DllImport(efl.Libs.Eina)] private static extern int eina_init();
11
12 [DllImport(efl.Libs.Eina)] private static extern void eina_log_print(
13 int domain,
14 Level level,
15 [MarshalAs(UnmanagedType.LPStr)] String file,
16 [MarshalAs(UnmanagedType.LPStr)] String function,
17 int line,
18 [MarshalAs(UnmanagedType.LPStr)] String message);
19
20 [DllImport(efl.Libs.Eina)] private static extern int eina_log_domain_register(
21 [MarshalAs(UnmanagedType.LPStr)] String name,
22 [MarshalAs(UnmanagedType.LPStr)] String color);
23
24 [DllImport(efl.Libs.Eina)] private static extern void eina_log_level_set(Level level);
25
26 [DllImport(efl.Libs.Eina)] private static extern Level eina_log_level_get();
27
28 public enum Level
29 {
30 Critical,
31 Error,
32 Warning,
33 Info,
34 Debug,
35 Unkown = (-2147483647 - 1)
36 }
37
38 public class Color
39 {
40 public static string LIGHTRED = "\033[31;1m";
41 public static string RED = "\033[31m";
42 public static string LIGHTBLUE = "\033[34;1m";
43 public static string BLUE = "\033[34m";
44 public static string GREEN = "\033[32;1m";
45 public static string YELLOW = "\033[33;1m";
46 public static string ORANGE = "\033[0;33m";
47 public static string WHITE = "\033[37;1m";
48 public static string LIGHTCYAN = "\033[36;1m";
49 public static string CYAN = "\033[36m";
50 public static string RESET = "\033[0m";
51 public static string HIGH = "\033[1m";
52 }
53
54 private static int domain = -1;
55
56 public static void Init(String name="mono", String color="\033[32;1m")
57 {
58 if (domain == -1)
59 {
60 // Maybe move this check outside when other eina stuff get support?
61 if (eina_init() == 0)
62 {
63 Console.WriteLine("Error: Can't initialize Eina for logging.");
64 return;
65 }
66 domain = eina_log_domain_register(name, color);
67 if (domain < 0)
68 Console.WriteLine("Error: Couldn't register Eina log domain for name {0}.", name);
69 else
70 Info($"Registered mono domain with number {domain}");
71 }
72 else
73 {
74 Warning("Trying to initialize the log system again.");
75 // TODO Export the domain registration to the binding user to allow custom domains.
76 }
77 }
78
79 private static void EnsureDomainRegistered()
80 {
81 if (domain < 0)
82 throw new InvalidOperationException("Log domain is not registered.");
83 }
84
85 public static void Critical(String message, [CallerLineNumber] int line=0, [CallerFilePath] string file=null, [CallerMemberName] string member = null)
86 {
87 EnsureDomainRegistered();
88 eina_log_print(domain, Level.Critical, file, member, line, message);
89 }
90 public static void Error(String message, [CallerLineNumber] int line=0, [CallerFilePath] string file=null, [CallerMemberName] string member = null)
91 {
92 EnsureDomainRegistered();
93 eina_log_print(domain, Level.Error, file, member, line, message);
94 }
95 public static void Warning(String message, [CallerLineNumber] int line=0, [CallerFilePath] string file=null, [CallerMemberName] string member = null)
96 {
97 EnsureDomainRegistered();
98 eina_log_print(domain, Level.Warning, file, member, line, message);
99 }
100 public static void Info(String message, [CallerLineNumber] int line=0, [CallerFilePath] string file=null, [CallerMemberName] string member = null)
101 {
102 EnsureDomainRegistered();
103 eina_log_print(domain, Level.Info, file, member, line, message);
104 }
105 public static void Debug(String message, [CallerLineNumber] int line=0, [CallerFilePath] string file=null, [CallerMemberName] string member = null)
106 {
107 EnsureDomainRegistered();
108 eina_log_print(domain, Level.Debug, file, member, line, message);
109 }
110
111 public static void GlobalLevelSet(Level level)
112 {
113 eina_log_level_set(level);
114 }
115
116 public static Level GlobalLevelGet()
117 {
118 return eina_log_level_get();
119 }
120}
121}
diff --git a/src/bindings/mono/eina_mono/eina_slice.cs b/src/bindings/mono/eina_mono/eina_slice.cs
new file mode 100644
index 0000000000..189e9a57c7
--- /dev/null
+++ b/src/bindings/mono/eina_mono/eina_slice.cs
@@ -0,0 +1,85 @@
1using System;
2using System.Runtime.InteropServices;
3
4namespace eina {
5
6public interface ISliceBase
7{
8 UIntPtr Len {get;set;}
9 IntPtr Mem {get;set;}
10
11 int Length {get;set;}
12};
13
14[StructLayout(LayoutKind.Sequential)]
15public struct Slice : ISliceBase
16{
17 public UIntPtr Len {get;set;}
18 public IntPtr Mem {get;set;}
19
20 public int Length
21 {
22 get { return (int) Len; }
23 set { Len = (UIntPtr) value; }
24 }
25
26 public Slice(IntPtr mem, UIntPtr len)
27 {
28 Mem = mem;
29 Len = len;
30 }
31
32 public Slice PinnedDataSet(IntPtr mem, UIntPtr len)
33 {
34 Mem = mem;
35 Len = len;
36 return this;
37 }
38}
39
40[StructLayout(LayoutKind.Sequential)]
41public struct Rw_Slice : ISliceBase
42{
43 public UIntPtr Len {get;set;}
44 public IntPtr Mem {get;set;}
45
46 public int Length
47 {
48 get { return (int) Len; }
49 set { Len = (UIntPtr) value; }
50 }
51
52 public Rw_Slice(IntPtr mem, UIntPtr len)
53 {
54 Mem = mem;
55 Len = len;
56 }
57
58 public Rw_Slice PinnedDataSet(IntPtr mem, UIntPtr len)
59 {
60 Mem = mem;
61 Len = len;
62 return this;
63 }
64
65 Slice ToSlice()
66 {
67 var r = new Slice();
68 r.Mem = Mem;
69 r.Len = Len;
70 return r;
71 }
72}
73
74}
75
76public static class Eina_SliceUtils
77{
78 public static byte[] GetBytes(this eina.ISliceBase slc)
79 {
80 var size = (int)(slc.Len);
81 byte[] mArray = new byte[size];
82 Marshal.Copy(slc.Mem, mArray, 0, size);
83 return mArray;
84 }
85}
diff --git a/src/bindings/mono/eina_mono/eina_stringshare.cs b/src/bindings/mono/eina_mono/eina_stringshare.cs
new file mode 100644
index 0000000000..825103d864
--- /dev/null
+++ b/src/bindings/mono/eina_mono/eina_stringshare.cs
@@ -0,0 +1,18 @@
1
2using System;
3using System.Runtime.InteropServices;
4
5
6namespace eina {
7
8public class Stringshare {
9 [DllImport(efl.Libs.Eina)] public static extern System.IntPtr
10 eina_stringshare_add_length(string str, System.UInt32 slen);
11 [DllImport(efl.Libs.Eina)] public static extern System.IntPtr
12 eina_stringshare_add(string str);
13 [DllImport(efl.Libs.Eina)] public static extern void
14 eina_stringshare_del(System.IntPtr str);
15}
16
17}
18
diff --git a/src/bindings/mono/eina_mono/eina_value.cs b/src/bindings/mono/eina_mono/eina_value.cs
new file mode 100644
index 0000000000..4ded15b10e
--- /dev/null
+++ b/src/bindings/mono/eina_mono/eina_value.cs
@@ -0,0 +1,1590 @@
1#define CODE_ANALYSIS
2
3using System;
4using System.Runtime.InteropServices;
5using System.Collections.Generic;
6using System.Security.Permissions;
7using System.Security;
8using System.Diagnostics.CodeAnalysis;
9using System.Runtime.Serialization;
10
11using static eina.EinaNative.UnsafeNativeMethods;
12using static eina.TraitFunctions;
13
14
15namespace eina {
16
17namespace EinaNative {
18
19// Structs to be passed from/to C when dealing with containers and
20// optional values.
21[StructLayout(LayoutKind.Sequential)]
22struct Value_Array
23{
24 public IntPtr subtype;
25 public uint step;
26 public IntPtr subarray;
27}
28
29[StructLayout(LayoutKind.Sequential)]
30struct Value_List
31{
32 public IntPtr subtype;
33 public IntPtr sublist;
34}
35
36[SuppressUnmanagedCodeSecurityAttribute]
37static internal class UnsafeNativeMethods {
38
39 [DllImport(efl.Libs.Eina)]
40 [return: MarshalAsAttribute(UnmanagedType.U1)]
41 internal static extern bool eina_value_convert(IntPtr handle, IntPtr convert);
42
43 // Wrapped and helper methods
44 [DllImport(efl.Libs.CustomExports)]
45 internal static extern int eina_value_sizeof();
46
47 [DllImport(efl.Libs.CustomExports, CharSet=CharSet.Ansi)]
48 [return: MarshalAsAttribute(UnmanagedType.U1)]
49 internal static extern bool eina_value_set_wrapper(IntPtr handle, string value);
50
51 [DllImport(efl.Libs.CustomExports)]
52 [return: MarshalAsAttribute(UnmanagedType.U1)]
53 internal static extern bool eina_value_set_wrapper(IntPtr handle, byte value);
54
55 [DllImport(efl.Libs.CustomExports)]
56 [return: MarshalAsAttribute(UnmanagedType.U1)]
57 internal static extern bool eina_value_set_wrapper(IntPtr handle, sbyte value);
58
59 [DllImport(efl.Libs.CustomExports)]
60 [return: MarshalAsAttribute(UnmanagedType.U1)]
61 internal static extern bool eina_value_set_wrapper(IntPtr handle, short value);
62
63 [DllImport(efl.Libs.CustomExports)]
64 [return: MarshalAsAttribute(UnmanagedType.U1)]
65 internal static extern bool eina_value_set_wrapper(IntPtr handle, ushort value);
66
67 [DllImport(efl.Libs.CustomExports)]
68 [return: MarshalAsAttribute(UnmanagedType.U1)]
69 internal static extern bool eina_value_set_wrapper(IntPtr handle, int value);
70
71 [DllImport(efl.Libs.CustomExports)]
72 [return: MarshalAsAttribute(UnmanagedType.U1)]
73 internal static extern bool eina_value_set_wrapper(IntPtr handle, uint value);
74
75 [DllImport(efl.Libs.CustomExports)]
76 [return: MarshalAsAttribute(UnmanagedType.U1)]
77 internal static extern bool eina_value_set_wrapper(IntPtr handle, long value);
78
79 [DllImport(efl.Libs.CustomExports)]
80 [return: MarshalAsAttribute(UnmanagedType.U1)]
81 internal static extern bool eina_value_set_wrapper(IntPtr handle, ulong value);
82
83 [DllImport(efl.Libs.CustomExports)]
84 [return: MarshalAsAttribute(UnmanagedType.U1)]
85 internal static extern bool eina_value_set_wrapper(IntPtr handle, float value);
86
87 [DllImport(efl.Libs.CustomExports)]
88 [return: MarshalAsAttribute(UnmanagedType.U1)]
89 internal static extern bool eina_value_set_wrapper(IntPtr handle, double value);
90
91 [DllImport(efl.Libs.CustomExports)]
92 [return: MarshalAsAttribute(UnmanagedType.U1)]
93 internal static extern bool eina_value_set_wrapper(IntPtr handle, IntPtr value);
94
95 [DllImport(efl.Libs.CustomExports)]
96 [return: MarshalAsAttribute(UnmanagedType.U1)]
97 internal static extern bool eina_value_setup_wrapper(IntPtr handle, IntPtr type);
98
99 [DllImport(efl.Libs.CustomExports)]
100 internal static extern void eina_value_flush_wrapper(IntPtr handle);
101
102 [DllImport(efl.Libs.CustomExports)]
103 internal static extern IntPtr eina_value_type_get_wrapper(IntPtr handle);
104
105 [DllImport(efl.Libs.CustomExports)]
106 [return: MarshalAsAttribute(UnmanagedType.U1)]
107 internal static extern bool eina_value_get_wrapper(IntPtr handle, out IntPtr output);
108
109 [DllImport(efl.Libs.CustomExports)]
110 [return: MarshalAsAttribute(UnmanagedType.U1)]
111 internal static extern bool eina_value_get_wrapper(IntPtr handle, out Value_List output);
112
113 [DllImport(efl.Libs.CustomExports)]
114 [return: MarshalAsAttribute(UnmanagedType.U1)]
115 internal static extern bool eina_value_get_wrapper(IntPtr handle, out Value_Array output);
116
117 [DllImport(efl.Libs.CustomExports)]
118 [return: MarshalAsAttribute(UnmanagedType.U1)]
119 internal static extern bool eina_value_get_wrapper(IntPtr handle, out byte output);
120
121 [DllImport(efl.Libs.CustomExports)]
122 [return: MarshalAsAttribute(UnmanagedType.U1)]
123 internal static extern bool eina_value_get_wrapper(IntPtr handle, out sbyte output);
124
125 [DllImport(efl.Libs.CustomExports)]
126 [return: MarshalAsAttribute(UnmanagedType.U1)]
127 internal static extern bool eina_value_get_wrapper(IntPtr handle, out short output);
128
129 [DllImport(efl.Libs.CustomExports)]
130 [return: MarshalAsAttribute(UnmanagedType.U1)]
131 internal static extern bool eina_value_get_wrapper(IntPtr handle, out ushort output);
132
133 [DllImport(efl.Libs.CustomExports)]
134 [return: MarshalAsAttribute(UnmanagedType.U1)]
135 internal static extern bool eina_value_get_wrapper(IntPtr handle, out int output);
136
137 [DllImport(efl.Libs.CustomExports)]
138 [return: MarshalAsAttribute(UnmanagedType.U1)]
139 internal static extern bool eina_value_get_wrapper(IntPtr handle, out uint output);
140
141 [DllImport(efl.Libs.CustomExports)]
142 [return: MarshalAsAttribute(UnmanagedType.U1)]
143 internal static extern bool eina_value_get_wrapper(IntPtr handle, out long output);
144
145 [DllImport(efl.Libs.CustomExports)]
146 [return: MarshalAsAttribute(UnmanagedType.U1)]
147 internal static extern bool eina_value_get_wrapper(IntPtr handle, out ulong output);
148
149 [DllImport(efl.Libs.CustomExports)]
150 [return: MarshalAsAttribute(UnmanagedType.U1)]
151 internal static extern bool eina_value_get_wrapper(IntPtr handle, out float output);
152
153 [DllImport(efl.Libs.CustomExports)]
154 [return: MarshalAsAttribute(UnmanagedType.U1)]
155 internal static extern bool eina_value_get_wrapper(IntPtr handle, out double output);
156
157 [DllImport(efl.Libs.CustomExports)]
158 internal static extern int eina_value_compare_wrapper(IntPtr handle, IntPtr other);
159
160 [DllImport(efl.Libs.Eina, CharSet=CharSet.Ansi)]
161 internal static extern IntPtr eina_value_to_string(IntPtr handle); // We take ownership of the returned string.
162
163 [DllImport(efl.Libs.CustomExports)]
164 [return: MarshalAsAttribute(UnmanagedType.U1)]
165 internal static extern bool eina_value_array_setup_wrapper(IntPtr handle, IntPtr subtype, uint step);
166
167 [DllImport(efl.Libs.CustomExports)]
168 [return: MarshalAsAttribute(UnmanagedType.U1)]
169 internal static extern bool eina_value_list_setup_wrapper(IntPtr handle, IntPtr subtype);
170
171 [DllImport(efl.Libs.CustomExports)]
172 [return: MarshalAsAttribute(UnmanagedType.U1)]
173 internal static extern bool eina_value_array_append_wrapper(IntPtr handle, IntPtr data);
174
175 [DllImport(efl.Libs.CustomExports)]
176 [return: MarshalAsAttribute(UnmanagedType.U1)]
177 internal static extern bool eina_value_list_append_wrapper(IntPtr handle, IntPtr data);
178
179 [DllImport(efl.Libs.CustomExports)]
180 [return: MarshalAsAttribute(UnmanagedType.U1)]
181 internal static extern bool eina_value_array_get_wrapper(IntPtr handle, int index, out IntPtr output);
182
183 [DllImport(efl.Libs.CustomExports)]
184 [return: MarshalAsAttribute(UnmanagedType.U1)]
185 internal static extern bool eina_value_list_get_wrapper(IntPtr handle, int index, out IntPtr output);
186
187 [DllImport(efl.Libs.CustomExports)]
188 [return: MarshalAsAttribute(UnmanagedType.U1)]
189 internal static extern bool eina_value_array_set_wrapper(IntPtr handle, int index, IntPtr value);
190
191 [DllImport(efl.Libs.CustomExports)]
192 [return: MarshalAsAttribute(UnmanagedType.U1)]
193 internal static extern bool eina_value_list_set_wrapper(IntPtr handle, int index, IntPtr value);
194
195 [DllImport(efl.Libs.CustomExports)]
196 internal static extern IntPtr eina_value_array_subtype_get_wrapper(IntPtr handle);
197
198 [DllImport(efl.Libs.CustomExports)]
199 internal static extern IntPtr eina_value_list_subtype_get_wrapper(IntPtr handle);
200
201 [DllImport(efl.Libs.CustomExports)]
202 internal static extern uint eina_value_array_count_wrapper(IntPtr handle);
203
204 [DllImport(efl.Libs.CustomExports)]
205 internal static extern uint eina_value_list_count_wrapper(IntPtr handle);
206
207 [DllImport(efl.Libs.CustomExports)]
208 [return: MarshalAsAttribute(UnmanagedType.U1)]
209 internal static extern bool eina_value_optional_empty_is_wrapper(IntPtr handle, [MarshalAsAttribute(UnmanagedType.U1)] out bool empty);
210
211 [DllImport(efl.Libs.Eina)]
212 [return: MarshalAsAttribute(UnmanagedType.U1)]
213 internal static extern bool eina_value_optional_pset(IntPtr handle, IntPtr subtype, ref byte value);
214
215 [DllImport(efl.Libs.Eina)]
216 [return: MarshalAsAttribute(UnmanagedType.U1)]
217 internal static extern bool eina_value_optional_pset(IntPtr handle, IntPtr subtype, ref sbyte value);
218
219 [DllImport(efl.Libs.Eina)]
220 [return: MarshalAsAttribute(UnmanagedType.U1)]
221 internal static extern bool eina_value_optional_pset(IntPtr handle, IntPtr subtype, ref short value);
222
223 [DllImport(efl.Libs.Eina)]
224 [return: MarshalAsAttribute(UnmanagedType.U1)]
225 internal static extern bool eina_value_optional_pset(IntPtr handle, IntPtr subtype, ref ushort value);
226
227 [DllImport(efl.Libs.Eina)]
228 [return: MarshalAsAttribute(UnmanagedType.U1)]</