yakov pushed a commit to branch master.

http://git.enlightenment.org/tools/erigo.git/commit/?id=0595a34c32dd251e5c6d6ea3977421713babe07b

commit 0595a34c32dd251e5c6d6ea3977421713babe07b
Author: Yakov Goldberg <yako...@samsung.com>
Date:   Mon May 25 15:38:55 2015 +0300

    Fix constructors call in ffi abstraction layer
---
 src/bin/gui/dnd.c         |  1 -
 src/bin/gui/editor.c      |  5 +----
 src/lib/espion_preload.c  |  1 -
 src/lib/ffi_abstraction.c | 53 ++++++++++++++++++-----------------------------
 src/lib/ffi_glue.c        |  2 ++
 src/lib/simulator.c       |  8 ++++---
 6 files changed, 28 insertions(+), 42 deletions(-)

diff --git a/src/bin/gui/dnd.c b/src/bin/gui/dnd.c
index 6ee6d97..cce2ad0 100644
--- a/src/bin/gui/dnd.c
+++ b/src/bin/gui/dnd.c
@@ -349,7 +349,6 @@ _iter_dragged_widget_create(Gui_Session *session, const 
Gui_Widget *wdg, Eo *par
 
    if (o)
      {
-        session_eo_set(session, wdg, o);
         manager_widget_configure(session, wdg, MODE_EDITOR, NULL);
         children = wdg_children_list_get(wdg);
         EINA_LIST_FOREACH(children, l, wid)
diff --git a/src/bin/gui/editor.c b/src/bin/gui/editor.c
index daa138e..b7c9dea 100644
--- a/src/bin/gui/editor.c
+++ b/src/bin/gui/editor.c
@@ -2371,11 +2371,9 @@ _widget_add(Gui_Session *session, const Gui_Widget *wdg, 
void *data)
      {
         Eo *o = _ffi_eo_add(session, wdg, NULL);
         if (!o) return EINA_FALSE;
+        /* Add specific callbacks, related to UI. */
         evas_object_event_callback_add(o, EVAS_CALLBACK_KEY_DOWN, _key_down, 
wdg_context_get(wdg));
-
         eo_do(o, eo_event_callback_add(EVAS_OBJECT_EVENT_RESIZE, _wdg_resize, 
NULL));
-        /* Add specific callbacks, related to UI. */
-        session_eo_set(session, wdg, o);
 
         if (!strcmp(wdg_class_name_get(wdg), DB_DEF_BOX_CLASS))
           {
@@ -2423,7 +2421,6 @@ _widget_add(Gui_Session *session, const Gui_Widget *wdg, 
void *data)
              if (!o) return EINA_FALSE;
              //eo_do(win, elm_obj_win_resize_object_add(o));
              eo_do(o, eo_key_data_set("__editor_win", win, NULL));
-             session_eo_set(session, wdg, o);
           }
         else
           {
diff --git a/src/lib/espion_preload.c b/src/lib/espion_preload.c
index a76c76b..5656812 100644
--- a/src/lib/espion_preload.c
+++ b/src/lib/espion_preload.c
@@ -217,7 +217,6 @@ eo_add_internal(const char *file, int line, const Eo_Class 
*klass_id, Eo *parent
                 op = EO_NOOP;
           }
         obj = _ffi_eo_add(_session, wdg);
-        session_eo_set(_session, wdg, obj);
         printf("\033[34mCreation: \033[31mClass\033[m %s -> %s (%p)\n", 
class_name, widget_name, obj);
         eina_hash_add(_widgets_hash_table, &obj, info);
         _intercept_eo = EINA_TRUE;
diff --git a/src/lib/ffi_abstraction.c b/src/lib/ffi_abstraction.c
index 011fe87..18f55fb 100644
--- a/src/lib/ffi_abstraction.c
+++ b/src/lib/ffi_abstraction.c
@@ -68,12 +68,6 @@ _ffi_eo_do(const Gui_Session *session, const Gui_Widget 
*wdg, const Gui_Widget_P
         goto end;
      }
 
-   /* FIXME: if property is constructor don't call eo_do */
-   if (db_op_desc_is_constructor(op_desc))
-     {
-        goto end;
-     }
-
    eo_cur = session_eo_get(session, wdg);
 
    if (!eo_cur)
@@ -320,7 +314,6 @@ Eo*
 _ffi_eo_add(const Gui_Session *session, const Gui_Widget *wdg, Eo *parent_eo)
 {
    Eina_Stringshare *class_id;
-   char *constr_id = NULL;
    const Eo_Class *kl;
    Eo *ret = NULL;
 
@@ -333,6 +326,7 @@ _ffi_eo_add(const Gui_Session *session, const Gui_Widget 
*wdg, Eo *parent_eo)
              parent_wdg = wdg_parent_get(wdg);
              parent_eo = session_eo_get(session, parent_wdg);
              eo_do(parent_eo, ret = elm_obj_win_main_menu_get());
+             session_eo_set((Gui_Session *) session, wdg, ret);
              return ret;
           }
      }
@@ -342,38 +336,20 @@ _ffi_eo_add(const Gui_Session *session, const Gui_Widget 
*wdg, Eo *parent_eo)
    if (!class_id)
      {
         ERR("Property \"class\" is missing in widget: \"%s\"\n", 
wdg_name_get(wdg));
-        return EINA_FALSE;
+        return NULL;
      }
-   constr_id = "eo_constructor";
-   if (wdg_has_constructors(wdg))
-     ERR("This is time to impelement calls of custom constructos :)");
 
    /* Looking for class_get func,
     * and create an object of given class
     * */
+   const Eo_Class* (*kl_func)();
+   kl_func = db_class_func_get(class_id);
+   if (!kl_func)
      {
-        const Eo_Class* (*kl_func)();
-        kl_func = db_class_func_get(class_id);
-        if (!kl_func)
-          {
-             ERR("Class function was not found for class: \"%s\"", class_id);
-             goto end;
-          }
-        kl = kl_func();
-     }
-
-   /* FIXME: workaround for now
-    * Looking for op_desc for current constructor*/
-   void (*func_pointer)() = NULL;
-   if (strcmp("eo_constructor", constr_id))
-     {
-        ERR("only Eo Constructor supported in ffi! Got: %s", constr_id);
-        exit(1);
-     }
-   else
-     {
-        func_pointer = eo_constructor;
+        ERR("Class function was not found for class: \"%s\"", class_id);
+        goto end;
      }
+   kl = kl_func();
 
    /* Provide values with parent object.
     * If parent name is NULL, where is no parent obj. */
@@ -393,7 +369,18 @@ _ffi_eo_add(const Gui_Session *session, const Gui_Widget 
*wdg, Eo *parent_eo)
    const Eo *_eoid_ = _tmp_obj;
    if (_eo_do_start(_eoid_, NULL, EINA_FALSE, __FILE__, __FUNCTION__, 
__LINE__))
      {
-        func_pointer();
+        session_eo_set((Gui_Session *) session, wdg, (Eo *) _eoid_);
+
+        /* Iterate over properties and call functions which are constructors. 
*/
+        Gui_Widget_Property *prop;
+        const Eina_List *lst = wdg_prop_list_get(wdg), *itr;
+        EINA_LIST_FOREACH(lst, itr, prop)
+          {
+             if (db_op_desc_is_constructor(prop_op_desc_get(prop)))
+               {
+                  _ffi_eo_do(session, wdg, prop);
+               }
+          }
         _tmp_obj = _eo_add_end();
      }
 
diff --git a/src/lib/ffi_glue.c b/src/lib/ffi_glue.c
index ac52616..312bb22 100644
--- a/src/lib/ffi_glue.c
+++ b/src/lib/ffi_glue.c
@@ -43,6 +43,8 @@ _wdg_prop_eo_do_test(Gui_Session *session, const Gui_Widget 
*wdg, const Gui_Widg
 Eina_Bool
 manager_widget_property_add(Gui_Session *session, const Gui_Widget *wdg, const 
Gui_Widget_Property *prop, Action_Mode mode, void *data)
 {
+   if (db_op_desc_is_constructor(prop_op_desc_get(prop))) return EINA_FALSE;
+
    if (_wdg_prop_eo_do_test(session, wdg, prop))
      {
         /* Don't call visible for window. Because it must be called after 
window creation.
diff --git a/src/lib/simulator.c b/src/lib/simulator.c
index 6963204..07c981d 100644
--- a/src/lib/simulator.c
+++ b/src/lib/simulator.c
@@ -150,6 +150,7 @@ _widget_add(Gui_Session *session, const Gui_Widget *wdg, 
void *data)
              if (parent) parent_eo = session_eo_get(session, parent);
           }
         o = _ffi_eo_add(session, wdg, parent_eo);
+        if (!o) return EINA_FALSE;
      }
    else
      {
@@ -165,6 +166,8 @@ _widget_add(Gui_Session *session, const Gui_Widget *wdg, 
void *data)
              parent_win = target;
              win_type = ELM_WIN_INLINED_IMAGE;
              o = eo_add(ELM_WIN_CLASS, parent_win, elm_obj_win_name_set(NULL), 
elm_obj_win_type_set(win_type));
+             if (!o) return EINA_FALSE;
+             session_eo_set(session, wdg, o);
 
              /* Hide currently top window, because following window could be 
resized. */
                {
@@ -185,11 +188,10 @@ _widget_add(Gui_Session *session, const Gui_Widget *wdg, 
void *data)
           }
         else
           {
-             o = eo_add(ELM_WIN_CLASS, parent_win, elm_obj_win_name_set(NULL), 
elm_obj_win_type_set(win_type));
+             o = _ffi_eo_add(session, wdg, parent_win);
+             if (!o) return EINA_FALSE;
           }
      }
-   if (!o) return EINA_FALSE;
-   session_eo_set(session, wdg, o);
 
    /* Apply theme to simulated project. */
    if (IS_WIN(wdg))

-- 


Reply via email to