mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 20:33:54 -06:00
qapi: Fix array first used in a different module
We generally put implicitly defined types in whatever module triggered their definition. This is wrong for array types, as the included test case demonstrates. Let's have a closer look at it. Type 'Status' is defined sub-sub-module.json. Array type ['Status'] occurs in main module qapi-schema-test.json and in include/sub-module.json. The main module's use is first, so the array type gets put into the main module. The generated C headers define StatusList in qapi-types.h. But include/qapi-types-sub-module.h uses it without including qapi-types.h. Oops. To fix that, put the array type into its element type's module. Now StatusList gets generated into qapi-types-sub-module.h, which all its users include. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20190301154051.23317-8-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
5e12eb987b
commit
56a4689582
3 changed files with 12 additions and 4 deletions
|
@ -1089,6 +1089,9 @@ class QAPISchemaEntity(object):
|
|||
self.ifcond = typ.ifcond
|
||||
else:
|
||||
self.ifcond = listify_cond(self._ifcond)
|
||||
if self.info:
|
||||
self.module = os.path.relpath(self.info['file'],
|
||||
os.path.dirname(schema.fname))
|
||||
|
||||
def is_implicit(self):
|
||||
return not self.info
|
||||
|
@ -1262,6 +1265,7 @@ class QAPISchemaArrayType(QAPISchemaType):
|
|||
self.element_type = schema.lookup_type(self._element_type_name)
|
||||
assert self.element_type
|
||||
self.element_type.check(schema)
|
||||
self.module = self.element_type.module
|
||||
self.ifcond = self.element_type.ifcond
|
||||
|
||||
def is_implicit(self):
|
||||
|
@ -1603,7 +1607,7 @@ class QAPISchemaEvent(QAPISchemaEntity):
|
|||
|
||||
class QAPISchema(object):
|
||||
def __init__(self, fname):
|
||||
self._fname = fname
|
||||
self.fname = fname
|
||||
if sys.version_info[0] >= 3:
|
||||
f = open(fname, 'r', encoding='utf-8')
|
||||
else:
|
||||
|
@ -1626,9 +1630,6 @@ class QAPISchema(object):
|
|||
self._entity_list.append(ent)
|
||||
if ent.name is not None:
|
||||
self._entity_dict[ent.name] = ent
|
||||
if ent.info:
|
||||
ent.module = os.path.relpath(ent.info['file'],
|
||||
os.path.dirname(self._fname))
|
||||
|
||||
def lookup_entity(self, name, typ=None):
|
||||
ent = self._entity_dict.get(name)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue