diff --git a/qapi-schema.json b/qapi-schema.json index a386605b6a349153494045d494be8d67a9d65de7..702b7b5dbd4817e06928a8c631956a1d6cbd1090 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3415,6 +3415,17 @@ 'cpuid-register': 'X86CPURegister32', 'features': 'int' } } +## +# @DummyForceArrays +# +# Not used by QMP; hack to let us use X86CPUFeatureWordInfoList internally +# +# Since 2.5 +## +{ 'struct': 'DummyForceArrays', + 'data': { 'unused': ['X86CPUFeatureWordInfo'] } } + + ## # @RxState: # diff --git a/scripts/qapi.py b/scripts/qapi.py index d7cf0f37147459fc35bed562f6f094c0f4ea90a3..9e017050c04e565689c3398bb6328c1ced1a3f6e 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -1143,7 +1143,12 @@ class QAPISchema(object): def _def_builtin_type(self, name, json_type, c_type, c_null): self._def_entity(QAPISchemaBuiltinType(name, json_type, c_type, c_null)) - self._make_array_type(name) # TODO really needed? + # TODO As long as we have QAPI_TYPES_BUILTIN to share multiple + # qapi-types.h from a single .c, all arrays of builtins must be + # declared in the first file whether or not they are used. Nicer + # would be to use lazy instantiation, while figuring out how to + # avoid compilation issues with multiple qapi-types.h. + self._make_array_type(name) def _def_predefineds(self): for t in [('str', 'string', 'char' + pointer_suffix, 'NULL'), @@ -1192,7 +1197,6 @@ class QAPISchema(object): data = expr['data'] prefix = expr.get('prefix') self._def_entity(QAPISchemaEnumType(name, info, data, prefix)) - self._make_array_type(name) # TODO really needed? def _make_member(self, name, typ): optional = False @@ -1215,7 +1219,6 @@ class QAPISchema(object): self._def_entity(QAPISchemaObjectType(name, info, base, self._make_members(data), None)) - self._make_array_type(name) # TODO really needed? def _make_variant(self, case, typ): return QAPISchemaObjectTypeVariant(case, typ) @@ -1251,7 +1254,6 @@ class QAPISchema(object): QAPISchemaObjectTypeVariants(tag_name, tag_enum, variants))) - self._make_array_type(name) # TODO really needed? def _def_alternate_type(self, expr, info): name = expr['alternate'] @@ -1264,7 +1266,6 @@ class QAPISchema(object): QAPISchemaObjectTypeVariants(None, tag_enum, variants))) - self._make_array_type(name) # TODO really needed? def _def_command(self, expr, info): name = expr['command'] diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qapi-schema-test.json index b48c6bd740c5cd17e2b203172c1d56f387ad7707..4e2d7c20630f6a76f3568672ecbab25a1d9b7c2d 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -40,6 +40,10 @@ 'data': { 'string0': 'str', 'dict1': 'UserDefTwoDict' } } +# dummy struct to force generation of array types not otherwise mentioned +{ 'struct': 'ForceArrays', + 'data': { 'unused1':['UserDefOne'], 'unused2':['UserDefTwo'] } } + # for testing unions # Among other things, test that a name collision between branches does # not cause any problems (since only one branch can be in use at a time), diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qapi-schema-test.out index 93f62503e7e2b56c9fe18f93f89807fe51f485bf..a6c80e04d7a6a4121536585d39ae2ef18b7cf00b 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -86,6 +86,9 @@ object EventStructOne member struct1: UserDefOne optional=False member string: str optional=False member enum2: EnumOne optional=True +object ForceArrays + member unused1: UserDefOneList optional=False + member unused2: UserDefTwoList optional=False enum MyEnum [] object NestedEnumsOne member enum1: EnumOne optional=False