tasn pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=8d16d8eb5711d246509e44bf0ce5366f65fd9aea

commit 8d16d8eb5711d246509e44bf0ce5366f65fd9aea
Author: Tom Hacohen <t...@stosb.com>
Date:   Thu Oct 2 15:02:14 2014 +0100

    Eo: Move eo_add_ref logic inside the library.
    
    It was a stupid lazy decision to leave it outside. Having it inside is safer
    and cleaner.
---
 src/lib/eo/Eo.h | 15 ++++++++++-----
 src/lib/eo/eo.c |  4 ++--
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h
index b280797..8c26d6e 100644
--- a/src/lib/eo/Eo.h
+++ b/src/lib/eo/Eo.h
@@ -636,7 +636,7 @@ EAPI void eo_error_set_internal(const Eo *obj, const char 
*file, int line);
 #define eo_add(klass, parent, ...) \
    ({ \
     const Eo_Class *_tmp_klass = klass; \
-    Eo *_tmp_obj = _eo_add_internal_start(__FILE__, __LINE__, _tmp_klass, 
parent); \
+    Eo *_tmp_obj = _eo_add_internal_start(__FILE__, __LINE__, _tmp_klass, 
parent, EINA_FALSE); \
     eo_do(_tmp_obj, \
            eo_constructor(); \
            __VA_ARGS__; \
@@ -659,12 +659,17 @@ EAPI void eo_error_set_internal(const Eo *obj, const char 
*file, int line);
  */
 #define eo_add_ref(klass, parent, ...) \
    ({ \
-    Eo *_tmp_obj_ref = eo_add(klass, parent, __VA_ARGS__); \
-    if (eo_do(_tmp_obj_ref, eo_parent_get())) eo_ref(_tmp_obj_ref); \
-    _tmp_obj_ref; \
+    const Eo_Class *_tmp_klass = klass; \
+    Eo *_tmp_obj = _eo_add_internal_start(__FILE__, __LINE__, _tmp_klass, 
parent, EINA_TRUE); \
+    eo_do(_tmp_obj, \
+           eo_constructor(); \
+           __VA_ARGS__; \
+           _tmp_obj = eo_finalize(); \
+          ); \
+    _tmp_obj; \
     })
 
-EAPI Eo * _eo_add_internal_start(const char *file, int line, const Eo_Class 
*klass_id, Eo *parent);
+EAPI Eo * _eo_add_internal_start(const char *file, int line, const Eo_Class 
*klass_id, Eo *parent, Eina_Bool ref);
 
 /**
  * @brief Get a pointer to the data of an object for a specific class.
diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index e78b6f0..6e3ed73 100644
--- a/src/lib/eo/eo.c
+++ b/src/lib/eo/eo.c
@@ -868,7 +868,7 @@ _eo_class_funcs_set(_Eo_Class *klass)
 }
 
 EAPI Eo *
-_eo_add_internal_start(const char *file, int line, const Eo_Class *klass_id, 
Eo *parent_id)
+_eo_add_internal_start(const char *file, int line, const Eo_Class *klass_id, 
Eo *parent_id, Eina_Bool ref)
 {
    _Eo_Object *obj;
 
@@ -915,7 +915,7 @@ _eo_add_internal_start(const char *file, int line, const 
Eo_Class *klass_id, Eo
 
    /* If there's a parent. Unref. Eo_add should return an object with either a
     * parent ref, or with the lack of, just a ref. */
-   if (eo_do(eo_id, eo_parent_get()))
+   if (!ref && eo_do(eo_id, eo_parent_get()))
      {
         _eo_unref(obj);
      }

-- 


Reply via email to