Eo: Force classes to inherit from EO_BASE_CLASS.

SVN revision: 71931
This commit is contained in:
Tom Hacohen 2012-06-11 07:35:02 +00:00
parent c74cf7666d
commit bc42fd3c1e
2 changed files with 19 additions and 2 deletions

View File

@ -941,6 +941,23 @@ eo_class_new(const Eo_Class_Description *desc, Eo_Class_Id id, const Eo_Class *p
klass->data_offset = klass->parent->data_offset +
EO_ALIGN_SIZE(klass->parent->desc->data_size);
}
/* EO_BASE_CLASS is allowed not to have a parent. */
else if (id != EO_BASE_CLASS_ID)
{
/* No parent. */
switch (klass->desc->type)
{
case EO_CLASS_TYPE_REGULAR:
case EO_CLASS_TYPE_REGULAR_NO_INSTANT:
ERR("Regular classes ('%s') must inherit from EO_BASE_CLASS.", klass->desc->name);
goto cleanup;
break;
case EO_CLASS_TYPE_INTERFACE:
case EO_CLASS_TYPE_MIXIN:
/* Do nothing. */
break;
}
}
if (!_eo_class_check_op_descs(klass, id))
{

View File

@ -82,7 +82,7 @@ START_TEST(eo_incomplete_desc)
fail_if(klass);
/* Should create a class. */
klass = eo_class_new(&class_desc, 0, NULL, NULL);
klass = eo_class_new(&class_desc, 0, EO_BASE_CLASS, NULL);
fail_if(!klass);
(void) klass;
@ -132,7 +132,7 @@ START_TEST(eo_inherit_errors)
klass_mixin = eo_class_new(&class_desc_mixin, 0, NULL, NULL);
fail_if(!klass_mixin);
klass_simple = eo_class_new(&class_desc_simple, 0, NULL, NULL);
klass_simple = eo_class_new(&class_desc_simple, 0, EO_BASE_CLASS, NULL);
fail_if(!klass_simple);
klass = eo_class_new(&class_desc, 0, klass_simple, NULL);