Eo: Fixed an issue with mixins and super calls.
authortasn <tasn>
Tue, 31 Jul 2012 07:15:33 +0000 (07:15 +0000)
committertasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 31 Jul 2012 07:15:33 +0000 (07:15 +0000)
git-svn-id: http://svn.enlightenment.org/svn/e/trunk/PROTO/eobj@74617 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/eo.c
src/tests/mixin/CMakeLists.txt
src/tests/mixin/inherit.c [new file with mode: 0644]
src/tests/mixin/inherit.h [new file with mode: 0644]
src/tests/mixin/main.c
src/tests/mixin/mixin4.c [new file with mode: 0644]
src/tests/mixin/mixin4.h [new file with mode: 0644]

index 2758044..5e95291 100644 (file)
@@ -285,14 +285,20 @@ _eo_kls_itr_next(const Eo_Class *orig_kls, Eo_Kls_Itr *cur, Eo_Kls_Itr *prev_sta
    if (*kls_itr)
      {
         kls_itr++;
-        if (*kls_itr)
+        while (*kls_itr)
           {
              const op_type_funcs *fsrc = _dich_func_get(*kls_itr, op);
+             if (!fsrc->func)
+               {
+                  kls_itr++;
+                  continue;
+               }
              cur->kls = fsrc->src;
              return cur->kls;
           }
      }
 
+   cur->kls = NULL;
    return NULL;
 }
 
index 557cbd3..557a3e6 100644 (file)
@@ -1,9 +1,11 @@
 LIST(APPEND MIXIN_CC_SOURCES
    main.c
    simple.c
+   inherit.c
    mixin.c
    mixin2.c
    mixin3.c
+   mixin4.c
    )
 
 include_directories(
diff --git a/src/tests/mixin/inherit.c b/src/tests/mixin/inherit.c
new file mode 100644 (file)
index 0000000..53c8826
--- /dev/null
@@ -0,0 +1,38 @@
+#include "Eo.h"
+#include "inherit.h"
+
+#include "config.h"
+
+#define MY_CLASS INHERIT_CLASS
+
+static void
+_a_get(Eo *obj, void *class_data EINA_UNUSED, va_list *list)
+{
+   int *name = va_arg(*list, int *);
+   eo_do_super(obj, simple_a_get(name));
+   printf("%s\n", __func__);
+}
+
+static void
+_class_constructor(Eo_Class *klass)
+{
+   const Eo_Op_Func_Description func_desc[] = {
+        EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_GET), _a_get),
+        EO_OP_FUNC_SENTINEL
+   };
+
+   eo_class_funcs_set(klass, func_desc);
+}
+
+static const Eo_Class_Description class_desc = {
+     EO_VERSION,
+     "Inherit",
+     EO_CLASS_TYPE_REGULAR,
+     EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
+     NULL,
+     0,
+     _class_constructor,
+     NULL
+};
+
+EO_DEFINE_CLASS(inherit_class_get, &class_desc, SIMPLE_CLASS, MIXIN4_CLASS, NULL);
diff --git a/src/tests/mixin/inherit.h b/src/tests/mixin/inherit.h
new file mode 100644 (file)
index 0000000..b6d78fb
--- /dev/null
@@ -0,0 +1,11 @@
+#ifndef INHERIT_H
+#define INHERIT_H
+
+#include "Eo.h"
+#include "simple.h"
+#include "mixin4.h"
+
+#define INHERIT_CLASS inherit_class_get()
+const Eo_Class *inherit_class_get(void);
+
+#endif
index b7109a1..c69754d 100644 (file)
@@ -1,5 +1,6 @@
 #include "Eo.h"
 #include "simple.h"
+#include "inherit.h"
 #include "mixin.h"
 #include "mixin2.h"
 #include "mixin3.h"
@@ -30,6 +31,12 @@ main(int argc, char *argv[])
    fail_if(pd3->count != 9);
 
    eo_unref(obj);
+
+   obj = eo_add(INHERIT_CLASS, NULL);
+   eo_do(obj, simple_a_set(5), simple_a_get(&a));
+   fail_if(a != 5);
+
+   eo_unref(obj);
    eo_shutdown();
    return 0;
 }
diff --git a/src/tests/mixin/mixin4.c b/src/tests/mixin/mixin4.c
new file mode 100644 (file)
index 0000000..17944bc
--- /dev/null
@@ -0,0 +1,24 @@
+#include "Eo.h"
+#include "mixin.h"
+#include "mixin4.h"
+#include "simple.h"
+
+#include "config.h"
+
+#include "../eunit_tests.h"
+
+#define MY_CLASS MIXIN4_CLASS
+
+static const Eo_Class_Description class_desc = {
+     EO_VERSION,
+     "Mixin4",
+     EO_CLASS_TYPE_MIXIN,
+     EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
+     NULL,
+     0,
+     NULL,
+     NULL
+};
+
+EO_DEFINE_CLASS(mixin4_class_get, &class_desc, NULL, NULL);
+
diff --git a/src/tests/mixin/mixin4.h b/src/tests/mixin/mixin4.h
new file mode 100644 (file)
index 0000000..e924332
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef MIXIN4_H
+#define MIXIN4_H
+
+#include "Eo.h"
+
+#define MIXIN4_CLASS mixin4_class_get()
+const Eo_Class *mixin4_class_get(void);
+
+#endif