summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2017-06-13 17:45:02 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2017-06-13 19:05:57 -0300
commitc182c0241d8bc7b4f37d612d1af6413d795a8e44 (patch)
tree3b8ef1a209c41eff70d3da620899a3c3846e2e3e
parent32daa0d45fc94cc250bf1544e0a77c328056d03a (diff)
downloadefl-c182c0241d8bc7b4f37d612d1af6413d795a8e44.tar.gz
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 bc8244162f..75ea92ad29 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
<< scope_tab << scope_tab << "efl.eo.IWrapper wrapper = efl.eo.Globals.data_get(pd);\n"
<< scope_tab << scope_tab << "if(wrapper != null) {\n"
<< scope_tab << scope_tab << scope_tab << eolian_mono::native_function_definition_preamble()
- << scope_tab << scope_tab << scope_tab << (return_type != "void" ? "_ret_var = " : "") << "((" << string << "Inherit)wrapper)." << string
+ << scope_tab << scope_tab << scope_tab << "try {\n"
+ << scope_tab << scope_tab << scope_tab << scope_tab << (return_type != "void" ? "_ret_var = " : "") << "((" << string << "Inherit)wrapper)." << string
<< "(" << (native_argument_invocation % ", ") << ");\n"
+ << scope_tab << scope_tab << scope_tab << "} catch (Exception e) {\n"
+ << scope_tab << scope_tab << scope_tab << scope_tab << "eina.Log.Warning($\"Callback error: {e.Message}\");\n"
+ << scope_tab << scope_tab << scope_tab << scope_tab << "eina.Error.Set(eina.Error.EFL_ERROR);\n"
+ << scope_tab << scope_tab << scope_tab << "}\n"
<< eolian_mono::native_function_definition_epilogue(*klass)
<< scope_tab << scope_tab << "} else {\n"
<< 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
{
test.Testing obj = new Overrider();
- // WIP
- /* Test.AssertRaises<efl.EflException>(obj.call_children_raise_error); */
+ Test.AssertRaises<efl.EflException>(obj.call_children_raise_error);
}
// return eina_error