forked from enlightenment/efl
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
This commit is contained in:
parent
064ae4f3a6
commit
8a4bac15e7
|
@ -211,7 +211,7 @@ struct event_definition_generator
|
||||||
<< scope_tab << scope_tab << "}\n"
|
<< scope_tab << scope_tab << "}\n"
|
||||||
<< scope_tab << scope_tab << "if (evt != null) { evt(this, e); }\n"
|
<< scope_tab << scope_tab << "if (evt != null) { evt(this, e); }\n"
|
||||||
<< scope_tab << "}\n"
|
<< scope_tab << "}\n"
|
||||||
<< scope_tab << "private void on_" << wrapper_evt_name << "_NativeCallback(System.IntPtr data, ref efl.Event evt)\n"
|
<< scope_tab << "private void on_" << wrapper_evt_name << "_NativeCallback(System.IntPtr data, ref efl.Event_StructInternal evt)\n"
|
||||||
<< scope_tab << "{\n"
|
<< scope_tab << "{\n"
|
||||||
<< scope_tab << scope_tab << event_args
|
<< scope_tab << scope_tab << event_args
|
||||||
<< scope_tab << scope_tab << "try {\n"
|
<< scope_tab << scope_tab << "try {\n"
|
||||||
|
|
|
@ -115,11 +115,12 @@ struct struct_internal_definition_generator
|
||||||
|| regular->base_type == "stringshare"
|
|| regular->base_type == "stringshare"
|
||||||
|| regular->base_type == "any_value_ptr")))
|
|| regular->base_type == "any_value_ptr")))
|
||||||
{
|
{
|
||||||
if (!as_generator(" internal System.IntPtr " << string << ";\n")
|
if (!as_generator("///<summary>Internal wrapper for field " << field_name << "</summary>\n"
|
||||||
.generate(sink, field_name, context))
|
<< "public System.IntPtr " << field_name << ";\n")
|
||||||
|
.generate(sink, nullptr, context))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (!as_generator(eolian_mono::marshall_annotation(false) << " internal " << eolian_mono::marshall_type(false) << " " << string << ";\n")
|
else if (!as_generator(eolian_mono::marshall_annotation(false) << " public " << eolian_mono::marshall_type(false) << " " << string << ";\n")
|
||||||
.generate(sink, std::make_tuple(field.type, field.type, field_name), context))
|
.generate(sink, std::make_tuple(field.type, field.type, field_name), context))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -368,9 +369,10 @@ struct struct_binding_conversion_functions_generator
|
||||||
// Open conversion class
|
// Open conversion class
|
||||||
if (!as_generator
|
if (!as_generator
|
||||||
(
|
(
|
||||||
"public static class " << string << "_StructConversion\n{\n"
|
"/// <summary>Conversion class for struct " << struct_.cxx_name << "</summary>\n"
|
||||||
|
"public static class " << struct_.cxx_name << "_StructConversion\n{\n"
|
||||||
)
|
)
|
||||||
.generate(sink, struct_.cxx_name, context))
|
.generate(sink, nullptr, context))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// to internal
|
// to internal
|
||||||
|
|
|
@ -106,7 +106,7 @@ public struct Event_Description {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
public delegate void Event_Cb(System.IntPtr data, ref Event evt);
|
public delegate void Event_Cb(System.IntPtr data, ref Event_StructInternal evt);
|
||||||
#pragma warning disable 0169
|
#pragma warning disable 0169
|
||||||
public struct Dbg_Info {
|
public struct Dbg_Info {
|
||||||
IntPtr name;
|
IntPtr name;
|
||||||
|
|
Loading…
Reference in New Issue