]> git.proxmox.com Git - mirror_qemu.git/blobdiff - tests/test-qobject-output-visitor.c
iotests: Fix test 200 on s390x without virtio-pci
[mirror_qemu.git] / tests / test-qobject-output-visitor.c
index a87438613f9138db3866197d5746132466eb1d93..3e993e5ba82abaffb7ca4c2280caf585ca988242 100644 (file)
 #include "qemu-common.h"
 #include "qapi/error.h"
 #include "qapi/qobject-output-visitor.h"
-#include "test-qapi-types.h"
 #include "test-qapi-visit.h"
-#include "qapi/qmp/types.h"
-#include "qapi/qmp/qjson.h"
+#include "qapi/qmp/qbool.h"
+#include "qapi/qmp/qdict.h"
+#include "qapi/qmp/qlist.h"
+#include "qapi/qmp/qnull.h"
+#include "qapi/qmp/qnum.h"
+#include "qapi/qmp/qstring.h"
 
 typedef struct TestOutputVisitorData {
     Visitor *ov;
@@ -37,7 +40,7 @@ static void visitor_output_teardown(TestOutputVisitorData *data,
 {
     visit_free(data->ov);
     data->ov = NULL;
-    qobject_decref(data->obj);
+    qobject_unref(data->obj);
     data->obj = NULL;
 }
 
@@ -58,81 +61,82 @@ static void test_visitor_out_int(TestOutputVisitorData *data,
                                  const void *unused)
 {
     int64_t value = -42;
-    QObject *obj;
+    int64_t val;
+    QNum *qnum;
 
     visit_type_int(data->ov, NULL, &value, &error_abort);
 
-    obj = visitor_get(data);
-    g_assert(qobject_type(obj) == QTYPE_QINT);
-    g_assert_cmpint(qint_get_int(qobject_to_qint(obj)), ==, value);
+    qnum = qobject_to(QNum, visitor_get(data));
+    g_assert(qnum);
+    g_assert(qnum_get_try_int(qnum, &val));
+    g_assert_cmpint(val, ==, value);
 }
 
 static void test_visitor_out_bool(TestOutputVisitorData *data,
                                   const void *unused)
 {
     bool value = true;
-    QObject *obj;
+    QBool *qbool;
 
     visit_type_bool(data->ov, NULL, &value, &error_abort);
 
-    obj = visitor_get(data);
-    g_assert(qobject_type(obj) == QTYPE_QBOOL);
-    g_assert(qbool_get_bool(qobject_to_qbool(obj)) == value);
+    qbool = qobject_to(QBool, visitor_get(data));
+    g_assert(qbool);
+    g_assert(qbool_get_bool(qbool) == value);
 }
 
 static void test_visitor_out_number(TestOutputVisitorData *data,
                                     const void *unused)
 {
     double value = 3.14;
-    QObject *obj;
+    QNum *qnum;
 
     visit_type_number(data->ov, NULL, &value, &error_abort);
 
-    obj = visitor_get(data);
-    g_assert(qobject_type(obj) == QTYPE_QFLOAT);
-    g_assert(qfloat_get_double(qobject_to_qfloat(obj)) == value);
+    qnum = qobject_to(QNum, visitor_get(data));
+    g_assert(qnum);
+    g_assert(qnum_get_double(qnum) == value);
 }
 
 static void test_visitor_out_string(TestOutputVisitorData *data,
                                     const void *unused)
 {
     char *string = (char *) "Q E M U";
-    QObject *obj;
+    QString *qstr;
 
     visit_type_str(data->ov, NULL, &string, &error_abort);
 
-    obj = visitor_get(data);
-    g_assert(qobject_type(obj) == QTYPE_QSTRING);
-    g_assert_cmpstr(qstring_get_str(qobject_to_qstring(obj)), ==, string);
+    qstr = qobject_to(QString, visitor_get(data));
+    g_assert(qstr);
+    g_assert_cmpstr(qstring_get_str(qstr), ==, string);
 }
 
 static void test_visitor_out_no_string(TestOutputVisitorData *data,
                                        const void *unused)
 {
     char *string = NULL;
-    QObject *obj;
+    QString *qstr;
 
     /* A null string should return "" */
     visit_type_str(data->ov, NULL, &string, &error_abort);
 
-    obj = visitor_get(data);
-    g_assert(qobject_type(obj) == QTYPE_QSTRING);
-    g_assert_cmpstr(qstring_get_str(qobject_to_qstring(obj)), ==, "");
+    qstr = qobject_to(QString, visitor_get(data));
+    g_assert(qstr);
+    g_assert_cmpstr(qstring_get_str(qstr), ==, "");
 }
 
 static void test_visitor_out_enum(TestOutputVisitorData *data,
                                   const void *unused)
 {
-    QObject *obj;
     EnumOne i;
+    QString *qstr;
 
     for (i = 0; i < ENUM_ONE__MAX; i++) {
         visit_type_EnumOne(data->ov, "unused", &i, &error_abort);
 
-        obj = visitor_get(data);
-        g_assert(qobject_type(obj) == QTYPE_QSTRING);
-        g_assert_cmpstr(qstring_get_str(qobject_to_qstring(obj)), ==,
-                        EnumOne_lookup[i]);
+        qstr = qobject_to(QString, visitor_get(data));
+        g_assert(qstr);
+        g_assert_cmpstr(qstring_get_str(qstr), ==, EnumOne_str(i));
         visitor_reset(data);
     }
 }
@@ -146,8 +150,7 @@ static void test_visitor_out_enum_errors(TestOutputVisitorData *data,
     for (i = 0; i < ARRAY_SIZE(bad_values) ; i++) {
         err = NULL;
         visit_type_EnumOne(data->ov, "unused", &bad_values[i], &err);
-        g_assert(err);
-        error_free(err);
+        error_free_or_abort(&err);
         visitor_reset(data);
     }
 }
@@ -164,7 +167,7 @@ static void test_visitor_out_struct(TestOutputVisitorData *data,
 
     visit_type_TestStruct(data->ov, NULL, &p, &error_abort);
 
-    qdict = qobject_to_qdict(visitor_get(data));
+    qdict = qobject_to(QDict, visitor_get(data));
     g_assert(qdict);
     g_assert_cmpint(qdict_size(qdict), ==, 3);
     g_assert_cmpint(qdict_get_int(qdict, "integer"), ==, 42);
@@ -203,7 +206,7 @@ static void test_visitor_out_struct_nested(TestOutputVisitorData *data,
 
     visit_type_UserDefTwo(data->ov, "unused", &ud2, &error_abort);
 
-    qdict = qobject_to_qdict(visitor_get(data));
+    qdict = qobject_to(QDict, visitor_get(data));
     g_assert(qdict);
     g_assert_cmpint(qdict_size(qdict), ==, 2);
     g_assert_cmpstr(qdict_get_str(qdict, "string0"), ==, strings[0]);
@@ -245,8 +248,7 @@ static void test_visitor_out_struct_errors(TestOutputVisitorData *data,
         u.has_enum1 = true;
         u.enum1 = bad_values[i];
         visit_type_UserDefOne(data->ov, "unused", &pu, &err);
-        g_assert(err);
-        error_free(err);
+        error_free_or_abort(&err);
         visitor_reset(data);
     }
 }
@@ -261,7 +263,6 @@ static void test_visitor_out_list(TestOutputVisitorData *data,
     bool value_bool = true;
     int value_int = 10;
     QListEntry *entry;
-    QObject *obj;
     QList *qlist;
     int i;
 
@@ -279,10 +280,8 @@ static void test_visitor_out_list(TestOutputVisitorData *data,
 
     visit_type_TestStructList(data->ov, NULL, &head, &error_abort);
 
-    obj = visitor_get(data);
-    g_assert(qobject_type(obj) == QTYPE_QLIST);
-
-    qlist = qobject_to_qlist(obj);
+    qlist = qobject_to(QList, visitor_get(data));
+    g_assert(qlist);
     g_assert(!qlist_empty(qlist));
 
     /* ...and ensure that the visitor sees it in order */
@@ -290,7 +289,7 @@ static void test_visitor_out_list(TestOutputVisitorData *data,
     QLIST_FOREACH_ENTRY(qlist, entry) {
         QDict *qdict;
 
-        qdict = qobject_to_qdict(entry->value);
+        qdict = qobject_to(QDict, entry->value);
         g_assert(qdict);
         g_assert_cmpint(qdict_size(qdict), ==, 3);
         g_assert_cmpint(qdict_get_int(qdict, "integer"), ==, value_int + i);
@@ -335,42 +334,38 @@ static void test_visitor_out_any(TestOutputVisitorData *data,
                                  const void *unused)
 {
     QObject *qobj;
-    QInt *qint;
+    QNum *qnum;
     QBool *qbool;
     QString *qstring;
     QDict *qdict;
-    QObject *obj;
+    int64_t val;
 
-    qobj = QOBJECT(qint_from_int(-42));
+    qobj = QOBJECT(qnum_from_int(-42));
     visit_type_any(data->ov, NULL, &qobj, &error_abort);
-    obj = visitor_get(data);
-    g_assert(qobject_type(obj) == QTYPE_QINT);
-    g_assert_cmpint(qint_get_int(qobject_to_qint(obj)), ==, -42);
-    qobject_decref(qobj);
+    qnum = qobject_to(QNum, visitor_get(data));
+    g_assert(qnum);
+    g_assert(qnum_get_try_int(qnum, &val));
+    g_assert_cmpint(val, ==, -42);
+    qobject_unref(qobj);
 
     visitor_reset(data);
     qdict = qdict_new();
-    qdict_put(qdict, "integer", qint_from_int(-42));
-    qdict_put(qdict, "boolean", qbool_from_bool(true));
-    qdict_put(qdict, "string", qstring_from_str("foo"));
+    qdict_put_int(qdict, "integer", -42);
+    qdict_put_bool(qdict, "boolean", true);
+    qdict_put_str(qdict, "string", "foo");
     qobj = QOBJECT(qdict);
     visit_type_any(data->ov, NULL, &qobj, &error_abort);
-    qobject_decref(qobj);
-    qdict = qobject_to_qdict(visitor_get(data));
+    qobject_unref(qobj);
+    qdict = qobject_to(QDict, visitor_get(data));
     g_assert(qdict);
-    qobj = qdict_get(qdict, "integer");
-    g_assert(qobj);
-    qint = qobject_to_qint(qobj);
-    g_assert(qint);
-    g_assert_cmpint(qint_get_int(qint), ==, -42);
-    qobj = qdict_get(qdict, "boolean");
-    g_assert(qobj);
-    qbool = qobject_to_qbool(qobj);
+    qnum = qobject_to(QNum, qdict_get(qdict, "integer"));
+    g_assert(qnum);
+    g_assert(qnum_get_try_int(qnum, &val));
+    g_assert_cmpint(val, ==, -42);
+    qbool = qobject_to(QBool, qdict_get(qdict, "boolean"));
     g_assert(qbool);
     g_assert(qbool_get_bool(qbool) == true);
-    qobj = qdict_get(qdict, "string");
-    g_assert(qobj);
-    qstring = qobject_to_qstring(qobj);
+    qstring = qobject_to(QString, qdict_get(qdict, "string"));
     g_assert(qstring);
     g_assert_cmpstr(qstring_get_str(qstring), ==, "foo");
 }
@@ -387,7 +382,7 @@ static void test_visitor_out_union_flat(TestOutputVisitorData *data,
     tmp->u.value1.boolean = true;
 
     visit_type_UserDefFlatUnion(data->ov, NULL, &tmp, &error_abort);
-    qdict = qobject_to_qdict(visitor_get(data));
+    qdict = qobject_to(QDict, visitor_get(data));
     g_assert(qdict);
     g_assert_cmpstr(qdict_get_str(qdict, "enum1"), ==, "value1");
     g_assert_cmpstr(qdict_get_str(qdict, "string"), ==, "str");
@@ -400,32 +395,43 @@ static void test_visitor_out_union_flat(TestOutputVisitorData *data,
 static void test_visitor_out_alternate(TestOutputVisitorData *data,
                                        const void *unused)
 {
-    QObject *arg;
     UserDefAlternate *tmp;
+    QNum *qnum;
+    QString *qstr;
     QDict *qdict;
+    int64_t val;
 
     tmp = g_new0(UserDefAlternate, 1);
-    tmp->type = QTYPE_QINT;
+    tmp->type = QTYPE_QNUM;
     tmp->u.i = 42;
 
     visit_type_UserDefAlternate(data->ov, NULL, &tmp, &error_abort);
-    arg = visitor_get(data);
-
-    g_assert(qobject_type(arg) == QTYPE_QINT);
-    g_assert_cmpint(qint_get_int(qobject_to_qint(arg)), ==, 42);
+    qnum = qobject_to(QNum, visitor_get(data));
+    g_assert(qnum);
+    g_assert(qnum_get_try_int(qnum, &val));
+    g_assert_cmpint(val, ==, 42);
 
     qapi_free_UserDefAlternate(tmp);
 
     visitor_reset(data);
     tmp = g_new0(UserDefAlternate, 1);
     tmp->type = QTYPE_QSTRING;
-    tmp->u.s = g_strdup("hello");
+    tmp->u.e = ENUM_ONE_VALUE1;
 
     visit_type_UserDefAlternate(data->ov, NULL, &tmp, &error_abort);
-    arg = visitor_get(data);
+    qstr = qobject_to(QString, visitor_get(data));
+    g_assert(qstr);
+    g_assert_cmpstr(qstring_get_str(qstr), ==, "value1");
 
-    g_assert(qobject_type(arg) == QTYPE_QSTRING);
-    g_assert_cmpstr(qstring_get_str(qobject_to_qstring(arg)), ==, "hello");
+    qapi_free_UserDefAlternate(tmp);
+
+    visitor_reset(data);
+    tmp = g_new0(UserDefAlternate, 1);
+    tmp->type = QTYPE_QNULL;
+    tmp->u.n = qnull();
+
+    visit_type_UserDefAlternate(data->ov, NULL, &tmp, &error_abort);
+    g_assert_cmpint(qobject_type(visitor_get(data)), ==, QTYPE_QNULL);
 
     qapi_free_UserDefAlternate(tmp);
 
@@ -438,7 +444,7 @@ static void test_visitor_out_alternate(TestOutputVisitorData *data,
     tmp->u.udfu.u.value1.boolean = true;
 
     visit_type_UserDefAlternate(data->ov, NULL, &tmp, &error_abort);
-    qdict = qobject_to_qdict(visitor_get(data));
+    qdict = qobject_to(QDict, visitor_get(data));
     g_assert(qdict);
     g_assert_cmpint(qdict_size(qdict), ==, 4);
     g_assert_cmpint(qdict_get_int(qdict, "integer"), ==, 1);
@@ -452,14 +458,15 @@ static void test_visitor_out_alternate(TestOutputVisitorData *data,
 static void test_visitor_out_null(TestOutputVisitorData *data,
                                   const void *unused)
 {
+    QNull *null = NULL;
     QDict *qdict;
     QObject *nil;
 
     visit_start_struct(data->ov, NULL, NULL, 0, &error_abort);
-    visit_type_null(data->ov, "a", &error_abort);
+    visit_type_null(data->ov, "a", &null, &error_abort);
     visit_check_struct(data->ov, &error_abort);
     visit_end_struct(data->ov, NULL);
-    qdict = qobject_to_qdict(visitor_get(data));
+    qdict = qobject_to(QDict, visitor_get(data));
     g_assert(qdict);
     g_assert_cmpint(qdict_size(qdict), ==, 1);
     nil = qdict_get(qdict, "a");
@@ -467,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);
@@ -481,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);
@@ -491,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);
@@ -501,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);
@@ -511,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);
@@ -521,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);
@@ -531,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);
@@ -541,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);
@@ -551,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);
@@ -561,17 +568,17 @@ 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);
-            (*list)->value = (i % 3 == 0);
+            (*list)->value = QEMU_IS_ALIGNED(i, 3);
             (*list)->next = NULL;
             list = &(*list)->next;
         }
         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);
@@ -581,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);
@@ -596,81 +603,99 @@ 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;
     int i;
 
