diff options
author | Lauro Moura <lauromoura@expertisesolutions.com.br> | 2019-12-20 01:35:23 +0000 |
---|---|---|
committer | Felipe Magno de Almeida <felipe@expertisesolutions.com.br> | 2019-12-23 13:50:12 -0300 |
commit | 0954e501fd4008c40b3848de1f2c91bcd53b2f71 (patch) | |
tree | 3b6e45b69d24c85fcd0463eb605837cebe410c6a /src/tests/efl_mono | |
parent | ed0572a33a28429f1ad6e47cb5bee9ef816e4a45 (diff) | |
download | efl-0954e501fd4008c40b3848de1f2c91bcd53b2f71.tar.gz |
csharp: Property Indexer implementation
Use Indexers to use brackets, eg [i], syntax.
Keys now can be used as following:
var someVal = obj.SomeProperty[key];
obj.SomeProperty[key] = someNewVal;
And for multiple keys:
var someVal = obj.SomeProperty[(key1, key2)];
obj.SomeProperty[(key1, key2)] = someNewVal;
T8384
Reviewed-by: WooHyun Jung <wh0705.jung@samsung.com>
Differential Revision: https://phab.enlightenment.org/D10791
Diffstat (limited to 'src/tests/efl_mono')
-rw-r--r-- | src/tests/efl_mono/Eo.cs | 62 | ||||
-rw-r--r-- | src/tests/efl_mono/dummy_event_manager.c | 6 | ||||
-rw-r--r-- | src/tests/efl_mono/dummy_event_manager.eo | 2 | ||||
-rw-r--r-- | src/tests/efl_mono/dummy_test_object.c | 31 | ||||
-rw-r--r-- | src/tests/efl_mono/dummy_test_object.eo | 25 |
5 files changed, 116 insertions, 10 deletions
diff --git a/src/tests/efl_mono/Eo.cs b/src/tests/efl_mono/Eo.cs index 7c580480ad..af40bf12d8 100644 --- a/src/tests/efl_mono/Eo.cs +++ b/src/tests/efl_mono/Eo.cs @@ -402,15 +402,15 @@ class TestCsharpProperties obj.Dispose(); } - public static void test_setter_only() - { - var obj = new Dummy.TestObject(); - int val = -1984; + // public static void test_setter_only() + // { + // var obj = new Dummy.TestObject(); + // int val = -1984; - obj.SetterOnly = val; - Test.AssertEquals(val, obj.GetSetterOnly()); - obj.Dispose(); - } + // obj.SetterOnly = val; + // Test.AssertEquals(val, obj.GetSetterOnly()); + // obj.Dispose(); + // } public static void test_class_property() { @@ -436,6 +436,52 @@ class TestCsharpProperties Test.AssertEquals(ret, (1, 2)); obj.Dispose(); } + + public static void test_csharp_keyed_multi_valued_prop() + { + var obj = new Dummy.TestObject(); + obj.KeyedMultiValuedProp[100] = (1, 2); + Test.AssertEquals(obj.KeyedMultiValuedProp[100], (1, 2)); + obj.Dispose(); + } + + public static void test_csharp_multi_keyed_multi_valued_prop() + { + var obj = new Dummy.TestObject(); + obj.MultiKeyedMultiValuedProp[(100, 101)] = (1, 2); + Test.AssertEquals(obj.MultiKeyedMultiValuedProp[(100, 101)], (1, 2)); + obj.Dispose(); + } + + public static void test_csharp_multi_prop() + { + var obj = new Dummy.TestObject(); + obj.MultiKeyedMultiValuedProp[(100, 101)] = (1, 2); + obj.KeyedMultiValuedProp[100] = (1, 2); + Test.AssertEquals(obj.KeyedMultiValuedProp[100], + obj.MultiKeyedMultiValuedProp[(100, 101)]); + int a1, b1, a2, b2; +#if __MonoCS__ + (int a, int b) t1 = obj.MultiKeyedMultiValuedProp[(100, 101)]; + (a1, b1) = (t1.Item1, t1.Item2); + (int a, int b) t2 = obj.KeyedMultiValuedProp[100]; + (a2, b2) = (t2.Item1, t2.Item2); +#else + (a1, b1) = obj.MultiKeyedMultiValuedProp[(100, 101)]; + (a2, b2) = obj.KeyedMultiValuedProp[100]; +#endif + Test.AssertEquals(a1, a2); + Test.AssertEquals(b1, b2); + var i = (100, 101); + var j = 100; + Test.AssertEquals(obj.KeyedMultiValuedProp[j], + obj.MultiKeyedMultiValuedProp[i]); + obj.MultiKeyedMultiValuedProp[i] = (1, 3); + obj.KeyedMultiValuedProp[j] = obj.MultiKeyedMultiValuedProp[i]; + Test.AssertEquals(obj.KeyedMultiValuedProp[j], + obj.MultiKeyedMultiValuedProp[i]); + + } } class TestEoGrandChildrenFinalize diff --git a/src/tests/efl_mono/dummy_event_manager.c b/src/tests/efl_mono/dummy_event_manager.c index 62bdd05c7f..813622929a 100644 --- a/src/tests/efl_mono/dummy_event_manager.c +++ b/src/tests/efl_mono/dummy_event_manager.c @@ -43,6 +43,12 @@ _dummy_event_manager_emitter_set(EINA_UNUSED Eo *obj, Dummy_Event_Manager_Data * pd->emitter = emitter; } +static Efl_Object* +_dummy_event_manager_emitter_get(EINA_UNUSED Eo const *obj, Dummy_Event_Manager_Data *pd) +{ + return pd->emitter; +} + static Eina_Bool _dummy_event_manager_emit_with_int(EINA_UNUSED Eo *obj, Dummy_Event_Manager_Data *pd, int data) { diff --git a/src/tests/efl_mono/dummy_event_manager.eo b/src/tests/efl_mono/dummy_event_manager.eo index b16f7b92cb..5c8b1d0791 100644 --- a/src/tests/efl_mono/dummy_event_manager.eo +++ b/src/tests/efl_mono/dummy_event_manager.eo @@ -4,8 +4,6 @@ class Dummy.Event_Manager extends Efl.Object { methods { @property emitter { - set { - } values { emitter: Efl.Object @move; } diff --git a/src/tests/efl_mono/dummy_test_object.c b/src/tests/efl_mono/dummy_test_object.c index b87aff1cd4..19539906f4 100644 --- a/src/tests/efl_mono/dummy_test_object.c +++ b/src/tests/efl_mono/dummy_test_object.c @@ -16,6 +16,7 @@ #define DUMMY_TEST_IFACE_PROTECTED +#include <assert.h> #include "libefl_mono_native_test.h" typedef struct Dummy_Test_Object_Data @@ -4612,6 +4613,36 @@ void _dummy_test_object_multi_valued_prop_set(Eo* obj EINA_UNUSED, Dummy_Test_Ob pd->prop2 = prop2; } +void _dummy_test_object_keyed_multi_valued_prop_get(Eo const* obj EINA_UNUSED, Dummy_Test_Object_Data* pd, int prop_key1, int* prop1, int* prop2) +{ + assert (prop_key1 == 100); + *prop1 = pd->prop1; + *prop2 = pd->prop2; +} + +void _dummy_test_object_keyed_multi_valued_prop_set(Eo* obj EINA_UNUSED, Dummy_Test_Object_Data* pd, int prop_key1, int prop1, int prop2) +{ + assert (prop_key1 == 100); + pd->prop1 = prop1; + pd->prop2 = prop2; +} + +void _dummy_test_object_multi_keyed_multi_valued_prop_get(Eo const* obj EINA_UNUSED, Dummy_Test_Object_Data* pd, int prop_key1, int prop_key2, int* prop1, int* prop2) +{ + assert (prop_key1 == 100); + assert (prop_key2 == 101); + *prop1 = pd->prop1; + *prop2 = pd->prop2; +} + +void _dummy_test_object_multi_keyed_multi_valued_prop_set(Eo* obj EINA_UNUSED, Dummy_Test_Object_Data* pd, int prop_key1, int prop_key2, int prop1, int prop2) +{ + assert (prop_key1 == 100); + assert (prop_key2 == 101); + pd->prop1 = prop1; + pd->prop2 = prop2; +} + /* Class Properties */ static int _dummy_test_object_klass_prop = 0; diff --git a/src/tests/efl_mono/dummy_test_object.eo b/src/tests/efl_mono/dummy_test_object.eo index cf2ae7ce03..37c08cb495 100644 --- a/src/tests/efl_mono/dummy_test_object.eo +++ b/src/tests/efl_mono/dummy_test_object.eo @@ -1581,6 +1581,31 @@ class Dummy.Test_Object extends Efl.Object implements Dummy.Test_Iface { } } + @property keyed_multi_valued_prop { + get {} + set {} + keys { + key1: int; + } + values { + prop1: int; + prop2: int; + } + } + + @property multi_keyed_multi_valued_prop { + get {} + set {} + keys { + key1: int; + key2: int; + } + values { + prop1: int; + prop2: int; + } + } + @property klass_prop @static { get {} set {} |