Skip to contentSkip to conversation

qom/object: add some interface asserts

PATCH New Marc-André Lureau 1 participant 1 message Sep 12, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qom/object: add some interface asserts

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

---
 qom/object.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
qom/object.c +8 -1
index 75d1d48944..9222b23172 100644
@@ -286,7 +286,14 @@ static void type_initialize(TypeImpl *ti)
     if (ti->instance_size == 0) {
         ti->abstract = true;
     }
-
+    if (type_is_ancestor(ti, 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(ti);
Signature · 1 line
2.19.0.rc1