summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-10-15 10:11:09 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2019-10-15 10:11:09 -0300
commit31bc3beb222b0c36b5a5ffb84beebd8e761dbdc2 (patch)
tree4b7e6bb6443ba9d5ae3af8922fa4bd13cd2cc8d0
parent64e22aaadad980d65e2bb2531374b399f0c876f8 (diff)
csharp: Avoid direct usage of some dllimport funcs
Summary: Instead of accessing them directly, generated code should access them only through proper managed wrappers. JIT should take care of inline them. This would allow D10338 without depending on the friendly assembly feature. Reviewers: YOhoho, felipealmeida, brunobelo, woohyun, segfaultxavi Reviewed By: YOhoho Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10366
-rw-r--r--src/bin/eolian_mono/eolian/mono/events.hh4
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_definition.hh4
-rw-r--r--src/bindings/mono/eo_mono/iwrapper.cs42
3 files changed, 46 insertions, 4 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/events.hh b/src/bin/eolian_mono/eolian/mono/events.hh
index ea37c9c..5ca6b1b 100644
--- a/src/bin/eolian_mono/eolian/mono/events.hh
+++ b/src/bin/eolian_mono/eolian/mono/events.hh
@@ -127,7 +127,7 @@ struct pack_event_info_and_call_visitor
127 Context const* context; 127 Context const* context;
128 attributes::type_def const& type; 128 attributes::type_def const& type;
129 129
130 static auto constexpr native_call = "Efl.Eo.Globals.efl_event_callback_call(this.NativeHandle, desc, info);\n"; 130 static auto constexpr native_call = "Efl.Eo.Globals.CallEventCallback(this.NativeHandle, desc, info);\n";
131 131
132 typedef pack_event_info_and_call_visitor<OutputIterator, Context> visitor_type; 132 typedef pack_event_info_and_call_visitor<OutputIterator, Context> visitor_type;
133 typedef bool result_type; 133 typedef bool result_type;
@@ -381,7 +381,7 @@ struct event_definition_generator
381 if (!etype.is_engaged()) 381 if (!etype.is_engaged())
382 { 382 {
383 auto event_call_site_sink = std::back_inserter(event_native_call); 383 auto event_call_site_sink = std::back_inserter(event_native_call);
384 if (!as_generator(indent.inc().inc() << "Efl.Eo.Globals.efl_event_callback_call(this.NativeHandle, desc, IntPtr.Zero);\n") 384 if (!as_generator(indent.inc().inc() << "Efl.Eo.Globals.CallEventCallback(this.NativeHandle, desc, IntPtr.Zero);\n")
385 .generate(event_call_site_sink, attributes::unused, context)) 385 .generate(event_call_site_sink, attributes::unused, context))
386 return false; 386 return false;
387 } 387 }
diff --git a/src/bin/eolian_mono/eolian/mono/function_definition.hh b/src/bin/eolian_mono/eolian/mono/function_definition.hh
index df72f2c..301f541 100644
--- a/src/bin/eolian_mono/eolian/mono/function_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_definition.hh
@@ -102,7 +102,7 @@ struct native_function_definition_generator
102 else 102 else
103 klass_cast_name = name_helpers::klass_inherit_name(*klass); 103 klass_cast_name = name_helpers::klass_inherit_name(*klass);
104 104
105 std::string self = "Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj))"; 105 std::string self = "Efl.Eo.Globals.Super(obj, Efl.Eo.Globals.GetClass(obj))";
106 106
107 if (f.is_static) 107 if (f.is_static)
108 self = ""; 108 self = "";
@@ -198,7 +198,7 @@ struct function_definition_generator
198 // IsGeneratedBindingClass is set in the constructor, true if this 198 // IsGeneratedBindingClass is set in the constructor, true if this
199 // instance is from a pure C# class (not generated). 199 // instance is from a pure C# class (not generated).
200 if (do_super && !f.is_static) 200 if (do_super && !f.is_static)
201 self = "(IsGeneratedBindingClass ? " + self + " : Efl.Eo.Globals.efl_super(" + self + ", this.NativeClass))"; 201 self = "(IsGeneratedBindingClass ? " + self + " : Efl.Eo.Globals.Super(" + self + ", this.NativeClass))";
202 else if (f.is_static) 202 else if (f.is_static)
203 self = ""; 203 self = "";
204 204
diff --git a/src/bindings/mono/eo_mono/iwrapper.cs b/src/bindings/mono/eo_mono/iwrapper.cs
index 8fe4b06..ae39b61 100644
--- a/src/bindings/mono/eo_mono/iwrapper.cs
+++ b/src/bindings/mono/eo_mono/iwrapper.cs
@@ -188,9 +188,37 @@ public class Globals
188 public delegate IntPtr efl_data_scope_get_delegate(IntPtr obj, IntPtr klass); 188 public delegate IntPtr efl_data_scope_get_delegate(IntPtr obj, IntPtr klass);
189 [DllImport(efl.Libs.Eo)] public static extern IntPtr efl_data_scope_get(IntPtr obj, IntPtr klass); 189 [DllImport(efl.Libs.Eo)] public static extern IntPtr efl_data_scope_get(IntPtr obj, IntPtr klass);
190 public delegate IntPtr efl_super_delegate(IntPtr obj, IntPtr klass); 190 public delegate IntPtr efl_super_delegate(IntPtr obj, IntPtr klass);
191
192 /// <summary>Gets a native pointer to <c>obj</c> that forwards the method call to its parent
193 /// implementation.
194 ///
195 /// <para>For generated code use only.</para>
196 /// <para>Since EFL 1.23.</para>
197 /// </summary>
198 /// <param name="obj">The native pointer to be prepared.</param>
199 /// <param name="klass">The current class.</param>
200 /// <returns>The native pointer to <c>obj</c> prepared to call the parent implementation of <c>klass</c>.</returns>
201 public static IntPtr Super(IntPtr obj, IntPtr klass)
202 {
203 return efl_super(obj, klass);
204 }
205
191 [DllImport(efl.Libs.Eo)] public static extern IntPtr efl_super(IntPtr obj, IntPtr klass); 206 [DllImport(efl.Libs.Eo)] public static extern IntPtr efl_super(IntPtr obj, IntPtr klass);
192 public delegate IntPtr efl_class_get_delegate(IntPtr obj); 207 public delegate IntPtr efl_class_get_delegate(IntPtr obj);
193 [DllImport(efl.Libs.Eo)] public static extern IntPtr efl_class_get(IntPtr obj); 208 [DllImport(efl.Libs.Eo)] public static extern IntPtr efl_class_get(IntPtr obj);
209
210 /// <summary>Gets the native EO class pointer for the given object.
211 /// <para>For generated code use only.</para>
212 /// <para>Since EFL 1.23.</para>
213 /// </summary>
214 /// <param name="obj">The native pointer to the <see cref="Efl.Object" /> instance to get the native class
215 /// from.</param>
216 /// <returns>The native class pointer or <see cref="IntPtr.Zero" /> if no such class existis.</returns>
217 public static IntPtr GetClass(IntPtr obj)
218 {
219 return efl_class_get(obj);
220 }
221
194 [DllImport(efl.Libs.Eo)] public static extern EflClassType efl_class_type_get(IntPtr klass); 222 [DllImport(efl.Libs.Eo)] public static extern EflClassType efl_class_type_get(IntPtr klass);
195 public delegate IntPtr dlerror_delegate(); 223 public delegate IntPtr dlerror_delegate();
196 [DllImport(efl.Libs.Evil)] public static extern IntPtr dlerror(); 224 [DllImport(efl.Libs.Evil)] public static extern IntPtr dlerror();
@@ -208,6 +236,20 @@ public class Globals
208 [DllImport(efl.Libs.Eo)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool 236 [DllImport(efl.Libs.Eo)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool
209 efl_event_callback_call(IntPtr obj, IntPtr desc, IntPtr event_info); 237 efl_event_callback_call(IntPtr obj, IntPtr desc, IntPtr event_info);
210 238
239 /// <summary>Calls the callbacks associated to an event.
240 /// <para>For generated code use only.</para>
241 /// <para>Since EFL 1.23.</para>
242 /// </summary>
243 /// <param name="obj">The native pointer to the <see cref="Efl.Object" /> instance that will be the emitter
244 /// of the event.</param>
245 /// <param name="desc">The native event description.</param>
246 /// <param name="event_info">The native payload of the event.</param>
247 /// <returns><c>false</c> if one of the callbacks aborted the call. <c>true</c> otherwise.</returns>
248 public static bool CallEventCallback(IntPtr obj, IntPtr desc, IntPtr event_info)
249 {
250 return efl_event_callback_call(obj, desc, event_info);
251 }
252
211 public const int RTLD_NOW = 2; 253 public const int RTLD_NOW = 2;
212 254
213 public delegate byte class_initializer(IntPtr klass); 255 public delegate byte class_initializer(IntPtr klass);