summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2018-12-14 18:17:23 -0200
committerVitor Sousa <vitorsousa@expertisesolutions.com.br>2018-12-14 18:30:59 -0200
commita83c3cdba446c42d42b22b314ed6f91351e5234d (patch)
tree5e33da910696f07626d0de2fd1977306ed6c42d6 /src/tests
parent0611dbc1e9bbf81026e7630a65766c325495bf47 (diff)
eolian_mono: Add support for C# style properties
Summary: Syntatic sugar around the Get/Set functions for now. Test Plan: Run efl-mono-suite Reviewers: vitor.sousa, segfaultxavi, felipealmeida, Jaehyun_Cho Reviewed By: vitor.sousa Subscribers: cedric Tags: #efl_language_bindings Differential Revision: https://phab.enlightenment.org/D7394
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/efl_mono/Eo.cs42
-rw-r--r--src/tests/efl_mono/dummy_test_iface.eo7
-rw-r--r--src/tests/efl_mono/dummy_test_object.eo12
-rw-r--r--src/tests/efl_mono/libefl_mono_native_test.c20
4 files changed, 81 insertions, 0 deletions
diff --git a/src/tests/efl_mono/Eo.cs b/src/tests/efl_mono/Eo.cs
index 535c309e1c..7d5df72457 100644
--- a/src/tests/efl_mono/Eo.cs
+++ b/src/tests/efl_mono/Eo.cs
@@ -303,4 +303,46 @@ class TestEoMultipleChildClasses
303 } 303 }
304} 304}
305 305
306class TestCsharpProperties
307{
308 public static void test_csharp_properties()
309 {
310 var obj = new Dummy.TestObject();
311 var name = "My Name";
312 obj.Name = name;
313
314 Test.AssertEquals(name, obj.Name);
315 }
316
317 public static void test_getter_only()
318 {
319 var obj = new Dummy.TestObject();
320 Test.Assert(!obj.Invalidating);
321 }
322
323 public static void test_setter_only()
324 {
325 var obj = new Dummy.TestObject();
326 int val = -1984;
327
328 obj.SetterOnly = val;
329 Test.AssertEquals(val, obj.GetSetterOnly());
330 }
331
332 public static void test_class_property()
333 {
334 int val = -42;
335 Dummy.TestObject.KlassProp = val;
336 Test.AssertEquals(val, Dummy.TestObject.KlassProp);
337 }
338
339 public static void test_iface_property()
340 {
341 int val = -33;
342 Dummy.TestIface iface = new Dummy.TestObject();
343 iface.IfaceProp = val;
344 Test.AssertEquals(val, iface.IfaceProp);
345 }
346}
347
306} 348}
diff --git a/src/tests/efl_mono/dummy_test_iface.eo b/src/tests/efl_mono/dummy_test_iface.eo
index f7295e719e..9cad4c41c2 100644
--- a/src/tests/efl_mono/dummy_test_iface.eo
+++ b/src/tests/efl_mono/dummy_test_iface.eo
@@ -5,6 +5,13 @@ interface Dummy.Test_Iface ()
5 } 5 }
6 emit_nonconflicted { 6 emit_nonconflicted {
7 } 7 }
8 @property iface_prop {
9 get {}
10 set {}
11 values {
12 data: int;
13 }
14 }
8 } 15 }
9 events { 16 events {
10 conflicted: void; 17 conflicted: void;
diff --git a/src/tests/efl_mono/dummy_test_object.eo b/src/tests/efl_mono/dummy_test_object.eo
index a72e13ace3..e37616c979 100644
--- a/src/tests/efl_mono/dummy_test_object.eo
+++ b/src/tests/efl_mono/dummy_test_object.eo
@@ -1641,6 +1641,17 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
1641 } 1641 }
1642 return: accessor<ptr(int)> @owned; 1642 return: accessor<ptr(int)> @owned;
1643 } 1643 }
1644
1645 @property setter_only {
1646 set {}
1647 values {
1648 prop: int;
1649 }
1650 }
1651
1652 get_setter_only {
1653 return: int;
1654 }
1644 } 1655 }
1645 implements { 1656 implements {
1646 class.constructor; 1657 class.constructor;
@@ -1649,6 +1660,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
1649 Efl.Part.part_get; 1660 Efl.Part.part_get;
1650 Dummy.Test_Iface.emit_test_conflicted; 1661 Dummy.Test_Iface.emit_test_conflicted;
1651 Dummy.Test_Iface.emit_nonconflicted; 1662 Dummy.Test_Iface.emit_nonconflicted;
1663 Dummy.Test_Iface.iface_prop { get; set; }
1652 Dummy.Another_Iface.emit_another_conflicted; 1664 Dummy.Another_Iface.emit_another_conflicted;
1653 } 1665 }
1654 events { 1666 events {
diff --git a/src/tests/efl_mono/libefl_mono_native_test.c b/src/tests/efl_mono/libefl_mono_native_test.c
index 8a4592e35b..52876e6859 100644
--- a/src/tests/efl_mono/libefl_mono_native_test.c
+++ b/src/tests/efl_mono/libefl_mono_native_test.c
@@ -57,6 +57,8 @@ typedef struct Dummy_Test_Object_Data
57 Eo *part_two; 57 Eo *part_two;
58 Eina_Promise *promise; 58 Eina_Promise *promise;
59 Eina_List *list_for_accessor; 59 Eina_List *list_for_accessor;
60 int setter_only;
61 int iface_prop;
60} Dummy_Test_Object_Data; 62} Dummy_Test_Object_Data;
61 63
62typedef struct Dummy_Numberwrapper_Data 64typedef struct Dummy_Numberwrapper_Data
@@ -3876,7 +3878,25 @@ void _dummy_test_object_dummy_another_iface_emit_another_conflicted(Eo *obj, Dum
3876 efl_event_callback_legacy_call(obj, DUMMY_ANOTHER_IFACE_EVENT_CONFLICTED, NULL); 3878 efl_event_callback_legacy_call(obj, DUMMY_ANOTHER_IFACE_EVENT_CONFLICTED, NULL);
3877} 3879}
3878 3880
3881void _dummy_test_object_setter_only_set(EINA_UNUSED Eo *obj, Dummy_Test_Object_Data *pd, int value)
3882{
3883 pd->setter_only = value;
3884}
3885
3886int _dummy_test_object_get_setter_only(EINA_UNUSED Eo *obj, Dummy_Test_Object_Data *pd)
3887{
3888 return pd->setter_only;
3889}
3879 3890
3891void _dummy_test_object_dummy_test_iface_iface_prop_set(EINA_UNUSED Eo *obj, Dummy_Test_Object_Data *pd, int value)
3892{
3893 pd->iface_prop = value;
3894}
3895
3896int _dummy_test_object_dummy_test_iface_iface_prop_get(EINA_UNUSED const Eo *obj, Dummy_Test_Object_Data *pd)
3897{
3898 return pd->iface_prop;
3899}
3880 3900
3881#include "dummy_test_object.eo.c" 3901#include "dummy_test_object.eo.c"
3882#include "dummy_numberwrapper.eo.c" 3902#include "dummy_numberwrapper.eo.c"