qemu-e2k/ui
Eric Blake 32bafa8fdd qapi: Don't special-case simple union wrappers
Simple unions were carrying a special case that hid their 'data'
QMP member from the resulting C struct, via the hack method
QAPISchemaObjectTypeVariant.simple_union_type().  But by using
the work we started by unboxing flat union and alternate
branches, coupled with the ability to visit the members of an
implicit type, we can now expose the simple union's implicit
type in qapi-types.h:

| struct q_obj_ImageInfoSpecificQCow2_wrapper {
|     ImageInfoSpecificQCow2 *data;
| };
|
| struct q_obj_ImageInfoSpecificVmdk_wrapper {
|     ImageInfoSpecificVmdk *data;
| };
...
| struct ImageInfoSpecific {
|     ImageInfoSpecificKind type;
|     union { /* union tag is @type */
|         void *data;
|-        ImageInfoSpecificQCow2 *qcow2;
|-        ImageInfoSpecificVmdk *vmdk;
|+        q_obj_ImageInfoSpecificQCow2_wrapper qcow2;
|+        q_obj_ImageInfoSpecificVmdk_wrapper vmdk;
|     } u;
| };

Doing this removes asymmetry between QAPI's QMP side and its
C side (both sides now expose 'data'), and means that the
treatment of a simple union as sugar for a flat union is now
equivalent in both languages (previously the two approaches used
a different layer of dereferencing, where the simple union could
be converted to a flat union with equivalent C layout but
different {} on the wire, or to an equivalent QMP wire form
but with different C representation).  Using the implicit type
also lets us get rid of the simple_union_type() hack.

Of course, now all clients of simple unions have to adjust from
using su->u.member to using su->u.member.data; while this touches
a number of files in the tree, some earlier cleanup patches
helped minimize the change to the initialization of a temporary
variable rather than every single member access.  The generated
qapi-visit.c code is also affected by the layout change:

|@@ -7393,10 +7393,10 @@ void visit_type_ImageInfoSpecific_member
|     }
|     switch (obj->type) {
|     case IMAGE_INFO_SPECIFIC_KIND_QCOW2:
|-        visit_type_ImageInfoSpecificQCow2(v, "data", &obj->u.qcow2, &err);
|+        visit_type_q_obj_ImageInfoSpecificQCow2_wrapper_members(v, &obj->u.qcow2, &err);
|         break;
|     case IMAGE_INFO_SPECIFIC_KIND_VMDK:
|-        visit_type_ImageInfoSpecificVmdk(v, "data", &obj->u.vmdk, &err);
|+        visit_type_q_obj_ImageInfoSpecificVmdk_wrapper_members(v, &obj->u.vmdk, &err);
|         break;
|     default:
|         abort();

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1458254921-17042-13-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-03-18 10:29:26 +01:00
..
shader
cocoa.m qapi: rename input buttons 2016-03-01 08:19:07 +01:00
console-gl.c ui: Clean up includes 2016-02-04 17:01:04 +00:00
console.c qapi: Don't special-case simple union wrappers 2016-03-18 10:29:26 +01:00
curses_keys.h ui/curses: Fix pageup/pagedown on -curses 2015-11-03 10:12:46 +01:00
curses.c ui: Clean up includes 2016-02-04 17:01:04 +00:00
cursor_hidden.xpm
cursor_left_ptr.xpm
cursor.c ui: Clean up includes 2016-02-04 17:01:04 +00:00
egl-context.c ui: Clean up includes 2016-02-04 17:01:04 +00:00
egl-helpers.c egl-helpers: add functions for render nodes and dma-buf passing 2016-02-23 12:04:39 +01:00
gtk-egl.c ui: Clean up includes 2016-02-04 17:01:04 +00:00
gtk-gl-area.c ui: Clean up includes 2016-02-04 17:01:04 +00:00
gtk.c qapi: rename input buttons 2016-03-01 08:19:07 +01:00
input-keymap.c qapi: Don't special-case simple union wrappers 2016-03-18 10:29:26 +01:00
input-legacy.c qapi: Don't special-case simple union wrappers 2016-03-18 10:29:26 +01:00
input-linux.c module: Rename machine_init() to opts_init() 2016-03-16 15:54:23 -03:00
input.c qapi: Don't special-case simple union wrappers 2016-03-18 10:29:26 +01:00
keymaps.c ui: Clean up includes 2016-02-04 17:01:04 +00:00
keymaps.h
Makefile.objs input: linux evdev support 2016-03-08 12:20:11 +01:00
qemu-pixman.c ui: Clean up includes 2016-02-04 17:01:04 +00:00
qemu-x509.h
sdl2-2d.c ui: Clean up includes 2016-02-04 17:01:04 +00:00
sdl2-gl.c ui: Clean up includes 2016-02-04 17:01:04 +00:00
sdl2-input.c ui: Clean up includes 2016-02-04 17:01:04 +00:00
sdl2-keymap.h
sdl2.c qapi: rename input buttons 2016-03-01 08:19:07 +01:00
sdl_keysym.h
sdl_zoom_template.h
sdl_zoom.c ui: Clean up includes 2016-02-04 17:01:04 +00:00
sdl_zoom.h
sdl.c qapi: rename input buttons 2016-03-01 08:19:07 +01:00
shader.c ui: Clean up includes 2016-02-04 17:01:04 +00:00
spice-core.c module: Rename machine_init() to opts_init() 2016-03-16 15:54:23 -03:00
spice-display.c spice/gl: tweak debug messages. 2016-02-23 12:04:40 +01:00
spice-input.c qapi: rename input buttons 2016-03-01 08:19:07 +01:00
vgafont.h
vnc_keysym.h
vnc-auth-sasl.c qapi: Don't special-case simple union wrappers 2016-03-18 10:29:26 +01:00
vnc-auth-sasl.h
vnc-auth-vencrypt.c ui: Clean up includes 2016-02-04 17:01:04 +00:00
vnc-auth-vencrypt.h
vnc-enc-hextile-template.h
vnc-enc-hextile.c ui: Clean up includes 2016-02-04 17:01:04 +00:00
vnc-enc-tight.c ui: Clean up includes 2016-02-04 17:01:04 +00:00
vnc-enc-tight.h
vnc-enc-zlib.c ui: Clean up includes 2016-02-04 17:01:04 +00:00
vnc-enc-zrle-template.c ui: Clean up includes 2016-02-04 17:01:04 +00:00
vnc-enc-zrle.c ui: Clean up includes 2016-02-04 17:01:04 +00:00
vnc-enc-zrle.h
vnc-enc-zywrle-template.c ui: Clean up includes 2016-02-04 17:01:04 +00:00
vnc-enc-zywrle.h
vnc-jobs.c ui: Clean up includes 2016-02-04 17:01:04 +00:00
vnc-jobs.h
vnc-palette.c ui: Clean up includes 2016-02-04 17:01:04 +00:00
vnc-palette.h all: Clean up includes 2016-02-23 12:43:05 +00:00
vnc-ws.c ui: Clean up includes 2016-02-04 17:01:04 +00:00
vnc-ws.h ui: convert VNC server to use QIOChannelWebsock 2015-12-18 15:02:11 +00:00
vnc.c qapi: Don't special-case simple union wrappers 2016-03-18 10:29:26 +01:00
vnc.h all: Clean up includes 2016-02-23 12:43:05 +00:00
x_keymap.c ui: Clean up includes 2016-02-04 17:01:04 +00:00
x_keymap.h