summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-04-05 19:53:37 -0300
committerVitor Sousa <vitorsousa@expertisesolutions.com.br>2019-04-05 19:56:42 -0300
commit1e22db1150049e313bcba7906fc5ffc9a745eaf0 (patch)
tree3dd72d0486e2e03d90e10e5f96554176326aa783 /src/tests
parent4edf8036e05c8e70f54abf6513e0df165a725a18 (diff)
csharp: Make classes abstract and rework casting
Summary: Abstract Eo classes are now proper C# abstract classes. As a side effect, returning Eo instances from native code was reworked to return instances of their actual Eo classes instead of previous behavior of returning a generic Efl.Object and using static_cast. Instead of `var window = Efl.Ui.Win.static_cast(widget.GetParent());` Use `var window = widget.GetParent() as Efl.Ui.Win;` Another side effect was that `efl_constructor` was removed from the list of supported `Efl.Object` overrides. It is invoked inside `efl_add_internal_start`, before the bindings makes the association of the newly created EoId with the C# instance that created it, making the managed delegate meaningless. C# users then can use regular C# constructors to initialize fields. Also changed to set the private data of C#-inherited classes before the call to constructing methods (aka constructor parameters) so C# classes can override them correctly. Fixes T7778 Fixes T7757 Reviewers: vitor.sousa, felipealmeida, segfaultxavi Reviewed By: vitor.sousa, segfaultxavi Subscribers: cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T7778, T7757, T7702 Differential Revision: https://phab.enlightenment.org/D8550
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/efl_mono/Eo.cs10
-rw-r--r--src/tests/efl_mono/dummy_test_object.eo4
-rw-r--r--src/tests/efl_mono/libefl_mono_native_test.c9
3 files changed, 16 insertions, 7 deletions
diff --git a/src/tests/efl_mono/Eo.cs b/src/tests/efl_mono/Eo.cs
index 578ad10790..f4e3f5d51f 100644
--- a/src/tests/efl_mono/Eo.cs
+++ b/src/tests/efl_mono/Eo.cs
@@ -131,7 +131,7 @@ class TestEoParent
131 131
132 Test.AssertEquals(parent, child.GetParent()); 132 Test.AssertEquals(parent, child.GetParent());
133 133
134 var parent_retrieved = Dummy.TestObject.static_cast(child.GetParent()); 134 var parent_retrieved = child.GetParent() as Dummy.TestObject;
135 Test.AssertEquals(parent, parent_retrieved); 135 Test.AssertEquals(parent, parent_retrieved);
136 } 136 }
137 137
@@ -142,7 +142,7 @@ class TestEoParent
142 142
143 Test.AssertEquals(parent, child.GetParent()); 143 Test.AssertEquals(parent, child.GetParent());
144 144
145 Dummy.Numberwrapper parent_retrieved = Dummy.Numberwrapper.static_cast(child.GetParent()); 145 Dummy.Numberwrapper parent_retrieved = child.GetParent() as Dummy.Numberwrapper;
146 Test.AssertEquals(parent, parent_retrieved); 146 Test.AssertEquals(parent, parent_retrieved);
147 } 147 }
148 148
@@ -160,7 +160,7 @@ class TestEoParent
160 160
161 Test.AssertEquals(parent, child.GetParent()); 161 Test.AssertEquals(parent, child.GetParent());
162 162
163 var parent_from_cast = Dummy.TestObject.static_cast(child.GetParent()); 163 var parent_from_cast = child.GetParent() as Derived;
164 Test.AssertEquals(parent, parent_from_cast); 164 Test.AssertEquals(parent, parent_from_cast);
165 } 165 }
166} 166}
@@ -430,7 +430,7 @@ class TestInterfaceConcrete
430 public static void test_iface_concrete_methods() 430 public static void test_iface_concrete_methods()
431 { 431 {
432 var obj = new Dummy.TestObject(); 432 var obj = new Dummy.TestObject();
433 Dummy.ITestIface iface = Dummy.ITestIfaceConcrete.static_cast(obj); 433 Dummy.ITestIface iface = obj.ReturnIface();
434 434
435 iface.IfaceProp = 1970; 435 iface.IfaceProp = 1970;
436 Test.AssertEquals(iface.IfaceProp, 1970); 436 Test.AssertEquals(iface.IfaceProp, 1970);
@@ -443,7 +443,7 @@ class TestProvider
443 { 443 {
444 // Tests only the direction C# -> C 444 // Tests only the direction C# -> C
445 var obj = new Dummy.TestObject(); 445 var obj = new Dummy.TestObject();
446 Dummy.Numberwrapper provider = Dummy.Numberwrapper.static_cast(obj.FindProvider(typeof(Dummy.Numberwrapper))); 446 Dummy.Numberwrapper provider = obj.FindProvider(typeof(Dummy.Numberwrapper)) as Dummy.Numberwrapper;
447 Test.AssertEquals(provider.GetType(), typeof(Dummy.Numberwrapper)); 447 Test.AssertEquals(provider.GetType(), typeof(Dummy.Numberwrapper));
448 Test.AssertEquals(provider.GetNumber(), 1999); 448 Test.AssertEquals(provider.GetNumber(), 1999);
449 } 449 }
diff --git a/src/tests/efl_mono/dummy_test_object.eo b/src/tests/efl_mono/dummy_test_object.eo
index 5475c81c3c..eabb6cd0ce 100644
--- a/src/tests/efl_mono/dummy_test_object.eo
+++ b/src/tests/efl_mono/dummy_test_object.eo
@@ -111,6 +111,10 @@ class Dummy.Test_Object extends Efl.Object implements Dummy.Test_Iface {
111 return: Dummy.Test_Object; 111 return: Dummy.Test_Object;
112 } 112 }
113 113
114 return_iface {
115 return: Dummy.Test_Iface;
116 }
117
114 int_out { 118 int_out {
115 params { 119 params {
116 @in x: int; 120 @in x: int;
diff --git a/src/tests/efl_mono/libefl_mono_native_test.c b/src/tests/efl_mono/libefl_mono_native_test.c
index 7b4dd1a77f..8575ebac9c 100644
--- a/src/tests/efl_mono/libefl_mono_native_test.c
+++ b/src/tests/efl_mono/libefl_mono_native_test.c
@@ -45,11 +45,11 @@
45# endif 45# endif
46#endif 46#endif
47 47
48#include "dummy_test_iface.eo.h"
49#include "dummy_inherit_iface.eo.h"
48#include "dummy_numberwrapper.eo.h" 50#include "dummy_numberwrapper.eo.h"
49#include "dummy_test_object.eo.h" 51#include "dummy_test_object.eo.h"
50#include "dummy_child.eo.h" 52#include "dummy_child.eo.h"
51#include "dummy_test_iface.eo.h"
52#include "dummy_inherit_iface.eo.h"
53#include "dummy_inherit_helper.eo.h" 53#include "dummy_inherit_helper.eo.h"
54#include "dummy_part_holder.eo.h" 54#include "dummy_part_holder.eo.h"
55 55
@@ -172,6 +172,11 @@ Efl_Object *_dummy_test_object_return_null_object(Eo *obj EINA_UNUSED, EINA_UNUS
172 return NULL; 172 return NULL;
173} 173}
174 174
175Dummy_Test_Iface *_dummy_test_object_return_iface(Eo *obj, EINA_UNUSED Dummy_Test_Object_Data *pd)
176{
177 return obj;
178}
179
175void _dummy_test_object_int_out(EINA_UNUSED Eo *obj, EINA_UNUSED Dummy_Test_Object_Data *pd, int x, int *y) 180void _dummy_test_object_int_out(EINA_UNUSED Eo *obj, EINA_UNUSED Dummy_Test_Object_Data *pd, int x, int *y)
176{ 181{
177 *y = -x; 182 *y = -x;