diff options
author | Markus Armbruster <armbru@redhat.com> | 2017-03-15 13:57:27 +0100 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2017-03-16 07:13:04 +0100 |
commit | a9f396b028bc304fd1c27b2d52b22966cfc98a61 (patch) | |
tree | 80f5025a2abd1b5b2eb653d3c6a8d4e3ad8c1543 /scripts | |
parent | 816a57cd6ebb6fe820766ac12478a56a5fa33d52 (diff) | |
download | qemu-a9f396b028bc304fd1c27b2d52b22966cfc98a61.zip qemu-a9f396b028bc304fd1c27b2d52b22966cfc98a61.tar.gz qemu-a9f396b028bc304fd1c27b2d52b22966cfc98a61.tar.bz2 |
qapi: Eliminate check_docs() and drop QAPIDoc.expr
Move what's left in check_docs() to check_expr(). Delegate the actual
checking to new QAPIDoc.check_expr().
QAPIDoc.expr is now unused; drop it.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <1489582656-31133-39-git-send-email-armbru@redhat.com>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/qapi.py | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/scripts/qapi.py b/scripts/qapi.py index ca9926b..1aaae8e 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -138,8 +138,6 @@ class QAPIDoc(object): self.sections = [] # the current section self.section = self.body - # associated expression (to be set by expression parser) - self.expr = None def has_section(self, name): """Return True if we have a section with this name.""" @@ -249,6 +247,11 @@ class QAPIDoc(object): self.args[member.name] = QAPIDoc.ArgSection(member.name) self.args[member.name].connect(member) + def check_expr(self, expr): + if self.has_section('Returns') and 'command' not in expr: + raise QAPISemError(self.info, + "'Returns:' is only valid for commands") + def check(self): bogus = [name for name, section in self.args.iteritems() if not section.member] @@ -316,7 +319,6 @@ class QAPISchemaParser(object): raise QAPISemError( self.cur_doc.info, "Expression documentation required") - self.cur_doc.expr = expr expr_elem['doc'] = self.cur_doc self.exprs.append(expr_elem) self.cur_doc = None @@ -984,6 +986,7 @@ def check_exprs(exprs): for expr_elem in exprs: expr = expr_elem['expr'] info = expr_elem['info'] + doc = expr_elem.get('doc') if 'enum' in expr: check_enum(expr, info) @@ -1000,20 +1003,10 @@ def check_exprs(exprs): else: assert False, 'unexpected meta type' - return exprs - + if doc: + doc.check_expr(expr) -def check_definition_doc(doc, expr, info): - if doc.has_section('Returns') and 'command' not in expr: - raise QAPISemError(info, "'Returns:' is only valid for commands") - - -def check_docs(docs): - for doc in docs: - if doc.expr: - check_definition_doc(doc, doc.expr, doc.info) - - return docs + return exprs # @@ -1511,7 +1504,7 @@ class QAPISchema(object): try: parser = QAPISchemaParser(open(fname, 'r')) self.exprs = check_exprs(parser.exprs) - self.docs = check_docs(parser.docs) + self.docs = parser.docs self._entity_dict = {} self._predefining = True self._def_predefineds() |