-    qdict = qobject_to_qdict(qobj);
+    qdict = qobject_to(QDict, qobj);
     g_assert(qdict);
     g_assert(qdict_haskey(qdict, "data"));
-    qlist = qlist_copy(qobject_to_qlist(qdict_get(qdict, "data")));
+    qlist = qlist_copy(qobject_to(QList, qdict_get(qdict, "data")));
 
     switch (kind) {
-    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_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:
-        /* all integer elements in JSON arrays get stored into QInts when
-         * we convert to QObjects, so we can check them all in the same
-         * fashion, so simply fall through here
+    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;
+            uint64_t val;
+
+            tmp = qlist_peek(qlist);
+            g_assert(tmp);
+            qvalue = qobject_to(QNum, tmp);
+            g_assert(qnum_get_try_uint(qvalue, &val));
+            g_assert_cmpint(val, ==, i);
+            qobject_unref(qlist_pop(qlist));
+        }
+        break;
+
+    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;
-            QInt *qvalue;
+            QNum *qvalue;
+            int64_t val;
+
             tmp = qlist_peek(qlist);
             g_assert(tmp);
-            qvalue = qobject_to_qint(tmp);
-            g_assert_cmpint(qint_get_int(qvalue), ==, i);
-            qobject_decref(qlist_pop(qlist));
+            qvalue = qobject_to(QNum, tmp);
+            g_assert(qnum_get_try_int(qvalue, &val));
+            g_assert_cmpint(val, ==, i);
+            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;
             tmp = qlist_peek(qlist);
             g_assert(tmp);
-            qvalue = qobject_to_qbool(tmp);
+            qvalue = qobject_to(QBool, tmp);
             g_assert_cmpint(qbool_get_bool(qvalue), ==, i % 3 == 0);
-            qobject_decref(qlist_pop(qlist));
+            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;
             gchar str[8];
             tmp = qlist_peek(qlist);
             g_assert(tmp);
-            qvalue = qobject_to_qstring(tmp);
+            qvalue = qobject_to(QString, tmp);
             sprintf(str, "%d", i);
             g_assert_cmpstr(qstring_get_str(qvalue), ==, str);
-            qobject_decref(qlist_pop(qlist));
+            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;
-            QFloat *qvalue;
+            QNum *qvalue;
             GString *double_expected = g_string_new("");
             GString *double_actual = g_string_new("");
 
             tmp = qlist_peek(qlist);
             g_assert(tmp);
-            qvalue = qobject_to_qfloat(tmp);
+            qvalue = qobject_to(QNum, tmp);
             g_string_printf(double_expected, "%.6f", (double)i / 3);
-            g_string_printf(double_actual, "%.6f", qfloat_get_double(qvalue));
+            g_string_printf(double_actual, "%.6f", qnum_get_double(qvalue));
             g_assert_cmpstr(double_actual->str, ==, double_expected->str);
 
-            qobject_decref(qlist_pop(qlist));
+            qobject_unref(qlist_pop(qlist));
             g_string_free(double_expected, true);
             g_string_free(double_actual, true);
         }
@@ -678,96 +703,96 @@ static void check_native_list(QObject *qobj,
     default:
         g_assert_not_reached();
     }
-    QDECREF(qlist);
+    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,
@@ -816,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();