Eo: Add a warning when trying to override a function that was already set for a class.

SVN revision: 74436
This commit is contained in:
Tom Hacohen 2012-07-26 12:21:01 +00:00
parent 6c9804fba9
commit d368088e59
2 changed files with 11 additions and 0 deletions

View File

@ -22,6 +22,8 @@ static void _eo_condtor_reset(Eo *obj);
static inline void *_eo_data_get(const Eo *obj, const Eo_Class *klass);
static inline Eo *_eo_ref(Eo *obj);
static inline void _eo_unref(Eo *obj);
static const Eo_Class *_eo_op_class_get(Eo_Op op);
static const Eo_Op_Description *_eo_op_id_desc_get(Eo_Op op);
typedef struct
{
@ -165,6 +167,14 @@ _dich_func_set(Eo_Class *klass, Eo_Op op, eo_op_func_type func)
size_t idx1 = DICH_CHAIN1(op);
Dich_Chain1 *chain1 = &klass->chain[idx1];
_dich_chain_alloc(chain1);
if (chain1->funcs[DICH_CHAIN_LAST(op)].src == klass)
{
const Eo_Class *op_kls = _eo_op_class_get(op);
const Eo_Op_Description *op_desc = _eo_op_id_desc_get(op);
WRN("Already set function for op %x (%s:%s). Overriding with func %p",
op, op_kls->desc->name, op_desc->name, func);
}
chain1->funcs[DICH_CHAIN_LAST(op)].func = func;
chain1->funcs[DICH_CHAIN_LAST(op)].src = klass;
}

View File

@ -224,6 +224,7 @@ _man_class_constructor(Eo_Class *klass)
const Eo_Op_Func_Description func_desc[] = {
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _man_con),
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _man_des),
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _man_des),
EO_OP_FUNC_SENTINEL
};