mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2024-12-31 23:15:44 +00:00
qapi: Simplify builtin type handling
There was some redundancy between builtin_types[] and builtin_type_qtypes{}. Merge them into one. Backports commit b52c4b9cf0bbafdf8cede4ea1f62770d86815718 from qemu
This commit is contained in:
parent
bf18f16174
commit
9d5a99b029
|
@ -45,7 +45,7 @@ const char *X86CPURegister32_lookup[] = {
|
|||
#define QAPI_TYPES_BUILTIN_CLEANUP_DEF_H
|
||||
|
||||
|
||||
void qapi_free_strList(strList *obj)
|
||||
void qapi_free_int32List(int32List *obj)
|
||||
{
|
||||
QapiDeallocVisitor *md;
|
||||
Visitor *v;
|
||||
|
@ -56,67 +56,7 @@ void qapi_free_strList(strList *obj)
|
|||
|
||||
md = qapi_dealloc_visitor_new();
|
||||
v = qapi_dealloc_get_visitor(md);
|
||||
visit_type_strList(v, &obj, NULL, NULL);
|
||||
qapi_dealloc_visitor_cleanup(md);
|
||||
}
|
||||
|
||||
void qapi_free_intList(intList *obj)
|
||||
{
|
||||
QapiDeallocVisitor *md;
|
||||
Visitor *v;
|
||||
|
||||
if (!obj) {
|
||||
return;
|
||||
}
|
||||
|
||||
md = qapi_dealloc_visitor_new();
|
||||
v = qapi_dealloc_get_visitor(md);
|
||||
visit_type_intList(v, &obj, NULL, NULL);
|
||||
qapi_dealloc_visitor_cleanup(md);
|
||||
}
|
||||
|
||||
void qapi_free_numberList(numberList *obj)
|
||||
{
|
||||
QapiDeallocVisitor *md;
|
||||
Visitor *v;
|
||||
|
||||
if (!obj) {
|
||||
return;
|
||||
}
|
||||
|
||||
md = qapi_dealloc_visitor_new();
|
||||
v = qapi_dealloc_get_visitor(md);
|
||||
visit_type_numberList(v, &obj, NULL, NULL);
|
||||
qapi_dealloc_visitor_cleanup(md);
|
||||
}
|
||||
|
||||
void qapi_free_boolList(boolList *obj)
|
||||
{
|
||||
QapiDeallocVisitor *md;
|
||||
Visitor *v;
|
||||
|
||||
if (!obj) {
|
||||
return;
|
||||
}
|
||||
|
||||
md = qapi_dealloc_visitor_new();
|
||||
v = qapi_dealloc_get_visitor(md);
|
||||
visit_type_boolList(v, &obj, NULL, NULL);
|
||||
qapi_dealloc_visitor_cleanup(md);
|
||||
}
|
||||
|
||||
void qapi_free_int8List(int8List *obj)
|
||||
{
|
||||
QapiDeallocVisitor *md;
|
||||
Visitor *v;
|
||||
|
||||
if (!obj) {
|
||||
return;
|
||||
}
|
||||
|
||||
md = qapi_dealloc_visitor_new();
|
||||
v = qapi_dealloc_get_visitor(md);
|
||||
visit_type_int8List(v, &obj, NULL, NULL);
|
||||
visit_type_int32List(v, &obj, NULL, NULL);
|
||||
qapi_dealloc_visitor_cleanup(md);
|
||||
}
|
||||
|
||||
|
@ -135,7 +75,7 @@ void qapi_free_int16List(int16List *obj)
|
|||
qapi_dealloc_visitor_cleanup(md);
|
||||
}
|
||||
|
||||
void qapi_free_int32List(int32List *obj)
|
||||
void qapi_free_intList(intList *obj)
|
||||
{
|
||||
QapiDeallocVisitor *md;
|
||||
Visitor *v;
|
||||
|
@ -146,22 +86,7 @@ void qapi_free_int32List(int32List *obj)
|
|||
|
||||
md = qapi_dealloc_visitor_new();
|
||||
v = qapi_dealloc_get_visitor(md);
|
||||
visit_type_int32List(v, &obj, NULL, NULL);
|
||||
qapi_dealloc_visitor_cleanup(md);
|
||||
}
|
||||
|
||||
void qapi_free_int64List(int64List *obj)
|
||||
{
|
||||
QapiDeallocVisitor *md;
|
||||
Visitor *v;
|
||||
|
||||
if (!obj) {
|
||||
return;
|
||||
}
|
||||
|
||||
md = qapi_dealloc_visitor_new();
|
||||
v = qapi_dealloc_get_visitor(md);
|
||||
visit_type_int64List(v, &obj, NULL, NULL);
|
||||
visit_type_intList(v, &obj, NULL, NULL);
|
||||
qapi_dealloc_visitor_cleanup(md);
|
||||
}
|
||||
|
||||
|
@ -180,7 +105,7 @@ void qapi_free_uint8List(uint8List *obj)
|
|||
qapi_dealloc_visitor_cleanup(md);
|
||||
}
|
||||
|
||||
void qapi_free_uint16List(uint16List *obj)
|
||||
void qapi_free_numberList(numberList *obj)
|
||||
{
|
||||
QapiDeallocVisitor *md;
|
||||
Visitor *v;
|
||||
|
@ -191,11 +116,11 @@ void qapi_free_uint16List(uint16List *obj)
|
|||
|
||||
md = qapi_dealloc_visitor_new();
|
||||
v = qapi_dealloc_get_visitor(md);
|
||||
visit_type_uint16List(v, &obj, NULL, NULL);
|
||||
visit_type_numberList(v, &obj, NULL, NULL);
|
||||
qapi_dealloc_visitor_cleanup(md);
|
||||
}
|
||||
|
||||
void qapi_free_uint32List(uint32List *obj)
|
||||
void qapi_free_int8List(int8List *obj)
|
||||
{
|
||||
QapiDeallocVisitor *md;
|
||||
Visitor *v;
|
||||
|
@ -206,7 +131,7 @@ void qapi_free_uint32List(uint32List *obj)
|
|||
|
||||
md = qapi_dealloc_visitor_new();
|
||||
v = qapi_dealloc_get_visitor(md);
|
||||
visit_type_uint32List(v, &obj, NULL, NULL);
|
||||
visit_type_int8List(v, &obj, NULL, NULL);
|
||||
qapi_dealloc_visitor_cleanup(md);
|
||||
}
|
||||
|
||||
|
@ -225,6 +150,81 @@ void qapi_free_uint64List(uint64List *obj)
|
|||
qapi_dealloc_visitor_cleanup(md);
|
||||
}
|
||||
|
||||
void qapi_free_uint16List(uint16List *obj)
|
||||
{
|
||||
QapiDeallocVisitor *md;
|
||||
Visitor *v;
|
||||
|
||||
if (!obj) {
|
||||
return;
|
||||
}
|
||||
|
||||
md = qapi_dealloc_visitor_new();
|
||||
v = qapi_dealloc_get_visitor(md);
|
||||
visit_type_uint16List(v, &obj, NULL, NULL);
|
||||
qapi_dealloc_visitor_cleanup(md);
|
||||
}
|
||||
|
||||
void qapi_free_boolList(boolList *obj)
|
||||
{
|
||||
QapiDeallocVisitor *md;
|
||||
Visitor *v;
|
||||
|
||||
if (!obj) {
|
||||
return;
|
||||
}
|
||||
|
||||
md = qapi_dealloc_visitor_new();
|
||||
v = qapi_dealloc_get_visitor(md);
|
||||
visit_type_boolList(v, &obj, NULL, NULL);
|
||||
qapi_dealloc_visitor_cleanup(md);
|
||||
}
|
||||
|
||||
void qapi_free_strList(strList *obj)
|
||||
{
|
||||
QapiDeallocVisitor *md;
|
||||
Visitor *v;
|
||||
|
||||
if (!obj) {
|
||||
return;
|
||||
}
|
||||
|
||||
md = qapi_dealloc_visitor_new();
|
||||
v = qapi_dealloc_get_visitor(md);
|
||||
visit_type_strList(v, &obj, NULL, NULL);
|
||||
qapi_dealloc_visitor_cleanup(md);
|
||||
}
|
||||
|
||||
void qapi_free_int64List(int64List *obj)
|
||||
{
|
||||
QapiDeallocVisitor *md;
|
||||
Visitor *v;
|
||||
|
||||
if (!obj) {
|
||||
return;
|
||||
}
|
||||
|
||||
md = qapi_dealloc_visitor_new();
|
||||
v = qapi_dealloc_get_visitor(md);
|
||||
visit_type_int64List(v, &obj, NULL, NULL);
|
||||
qapi_dealloc_visitor_cleanup(md);
|
||||
}
|
||||
|
||||
void qapi_free_uint32List(uint32List *obj)
|
||||
{
|
||||
QapiDeallocVisitor *md;
|
||||
Visitor *v;
|
||||
|
||||
if (!obj) {
|
||||
return;
|
||||
}
|
||||
|
||||
md = qapi_dealloc_visitor_new();
|
||||
v = qapi_dealloc_get_visitor(md);
|
||||
visit_type_uint32List(v, &obj, NULL, NULL);
|
||||
qapi_dealloc_visitor_cleanup(md);
|
||||
}
|
||||
|
||||
#endif /* QAPI_TYPES_BUILTIN_CLEANUP_DEF_H */
|
||||
|
||||
|
||||
|
|
|
@ -23,50 +23,14 @@
|
|||
#define QAPI_TYPES_BUILTIN_STRUCT_DECL_H
|
||||
|
||||
|
||||
typedef struct strList
|
||||
typedef struct int32List
|
||||
{
|
||||
union {
|
||||
char *value;
|
||||
int32_t value;
|
||||
uint64_t padding;
|
||||
};
|
||||
struct strList *next;
|
||||
} strList;
|
||||
|
||||
typedef struct intList
|
||||
{
|
||||
union {
|
||||
int64_t value;
|
||||
uint64_t padding;
|
||||
};
|
||||
struct intList *next;
|
||||
} intList;
|
||||
|
||||
typedef struct numberList
|
||||
{
|
||||
union {
|
||||
double value;
|
||||
uint64_t padding;
|
||||
};
|
||||
struct numberList *next;
|
||||
} numberList;
|
||||
|
||||
typedef struct boolList
|
||||
{
|
||||
union {
|
||||
bool value;
|
||||
uint64_t padding;
|
||||
};
|
||||
struct boolList *next;
|
||||
} boolList;
|
||||
|
||||
typedef struct int8List
|
||||
{
|
||||
union {
|
||||
int8_t value;
|
||||
uint64_t padding;
|
||||
};
|
||||
struct int8List *next;
|
||||
} int8List;
|
||||
struct int32List *next;
|
||||
} int32List;
|
||||
|
||||
typedef struct int16List
|
||||
{
|
||||
|
@ -77,23 +41,14 @@ typedef struct int16List
|
|||
struct int16List *next;
|
||||
} int16List;
|
||||
|
||||
typedef struct int32List
|
||||
{
|
||||
union {
|
||||
int32_t value;
|
||||
uint64_t padding;
|
||||
};
|
||||
struct int32List *next;
|
||||
} int32List;
|
||||
|
||||
typedef struct int64List
|
||||
typedef struct intList
|
||||
{
|
||||
union {
|
||||
int64_t value;
|
||||
uint64_t padding;
|
||||
};
|
||||
struct int64List *next;
|
||||
} int64List;
|
||||
struct intList *next;
|
||||
} intList;
|
||||
|
||||
typedef struct uint8List
|
||||
{
|
||||
|
@ -104,23 +59,23 @@ typedef struct uint8List
|
|||
struct uint8List *next;
|
||||
} uint8List;
|
||||
|
||||
typedef struct uint16List
|
||||
typedef struct numberList
|
||||
{
|
||||
union {
|
||||
uint16_t value;
|
||||
double value;
|
||||
uint64_t padding;
|
||||
};
|
||||
struct uint16List *next;
|
||||
} uint16List;
|
||||
struct numberList *next;
|
||||
} numberList;
|
||||
|
||||
typedef struct uint32List
|
||||
typedef struct int8List
|
||||
{
|
||||
union {
|
||||
uint32_t value;
|
||||
int8_t value;
|
||||
uint64_t padding;
|
||||
};
|
||||
struct uint32List *next;
|
||||
} uint32List;
|
||||
struct int8List *next;
|
||||
} int8List;
|
||||
|
||||
typedef struct uint64List
|
||||
{
|
||||
|
@ -131,6 +86,51 @@ typedef struct uint64List
|
|||
struct uint64List *next;
|
||||
} uint64List;
|
||||
|
||||
typedef struct uint16List
|
||||
{
|
||||
union {
|
||||
uint16_t value;
|
||||
uint64_t padding;
|
||||
};
|
||||
struct uint16List *next;
|
||||
} uint16List;
|
||||
|
||||
typedef struct boolList
|
||||
{
|
||||
union {
|
||||
bool value;
|
||||
uint64_t padding;
|
||||
};
|
||||
struct boolList *next;
|
||||
} boolList;
|
||||
|
||||
typedef struct strList
|
||||
{
|
||||
union {
|
||||
char *value;
|
||||
uint64_t padding;
|
||||
};
|
||||
struct strList *next;
|
||||
} strList;
|
||||
|
||||
typedef struct int64List
|
||||
{
|
||||
union {
|
||||
int64_t value;
|
||||
uint64_t padding;
|
||||
};
|
||||
struct int64List *next;
|
||||
} int64List;
|
||||
|
||||
typedef struct uint32List
|
||||
{
|
||||
union {
|
||||
uint32_t value;
|
||||
uint64_t padding;
|
||||
};
|
||||
struct uint32List *next;
|
||||
} uint32List;
|
||||
|
||||
#endif /* QAPI_TYPES_BUILTIN_STRUCT_DECL_H */
|
||||
|
||||
|
||||
|
@ -193,18 +193,18 @@ typedef struct X86CPUFeatureWordInfoList
|
|||
#ifndef QAPI_TYPES_BUILTIN_CLEANUP_DECL_H
|
||||
#define QAPI_TYPES_BUILTIN_CLEANUP_DECL_H
|
||||
|
||||
void qapi_free_strList(strList *obj);
|
||||
void qapi_free_intList(intList *obj);
|
||||
void qapi_free_numberList(numberList *obj);
|
||||
void qapi_free_boolList(boolList *obj);
|
||||
void qapi_free_int8List(int8List *obj);
|
||||
void qapi_free_int16List(int16List *obj);
|
||||
void qapi_free_int32List(int32List *obj);
|
||||
void qapi_free_int64List(int64List *obj);
|
||||
void qapi_free_int16List(int16List *obj);
|
||||
void qapi_free_intList(intList *obj);
|
||||
void qapi_free_uint8List(uint8List *obj);
|
||||
void qapi_free_uint16List(uint16List *obj);
|
||||
void qapi_free_uint32List(uint32List *obj);
|
||||
void qapi_free_numberList(numberList *obj);
|
||||
void qapi_free_int8List(int8List *obj);
|
||||
void qapi_free_uint64List(uint64List *obj);
|
||||
void qapi_free_uint16List(uint16List *obj);
|
||||
void qapi_free_boolList(boolList *obj);
|
||||
void qapi_free_strList(strList *obj);
|
||||
void qapi_free_int64List(int64List *obj);
|
||||
void qapi_free_uint32List(uint32List *obj);
|
||||
|
||||
#endif /* QAPI_TYPES_BUILTIN_CLEANUP_DECL_H */
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include "qemu-common.h"
|
||||
#include "qapi-visit.h"
|
||||
|
||||
void visit_type_strList(Visitor *m, strList **obj, const char *name, Error **errp)
|
||||
void visit_type_int32List(Visitor *m, int32List **obj, const char *name, Error **errp)
|
||||
{
|
||||
Error *err = NULL;
|
||||
GenericList *i, **prev;
|
||||
|
@ -29,104 +29,8 @@ void visit_type_strList(Visitor *m, strList **obj, const char *name, Error **err
|
|||
for (prev = (GenericList **)obj;
|
||||
!err && (i = visit_next_list(m, prev)) != NULL;
|
||||
prev = &i) {
|
||||
strList *native_i = (strList *)i;
|
||||
visit_type_str(m, &native_i->value, NULL, &err);
|
||||
}
|
||||
|
||||
error_propagate(errp, err);
|
||||
err = NULL;
|
||||
visit_end_list(m);
|
||||
out:
|
||||
error_propagate(errp, err);
|
||||
}
|
||||
|
||||
void visit_type_intList(Visitor *m, intList **obj, const char *name, Error **errp)
|
||||
{
|
||||
Error *err = NULL;
|
||||
GenericList *i, **prev;
|
||||
|
||||
visit_start_list(m, name, &err);
|
||||
if (err) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (prev = (GenericList **)obj;
|
||||
!err && (i = visit_next_list(m, prev)) != NULL;
|
||||
prev = &i) {
|
||||
intList *native_i = (intList *)i;
|
||||
visit_type_int(m, &native_i->value, NULL, &err);
|
||||
}
|
||||
|
||||
error_propagate(errp, err);
|
||||
err = NULL;
|
||||
visit_end_list(m);
|
||||
out:
|
||||
error_propagate(errp, err);
|
||||
}
|
||||
|
||||
void visit_type_numberList(Visitor *m, numberList **obj, const char *name, Error **errp)
|
||||
{
|
||||
Error *err = NULL;
|
||||
GenericList *i, **prev;
|
||||
|
||||
visit_start_list(m, name, &err);
|
||||
if (err) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (prev = (GenericList **)obj;
|
||||
!err && (i = visit_next_list(m, prev)) != NULL;
|
||||
prev = &i) {
|
||||
numberList *native_i = (numberList *)i;
|
||||
visit_type_number(m, &native_i->value, NULL, &err);
|
||||
}
|
||||
|
||||
error_propagate(errp, err);
|
||||
err = NULL;
|
||||
visit_end_list(m);
|
||||
out:
|
||||
error_propagate(errp, err);
|
||||
}
|
||||
|
||||
void visit_type_boolList(Visitor *m, boolList **obj, const char *name, Error **errp)
|
||||
{
|
||||
Error *err = NULL;
|
||||
GenericList *i, **prev;
|
||||
|
||||
visit_start_list(m, name, &err);
|
||||
if (err) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (prev = (GenericList **)obj;
|
||||
!err && (i = visit_next_list(m, prev)) != NULL;
|
||||
prev = &i) {
|
||||
boolList *native_i = (boolList *)i;
|
||||
visit_type_bool(m, &native_i->value, NULL, &err);
|
||||
}
|
||||
|
||||
error_propagate(errp, err);
|
||||
err = NULL;
|
||||
visit_end_list(m);
|
||||
out:
|
||||
error_propagate(errp, err);
|
||||
}
|
||||
|
||||
void visit_type_int8List(Visitor *m, int8List **obj, const char *name, Error **errp)
|
||||
{
|
||||
Error *err = NULL;
|
||||
GenericList *i, **prev;
|
||||
|
||||
visit_start_list(m, name, &err);
|
||||
if (err) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (prev = (GenericList **)obj;
|
||||
!err && (i = visit_next_list(m, prev)) != NULL;
|
||||
prev = &i) {
|
||||
int8List *native_i = (int8List *)i;
|
||||
visit_type_int8(m, &native_i->value, NULL, &err);
|
||||
int32List *native_i = (int32List *)i;
|
||||
visit_type_int32(m, &native_i->value, NULL, &err);
|
||||
}
|
||||
|
||||
error_propagate(errp, err);
|
||||
|
@ -160,7 +64,7 @@ out:
|
|||
error_propagate(errp, err);
|
||||
}
|
||||
|
||||
void visit_type_int32List(Visitor *m, int32List **obj, const char *name, Error **errp)
|
||||
void visit_type_intList(Visitor *m, intList **obj, const char *name, Error **errp)
|
||||
{
|
||||
Error *err = NULL;
|
||||
GenericList *i, **prev;
|
||||
|
@ -173,32 +77,8 @@ void visit_type_int32List(Visitor *m, int32List **obj, const char *name, Error *
|
|||
for (prev = (GenericList **)obj;
|
||||
!err && (i = visit_next_list(m, prev)) != NULL;
|
||||
prev = &i) {
|
||||
int32List *native_i = (int32List *)i;
|
||||
visit_type_int32(m, &native_i->value, NULL, &err);
|
||||
}
|
||||
|
||||
error_propagate(errp, err);
|
||||
err = NULL;
|
||||
visit_end_list(m);
|
||||
out:
|
||||
error_propagate(errp, err);
|
||||
}
|
||||
|
||||
void visit_type_int64List(Visitor *m, int64List **obj, const char *name, Error **errp)
|
||||
{
|
||||
Error *err = NULL;
|
||||
GenericList *i, **prev;
|
||||
|
||||
visit_start_list(m, name, &err);
|
||||
if (err) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (prev = (GenericList **)obj;
|
||||
!err && (i = visit_next_list(m, prev)) != NULL;
|
||||
prev = &i) {
|
||||
int64List *native_i = (int64List *)i;
|
||||
visit_type_int64(m, &native_i->value, NULL, &err);
|
||||
intList *native_i = (intList *)i;
|
||||
visit_type_int(m, &native_i->value, NULL, &err);
|
||||
}
|
||||
|
||||
error_propagate(errp, err);
|
||||
|
@ -232,7 +112,7 @@ out:
|
|||
error_propagate(errp, err);
|
||||
}
|
||||
|
||||
void visit_type_uint16List(Visitor *m, uint16List **obj, const char *name, Error **errp)
|
||||
void visit_type_numberList(Visitor *m, numberList **obj, const char *name, Error **errp)
|
||||
{
|
||||
Error *err = NULL;
|
||||
GenericList *i, **prev;
|
||||
|
@ -245,8 +125,8 @@ void visit_type_uint16List(Visitor *m, uint16List **obj, const char *name, Error
|
|||
for (prev = (GenericList **)obj;
|
||||
!err && (i = visit_next_list(m, prev)) != NULL;
|
||||
prev = &i) {
|
||||
uint16List *native_i = (uint16List *)i;
|
||||
visit_type_uint16(m, &native_i->value, NULL, &err);
|
||||
numberList *native_i = (numberList *)i;
|
||||
visit_type_number(m, &native_i->value, NULL, &err);
|
||||
}
|
||||
|
||||
error_propagate(errp, err);
|
||||
|
@ -256,7 +136,7 @@ out:
|
|||
error_propagate(errp, err);
|
||||
}
|
||||
|
||||
void visit_type_uint32List(Visitor *m, uint32List **obj, const char *name, Error **errp)
|
||||
void visit_type_int8List(Visitor *m, int8List **obj, const char *name, Error **errp)
|
||||
{
|
||||
Error *err = NULL;
|
||||
GenericList *i, **prev;
|
||||
|
@ -269,8 +149,8 @@ void visit_type_uint32List(Visitor *m, uint32List **obj, const char *name, Error
|
|||
for (prev = (GenericList **)obj;
|
||||
!err && (i = visit_next_list(m, prev)) != NULL;
|
||||
prev = &i) {
|
||||
uint32List *native_i = (uint32List *)i;
|
||||
visit_type_uint32(m, &native_i->value, NULL, &err);
|
||||
int8List *native_i = (int8List *)i;
|
||||
visit_type_int8(m, &native_i->value, NULL, &err);
|
||||
}
|
||||
|
||||
error_propagate(errp, err);
|
||||
|
@ -304,6 +184,126 @@ out:
|
|||
error_propagate(errp, err);
|
||||
}
|
||||
|
||||
void visit_type_uint16List(Visitor *m, uint16List **obj, const char *name, Error **errp)
|
||||
{
|
||||
Error *err = NULL;
|
||||
GenericList *i, **prev;
|
||||
|
||||
visit_start_list(m, name, &err);
|
||||
if (err) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (prev = (GenericList **)obj;
|
||||
!err && (i = visit_next_list(m, prev)) != NULL;
|
||||
prev = &i) {
|
||||
uint16List *native_i = (uint16List *)i;
|
||||
visit_type_uint16(m, &native_i->value, NULL, &err);
|
||||
}
|
||||
|
||||
error_propagate(errp, err);
|
||||
err = NULL;
|
||||
visit_end_list(m);
|
||||
out:
|
||||
error_propagate(errp, err);
|
||||
}
|
||||
|
||||
void visit_type_boolList(Visitor *m, boolList **obj, const char *name, Error **errp)
|
||||
{
|
||||
Error *err = NULL;
|
||||
GenericList *i, **prev;
|
||||
|
||||
visit_start_list(m, name, &err);
|
||||
if (err) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (prev = (GenericList **)obj;
|
||||
!err && (i = visit_next_list(m, prev)) != NULL;
|
||||
prev = &i) {
|
||||
boolList *native_i = (boolList *)i;
|
||||
visit_type_bool(m, &native_i->value, NULL, &err);
|
||||
}
|
||||
|
||||
error_propagate(errp, err);
|
||||
err = NULL;
|
||||
visit_end_list(m);
|
||||
out:
|
||||
error_propagate(errp, err);
|
||||
}
|
||||
|
||||
void visit_type_strList(Visitor *m, strList **obj, const char *name, Error **errp)
|
||||
{
|
||||
Error *err = NULL;
|
||||
GenericList *i, **prev;
|
||||
|
||||
visit_start_list(m, name, &err);
|
||||
if (err) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (prev = (GenericList **)obj;
|
||||
!err && (i = visit_next_list(m, prev)) != NULL;
|
||||
prev = &i) {
|
||||
strList *native_i = (strList *)i;
|
||||
visit_type_str(m, &native_i->value, NULL, &err);
|
||||
}
|
||||
|
||||
error_propagate(errp, err);
|
||||
err = NULL;
|
||||
visit_end_list(m);
|
||||
out:
|
||||
error_propagate(errp, err);
|
||||
}
|
||||
|
||||
void visit_type_int64List(Visitor *m, int64List **obj, const char *name, Error **errp)
|
||||
{
|
||||
Error *err = NULL;
|
||||
GenericList *i, **prev;
|
||||
|
||||
visit_start_list(m, name, &err);
|
||||
if (err) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (prev = (GenericList **)obj;
|
||||
!err && (i = visit_next_list(m, prev)) != NULL;
|
||||
prev = &i) {
|
||||
int64List *native_i = (int64List *)i;
|
||||
visit_type_int64(m, &native_i->value, NULL, &err);
|
||||
}
|
||||
|
||||
error_propagate(errp, err);
|
||||
err = NULL;
|
||||
visit_end_list(m);
|
||||
out:
|
||||
error_propagate(errp, err);
|
||||
}
|
||||
|
||||
void visit_type_uint32List(Visitor *m, uint32List **obj, const char *name, Error **errp)
|
||||
{
|
||||
Error *err = NULL;
|
||||
GenericList *i, **prev;
|
||||
|
||||
visit_start_list(m, name, &err);
|
||||
if (err) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (prev = (GenericList **)obj;
|
||||
!err && (i = visit_next_list(m, prev)) != NULL;
|
||||
prev = &i) {
|
||||
uint32List *native_i = (uint32List *)i;
|
||||
visit_type_uint32(m, &native_i->value, NULL, &err);
|
||||
}
|
||||
|
||||
error_propagate(errp, err);
|
||||
err = NULL;
|
||||
visit_end_list(m);
|
||||
out:
|
||||
error_propagate(errp, err);
|
||||
}
|
||||
|
||||
void visit_type_ErrorClassList(Visitor *m, ErrorClassList **obj, const char *name, Error **errp)
|
||||
{
|
||||
Error *err = NULL;
|
||||
|
|
|
@ -23,18 +23,18 @@
|
|||
#ifndef QAPI_VISIT_BUILTIN_VISITOR_DECL_H
|
||||
#define QAPI_VISIT_BUILTIN_VISITOR_DECL_H
|
||||
|
||||
void visit_type_strList(Visitor *m, strList **obj, const char *name, Error **errp);
|
||||
void visit_type_intList(Visitor *m, intList **obj, const char *name, Error **errp);
|
||||
void visit_type_numberList(Visitor *m, numberList **obj, const char *name, Error **errp);
|
||||
void visit_type_boolList(Visitor *m, boolList **obj, const char *name, Error **errp);
|
||||
void visit_type_int8List(Visitor *m, int8List **obj, const char *name, Error **errp);
|
||||
void visit_type_int16List(Visitor *m, int16List **obj, const char *name, Error **errp);
|
||||
void visit_type_int32List(Visitor *m, int32List **obj, const char *name, Error **errp);
|
||||
void visit_type_int64List(Visitor *m, int64List **obj, const char *name, Error **errp);
|
||||
void visit_type_int16List(Visitor *m, int16List **obj, const char *name, Error **errp);
|
||||
void visit_type_intList(Visitor *m, intList **obj, const char *name, Error **errp);
|
||||
void visit_type_uint8List(Visitor *m, uint8List **obj, const char *name, Error **errp);
|
||||
void visit_type_uint16List(Visitor *m, uint16List **obj, const char *name, Error **errp);
|
||||
void visit_type_uint32List(Visitor *m, uint32List **obj, const char *name, Error **errp);
|
||||
void visit_type_numberList(Visitor *m, numberList **obj, const char *name, Error **errp);
|
||||
void visit_type_int8List(Visitor *m, int8List **obj, const char *name, Error **errp);
|
||||
void visit_type_uint64List(Visitor *m, uint64List **obj, const char *name, Error **errp);
|
||||
void visit_type_uint16List(Visitor *m, uint16List **obj, const char *name, Error **errp);
|
||||
void visit_type_boolList(Visitor *m, boolList **obj, const char *name, Error **errp);
|
||||
void visit_type_strList(Visitor *m, strList **obj, const char *name, Error **errp);
|
||||
void visit_type_int64List(Visitor *m, int64List **obj, const char *name, Error **errp);
|
||||
void visit_type_uint32List(Visitor *m, uint32List **obj, const char *name, Error **errp);
|
||||
|
||||
#endif /* QAPI_VISIT_BUILTIN_VISITOR_DECL_H */
|
||||
|
||||
|
|
|
@ -171,8 +171,8 @@ const int %(name)s_qtypes[QTYPE_MAX] = {
|
|||
|
||||
for key in members:
|
||||
qapi_type = members[key]
|
||||
if builtin_type_qtypes.has_key(qapi_type):
|
||||
qtype = builtin_type_qtypes[qapi_type]
|
||||
if builtin_types.has_key(qapi_type):
|
||||
qtype = builtin_types[qapi_type]
|
||||
elif find_struct(qapi_type):
|
||||
qtype = "QTYPE_QDICT"
|
||||
elif find_union(qapi_type):
|
||||
|
@ -386,7 +386,7 @@ exprs = parse_schema(input_file)
|
|||
exprs = filter(lambda expr: not expr.has_key('gen'), exprs)
|
||||
|
||||
fdecl.write(guardstart("QAPI_TYPES_BUILTIN_STRUCT_DECL"))
|
||||
for typename in builtin_types:
|
||||
for typename in builtin_types.keys():
|
||||
fdecl.write(generate_fwd_struct(typename, None, builtin_type=True))
|
||||
fdecl.write(guardend("QAPI_TYPES_BUILTIN_STRUCT_DECL"))
|
||||
|
||||
|
@ -414,7 +414,7 @@ for expr in exprs:
|
|||
# to avoid header dependency hell, we always generate declarations
|
||||
# for built-in types in our header files and simply guard them
|
||||
fdecl.write(guardstart("QAPI_TYPES_BUILTIN_CLEANUP_DECL"))
|
||||
for typename in builtin_types:
|
||||
for typename in builtin_types.keys():
|
||||
fdecl.write(generate_type_cleanup_decl(typename + "List"))
|
||||
fdecl.write(guardend("QAPI_TYPES_BUILTIN_CLEANUP_DECL"))
|
||||
|
||||
|
@ -423,7 +423,7 @@ fdecl.write(guardend("QAPI_TYPES_BUILTIN_CLEANUP_DECL"))
|
|||
# over these cases
|
||||
if do_builtins:
|
||||
fdef.write(guardstart("QAPI_TYPES_BUILTIN_CLEANUP_DEF"))
|
||||
for typename in builtin_types:
|
||||
for typename in builtin_types.keys():
|
||||
fdef.write(generate_type_cleanup(typename + "List"))
|
||||
fdef.write(guardend("QAPI_TYPES_BUILTIN_CLEANUP_DEF"))
|
||||
|
||||
|
|
|
@ -261,7 +261,7 @@ void visit_type_%(name)s(Visitor *m, %(name)s **obj, const char *name, Error **e
|
|||
disc_type = '%sKind' % (name)
|
||||
|
||||
for key in members:
|
||||
assert (members[key] in builtin_types
|
||||
assert (members[key] in builtin_types.keys()
|
||||
or find_struct(members[key])
|
||||
or find_union(members[key])
|
||||
or find_enum(members[key])), "Invalid anonymous union member"
|
||||
|
@ -539,7 +539,7 @@ exprs = parse_schema(input_file)
|
|||
# to avoid header dependency hell, we always generate declarations
|
||||
# for built-in types in our header files and simply guard them
|
||||
fdecl.write(guardstart("QAPI_VISIT_BUILTIN_VISITOR_DECL"))
|
||||
for typename in builtin_types:
|
||||
for typename in builtin_types.keys():
|
||||
fdecl.write(generate_declaration(typename, None, builtin_type=True))
|
||||
fdecl.write(guardend("QAPI_VISIT_BUILTIN_VISITOR_DECL"))
|
||||
|
||||
|
@ -547,7 +547,7 @@ fdecl.write(guardend("QAPI_VISIT_BUILTIN_VISITOR_DECL"))
|
|||
# have the functions defined, so we use -b option to provide control
|
||||
# over these cases
|
||||
if do_builtins:
|
||||
for typename in builtin_types:
|
||||
for typename in builtin_types.keys():
|
||||
fdef.write(generate_visit_list(typename, None))
|
||||
|
||||
for expr in exprs:
|
||||
|
|
|
@ -16,13 +16,7 @@ from ordereddict import OrderedDict
|
|||
import os
|
||||
import sys
|
||||
|
||||
builtin_types = [
|
||||
'str', 'int', 'number', 'bool',
|
||||
'int8', 'int16', 'int32', 'int64',
|
||||
'uint8', 'uint16', 'uint32', 'uint64'
|
||||
]
|
||||
|
||||
builtin_type_qtypes = {
|
||||
builtin_types = {
|
||||
'str': 'QTYPE_QSTRING',
|
||||
'int': 'QTYPE_QINT',
|
||||
'number': 'QTYPE_QFLOAT',
|
||||
|
|
Loading…
Reference in a new issue