diff mbox

[v9,21/27] qapi: Factor out QAPISchemaObjectType.check_clash()

Message ID 1446618049-13596-22-git-send-email-eblake@redhat.com
State New
Headers show

Commit Message

Eric Blake Nov. 4, 2015, 6:20 a.m. UTC
Consolidate two common sequences of clash detection into a
new QAPISchemaObjectType.check_clash() helper method.

No change to generated code.

Signed-off-by: Eric Blake <eblake@redhat.com>

---
v9: new patch, split off from v8 7/17
---
 scripts/qapi.py | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

Comments

Markus Armbruster Nov. 5, 2015, 3:29 p.m. UTC | #1
I really like the simplification.  The (one-time) churn is annoying.
Worthwhile?

See PATCH 3 for details.

Markus Armbruster (5):
  qapi: Generate a sed script to help eliminate camel_to_upper()
  Revert "qapi: Generate a sed script to help eliminate
    camel_to_upper()"
  qapi: Use common name mangling for enumeration constants
  crypto: Drop name mangling override
  Revert "qapi: allow override of default enum prefix naming"

 backends/baum.c                          |   2 +-
 backends/hostmem.c                       |  10 +-
 backends/msmouse.c                       |   2 +-
 backends/rng-egd.c                       |   2 +-
 backends/testdev.c                       |   2 +-
 balloon.c                                |   4 +-
 block.c                                  |  18 +-
 block/backup.c                           |  20 +-
 block/block-backend.c                    |  38 +--
 block/commit.c                           |  12 +-
 block/io.c                               |   4 +-
 block/mirror.c                           |  22 +-
 block/nbd.c                              |   6 +-
 block/qcow2.c                            |  10 +-
 block/quorum.c                           |  10 +-
 block/raw-posix.c                        |   8 +-
 block/stream.c                           |  10 +-
 block/vmdk.c                             |   2 +-
 blockdev-nbd.c                           |   2 +-
 blockdev.c                               | 134 ++++-----
 blockjob.c                               |  30 +-
 crypto/tlscredsanon.c                    |   6 +-
 crypto/tlscredsx509.c                    |   6 +-
 crypto/tlssession.c                      |   6 +-
 docs/qapi-code-gen.txt                   |  18 +-
 docs/writing-qmp-commands.txt            |   8 +-
 dump.c                                   |  28 +-
 gdbstub.c                                |  26 +-
 hmp.c                                    |  80 +++---
 hw/acpi/memory_hotplug.c                 |   2 +-
 hw/arm/musicpal.c                        |   2 +-
 hw/block/block.c                         |   2 +-
 hw/block/fdc.c                           |   4 +-
 hw/block/hd-geometry.c                   |  12 +-
 hw/block/virtio-blk.c                    |   8 +-
 hw/char/escc.c                           | 246 ++++++++--------
 hw/core/qdev-properties-system.c         |   2 +-
 hw/display/qxl.c                         |   4 +-
 hw/i386/kvm/i8254.c                      |   6 +-
 hw/i386/pc.c                             |  10 +-
 hw/i386/pc_piix.c                        |  10 +-
 hw/i386/pc_q35.c                         |  10 +-
 hw/ide/ahci.c                            |   4 +-
 hw/ide/core.c                            |   6 +-
 hw/ide/qdev.c                            |   2 +-
 hw/input/hid.c                           |  26 +-
 hw/input/ps2.c                           |  20 +-
 hw/input/virtio-input-hid.c              | 242 ++++++++--------
 hw/mem/pc-dimm.c                         |   2 +-
 hw/net/allwinner_emac.c                  |   2 +-
 hw/net/cadence_gem.c                     |   2 +-
 hw/net/dp8393x.c                         |   2 +-
 hw/net/e1000.c                           |   2 +-
 hw/net/eepro100.c                        |   2 +-
 hw/net/etraxfs_eth.c                     |   2 +-
 hw/net/fsl_etsec/etsec.c                 |   2 +-
 hw/net/imx_fec.c                         |   2 +-
 hw/net/lan9118.c                         |   2 +-
 hw/net/lance.c                           |   2 +-
 hw/net/mcf_fec.c                         |   2 +-
 hw/net/milkymist-minimac2.c              |   2 +-
 hw/net/mipsnet.c                         |   2 +-
 hw/net/ne2000-isa.c                      |   2 +-
 hw/net/ne2000.c                          |   2 +-
 hw/net/opencores_eth.c                   |   2 +-
 hw/net/pcnet-pci.c                       |   2 +-
 hw/net/rocker/rocker.c                   |   4 +-
 hw/net/rocker/rocker_fp.c                |   2 +-
 hw/net/rocker/rocker_of_dpa.c            |   8 +-
 hw/net/rtl8139.c                         |   2 +-
 hw/net/smc91c111.c                       |   2 +-
 hw/net/spapr_llan.c                      |   2 +-
 hw/net/stellaris_enet.c                  |   2 +-
 hw/net/vhost_net.c                       |  18 +-
 hw/net/virtio-net.c                      |  28 +-
 hw/net/vmxnet3.c                         |   2 +-
 hw/net/xen_nic.c                         |   2 +-
 hw/net/xgmac.c                           |   2 +-
 hw/net/xilinx_axienet.c                  |   2 +-
 hw/net/xilinx_ethlite.c                  |   2 +-
 hw/ppc/spapr_rtas.c                      |   2 +-
 hw/scsi/scsi-disk.c                      |   6 +-
 hw/scsi/scsi-generic.c                   |   4 +-
 hw/timer/mc146818rtc.c                   |  14 +-
 hw/tpm/tpm_passthrough.c                 |   2 +-
 hw/tpm/tpm_tis.c                         |   4 +-
 hw/usb/dev-network.c                     |   2 +-
 hw/usb/hcd-ehci.c                        |   4 +-
 hw/usb/redirect.c                        |   8 +-
 hw/vfio/pci.c                            |   2 +-
 hw/watchdog/watchdog.c                   |  16 +-
 include/block/block_int.h                |   2 +-
 include/crypto/tlssession.h              |   2 +-
 include/migration/migration.h            |   4 +-
 include/qapi/error.h                     |   6 +-
 include/ui/input.h                       |   8 +-
 include/ui/qemu-spice.h                  |   2 +-
 kvm-all.c                                |   2 +-
 migration/migration.c                    | 170 +++++------
 migration/ram.c                          |   4 +-
 migration/rdma.c                         |   2 +-
 migration/savevm.c                       |   4 +-
 monitor.c                                |  62 ++--
 net/dump.c                               |   4 +-
 net/filter.c                             |  10 +-
 net/hub.c                                |  20 +-
 net/l2tpv3.c                             |   4 +-
 net/net.c                                |  78 ++---
 net/netmap.c                             |   2 +-
 net/slirp.c                              |   4 +-
 net/socket.c                             |   6 +-
 net/tap-win32.c                          |   4 +-
 net/tap.c                                |  20 +-
 net/vde.c                                |   4 +-
 net/vhost-user.c                         |  16 +-
 numa.c                                   |   4 +-
 qapi/crypto.json                         |   1 -
 qapi/qmp-dispatch.c                      |   2 +-
 qdev-monitor.c                           |   4 +-
 qemu-char.c                              |  54 ++--
 qemu-img.c                               |   2 +-
 qemu-nbd.c                               |  12 +-
 qga/commands-posix.c                     |  34 +--
 qga/commands-win32.c                     |  44 +--
 qmp.c                                    |  16 +-
 qom/object.c                             |   6 +-
 scripts/qapi-introspect.py               |   2 +-
 scripts/qapi-types.py                    |   6 +-
 scripts/qapi-visit.py                    |   2 +-
 scripts/qapi.py                          |  85 ++----
 spice-qemu-char.c                        |   4 +-
 stubs/runstate-check.c                   |   2 +-
 target-i386/cpu.c                        |   2 +-
 target-lm32/op_helper.c                  |   2 +-
 tests/Makefile                           |   1 -
 tests/qapi-schema/enum-bad-prefix.err    |   1 -
 tests/qapi-schema/enum-bad-prefix.exit   |   1 -
 tests/qapi-schema/enum-bad-prefix.json   |   2 -
 tests/qapi-schema/enum-bad-prefix.out    |   0
 tests/qapi-schema/enum-clash-member.err  |   2 +-
 tests/qapi-schema/enum-clash-member.json |   2 +-
 tests/qapi-schema/enum-max-member.err    |   2 +-
 tests/qapi-schema/enum-max-member.json   |   4 +-
 tests/qapi-schema/qapi-schema-test.json  |   5 -
 tests/qapi-schema/qapi-schema-test.out   |   2 -
 tests/qapi-schema/test-qapi.py           |   4 +-
 tests/qapi-schema/union-bad-branch.err   |   2 +-
 tests/qapi-schema/union-bad-branch.json  |   4 +-
 tests/qapi-schema/union-max.err          |   2 +-
 tests/qapi-schema/union-max.json         |   2 +-
 tests/test-crypto-tlscredsx509.c         |   6 +-
 tests/test-crypto-tlssession.c           |  12 +-
 tests/test-qmp-commands.c                |   2 +-
 tests/test-qmp-event.c                   |   6 +-
 tests/test-qmp-input-visitor.c           |  66 ++---
 tests/test-qmp-output-visitor.c          |  84 +++---
 tests/test-string-output-visitor.c       |   4 +-
 tpm.c                                    |  14 +-
 trace/qmp.c                              |   6 +-
 ui/cocoa.m                               |  20 +-
 ui/console.c                             |  22 +-
 ui/gtk.c                                 |  20 +-
 ui/input-keymap.c                        | 274 +++++++++---------
 ui/input-legacy.c                        |  38 +--
 ui/input.c                               |  56 ++--
 ui/sdl.c                                 |  22 +-
 ui/sdl2-keymap.h                         | 480 +++++++++++++++----------------
 ui/sdl2.c                                |  20 +-
 ui/spice-core.c                          |   4 +-
 ui/spice-input.c                         |  20 +-
 ui/vnc-auth-vencrypt.c                   |   2 +-
 ui/vnc-ws.c                              |   2 +-
 ui/vnc.c                                 |  84 +++---
 util/error.c                             |   6 +-
 util/qemu-config.c                       |   8 +-
 util/qemu-sockets.c                      |  32 +--
 vl.c                                     | 166 +++++------
 xen-hvm.c                                |   4 +-
 178 files changed, 1746 insertions(+), 1816 deletions(-)
 delete mode 100644 tests/qapi-schema/enum-bad-prefix.err
 delete mode 100644 tests/qapi-schema/enum-bad-prefix.exit
 delete mode 100644 tests/qapi-schema/enum-bad-prefix.json
 delete mode 100644 tests/qapi-schema/enum-bad-prefix.out
