summaryrefslogtreecommitdiff
path: root/src/bin
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
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')
-rw-r--r--src/bin/eolian_mono/eolian/mono/events.hh5
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_definition.hh75
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_pointer.hh8
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_registration.hh7
-rw-r--r--src/bin/eolian_mono/eolian/mono/klass.hh18
-rw-r--r--src/bin/eolian_mono/eolian/mono/marshall_annotation.hh128
-rw-r--r--src/bin/eolian_mono/eolian/mono/marshall_type.hh46
-rw-r--r--src/bin/eolian_mono/eolian/mono/marshall_type_impl.hh26
-rw-r--r--src/bin/eolian_mono/eolian/mono/name_helpers.hh18
-rw-r--r--src/bin/eolian_mono/eolian/mono/parameter.hh8
-rw-r--r--src/bin/eolian_mono/eolian/mono/part_definition.hh2
-rw-r--r--src/bin/eolian_mono/eolian/mono/struct_definition.hh44
12 files changed, 130 insertions, 255 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/events.hh b/src/bin/eolian_mono/eolian/mono/events.hh
index 20225b4f41..2a2aa4c9eb 100644
--- a/src/bin/eolian_mono/eolian/mono/events.hh
+++ b/src/bin/eolian_mono/eolian/mono/events.hh
@@ -301,12 +301,15 @@ struct event_definition_generator
301 bool generate_event_add_remove(OutputIterator sink, attributes::event_def const &evt, const std::string& event_name, Context context) const 301 bool generate_event_add_remove(OutputIterator sink, attributes::event_def const &evt, const std::string& event_name, Context context) const
302 { 302 {
303 std::string upper_c_name = utils::to_uppercase(evt.c_name); 303 std::string upper_c_name = utils::to_uppercase(evt.c_name);
304 auto unit = (const Eolian_Unit*) context_find_tag<eolian_state_context>(context).state;
305 attributes::klass_def klass(get_klass(evt.klass, unit), unit);
306 auto library_name = context_find_tag<library_context>(context).actual_library_name(klass.filename);
304 return as_generator( 307 return as_generator(
305 scope_tab << "{\n" 308 scope_tab << "{\n"
306 << scope_tab << scope_tab << "add {\n" 309 << scope_tab << scope_tab << "add {\n"
307 << scope_tab << scope_tab << scope_tab << "lock (eventLock) {\n" 310 << scope_tab << scope_tab << scope_tab << "lock (eventLock) {\n"
308 << scope_tab << scope_tab << scope_tab << scope_tab << "string key = \"_" << upper_c_name << "\";\n" 311 << scope_tab << scope_tab << scope_tab << scope_tab << "string key = \"_" << upper_c_name << "\";\n"
309 << scope_tab << scope_tab << scope_tab << scope_tab << "if (add_cpp_event_handler(key, this.evt_" << event_name << "_delegate)) {\n" 312 << scope_tab << scope_tab << scope_tab << scope_tab << "if (add_cpp_event_handler(" << library_name << ", key, this.evt_" << event_name << "_delegate)) {\n"
310 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "eventHandlers.AddHandler(" << event_name << "Key , value);\n" 313 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "eventHandlers.AddHandler(" << event_name << "Key , value);\n"
311 << scope_tab << scope_tab << scope_tab << scope_tab << "} else\n" 314 << scope_tab << scope_tab << scope_tab << scope_tab << "} else\n"
312 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Log.Error($\"Error adding proxy for event {key}\");\n" 315 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Log.Error($\"Error adding proxy for event {key}\");\n"
diff --git a/src/bin/eolian_mono/eolian/mono/function_definition.hh b/src/bin/eolian_mono/eolian/mono/function_definition.hh
index 9fef462002..67dfcc0ce4 100644
--- a/src/bin/eolian_mono/eolian/mono/function_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_definition.hh
@@ -32,41 +32,50 @@ struct native_function_definition_generator
32 bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const 32 bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const
33 { 33 {
34 EINA_CXX_DOM_LOG_DBG(eolian_mono::domain) << "native_function_definition_generator: " << f.c_name << std::endl; 34 EINA_CXX_DOM_LOG_DBG(eolian_mono::domain) << "native_function_definition_generator: " << f.c_name << std::endl;
35 if(blacklist::is_function_blacklisted(f, context) || f.is_static) // Only Concrete classes implement static methods. 35 if(blacklist::is_function_blacklisted(f, context))
36 return true; 36 return true;
37 else 37 else
38 { 38 {
39 if(!as_generator 39 if(!as_generator
40 ("\n\n" << scope_tab 40 ("\n\n" << scope_tab
41 << eolian_mono::marshall_native_annotation(true) 41 << eolian_mono::marshall_annotation(true)
42 << " private delegate " 42 << " private delegate "
43 << eolian_mono::marshall_type(true) 43 << eolian_mono::marshall_type(true)
44 << " " 44 << " "
45 << string 45 << string
46 << "_delegate(System.IntPtr obj, System.IntPtr pd" 46 << "_delegate(" << (f.is_static ? "" : "System.IntPtr obj, System.IntPtr pd")
47 << *grammar::attribute_reorder<-1, -1> 47 << ((!f.is_static && f.parameters.size() > 0) ? ", " : "")
48 << (grammar::attribute_reorder<-1, -1>
48 ( 49 (
49 (", " << marshall_native_annotation << " " << marshall_parameter) 50 (marshall_annotation << " " << marshall_parameter)
50 ) 51 ) % ", ")
51 << ");\n") 52 << ");\n")
52 .generate(sink, std::make_tuple(f.return_type, f.return_type, f.c_name, f.parameters), context)) 53 .generate(sink, std::make_tuple(f.return_type, f.return_type, f.c_name, f.parameters), context))
53 return false; 54 return false;
54 55
55 if(!as_generator 56 if(!as_generator
56 (scope_tab << "[System.Runtime.InteropServices.DllImport(" << context_find_tag<library_context>(context).actual_library_name(f.filename) << ")] " 57 ("\n\n" << scope_tab
57 << eolian_mono::marshall_native_annotation(true) 58 << eolian_mono::marshall_annotation(true)
58 << " private static extern " 59 << " public delegate "
59 << eolian_mono::marshall_type(true) 60 << eolian_mono::marshall_type(true)
60 << " " << string 61 << " "
61 << "(System.IntPtr obj" 62 << string << "_api_delegate(" << (f.is_static ? "" : "System.IntPtr obj")
62 << *grammar::attribute_reorder<-1, -1> 63 << ((!f.is_static && f.parameters.size() > 0) ? ", " : "")
64 << (grammar::attribute_reorder<-1, -1>
63 ( 65 (
64 (", " << marshall_native_annotation << " " << marshall_parameter) 66 (marshall_annotation << " " << marshall_parameter)
65 ) 67 ) % ", ")
66 << ");\n") 68 << ");\n")
67 .generate(sink, std::make_tuple(f.return_type, f.return_type, f.c_name, f.parameters), context)) 69 .generate(sink, std::make_tuple(f.return_type, f.return_type, f.c_name, f.parameters), context))
68 return false; 70 return false;
69 71
72 if(!as_generator
73 (scope_tab
74 << " public static Efl.Eo.FunctionWrapper<" << string << "_api_delegate> " << string << "_ptr = new Efl.Eo.FunctionWrapper<"
75 << string << "_api_delegate>(_Module, \"" << string << "\");\n")
76 .generate(sink, std::make_tuple(f.c_name, f.c_name, f.c_name, f.c_name), context))
77 return false;
78
70 std::string return_type; 79 std::string return_type;
71 if(!as_generator(eolian_mono::type(true)).generate(std::back_inserter(return_type), f.return_type, context)) 80 if(!as_generator(eolian_mono::type(true)).generate(std::back_inserter(return_type), f.return_type, context))
72 return false; 81 return false;
@@ -77,6 +86,11 @@ struct native_function_definition_generator
77 else 86 else
78 klass_cast_name = name_helpers::klass_interface_name(*klass); 87 klass_cast_name = name_helpers::klass_interface_name(*klass);
79 88
89 std::string self = "Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj))";
90
91 if (f.is_static)
92 self = "";
93
80 if(!as_generator 94 if(!as_generator
81 (scope_tab 95 (scope_tab
82 << " private static " 96 << " private static "
@@ -93,7 +107,8 @@ struct native_function_definition_generator
93 << scope_tab << scope_tab << "if(wrapper != null) {\n" 107 << scope_tab << scope_tab << "if(wrapper != null) {\n"
94 << scope_tab << scope_tab << scope_tab << eolian_mono::native_function_definition_preamble() 108 << scope_tab << scope_tab << scope_tab << eolian_mono::native_function_definition_preamble()
95 << scope_tab << scope_tab << scope_tab << "try {\n" 109 << scope_tab << scope_tab << scope_tab << "try {\n"
96 << scope_tab << scope_tab << scope_tab << scope_tab << (return_type != " void" ? "_ret_var = " : "") << "((" << klass_cast_name << ")wrapper)." << string 110 << scope_tab << scope_tab << scope_tab << scope_tab << (return_type != " void" ? "_ret_var = " : "")
111 << (f.is_static ? "" : "((") << klass_cast_name << (f.is_static ? "." : ")wrapper).") << string
97 << "(" << (native_argument_invocation % ", ") << ");\n" 112 << "(" << (native_argument_invocation % ", ") << ");\n"
98 << scope_tab << scope_tab << scope_tab << "} catch (Exception e) {\n" 113 << scope_tab << scope_tab << scope_tab << "} catch (Exception e) {\n"
99 << scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Log.Warning($\"Callback error: {e.ToString()}\");\n" 114 << scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Log.Warning($\"Callback error: {e.ToString()}\");\n"
@@ -102,7 +117,7 @@ struct native_function_definition_generator
102 << eolian_mono::native_function_definition_epilogue(*klass) 117 << eolian_mono::native_function_definition_epilogue(*klass)
103 << scope_tab << scope_tab << "} else {\n" 118 << scope_tab << scope_tab << "} else {\n"
104 << scope_tab << scope_tab << scope_tab << (return_type != " void" ? "return " : "") << string 119 << scope_tab << scope_tab << scope_tab << (return_type != " void" ? "return " : "") << string
105 << "(Efl.Eo.Globals.efl_super(obj, " << "Efl.Eo.Globals.efl_class_get(obj))" << *(", " << argument) << ");\n" 120 << "_ptr.Value.Delegate(" << self << ((!f.is_static && f.parameters.size() > 0) ? ", " : "") << (argument % ", ") << ");\n"
106 << scope_tab << scope_tab << "}\n" 121 << scope_tab << scope_tab << "}\n"
107 << scope_tab << "}\n" 122 << scope_tab << "}\n"
108 ) 123 )
@@ -118,9 +133,13 @@ struct native_function_definition_generator
118 , context)) 133 , context))
119 return false; 134 return false;
120 135
136 // Static functions do not need to be called from C
137 if (f.is_static)
138 return true;
139
121 // This is the delegate that will be passed to Eo to be called from C. 140 // This is the delegate that will be passed to Eo to be called from C.
122 if(!as_generator( 141 if(!as_generator(
123 scope_tab << "private " << f.c_name << "_delegate " << f.c_name << "_static_delegate;\n" 142 scope_tab << "private static " << f.c_name << "_delegate " << f.c_name << "_static_delegate;\n"
124 ).generate(sink, attributes::unused, context)) 143 ).generate(sink, attributes::unused, context))
125 return false; 144 return false;
126 return true; 145 return true;
@@ -141,22 +160,6 @@ struct function_definition_generator
141 if(blacklist::is_function_blacklisted(f, context)) 160 if(blacklist::is_function_blacklisted(f, context))
142 return true; 161 return true;
143 162
144 if(!as_generator
145 ("\n\n" << scope_tab << "[System.Runtime.InteropServices.DllImport(" << context_find_tag<library_context>(context).actual_library_name(f.filename) << ")]\n"
146 << scope_tab << eolian_mono::marshall_annotation(true)
147 << (do_super ? " protected " : " private ") << "static extern "
148 << eolian_mono::marshall_type(true)
149 << " " << string
150 << "(" << (f.is_static ? "" : "System.IntPtr obj")
151 << ((!f.is_static && (f.parameters.size() > 0)) ? ", " : "")
152 << (grammar::attribute_reorder<-1, -1>
153 (
154 (marshall_annotation << " " << marshall_parameter)
155 ) % ",")
156 << ");\n")
157 .generate(sink, std::make_tuple(f.return_type, f.return_type, f.c_name, f.parameters), context))
158 return false;
159
160 std::string return_type; 163 std::string return_type;
161 if(!as_generator(eolian_mono::type(true)).generate(std::back_inserter(return_type), f.return_type, context)) 164 if(!as_generator(eolian_mono::type(true)).generate(std::back_inserter(return_type), f.return_type, context))
162 return false; 165 return false;
@@ -176,8 +179,10 @@ struct function_definition_generator
176 if(!as_generator 179 if(!as_generator
177 (scope_tab << ((do_super && !f.is_static) ? "virtual " : "") << "public " << (f.is_static ? "static " : "") << return_type << " " << string << "(" << (parameter % ", ") 180 (scope_tab << ((do_super && !f.is_static) ? "virtual " : "") << "public " << (f.is_static ? "static " : "") << return_type << " " << string << "(" << (parameter % ", ")
178 << ") {\n " 181 << ") {\n "
179 << eolian_mono::function_definition_preamble() << string << "(" 182 << eolian_mono::function_definition_preamble()
180 << self << ((!f.is_static && (f.parameters.size() > 0)) ? "," : "") 183 << klass_full_native_inherit_name(f.klass) << "." << string << "_ptr.Value.Delegate("
184 << self
185 << ((!f.is_static && (f.parameters.size() > 0)) ? "," : "")
181 << (argument_invocation % ", ") << ");\n" 186 << (argument_invocation % ", ") << ");\n"
182 << eolian_mono::function_definition_epilogue() 187 << eolian_mono::function_definition_epilogue()
183 << " }\n") 188 << " }\n")
diff --git a/src/bin/eolian_mono/eolian/mono/function_pointer.hh b/src/bin/eolian_mono/eolian/mono/function_pointer.hh
index 2c62abeb12..a7e692bbad 100644
--- a/src/bin/eolian_mono/eolian/mono/function_pointer.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_pointer.hh
@@ -47,9 +47,9 @@ struct function_pointer {
47 .generate(sink, std::make_tuple(f, f.return_type, f_name, f.parameters), funcptr_ctx)) 47 .generate(sink, std::make_tuple(f, f.return_type, f_name, f.parameters), funcptr_ctx))
48 return false; 48 return false;
49 // "Internal" delegate, 1-to-1 with the Unamaged function type 49 // "Internal" delegate, 1-to-1 with the Unamaged function type
50 if (!as_generator(marshall_native_annotation(true) 50 if (!as_generator(marshall_annotation(true)
51 << "public delegate " << marshall_type(true) << " " << string // public? 51 << "public delegate " << marshall_type(true) << " " << string // public?
52 << "Internal(IntPtr data" << *grammar::attribute_reorder<-1, -1>((", " << marshall_native_annotation << " " << marshall_parameter)) << ");\n") 52 << "Internal(IntPtr data" << *grammar::attribute_reorder<-1, -1>((", " << marshall_annotation << " " << marshall_parameter)) << ");\n")
53 .generate(sink, std::make_tuple(f.return_type, f.return_type, f_name, f.parameters), funcptr_ctx)) 53 .generate(sink, std::make_tuple(f.return_type, f.return_type, f_name, f.parameters), funcptr_ctx))
54 return false; 54 return false;
55 55
@@ -80,8 +80,8 @@ struct function_pointer {
80 << scope_tab << "}\n\n" 80 << scope_tab << "}\n\n"
81 81
82 82
83 << scope_tab << marshall_native_annotation(true) 83 << scope_tab << marshall_annotation(true)
84 << scope_tab << "internal static " << marshall_type(true) << " Cb(IntPtr cb_data" << *grammar::attribute_reorder<-1, -1>((", " << marshall_native_annotation << " " << marshall_parameter)) << ")\n" 84 << scope_tab << "internal static " << marshall_type(true) << " Cb(IntPtr cb_data" << *grammar::attribute_reorder<-1, -1>((", " << marshall_annotation << " " << marshall_parameter)) << ")\n"
85 << scope_tab << "{\n" 85 << scope_tab << "{\n"
86 << scope_tab << scope_tab << "GCHandle handle = GCHandle.FromIntPtr(cb_data);\n" 86 << scope_tab << scope_tab << "GCHandle handle = GCHandle.FromIntPtr(cb_data);\n"
87 << scope_tab << scope_tab << string << " cb = (" << string << ")handle.Target;\n" 87 << scope_tab << scope_tab << string << " cb = (" << string << ")handle.Target;\n"
diff --git a/src/bin/eolian_mono/eolian/mono/function_registration.hh b/src/bin/eolian_mono/eolian/mono/function_registration.hh
index 90cbbc485d..cc7534b29a 100644
--- a/src/bin/eolian_mono/eolian/mono/function_registration.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_registration.hh
@@ -37,7 +37,8 @@ struct function_registration_generator
37 // auto index = index_generator(); 37 // auto index = index_generator();
38 38
39 if(!as_generator( 39 if(!as_generator(
40 scope_tab << scope_tab << f.c_name << "_static_delegate = new " << f.c_name << "_delegate(" << 40 scope_tab << scope_tab << "if (" << f.c_name << "_static_delegate == null)\n"
41 << scope_tab << scope_tab << f.c_name << "_static_delegate = new " << f.c_name << "_delegate(" <<
41 escape_keyword(f.name) << ");\n" 42 escape_keyword(f.name) << ");\n"
42 ).generate(sink, attributes::unused, context)) 43 ).generate(sink, attributes::unused, context))
43 return false; 44 return false;
@@ -47,9 +48,9 @@ struct function_registration_generator
47#ifdef _WIN32 48#ifdef _WIN32
48 << "api_func = Marshal.StringToHGlobalAnsi(\"" << string << "\")" 49 << "api_func = Marshal.StringToHGlobalAnsi(\"" << string << "\")"
49#else 50#else
50 << "api_func = Efl.Eo.Globals.dlsym(Efl.Eo.Globals.RTLD_DEFAULT, \"" << string << "\")" 51 << "api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(_Module.Module, \"" << string << "\")"
51#endif 52#endif
52 ", func = Marshal.GetFunctionPointerForDelegate(" << string << "_static_delegate)});\n" 53 << ", func = Marshal.GetFunctionPointerForDelegate(" << string << "_static_delegate)});\n"
53 ) 54 )
54 .generate(sink, std::make_tuple(f.c_name, f.c_name), context)) 55 .generate(sink, std::make_tuple(f.c_name, f.c_name), context))
55 return false; 56 return false;
diff --git a/src/bin/eolian_mono/eolian/mono/klass.hh b/src/bin/eolian_mono/eolian/mono/klass.hh
index e70729b6ae..993378fa21 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"
diff --git a/src/bin/eolian_mono/eolian/mono/marshall_annotation.hh b/src/bin/eolian_mono/eolian/mono/marshall_annotation.hh
index 744b4f8720..4159b6a952 100644
--- a/src/bin/eolian_mono/eolian/mono/marshall_annotation.hh
+++ b/src/bin/eolian_mono/eolian/mono/marshall_annotation.hh
@@ -90,7 +90,7 @@ struct marshall_annotation_visitor_generate
90 {"string", true, [&] { 90 {"string", true, [&] {
91 return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringPassOwnershipMarshaler))]"; 91 return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringPassOwnershipMarshaler))]";
92 }}, 92 }},
93 {"string", false, [&] { 93 {"string", nullptr, [&] {
94 return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))]"; 94 return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))]";
95 }}, 95 }},
96 {"mstring", true, [&] { 96 {"mstring", true, [&] {
@@ -112,10 +112,10 @@ struct marshall_annotation_visitor_generate
112 return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.ValueMarshaler))]"; 112 return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.ValueMarshaler))]";
113 }}, 113 }},
114 {"strbuf", true, [&] { 114 {"strbuf", true, [&] {
115 return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufPassOwnershipMarshaler))]"; 115 return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufPassOwnershipMarshaler))]";
116 }}, 116 }},
117 {"strbuf", false, [&] { 117 {"strbuf", false, [&] {
118 return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufKeepOwnershipMarshaler))]"; 118 return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufKeepOwnershipMarshaler))]";
119 }}, 119 }},
120 }; 120 };
121 121
@@ -169,128 +169,6 @@ struct marshall_annotation_visitor_generate
169 return true; 169 return true;
170 } 170 }
171}; 171};
172
173template <typename OutputIterator, typename Context>
174struct marshall_native_annotation_visitor_generate
175{
176 mutable OutputIterator sink;
177 Context const* context;
178 std::string c_type;
179 bool is_out;
180 bool is_return;
181 bool is_ptr;
182
183 typedef marshall_type_visitor_generate<OutputIterator, Context> visitor_type;
184 typedef bool result_type;
185
186 bool operator()(attributes::regular_type_def const& regular) const
187 {
188 using attributes::regular_type_def;
189 struct match
190 {
191 eina::optional<std::string> name;
192 eina::optional<bool> has_own;
193 std::function<std::string()> function;
194 };
195 match const parameter_match_table[] =
196 {
197 // signed primitives
198 {"bool", nullptr, [&] { return " [MarshalAs(UnmanagedType.U1)]"; }},
199 {"string", true, [&] {
200 return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringPassOwnershipMarshaler))]";
201 }},
202 {"string", false, [&] {
203 if (is_out)
204 return "";
205 return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))]";
206 }},
207 {"stringshare", true, [&] {
208 return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringsharePassOwnershipMarshaler))]";
209 }},
210 {"stringshare", false, [&] {
211 if (is_out)
212 return "";
213 return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringshareKeepOwnershipMarshaler))]";
214 }},
215 {"strbuf", true, [&] {
216 return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufPassOwnershipMarshaler))]";
217 }},
218 {"strbuf", false, [&] {
219 return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufKeepOwnershipMarshaler))]";
220 }},
221 };
222 match const return_match_table[] =
223 {
224 // signed primitives
225 {"bool", nullptr, [&] { return " [return: MarshalAs(UnmanagedType.U1)]"; }},
226 {"string", true, [&] {
227 return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringPassOwnershipMarshaler))]";
228 }},
229 {"string", false, [&] { return ""; }},
230 {"stringshare", true, [&] {
231 return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringsharePassOwnershipMarshaler))]";
232 }},
233 {"stringshare", false, [&] { return ""; }},
234 {"strbuf", true, [&] {
235 return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufPassOwnershipMarshaler))]";
236 }},
237 {"strbuf", false, [&] {
238 return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufKeepOwnershipMarshaler))]";
239 }},
240 };
241
242 if(eina::optional<bool> b = call_annotation_match
243 ((is_return ? return_match_table : parameter_match_table)
244 , [&] (match const& m)
245 {
246 return (!m.name || *m.name == regular.base_type)
247 && (!m.has_own || *m.has_own == (bool)(regular.base_qualifier & qualifier_info::is_own))
248 ;
249 }
250 , [&] (std::string const& string)
251 {
252 std::copy(string.begin(), string.end(), sink);
253 return true;
254 }))
255 {
256 return *b;
257 }
258 else
259 {
260 return true;
261 }
262 }
263 bool operator()(attributes::klass_name const& klass_name) const
264 {
265 const char *return_prefix = is_return ? "return:" : "";
266 const char *marshal_prefix = "MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(";
267
268 std::string name = name_helpers::klass_full_concrete_name(klass_name);
269
270 if (name == "Efl.Class")
271 name = "Efl.Eo.MarshalEflClass";
272 else
273 {
274 auto own = klass_name.base_qualifier & qualifier_info::is_own ? "OwnTag" : "NonOwnTag";
275 name = "Efl.Eo.MarshalTest<" + name + ", Efl.Eo." + own + ">";
276 }
277
278 return as_generator(
279 lit("[") << return_prefix << marshal_prefix << name << "))]"
280 ).generate(sink, name, *context);
281 }
282 bool operator()(attributes::complex_type_def const& c) const
283 {
284 if (c.outer.base_type == "future")
285 {
286 std::string prefix = is_return ? "return: " : "";
287 return as_generator("[" << prefix << "MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.FutureMarshaler))]").generate(sink, nullptr, *context);
288 }
289 return true;
290 }
291};
292
293
294} } 172} }
295 173
296#endif 174#endif
diff --git a/src/bin/eolian_mono/eolian/mono/marshall_type.hh b/src/bin/eolian_mono/eolian/mono/marshall_type.hh
index add954ade2..5c350adebe 100644
--- a/src/bin/eolian_mono/eolian/mono/marshall_type.hh
+++ b/src/bin/eolian_mono/eolian/mono/marshall_type.hh
@@ -13,8 +13,6 @@ template <typename OutputIterator, typename Context>
13struct marshall_type_visitor_generate; 13struct marshall_type_visitor_generate;
14template <typename OutputIterator, typename Context> 14template <typename OutputIterator, typename Context>
15struct marshall_annotation_visitor_generate; 15struct marshall_annotation_visitor_generate;
16template <typename OutputIterator, typename Context>
17struct marshall_native_annotation_visitor_generate;
18} 16}
19 17
20/* 18/*
@@ -73,26 +71,6 @@ struct marshall_annotation_generator
73 bool is_return; 71 bool is_return;
74}; 72};
75 73
76struct marshall_native_annotation_generator
77{
78 marshall_native_annotation_generator(bool is_return = false)
79 : is_return(is_return) {}
80
81 template <typename OutputIterator, typename Context>
82 bool generate(OutputIterator sink, attributes::type_def const& type, Context const& context) const
83 {
84 return type.original_type.visit(detail::marshall_native_annotation_visitor_generate<OutputIterator, Context>{sink, &context, type.c_type, false, is_return, type.is_ptr});
85 }
86 template <typename OutputIterator, typename Context>
87 bool generate(OutputIterator sink, attributes::parameter_def const& param, Context const& context) const
88 {
89 return param.type.original_type.visit(detail::marshall_native_annotation_visitor_generate<OutputIterator, Context>{sink, &context, param.type.c_type
90 , param.direction != attributes::parameter_direction::in, false, param.type.is_ptr});
91 }
92
93 bool is_return;
94};
95
96struct marshall_type_terminal 74struct marshall_type_terminal
97{ 75{
98 marshall_type_generator const operator()(bool is_return) const 76 marshall_type_generator const operator()(bool is_return) const
@@ -120,19 +98,6 @@ marshall_annotation_generator const as_generator(marshall_annotation_terminal)
120} 98}
121 99
122 100
123struct marshall_native_annotation_terminal
124{
125 marshall_native_annotation_generator const operator()(bool is_return) const
126 {
127 return marshall_native_annotation_generator(is_return);
128 }
129} const marshall_native_annotation = {};
130
131marshall_native_annotation_generator const as_generator(marshall_native_annotation_terminal)
132{
133 return marshall_native_annotation_generator{};
134}
135
136} 101}
137 102
138namespace efl { namespace eolian { namespace grammar { 103namespace efl { namespace eolian { namespace grammar {
@@ -158,23 +123,12 @@ struct is_generator< ::eolian_mono::marshall_annotation_generator> : std::true_t
158template <> 123template <>
159struct is_generator< ::eolian_mono::marshall_annotation_terminal> : std::true_type {}; 124struct is_generator< ::eolian_mono::marshall_annotation_terminal> : std::true_type {};
160 125
161template <>
162struct is_eager_generator< ::eolian_mono::marshall_native_annotation_generator> : std::true_type {};
163template <>
164struct is_generator< ::eolian_mono::marshall_native_annotation_generator> : std::true_type {};
165template <>
166struct is_generator< ::eolian_mono::marshall_native_annotation_terminal> : std::true_type {};
167
168namespace type_traits { 126namespace type_traits {
169template <> 127template <>
170struct attributes_needed< ::eolian_mono::marshall_annotation_generator> : std::integral_constant<int, 1> {}; 128struct attributes_needed< ::eolian_mono::marshall_annotation_generator> : std::integral_constant<int, 1> {};
171template <> 129template <>
172struct attributes_needed< ::eolian_mono::marshall_annotation_terminal> : std::integral_constant<int, 1> {}; 130struct attributes_needed< ::eolian_mono::marshall_annotation_terminal> : std::integral_constant<int, 1> {};
173 131
174template <>
175struct attributes_needed< ::eolian_mono::marshall_native_annotation_generator> : std::integral_constant<int, 1> {};
176template <>
177struct attributes_needed< ::eolian_mono::marshall_native_annotation_terminal> : std::integral_constant<int, 1> {};
178} 132}
179 133
180} } } 134} } }
diff --git a/src/bin/eolian_mono/eolian/mono/marshall_type_impl.hh b/src/bin/eolian_mono/eolian/mono/marshall_type_impl.hh
index 3bd8791e89..998ca0bdb3 100644
--- a/src/bin/eolian_mono/eolian/mono/marshall_type_impl.hh
+++ b/src/bin/eolian_mono/eolian/mono/marshall_type_impl.hh
@@ -32,7 +32,6 @@ struct marshall_type_visitor_generate
32 bool operator()(attributes::regular_type_def const& regular) const 32 bool operator()(attributes::regular_type_def const& regular) const
33 { 33 {
34 using attributes::regular_type_def; 34 using attributes::regular_type_def;
35 bool is_inherit_native = context_find_tag<class_context>(*context).current_wrapper_kind == class_context::inherit_native;
36 35
37 struct match 36 struct match
38 { 37 {
@@ -47,32 +46,24 @@ struct marshall_type_visitor_generate
47 { 46 {
48 regular_type_def r = regular; 47 regular_type_def r = regular;
49 r.base_qualifier.qualifier ^= qualifier_info::is_ref; 48 r.base_qualifier.qualifier ^= qualifier_info::is_ref;
50 // if(is_out || is_return)
51 return replace_base_type(r, " System.String"); 49 return replace_base_type(r, " System.String");
52 // else return replace_base_type(r, " ::efl::eina::string_view");
53 }} 50 }}
54 , {"string", false, [&] 51 , {"string", false, [&]
55 { 52 {
56 regular_type_def r = regular; 53 regular_type_def r = regular;
57 r.base_qualifier.qualifier ^= qualifier_info::is_ref; 54 r.base_qualifier.qualifier ^= qualifier_info::is_ref;
58 if (is_inherit_native && (is_return || is_out))
59 return replace_base_type(r, " System.IntPtr");
60 return replace_base_type(r, " System.String"); 55 return replace_base_type(r, " System.String");
61 }} 56 }}
62 , {"mstring", true, [&] 57 , {"mstring", true, [&]
63 { 58 {
64 regular_type_def r = regular; 59 regular_type_def r = regular;
65 r.base_qualifier.qualifier ^= qualifier_info::is_ref; 60 r.base_qualifier.qualifier ^= qualifier_info::is_ref;
66 // if(is_out || is_return)
67 return replace_base_type(r, " System.String"); 61 return replace_base_type(r, " System.String");
68 // else return replace_base_type(r, " ::efl::eina::string_view");
69 }} 62 }}
70 , {"mstring", false, [&] 63 , {"mstring", false, [&]
71 { 64 {
72 regular_type_def r = regular; 65 regular_type_def r = regular;
73 r.base_qualifier.qualifier ^= qualifier_info::is_ref; 66 r.base_qualifier.qualifier ^= qualifier_info::is_ref;
74 if (is_inherit_native && (is_return || is_out))
75 return replace_base_type(r, " System.IntPtr");
76 return replace_base_type(r, " System.String"); 67 return replace_base_type(r, " System.String");
77 }} 68 }}
78 , {"stringshare", true, [&] 69 , {"stringshare", true, [&]
@@ -85,10 +76,7 @@ struct marshall_type_visitor_generate
85 { 76 {
86 regular_type_def r = regular; 77 regular_type_def r = regular;
87 r.base_qualifier.qualifier ^= qualifier_info::is_ref; 78 r.base_qualifier.qualifier ^= qualifier_info::is_ref;
88 if (is_inherit_native && (is_return || is_out)) 79 return replace_base_type(r, " System.String");
89 return replace_base_type(r, " System.IntPtr");
90 else
91 return replace_base_type(r, " System.String");
92 }} 80 }}
93 , {"strbuf", nullptr, [&] 81 , {"strbuf", nullptr, [&]
94 { 82 {
@@ -193,7 +181,6 @@ struct marshall_type_visitor_generate
193 bool operator()(attributes::klass_name klass_name) const 181 bool operator()(attributes::klass_name klass_name) const
194 { 182 {
195 return visitor_generate<OutputIterator, Context>{sink, context, c_type, is_out, is_return, is_ptr}(klass_name); 183 return visitor_generate<OutputIterator, Context>{sink, context, c_type, is_out, is_return, is_ptr}(klass_name);
196 // return as_generator(" System.IntPtr").generate(sink, attributes::unused, *context);
197 } 184 }
198 bool operator()(attributes::complex_type_def const& complex) const 185 bool operator()(attributes::complex_type_def const& complex) const
199 { 186 {
@@ -237,14 +224,8 @@ struct marshall_type_visitor_generate
237 auto default_match = [&] (attributes::complex_type_def const& complex) 224 auto default_match = [&] (attributes::complex_type_def const& complex)
238 { 225 {
239 regular_type_def no_pointer_regular = complex.outer; 226 regular_type_def no_pointer_regular = complex.outer;
240 // std::vector<attributes::pointer_indirection> pointers;
241 // pointers.swap(no_pointer_regular.pointers);
242 // if(is_out)
243 // pointers.push_back({{attributes::qualifier_info::is_none, {}}, true});
244 return visitor_type{sink, context, c_type, false}(no_pointer_regular) 227 return visitor_type{sink, context, c_type, false}(no_pointer_regular)
245 && as_generator("<" << (type % ", ") << ">").generate(sink, complex.subtypes, *context) 228 && as_generator("<" << (type % ", ") << ">").generate(sink, complex.subtypes, *context);
246 ;
247 // && detail::generate_pointers(sink, pointers, *context, false);
248 }; 229 };
249 230
250 if(eina::optional<bool> b = call_match 231 if(eina::optional<bool> b = call_match
@@ -269,12 +250,9 @@ struct marshall_type_visitor_generate
269 return *b; 250 return *b;
270 } 251 }
271 252
272 //return default_match(complex);
273 return visitor_generate<OutputIterator, Context>{sink, context, c_type, is_out, is_return, is_ptr}(complex); 253 return visitor_generate<OutputIterator, Context>{sink, context, c_type, is_out, is_return, is_ptr}(complex);
274 // return as_generator(" System.IntPtr").generate(sink, attributes::unused, *context);
275 } 254 }
276}; 255};
277
278} } 256} }
279 257
280#endif 258#endif
diff --git a/src/bin/eolian_mono/eolian/mono/name_helpers.hh b/src/bin/eolian_mono/eolian/mono/name_helpers.hh
index ccbbfce3b4..5fc1f18d22 100644
--- a/src/bin/eolian_mono/eolian/mono/name_helpers.hh
+++ b/src/bin/eolian_mono/eolian/mono/name_helpers.hh
@@ -364,13 +364,27 @@ inline std::string klass_inherit_name(T const& klass)
364template<typename T> 364template<typename T>
365inline std::string klass_native_inherit_name(T const& klass) 365inline std::string klass_native_inherit_name(T const& klass)
366{ 366{
367 return klass_concrete_name(klass) + "NativeInherit"; 367 switch(klass.type)
368 {
369 case attributes::class_type::abstract_:
370 case attributes::class_type::regular:
371 return klass_concrete_name(klass) + "NativeInherit";
372 default:
373 return klass_interface_name(klass) + "NativeInherit";
374 }
368} 375}
369 376
370template<typename T> 377template<typename T>
371inline std::string klass_full_native_inherit_name(T const& klass) 378inline std::string klass_full_native_inherit_name(T const& klass)
372{ 379{
373 return klass_full_concrete_name(klass) + "NativeInherit"; 380 switch(klass.type)
381 {
382 case attributes::class_type::abstract_:
383 case attributes::class_type::regular:
384 return klass_full_concrete_name(klass) + "NativeInherit";
385 default:
386 return klass_full_interface_name(klass) + "NativeInherit";
387 }
374} 388}
375 389
376template<typename T> 390template<typename T>
diff --git a/src/bin/eolian_mono/eolian/mono/parameter.hh b/src/bin/eolian_mono/eolian/mono/parameter.hh
index ab4362519b..1314c125cb 100644
--- a/src/bin/eolian_mono/eolian/mono/parameter.hh
+++ b/src/bin/eolian_mono/eolian/mono/parameter.hh
@@ -1112,7 +1112,7 @@ struct native_convert_out_assign_generator
1112 return false; 1112 return false;
1113 } 1113 }
1114 return as_generator( 1114 return as_generator(
1115 string << "= Efl.Eo.Globals.cached_stringshare_to_intptr(((" << name_helpers::klass_inherit_name(*klass) << ")wrapper).cached_stringshares, " << string << ");\n" 1115 string << "= " << string << ";\n"
1116 ).generate(sink, std::make_tuple(escape_keyword(param.param_name), out_variable_name(param.param_name)), context); 1116 ).generate(sink, std::make_tuple(escape_keyword(param.param_name), out_variable_name(param.param_name)), context);
1117 } 1117 }
1118 else if (param_is_acceptable(param, "const char *", !WANT_OWN, WANT_OUT)) 1118 else if (param_is_acceptable(param, "const char *", !WANT_OWN, WANT_OUT))
@@ -1123,7 +1123,7 @@ struct native_convert_out_assign_generator
1123 return false; 1123 return false;
1124 } 1124 }
1125 return as_generator( 1125 return as_generator(
1126 string << "= Efl.Eo.Globals.cached_string_to_intptr(((" << name_helpers::klass_inherit_name(*klass) << ")wrapper).cached_strings, " << string << ");\n" 1126 string << " = " << string << ";\n"
1127 ).generate(sink, std::make_tuple(escape_keyword(param.param_name), out_variable_name(param.param_name)), context); 1127 ).generate(sink, std::make_tuple(escape_keyword(param.param_name), out_variable_name(param.param_name)), context);
1128 } 1128 }
1129 else if (param_is_acceptable(param, "Eina_Binbuf *", WANT_OWN, WANT_OUT) 1129 else if (param_is_acceptable(param, "Eina_Binbuf *", WANT_OWN, WANT_OUT)
@@ -1253,7 +1253,7 @@ struct native_convert_return_generator
1253 return false; 1253 return false;
1254 } 1254 }
1255 return as_generator( 1255 return as_generator(
1256 "return Efl.Eo.Globals.cached_string_to_intptr(((" << name_helpers::klass_inherit_name(*klass) << ")wrapper).cached_strings, _ret_var);\n" 1256 "return _ret_var;\n"
1257 ).generate(sink, attributes::unused, context); 1257 ).generate(sink, attributes::unused, context);
1258 } 1258 }
1259 else 1259 else
@@ -1271,7 +1271,7 @@ struct native_convert_return_generator
1271 return false; 1271 return false;
1272 } 1272 }
1273 return as_generator( 1273 return as_generator(
1274 "return Efl.Eo.Globals.cached_stringshare_to_intptr(((" << name_helpers::klass_inherit_name(*klass) << ")wrapper).cached_stringshares, _ret_var);\n" 1274 "return _ret_var;\n"
1275 ).generate(sink, attributes::unused, context); 1275 ).generate(sink, attributes::unused, context);
1276 } 1276 }
1277 else 1277 else
diff --git a/src/bin/eolian_mono/eolian/mono/part_definition.hh b/src/bin/eolian_mono/eolian/mono/part_definition.hh
index bd12ee2a40..47951f4bf1 100644
--- a/src/bin/eolian_mono/eolian/mono/part_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/part_definition.hh
@@ -24,7 +24,7 @@ struct part_definition_generator
24 << scope_tab << "{\n" 24 << scope_tab << "{\n"
25 << scope_tab << scope_tab << "get\n" 25 << scope_tab << scope_tab << "get\n"
26 << scope_tab << scope_tab << "{\n" 26 << scope_tab << scope_tab << "{\n"
27 << scope_tab << scope_tab << scope_tab << "Efl.Object obj = efl_part_get(NativeHandle, \"" << part.name << "\");\n" 27 << scope_tab << scope_tab << scope_tab << "Efl.Object obj = Efl.PartNativeInherit.efl_part_get_ptr.Value.Delegate(NativeHandle, \"" << part.name << "\");\n"
28 << scope_tab << scope_tab << scope_tab << "return " << part_klass_name << ".static_cast(obj);\n" 28 << scope_tab << scope_tab << scope_tab << "return " << part_klass_name << ".static_cast(obj);\n"
29 << scope_tab << scope_tab << "}\n" 29 << scope_tab << scope_tab << "}\n"
30 << scope_tab << "}\n" 30 << scope_tab << "}\n"
diff --git a/src/bin/eolian_mono/eolian/mono/struct_definition.hh b/src/bin/eolian_mono/eolian/mono/struct_definition.hh
index 7802b4518c..17485d12e4 100644
--- a/src/bin/eolian_mono/eolian/mono/struct_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/struct_definition.hh
@@ -131,6 +131,22 @@ struct struct_internal_definition_generator
131 .generate(sink, nullptr, context)) 131 .generate(sink, nullptr, context))
132 return false; 132 return false;
133 } 133 }
134 else if (regular && !(regular->base_qualifier & efl::eolian::grammar::attributes::qualifier_info::is_ref)
135 && regular->base_type == "bool")
136 {
137 if (!as_generator("///<summary>Internal wrapper for field " << field_name << "</summary>\n"
138 "public System.Byte " << field_name << ";\n")
139 .generate(sink, nullptr, context))
140 return false;
141 }
142 else if (regular && !(regular->base_qualifier & efl::eolian::grammar::attributes::qualifier_info::is_ref)
143 && regular->base_type == "char")
144 {
145 if (!as_generator("///<summary>Internal wrapper for field " << field_name << "</summary>\n"
146 "public System.Byte " << field_name << ";\n")
147 .generate(sink, nullptr, context))
148 return false;
149 }
134 else if (!as_generator(scope_tab << eolian_mono::marshall_annotation(false) << "\n" 150 else if (!as_generator(scope_tab << eolian_mono::marshall_annotation(false) << "\n"
135 << scope_tab << "public " << eolian_mono::marshall_type(false) << " " << string << ";\n") 151 << scope_tab << "public " << eolian_mono::marshall_type(false) << " " << string << ";\n")
136 .generate(sink, std::make_tuple(field.type, field.type, field_name), context)) 152 .generate(sink, std::make_tuple(field.type, field.type, field_name), context))
@@ -255,6 +271,20 @@ struct to_internal_field_convert_generator
255 ).generate(sink, std::make_tuple(field_name, field_name), context)) 271 ).generate(sink, std::make_tuple(field_name, field_name), context))
256 return false; 272 return false;
257 } 273 }
274 else if (!field.type.is_ptr && regular && regular->base_type == "bool")
275 {
276 if (!as_generator(
277 scope_tab << scope_tab << "_internal_struct." << string << " = _external_struct." << string << " ? (byte)1 : (byte)0;\n")
278 .generate(sink, std::make_tuple(field_name, field_name), context))
279 return false;
280 }
281 else if (!field.type.is_ptr && regular && regular->base_type == "char")
282 {
283 if (!as_generator(
284 scope_tab << scope_tab << "_internal_struct." << string << " = (byte)_external_struct." << string << ";\n")
285 .generate(sink, std::make_tuple(field_name, field_name), context))
286 return false;
287 }
258 else // primitives and enums 288 else // primitives and enums
259 { 289 {
260 if (!as_generator( 290 if (!as_generator(
@@ -358,6 +388,20 @@ struct to_external_field_convert_generator
358 ).generate(sink, std::make_tuple(field_name, field_name), context)) 388 ).generate(sink, std::make_tuple(field_name, field_name), context))
359 return false; 389 return false;
360 } 390 }
391 else if (!field.type.is_ptr && regular && regular->base_type == "bool")
392 {
393 if (!as_generator(
394 scope_tab << scope_tab << "_external_struct." << string << " = _internal_struct." << string << " != 0;\n"
395 ).generate(sink, std::make_tuple(field_name, field_name), context))
396 return false;
397 }
398 else if (!field.type.is_ptr && regular && regular->base_type == "char")
399 {
400 if (!as_generator(
401 scope_tab << scope_tab << "_external_struct." << string << " = (char)_internal_struct." << string << ";\n"
402 ).generate(sink, std::make_tuple(field_name, field_name), context))
403 return false;
404 }
361 else // primitives and enums 405 else // primitives and enums
362 { 406 {
363 if (!as_generator( 407 if (!as_generator(