From: Jérémy Zurcher Date: Wed, 25 Dec 2013 14:12:06 +0000 (+0100) Subject: eo2: better op_descs integration X-Git-Tag: v1.10.0-alpha1~200^2~149 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2490a1bef26b3b9b578843a940b57acabbc18e6b;p=platform%2Fupstream%2Fefl.git eo2: better op_descs integration struct _Eo_Class_Description swallows Eo2_Op_Description *descs2; --- diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index bfd9fde..e5fa687 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -471,13 +471,13 @@ struct _Eo_Class_Description struct { Eo_Op *base_op_id; const Eo_Op_Description *descs; + Eo2_Op_Description *descs2; /**< EO2 */ size_t count; } ops; /**< The ops description, should be filled using #EO_CLASS_DESCRIPTION_OPS */ const Eo_Event_Description **events; /**< The event descriptions for this class. */ size_t data_size; /**< The size of data (private + protected + public) this class needs per object. */ void (*class_constructor)(Eo_Class *klass); /**< The constructor of the class. */ void (*class_destructor)(Eo_Class *klass); /**< The destructor of the class. */ - Eo2_Op_Description *op_descs; /**< should replace ops.descs */ }; /** @@ -493,7 +493,7 @@ typedef struct _Eo_Class_Description Eo_Class_Description; * @param op_descs the op descriptions array. * @param count the number of ops in the op descriptions array. */ -#define EO_CLASS_DESCRIPTION_OPS(base_op_id, op_descs, count) { base_op_id, op_descs, count } +#define EO_CLASS_DESCRIPTION_OPS(base_op_id, op_descs, count) { base_op_id, op_descs, NULL, count } /** * @def EO_OP_DESCRIPTION(op, doc) @@ -604,6 +604,12 @@ EAPI Eina_Bool eo_shutdown(void); /************************************ EO2 ************************************/ +// computes size of Eo2_Op_Description[] +#define OP_DESC_SIZE(desc) (sizeof(desc)/sizeof(Eo2_Op_Description) -1 ) + +// An helper macro to help populating #Eo_Class_Description. +#define EO2_CLASS_DESCRIPTION_OPS(op_descs, count) { NULL, NULL, op_descs, count } + // sort Eo2_Op_Description[] by eapi_func then attribute OP ids EAPI void eo2_class_funcs_set(Eo_Class *klass_id); diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 8a69b2a..906183a9 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -305,7 +305,7 @@ eo2_get_op_id(_Eo *obj, void *api_func) imin = 0; imax = obj->klass->desc->ops.count - 1; - op_descs = obj->klass->desc->op_descs; + op_descs = obj->klass->desc->ops.descs2; while (imax >= imin) { @@ -337,32 +337,33 @@ eo2_api_funcs_cmp(const void *p1, const void *p2) EAPI void eo2_class_funcs_set(Eo_Class *klass_id) { - int i, base_op_id, n; + int op_id, n; _Eo_Class *klass; Eo2_Op_Description *op_desc; + Eo2_Op_Description *op_descs; klass = _eo_class_pointer_get(klass_id); EO_MAGIC_RETURN(klass, EO_CLASS_EINA_MAGIC); + op_descs = klass->desc->ops.descs2; - base_op_id = *klass->desc->ops.base_op_id; // klass->desc->ops.count only counts class OP, not _constructor or _destructor - for (op_desc = klass->desc->op_descs; op_desc->op_type != EO_OP_TYPE_INVALID; op_desc++); - n = op_desc - klass->desc->op_descs; + for (op_desc = op_descs; op_desc->op_type != EO_OP_TYPE_INVALID; op_desc++); + n = op_desc - op_descs; - qsort((void*)klass->desc->op_descs, n, sizeof(Eo2_Op_Description), eo2_api_funcs_cmp); + qsort((void*)op_descs, n, sizeof(Eo2_Op_Description), eo2_api_funcs_cmp); - i = 0; - for (op_desc = klass->desc->op_descs; op_desc->op_type != EO_OP_TYPE_INVALID; op_desc++) + op_id = klass->base_id; + for (op_desc = op_descs; op_desc->op_type != EO_OP_TYPE_INVALID; op_desc++) { if (op_desc->op == EO_NOOP) { if(op_desc->api_func == NULL) ERR("Setting implementation for NULL EAPI for class '%s'. Func index: %lu", - klass->desc->name, (unsigned long) (op_desc - klass->desc->op_descs)); + klass->desc->name, (unsigned long) (op_desc - op_descs)); - op_desc->op = base_op_id + i; - i++; + op_desc->op = op_id; + op_id++; } /* printf("%d %p %p\n", op_desc->op, op_desc->api_func, op_desc->func); */ // no need to check func->op_type != op_desc->op_type @@ -886,8 +887,16 @@ eo_class_new(const Eo_Class_Description *desc, const Eo_Class *parent_id, ...) DBG("Started building class '%s'", desc->name); - if (!_eo_class_check_op_descs(desc)) - return NULL; + if (desc->version == 1) + { + if (!_eo_class_check_op_descs(desc)) + return NULL; + } + else { + // FIXME: jeyzu + /* if (!_eo2_class_check_op_descs(desc)) */ + /* return NULL; */ + } _Eo_Class *parent = _eo_class_pointer_get(parent_id); #ifndef HAVE_EO_ID diff --git a/src/lib/eo/eo_base_class.c b/src/lib/eo/eo_base_class.c index b5a5edd..c83b19b 100644 --- a/src/lib/eo/eo_base_class.c +++ b/src/lib/eo/eo_base_class.c @@ -1007,7 +1007,6 @@ static const Eo_Class_Description class_desc = { event_desc, sizeof(Private_Data), _class_constructor, - NULL, NULL };