summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortasn <tasn>2012-07-26 12:21:01 +0000
committertasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>2012-07-26 12:21:01 +0000
commit872730f6434c7a9f2ff3b6c2973e50c8551deef5 (patch)
treed019b0b727efff74bd42ed72fe0243d8c6cea6a9
parent50a3537c3f75975c98cec1722a1d5b16b7c260cc (diff)
downloadeobj-872730f6434c7a9f2ff3b6c2973e50c8551deef5.tar.gz
eobj-872730f6434c7a9f2ff3b6c2973e50c8551deef5.tar.bz2
eobj-872730f6434c7a9f2ff3b6c2973e50c8551deef5.zip
Eo: Add a warning when trying to override a function that was already set for a class.
git-svn-id: http://svn.enlightenment.org/svn/e/trunk/PROTO/eobj@74436 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33
-rw-r--r--src/lib/eo.c10
-rw-r--r--src/tests/eo_suite/eo_test_general.c1
2 files changed, 11 insertions, 0 deletions
diff --git a/src/lib/eo.c b/src/lib/eo.c
index 2dc7a2e..ded5b32 100644
--- a/src/lib/eo.c
+++ b/src/lib/eo.c
@@ -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;
}
diff --git a/src/tests/eo_suite/eo_test_general.c b/src/tests/eo_suite/eo_test_general.c
index f6d872f..12791a0 100644
--- a/src/tests/eo_suite/eo_test_general.c
+++ b/src/tests/eo_suite/eo_test_general.c
@@ -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
};