*(desc->ops.base_op_id) = klass->class_id << OP_CLASS_OFFSET;
}
+static Eina_Bool
+_eo_class_mro_has(const Eo_Class *klass, const Eo_Class *find)
+{
+ const Eo_Class **itr;
+ for (itr = klass->mro ; *itr ; itr++)
+ {
+ if (*itr == find)
+ {
+ return EINA_TRUE;
+ }
+ }
+
+ return EINA_FALSE;
+}
+
static Eina_List *
_eo_class_mro_add(Eina_List *mro, const Eo_Class *klass)
{
{
EO_MAGIC_RETURN_VAL(obj, EO_EINA_MAGIC, NULL);
- /* FIXME: Add a check that this is of the right klass and we don't seg.
- * Probably just return NULL. */
+#ifndef NDEBUG
+ if (!_eo_class_mro_has(obj->klass, klass))
+ {
+ ERR("Tried getting data of class '%s' from object of class '%s', but the former is not a direct inheritance of the latter.", klass->desc->name, obj->klass->desc->name);
+ return NULL;
+ }
+#endif
if (EINA_LIKELY(klass->desc->data_size > 0))
{
if (EINA_UNLIKELY(klass->desc->type == EO_CLASS_TYPE_MIXIN))
}
END_TEST
+START_TEST(eo_data_fetch)
+{
+ eo_init();
+
+ static const Eo_Class_Description class_desc = {
+ "Simple2",
+ EO_CLASS_TYPE_REGULAR,
+ EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
+ NULL,
+ 10,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ };
+
+ const Eo_Class *klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL);
+ fail_if(!klass);
+
+ Eo *obj = eo_add(klass, NULL);
+ fail_if(!obj);
+ fail_if(eo_data_get(obj, SIMPLE_CLASS));
+
+ eo_shutdown();
+}
+END_TEST
+
START_TEST(eo_refs)
{
eo_init();
tcase_add_test(tc, eo_weak_reference);
tcase_add_test(tc, eo_refs);
tcase_add_test(tc, eo_magic_checks);
+ tcase_add_test(tc, eo_data_fetch);
}