summaryrefslogtreecommitdiff
path: root/legacy/eobj
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2012-06-11 07:35:02 +0000
committerTom Hacohen <tom@stosb.com>2012-06-11 07:35:02 +0000
commitbc42fd3c1eb515c7d5186f91c30d310c89d1a418 (patch)
tree8b1c7600bf633c3d54bb76c105046d489f39ae3f /legacy/eobj
parentc74cf7666d8dfa8283d6e6b285ddf65bbd1f73ef (diff)
Eo: Force classes to inherit from EO_BASE_CLASS.
SVN revision: 71931
Diffstat (limited to 'legacy/eobj')
-rw-r--r--legacy/eobj/src/lib/eo.c17
-rw-r--r--legacy/eobj/src/tests/eo_suite/eo_test_class_errors.c4
2 files changed, 19 insertions, 2 deletions
diff --git a/legacy/eobj/src/lib/eo.c b/legacy/eobj/src/lib/eo.c
index 4f8d73863c..42f5f3d990 100644
--- a/legacy/eobj/src/lib/eo.c
+++ b/legacy/eobj/src/lib/eo.c
@@ -941,6 +941,23 @@ eo_class_new(const Eo_Class_Description *desc, Eo_Class_Id id, const Eo_Class *p
941 klass->data_offset = klass->parent->data_offset + 941 klass->data_offset = klass->parent->data_offset +
942 EO_ALIGN_SIZE(klass->parent->desc->data_size); 942 EO_ALIGN_SIZE(klass->parent->desc->data_size);
943 } 943 }
944 /* EO_BASE_CLASS is allowed not to have a parent. */
945 else if (id != EO_BASE_CLASS_ID)
946 {
947 /* No parent. */
948 switch (klass->desc->type)
949 {
950 case EO_CLASS_TYPE_REGULAR:
951 case EO_CLASS_TYPE_REGULAR_NO_INSTANT:
952 ERR("Regular classes ('%s') must inherit from EO_BASE_CLASS.", klass->desc->name);
953 goto cleanup;
954 break;
955 case EO_CLASS_TYPE_INTERFACE:
956 case EO_CLASS_TYPE_MIXIN:
957 /* Do nothing. */
958 break;
959 }
960 }
944 961
945 if (!_eo_class_check_op_descs(klass, id)) 962 if (!_eo_class_check_op_descs(klass, id))
946 { 963 {
diff --git a/legacy/eobj/src/tests/eo_suite/eo_test_class_errors.c b/legacy/eobj/src/tests/eo_suite/eo_test_class_errors.c
index 4f503361f1..c7b9c70006 100644
--- a/legacy/eobj/src/tests/eo_suite/eo_test_class_errors.c
+++ b/legacy/eobj/src/tests/eo_suite/eo_test_class_errors.c
@@ -82,7 +82,7 @@ START_TEST(eo_incomplete_desc)
82 fail_if(klass); 82 fail_if(klass);
83 83
84 /* Should create a class. */ 84 /* Should create a class. */
85 klass = eo_class_new(&class_desc, 0, NULL, NULL); 85 klass = eo_class_new(&class_desc, 0, EO_BASE_CLASS, NULL);
86 fail_if(!klass); 86 fail_if(!klass);
87 87
88 (void) klass; 88 (void) klass;
@@ -132,7 +132,7 @@ START_TEST(eo_inherit_errors)
132 klass_mixin = eo_class_new(&class_desc_mixin, 0, NULL, NULL); 132 klass_mixin = eo_class_new(&class_desc_mixin, 0, NULL, NULL);
133 fail_if(!klass_mixin); 133 fail_if(!klass_mixin);
134 134
135 klass_simple = eo_class_new(&class_desc_simple, 0, NULL, NULL); 135 klass_simple = eo_class_new(&class_desc_simple, 0, EO_BASE_CLASS, NULL);
136 fail_if(!klass_simple); 136 fail_if(!klass_simple);
137 137
138 klass = eo_class_new(&class_desc, 0, klass_simple, NULL); 138 klass = eo_class_new(&class_desc, 0, klass_simple, NULL);