diff mbox

Patch

diff --git a/scripts/qapi.py b/scripts/qapi.py
index 6653c70..843e364 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -980,11 +980,7 @@  class QAPISchemaObjectType(QAPISchemaType):
         seen = OrderedDict()
         if self._base_name:
             self.base = schema.lookup_type(self._base_name)
-            assert isinstance(self.base, QAPISchemaObjectType)
-            assert not self.base.variants       # not implemented
-            self.base.check(schema)
-            for m in self.base.members:
-                m.check_clash(seen)
+            self.base.check_clash(schema, seen)
         for m in self.local_members:
             m.check(schema)
             m.check_clash(seen)
@@ -993,6 +989,12 @@  class QAPISchemaObjectType(QAPISchemaType):
             self.variants.check(schema, seen)
             assert self.variants.tag_member in self.members

+    def check_clash(self, schema, seen):
+        self.check(schema)
+        assert not self.variants       # not implemented
+        for m in self.members:
+            m.check_clash(seen)
+
     def is_implicit(self):
         # See QAPISchema._make_implicit_object_type()
         return self.name[0] == ':'
@@ -1071,11 +1073,7 @@  class QAPISchemaObjectTypeVariant(QAPISchemaObjectTypeMember):
         if seen:
             # This variant is used within a union; ensure each qapi member
             # field does not collide with the union's non-variant members.
-            assert isinstance(self.type, QAPISchemaObjectType)
-            assert not self.type.variants       # not implemented
-            self.type.check(schema)
-            for m in self.type.members:
-                m.check_clash(seen)
+            self.type.check_clash(schema, seen)

     # This function exists to support ugly simple union special cases
     # TODO get rid of them, and drop the function