From 42ad23c5c87b44fd982849f17b6ab8f540407c87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 26 Dec 2013 16:23:55 +0100 Subject: [PATCH] eo2: eo2_add accepts non-defauld constructors --- src/lib/eo/Eo.h | 2 +- src/lib/eo/eo.c | 20 +++++++++++++++++--- src/lib/eo/eo_private.h | 1 + 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index e2c29f11b0..9724663beb 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -822,7 +822,7 @@ EAPI void eo_error_set_internal(const Eo *obj, const char *file, int line); #define eo2_add(klass, parent, ...) \ ({ \ const Eo_Class *_tmp_klass = klass; \ - eo_add_internal(__FILE__, __LINE__, _tmp_klass, parent, ## __VA_ARGS__, EO_NOOP); \ + eo_add_internal(__FILE__, __LINE__, _tmp_klass, parent, eo2_constructor, ## __VA_ARGS__, EO_NOOP); \ }) /** diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 8cc8bb36a1..168bac008c 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -1405,10 +1405,24 @@ eo_add_internal(const char *file, int line, const Eo_Class *klass_id, Eo *parent _eo_parent_internal_set(obj, parent_id); - if (klass->desc->version == EO2_VERSION) - eo2_do((Eo *)obj_id, eo2_constructor()); - /* Run the relevant do stuff. */ + if (klass->desc->version == EO2_VERSION) + { + eo2_constructor_type constr; + va_list p_list; + if(eo2_do_start((Eo *)obj_id, EINA_FALSE)) + { + va_start(p_list, parent_id); + while ((constr = va_arg(p_list, eo2_constructor_type))) + constr(); + va_end(p_list); + eo2_do_end(NULL); + do_err = EINA_FALSE; + } + else + do_err = EINA_TRUE; + } + else { va_list p_list; va_start(p_list, parent_id); diff --git a/src/lib/eo/eo_private.h b/src/lib/eo/eo_private.h index 9af5a51f74..a645a910a8 100644 --- a/src/lib/eo/eo_private.h +++ b/src/lib/eo/eo_private.h @@ -61,6 +61,7 @@ typedef struct _Eo_Class _Eo_Class; typedef struct _Eo_Object _Eo_Object; typedef struct _Eo_Base Eo_Base; typedef struct _Eo_Internal _Eo; +typedef void (*eo2_constructor_type)(void); /* Retrieves the pointer to the object from the id */ static inline _Eo_Object *_eo_obj_pointer_get(const Eo_Id obj_id);