aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2019-01-27 20:58:51 +0900
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2019-01-31 16:16:16 +0900
commit63d01fcf1481aef784b29950f4fd7b0d782ac9ff (patch)
treee309cb2996c1d544e56a3000b7f0d3ba82c3bbec
parentefl-mono: Pass module name to event symbol loading (diff)
downloadefl-63d01fcf1481aef784b29950f4fd7b0d782ac9ff.tar.gz
efl-mono: Create workaround for DotNet Core inability to Marshal bool and char in structs
Create workaround for bool and chars in Structs for C# marshaling. Going through System.Byte instead and Marshaling manually to their respective types.
-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 0eda387668..70a6537bf1 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
.generate(sink, nullptr, context))
return false;
}
+ else if (regular && !(regular->base_qualifier & efl::eolian::grammar::attributes::qualifier_info::is_ref)
+ && regular->base_type == "bool")
+ {
+ if (!as_generator("///<summary>Internal wrapper for field " << field_name << "</summary>\n"
+ "public System.Byte " << field_name << ";\n")
+ .generate(sink, nullptr, context))
+ return false;
+ }
+ else if (regular && !(regular->base_qualifier & efl::eolian::grammar::attributes::qualifier_info::is_ref)
+ && regular->base_type == "char")
+ {
+ if (!as_generator("///<summary>Internal wrapper for field " << field_name << "</summary>\n"
+ "public System.Byte " << field_name << ";\n")
+ .generate(sink, nullptr, context))
+ return false;
+ }
else if (!as_generator(scope_tab << eolian_mono::marshall_annotation(false) << "\n"
<< scope_tab << "public " << eolian_mono::marshall_type(false) << " " << string << ";\n")
.generate(sink, std::make_tuple(field.type, field.type, field_name), context))
@@ -257,6 +273,20 @@ struct to_internal_field_convert_generator
).generate(sink, std::make_tuple(field_name, field_name), context))
return false;
}
+ else if (!field.type.is_ptr && regular && regular->base_type == "bool")
+ {
+ if (!as_generator(
+ scope_tab << scope_tab << "_internal_struct." << string << " = _external_struct." << string << " ? (byte)1 : (byte)0;\n")
+ .generate(sink, std::make_tuple(field_name, field_name), context))
+ return false;
+ }
+ else if (!field.type.is_ptr && regular && regular->base_type == "char")
+ {
+ if (!as_generator(
+ scope_tab << scope_tab << "_internal_struct." << string << " = (byte)_external_struct." << string << ";\n")
+ .generate(sink, std::make_tuple(field_name, field_name), context))
+ return false;
+ }
else // primitives and enums
{
if (!as_generator(
@@ -362,6 +392,20 @@ struct to_external_field_convert_generator
).generate(sink, std::make_tuple(field_name, field_name), context))
return false;
}
+ else if (!field.type.is_ptr && regular && regular->base_type == "bool")
+ {
+ if (!as_generator(
+ scope_tab << scope_tab << "_external_struct." << string << " = _internal_struct." << string << " != 0;\n"
+ ).generate(sink, std::make_tuple(field_name, field_name), context))
+ return false;
+ }
+ else if (!field.type.is_ptr && regular && regular->base_type == "char")
+ {
+ if (!as_generator(
+ scope_tab << scope_tab << "_external_struct." << string << " = (char)_internal_struct." << string << ";\n"
+ ).generate(sink, std::make_tuple(field_name, field_name), context))
+ return false;
+ }
else // primitives and enums
{
if (!as_generator(