summaryrefslogtreecommitdiff
path: root/src/bin/eolian_mono/eolian/mono/klass.hh
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2019-01-16 16:29:56 +0900
committerVitor Sousa <vitorsousa@expertisesolutions.com.br>2019-03-01 23:58:56 -0300
commitf392c5a4363cf09e8c0e50a42c46416a09a72c74 (patch)
tree1966addc0a769679e9dfa641df816c80d243651b /src/bin/eolian_mono/eolian/mono/klass.hh
parentdd89eb2fd1755c2816d97f28822639e03ed38608 (diff)
efl-mono: Add support for dotnet core
Summary: This commits adds dotnet as a supported C# platform for EFL# bindings. Due to differences between Mono and Dotnet regarding DllImport, the bindings now are using an imperative approach to load the function pointers through the NativeModule and FunctionWrapper classes. These classes handle the dlopen/LoadLibrary and dlsym/GetProcAddress calls. Also, the previous caching of non-owned strings returned to native code was removed until further memory checks. We also had to create workaround for bool and chars in Structs for C# marshaling. Going through System.Byte instead and Marshaling manually to their respective types. In order to actually build efl_mono.dll with dotnet right now, issue #4782 from Meson should be fixed to make it properly detect and used the Dotnet compiler. Also use "-Ddotnet=true" when running meson. Fixes T7394 Reviewers: felipealmeida, vitor.sousa, bu5hm4n Reviewed By: vitor.sousa Subscribers: cedric Tags: #efl Maniphest Tasks: T7394 Differential Revision: https://phab.enlightenment.org/D8069
Diffstat (limited to 'src/bin/eolian_mono/eolian/mono/klass.hh')
-rw-r--r--src/bin/eolian_mono/eolian/mono/klass.hh18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/klass.hh b/src/bin/eolian_mono/eolian/mono/klass.hh
index e70729b..993378f 100644
--- a/src/bin/eolian_mono/eolian/mono/klass.hh
+++ b/src/bin/eolian_mono/eolian/mono/klass.hh
@@ -374,9 +374,10 @@ struct klass
374 374
375 if(!as_generator 375 if(!as_generator
376 ( 376 (
377 "public class " << native_inherit_name << " " << (root ? ": Efl.Eo.NativeClass" : (": " + base_name)) <<"{\n" 377 "public class " << native_inherit_name << " " << (root ? " : Efl.Eo.NativeClass" : (": " + base_name)) <<"{\n"
378 // << scope_tab << (root ? "protected IntPtr EoKlass { get; set; }\n" : "\n") 378 << scope_tab << "public " << (root ? "" : "new ") << " static Efl.Eo.NativeModule _Module = new Efl.Eo.NativeModule("
379 << scope_tab << "public " << /*(root ? "" : "new ")*/ "override " << "System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)\n" 379 << context_find_tag<library_context>(context).actual_library_name(cls.filename) << ");\n"
380 << scope_tab << "public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)\n"
380 << scope_tab << "{\n" 381 << scope_tab << "{\n"
381 << scope_tab << scope_tab << "var descs = new System.Collections.Generic.List<Efl_Op_Description>();\n" 382 << scope_tab << scope_tab << "var descs = new System.Collections.Generic.List<Efl_Op_Description>();\n"
382 ) 383 )
@@ -488,8 +489,6 @@ struct klass
488 489
489 return as_generator( 490 return as_generator(
490 scope_tab << visibility << " System.IntPtr handle;\n" 491 scope_tab << visibility << " System.IntPtr handle;\n"
491 << scope_tab << "public Dictionary<String, IntPtr> cached_strings = new Dictionary<String, IntPtr>();" << "\n"
492 << scope_tab << "public Dictionary<String, IntPtr> cached_stringshares = new Dictionary<String, IntPtr>();" << "\n"
493 << scope_tab << "///<summary>Pointer to the native instance.</summary>\n" 492 << scope_tab << "///<summary>Pointer to the native instance.</summary>\n"
494 << scope_tab << "public System.IntPtr NativeHandle {\n" 493 << scope_tab << "public System.IntPtr NativeHandle {\n"
495 << scope_tab << scope_tab << "get { return handle; }\n" 494 << scope_tab << scope_tab << "get { return handle; }\n"
@@ -603,8 +602,6 @@ struct klass
603 << scope_tab << "///<summary>Releases the underlying native instance.</summary>\n" 602 << scope_tab << "///<summary>Releases the underlying native instance.</summary>\n"
604 << scope_tab << "public void Dispose()\n" 603 << scope_tab << "public void Dispose()\n"
605 << scope_tab << "{\n" 604 << scope_tab << "{\n"
606 << scope_tab << "Efl.Eo.Globals.free_dict_values(cached_strings);" << "\n"
607 << scope_tab << "Efl.Eo.Globals.free_stringshare_values(cached_stringshares);" << "\n"
608 << scope_tab << scope_tab << "Dispose(true);\n" 605 << scope_tab << scope_tab << "Dispose(true);\n"
609 << scope_tab << scope_tab << "GC.SuppressFinalize(this);\n" 606 << scope_tab << scope_tab << "GC.SuppressFinalize(this);\n"
610 << scope_tab << "}\n" 607 << scope_tab << "}\n"
@@ -681,13 +678,13 @@ struct klass
681 678
682 // Callback registration functions 679 // Callback registration functions
683 if (!as_generator( 680 if (!as_generator(
684 scope_tab << visibility << "bool add_cpp_event_handler(string key, Efl.EventCb evt_delegate) {\n" 681 scope_tab << visibility << "bool add_cpp_event_handler(string lib, string key, Efl.EventCb evt_delegate) {\n"
685 << scope_tab << scope_tab << "int event_count = 0;\n" 682 << scope_tab << scope_tab << "int event_count = 0;\n"
686 << scope_tab << scope_tab << "if (!event_cb_count.TryGetValue(key, out event_count))\n" 683 << scope_tab << scope_tab << "if (!event_cb_count.TryGetValue(key, out event_count))\n"
687 << scope_tab << scope_tab << scope_tab << "event_cb_count[key] = event_count;\n" 684 << scope_tab << scope_tab << scope_tab << "event_cb_count[key] = event_count;\n"
688 << scope_tab << scope_tab << "if (event_count == 0) {\n" 685 << scope_tab << scope_tab << "if (event_count == 0) {\n"
689 686
690 << scope_tab << scope_tab << scope_tab << "IntPtr desc = Efl.EventDescription.GetNative(key);\n" 687 << scope_tab << scope_tab << scope_tab << "IntPtr desc = Efl.EventDescription.GetNative(lib, key);\n"
691 << scope_tab << scope_tab << scope_tab << "if (desc == IntPtr.Zero) {\n" 688 << scope_tab << scope_tab << scope_tab << "if (desc == IntPtr.Zero) {\n"
692 << scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Log.Error($\"Failed to get native event {key}\");\n" 689 << scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Log.Error($\"Failed to get native event {key}\");\n"
693 << scope_tab << scope_tab << scope_tab << scope_tab << "return false;\n" 690 << scope_tab << scope_tab << scope_tab << scope_tab << "return false;\n"
@@ -709,7 +706,8 @@ struct klass
709 << scope_tab << scope_tab << scope_tab << "event_cb_count[key] = event_count;\n" 706 << scope_tab << scope_tab << scope_tab << "event_cb_count[key] = event_count;\n"
710 << scope_tab << scope_tab << "if (event_count == 1) {\n" 707 << scope_tab << scope_tab << "if (event_count == 1) {\n"
711 708
712 << scope_tab << scope_tab << scope_tab << "IntPtr desc = Efl.EventDescription.GetNative(key);\n" 709 << scope_tab << scope_tab << scope_tab << "IntPtr desc = Efl.EventDescription.GetNative("
710 << context_find_tag<library_context>(context).actual_library_name(cls.filename) << ", key);\n"
713 << scope_tab << scope_tab << scope_tab << "if (desc == IntPtr.Zero) {\n" 711 << scope_tab << scope_tab << scope_tab << "if (desc == IntPtr.Zero) {\n"
714 << scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Log.Error($\"Failed to get native event {key}\");\n" 712 << scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Log.Error($\"Failed to get native event {key}\");\n"
715 << scope_tab << scope_tab << scope_tab << scope_tab << "return false;\n" 713 << scope_tab << scope_tab << scope_tab << scope_tab << "return false;\n"