diff options
| author | Peter Maydell <peter.maydell@linaro.org> | 2014-05-19 14:10:00 +0100 |
|---|---|---|
| committer | Peter Maydell <peter.maydell@linaro.org> | 2014-05-19 14:10:01 +0100 |
| commit | c5fa6c86d0765f837515d1c10654c621724a77e0 (patch) | |
| tree | f7d52e821b4983ef18a57dce08c7b7c6cf97f115 /scripts/qapi.py | |
| parent | 5bc8f026dd5eb76c89395933d38dc5b0cebf5763 (diff) | |
| parent | 24fd848950b44de7e2d71fb69ba52b90d6acb220 (diff) | |
| download | focaccia-qemu-c5fa6c86d0765f837515d1c10654c621724a77e0.tar.gz focaccia-qemu-c5fa6c86d0765f837515d1c10654c621724a77e0.zip | |
Merge remote-tracking branch 'remotes/qmp-unstable/queue/qmp' into staging
* remotes/qmp-unstable/queue/qmp: qapi: skip redundant includes monitor: Add netdev_del id argument completion. monitor: Add netdev_add type argument completion. monitor: Add set_link arguments completion. monitor: Add chardev-add backend argument completion. monitor: Add chardev-remove command completion. monitor: Convert sendkey to use command_completion. qapi: Show qapi-commands.py invocation in qapi-code-gen.txt qapi: Replace uncommon use of the error API by the common one tests: Don't call visit_end_struct() after visit_start_struct() fails hw: Don't call visit_end_struct() after visit_start_struct() fails hmp: Call visit_end_struct() after visit_start_struct() succeeds qapi: Un-inline visit of implicit struct qapi-visit.py: Clean up a sloppy use of field prefix qapi: Clean up shadowing of parameters and locals in inner scopes qapi-visit.py: Clean up confusing push_indent() / pop_indent() use qapi: Replace start_optional()/end_optional() by optional() qapi: Remove unused Visitor callbacks start_handle(), end_handle() qapi: Normalize marshalling's visitor initialization and cleanup qapi: Update qapi-code-gen.txt example to match current code Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'scripts/qapi.py')
| -rw-r--r-- | scripts/qapi.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/scripts/qapi.py b/scripts/qapi.py index ec806aabeb..0265b404dd 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -73,13 +73,18 @@ class QAPIExprError(Exception): class QAPISchema: - def __init__(self, fp, input_relname=None, include_hist=[], parent_info=None): + def __init__(self, fp, input_relname=None, include_hist=[], + previously_included=[], parent_info=None): + """ include_hist is a stack used to detect inclusion cycles + previously_included is a global state used to avoid multiple + inclusions of the same file""" input_fname = os.path.abspath(fp.name) if input_relname is None: input_relname = fp.name self.input_dir = os.path.dirname(input_fname) self.input_file = input_relname self.include_hist = include_hist + [(input_relname, input_fname)] + previously_included.append(input_fname) self.parent_info = parent_info self.src = fp.read() if self.src == '' or self.src[-1] != '\n': @@ -106,13 +111,16 @@ class QAPISchema: for elem in self.include_hist): raise QAPIExprError(expr_info, "Inclusion loop for %s" % include) + # skip multiple include of the same file + if include_path in previously_included: + continue try: fobj = open(include_path, 'r') except IOError as e: raise QAPIExprError(expr_info, '%s: %s' % (e.strerror, include)) - exprs_include = QAPISchema(fobj, include, - self.include_hist, expr_info) + exprs_include = QAPISchema(fobj, include, self.include_hist, + previously_included, expr_info) self.exprs.extend(exprs_include.exprs) else: expr_elem = {'expr': expr, |