From: tasn Date: Mon, 11 Jun 2012 07:35:02 +0000 (+0000) Subject: Eo: Force classes to inherit from EO_BASE_CLASS. X-Git-Tag: submit/2.0alpha-wayland/20121127.222020~70 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8d5c32afb6f79c43e54e32377145444b7a3d5194;p=profile%2Fivi%2Feobj.git Eo: Force classes to inherit from EO_BASE_CLASS. git-svn-id: http://svn.enlightenment.org/svn/e/trunk/PROTO/eobj@71931 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/lib/eo.c b/src/lib/eo.c index 4f8d738..42f5f3d 100644 --- a/src/lib/eo.c +++ b/src/lib/eo.c @@ -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)) { diff --git a/src/tests/eo_suite/eo_test_class_errors.c b/src/tests/eo_suite/eo_test_class_errors.c index 4f50336..c7b9c70 100644 --- a/src/tests/eo_suite/eo_test_class_errors.c +++ b/src/tests/eo_suite/eo_test_class_errors.c @@ -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);