qom/object: add some interface asserts

An interface can't have any instance size or callback, or itself
implement other interfaces (this is unsupported).

Backports commit 422ca1432f7b44f2a9f3ad94a65d36927da021fa from qemu
This commit is contained in:
Marc-André Lureau 2018-10-04 04:28:37 -04:00 committed by Lioncash
parent 752aea8379
commit 710467e034
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7

View file

@ -273,7 +273,18 @@ static void type_initialize(struct uc_struct *uc, TypeImpl *ti)
ti->class_size = type_class_get_size(uc, ti);
ti->instance_size = type_object_get_size(uc, ti);
if (ti->instance_size == 0) {
ti->abstract = true;
}
if (type_is_ancestor(uc, ti, uc->type_interface)) {
assert(ti->instance_size == 0);
assert(ti->abstract);
assert(!ti->instance_init);
assert(!ti->instance_post_init);
assert(!ti->instance_finalize);
assert(!ti->num_interfaces);
}
ti->class = g_malloc0(ti->class_size);
parent = type_get_parent(uc, ti);