mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-29 05:13:54 -06:00
qapi: Make cur_doc local to QAPISchemaParser.__init__()
QAPISchemaParser.cur_doc is used only by .__init__() and its helper .reject_expr_doc(). Make it local to __init__() and pass it to .reject_expr_doc() explicitly. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20171002141341.24616-5-armbru@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
parent
2281d00c3d
commit
64d6033b20
1 changed files with 17 additions and 17 deletions
|
@ -272,21 +272,21 @@ class QAPISchemaParser(object):
|
||||||
self.line_pos = 0
|
self.line_pos = 0
|
||||||
self.exprs = []
|
self.exprs = []
|
||||||
self.docs = []
|
self.docs = []
|
||||||
self.cur_doc = None
|
|
||||||
self.accept()
|
self.accept()
|
||||||
|
cur_doc = None
|
||||||
|
|
||||||
while self.tok is not None:
|
while self.tok is not None:
|
||||||
info = {'file': self.fname, 'line': self.line,
|
info = {'file': self.fname, 'line': self.line,
|
||||||
'parent': self.incl_info}
|
'parent': self.incl_info}
|
||||||
if self.tok == '#':
|
if self.tok == '#':
|
||||||
self.reject_expr_doc()
|
self.reject_expr_doc(cur_doc)
|
||||||
self.cur_doc = self.get_doc(info)
|
cur_doc = self.get_doc(info)
|
||||||
self.docs.append(self.cur_doc)
|
self.docs.append(cur_doc)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
expr = self.get_expr(False)
|
expr = self.get_expr(False)
|
||||||
if 'include' in expr:
|
if 'include' in expr:
|
||||||
self.reject_expr_doc()
|
self.reject_expr_doc(cur_doc)
|
||||||
if len(expr) != 1:
|
if len(expr) != 1:
|
||||||
raise QAPISemError(info, "Invalid 'include' directive")
|
raise QAPISemError(info, "Invalid 'include' directive")
|
||||||
include = expr['include']
|
include = expr['include']
|
||||||
|
@ -296,7 +296,7 @@ class QAPISchemaParser(object):
|
||||||
self._include(include, info, os.path.dirname(abs_fname),
|
self._include(include, info, os.path.dirname(abs_fname),
|
||||||
previously_included)
|
previously_included)
|
||||||
elif "pragma" in expr:
|
elif "pragma" in expr:
|
||||||
self.reject_expr_doc()
|
self.reject_expr_doc(cur_doc)
|
||||||
if len(expr) != 1:
|
if len(expr) != 1:
|
||||||
raise QAPISemError(info, "Invalid 'pragma' directive")
|
raise QAPISemError(info, "Invalid 'pragma' directive")
|
||||||
pragma = expr['pragma']
|
pragma = expr['pragma']
|
||||||
|
@ -308,22 +308,22 @@ class QAPISchemaParser(object):
|
||||||
else:
|
else:
|
||||||
expr_elem = {'expr': expr,
|
expr_elem = {'expr': expr,
|
||||||
'info': info}
|
'info': info}
|
||||||
if self.cur_doc:
|
if cur_doc:
|
||||||
if not self.cur_doc.symbol:
|
if not cur_doc.symbol:
|
||||||
raise QAPISemError(
|
raise QAPISemError(
|
||||||
self.cur_doc.info,
|
cur_doc.info, "Expression documentation required")
|
||||||
"Expression documentation required")
|
expr_elem['doc'] = cur_doc
|
||||||
expr_elem['doc'] = self.cur_doc
|
|
||||||
self.exprs.append(expr_elem)
|
self.exprs.append(expr_elem)
|
||||||
self.cur_doc = None
|
cur_doc = None
|
||||||
self.reject_expr_doc()
|
self.reject_expr_doc(cur_doc)
|
||||||
|
|
||||||
def reject_expr_doc(self):
|
@staticmethod
|
||||||
if self.cur_doc and self.cur_doc.symbol:
|
def reject_expr_doc(doc):
|
||||||
|
if doc and doc.symbol:
|
||||||
raise QAPISemError(
|
raise QAPISemError(
|
||||||
self.cur_doc.info,
|
doc.info,
|
||||||
"Documentation for '%s' is not followed by the definition"
|
"Documentation for '%s' is not followed by the definition"
|
||||||
% self.cur_doc.symbol)
|
% doc.symbol)
|
||||||
|
|
||||||
def _include(self, include, info, base_dir, previously_included):
|
def _include(self, include, info, base_dir, previously_included):
|
||||||
incl_abs_fname = os.path.join(base_dir, include)
|
incl_abs_fname = os.path.join(base_dir, include)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue