[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH for-2.9 38/47] qapi: Eliminate check_docs() and drop
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] [PATCH for-2.9 38/47] qapi: Eliminate check_docs() and drop QAPIDoc.expr |
Date: |
Mon, 13 Mar 2017 07:18:38 +0100 |
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 <address@hidden>
---
scripts/qapi.py | 27 ++++++++++-----------------
1 file changed, 10 insertions(+), 17 deletions(-)
diff --git a/scripts/qapi.py b/scripts/qapi.py
index 0b0ba59..0da426a 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]
@@ -311,7 +314,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
@@ -979,6 +981,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)
@@ -995,22 +998,12 @@ def check_exprs(exprs):
else:
assert False, 'unexpected meta type'
+ if doc:
+ doc.check_expr(expr)
+
return exprs
-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
-
-
#
# Schema compiler frontend
#
@@ -1506,7 +1499,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()
--
2.7.4
- Re: [Qemu-devel] [PATCH for-2.9 32/47] qapi: Move detection of doc / expression name mismatch, (continued)
- [Qemu-devel] [PATCH for-2.9 40/47] qapi: Simplify what gets stored in enum_types, Markus Armbruster, 2017/03/13
- [Qemu-devel] [PATCH for-2.9 33/47] qapi: Improve error message on @NAME: in free-form doc, Markus Armbruster, 2017/03/13
- [Qemu-devel] [PATCH for-2.9 43/47] qapi: struct_types is a list used like a dict, make it one, Markus Armbruster, 2017/03/13
- [Qemu-devel] [PATCH for-2.9 44/47] qapi: union_types is a list used like a dict, make it one, Markus Armbruster, 2017/03/13
- [Qemu-devel] [PATCH for-2.9 38/47] qapi: Eliminate check_docs() and drop QAPIDoc.expr,
Markus Armbruster <=
- [Qemu-devel] [PATCH for-2.9 35/47] tests/qapi-schema: Rename doc-bad-args to doc-bad-command-arg, Markus Armbruster, 2017/03/13
- [Qemu-devel] [PATCH for-2.9 34/47] qapi: Move empty doc section checking to doc parser, Markus Armbruster, 2017/03/13
- Re: [Qemu-devel] [PATCH for-2.9 34/47] qapi: Move empty doc section checking to doc parser, Eric Blake, 2017/03/14
- [Qemu-devel] [PATCH for-2.9 31/47] qapi: Fix detection of doc / expression mismatch, Markus Armbruster, 2017/03/13