From b85bb3718389470bfc78c079dd5e06def5e963f3 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Wed, 9 Mar 2016 15:06:49 +0000 Subject: [PATCH] Eo: Change to the Eo4 eo_add syntax. The current one was a hack in the meanwhile and was not protable. --- src/lib/eo/Eo.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 387f187..a6e4f96 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -610,12 +610,12 @@ EAPI Eo *eo_super(const Eo *obj, const Eo_Class *cur_klass); */ EAPI const Eo_Class *eo_class_get(const Eo *obj); -#define _eo_add_common(klass, parent, is_ref, ...) \ - ({ \ - Eo * const eoid = _eo_add_internal_start(__FILE__, __LINE__, klass, parent, is_ref); \ - __VA_ARGS__; \ - (Eo *) _eo_add_end(eoid); \ - }) +#define _eo_add_common(objp, klass, parent, is_ref, ...) \ + ((Eo *) ( \ + *objp = _eo_add_internal_start(__FILE__, __LINE__, klass, parent, is_ref), \ + ##__VA_ARGS__, \ + *objp = _eo_add_end(*objp) \ + )) /** * @def eo_add @@ -631,12 +631,13 @@ EAPI const Eo_Class *eo_class_get(const Eo *obj); * * If you want a more "consistent" behaviour, take a look at #eo_add_ref. * + * @param objp a pointer to the object id (Eo **) * @param klass the class of the object to create. * @param parent the parent to set to the object. * @param ... The ops to run. * @return An handle to the new object on success, NULL otherwise. */ -#define eo_add(klass, parent, ...) _eo_add_common(klass, parent, EINA_FALSE, ##__VA_ARGS__) +#define eo_add(objp, klass, parent, ...) _eo_add_common(objp, klass, parent, EINA_FALSE, ##__VA_ARGS__) /** * @def eo_add_ref @@ -648,12 +649,13 @@ EAPI const Eo_Class *eo_class_get(const Eo *obj); * when the parent object is deleted until you manually remove the ref * by calling eo_unref(). * + * @param objp a pointer to the object id (Eo **) * @param klass the class of the object to create. * @param parent the parent to set to the object. * @param ... The ops to run. * @return An handle to the new object on success, NULL otherwise. */ -#define eo_add_ref(klass, parent, ...) _eo_add_common(klass, parent, EINA_TRUE, ##__VA_ARGS__) +#define eo_add_ref(objp, klass, parent, ...) _eo_add_common(objp, klass, parent, EINA_TRUE, ##__VA_ARGS__) EAPI Eo * _eo_add_internal_start(const char *file, int line, const Eo_Class *klass_id, Eo *parent, Eina_Bool ref); -- 2.7.4