summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_pointer.hh27
-rw-r--r--src/bin/eolian_mono/eolian/mono/klass.hh9
-rw-r--r--src/bindings/mono/efl_mono/meson.build7
-rw-r--r--src/bindings/mono/eina_mono/eina_accessor.cs9
-rw-r--r--src/bindings/mono/eina_mono/eina_array.cs9
-rw-r--r--src/bindings/mono/eina_mono/eina_binbuf.cs9
-rw-r--r--src/bindings/mono/eina_mono/eina_container_common.cs2
-rw-r--r--src/bindings/mono/eina_mono/eina_hash.cs9
-rw-r--r--src/bindings/mono/eina_mono/eina_inarray.cs9
-rw-r--r--src/bindings/mono/eina_mono/eina_iterator.cs9
-rw-r--r--src/bindings/mono/eina_mono/eina_list.cs11
-rw-r--r--src/bindings/mono/eina_mono/eina_promises.cs12
-rw-r--r--src/bindings/mono/eina_mono/eina_strbuf.cs11
-rw-r--r--src/bindings/mono/eina_mono/eina_value.cs9
-rw-r--r--src/bindings/mono/eldbus_mono/eldbus_connection.cs9
-rw-r--r--src/bindings/mono/eldbus_mono/eldbus_message.cs9
-rw-r--r--src/bindings/mono/eldbus_mono/eldbus_object.cs9
-rw-r--r--src/bindings/mono/eldbus_mono/eldbus_proxy.cs9
-rw-r--r--src/bindings/mono/eo_mono/iwrapper.cs12
-rw-r--r--src/bindings/mono/meson.build3
-rw-r--r--src/lib/efl_mono/efl_custom_exports_mono.c49
-rw-r--r--src/tests/efl_mono/Eina.cs30
-rw-r--r--src/tests/efl_mono/FunctionPointers.cs1
-rw-r--r--src/tests/efl_mono/Main.cs2
-rw-r--r--src/tests/efl_mono/dummy_test_object.eo8
-rw-r--r--src/tests/efl_mono/libefl_mono_native_test.c10
26 files changed, 255 insertions, 38 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/function_pointer.hh b/src/bin/eolian_mono/eolian/mono/function_pointer.hh
index aa99601c8c..e243ca744c 100644
--- a/src/bin/eolian_mono/eolian/mono/function_pointer.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_pointer.hh
@@ -56,7 +56,7 @@ struct function_pointer {
56 return false; 56 return false;
57 57
58 // Wrapper type, with callback matching the Unamanaged one 58 // Wrapper type, with callback matching the Unamanaged one
59 if (!as_generator("internal class " << f_name << "Wrapper\n" 59 if (!as_generator("internal class " << f_name << "Wrapper : IDisposable\n"
60 << "{\n\n" 60 << "{\n\n"
61 << scope_tab << "private " << f_name << "Internal _cb;\n" 61 << scope_tab << "private " << f_name << "Internal _cb;\n"
62 << scope_tab << "private IntPtr _cb_data;\n" 62 << scope_tab << "private IntPtr _cb_data;\n"
@@ -71,8 +71,31 @@ struct function_pointer {
71 71
72 << scope_tab << "~" << f_name << "Wrapper()\n" 72 << scope_tab << "~" << f_name << "Wrapper()\n"
73 << scope_tab << "{\n" 73 << scope_tab << "{\n"
74 << scope_tab << scope_tab << "Dispose(false);\n"
75 << scope_tab << "}\n\n"
76
77 << scope_tab << "protected virtual void Dispose(bool disposing)\n"
78 << scope_tab << "{\n"
74 << scope_tab << scope_tab << "if (this._cb_free_cb != null)\n" 79 << scope_tab << scope_tab << "if (this._cb_free_cb != null)\n"
75 << scope_tab << scope_tab << scope_tab << "this._cb_free_cb(this._cb_data);\n" 80 << scope_tab << scope_tab << "{\n"
81 << scope_tab << scope_tab << scope_tab << "if (disposing)\n"
82 << scope_tab << scope_tab << scope_tab << "{\n"
83 << scope_tab << scope_tab << scope_tab << scope_tab << "this._cb_free_cb(this._cb_data);\n"
84 << scope_tab << scope_tab << scope_tab << "}\n"
85 << scope_tab << scope_tab << scope_tab << "else\n"
86 << scope_tab << scope_tab << scope_tab << "{\n"
87 << scope_tab << scope_tab << scope_tab << scope_tab << "Efl.Eo.Globals.efl_mono_thread_safe_free_cb_exec(this._cb_free_cb, this._cb_data);\n"
88 << scope_tab << scope_tab << scope_tab << "}\n"
89 << scope_tab << scope_tab << scope_tab << "this._cb_free_cb = null;\n"
90 << scope_tab << scope_tab << scope_tab << "this._cb_data = IntPtr.Zero;\n"
91 << scope_tab << scope_tab << scope_tab << "this._cb = null;\n"
92 << scope_tab << scope_tab << "}\n"
93 << scope_tab << "}\n\n"
94
95 << scope_tab << "public void Dispose()\n"
96 << scope_tab << "{\n"
97 << scope_tab << scope_tab << "Dispose(true);\n"
98 << scope_tab << scope_tab << "GC.SuppressFinalize(this);\n"
76 << scope_tab << "}\n\n" 99 << scope_tab << "}\n\n"
77 100
78 << scope_tab << "internal " << type << " ManagedCb(" << (parameter % ",") << ")\n" 101 << scope_tab << "internal " << type << " ManagedCb(" << (parameter % ",") << ")\n"
diff --git a/src/bin/eolian_mono/eolian/mono/klass.hh b/src/bin/eolian_mono/eolian/mono/klass.hh
index 2f0bc62d6c..7973c7d763 100644
--- a/src/bin/eolian_mono/eolian/mono/klass.hh
+++ b/src/bin/eolian_mono/eolian/mono/klass.hh
@@ -600,7 +600,14 @@ struct klass
600 << scope_tab << visibility << "void Dispose(bool disposing)\n" 600 << scope_tab << visibility << "void Dispose(bool disposing)\n"
601 << scope_tab << "{\n" 601 << scope_tab << "{\n"
602 << scope_tab << scope_tab << "if (handle != System.IntPtr.Zero) {\n" 602 << scope_tab << scope_tab << "if (handle != System.IntPtr.Zero) {\n"
603 << scope_tab << scope_tab << scope_tab << "Efl.Eo.Globals.efl_unref(handle);\n" 603 << scope_tab << scope_tab << scope_tab << "if (disposing)\n"
604 << scope_tab << scope_tab << scope_tab << "{\n"
605 << scope_tab << scope_tab << scope_tab << scope_tab << "Efl.Eo.Globals.efl_unref(handle);\n"
606 << scope_tab << scope_tab << scope_tab << "}\n"
607 << scope_tab << scope_tab << scope_tab << "else\n"
608 << scope_tab << scope_tab << scope_tab << "{\n"
609 << scope_tab << scope_tab << scope_tab << scope_tab << "Efl.Eo.Globals.efl_mono_thread_safe_efl_unref(handle);\n"
610 << scope_tab << scope_tab << scope_tab << "}\n"
604 << scope_tab << scope_tab << scope_tab << "handle = System.IntPtr.Zero;\n" 611 << scope_tab << scope_tab << scope_tab << "handle = System.IntPtr.Zero;\n"
605 << scope_tab << scope_tab << "}\n" 612 << scope_tab << scope_tab << "}\n"
606 << scope_tab << "}\n" 613 << scope_tab << "}\n"
diff --git a/src/bindings/mono/efl_mono/meson.build b/src/bindings/mono/efl_mono/meson.build
index acfeb4bc3f..3edefb3c0c 100644
--- a/src/bindings/mono/efl_mono/meson.build
+++ b/src/bindings/mono/efl_mono/meson.build
@@ -8,13 +8,6 @@ bash = find_program('bash')
8map = run_command('map_generate.sh').stdout() 8map = run_command('map_generate.sh').stdout()
9 9
10 10
11efl_mono_lib = library('eflcustomexportsmono',
12 join_paths('..', '..', '..', 'lib', 'efl_mono', 'efl_custom_exports_mono.c'),
13 install : true,
14 install_dir : join_paths(dir_lib, 'efl-mono-'+version_major),
15 dependencies : [eo, eina]
16)
17
18efl_libs = configuration_data() 11efl_libs = configuration_data()
19efl_libs.set('EFL_MONO_LIBRARY_MAP', map) 12efl_libs.set('EFL_MONO_LIBRARY_MAP', map)
20efl_libs.set('CUSTOM_EXPORTS_MONO_DL_MONO', 'eflcustomexportsmono') 13efl_libs.set('CUSTOM_EXPORTS_MONO_DL_MONO', 'eflcustomexportsmono')
diff --git a/src/bindings/mono/eina_mono/eina_accessor.cs b/src/bindings/mono/eina_mono/eina_accessor.cs
index 31574d552f..d14a2039d5 100644
--- a/src/bindings/mono/eina_mono/eina_accessor.cs
+++ b/src/bindings/mono/eina_mono/eina_accessor.cs
@@ -72,7 +72,14 @@ public class Accessor<T> : IEnumerable<T>, IDisposable
72 { 72 {
73 if (Ownership == Ownership.Managed && Handle != IntPtr.Zero) 73 if (Ownership == Ownership.Managed && Handle != IntPtr.Zero)
74 { 74 {
75 eina_accessor_free(Handle); 75 if (disposing)
76 {
77 eina_accessor_free(Handle);
78 }
79 else
80 {
81 Efl.Eo.Globals.efl_mono_thread_safe_free_cb_exec(eina_accessor_free, Handle);
82 }
76 Handle = IntPtr.Zero; 83 Handle = IntPtr.Zero;
77 } 84 }
78 } 85 }
diff --git a/src/bindings/mono/eina_mono/eina_array.cs b/src/bindings/mono/eina_mono/eina_array.cs
index 106af08226..afa73e9775 100644
--- a/src/bindings/mono/eina_mono/eina_array.cs
+++ b/src/bindings/mono/eina_mono/eina_array.cs
@@ -149,7 +149,14 @@ public class Array<T> : IEnumerable<T>, IDisposable
149 149
150 if (Own) 150 if (Own)
151 { 151 {
152 eina_array_free(h); 152 if (disposing)
153 {
154 eina_array_free(h);
155 }
156 else
157 {
158 Efl.Eo.Globals.efl_mono_thread_safe_free_cb_exec(eina_array_free, h);
159 }
153 } 160 }
154 } 161 }
155 162
diff --git a/src/bindings/mono/eina_mono/eina_binbuf.cs b/src/bindings/mono/eina_mono/eina_binbuf.cs
index 24fdaee5b1..2ae04ec1bd 100644
--- a/src/bindings/mono/eina_mono/eina_binbuf.cs
+++ b/src/bindings/mono/eina_mono/eina_binbuf.cs
@@ -103,7 +103,14 @@ public class Binbuf : IDisposable
103 Handle = IntPtr.Zero; 103 Handle = IntPtr.Zero;
104 if (Own && h != IntPtr.Zero) 104 if (Own && h != IntPtr.Zero)
105 { 105 {
106 eina_binbuf_free(Handle); 106 if (disposing)
107 {
108 eina_binbuf_free(Handle);
109 }
110 else
111 {
112 Efl.Eo.Globals.efl_mono_thread_safe_free_cb_exec(eina_binbuf_free, Handle);
113 }
107 } 114 }
108 } 115 }
109 116
diff --git a/src/bindings/mono/eina_mono/eina_container_common.cs b/src/bindings/mono/eina_mono/eina_container_common.cs
index 9695c098da..630b084207 100644
--- a/src/bindings/mono/eina_mono/eina_container_common.cs
+++ b/src/bindings/mono/eina_mono/eina_container_common.cs
@@ -229,7 +229,7 @@ public class EflObjectElementTraits<T> : IBaseElementTraits<T>
229 { 229 {
230 if (nat != IntPtr.Zero) 230 if (nat != IntPtr.Zero)
231 { 231 {
232 Efl.Eo.Globals.efl_unref(nat); 232 Efl.Eo.Globals.efl_mono_thread_safe_efl_unref(nat);
233 } 233 }
234 } 234 }
235 235
diff --git a/src/bindings/mono/eina_mono/eina_hash.cs b/src/bindings/mono/eina_mono/eina_hash.cs
index 9659a809fd..d74c96970b 100644
--- a/src/bindings/mono/eina_mono/eina_hash.cs
+++ b/src/bindings/mono/eina_mono/eina_hash.cs
@@ -187,7 +187,14 @@ public class Hash<TKey, TValue> : IEnumerable<KeyValuePair<TKey, TValue>>, IDi
187 187
188 if (Own) 188 if (Own)
189 { 189 {
190 eina_hash_free(h); 190 if (disposing)
191 {
192 eina_hash_free(h);
193 }
194 else
195 {
196 Efl.Eo.Globals.efl_mono_thread_safe_free_cb_exec(eina_hash_free, h);
197 }
191 } 198 }
192 } 199 }
193 200
diff --git a/src/bindings/mono/eina_mono/eina_inarray.cs b/src/bindings/mono/eina_mono/eina_inarray.cs
index 987b46600f..8fbd89191c 100644
--- a/src/bindings/mono/eina_mono/eina_inarray.cs
+++ b/src/bindings/mono/eina_mono/eina_inarray.cs
@@ -141,7 +141,14 @@ public class Inarray<T> : IEnumerable<T>, IDisposable
141 141
142 if (Own) 142 if (Own)
143 { 143 {
144 eina_inarray_free(h); 144 if (disposing)
145 {
146 eina_inarray_free(h);
147 }
148 else
149 {
150 Efl.Eo.Globals.efl_mono_thread_safe_free_cb_exec(eina_inarray_free, h);
151 }
145 } 152 }
146 } 153 }
147 154
diff --git a/src/bindings/mono/eina_mono/eina_iterator.cs b/src/bindings/mono/eina_mono/eina_iterator.cs
index c8f61410ce..75ca1b2785 100644
--- a/src/bindings/mono/eina_mono/eina_iterator.cs
+++ b/src/bindings/mono/eina_mono/eina_iterator.cs
@@ -73,7 +73,14 @@ public class Iterator<T> : IEnumerable<T>, IDisposable
73 73
74 if (Own) 74 if (Own)
75 { 75 {
76 eina_iterator_free(h); 76 if (disposing)
77 {
78 eina_iterator_free(h);
79 }
80 else
81 {
82 Efl.Eo.Globals.efl_mono_thread_safe_free_cb_exec(eina_iterator_free, h);
83 }
77 } 84 }
78 } 85 }
79 86
diff --git a/src/bindings/mono/eina_mono/eina_list.cs b/src/bindings/mono/eina_mono/eina_list.cs
index fe956508b8..4b9e5f5856 100644
--- a/src/bindings/mono/eina_mono/eina_list.cs
+++ b/src/bindings/mono/eina_mono/eina_list.cs
@@ -45,6 +45,8 @@ public static class ListNativeFunctions
45 eina_list_move_list(ref IntPtr to, ref IntPtr from, IntPtr data); 45 eina_list_move_list(ref IntPtr to, ref IntPtr from, IntPtr data);
46 [DllImport(efl.Libs.Eina)] public static extern IntPtr 46 [DllImport(efl.Libs.Eina)] public static extern IntPtr
47 eina_list_free(IntPtr list); 47 eina_list_free(IntPtr list);
48 [DllImport(efl.Libs.CustomExports)] public static extern void
49 efl_mono_thread_safe_eina_list_free(IntPtr list);
48 [DllImport(efl.Libs.Eina)] public static extern IntPtr 50 [DllImport(efl.Libs.Eina)] public static extern IntPtr
49 eina_list_nth(IntPtr list, uint n); 51 eina_list_nth(IntPtr list, uint n);
50 [DllImport(efl.Libs.Eina)] public static extern IntPtr 52 [DllImport(efl.Libs.Eina)] public static extern IntPtr
@@ -190,7 +192,14 @@ public class List<T> : IEnumerable<T>, IDisposable
190 192
191 if (Own) 193 if (Own)
192 { 194 {
193 eina_list_free(h); 195 if (disposing)
196 {
197 eina_list_free(h);
198 }
199 else
200 {
201 efl_mono_thread_safe_eina_list_free(h);
202 }
194 } 203 }
195 } 204 }
196 205
diff --git a/src/bindings/mono/eina_mono/eina_promises.cs b/src/bindings/mono/eina_mono/eina_promises.cs
index c7b68fe7a9..25077a3c97 100644
--- a/src/bindings/mono/eina_mono/eina_promises.cs
+++ b/src/bindings/mono/eina_mono/eina_promises.cs
@@ -28,6 +28,9 @@ static internal class PromiseNativeMethods
28 [DllImport(efl.Libs.Eina)] 28 [DllImport(efl.Libs.Eina)]
29 internal static extern void eina_promise_reject(IntPtr scheduler, Eina.Error reason); 29 internal static extern void eina_promise_reject(IntPtr scheduler, Eina.Error reason);
30 30
31 [DllImport(efl.Libs.CustomExports)]
32 internal static extern void efl_mono_thread_safe_promise_reject(IntPtr scheduler, Eina.Error reason);
33
31 [DllImport(efl.Libs.Eina)] 34 [DllImport(efl.Libs.Eina)]
32 internal static extern IntPtr eina_future_new(IntPtr promise); 35 internal static extern IntPtr eina_future_new(IntPtr promise);
33 36
@@ -148,7 +151,14 @@ public class Promise : IDisposable
148 { 151 {
149 if (Handle != IntPtr.Zero) 152 if (Handle != IntPtr.Zero)
150 { 153 {
151 eina_promise_reject(Handle, Eina.Error.ECANCELED); 154 if (disposing)
155 {
156 eina_promise_reject(Handle, Eina.Error.ECANCELED);
157 }
158 else
159 {
160 efl_mono_thread_safe_promise_reject(Handle, Eina.Error.ECANCELED);
161 }
152 Handle = IntPtr.Zero; 162 Handle = IntPtr.Zero;
153 } 163 }
154 } 164 }
diff --git a/src/bindings/mono/eina_mono/eina_strbuf.cs b/src/bindings/mono/eina_mono/eina_strbuf.cs
index 5b25ff15de..927a21da08 100644
--- a/src/bindings/mono/eina_mono/eina_strbuf.cs
+++ b/src/bindings/mono/eina_mono/eina_strbuf.cs
@@ -93,7 +93,16 @@ public class Strbuf : IDisposable
93 93
94 if (!Disposed && (Handle != IntPtr.Zero)) 94 if (!Disposed && (Handle != IntPtr.Zero))
95 { 95 {
96 eina_strbuf_free(Handle); 96 if (disposing)
97 {
98 eina_strbuf_free(Handle);
99 }
100 else
101 {
102 Efl.Eo.Globals.efl_mono_thread_safe_free_cb_exec(eina_strbuf_free, Handle);
103 }
104
105 Handle = IntPtr.Zero;
97 } 106 }
98 107
99 Disposed = true; 108 Disposed = true;
diff --git a/src/bindings/mono/eina_mono/eina_value.cs b/src/bindings/mono/eina_mono/eina_value.cs
index 742dc4d366..3c9cb53ced 100644
--- a/src/bindings/mono/eina_mono/eina_value.cs
+++ b/src/bindings/mono/eina_mono/eina_value.cs
@@ -1405,7 +1405,14 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
1405 if (!Disposed && (Handle != IntPtr.Zero)) 1405 if (!Disposed && (Handle != IntPtr.Zero))
1406 { 1406 {
1407 // No need to call flush as eina_value_free already calls it for us. 1407 // No need to call flush as eina_value_free already calls it for us.
1408 Free(this.Handle); 1408 if (disposing)
1409 {
1410 Free(this.Handle);
1411 }
1412 else
1413 {
1414 Efl.Eo.Globals.efl_mono_thread_safe_free_cb_exec(eina_value_free, this.Handle);
1415 }
1409 } 1416 }
1410 1417
1411 Disposed = true; 1418 Disposed = true;
diff --git a/src/bindings/mono/eldbus_mono/eldbus_connection.cs b/src/bindings/mono/eldbus_mono/eldbus_connection.cs
index 24a1ad9aff..ea8a45f7a1 100644
--- a/src/bindings/mono/eldbus_mono/eldbus_connection.cs
+++ b/src/bindings/mono/eldbus_mono/eldbus_connection.cs
@@ -161,7 +161,14 @@ public class Connection : IDisposable
161 161
162 if (Own) 162 if (Own)
163 { 163 {
164 eldbus_connection_unref(h); 164 if (disposing)
165 {
166 eldbus_connection_unref(h);
167 }
168 else
169 {
170 Efl.Eo.Globals.efl_mono_thread_safe_free_cb_exec(eldbus_connection_unref, h);
171 }
165 } 172 }
166 } 173 }
167 174
diff --git a/src/bindings/mono/eldbus_mono/eldbus_message.cs b/src/bindings/mono/eldbus_mono/eldbus_message.cs
index 4e2c154e6a..eec9167d18 100644
--- a/src/bindings/mono/eldbus_mono/eldbus_message.cs
+++ b/src/bindings/mono/eldbus_mono/eldbus_message.cs
@@ -230,7 +230,14 @@ public class Message : IDisposable
230 230
231 if (Own) 231 if (Own)
232 { 232 {
233 eldbus_message_unref(h); 233 if (disposing)
234 {
235 eldbus_message_unref(h);
236 }
237 else
238 {
239 Efl.Eo.Globals.efl_mono_thread_safe_free_cb_exec(eldbus_message_unref, h);
240 }
234 } 241 }
235 } 242 }
236 243
diff --git a/src/bindings/mono/eldbus_mono/eldbus_object.cs b/src/bindings/mono/eldbus_mono/eldbus_object.cs
index 1e9af69709..136e8407ac 100644
--- a/src/bindings/mono/eldbus_mono/eldbus_object.cs
+++ b/src/bindings/mono/eldbus_mono/eldbus_object.cs
@@ -152,7 +152,14 @@ public class Object : System.IDisposable
152 152
153 if (Own) 153 if (Own)
154 { 154 {
155 eldbus_object_unref(h); 155 if (disposing)
156 {
157 eldbus_object_unref(h);
158 }
159 else
160 {
161 Efl.Eo.Globals.efl_mono_thread_safe_free_cb_exec(eldbus_object_unref, h);
162 }
156 } 163 }
157 } 164 }
158 165
diff --git a/src/bindings/mono/eldbus_mono/eldbus_proxy.cs b/src/bindings/mono/eldbus_mono/eldbus_proxy.cs
index 0fab5ebcab..c8ac4d265a 100644
--- a/src/bindings/mono/eldbus_mono/eldbus_proxy.cs
+++ b/src/bindings/mono/eldbus_mono/eldbus_proxy.cs
@@ -111,7 +111,14 @@ public class Proxy : IDisposable
111 111
112 if (Own) 112 if (Own)
113 { 113 {
114 eldbus_proxy_unref(h); 114 if (disposing)
115 {
116 eldbus_proxy_unref(h);
117 }
118 else
119 {
120 Efl.Eo.Globals.efl_mono_thread_safe_free_cb_exec(eldbus_proxy_unref, h);
121 }
115 } 122 }
116 } 123 }
117 124
diff --git a/src/bindings/mono/eo_mono/iwrapper.cs b/src/bindings/mono/eo_mono/iwrapper.cs
index 3600cdec50..69adf045ce 100644
--- a/src/bindings/mono/eo_mono/iwrapper.cs
+++ b/src/bindings/mono/eo_mono/iwrapper.cs
@@ -2,6 +2,7 @@
2 2
3using System; 3using System;
4using System.Runtime.InteropServices; 4using System.Runtime.InteropServices;
5using System.Runtime.CompilerServices;
5using System.Collections.Generic; 6using System.Collections.Generic;
6using System.Diagnostics; 7using System.Diagnostics;
7using System.Reflection; 8using System.Reflection;
@@ -66,6 +67,11 @@ public class Globals
66 efl_ref_count_delegate(IntPtr eo); 67 efl_ref_count_delegate(IntPtr eo);
67 [DllImport(efl.Libs.Eo)] public static extern int 68 [DllImport(efl.Libs.Eo)] public static extern int
68 efl_ref_count(IntPtr eo); 69 efl_ref_count(IntPtr eo);
70 [DllImport(efl.Libs.CustomExports)] public static extern void
71 efl_mono_thread_safe_efl_unref(IntPtr eo);
72
73 [DllImport(efl.Libs.CustomExports)] public static extern void
74 efl_mono_thread_safe_free_cb_exec(EinaFreeCb free_cb, IntPtr cb_data);
69 75
70 [DllImport(efl.Libs.Eo)] public static extern IntPtr 76 [DllImport(efl.Libs.Eo)] public static extern IntPtr
71 efl_class_name_get(IntPtr eo); 77 efl_class_name_get(IntPtr eo);
@@ -415,7 +421,9 @@ public class Globals
415 } 421 }
416 } 422 }
417 423
418 public static IntPtr instantiate_start(IntPtr klass, Efl.Object parent) 424 public static IntPtr instantiate_start(IntPtr klass, Efl.Object parent,
425 [CallerFilePath] string file = null,
426 [CallerLineNumber] int line = 0)
419 { 427 {
420 Eina.Log.Debug($"Instantiating from klass 0x{klass.ToInt64():x}"); 428 Eina.Log.Debug($"Instantiating from klass 0x{klass.ToInt64():x}");
421 System.IntPtr parent_ptr = System.IntPtr.Zero; 429 System.IntPtr parent_ptr = System.IntPtr.Zero;
@@ -424,7 +432,7 @@ public class Globals
424 parent_ptr = parent.NativeHandle; 432 parent_ptr = parent.NativeHandle;
425 } 433 }
426 434
427 System.IntPtr eo = Efl.Eo.Globals._efl_add_internal_start("file", 0, klass, parent_ptr, 1, 0); 435 System.IntPtr eo = Efl.Eo.Globals._efl_add_internal_start(file, line, klass, parent_ptr, 1, 0);
428 if (eo == System.IntPtr.Zero) 436 if (eo == System.IntPtr.Zero)
429 { 437 {
430 throw new Exception("Instantiation failed"); 438 throw new Exception("Instantiation failed");
diff --git a/src/bindings/mono/meson.build b/src/bindings/mono/meson.build
index 67c77a647d..dc2c856404 100644
--- a/src/bindings/mono/meson.build
+++ b/src/bindings/mono/meson.build
@@ -94,7 +94,8 @@ blacklisted_files = [
94efl_mono_lib = library('eflcustomexportsmono', 94efl_mono_lib = library('eflcustomexportsmono',
95 join_paths('..', '..', 'lib', 'efl_mono', 'efl_custom_exports_mono.c'), 95 join_paths('..', '..', 'lib', 'efl_mono', 'efl_custom_exports_mono.c'),
96 install : true, 96 install : true,
97 dependencies : [eo, eina] 97 install_dir : join_paths(dir_lib, 'efl-mono-'+version_major),
98 dependencies : [eo, eina, ecore]
98) 99)
99 100
100beta_option = [] 101beta_option = []
diff --git a/src/lib/efl_mono/efl_custom_exports_mono.c b/src/lib/efl_mono/efl_custom_exports_mono.c
index fce3a43a1e..669625969e 100644
--- a/src/lib/efl_mono/efl_custom_exports_mono.c
+++ b/src/lib/efl_mono/efl_custom_exports_mono.c
@@ -1,5 +1,6 @@
1#include "Eo.h" 1#include "Eo.h"
2#include "Eina.h" 2#include "Eina.h"
3#include "Ecore.h"
3 4
4#include <stdlib.h> 5#include <stdlib.h>
5#include <string.h> 6#include <string.h>
@@ -22,6 +23,52 @@
22# endif 23# endif
23#endif /* ! _WIN32 */ 24#endif /* ! _WIN32 */
24 25
26static void _efl_mono_unref_cb(void *obj)
27{
28 efl_unref(obj);
29}
30
31EAPI void efl_mono_thread_safe_efl_unref(Eo* obj)
32{
33 ecore_main_loop_thread_safe_call_async(_efl_mono_unref_cb, obj);
34}
35
36EAPI void efl_mono_thread_safe_free_cb_exec(Eina_Free_Cb free_cb, void* cb_data)
37{
38 ecore_main_loop_thread_safe_call_async(free_cb, cb_data);
39}
40
41static void _efl_mono_list_free_cb(void *l)
42{
43 eina_list_free(l);
44}
45
46EAPI void efl_mono_thread_safe_eina_list_free(Eina_List* list)
47{
48 ecore_main_loop_thread_safe_call_async(_efl_mono_list_free_cb, list);
49}
50
51typedef struct _Efl_Mono_Promise_Reject_Data
52{
53 Eina_Promise *promise;
54 Eina_Error err;
55} Efl_Mono_Promise_Reject_Data;
56
57static void _efl_mono_promise_reject_cb(void *data)
58{
59 Efl_Mono_Promise_Reject_Data *d = data;
60 eina_promise_reject(d->promise, d->err);
61 free(d);
62}
63
64EAPI void efl_mono_thread_safe_promise_reject(Eina_Promise *p, Eina_Error err)
65{
66 Efl_Mono_Promise_Reject_Data *d = malloc(sizeof(Efl_Mono_Promise_Reject_Data));
67 d->promise = p;
68 d->err = err;
69 ecore_main_loop_thread_safe_call_async(_efl_mono_promise_reject_cb, d);
70}
71
25EAPI void *efl_mono_native_alloc(unsigned int size) 72EAPI void *efl_mono_native_alloc(unsigned int size)
26{ 73{
27 return malloc(size); 74 return malloc(size);
@@ -81,7 +128,7 @@ EAPI Eina_Free_Cb efl_mono_native_free_addr_get()
81 128
82EAPI Eina_Free_Cb efl_mono_native_efl_unref_addr_get() 129EAPI Eina_Free_Cb efl_mono_native_efl_unref_addr_get()
83{ 130{
84 return (Eina_Free_Cb)efl_unref; 131 return (Eina_Free_Cb)efl_mono_thread_safe_efl_unref;
85} 132}
86 133
87// Iterator Wrapper // 134// Iterator Wrapper //
diff --git a/src/tests/efl_mono/Eina.cs b/src/tests/efl_mono/Eina.cs
index 6a07e2f288..1705c7ab83 100644
--- a/src/tests/efl_mono/Eina.cs
+++ b/src/tests/efl_mono/Eina.cs
@@ -454,6 +454,16 @@ class TestEinaSlice
454 454
455class TestEinaArray 455class TestEinaArray
456{ 456{
457 public static void SetUp()
458 {
459 Dummy.TestObject.CreateCmpArrayObjects();
460 }
461
462 public static void TearDown()
463 {
464 Dummy.TestObject.DestroyCmpArrayObjects();
465 }
466
457 public static void eina_array_default() 467 public static void eina_array_default()
458 { 468 {
459 var a = new Eina.Array<int>(); 469 var a = new Eina.Array<int>();
@@ -1273,6 +1283,16 @@ class TestEinaInarray
1273 1283
1274class TestEinaList 1284class TestEinaList
1275{ 1285{
1286 public static void SetUp()
1287 {
1288 Dummy.TestObject.CreateCmpArrayObjects();
1289 }
1290
1291 public static void TearDown()
1292 {
1293 Dummy.TestObject.DestroyCmpArrayObjects();
1294 }
1295
1276 public static void data_set_int() 1296 public static void data_set_int()
1277 { 1297 {
1278 var lst = new Eina.List<int>(); 1298 var lst = new Eina.List<int>();
@@ -2547,6 +2567,16 @@ class TestEinaHash
2547 2567
2548class TestEinaIterator 2568class TestEinaIterator
2549{ 2569{
2570 public static void SetUp()
2571 {
2572 Dummy.TestObject.CreateCmpArrayObjects();
2573 }
2574
2575 public static void TearDown()
2576 {
2577 Dummy.TestObject.DestroyCmpArrayObjects();
2578 }
2579
2550 // Array // 2580 // Array //
2551 2581
2552 public static void eina_array_int_empty_iterator() 2582 public static void eina_array_int_empty_iterator()
diff --git a/src/tests/efl_mono/FunctionPointers.cs b/src/tests/efl_mono/FunctionPointers.cs
index de363c86d6..4536704389 100644
--- a/src/tests/efl_mono/FunctionPointers.cs
+++ b/src/tests/efl_mono/FunctionPointers.cs
@@ -173,6 +173,7 @@ class TestFunctionPointers
173 173
174 GC.Collect(); 174 GC.Collect();
175 GC.WaitForPendingFinalizers(); 175 GC.WaitForPendingFinalizers();
176 Efl.App.AppMain.Iterate();
176 177
177 Test.Assert(obj.set_called, "set_callback override must have been called"); 178 Test.Assert(obj.set_called, "set_callback override must have been called");
178 Test.Assert(!obj.invoke_called, "invoke_callback must not have been called"); 179 Test.Assert(!obj.invoke_called, "invoke_callback must not have been called");
diff --git a/src/tests/efl_mono/Main.cs b/src/tests/efl_mono/Main.cs
index 3ae3584798..a5700ff180 100644
--- a/src/tests/efl_mono/Main.cs
+++ b/src/tests/efl_mono/Main.cs
@@ -92,6 +92,8 @@ class TestMain
92 } 92 }
93 Console.WriteLine("[ END SUITE ] " + ckRunSuite); 93 Console.WriteLine("[ END SUITE ] " + ckRunSuite);
94 94
95 Efl.All.Shutdown();
96
95 if (!pass) 97 if (!pass)
96 return -1; 98 return -1;
97 99
diff --git a/src/tests/efl_mono/dummy_test_object.eo b/src/tests/efl_mono/dummy_test_object.eo
index eabb6cd0ce..a50c70e2e6 100644
--- a/src/tests/efl_mono/dummy_test_object.eo
+++ b/src/tests/efl_mono/dummy_test_object.eo
@@ -1356,6 +1356,12 @@ class Dummy.Test_Object extends Efl.Object implements Dummy.Test_Iface {
1356 } 1356 }
1357 } 1357 }
1358 1358
1359 create_cmp_array_objects @class {
1360 }
1361
1362 destroy_cmp_array_objects @class {
1363 }
1364
1359 /* Futures */ 1365 /* Futures */
1360 1366
1361 get_future { 1367 get_future {
@@ -1405,8 +1411,6 @@ class Dummy.Test_Object extends Efl.Object implements Dummy.Test_Iface {
1405 } 1411 }
1406 } 1412 }
1407 implements { 1413 implements {
1408 class.constructor;
1409 class.destructor;
1410 Efl.Object.constructor; 1414 Efl.Object.constructor;
1411 Efl.Object.provider_find; 1415 Efl.Object.provider_find;
1412 Dummy.Test_Iface.emit_nonconflicted; 1416 Dummy.Test_Iface.emit_nonconflicted;
diff --git a/src/tests/efl_mono/libefl_mono_native_test.c b/src/tests/efl_mono/libefl_mono_native_test.c
index 8575ebac9c..17ef5065b2 100644
--- a/src/tests/efl_mono/libefl_mono_native_test.c
+++ b/src/tests/efl_mono/libefl_mono_native_test.c
@@ -3640,12 +3640,11 @@ Dummy_StructComplex* _dummy_test_object_struct_complex_ptr_return_own(EINA_UNUSE
3640} 3640}
3641 3641
3642// // 3642// //
3643// Class constructor 3643// Class methods
3644// // 3644// //
3645EOLIAN static void 3645EOLIAN static void
3646_dummy_test_object_class_constructor(Efl_Class *klass) 3646_dummy_test_object_create_cmp_array_objects(void)
3647{ 3647{
3648 (void)klass;
3649 modified_seq_obj[0] = base_seq_obj[0] = _new_obj(0x0); 3648 modified_seq_obj[0] = base_seq_obj[0] = _new_obj(0x0);
3650 modified_seq_obj[1] = base_seq_obj[1] = _new_obj(0x2A); 3649 modified_seq_obj[1] = base_seq_obj[1] = _new_obj(0x2A);
3651 modified_seq_obj[2] = base_seq_obj[2] = _new_obj(0x42); 3650 modified_seq_obj[2] = base_seq_obj[2] = _new_obj(0x42);
@@ -3655,11 +3654,8 @@ _dummy_test_object_class_constructor(Efl_Class *klass)
3655} 3654}
3656 3655
3657EOLIAN static void 3656EOLIAN static void
3658_dummy_test_object_class_destructor(Efl_Class *klass) 3657_dummy_test_object_destroy_cmp_array_objects(void)
3659{ 3658{
3660 (void)klass;
3661 for (unsigned i = 0; i < base_seq_obj_size; ++i)
3662 efl_unref(base_seq_obj[i]);
3663 for (unsigned i = 0; i < modified_seq_obj_size; ++i) 3659 for (unsigned i = 0; i < modified_seq_obj_size; ++i)
3664 efl_unref(modified_seq_obj[i]); 3660 efl_unref(modified_seq_obj[i]);
3665} 3661}