summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2017-06-13 17:45:02 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2017-07-13 18:25:43 -0300
commit0ef0605ee7715f47e739ca967cfcffb61be2d3a1 (patch)
treea0551d4d726025d2789e4860d198c5a53ab93203
parent97030c4d0d7924f785e79b98a25f67396e7ab0fb (diff)
eolian_mono: Set error for native wrappers
Exceptions leaking back to the native callback from the managed code can be harmful to P/Invoke sanity. This commit changes the wrapper to set a binding specific error that can be restored later into an exception when the flow returns to the managed side.
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_definition.hh7
-rw-r--r--src/tests/efl_mono/Errors.cs3
2 files changed, 7 insertions, 3 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/function_definition.hh b/src/bin/eolian_mono/eolian/mono/function_definition.hh
index 5c3f52c125..394efbfb8a 100644
--- a/src/bin/eolian_mono/eolian/mono/function_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_definition.hh
@@ -66,8 +66,13 @@ struct native_function_definition_generator
66 << scope_tab << scope_tab << "efl.eo.IWrapper wrapper = efl.eo.Globals.data_get(pd);\n" 66 << scope_tab << scope_tab << "efl.eo.IWrapper wrapper = efl.eo.Globals.data_get(pd);\n"
67 << scope_tab << scope_tab << "if(wrapper != null) {\n" 67 << scope_tab << scope_tab << "if(wrapper != null) {\n"
68 << scope_tab << scope_tab << scope_tab << eolian_mono::native_function_definition_preamble() 68 << scope_tab << scope_tab << scope_tab << eolian_mono::native_function_definition_preamble()
69 << scope_tab << scope_tab << scope_tab << (return_type != "void" ? "_ret_var = " : "") << "((" << string << "Inherit)wrapper)." << string 69 << scope_tab << scope_tab << scope_tab << "try {\n"
70 << scope_tab << scope_tab << scope_tab << scope_tab << (return_type != "void" ? "_ret_var = " : "") << "((" << string << "Inherit)wrapper)." << string
70 << "(" << (native_argument_invocation % ", ") << ");\n" 71 << "(" << (native_argument_invocation % ", ") << ");\n"
72 << scope_tab << scope_tab << scope_tab << "} catch (Exception e) {\n"
73 << scope_tab << scope_tab << scope_tab << scope_tab << "eina.Log.Warning($\"Callback error: {e.Message}\");\n"
74 << scope_tab << scope_tab << scope_tab << scope_tab << "eina.Error.Set(eina.Error.EFL_ERROR);\n"
75 << scope_tab << scope_tab << scope_tab << "}\n"
71 << eolian_mono::native_function_definition_epilogue(*klass) 76 << eolian_mono::native_function_definition_epilogue(*klass)
72 << scope_tab << scope_tab << "} else {\n" 77 << scope_tab << scope_tab << "} else {\n"
73 << scope_tab << scope_tab << scope_tab << (return_type != "void" ? "return " : "") << string << "Inherit." << string 78 << scope_tab << scope_tab << scope_tab << (return_type != "void" ? "return " : "") << string << "Inherit." << string
diff --git a/src/tests/efl_mono/Errors.cs b/src/tests/efl_mono/Errors.cs
index 7032964ab1..6c9b217313 100644
--- a/src/tests/efl_mono/Errors.cs
+++ b/src/tests/efl_mono/Errors.cs
@@ -46,8 +46,7 @@ class TestEolianError
46 { 46 {
47 test.Testing obj = new Overrider(); 47 test.Testing obj = new Overrider();
48 48
49 // WIP 49 Test.AssertRaises<efl.EflException>(obj.call_children_raise_error);
50 /* Test.AssertRaises<efl.EflException>(obj.call_children_raise_error); */
51 } 50 }
52 51
53 // return eina_error 52 // return eina_error