summaryrefslogtreecommitdiff
path: root/src/bin/eolian_mono/eolian/mono/struct_definition.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/struct_definition.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/struct_definition.hh')
-rw-r--r--src/bin/eolian_mono/eolian/mono/struct_definition.hh44
1 files changed, 44 insertions, 0 deletions
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(