summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2017-06-14 20:06:06 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2017-07-13 18:25:43 -0300
commitfd9a300b730fe3c61d3b1e6d95546136e6fd51c8 (patch)
treed1daabea3fc547704a18ebc0a067de47c7541bd6
parent0ef0605ee7715f47e739ca967cfcffb61be2d3a1 (diff)
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.hh2
-rw-r--r--src/bindings/mono/eina_mono/eina_error.cs10
-rw-r--r--src/tests/efl_mono/Errors.cs43
-rw-r--r--src/tests/efl_mono/libefl_mono_native_test.c10
-rw-r--r--src/tests/efl_mono/test_testing.eo6
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
86 , {"void_ptr", nullptr, [&] { return replace_base_type(regular, " System.IntPtr"); }} 86 , {"void_ptr", nullptr, [&] { return replace_base_type(regular, " System.IntPtr"); }}
87 , {"Error", nullptr, [&] // Eina.Error 87 , {"Error", nullptr, [&] // Eina.Error
88 { 88 {
89 return regular_type_def{" System.IntPtr", regular.base_qualifier, {}}; 89 return regular_type_def{" eina.Error", regular.base_qualifier, {}};
90 }} // TODO 90 }} // TODO
91 , {"string", true, [&] 91 , {"string", true, [&]
92 { 92 {
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;
3 3
4namespace eina { 4namespace eina {
5 5
6public struct Error 6public struct Error : IComparable<Error>
7{ 7{
8 int code; 8 int code;
9 9
@@ -27,6 +27,14 @@ public struct Error
27 { 27 {
28 return error.code; 28 return error.code;
29 } 29 }
30 public int CompareTo(Error err)
31 {
32 return code.CompareTo(err.code);
33 }
34 public override string ToString()
35 {
36 return "eina.Error(" + code + ")";
37 }
30 38
31 public static void Init() 39 public static void Init()
32 { 40 {
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
50 } 50 }
51 51
52 // return eina_error 52 // return eina_error
53 public static void eina_error_return()
54 {
55 test.Testing obj = new test.TestingConcrete();
56 eina.Error expected = 42;
57 obj.error_ret_set(expected);
58 eina.Error error = obj.returns_error();
59
60 Test.AssertEquals(expected, error);
61
62 expected = 0;
63 obj.error_ret_set(expected);
64 error = obj.returns_error();
65
66 Test.AssertEquals(expected, error);
67 }
68
69 class ReturnOverride : test.TestingInherit {
70 eina.Error code;
71 public override void error_ret_set(eina.Error err) {
72 code = 2 * err;
73 }
74 public override eina.Error returns_error()
75 {
76 return code;
77 }
78 }
79
80 public static void eina_error_return_from_inherited_virtual()
81 {
82 test.Testing obj = new ReturnOverride();
83 eina.Error expected = 42;
84 obj.error_ret_set(expected);
85 eina.Error error = obj.returns_error();
86
87 Test.AssertEquals(new eina.Error(expected * 2), error);
88
89 expected = 0;
90 obj.error_ret_set(expected);
91 error = obj.returns_error();
92
93 Test.AssertEquals(new eina.Error(expected * 2), error);
94 }
95
53 // events 96 // events
54 // virtual callbacks 97 // virtual callbacks
55} 98}
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
39 SimpleCb cb; 39 SimpleCb cb;
40 void *cb_data; 40 void *cb_data;
41 Eina_Free_Cb free_cb; 41 Eina_Free_Cb free_cb;
42 Eina_Error error_code;
42 43
43} Test_Testing_Data; 44} Test_Testing_Data;
44 45
@@ -1806,9 +1807,14 @@ void _test_testing_call_children_raise_error(Eo *obj, EINA_UNUSED Test_Testing_D
1806 test_testing_children_raise_error(obj); 1807 test_testing_children_raise_error(obj);
1807} 1808}
1808 1809
1809Eina_Error _test_testing_returns_error(EINA_UNUSED Eo *obj, EINA_UNUSED Test_Testing_Data *pd) 1810void _test_testing_error_ret_set(EINA_UNUSED Eo *obj, Test_Testing_Data *pd, Eina_Error error)
1810{ 1811{
1811 return EPERM; 1812 pd->error_code = error;
1813}
1814
1815Eina_Error _test_testing_returns_error(EINA_UNUSED Eo *obj, Test_Testing_Data *pd)
1816{
1817 return pd->error_code;
1812} 1818}
1813 1819
1814#include "test_testing.eo.c" 1820#include "test_testing.eo.c"
diff --git a/src/tests/efl_mono/test_testing.eo b/src/tests/efl_mono/test_testing.eo
index 213b5e2da1..612aef4851 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) {
737 737
738 } 738 }
739 739
740 error_ret_set {
741 params {
742 error: Eina.Error;
743 }
744 }
745
740 returns_error { 746 returns_error {
741 return: Eina.Error; 747 return: Eina.Error;
742 } 748 }