diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2019-03-05 19:23:45 +0000 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2019-03-05 19:23:45 +0000 |
commit | a3e3b0a7bd5de211a62cdf2d6c12b96d3c403560 (patch) | |
tree | b6c5f9492569c8840f61633c02e4aa326dda0aa4 | |
parent | c99b58326d92034a00003c4f2e019f662c3dbee5 (diff) | |
parent | 56a4689582433125d7042ba506a081e08dc264d4 (diff) |
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2019-03-05' into staging
QAPI patches for 2019-03-05
# gpg: Signature made Tue 05 Mar 2019 16:47:17 GMT
# gpg: using RSA key 3870B400EB918653
# gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full]
# gpg: aka "Markus Armbruster <armbru@pond.sub.org>" [full]
# Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867 4E5F 3870 B400 EB91 8653
* remotes/armbru/tags/pull-qapi-2019-03-05:
qapi: Fix array first used in a different module
tests/qapi-schema: Cover forward reference to sub-module
tests: Rename UserDefNativeListUnion to UserDefListUnion
qapi: Fix code generation for sub-modules in other directories
qapi: Pass file name to QAPIGen constructor instead of methods
tests/qapi-schema: Cover conditional arrays
tests/qapi-schema: Make test-qapi.py print arrays
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r-- | scripts/qapi/commands.py | 2 | ||||
-rw-r--r-- | scripts/qapi/common.py | 106 | ||||
-rwxr-xr-x | scripts/qapi/doc.py | 4 | ||||
-rw-r--r-- | tests/.gitignore | 8 | ||||
-rw-r--r-- | tests/Makefile.include | 44 | ||||
-rw-r--r-- | tests/qapi-schema/include-relpath-sub.json | 2 | ||||
-rw-r--r-- | tests/qapi-schema/include-relpath.err | 0 | ||||
-rw-r--r-- | tests/qapi-schema/include-relpath.exit | 1 | ||||
-rw-r--r-- | tests/qapi-schema/include-relpath.json | 1 | ||||
-rw-r--r-- | tests/qapi-schema/include-relpath.out | 20 | ||||
-rw-r--r-- | tests/qapi-schema/include/relpath.json | 1 | ||||
-rw-r--r-- | tests/qapi-schema/include/sub-module.json | 7 | ||||
-rw-r--r-- | tests/qapi-schema/qapi-schema-test.json | 14 | ||||
-rw-r--r-- | tests/qapi-schema/qapi-schema-test.out | 37 | ||||
-rw-r--r-- | tests/qapi-schema/sub-sub-module.json | 6 | ||||
-rw-r--r-- | tests/qapi-schema/test-qapi.py | 6 | ||||
-rw-r--r-- | tests/test-clone-visitor.c | 16 | ||||
-rw-r--r-- | tests/test-qmp-cmds.c | 2 | ||||
-rw-r--r-- | tests/test-qobject-input-visitor.c | 196 | ||||
-rw-r--r-- | tests/test-qobject-output-visitor.c | 190 |
20 files changed, 371 insertions, 292 deletions
diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py index ebf488953d..6d66bf6aa3 100644 --- a/scripts/qapi/commands.py +++ b/scripts/qapi/commands.py @@ -239,7 +239,7 @@ class QAPISchemaGenCommandVisitor(QAPISchemaModularCVisitor): QAPISchemaModularCVisitor.__init__( self, prefix, 'qapi-commands', ' * Schema-defined QAPI/QMP commands', __doc__) - self._regy = QAPIGenCCode() + self._regy = QAPIGenCCode(None) self._visited_ret_types = {} def _begin_user_module(self, name): diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index c327ae5036..f07869ec73 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -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) @@ -2017,8 +2018,8 @@ def mcgen(code, **kwds): return cgen(code, **kwds) -def guardname(filename): - return re.sub(r'[^A-Za-z0-9_]', '_', filename).upper() +def c_fname(filename): + return re.sub(r'[^A-Za-z0-9_]', '_', filename) def guardstart(name): @@ -2027,7 +2028,7 @@ def guardstart(name): #define %(name)s ''', - name=guardname(name)) + name=c_fname(name).upper()) def guardend(name): @@ -2035,7 +2036,7 @@ def guardend(name): #endif /* %(name)s */ ''', - name=guardname(name)) + name=c_fname(name).upper()) def gen_if(ifcond): @@ -2158,7 +2159,8 @@ def build_params(arg_type, boxed, extra=None): class QAPIGen(object): - def __init__(self): + def __init__(self, fname): + self.fname = fname self._preamble = '' self._body = '' @@ -2168,18 +2170,17 @@ class QAPIGen(object): def add(self, text): self._body += text - def get_content(self, fname=None): - return (self._top(fname) + self._preamble + self._body - + self._bottom(fname)) + def get_content(self): + return self._top() + self._preamble + self._body + self._bottom() - def _top(self, fname): + def _top(self): return '' - def _bottom(self, fname): + def _bottom(self): return '' - def write(self, output_dir, fname): - pathname = os.path.join(output_dir, fname) + def write(self, output_dir): + pathname = os.path.join(output_dir, self.fname) dir = os.path.dirname(pathname) if dir: try: @@ -2192,7 +2193,7 @@ class QAPIGen(object): f = open(fd, 'r+', encoding='utf-8') else: f = os.fdopen(fd, 'r+') - text = self.get_content(fname) + text = self.get_content() oldtext = f.read(len(text) + 1) if text != oldtext: f.seek(0) @@ -2229,8 +2230,8 @@ def ifcontext(ifcond, *args): class QAPIGenCCode(QAPIGen): - def __init__(self): - QAPIGen.__init__(self) + def __init__(self, fname): + QAPIGen.__init__(self, fname) self._start_if = None def start_if(self, ifcond): @@ -2248,20 +2249,20 @@ class QAPIGenCCode(QAPIGen): self._preamble = _wrap_ifcond(self._start_if[0], self._start_if[2], self._preamble) - def get_content(self, fname=None): + def get_content(self): assert self._start_if is None - return QAPIGen.get_content(self, fname) + return QAPIGen.get_content(self) class QAPIGenC(QAPIGenCCode): - def __init__(self, blurb, pydoc): - QAPIGenCCode.__init__(self) + def __init__(self, fname, blurb, pydoc): + QAPIGenCCode.__init__(self, fname) self._blurb = blurb self._copyright = '\n * '.join(re.findall(r'^Copyright .*', pydoc, re.MULTILINE)) - def _top(self, fname): + def _top(self): return mcgen(''' /* AUTOMATICALLY GENERATED, DO NOT MODIFY */ @@ -2277,28 +2278,28 @@ class QAPIGenC(QAPIGenCCode): ''', blurb=self._blurb, copyright=self._copyright) - def _bottom(self, fname): + def _bottom(self): return mcgen(''' /* Dummy declaration to prevent empty .o file */ -char dummy_%(name)s; +char qapi_dummy_%(name)s; ''', - name=c_name(fname)) + name=c_fname(self.fname)) class QAPIGenH(QAPIGenC): - def _top(self, fname): - return QAPIGenC._top(self, fname) + guardstart(fname) + def _top(self): + return QAPIGenC._top(self) + guardstart(self.fname) - def _bottom(self, fname): - return guardend(fname) + def _bottom(self): + return guardend(self.fname) class QAPIGenDoc(QAPIGen): - def _top(self, fname): - return (QAPIGen._top(self, fname) + def _top(self): + return (QAPIGen._top(self) + '@c AUTOMATICALLY GENERATED, DO NOT MODIFY\n\n') @@ -2307,12 +2308,14 @@ class QAPISchemaMonolithicCVisitor(QAPISchemaVisitor): def __init__(self, prefix, what, blurb, pydoc): self._prefix = prefix self._what = what - self._genc = QAPIGenC(blurb, pydoc) - self._genh = QAPIGenH(blurb, pydoc) + self._genc = QAPIGenC(self._prefix + self._what + '.c', + blurb, pydoc) + self._genh = QAPIGenH(self._prefix + self._what + '.h', + blurb, pydoc) def write(self, output_dir): - self._genc.write(output_dir, self._prefix + self._what + '.c') - self._genh.write(output_dir, self._prefix + self._what + '.h') + self._genc.write(output_dir) + self._genh.write(output_dir) class QAPISchemaModularCVisitor(QAPISchemaVisitor): @@ -2335,22 +2338,31 @@ class QAPISchemaModularCVisitor(QAPISchemaVisitor): def _is_builtin_module(name): return not name + def _module_dirname(self, what, name): + if self._is_user_module(name): + return os.path.dirname(name) + return '' + def _module_basename(self, what, name): ret = '' if self._is_builtin_module(name) else self._prefix if self._is_user_module(name): - dirname, basename = os.path.split(name) + basename = os.path.basename(name) ret += what if name != self._main_module: ret += '-' + os.path.splitext(basename)[0] - ret = os.path.join(dirname, ret) else: name = name[2:] if name else 'builtin' ret += re.sub(r'-', '-' + name + '-', what) return ret + def _module_filename(self, what, name): + return os.path.join(self._module_dirname(what, name), + self._module_basename(what, name)) + def _add_module(self, name, blurb): - genc = QAPIGenC(blurb, self._pydoc) - genh = QAPIGenH(blurb, self._pydoc) + basename = self._module_filename(self._what, name) + genc = QAPIGenC(basename + '.c', blurb, self._pydoc) + genh = QAPIGenH(basename + '.h', blurb, self._pydoc) self._module[name] = (genc, genh) self._set_module(name) @@ -2370,10 +2382,9 @@ class QAPISchemaModularCVisitor(QAPISchemaVisitor): for name in self._module: if self._is_builtin_module(name) and not opt_builtins: continue - basename = self._module_basename(self._what, name) (genc, genh) = self._module[name] - genc.write(output_dir, basename + '.c') - genh.write(output_dir, basename + '.h') + genc.write(output_dir) + genh.write(output_dir) def _begin_user_module(self, name): pass @@ -2391,8 +2402,9 @@ class QAPISchemaModularCVisitor(QAPISchemaVisitor): self._begin_user_module(name) def visit_include(self, name, info): - basename = self._module_basename(self._what, name) + relname = os.path.relpath(self._module_filename(self._what, name), + os.path.dirname(self._genh.fname)) self._genh.preamble_add(mcgen(''' -#include "%(basename)s.h" +#include "%(relname)s.h" ''', - basename=basename)) + relname=relname)) diff --git a/scripts/qapi/doc.py b/scripts/qapi/doc.py index c03b690161..5c8c136899 100755 --- a/scripts/qapi/doc.py +++ b/scripts/qapi/doc.py @@ -207,11 +207,11 @@ def texi_entity(doc, what, ifcond, base=None, variants=None, class QAPISchemaGenDocVisitor(qapi.common.QAPISchemaVisitor): def __init__(self, prefix): self._prefix = prefix - self._gen = qapi.common.QAPIGenDoc() + self._gen = qapi.common.QAPIGenDoc(self._prefix + 'qapi-doc.texi') self.cur_doc = None def write(self, output_dir): - self._gen.write(output_dir, self._prefix + 'qapi-doc.texi') + self._gen.write(output_dir) def visit_enum_type(self, name, info, ifcond, members, prefix): doc = self.cur_doc diff --git a/tests/.gitignore b/tests/.gitignore index f2bf85c8c4..c88f8f2537 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -12,9 +12,17 @@ test-* !test-*.c !docker/test-* test-qapi-commands.[ch] +include/test-qapi-commands-sub-module.[ch] +test-qapi-commands-sub-sub-module.[ch] test-qapi-events.[ch] +include/test-qapi-events-sub-module.[ch] +test-qapi-events-sub-sub-module.[ch] test-qapi-types.[ch] +include/test-qapi-types-sub-module.[ch] +test-qapi-types-sub-sub-module.[ch] test-qapi-visit.[ch] +include/test-qapi-visit-sub-module.[ch] +test-qapi-visit-sub-sub-module.[ch] test-qapi-introspect.[ch] *-test qapi-schema/*.test.* diff --git a/tests/Makefile.include b/tests/Makefile.include index 5527581f67..97e1cb90a3 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -441,7 +441,6 @@ qapi-schema += include-format-err.json qapi-schema += include-nested-err.json qapi-schema += include-no-file.json qapi-schema += include-non-file.json -qapi-schema += include-relpath.json qapi-schema += include-repetition.json qapi-schema += include-self-cycle.json qapi-schema += include-simple.json @@ -508,8 +507,18 @@ qapi-schema += unknown-expr-key.json check-qapi-schema-y := $(addprefix tests/qapi-schema/, $(qapi-schema)) -GENERATED_FILES += tests/test-qapi-types.h tests/test-qapi-visit.h \ - tests/test-qapi-commands.h tests/test-qapi-events.h \ +GENERATED_FILES += tests/test-qapi-types.h \ + tests/include/test-qapi-types-sub-module.h \ + tests/test-qapi-types-sub-sub-module.h \ + tests/test-qapi-visit.h \ + tests/include/test-qapi-visit-sub-module.h \ + tests/test-qapi-visit-sub-sub-module.h \ + tests/test-qapi-commands.h \ + tests/include/test-qapi-commands-sub-module.h \ + tests/test-qapi-commands-sub-sub-module.h \ + tests/test-qapi-events.h \ + tests/include/test-qapi-events-sub-module.h \ + tests/test-qapi-events-sub-sub-module.h \ tests/test-qapi-introspect.h test-obj-y = tests/check-qnum.o tests/check-qstring.o tests/check-qdict.o \ @@ -537,7 +546,12 @@ QEMU_CFLAGS += -I$(SRC_PATH)/tests # Deps that are common to various different sets of tests below test-util-obj-y = libqemuutil.a test-qom-obj-y = $(qom-obj-y) $(test-util-obj-y) -test-qapi-obj-y = tests/test-qapi-visit.o tests/test-qapi-types.o \ +test-qapi-obj-y = tests/test-qapi-types.o \ + tests/include/test-qapi-types-sub-module.o \ + tests/test-qapi-types-sub-sub-module.o \ + tests/test-qapi-visit.o \ + tests/include/test-qapi-visit-sub-module.o \ + tests/test-qapi-visit-sub-sub-module.o \ tests/test-qapi-introspect.o \ $(test-qom-obj-y) benchmark-crypto-obj-y = $(authz-obj-y) $(crypto-obj-y) $(test-qom-obj-y) @@ -613,12 +627,32 @@ tests/test-replication$(EXESUF): tests/test-replication.o $(test-util-obj-y) \ $(test-block-obj-y) tests/test-qapi-types.c tests/test-qapi-types.h \ +tests/include/test-qapi-types-sub-module.c \ +tests/include/test-qapi-types-sub-module.h \ +tests/test-qapi-types-sub-sub-module.c \ +tests/test-qapi-types-sub-sub-module.h \ tests/test-qapi-visit.c tests/test-qapi-visit.h \ +tests/include/test-qapi-visit-sub-module.c \ +tests/include/test-qapi-visit-sub-module.h \ +tests/test-qapi-visit-sub-sub-module.c \ +tests/test-qapi-visit-sub-sub-module.h \ tests/test-qapi-commands.h tests/test-qapi-commands.c \ +tests/include/test-qapi-commands-sub-module.h \ +tests/include/test-qapi-commands-sub-module.c \ +tests/test-qapi-commands-sub-sub-module.h \ +tests/test-qapi-commands-sub-sub-module.c \ tests/test-qapi-events.c tests/test-qapi-events.h \ +tests/include/test-qapi-events-sub-module.c \ +tests/include/test-qapi-events-sub-module.h \ +tests/test-qapi-events-sub-sub-module.c \ +tests/test-qapi-events-sub-sub-module.h \ tests/test-qapi-introspect.c tests/test-qapi-introspect.h: \ tests/test-qapi-gen-timestamp ; -tests/test-qapi-gen-timestamp: $(SRC_PATH)/tests/qapi-schema/qapi-schema-test.json $(qapi-py) +tests/test-qapi-gen-timestamp: \ + $(SRC_PATH)/tests/qapi-schema/qapi-schema-test.json \ + $(SRC_PATH)/tests/qapi-schema/include/sub-module.json \ + $(SRC_PATH)/tests/qapi-schema/sub-sub-module.json \ + $(qapi-py) $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-gen.py \ -o tests -p "test-" $<, \ "GEN","$(@:%-timestamp=%)") diff --git a/tests/qapi-schema/include-relpath-sub.json b/tests/qapi-schema/include-relpath-sub.json deleted file mode 100644 index 4bd4af4162..0000000000 --- a/tests/qapi-schema/include-relpath-sub.json +++ /dev/null @@ -1,2 +0,0 @@ -{ 'enum': 'Status', - 'data': [ 'good', 'bad', 'ugly' ] } diff --git a/tests/qapi-schema/include-relpath.err b/tests/qapi-schema/include-relpath.err deleted file mode 100644 index e69de29bb2..0000000000 --- a/tests/qapi-schema/include-relpath.err +++ /dev/null diff --git a/tests/qapi-schema/include-relpath.exit b/tests/qapi-schema/include-relpath.exit deleted file mode 100644 index 573541ac97..0000000000 --- a/tests/qapi-schema/include-relpath.exit +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/tests/qapi-schema/include-relpath.json b/tests/qapi-schema/include-relpath.json deleted file mode 100644 index 05018f3908..0000000000 --- a/tests/qapi-schema/include-relpath.json +++ /dev/null @@ -1 +0,0 @@ -{ 'include': 'include/relpath.json' } diff --git a/tests/qapi-schema/include-relpath.out b/tests/qapi-schema/include-relpath.out deleted file mode 100644 index cf8636b78f..0000000000 --- a/tests/qapi-schema/include-relpath.out +++ /dev/null @@ -1,20 +0,0 @@ -module None -object q_empty -enum QType - prefix QTYPE - member none - member qnull - member qnum - member qstring - member qdict - member qlist - member qbool -module include-relpath.json -include include/relpath.json -module include/relpath.json -include include-relpath-sub.json -module include-relpath-sub.json -enum Status - member good - member bad - member ugly diff --git a/tests/qapi-schema/include/relpath.json b/tests/qapi-schema/include/relpath.json deleted file mode 100644 index 45dee24704..0000000000 --- a/tests/qapi-schema/include/relpath.json +++ /dev/null @@ -1 +0,0 @@ -{ 'include': '../include-relpath-sub.json' } diff --git a/tests/qapi-schema/include/sub-module.json b/tests/qapi-schema/include/sub-module.json new file mode 100644 index 0000000000..afdb267228 --- /dev/null +++ b/tests/qapi-schema/include/sub-module.json @@ -0,0 +1,7 @@ +# *-*- Mode: Python -*-* + +# Sub-module of ../qapi-schema-test.json + +{ 'include': '../sub-sub-module.json' } + +{ 'struct': 'SecondArrayRef', 'data': { 's': ['Status'] } } diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qapi-schema-test.json index cb0857df52..0952c68734 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -113,8 +113,8 @@ # for testing use of 'str' within alternates { 'alternate': 'AltStrObj', 'data': { 's': 'str', 'o': 'TestStruct' } } -# for testing native lists -{ 'union': 'UserDefNativeListUnion', +# for testing lists +{ 'union': 'UserDefListUnion', 'data': { 'integer': ['int'], 's8': ['int8'], 's16': ['int16'], @@ -128,7 +128,11 @@ 'boolean': ['bool'], 'string': ['str'], 'sizes': ['size'], - 'any': ['any'] } } + 'any': ['any'], + 'user': ['Status'] } } # intentional forward ref. to sub-module + +# for testing sub-modules +{ 'include': 'include/sub-module.json' } # testing commands { 'command': 'user_def_cmd', 'data': {} } @@ -144,7 +148,7 @@ 'returns': 'int' } { 'command': 'guest-sync', 'data': { 'arg': 'any' }, 'returns': 'any' } { 'command': 'boxed-struct', 'boxed': true, 'data': 'UserDefZero' } -{ 'command': 'boxed-union', 'data': 'UserDefNativeListUnion', 'boxed': true } +{ 'command': 'boxed-union', 'data': 'UserDefListUnion', 'boxed': true } # Smoke test on out-of-band and allow-preconfig-test { 'command': 'test-flags-command', 'allow-oob': true, 'allow-preconfig': true } @@ -236,5 +240,5 @@ { 'event': 'TestIfEvent', 'data': { 'foo': 'TestIfStruct', - 'bar': { 'type': 'TestIfEnum', 'if': 'defined(TEST_IF_EVT_BAR)' } }, + 'bar': { 'type': ['TestIfEnum'], 'if': 'defined(TEST_IF_EVT_BAR)' } }, 'if': 'defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT)' } diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qapi-schema-test.out index d8aec17115..77fb1e1aa9 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -52,6 +52,9 @@ object UserDefTwo member dict1: UserDefTwoDict optional=False object UserDefThree member string0: str optional=False +array UserDefOneList UserDefOne +array UserDefTwoList UserDefTwo +array TestStructList TestStruct object ForceArrays member unused1: UserDefOneList optional=False member unused2: UserDefTwoList optional=False @@ -141,7 +144,12 @@ object q_obj_sizeList-wrapper member data: sizeList optional=False object q_obj_anyList-wrapper member data: anyList optional=False -enum UserDefNativeListUnionKind +module sub-sub-module.json +array StatusList Status +module qapi-schema-test.json +object q_obj_StatusList-wrapper + member data: StatusList optional=False +enum UserDefListUnionKind member integer member s8 member s16 @@ -156,8 +164,9 @@ enum UserDefNativeListUnionKind member string member sizes member any -object UserDefNativeListUnion - member type: UserDefNativeListUnionKind optional=False + member user +object UserDefListUnion + member type: UserDefListUnionKind optional=False tag type case integer: q_obj_intList-wrapper case s8: q_obj_int8List-wrapper @@ -173,6 +182,19 @@ object UserDefNativeListUnion case string: q_obj_strList-wrapper case sizes: q_obj_sizeList-wrapper case any: q_obj_anyList-wrapper + case user: q_obj_StatusList-wrapper +include include/sub-module.json +module include/sub-module.json +include sub-sub-module.json +module sub-sub-module.json +enum Status + member good + member bad + member ugly +module include/sub-module.json +object SecondArrayRef + member s: StatusList optional=False +module qapi-schema-test.json command user_def_cmd None -> None gen=True success_response=True boxed=False oob=False preconfig=False object q_obj_user_def_cmd1-arg @@ -197,7 +219,7 @@ command guest-sync q_obj_guest-sync-arg -> any gen=True success_response=True boxed=False oob=False preconfig=False command boxed-struct UserDefZero -> None gen=True success_response=True boxed=True oob=False preconfig=False -command boxed-union UserDefNativeListUnion -> None +command boxed-union UserDefListUnion -> None gen=True success_response=True boxed=True oob=False preconfig=False command test-flags-command None -> None gen=True success_response=True boxed=False oob=True preconfig=True @@ -248,6 +270,7 @@ object __org.qemu_x-Union1 member type: __org.qemu_x-Union1Kind optional=False tag type case __org.qemu_x-branch: q_obj_str-wrapper +array __org.qemu_x-Union1List __org.qemu_x-Union1 object __org.qemu_x-Struct2 member array: __org.qemu_x-Union1List optional=False object __org.qemu_x-Union2 @@ -260,6 +283,8 @@ alternate __org.qemu_x-Alt case b: __org.qemu_x-Base event __ORG.QEMU_X-EVENT __org.qemu_x-Struct boxed=False +array __org.qemu_x-EnumList __org.qemu_x-Enum +array __org.qemu_x-StructList __org.qemu_x-Struct object q_obj___org.qemu_x-command-arg member a: __org.qemu_x-EnumList optional=False member b: __org.qemu_x-StructList optional=False @@ -319,9 +344,11 @@ command TestIfCmd q_obj_TestIfCmd-arg -> UserDefThree if ['defined(TEST_IF_CMD)', 'defined(TEST_IF_STRUCT)'] command TestCmdReturnDefThree None -> UserDefThree gen=True success_response=True boxed=False oob=False preconfig=False +array TestIfEnumList TestIfEnum + if ['defined(TEST_IF_ENUM)'] object q_obj_TestIfEvent-arg member foo: TestIfStruct optional=False - member bar: TestIfEnum optional=False + member bar: TestIfEnumList optional=False if ['defined(TEST_IF_EVT_BAR)'] if ['defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT)'] event TestIfEvent q_obj_TestIfEvent-arg diff --git a/tests/qapi-schema/sub-sub-module.json b/tests/qapi-schema/sub-sub-module.json new file mode 100644 index 0000000000..524ef9b83f --- /dev/null +++ b/tests/qapi-schema/sub-sub-module.json @@ -0,0 +1,6 @@ +# *-*- Mode: Python -*-* + +# Sub-module of sub-module include/sub-module.json of qapi-schema-test.json + +{ 'enum': 'Status', + 'data': [ 'good', 'bad', 'ugly' ] } diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py index d592854601..d21fca01fc 100644 --- a/tests/qapi-schema/test-qapi.py +++ b/tests/qapi-schema/test-qapi.py @@ -32,6 +32,12 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor): self._print_if(m.ifcond, indent=8) self._print_if(ifcond) + def visit_array_type(self, name, info, ifcond, element_type): + if not info: + return # suppress built-in arrays + print('array %s %s' % (name, element_type.name)) + self._print_if(ifcond) + def visit_object_type(self, name, info, ifcond, base, members, variants): print('object %s' % name) if base: diff --git a/tests/test-clone-visitor.c b/tests/test-clone-visitor.c index 9aeaf86a07..5e1e8b2f5e 100644 --- a/tests/test-clone-visitor.c +++ b/tests/test-clone-visitor.c @@ -63,7 +63,7 @@ static void test_clone_alternate(void) qapi_free_AltEnumBool(s_dst); } -static void test_clone_native_list(void) +static void test_clone_list_union(void) { uint8List *src, *dst; uint8List *tmp = NULL; @@ -102,18 +102,18 @@ static void test_clone_empty(void) static void test_clone_complex1(void) { - UserDefNativeListUnion *src, *dst; + UserDefListUnion *src, *dst; - src = g_new0(UserDefNativeListUnion, 1); - src->type = USER_DEF_NATIVE_LIST_UNION_KIND_STRING; + src = g_new0(UserDefListUnion, 1); + src->type = USER_DEF_LIST_UNION_KIND_STRING; - dst = QAPI_CLONE(UserDefNativeListUnion, src); + dst = QAPI_CLONE(UserDefListUnion, src); g_assert(dst); g_assert_cmpint(dst->type, ==, src->type); g_assert(!dst->u.string.data); - qapi_free_UserDefNativeListUnion(src); - qapi_free_UserDefNativeListUnion(dst); + qapi_free_UserDefListUnion(src); + qapi_free_UserDefListUnion(dst); } static void test_clone_complex2(void) @@ -192,7 +192,7 @@ int main(int argc, char **argv) g_test_add_func("/visitor/clone/struct", test_clone_struct); g_test_add_func("/visitor/clone/alternate", test_clone_alternate); - g_test_add_func("/visitor/clone/native_list", test_clone_native_list); + g_test_add_func("/visitor/clone/list_union", test_clone_list_union); g_test_add_func("/visitor/clone/empty", test_clone_empty); g_test_add_func("/visitor/clone/complex1", test_clone_complex1); g_test_add_func("/visitor/clone/complex2", test_clone_complex2); diff --git a/tests/test-qmp-cmds.c b/tests/test-qmp-cmds.c index 481cb069ca..630b1b9bac 100644 --- a/tests/test-qmp-cmds.c +++ b/tests/test-qmp-cmds.c @@ -87,7 +87,7 @@ void qmp_boxed_struct(UserDefZero *arg, Error **errp) { } -void qmp_boxed_union(UserDefNativeListUnion *arg, Error **errp) +void qmp_boxed_union(UserDefListUnion *arg, Error **errp) { } diff --git a/tests/test-qobject-input-visitor.c b/tests/test-qobject-input-visitor.c index 609334adf6..6bacabf063 100644 --- a/tests/test-qobject-input-visitor.c +++ b/tests/test-qobject-input-visitor.c @@ -686,11 +686,11 @@ static void test_visitor_in_alternate_number(TestInputVisitorData *data, qapi_free_AltEnumInt(asi); } -static void test_native_list_integer_helper(TestInputVisitorData *data, - const void *unused, - UserDefNativeListUnionKind kind) +static void test_list_union_integer_helper(TestInputVisitorData *data, + const void *unused, + UserDefListUnionKind kind) { - UserDefNativeListUnion *cvalue = NULL; + UserDefListUnion *cvalue = NULL; Visitor *v; GString *gstr_list = g_string_new(""); GString *gstr_union = g_string_new(""); @@ -703,16 +703,16 @@ static void test_native_list_integer_helper(TestInputVisitorData *data, } } g_string_append_printf(gstr_union, "{ 'type': '%s', 'data': [ %s ] }", - UserDefNativeListUnionKind_str(kind), + UserDefListUnionKind_str(kind), gstr_list->str); v = visitor_input_test_init_raw(data, gstr_union->str); - visit_type_UserDefNativeListUnion(v, NULL, &cvalue, &error_abort); + visit_type_UserDefListUnion(v, NULL, &cvalue, &error_abort); g_assert(cvalue != NULL); g_assert_cmpint(cvalue->type, ==, kind); switch (kind) { - case USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER: { + case USER_DEF_LIST_UNION_KIND_INTEGER: { intList *elem = NULL; for (i = 0, elem = cvalue->u.integer.data; elem; elem = elem->next, i++) { @@ -720,56 +720,56 @@ static void test_native_list_integer_helper(TestInputVisitorData *data, } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_S8: { + case USER_DEF_LIST_UNION_KIND_S8: { int8List *elem = NULL; for (i = 0, elem = cvalue->u.s8.data; elem; elem = elem->next, i++) { g_assert_cmpint(elem->value, ==, i); } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_S16: { + case USER_DEF_LIST_UNION_KIND_S16: { int16List *elem = NULL; for (i = 0, elem = cvalue->u.s16.data; elem; elem = elem->next, i++) { g_assert_cmpint(elem->value, ==, i); } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_S32: { + case USER_DEF_LIST_UNION_KIND_S32: { int32List *elem = NULL; for (i = 0, elem = cvalue->u.s32.data; elem; elem = elem->next, i++) { g_assert_cmpint(elem->value, ==, i); } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_S64: { + case USER_DEF_LIST_UNION_KIND_S64: { int64List *elem = NULL; for (i = 0, elem = cvalue->u.s64.data; elem; elem = elem->next, i++) { g_assert_cmpint(elem->value, ==, i); } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_U8: { + case USER_DEF_LIST_UNION_KIND_U8: { uint8List *elem = NULL; for (i = 0, elem = cvalue->u.u8.data; elem; elem = elem->next, i++) { g_assert_cmpint(elem->value, ==, i); } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_U16: { + case USER_DEF_LIST_UNION_KIND_U16: { uint16List *elem = NULL; for (i = 0, elem = cvalue->u.u16.data; elem; elem = elem->next, i++) { g_assert_cmpint(elem->value, ==, i); } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_U32: { + case USER_DEF_LIST_UNION_KIND_U32: { uint32List *elem = NULL; for (i = 0, elem = cvalue->u.u32.data; elem; elem = elem->next, i++) { g_assert_cmpint(elem->value, ==, i); } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_U64: { + case USER_DEF_LIST_UNION_KIND_U64: { uint64List *elem = NULL; for (i = 0, elem = cvalue->u.u64.data; elem; elem = elem->next, i++) { g_assert_cmpint(elem->value, ==, i); @@ -782,76 +782,76 @@ static void test_native_list_integer_helper(TestInputVisitorData *data, g_string_free(gstr_union, true); g_string_free(gstr_list, true); - qapi_free_UserDefNativeListUnion(cvalue); + qapi_free_UserDefListUnion(cvalue); } -static void test_visitor_in_native_list_int(TestInputVisitorData *data, - const void *unused) +static void test_visitor_in_list_union_int(TestInputVisitorData *data, + const void *unused) { - test_native_list_integer_helper(data, unused, - USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER); + test_list_union_integer_helper(data, unused, + USER_DEF_LIST_UNION_KIND_INTEGER); } -static void test_visitor_in_native_list_int8(TestInputVisitorData *data, - const void *unused) +static void test_visitor_in_list_union_int8(TestInputVisitorData *data, + const void *unused) { - test_native_list_integer_helper(data, unused, - USER_DEF_NATIVE_LIST_UNION_KIND_S8); + test_list_union_integer_helper(data, unused, + USER_DEF_LIST_UNION_KIND_S8); } -static void test_visitor_in_native_list_int16(TestInputVisitorData *data, - const void *unused) +static void test_visitor_in_list_union_int16(TestInputVisitorData *data, + const void *unused) { - test_native_list_integer_helper(data, unused, - USER_DEF_NATIVE_LIST_UNION_KIND_S16); + test_list_union_integer_helper(data, unused, + USER_DEF_LIST_UNION_KIND_S16); } -static void test_visitor_in_native_list_int32(TestInputVisitorData *data, - const void *unused) +static void test_visitor_in_list_union_int32(TestInputVisitorData *data, + const void *unused) { - test_native_list_integer_helper(data, unused, - USER_DEF_NATIVE_LIST_UNION_KIND_S32); + test_list_union_integer_helper(data, unused, + USER_DEF_LIST_UNION_KIND_S32); } -static void test_visitor_in_native_list_int64(TestInputVisitorData *data, - const void *unused) +static void test_visitor_in_list_union_int64(TestInputVisitorData *data, + const void *unused) { - test_native_list_integer_helper(data, unused, - USER_DEF_NATIVE_LIST_UNION_KIND_S64); + test_list_union_integer_helper(data, unused, + USER_DEF_LIST_UNION_KIND_S64); } -static void test_visitor_in_native_list_uint8(TestInputVisitorData *data, +static void test_visitor_in_list_union_uint8(TestInputVisitorData *data, const void *unused) { - test_native_list_integer_helper(data, unused, - USER_DEF_NATIVE_LIST_UNION_KIND_U8); + test_list_union_integer_helper(data, unused, + USER_DEF_LIST_UNION_KIND_U8); } -static void test_visitor_in_native_list_uint16(TestInputVisitorData *data, - const void *unused) +static void test_visitor_in_list_union_uint16(TestInputVisitorData *data, + const void *unused) { - test_native_list_integer_helper(data, unused, - USER_DEF_NATIVE_LIST_UNION_KIND_U16); + test_list_union_integer_helper(data, unused, + USER_DEF_LIST_UNION_KIND_U16); } -static void test_visitor_in_native_list_uint32(TestInputVisitorData *data, - const void *unused) +static void test_visitor_in_list_union_uint32(TestInputVisitorData *data, + const void *unused) { - test_native_list_integer_helper(data, unused, - USER_DEF_NATIVE_LIST_UNION_KIND_U32); + test_list_union_integer_helper(data, unused, + USER_DEF_LIST_UNION_KIND_U32); } -static void test_visitor_in_native_list_uint64(TestInputVisitorData *data, - const void *unused) +static void test_visitor_in_list_union_uint64(TestInputVisitorData *data, + const void *unused) { - test_native_list_integer_helper(data, unused, - USER_DEF_NATIVE_LIST_UNION_KIND_U64); + test_list_union_integer_helper(data, unused, + USER_DEF_LIST_UNION_KIND_U64); } -static void test_visitor_in_native_list_bool(TestInputVisitorData *data, +static void test_visitor_in_list_union_bool(TestInputVisitorData *data, const void *unused) { - UserDefNativeListUnion *cvalue = NULL; + UserDefListUnion *cvalue = NULL; boolList *elem = NULL; Visitor *v; GString *gstr_list = g_string_new(""); @@ -869,9 +869,9 @@ static void test_visitor_in_native_list_bool(TestInputVisitorData *data, gstr_list->str); v = visitor_input_test_init_raw(data, gstr_union->str); - visit_type_UserDefNativeListUnion(v, NULL, &cvalue, &error_abort); + visit_type_UserDefListUnion(v, NULL, &cvalue, &error_abort); g_assert(cvalue != NULL); - g_assert_cmpint(cvalue->type, ==, USER_DEF_NATIVE_LIST_UNION_KIND_BOOLEAN); + g_assert_cmpint(cvalue->type, ==, USER_DEF_LIST_UNION_KIND_BOOLEAN); for (i = 0, elem = cvalue->u.boolean.data; elem; elem = elem->next, i++) { g_assert_cmpint(elem->value, ==, (i % 3 == 0) ? 1 : 0); @@ -879,13 +879,13 @@ static void test_visitor_in_native_list_bool(TestInputVisitorData *data, g_string_free(gstr_union, true); g_string_free(gstr_list, true); - qapi_free_UserDefNativeListUnion(cvalue); + qapi_free_UserDefListUnion(cvalue); } -static void test_visitor_in_native_list_string(TestInputVisitorData *data, - const void *unused) +static void test_visitor_in_list_union_string(TestInputVisitorData *data, + const void *unused) { - UserDefNativeListUnion *cvalue = NULL; + UserDefListUnion *cvalue = NULL; strList *elem = NULL; Visitor *v; GString *gstr_list = g_string_new(""); @@ -902,9 +902,9 @@ static void test_visitor_in_native_list_string(TestInputVisitorData *data, gstr_list->str); v = visitor_input_test_init_raw(data, gstr_union->str); - visit_type_UserDefNativeListUnion(v, NULL, &cvalue, &error_abort); + visit_type_UserDefListUnion(v, NULL, &cvalue, &error_abort); g_assert(cvalue != NULL); - g_assert_cmpint(cvalue->type, ==, USER_DEF_NATIVE_LIST_UNION_KIND_STRING); + g_assert_cmpint(cvalue->type, ==, USER_DEF_LIST_UNION_KIND_STRING); for (i = 0, elem = cvalue->u.string.data; elem; elem = elem->next, i++) { gchar str[8]; @@ -914,15 +914,15 @@ static void test_visitor_in_native_list_string(TestInputVisitorData *data, g_string_free(gstr_union, true); g_string_free(gstr_list, true); - qapi_free_UserDefNativeListUnion(cvalue); + qapi_free_UserDefListUnion(cvalue); } #define DOUBLE_STR_MAX 16 -static void test_visitor_in_native_list_number(TestInputVisitorData *data, - const void *unused) +static void test_visitor_in_list_union_number(TestInputVisitorData *data, + const void *unused) { - UserDefNativeListUnion *cvalue = NULL; + UserDefListUnion *cvalue = NULL; numberList *elem = NULL; Visitor *v; GString *gstr_list = g_string_new(""); @@ -939,9 +939,9 @@ static void test_visitor_in_native_list_number(TestInputVisitorData *data, gstr_list->str); v = visitor_input_test_init_raw(data, gstr_union->str); - visit_type_UserDefNativeListUnion(v, NULL, &cvalue, &error_abort); + visit_type_UserDefListUnion(v, NULL, &cvalue, &error_abort); g_assert(cvalue != NULL); - g_assert_cmpint(cvalue->type, ==, USER_DEF_NATIVE_LIST_UNION_KIND_NUMBER); + g_assert_cmpint(cvalue->type, ==, USER_DEF_LIST_UNION_KIND_NUMBER); for (i = 0, elem = cvalue->u.number.data; elem; elem = elem->next, i++) { GString *double_expected = g_string_new(""); @@ -957,7 +957,7 @@ static void test_visitor_in_native_list_number(TestInputVisitorData *data, g_string_free(gstr_union, true); g_string_free(gstr_list, true); - qapi_free_UserDefNativeListUnion(cvalue); + qapi_free_UserDefListUnion(cvalue); } static void input_visitor_test_add(const char *testpath, @@ -1192,17 +1192,17 @@ static void test_visitor_in_fail_list_nested(TestInputVisitorData *data, visit_end_list(v, NULL); } -static void test_visitor_in_fail_union_native_list(TestInputVisitorData *data, - const void *unused) +static void test_visitor_in_fail_union_list(TestInputVisitorData *data, + const void *unused) { - UserDefNativeListUnion *tmp = NULL; + UserDefListUnion *tmp = NULL; Error *err = NULL; Visitor *v; v = visitor_input_test_init(data, "{ 'type': 'integer', 'data' : [ 'string' ] }"); - visit_type_UserDefNativeListUnion(v, NULL, &tmp, &err); + visit_type_UserDefListUnion(v, NULL, &tmp, &err); error_free_or_abort(&err); g_assert(!tmp); } @@ -1335,30 +1335,30 @@ int main(int argc, char **argv) NULL, test_visitor_in_wrong_type); input_visitor_test_add("/visitor/input/alternate-number", NULL, test_visitor_in_alternate_number); - input_visitor_test_add("/visitor/input/native_list/int", - NULL, test_visitor_in_native_list_int); - input_visitor_test_add("/visitor/input/native_list/int8", - NULL, test_visitor_in_native_list_int8); - input_visitor_test_add("/visitor/input/native_list/int16", - NULL, test_visitor_in_native_list_int16); - input_visitor_test_add("/visitor/input/native_list/int32", - NULL, test_visitor_in_native_list_int32); - input_visitor_test_add("/visitor/input/native_list/int64", - NULL, test_visitor_in_native_list_int64); - input_visitor_test_add("/visitor/input/native_list/uint8", - NULL, test_visitor_in_native_list_uint8); - input_visitor_test_add("/visitor/input/native_list/uint16", - NULL, test_visitor_in_native_list_uint16); - input_visitor_test_add("/visitor/input/native_list/uint32", - NULL, test_visitor_in_native_list_uint32); - input_visitor_test_add("/visitor/input/native_list/uint64", - NULL, test_visitor_in_native_list_uint64); - input_visitor_test_add("/visitor/input/native_list/bool", - NULL, test_visitor_in_native_list_bool); - input_visitor_test_add("/visitor/input/native_list/str", - NULL, test_visitor_in_native_list_string); - input_visitor_test_add("/visitor/input/native_list/number", - NULL, test_visitor_in_native_list_number); + input_visitor_test_add("/visitor/input/list_union/int", + NULL, test_visitor_in_list_union_int); + input_visitor_test_add("/visitor/input/list_union/int8", + NULL, test_visitor_in_list_union_int8); + input_visitor_test_add("/visitor/input/list_union/int16", + NULL, test_visitor_in_list_union_int16); + input_visitor_test_add("/visitor/input/list_union/int32", + NULL, test_visitor_in_list_union_int32); + input_visitor_test_add("/visitor/input/list_union/int64", + NULL, test_visitor_in_list_union_int64); + input_visitor_test_add("/visitor/input/list_union/uint8", + NULL, test_visitor_in_list_union_uint8); + input_visitor_test_add("/visitor/input/list_union/uint16", + NULL, test_visitor_in_list_union_uint16); + input_visitor_test_add("/visitor/input/list_union/uint32", + NULL, test_visitor_in_list_union_uint32); + input_visitor_test_add("/visitor/input/list_union/uint64", + NULL, test_visitor_in_list_union_uint64); + input_visitor_test_add("/visitor/input/list_union/bool", + NULL, test_visitor_in_list_union_bool); + input_visitor_test_add("/visitor/input/list_union/str", + NULL, test_visitor_in_list_union_string); + input_visitor_test_add("/visitor/input/list_union/number", + NULL, test_visitor_in_list_union_number); input_visitor_test_add("/visitor/input/fail/struct", NULL, test_visitor_in_fail_struct); input_visitor_test_add("/visitor/input/fail/struct-nested", @@ -1377,8 +1377,8 @@ int main(int argc, char **argv) NULL, test_visitor_in_fail_union_flat_no_discrim); input_visitor_test_add("/visitor/input/fail/alternate", NULL, test_visitor_in_fail_alternate); - input_visitor_test_add("/visitor/input/fail/union-native-list", - NULL, test_visitor_in_fail_union_native_list); + input_visitor_test_add("/visitor/input/fail/union-list", + NULL, test_visitor_in_fail_union_list); input_visitor_test_add("/visitor/input/qapi-introspect", NULL, test_visitor_in_qmp_introspect); diff --git a/tests/test-qobject-output-visitor.c b/tests/test-qobject-output-visitor.c index be635854b4..3e993e5ba8 100644 --- a/tests/test-qobject-output-visitor.c +++ b/tests/test-qobject-output-visitor.c @@ -474,11 +474,11 @@ static void test_visitor_out_null(TestOutputVisitorData *data, g_assert(qobject_type(nil) == QTYPE_QNULL); } -static void init_native_list(UserDefNativeListUnion *cvalue) +static void init_list_union(UserDefListUnion *cvalue) { int i; switch (cvalue->type) { - case USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER: { + case USER_DEF_LIST_UNION_KIND_INTEGER: { intList **list = &cvalue->u.integer.data; for (i = 0; i < 32; i++) { *list = g_new0(intList, 1); @@ -488,7 +488,7 @@ static void init_native_list(UserDefNativeListUnion *cvalue) } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_S8: { + case USER_DEF_LIST_UNION_KIND_S8: { int8List **list = &cvalue->u.s8.data; for (i = 0; i < 32; i++) { *list = g_new0(int8List, 1); @@ -498,7 +498,7 @@ static void init_native_list(UserDefNativeListUnion *cvalue) } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_S16: { + case USER_DEF_LIST_UNION_KIND_S16: { int16List **list = &cvalue->u.s16.data; for (i = 0; i < 32; i++) { *list = g_new0(int16List, 1); @@ -508,7 +508,7 @@ static void init_native_list(UserDefNativeListUnion *cvalue) } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_S32: { + case USER_DEF_LIST_UNION_KIND_S32: { int32List **list = &cvalue->u.s32.data; for (i = 0; i < 32; i++) { *list = g_new0(int32List, 1); @@ -518,7 +518,7 @@ static void init_native_list(UserDefNativeListUnion *cvalue) } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_S64: { + case USER_DEF_LIST_UNION_KIND_S64: { int64List **list = &cvalue->u.s64.data; for (i = 0; i < 32; i++) { *list = g_new0(int64List, 1); @@ -528,7 +528,7 @@ static void init_native_list(UserDefNativeListUnion *cvalue) } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_U8: { + case USER_DEF_LIST_UNION_KIND_U8: { uint8List **list = &cvalue->u.u8.data; for (i = 0; i < 32; i++) { *list = g_new0(uint8List, 1); @@ -538,7 +538,7 @@ static void init_native_list(UserDefNativeListUnion *cvalue) } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_U16: { + case USER_DEF_LIST_UNION_KIND_U16: { uint16List **list = &cvalue->u.u16.data; for (i = 0; i < 32; i++) { *list = g_new0(uint16List, 1); @@ -548,7 +548,7 @@ static void init_native_list(UserDefNativeListUnion *cvalue) } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_U32: { + case USER_DEF_LIST_UNION_KIND_U32: { uint32List **list = &cvalue->u.u32.data; for (i = 0; i < 32; i++) { *list = g_new0(uint32List, 1); @@ -558,7 +558,7 @@ static void init_native_list(UserDefNativeListUnion *cvalue) } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_U64: { + case USER_DEF_LIST_UNION_KIND_U64: { uint64List **list = &cvalue->u.u64.data; for (i = 0; i < 32; i++) { *list = g_new0(uint64List, 1); @@ -568,7 +568,7 @@ static void init_native_list(UserDefNativeListUnion *cvalue) } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_BOOLEAN: { + case USER_DEF_LIST_UNION_KIND_BOOLEAN: { boolList **list = &cvalue->u.boolean.data; for (i = 0; i < 32; i++) { *list = g_new0(boolList, 1); @@ -578,7 +578,7 @@ static void init_native_list(UserDefNativeListUnion *cvalue) } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_STRING: { + case USER_DEF_LIST_UNION_KIND_STRING: { strList **list = &cvalue->u.string.data; for (i = 0; i < 32; i++) { *list = g_new0(strList, 1); @@ -588,7 +588,7 @@ static void init_native_list(UserDefNativeListUnion *cvalue) } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_NUMBER: { + case USER_DEF_LIST_UNION_KIND_NUMBER: { numberList **list = &cvalue->u.number.data; for (i = 0; i < 32; i++) { *list = g_new0(numberList, 1); @@ -603,8 +603,8 @@ static void init_native_list(UserDefNativeListUnion *cvalue) } } -static void check_native_list(QObject *qobj, - UserDefNativeListUnionKind kind) +static void check_list_union(QObject *qobj, + UserDefListUnionKind kind) { QDict *qdict; QList *qlist; @@ -616,10 +616,10 @@ static void check_native_list(QObject *qobj, qlist = qlist_copy(qobject_to(QList, qdict_get(qdict, "data"))); switch (kind) { - case USER_DEF_NATIVE_LIST_UNION_KIND_U8: - case USER_DEF_NATIVE_LIST_UNION_KIND_U16: - case USER_DEF_NATIVE_LIST_UNION_KIND_U32: - case USER_DEF_NATIVE_LIST_UNION_KIND_U64: + case USER_DEF_LIST_UNION_KIND_U8: + case USER_DEF_LIST_UNION_KIND_U16: + case USER_DEF_LIST_UNION_KIND_U32: + case USER_DEF_LIST_UNION_KIND_U64: for (i = 0; i < 32; i++) { QObject *tmp; QNum *qvalue; @@ -634,16 +634,16 @@ static void check_native_list(QObject *qobj, } break; - case USER_DEF_NATIVE_LIST_UNION_KIND_S8: - case USER_DEF_NATIVE_LIST_UNION_KIND_S16: - case USER_DEF_NATIVE_LIST_UNION_KIND_S32: - case USER_DEF_NATIVE_LIST_UNION_KIND_S64: + case USER_DEF_LIST_UNION_KIND_S8: + case USER_DEF_LIST_UNION_KIND_S16: + case USER_DEF_LIST_UNION_KIND_S32: + case USER_DEF_LIST_UNION_KIND_S64: /* * All integer elements in JSON arrays get stored into QNums * when we convert to QObjects, so we can check them all in * the same fashion, so simply fall through here. */ - case USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER: + case USER_DEF_LIST_UNION_KIND_INTEGER: for (i = 0; i < 32; i++) { QObject *tmp; QNum *qvalue; @@ -657,7 +657,7 @@ static void check_native_list(QObject *qobj, qobject_unref(qlist_pop(qlist)); } break; - case USER_DEF_NATIVE_LIST_UNION_KIND_BOOLEAN: + case USER_DEF_LIST_UNION_KIND_BOOLEAN: for (i = 0; i < 32; i++) { QObject *tmp; QBool *qvalue; @@ -668,7 +668,7 @@ static void check_native_list(QObject *qobj, qobject_unref(qlist_pop(qlist)); } break; - case USER_DEF_NATIVE_LIST_UNION_KIND_STRING: + case USER_DEF_LIST_UNION_KIND_STRING: for (i = 0; i < 32; i++) { QObject *tmp; QString *qvalue; @@ -681,7 +681,7 @@ static void check_native_list(QObject *qobj, qobject_unref(qlist_pop(qlist)); } break; - case USER_DEF_NATIVE_LIST_UNION_KIND_NUMBER: + case USER_DEF_LIST_UNION_KIND_NUMBER: for (i = 0; i < 32; i++) { QObject *tmp; QNum *qvalue; @@ -706,93 +706,93 @@ static void check_native_list(QObject *qobj, qobject_unref(qlist); } -static void test_native_list(TestOutputVisitorData *data, - const void *unused, - UserDefNativeListUnionKind kind) +static void test_list_union(TestOutputVisitorData *data, + const void *unused, + UserDefListUnionKind kind) { - UserDefNativeListUnion *cvalue = g_new0(UserDefNativeListUnion, 1); + UserDefListUnion *cvalue = g_new0(UserDefListUnion, 1); QObject *obj; cvalue->type = kind; - init_native_list(cvalue); + init_list_union(cvalue); - visit_type_UserDefNativeListUnion(data->ov, NULL, &cvalue, &error_abort); + visit_type_UserDefListUnion(data->ov, NULL, &cvalue, &error_abort); obj = visitor_get(data); - check_native_list(obj, cvalue->type); - qapi_free_UserDefNativeListUnion(cvalue); + check_list_union(obj, cvalue->type); + qapi_free_UserDefListUnion(cvalue); } -static void test_visitor_out_native_list_int(TestOutputVisitorData *data, - const void *unused) +static void test_visitor_out_list_union_int(TestOutputVisitorData *data, + const void *unused) { - test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER); + test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_INTEGER); } -static void test_visitor_out_native_list_int8(TestOutputVisitorData *data, - const void *unused) +static void test_visitor_out_list_union_int8(TestOutputVisitorData *data, + const void *unused) { - test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_S8); + test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_S8); } -static void test_visitor_out_native_list_int16(TestOutputVisitorData *data, - const void *unused) +static void test_visitor_out_list_union_int16(TestOutputVisitorData *data, + const void *unused) { - test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_S16); + test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_S16); } -static void test_visitor_out_native_list_int32(TestOutputVisitorData *data, - const void *unused) +static void test_visitor_out_list_union_int32(TestOutputVisitorData *data, + const void *unused) { - test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_S32); + test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_S32); } -static void test_visitor_out_native_list_int64(TestOutputVisitorData *data, - const void *unused) +static void test_visitor_out_list_union_int64(TestOutputVisitorData *data, + const void *unused) { - test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_S64); + test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_S64); } -static void test_visitor_out_native_list_uint8(TestOutputVisitorData *data, - const void *unused) +static void test_visitor_out_list_union_uint8(TestOutputVisitorData *data, + const void *unused) { - test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_U8); + test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_U8); } -static void test_visitor_out_native_list_uint16(TestOutputVisitorData *data, - const void *unused) +static void test_visitor_out_list_union_uint16(TestOutputVisitorData *data, + const void *unused) { - test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_U16); + test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_U16); } -static void test_visitor_out_native_list_uint32(TestOutputVisitorData *data, - const void *unused) +static void test_visitor_out_list_union_uint32(TestOutputVisitorData *data, + const void *unused) { - test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_U32); + test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_U32); } -static void test_visitor_out_native_list_uint64(TestOutputVisitorData *data, - const void *unused) +static void test_visitor_out_list_union_uint64(TestOutputVisitorData *data, + const void *unused) { - test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_U64); + test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_U64); } -static void test_visitor_out_native_list_bool(TestOutputVisitorData *data, - const void *unused) +static void test_visitor_out_list_union_bool(TestOutputVisitorData *data, + const void *unused) { - test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_BOOLEAN); + test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_BOOLEAN); } -static void test_visitor_out_native_list_str(TestOutputVisitorData *data, - const void *unused) +static void test_visitor_out_list_union_str(TestOutputVisitorData *data, + const void *unused) { - test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_STRING); + test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_STRING); } -static void test_visitor_out_native_list_number(TestOutputVisitorData *data, - const void *unused) +static void test_visitor_out_list_union_number(TestOutputVisitorData *data, + const void *unused) { - test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_NUMBER); + test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_NUMBER); } static void output_visitor_test_add(const char *testpath, @@ -841,42 +841,42 @@ int main(int argc, char **argv) &out_visitor_data, test_visitor_out_alternate); output_visitor_test_add("/visitor/output/null", &out_visitor_data, test_visitor_out_null); - output_visitor_test_add("/visitor/output/native_list/int", + output_visitor_test_add("/visitor/output/list_union/int", &out_visitor_data, - test_visitor_out_native_list_int); - output_visitor_test_add("/visitor/output/native_list/int8", + test_visitor_out_list_union_int); + output_visitor_test_add("/visitor/output/list_union/int8", &out_visitor_data, - test_visitor_out_native_list_int8); - output_visitor_test_add("/visitor/output/native_list/int16", + test_visitor_out_list_union_int8); + output_visitor_test_add("/visitor/output/list_union/int16", &out_visitor_data, - test_visitor_out_native_list_int16); - output_visitor_test_add("/visitor/output/native_list/int32", + test_visitor_out_list_union_int16); + output_visitor_test_add("/visitor/output/list_union/int32", &out_visitor_data, - test_visitor_out_native_list_int32); - output_visitor_test_add("/visitor/output/native_list/int64", + test_visitor_out_list_union_int32); + output_visitor_test_add("/visitor/output/list_union/int64", &out_visitor_data, - test_visitor_out_native_list_int64); - output_visitor_test_add("/visitor/output/native_list/uint8", + test_visitor_out_list_union_int64); + output_visitor_test_add("/visitor/output/list_union/uint8", &out_visitor_data, - test_visitor_out_native_list_uint8); - output_visitor_test_add("/visitor/output/native_list/uint16", + test_visitor_out_list_union_uint8); + output_visitor_test_add("/visitor/output/list_union/uint16", &out_visitor_data, - test_visitor_out_native_list_uint16); - output_visitor_test_add("/visitor/output/native_list/uint32", + test_visitor_out_list_union_uint16); + output_visitor_test_add("/visitor/output/list_union/uint32", &out_visitor_data, - test_visitor_out_native_list_uint32); - output_visitor_test_add("/visitor/output/native_list/uint64", + test_visitor_out_list_union_uint32); + output_visitor_test_add("/visitor/output/list_union/uint64", &out_visitor_data, - test_visitor_out_native_list_uint64); - output_visitor_test_add("/visitor/output/native_list/bool", + test_visitor_out_list_union_uint64); + output_visitor_test_add("/visitor/output/list_union/bool", &out_visitor_data, - test_visitor_out_native_list_bool); - output_visitor_test_add("/visitor/output/native_list/string", + test_visitor_out_list_union_bool); + output_visitor_test_add("/visitor/output/list_union/string", &out_visitor_data, - test_visitor_out_native_list_str); - output_visitor_test_add("/visitor/output/native_list/number", + test_visitor_out_list_union_str); + output_visitor_test_add("/visitor/output/list_union/number", &out_visitor_data, - test_visitor_out_native_list_number); + test_visitor_out_list_union_number); g_test_run(); |