eo: fix efl_isa to work propertly with interfaces
authorMarcel Hollerbach <mail@marcel-hollerbach.de>
Fri, 1 Feb 2019 10:08:34 +0000 (11:08 +0100)
committerJongmin Lee <jm105.lee@samsung.com>
Wed, 6 Feb 2019 22:20:24 +0000 (07:20 +0900)
mro only contains special interfaces, not in general all, in order to
have a working function, while NOT having a bad performance. In order to
achive that we just copy the code that is done on efl_isa for a object.
which is a linear walk of a list

ref D7857

Reviewed-by: SangHyeon Jade Lee <sh10233.lee@samsung.com>
Differential Revision: https://phab.enlightenment.org/D7860

src/lib/eo/eo.c
src/tests/eo/interface/interface_main.c

index 3e4ac6c..8f711d8 100644 (file)
@@ -1760,24 +1760,14 @@ efl_isa(const Eo *eo_id, const Efl_Class *klass_id)
    // Case where we are looking if eo_id is a class that contain klass_id
    if (EINA_UNLIKELY(_eo_is_a_class(eo_id)))
      {
-        const _Efl_Class **kls_itr;
 
         EO_CLASS_POINTER_GOTO(klass_id, klass, err_class);
         EO_CLASS_POINTER_GOTO(eo_id, lookinto, err_class0);
 
-        if (lookinto == klass) return EINA_TRUE;
-
-        kls_itr = lookinto->mro;
-        if (!kls_itr) return EINA_FALSE;
-
-        while (*kls_itr)
-          {
-             if ((*kls_itr) == klass)
-               return EINA_TRUE;
-             kls_itr++;
-          }
+        const op_type_funcs *func = _vtable_func_get
+          (&lookinto->vtable, klass->base_id + klass->ops_count);
 
-        return EINA_FALSE;
+        return (func && (func->func == _eo_class_isa_func));;
      }
 
    domain = ((Eo_Id)eo_id >> SHIFT_DOMAIN) & MASK_DOMAIN;
index 53142cf..ed56c9f 100644 (file)
@@ -37,6 +37,9 @@ main(int argc, char *argv[])
 
    fail_if(!efl_isa(obj, INTERFACE_CLASS));
    fail_if(!efl_isa(obj, INTERFACE2_CLASS));
+   fail_if(!efl_isa(SIMPLE_CLASS, INTERFACE_CLASS));
+   fail_if(!efl_isa(SIMPLE_CLASS, INTERFACE2_CLASS));
+   fail_if(efl_isa(INTERFACE_CLASS, INTERFACE2_CLASS));
 
    efl_unref(obj);
    efl_object_shutdown();