Revert "Revert "Eo: Move eo_add_ref logic inside the library.""

This reverts commit 11da942184.

Can't reproduce with the non-existent bug report, thus have no choice
but consider it as working.
This commit is contained in:
Tom Hacohen 2014-10-10 09:30:52 +01:00
parent 11da942184
commit 5db7a70603
2 changed files with 12 additions and 7 deletions

View File

@ -636,7 +636,7 @@ EAPI void eo_error_set_internal(const Eo *obj, const char *file, int line);
#define eo_add(klass, parent, ...) \ #define eo_add(klass, parent, ...) \
({ \ ({ \
const Eo_Class *_tmp_klass = klass; \ 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_do(_tmp_obj, \
eo_constructor(); \ eo_constructor(); \
__VA_ARGS__; \ __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, ...) \ #define eo_add_ref(klass, parent, ...) \
({ \ ({ \
Eo *_tmp_obj_ref = eo_add(klass, parent, __VA_ARGS__); \ const Eo_Class *_tmp_klass = klass; \
if (eo_do(_tmp_obj_ref, eo_parent_get())) eo_ref(_tmp_obj_ref); \ Eo *_tmp_obj = _eo_add_internal_start(__FILE__, __LINE__, _tmp_klass, parent, EINA_TRUE); \
_tmp_obj_ref; \ 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. * @brief Get a pointer to the data of an object for a specific class.

View File

@ -868,7 +868,7 @@ _eo_class_funcs_set(_Eo_Class *klass)
} }
EAPI Eo * 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; _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 /* 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. */ * 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); _eo_unref(obj);
} }