summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-03-08 08:19:23 -0500
committerMike Blumenkrantz <zmike@samsung.com>2019-03-08 08:19:23 -0500
commit8118330d2a34a26078d3642ebbebf188146a5415 (patch)
tree6ed9873707d6faf2adb4a00a0aa4887909b44126
parent1a17aff85ffca1cae6d71aa6273e6a8214154276 (diff)
eo: fix reflection
Summary: the DFS tree walk was accidently stopped by a too early return statement. We should only return if we found a reflection entry, if not, then we should continue our search Depends on D7996 Reviewers: cedric, zmike, q66, segfaultxavi Reviewed By: cedric, zmike Subscribers: #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D7997
-rw-r--r--src/lib/eo/eo.c5
-rw-r--r--src/tests/eo/suite/eo_test_reflection.c17
-rw-r--r--src/tests/eo/suite/eo_test_reflection_complex_class_structure.c211
-rw-r--r--src/tests/eo/suite/eo_test_reflection_complex_class_structure.h20
4 files changed, 252 insertions, 1 deletions
diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index 76bebef023..a5da8c0289 100644
--- a/src/lib/eo/eo.c
+++ b/src/lib/eo/eo.c
@@ -3630,7 +3630,10 @@ _efl_class_reflection_find(const _Efl_Class *klass, const char *property_name)
3630 3630
3631 for (; *klass_iter; klass_iter++) 3631 for (; *klass_iter; klass_iter++)
3632 { 3632 {
3633 return _efl_class_reflection_find(*klass_iter, property_name); 3633 const Efl_Object_Property_Reflection *ref;
3634
3635 ref = _efl_class_reflection_find(*klass_iter, property_name);
3636 if (ref) return ref;
3634 } 3637 }
3635 3638
3636 return NULL; 3639 return NULL;
diff --git a/src/tests/eo/suite/eo_test_reflection.c b/src/tests/eo/suite/eo_test_reflection.c
index 9175785f14..c5a5b16929 100644
--- a/src/tests/eo/suite/eo_test_reflection.c
+++ b/src/tests/eo/suite/eo_test_reflection.c
@@ -8,6 +8,7 @@
8 8
9#include "eo_suite.h" 9#include "eo_suite.h"
10#include "eo_test_class_simple.h" 10#include "eo_test_class_simple.h"
11#include "eo_test_reflection_complex_class_structure.h"
11 12
12 13
13EFL_START_TEST(eo_test_reflection_invalid) 14EFL_START_TEST(eo_test_reflection_invalid)
@@ -66,9 +67,25 @@ EFL_START_TEST(eo_test_reflection_simple)
66} 67}
67EFL_END_TEST 68EFL_END_TEST
68 69
70EFL_START_TEST(eo_test_reflection_complex_class_structure)
71{
72 const int numb = 42;
73 Eina_Value numb_val = eina_value_int_init(numb);
74 Eo *simple = efl_new(COMPLEX_CLASS_CLASS);
75
76 efl_property_reflection_set(simple, "m_test", numb_val);
77 efl_property_reflection_set(simple, "i_test", numb_val);
78
79 ck_assert_int_eq(complex_mixin_m_test_get(simple), numb);
80 ck_assert_int_eq(complex_interface_i_test_get(simple), numb);
81}
82EFL_END_TEST
83
69void eo_test_reflection(TCase *tc) 84void eo_test_reflection(TCase *tc)
70{ 85{
71 tcase_add_test(tc, eo_test_reflection_simple); 86 tcase_add_test(tc, eo_test_reflection_simple);
72 tcase_add_test(tc, eo_test_reflection_inherited); 87 tcase_add_test(tc, eo_test_reflection_inherited);
73 tcase_add_test(tc, eo_test_reflection_invalid); 88 tcase_add_test(tc, eo_test_reflection_invalid);
89 tcase_add_test(tc, eo_test_reflection_complex_class_structure);
74} 90}
91#include "eo_test_reflection_complex_class_structure.c"
diff --git a/src/tests/eo/suite/eo_test_reflection_complex_class_structure.c b/src/tests/eo/suite/eo_test_reflection_complex_class_structure.c
new file mode 100644
index 0000000000..474f0f77c2
--- /dev/null
+++ b/src/tests/eo/suite/eo_test_reflection_complex_class_structure.c
@@ -0,0 +1,211 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include <stdio.h>
6
7#include <Eo.h>
8
9#include "eo_suite.h"
10#include "eo_test_class_simple.h"
11#include "eo_test_reflection_complex_class_structure.h"
12
13typedef struct {
14 int i;
15} Complex_Class_Data;
16
17typedef struct {
18 int i;
19} Complex_Mixin_Data;
20
21static void
22_complex_class_complex_interface_i_test_set(Eo *obj EINA_UNUSED, Complex_Class_Data *pd, int i)
23{
24 pd->i = i;
25}
26
27static int
28_complex_class_complex_interface_i_test_get(const Eo *obj EINA_UNUSED, Complex_Class_Data *pd)
29{
30 return pd->i;
31}
32
33static int
34_complex_mixin_m_test_get(const Eo *obj EINA_UNUSED, Complex_Mixin_Data *pd)
35{
36 return pd->i;
37}
38
39static void
40_complex_mixin_m_test_set(Eo *obj EINA_UNUSED, Complex_Mixin_Data *pd, int i)
41{
42 pd->i = i;
43}
44
45static Eina_Bool
46_complex_class_class_initializer(Efl_Class *klass)
47{
48 const Efl_Object_Ops *opsp = NULL;
49
50 const Efl_Object_Property_Reflection_Ops *ropsp = NULL;
51
52#ifndef COMPLEX_CLASS_EXTRA_OPS
53#define COMPLEX_CLASS_EXTRA_OPS
54#endif
55
56 EFL_OPS_DEFINE(ops,
57 EFL_OBJECT_OP_FUNC(complex_interface_i_test_set, _complex_class_complex_interface_i_test_set),
58 EFL_OBJECT_OP_FUNC(complex_interface_i_test_get, _complex_class_complex_interface_i_test_get),
59 COMPLEX_CLASS_EXTRA_OPS
60 );
61 opsp = &ops;
62
63 return efl_class_functions_set(klass, opsp, ropsp);
64}
65
66static const Efl_Class_Description _complex_class_class_desc = {
67 EO_VERSION,
68 "Complex_Class",
69 EFL_CLASS_TYPE_REGULAR,
70 sizeof(Complex_Class_Data),
71 _complex_class_class_initializer,
72 NULL,
73 NULL
74};
75
76EFL_DEFINE_CLASS(complex_class_class_get, &_complex_class_class_desc, EO_CLASS, COMPLEX_INTERFACE_INTERFACE, COMPLEX_MIXIN_MIXIN, NULL);
77
78static Eina_Error
79__eolian_complex_interface_i_test_set_reflect(Eo *obj, Eina_Value val)
80{
81 Eina_Error r = 0; int cval;
82 if (!eina_value_int_convert(&val, &cval))
83 {
84 r = EINA_ERROR_VALUE_FAILED;
85 goto end;
86 }
87 complex_interface_i_test_set(obj, cval);
88 end:
89 eina_value_flush(&val);
90 return r;
91}
92
93EOAPI EFL_VOID_FUNC_BODYV(complex_interface_i_test_set, EFL_FUNC_CALL(i), int i);
94
95static Eina_Value
96__eolian_complex_interface_i_test_get_reflect(Eo *obj)
97{
98 int val = complex_interface_i_test_get(obj);
99 return eina_value_int_init(val);
100}
101
102EOAPI EFL_FUNC_BODY_CONST(complex_interface_i_test_get, int, 0);
103
104static Eina_Bool
105_complex_interface_class_initializer(Efl_Class *klass)
106{
107 const Efl_Object_Ops *opsp = NULL;
108
109 const Efl_Object_Property_Reflection_Ops *ropsp = NULL;
110
111#ifndef COMPLEX_INTERFACE_EXTRA_OPS
112#define COMPLEX_INTERFACE_EXTRA_OPS
113#endif
114
115 EFL_OPS_DEFINE(ops,
116 EFL_OBJECT_OP_FUNC(complex_interface_i_test_set, NULL),
117 EFL_OBJECT_OP_FUNC(complex_interface_i_test_get, NULL),
118 COMPLEX_INTERFACE_EXTRA_OPS
119 );
120 opsp = &ops;
121
122 static const Efl_Object_Property_Reflection refl_table[] = {
123 {"i_test", __eolian_complex_interface_i_test_set_reflect, __eolian_complex_interface_i_test_get_reflect},
124 };
125 static const Efl_Object_Property_Reflection_Ops rops = {
126 refl_table, EINA_C_ARRAY_LENGTH(refl_table)
127 };
128 ropsp = &rops;
129
130 return efl_class_functions_set(klass, opsp, ropsp);
131}
132
133static const Efl_Class_Description _complex_interface_class_desc = {
134 EO_VERSION,
135 "Complex_Interface",
136 EFL_CLASS_TYPE_INTERFACE,
137 0,
138 _complex_interface_class_initializer,
139 NULL,
140 NULL
141};
142
143EFL_DEFINE_CLASS(complex_interface_interface_get, &_complex_interface_class_desc, NULL, NULL);
144
145static Eina_Error
146__eolian_complex_mixin_m_test_set_reflect(Eo *obj, Eina_Value val)
147{
148 Eina_Error r = 0; int cval;
149 if (!eina_value_int_convert(&val, &cval))
150 {
151 r = EINA_ERROR_VALUE_FAILED;
152 goto end;
153 }
154 complex_mixin_m_test_set(obj, cval);
155 end:
156 eina_value_flush(&val);
157 return r;
158}
159
160EOAPI EFL_VOID_FUNC_BODYV(complex_mixin_m_test_set, EFL_FUNC_CALL(i), int i);
161
162
163static Eina_Value
164__eolian_complex_mixin_m_test_get_reflect(Eo *obj)
165{
166 int val = complex_mixin_m_test_get(obj);
167 return eina_value_int_init(val);
168}
169
170EOAPI EFL_FUNC_BODY_CONST(complex_mixin_m_test_get, int, 0);
171
172static Eina_Bool
173_complex_mixin_class_initializer(Efl_Class *klass)
174{
175 const Efl_Object_Ops *opsp = NULL;
176
177 const Efl_Object_Property_Reflection_Ops *ropsp = NULL;
178
179#ifndef COMPLEX_MIXIN_EXTRA_OPS
180#define COMPLEX_MIXIN_EXTRA_OPS
181#endif
182
183 EFL_OPS_DEFINE(ops,
184 EFL_OBJECT_OP_FUNC(complex_mixin_m_test_set, _complex_mixin_m_test_set),
185 EFL_OBJECT_OP_FUNC(complex_mixin_m_test_get, _complex_mixin_m_test_get),
186 COMPLEX_MIXIN_EXTRA_OPS
187 );
188 opsp = &ops;
189
190 static const Efl_Object_Property_Reflection refl_table[] = {
191 {"m_test", __eolian_complex_mixin_m_test_set_reflect, __eolian_complex_mixin_m_test_get_reflect},
192 };
193 static const Efl_Object_Property_Reflection_Ops rops = {
194 refl_table, EINA_C_ARRAY_LENGTH(refl_table)
195 };
196 ropsp = &rops;
197
198 return efl_class_functions_set(klass, opsp, ropsp);
199}
200
201static const Efl_Class_Description _complex_mixin_class_desc = {
202 EO_VERSION,
203 "Complex_Mixin",
204 EFL_CLASS_TYPE_MIXIN,
205 sizeof(Complex_Mixin_Data),
206 _complex_mixin_class_initializer,
207 NULL,
208 NULL
209};
210
211EFL_DEFINE_CLASS(complex_mixin_mixin_get, &_complex_mixin_class_desc, NULL, NULL);
diff --git a/src/tests/eo/suite/eo_test_reflection_complex_class_structure.h b/src/tests/eo/suite/eo_test_reflection_complex_class_structure.h
new file mode 100644
index 0000000000..ae615c9428
--- /dev/null
+++ b/src/tests/eo/suite/eo_test_reflection_complex_class_structure.h
@@ -0,0 +1,20 @@
1#ifndef EO_TEST_REFLECTION_COMPLEX_CLASS_STRCUTURE_H
2#define EO_TEST_REFLECTION_COMPLEX_CLASS_STRCUTURE_H
3
4typedef Eo Complex_Mixin;
5#define COMPLEX_MIXIN_MIXIN complex_mixin_mixin_get()
6EWAPI const Efl_Class *complex_mixin_mixin_get(void);
7EOAPI void complex_mixin_m_test_set(Eo *obj, int i);
8EOAPI int complex_mixin_m_test_get(const Eo *obj);
9
10typedef Eo Complex_Interface;
11#define COMPLEX_INTERFACE_INTERFACE complex_interface_interface_get()
12EWAPI const Efl_Class *complex_interface_interface_get(void);
13EOAPI void complex_interface_i_test_set(Eo *obj, int i);
14EOAPI int complex_interface_i_test_get(const Eo *obj);
15
16typedef Eo Complex_Class;
17#define COMPLEX_CLASS_CLASS complex_class_class_get()
18EWAPI const Efl_Class *complex_class_class_get(void);
19
20#endif