summaryrefslogtreecommitdiff
path: root/src/bin/eolian_mono
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@gmail.com>2018-09-26 12:01:49 -0300
committerVitor Sousa <vitorsousa@expertisesolutions.com.br>2018-09-26 12:16:09 -0300
commit8a4bac15e7a0a0a9f0901eee1dc7b23fc990d18e (patch)
treec3279b2bb75f020e0282b289674aaf89db040bef /src/bin/eolian_mono
parent064ae4f3a69108f28519beb12b5bb0786642b301 (diff)
efl-csharp: Fix event struct marshalling.
Summary: The efl.Event struct has a class field that gets generated normally but can be problematic when marshalling the struct back from C to C#. The compilation works fine but when C# runtime tries to marshall the C data (e.g. accessing the Event.Info field), it becomes erratic, either complaining about missing references to object or even segfault. This commit changes the event handling code to use the "Event_StructInternal" struct as is already done when receiving structs from C code. In order to work with other assemblies, the _StructInternal fields were made publit too. Fixes the events tests and the text editor app. Test Plan: make check and run the text editor app in examples repo. Reviewers: segfaultxavi, vitor.sousa Reviewed By: vitor.sousa Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D7106
Diffstat (limited to 'src/bin/eolian_mono')
-rw-r--r--src/bin/eolian_mono/eolian/mono/events.hh2
-rw-r--r--src/bin/eolian_mono/eolian/mono/struct_definition.hh12
2 files changed, 8 insertions, 6 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/events.hh b/src/bin/eolian_mono/eolian/mono/events.hh
index 2da287b..a5fe8ec 100644
--- a/src/bin/eolian_mono/eolian/mono/events.hh
+++ b/src/bin/eolian_mono/eolian/mono/events.hh
@@ -211,7 +211,7 @@ struct event_definition_generator
211 << scope_tab << scope_tab << "}\n" 211 << scope_tab << scope_tab << "}\n"
212 << scope_tab << scope_tab << "if (evt != null) { evt(this, e); }\n" 212 << scope_tab << scope_tab << "if (evt != null) { evt(this, e); }\n"
213 << scope_tab << "}\n" 213 << scope_tab << "}\n"
214 << scope_tab << "private void on_" << wrapper_evt_name << "_NativeCallback(System.IntPtr data, ref efl.Event evt)\n" 214 << scope_tab << "private void on_" << wrapper_evt_name << "_NativeCallback(System.IntPtr data, ref efl.Event_StructInternal evt)\n"
215 << scope_tab << "{\n" 215 << scope_tab << "{\n"
216 << scope_tab << scope_tab << event_args 216 << scope_tab << scope_tab << event_args
217 << scope_tab << scope_tab << "try {\n" 217 << scope_tab << scope_tab << "try {\n"
diff --git a/src/bin/eolian_mono/eolian/mono/struct_definition.hh b/src/bin/eolian_mono/eolian/mono/struct_definition.hh
index 42d2f0d..58007a2 100644
--- a/src/bin/eolian_mono/eolian/mono/struct_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/struct_definition.hh
@@ -115,11 +115,12 @@ struct struct_internal_definition_generator
115 || regular->base_type == "stringshare" 115 || regular->base_type == "stringshare"
116 || regular->base_type == "any_value_ptr"))) 116 || regular->base_type == "any_value_ptr")))
117 { 117 {
118 if (!as_generator(" internal System.IntPtr " << string << ";\n") 118 if (!as_generator("///<summary>Internal wrapper for field " << field_name << "</summary>\n"
119 .generate(sink, field_name, context)) 119 << "public System.IntPtr " << field_name << ";\n")
120 .generate(sink, nullptr, context))
120 return false; 121 return false;
121 } 122 }
122 else if (!as_generator(eolian_mono::marshall_annotation(false) << " internal " << eolian_mono::marshall_type(false) << " " << string << ";\n") 123 else if (!as_generator(eolian_mono::marshall_annotation(false) << " public " << eolian_mono::marshall_type(false) << " " << string << ";\n")
123 .generate(sink, std::make_tuple(field.type, field.type, field_name), context)) 124 .generate(sink, std::make_tuple(field.type, field.type, field_name), context))
124 return false; 125 return false;
125 } 126 }
@@ -368,9 +369,10 @@ struct struct_binding_conversion_functions_generator
368 // Open conversion class 369 // Open conversion class
369 if (!as_generator 370 if (!as_generator
370 ( 371 (
371 "public static class " << string << "_StructConversion\n{\n" 372 "/// <summary>Conversion class for struct " << struct_.cxx_name << "</summary>\n"
373 "public static class " << struct_.cxx_name << "_StructConversion\n{\n"
372 ) 374 )
373 .generate(sink, struct_.cxx_name, context)) 375 .generate(sink, nullptr, context))
374 return false; 376 return false;
375 377
376 // to internal 378 // to internal