From 4292c61dbef0c8ac613005e6c05bdddf420642b5 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Mon, 19 Feb 2018 15:06:21 -0500 Subject: [PATCH] qapi: Support downstream flat unions Enhance the testsuite to cover downstream flat unions, including the base type, discriminator name and type, and branch name and type. Update the generator to mangle the union names in the appropriate places. Backports commit 857af5f06c3fb097d1bb6bc8a23b9992aac99e75 from qemu --- qemu/scripts/qapi-types.py | 2 +- qemu/scripts/qapi-visit.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/qemu/scripts/qapi-types.py b/qemu/scripts/qapi-types.py index 50aa85b1..741cc326 100644 --- a/qemu/scripts/qapi-types.py +++ b/qemu/scripts/qapi-types.py @@ -204,7 +204,7 @@ struct %(name)s void *data; ''', name=name, - discriminator_type_name=discriminator_type_name) + discriminator_type_name=c_name(discriminator_type_name)) for key in typeinfo: ret += mcgen(''' diff --git a/qemu/scripts/qapi-visit.py b/qemu/scripts/qapi-visit.py index f0f3305e..589f2d67 100644 --- a/qemu/scripts/qapi-visit.py +++ b/qemu/scripts/qapi-visit.py @@ -253,7 +253,7 @@ def generate_visit_union(expr): if enum_define: # Use the enum type as discriminator ret = "" - disc_type = enum_define['enum_name'] + disc_type = c_name(enum_define['enum_name']) else: # There will always be a discriminator in the C switch code, by default # it is an enum type generated silently @@ -291,7 +291,7 @@ void visit_type_%(name)s(Visitor *m, %(name)s **obj, const char *name, Error **e goto out_obj; } ''', - name=name) + name=c_name(name)) if not discriminator: disc_key = "type"