diff options
author | Lauro Moura <lauromoura@expertisesolutions.com.br> | 2017-06-14 20:06:06 -0300 |
---|---|---|
committer | Lauro Moura <lauromoura@expertisesolutions.com.br> | 2017-06-14 20:06:06 -0300 |
commit | 8bd40079922be694d8bbe755a0511fe814fbdf32 (patch) | |
tree | 3e6aa82bf0905a51dc089ccee00566e38d5d5358 | |
parent | c182c0241d8bc7b4f37d612d1af6413d795a8e44 (diff) | |
download | efl-8bd40079922be694d8bbe755a0511fe814fbdf32.tar.gz |
eolian_mono: Support returning eina.Error
- Added correct conversion to type_impl.hh
- Added more convenience methods to eina.Error
- Added test on both Concrete and Inherit methods returning eina.Errors.
-rw-r--r-- | src/bin/eolian_mono/eolian/mono/type_impl.hh | 2 | ||||
-rw-r--r-- | src/bindings/mono/eina_mono/eina_error.cs | 10 | ||||
-rw-r--r-- | src/tests/efl_mono/Errors.cs | 43 | ||||
-rw-r--r-- | src/tests/efl_mono/libefl_mono_native_test.c | 10 | ||||
-rw-r--r-- | src/tests/efl_mono/test_testing.eo | 6 |
5 files changed, 67 insertions, 4 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/type_impl.hh b/src/bin/eolian_mono/eolian/mono/type_impl.hh index c3c33bd891..8f654c5598 100644 --- a/src/bin/eolian_mono/eolian/mono/type_impl.hh +++ b/src/bin/eolian_mono/eolian/mono/type_impl.hh @@ -86,7 +86,7 @@ struct visitor_generate , {"void_ptr", nullptr, [&] { return replace_base_type(regular, " System.IntPtr"); }} , {"Error", nullptr, [&] // Eina.Error { - return regular_type_def{" System.IntPtr", regular.base_qualifier, {}}; + return regular_type_def{" eina.Error", regular.base_qualifier, {}}; }} // TODO , {"string", true, [&] { diff --git a/src/bindings/mono/eina_mono/eina_error.cs b/src/bindings/mono/eina_mono/eina_error.cs index 36d185c2b8..08444cc782 100644 --- a/src/bindings/mono/eina_mono/eina_error.cs +++ b/src/bindings/mono/eina_mono/eina_error.cs @@ -3,7 +3,7 @@ using System.Runtime.InteropServices; namespace eina { -public struct Error +public struct Error : IComparable<Error> { int code; @@ -27,6 +27,14 @@ public struct Error { return error.code; } + public int CompareTo(Error err) + { + return code.CompareTo(err.code); + } + public override string ToString() + { + return "eina.Error(" + code + ")"; + } public static void Init() { diff --git a/src/tests/efl_mono/Errors.cs b/src/tests/efl_mono/Errors.cs index 6c9b217313..042e4ae0e4 100644 --- a/src/tests/efl_mono/Errors.cs +++ b/src/tests/efl_mono/Errors.cs @@ -50,6 +50,49 @@ class TestEolianError } // return eina_error + public static void eina_error_return() + { + test.Testing obj = new test.TestingConcrete(); + eina.Error expected = 42; + obj.error_ret_set(expected); + eina.Error error = obj.returns_error(); + + Test.AssertEquals(expected, error); + + expected = 0; + obj.error_ret_set(expected); + error = obj.returns_error(); + + Test.AssertEquals(expected, error); + } + + class ReturnOverride : test.TestingInherit { + eina.Error code; + public override void error_ret_set(eina.Error err) { + code = 2 * err; + } + public override eina.Error returns_error() + { + return code; + } + } + + public static void eina_error_return_from_inherited_virtual() + { + test.Testing obj = new ReturnOverride(); + eina.Error expected = 42; + obj.error_ret_set(expected); + eina.Error error = obj.returns_error(); + + Test.AssertEquals(new eina.Error(expected * 2), error); + + expected = 0; + obj.error_ret_set(expected); + error = obj.returns_error(); + + Test.AssertEquals(new eina.Error(expected * 2), error); + } + // events // virtual callbacks } diff --git a/src/tests/efl_mono/libefl_mono_native_test.c b/src/tests/efl_mono/libefl_mono_native_test.c index 0c53c26dbb..8f024df0dd 100644 --- a/src/tests/efl_mono/libefl_mono_native_test.c +++ b/src/tests/efl_mono/libefl_mono_native_test.c @@ -39,6 +39,7 @@ typedef struct Test_Testing_Data SimpleCb cb; void *cb_data; Eina_Free_Cb free_cb; + Eina_Error error_code; } Test_Testing_Data; @@ -1806,9 +1807,14 @@ void _test_testing_call_children_raise_error(Eo *obj, EINA_UNUSED Test_Testing_D test_testing_children_raise_error(obj); } -Eina_Error _test_testing_returns_error(EINA_UNUSED Eo *obj, EINA_UNUSED Test_Testing_Data *pd) +void _test_testing_error_ret_set(EINA_UNUSED Eo *obj, Test_Testing_Data *pd, Eina_Error error) { - return EPERM; + pd->error_code = error; +} + +Eina_Error _test_testing_returns_error(EINA_UNUSED Eo *obj, Test_Testing_Data *pd) +{ + return pd->error_code; } #include "test_testing.eo.c" diff --git a/src/tests/efl_mono/test_testing.eo b/src/tests/efl_mono/test_testing.eo index 159a5d20e9..cf09801afb 100644 --- a/src/tests/efl_mono/test_testing.eo +++ b/src/tests/efl_mono/test_testing.eo @@ -737,6 +737,12 @@ class Test.Testing (Efl.Object) { } + error_ret_set { + params { + error: Eina.Error; + } + } + returns_error { return: Eina.Error; } |