summaryrefslogtreecommitdiff
path: root/legacy/eobj
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2012-07-18 12:27:09 +0000
committerTom Hacohen <tom@stosb.com>2012-07-18 12:27:09 +0000
commitfc73ddb3320fbb5455226804b49cc9a4149ebd2f (patch)
tree248be227aee1185d3ba02d4ee9cbef8687f5f6ce /legacy/eobj
parent677080ab4ebab1b03ab8032a9fbf19b4541bb31e (diff)
Eo: Fixed super of different functions.
I.e calling super a_get from an a_set implementation. This slows things down a bit. SVN revision: 74062
Diffstat (limited to 'legacy/eobj')
-rw-r--r--legacy/eobj/src/lib/eo.c66
-rw-r--r--legacy/eobj/src/tests/function_overrides/inherit2.c4
2 files changed, 38 insertions, 32 deletions
diff --git a/legacy/eobj/src/lib/eo.c b/legacy/eobj/src/lib/eo.c
index 1e355db828..3d0f498b01 100644
--- a/legacy/eobj/src/lib/eo.c
+++ b/legacy/eobj/src/lib/eo.c
@@ -25,8 +25,7 @@ static inline void _eo_unref(Eo *obj);
25 25
26typedef struct 26typedef struct
27{ 27{
28 const Eo_Class **kls_itr; 28 const Eo_Class *kls;
29 Eina_Bool insuper_context:1;
30} Eo_Kls_Itr; 29} Eo_Kls_Itr;
31 30
32struct _Eo { 31struct _Eo {
@@ -240,48 +239,51 @@ _eo_op_id_name_get(Eo_Op op)
240static inline void 239static inline void
241_eo_kls_itr_init(const Eo_Class *obj_klass, Eo_Kls_Itr *cur, Eo_Kls_Itr *prev_state) 240_eo_kls_itr_init(const Eo_Class *obj_klass, Eo_Kls_Itr *cur, Eo_Kls_Itr *prev_state)
242{ 241{
243 if (cur->insuper_context) 242 memcpy(prev_state, cur, sizeof(*cur));
244 { 243 cur->kls = *obj_klass->mro;
245 memcpy(prev_state, cur, sizeof(*cur));
246 cur->kls_itr = obj_klass->mro;
247 }
248} 244}
249 245
250static inline void 246static inline void
251_eo_kls_itr_end(Eo_Kls_Itr *cur, Eo_Kls_Itr *prev_state) 247_eo_kls_itr_end(Eo_Kls_Itr *cur, Eo_Kls_Itr *prev_state)
252{ 248{
253 if (cur->insuper_context) 249 memcpy(cur, prev_state, sizeof(*cur));
254 {
255 memcpy(cur, prev_state, sizeof(*cur));
256 }
257} 250}
258 251
259static inline const Eo_Class * 252static inline const Eo_Class *
260_eo_kls_itr_get(Eo_Kls_Itr *cur) 253_eo_kls_itr_get(Eo_Kls_Itr *cur)
261{ 254{
262 return *(cur->kls_itr); 255 return cur->kls;
256}
257
258static inline void
259_eo_kls_itr_set(Eo_Kls_Itr *cur, const Eo_Class *kls)
260{
261 cur->kls = kls;
263} 262}
264 263
265static inline const Eo_Class * 264static inline const Eo_Class *
266_eo_kls_itr_next(Eo_Kls_Itr *cur, Eo_Kls_Itr *prev_state, Eo_Op op) 265_eo_kls_itr_next(const Eo_Class *orig_kls, Eo_Kls_Itr *cur, Eo_Kls_Itr *prev_state, Eo_Op op)
267{ 266{
268 const Eo_Class **kls_itr = cur->kls_itr; 267 const Eo_Class **kls_itr = NULL;
269 memcpy(prev_state, cur, sizeof(*cur)); 268 memcpy(prev_state, cur, sizeof(*cur));
270 cur->insuper_context = EINA_TRUE;
271 if (*kls_itr)
272 {
273 const op_type_funcs *fsrc = _dich_func_get(*kls_itr, op);
274 269
275 while (*kls_itr && (*(kls_itr++) != fsrc->src)) 270 /* Find the kls itr. */
276 ; 271 kls_itr = orig_kls->mro;
272 while (*kls_itr && (*kls_itr != cur->kls))
273 kls_itr++;
277 274
278 cur->kls_itr = kls_itr; 275 if (*kls_itr)
279 return *kls_itr;
280 }
281 else
282 { 276 {
283 return NULL; 277 kls_itr++;
278 if (*kls_itr)
279 {
280 const op_type_funcs *fsrc = _dich_func_get(*kls_itr, op);
281 cur->kls = fsrc->src;
282 return cur->kls;
283 }
284 } 284 }
285
286 return NULL;
285} 287}
286 288
287static inline const op_type_funcs * 289static inline const op_type_funcs *
@@ -294,10 +296,12 @@ _eo_kls_itr_func_get(Eo_Kls_Itr *mro_itr, Eo_Op op)
294 296
295 if (func && func->func) 297 if (func && func->func)
296 { 298 {
299 _eo_kls_itr_set(mro_itr, func->src);
297 return func; 300 return func;
298 } 301 }
299 } 302 }
300 303
304 _eo_kls_itr_set(mro_itr, NULL);
301 return NULL; 305 return NULL;
302} 306}
303 307
@@ -344,10 +348,15 @@ _eo_op_internal(Eo *obj, Eo_Op_Type op_type, Eo_Op op, va_list *p_list)
344 Eo *emb_obj; 348 Eo *emb_obj;
345 EINA_LIST_FOREACH(obj->composite_objects, itr, emb_obj) 349 EINA_LIST_FOREACH(obj->composite_objects, itr, emb_obj)
346 { 350 {
351 /* FIXME: Clean this up a bit. */
352 Eo_Kls_Itr prev_state;
353 _eo_kls_itr_init(emb_obj->klass, &emb_obj->mro_itr, &prev_state);
347 if (_eo_op_internal(emb_obj, op_type, op, p_list)) 354 if (_eo_op_internal(emb_obj, op_type, op, p_list))
348 { 355 {
356 _eo_kls_itr_end(&emb_obj->mro_itr, &prev_state);
349 return EINA_TRUE; 357 return EINA_TRUE;
350 } 358 }
359 _eo_kls_itr_end(&emb_obj->mro_itr, &prev_state);
351 } 360 }
352 } 361 }
353 return EINA_FALSE; 362 return EINA_FALSE;
@@ -405,7 +414,7 @@ eo_do_super_internal(Eo *obj, Eo_Op_Type op_type, Eo_Op op, ...)
405 EO_MAGIC_RETURN_VAL(obj, EO_EINA_MAGIC, EINA_FALSE); 414 EO_MAGIC_RETURN_VAL(obj, EO_EINA_MAGIC, EINA_FALSE);
406 415
407 /* Advance the kls itr. */ 416 /* Advance the kls itr. */
408 nklass = _eo_kls_itr_next(&obj->mro_itr, &prev_state, op); 417 nklass = _eo_kls_itr_next(obj->klass, &obj->mro_itr, &prev_state, op);
409 418
410 va_start(p_list, op); 419 va_start(p_list, op);
411 if (!_eo_op_internal(obj, op_type, op, &p_list)) 420 if (!_eo_op_internal(obj, op_type, op, &p_list))
@@ -493,7 +502,7 @@ eo_class_do_super_internal(const Eo_Class *klass, Eo_Op op, ...)
493 EO_MAGIC_RETURN_VAL(klass, EO_CLASS_EINA_MAGIC, EINA_FALSE); 502 EO_MAGIC_RETURN_VAL(klass, EO_CLASS_EINA_MAGIC, EINA_FALSE);
494 503
495 /* Advance the kls itr. */ 504 /* Advance the kls itr. */
496 nklass = _eo_kls_itr_next(&((Eo_Class *) klass)->mro_itr, &prev_state, op); 505 nklass = _eo_kls_itr_next(klass, &((Eo_Class *) klass)->mro_itr, &prev_state, op);
497 506
498 va_start(p_list, op); 507 va_start(p_list, op);
499 if (!_eo_class_op_internal((Eo_Class *) klass, op, &p_list)) 508 if (!_eo_class_op_internal((Eo_Class *) klass, op, &p_list))
@@ -1030,8 +1039,6 @@ eo_class_new(const Eo_Class_Description *desc, Eo_Class_Id id, const Eo_Class *p
1030 } 1039 }
1031 } 1040 }
1032 1041
1033 klass->mro_itr.kls_itr = klass->mro;
1034
1035 _eo_class_constructor(klass); 1042 _eo_class_constructor(klass);
1036 1043
1037 va_end(p_list); 1044 va_end(p_list);
@@ -1113,7 +1120,6 @@ eo_add(const Eo_Class *klass, Eo *parent)
1113 EINA_MAGIC_SET(obj, EO_EINA_MAGIC); 1120 EINA_MAGIC_SET(obj, EO_EINA_MAGIC);
1114 obj->refcount++; 1121 obj->refcount++;
1115 obj->klass = klass; 1122 obj->klass = klass;
1116 obj->mro_itr.kls_itr = obj->klass->mro;
1117 1123
1118 eo_parent_set(obj, parent); 1124 eo_parent_set(obj, parent);
1119 1125
diff --git a/legacy/eobj/src/tests/function_overrides/inherit2.c b/legacy/eobj/src/tests/function_overrides/inherit2.c
index 84c6be93c2..6814a34a4d 100644
--- a/legacy/eobj/src/tests/function_overrides/inherit2.c
+++ b/legacy/eobj/src/tests/function_overrides/inherit2.c
@@ -21,7 +21,7 @@ _a_set(Eo *obj, void *class_data EINA_UNUSED, va_list *list)
21 eo_do(obj, simple_a_print()); 21 eo_do(obj, simple_a_print());
22 eo_do_super(obj, simple_a_set(a + 1)); 22 eo_do_super(obj, simple_a_set(a + 1));
23 23
24 fail_if(eo_do_super(obj, simple_a_print())); 24 fail_if(!eo_do_super(obj, simple_a_print()));
25} 25}
26 26
27static void 27static void
@@ -43,7 +43,7 @@ _class_print(const Eo_Class *klass, va_list *list)
43 (void) list; 43 (void) list;
44 printf("Print %s-%s\n", eo_class_name_get(klass), eo_class_name_get(MY_CLASS)); 44 printf("Print %s-%s\n", eo_class_name_get(klass), eo_class_name_get(MY_CLASS));
45 fail_if(!eo_class_do_super(klass, simple_class_print())); 45 fail_if(!eo_class_do_super(klass, simple_class_print()));
46 fail_if(eo_class_do_super(klass, simple_class_print2())); 46 fail_if(!eo_class_do_super(klass, simple_class_print2()));
47} 47}
48 48
49static void 49static void