qapi: Assert .visit() and .check_clash() run only after .check()

Easy since the previous commit provides .checked.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20190914153506.2151-20-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
Markus Armbruster 2019-09-14 17:35:06 +02:00
parent f9d1743b9b
commit 56176412e7
1 changed files with 10 additions and 1 deletions

View File

@ -1190,7 +1190,7 @@ def is_implicit(self):
return not self.info
def visit(self, visitor):
pass
assert self._checked
class QAPISchemaVisitor(object):
@ -1245,6 +1245,7 @@ def __init__(self, fname, info):
self.fname = fname
def visit(self, visitor):
QAPISchemaEntity.visit(self, visitor)
visitor.visit_include(self.fname, self.info)
@ -1309,6 +1310,7 @@ def doc_type(self):
return self.json_type()
def visit(self, visitor):
QAPISchemaType.visit(self, visitor)
visitor.visit_builtin_type(self.name, self.info, self.json_type())
@ -1344,6 +1346,7 @@ def json_type(self):
return 'string'
def visit(self, visitor):
QAPISchemaType.visit(self, visitor)
visitor.visit_enum_type(self.name, self.info, self.ifcond,
self.members, self.prefix)
@ -1386,6 +1389,7 @@ def doc_type(self):
return 'array of ' + elt_doc_type
def visit(self, visitor):
QAPISchemaType.visit(self, visitor)
visitor.visit_array_type(self.name, self.info, self.ifcond,
self.element_type)
@ -1461,6 +1465,7 @@ def check(self, schema):
# and update seen to track the members seen so far. Report any errors
# on behalf of info, which is not necessarily self.info
def check_clash(self, info, seen):
assert self._checked
assert not self.variants # not implemented
for m in self.members:
m.check_clash(info, seen)
@ -1498,6 +1503,7 @@ def json_type(self):
return 'object'
def visit(self, visitor):
QAPISchemaType.visit(self, visitor)
visitor.visit_object_type(self.name, self.info, self.ifcond,
self.base, self.local_members, self.variants,
self.features)
@ -1665,6 +1671,7 @@ def json_type(self):
return 'value'
def visit(self, visitor):
QAPISchemaType.visit(self, visitor)
visitor.visit_alternate_type(self.name, self.info, self.ifcond,
self.variants)
@ -1698,6 +1705,7 @@ def check(self, schema):
assert isinstance(self.ret_type, QAPISchemaType)
def visit(self, visitor):
QAPISchemaEntity.visit(self, visitor)
visitor.visit_command(self.name, self.info, self.ifcond,
self.arg_type, self.ret_type,
self.gen, self.success_response,
@ -1723,6 +1731,7 @@ def check(self, schema):
raise QAPISemError(self.info, "Use of 'boxed' requires 'data'")
def visit(self, visitor):
QAPISchemaEntity.visit(self, visitor)
visitor.visit_event(self.name, self.info, self.ifcond,
self.arg_type, self.boxed)