qapi: Swap visit_* arguments for consistent 'name' placement

JSON uses "name":value, but many of our visitor interfaces were
called with visit_type_FOO(v, &value, name, errp). This can be
a bit confusing to have to mentally swap the parameter order to
match JSON order. It's particularly bad for visit_start_struct(),
where the 'name' parameter is smack in the middle of the
otherwise-related group of 'obj, kind, size' parameters! It's
time to do a global swap of the parameter ordering, so that the
'name' parameter is always immediately after the Visitor argument.

Additional reason in favor of the swap: the existing include/qjson.h
prefers listing 'name' first in json_prop_*(), and I have plans to
unify that file with the qapi visitors; listing 'name' first in
qapi will minimize churn to the (admittedly few) qjson.h clients.

Later patches will then fix docs, object.h, visitor-impl.h, and
those clients to match.

Done by first patching scripts/qapi*.py by hand to make generated
files do what I want, then by running the following Coccinelle
script to affect the rest of the code base:
$ spatch --sp-file script `git grep -l '\bvisit_' -- '**/*.[ch]'`
I then had to apply some touchups (Coccinelle insisted on TAB
indentation in visitor.h, and botched the signature of
visit_type_enum() by rewriting 'const char *const strings[]' to
the syntactically invalid 'const char*const[] strings'). The
movement of parameters is sufficient to provoke compiler errors
if any callers were missed.

// Part 1: Swap declaration order
@@
type TV, TErr, TObj, T1, T2;
identifier OBJ, ARG1, ARG2;
@@
void visit_start_struct
-(TV v, TObj OBJ, T1 ARG1, const char *name, T2 ARG2, TErr errp)
+(TV v, const char *name, TObj OBJ, T1 ARG1, T2 ARG2, TErr errp)
{ ... }

@@
type bool, TV, T1;
identifier ARG1;
@@
bool visit_optional
-(TV v, T1 ARG1, const char *name)
+(TV v, const char *name, T1 ARG1)
{ ... }

@@
type TV, TErr, TObj, T1;
identifier OBJ, ARG1;
@@
void visit_get_next_type
-(TV v, TObj OBJ, T1 ARG1, const char *name, TErr errp)
+(TV v, const char *name, TObj OBJ, T1 ARG1, TErr errp)
{ ... }

@@
type TV, TErr, TObj, T1, T2;
identifier OBJ, ARG1, ARG2;
@@
void visit_type_enum
-(TV v, TObj OBJ, T1 ARG1, T2 ARG2, const char *name, TErr errp)
+(TV v, const char *name, TObj OBJ, T1 ARG1, T2 ARG2, TErr errp)
{ ... }

@@
type TV, TErr, TObj;
identifier OBJ;
identifier VISIT_TYPE =~ "^visit_type_";
@@
void VISIT_TYPE
-(TV v, TObj OBJ, const char *name, TErr errp)
+(TV v, const char *name, TObj OBJ, TErr errp)
{ ... }

// Part 2: swap caller order
@@
expression V, NAME, OBJ, ARG1, ARG2, ERR;
identifier VISIT_TYPE =~ "^visit_type_";
@@
(
-visit_start_struct(V, OBJ, ARG1, NAME, ARG2, ERR)
+visit_start_struct(V, NAME, OBJ, ARG1, ARG2, ERR)
|
-visit_optional(V, ARG1, NAME)
+visit_optional(V, NAME, ARG1)
|
-visit_get_next_type(V, OBJ, ARG1, NAME, ERR)
+visit_get_next_type(V, NAME, OBJ, ARG1, ERR)
|
-visit_type_enum(V, OBJ, ARG1, ARG2, NAME, ERR)
+visit_type_enum(V, NAME, OBJ, ARG1, ARG2, ERR)
|
-VISIT_TYPE(V, OBJ, NAME, ERR)
+VISIT_TYPE(V, NAME, OBJ, ERR)
)

Backports commit 51e72bc1dd6ace6e91d675f41a1f09bd00ab8043 from qemu
This commit is contained in:
Eric Blake 2018-02-19 22:31:04 -05:00 committed by Lioncash
parent 5b6f0cbdb7
commit 5dd5646a9a
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
9 changed files with 109 additions and 90 deletions

View file

@ -27,8 +27,8 @@ typedef struct GenericList
struct GenericList *next;
} GenericList;
void visit_start_struct(Visitor *v, void **obj, const char *kind,
const char *name, size_t size, Error **errp);
void visit_start_struct(Visitor *v, const char *name, void **obj,
const char *kind, size_t size, Error **errp);
void visit_end_struct(Visitor *v, Error **errp);
void visit_start_implicit_struct(Visitor *v, void **obj, size_t size,
Error **errp);
@ -43,7 +43,7 @@ void visit_end_list(Visitor *v);
* corresponding visit_type_*() needs calling; for other visitors,
* leave *@present unchanged. Return *@present for convenience.
*/
bool visit_optional(Visitor *v, bool *present, const char *name);
bool visit_optional(Visitor *v, const char *name, bool *present);
/**
* Determine the qtype of the item @name in the current object visit.
@ -51,24 +51,34 @@ bool visit_optional(Visitor *v, bool *present, const char *name);
* alternate type; for other visitors, leave *@type unchanged.
* If @promote_int, treat integers as QTYPE_FLOAT.
*/
void visit_get_next_type(Visitor *v, QType *type, bool promote_int,
const char *name, Error **errp);
void visit_type_enum(Visitor *v, int *obj, const char * const strings[],
const char *kind, const char *name, Error **errp);
void visit_type_int(Visitor *v, int64_t *obj, const char *name, Error **errp);
void visit_type_uint8(Visitor *v, uint8_t *obj, const char *name, Error **errp);
void visit_type_uint16(Visitor *v, uint16_t *obj, const char *name, Error **errp);
void visit_type_uint32(Visitor *v, uint32_t *obj, const char *name, Error **errp);
void visit_type_uint64(Visitor *v, uint64_t *obj, const char *name, Error **errp);
void visit_type_int8(Visitor *v, int8_t *obj, const char *name, Error **errp);
void visit_type_int16(Visitor *v, int16_t *obj, const char *name, Error **errp);
void visit_type_int32(Visitor *v, int32_t *obj, const char *name, Error **errp);
void visit_type_int64(Visitor *v, int64_t *obj, const char *name, Error **errp);
void visit_type_size(Visitor *v, uint64_t *obj, const char *name, Error **errp);
void visit_type_bool(Visitor *v, bool *obj, const char *name, Error **errp);
void visit_type_str(Visitor *v, char **obj, const char *name, Error **errp);
void visit_type_number(Visitor *v, double *obj, const char *name, Error **errp);
void visit_type_any(Visitor *v, QObject **obj, const char *name, Error **errp);
void visit_get_next_type(Visitor *v, const char *name, QType *type,
bool promote_int, Error **errp);
void visit_type_enum(Visitor *v, const char *name, int *obj,
const char *const strings[], const char *kind,
Error **errp);
void visit_type_int(Visitor *v, const char *name, int64_t *obj, Error **errp);
void visit_type_uint8(Visitor *v, const char *name, uint8_t *obj,
Error **errp);
void visit_type_uint16(Visitor *v, const char *name, uint16_t *obj,
Error **errp);
void visit_type_uint32(Visitor *v, const char *name, uint32_t *obj,
Error **errp);
void visit_type_uint64(Visitor *v, const char *name, uint64_t *obj,
Error **errp);
void visit_type_int8(Visitor *v, const char *name, int8_t *obj, Error **errp);
void visit_type_int16(Visitor *v, const char *name, int16_t *obj,
Error **errp);
void visit_type_int32(Visitor *v, const char *name, int32_t *obj,
Error **errp);
void visit_type_int64(Visitor *v, const char *name, int64_t *obj,
Error **errp);
void visit_type_size(Visitor *v, const char *name, uint64_t *obj,
Error **errp);
void visit_type_bool(Visitor *v, const char *name, bool *obj, Error **errp);
void visit_type_str(Visitor *v, const char *name, char **obj, Error **errp);
void visit_type_number(Visitor *v, const char *name, double *obj,
Error **errp);
void visit_type_any(Visitor *v, const char *name, QObject **obj, Error **errp);
bool visit_start_union(Visitor *v, bool data_present, Error **errp);
#endif

View file

@ -892,7 +892,7 @@ static void memory_region_get_addr(struct uc_struct *uc, Object *obj, Visitor *v
MemoryRegion *mr = MEMORY_REGION(uc, obj);
uint64_t value = mr->addr;
visit_type_uint64(v, &value, name, errp);
visit_type_uint64(v, name, &value, errp);
}
static void memory_region_get_container(struct uc_struct *uc, Object *obj, Visitor *v, void *opaque,
@ -904,7 +904,7 @@ static void memory_region_get_container(struct uc_struct *uc, Object *obj, Visit
if (mr->container) {
path = object_get_canonical_path(OBJECT(mr->container));
}
visit_type_str(v, &path, name, errp);
visit_type_str(v, name, &path, errp);
if (mr->container) {
g_free(path);
}
@ -924,7 +924,7 @@ static void memory_region_get_priority(struct uc_struct *uc, Object *obj, Visito
MemoryRegion *mr = MEMORY_REGION(uc, obj);
int32_t value = mr->priority;
visit_type_int32(v, &value, name, errp);
visit_type_int32(v, name, &value, errp);
}
static bool memory_region_get_may_overlap(struct uc_struct *uc, Object *obj, Error **errp)
@ -940,7 +940,7 @@ static void memory_region_get_size(struct uc_struct *uc, Object *obj, Visitor *v
MemoryRegion *mr = MEMORY_REGION(uc, obj);
uint64_t value = memory_region_size(mr);
visit_type_uint64(v, &value, name, errp);
visit_type_uint64(v, name, &value, errp);
}
static void memory_region_initfn(struct uc_struct *uc, Object *obj, void *opaque)

View file

@ -20,8 +20,8 @@
#include "qapi/visitor.h"
#include "qapi/visitor-impl.h"
void visit_start_struct(Visitor *v, void **obj, const char *kind,
const char *name, size_t size, Error **errp)
void visit_start_struct(Visitor *v, const char *name, void **obj,
const char *kind, size_t size, Error **errp)
{
v->start_struct(v, obj, kind, name, size, errp);
}
@ -69,7 +69,7 @@ bool visit_start_union(Visitor *v, bool data_present, Error **errp)
return true;
}
bool visit_optional(Visitor *v, bool *present, const char *name)
bool visit_optional(Visitor *v, const char *name, bool *present)
{
if (v->optional) {
v->optional(v, present, name);
@ -77,26 +77,28 @@ bool visit_optional(Visitor *v, bool *present, const char *name)
return *present;
}
void visit_get_next_type(Visitor *v, QType *type, bool promote_int,
const char *name, Error **errp)
void visit_get_next_type(Visitor *v, const char *name, QType *type,
bool promote_int, Error **errp)
{
if (v->get_next_type) {
v->get_next_type(v, type, promote_int, name, errp);
}
}
void visit_type_enum(Visitor *v, int *obj, const char * const strings[],
const char *kind, const char *name, Error **errp)
void visit_type_enum(Visitor *v, const char *name, int *obj,
const char *const strings[], const char *kind,
Error **errp)
{
v->type_enum(v, obj, strings, kind, name, errp);
}
void visit_type_int(Visitor *v, int64_t *obj, const char *name, Error **errp)
void visit_type_int(Visitor *v, const char *name, int64_t *obj, Error **errp)
{
v->type_int64(v, obj, name, errp);
}
void visit_type_uint8(Visitor *v, uint8_t *obj, const char *name, Error **errp)
void visit_type_uint8(Visitor *v, const char *name, uint8_t *obj,
Error **errp)
{
uint64_t value;
@ -116,7 +118,8 @@ void visit_type_uint8(Visitor *v, uint8_t *obj, const char *name, Error **errp)
}
}
void visit_type_uint16(Visitor *v, uint16_t *obj, const char *name, Error **errp)
void visit_type_uint16(Visitor *v, const char *name, uint16_t *obj,
Error **errp)
{
uint64_t value;
@ -136,7 +139,8 @@ void visit_type_uint16(Visitor *v, uint16_t *obj, const char *name, Error **errp
}
}
void visit_type_uint32(Visitor *v, uint32_t *obj, const char *name, Error **errp)
void visit_type_uint32(Visitor *v, const char *name, uint32_t *obj,
Error **errp)
{
uint64_t value;
@ -156,12 +160,13 @@ void visit_type_uint32(Visitor *v, uint32_t *obj, const char *name, Error **errp
}
}
void visit_type_uint64(Visitor *v, uint64_t *obj, const char *name, Error **errp)
void visit_type_uint64(Visitor *v, const char *name, uint64_t *obj,
Error **errp)
{
v->type_uint64(v, obj, name, errp);
}
void visit_type_int8(Visitor *v, int8_t *obj, const char *name, Error **errp)
void visit_type_int8(Visitor *v, const char *name, int8_t *obj, Error **errp)
{
int64_t value;
@ -181,7 +186,8 @@ void visit_type_int8(Visitor *v, int8_t *obj, const char *name, Error **errp)
}
}
void visit_type_int16(Visitor *v, int16_t *obj, const char *name, Error **errp)
void visit_type_int16(Visitor *v, const char *name, int16_t *obj,
Error **errp)
{
int64_t value;
@ -201,7 +207,8 @@ void visit_type_int16(Visitor *v, int16_t *obj, const char *name, Error **errp)
}
}
void visit_type_int32(Visitor *v, int32_t *obj, const char *name, Error **errp)
void visit_type_int32(Visitor *v, const char *name, int32_t *obj,
Error **errp)
{
int64_t value;
@ -221,12 +228,14 @@ void visit_type_int32(Visitor *v, int32_t *obj, const char *name, Error **errp)
}
}
void visit_type_int64(Visitor *v, int64_t *obj, const char *name, Error **errp)
void visit_type_int64(Visitor *v, const char *name, int64_t *obj,
Error **errp)
{
v->type_int64(v, obj, name, errp);
}
void visit_type_size(Visitor *v, uint64_t *obj, const char *name, Error **errp)
void visit_type_size(Visitor *v, const char *name, uint64_t *obj,
Error **errp)
{
if (v->type_size) {
v->type_size(v, obj, name, errp);
@ -235,23 +244,23 @@ void visit_type_size(Visitor *v, uint64_t *obj, const char *name, Error **errp)
}
}
void visit_type_bool(Visitor *v, bool *obj, const char *name, Error **errp)
void visit_type_bool(Visitor *v, const char *name, bool *obj, Error **errp)
{
v->type_bool(v, obj, name, errp);
}
void visit_type_str(Visitor *v, char **obj, const char *name, Error **errp)
void visit_type_str(Visitor *v, const char *name, char **obj, Error **errp)
{
v->type_str(v, obj, name, errp);
}
void visit_type_number(Visitor *v, double *obj, const char *name, Error **errp)
void visit_type_number(Visitor *v, const char *name, double *obj,
Error **errp)
{
v->type_number(v, obj, name, errp);
}
void visit_type_any(Visitor *v, QObject **obj, const char *name,
Error **errp)
void visit_type_any(Visitor *v, const char *name, QObject **obj, Error **errp)
{
v->type_any(v, obj, name, errp);
}
@ -272,7 +281,7 @@ void output_type_enum(Visitor *v, int *obj, const char * const strings[],
}
enum_str = (char *)strings[value];
visit_type_str(v, &enum_str, name, errp);
visit_type_str(v, name, &enum_str, errp);
}
void input_type_enum(Visitor *v, int *obj, const char * const strings[],
@ -285,7 +294,7 @@ void input_type_enum(Visitor *v, int *obj, const char * const strings[],
assert(strings);
visit_type_str(v, &enum_str, name, &local_err);
visit_type_str(v, name, &enum_str, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;

View file

@ -1036,7 +1036,7 @@ static void object_get_child_property(struct uc_struct *uc, Object *obj, Visitor
gchar *path;
path = object_get_canonical_path(child);
visit_type_str(v, &path, name, errp);
visit_type_str(v, name, &path, errp);
g_free(path);
}
@ -1107,11 +1107,11 @@ static void object_get_link_property(struct uc_struct *uc, Object *obj, Visitor
if (*child) {
path = object_get_canonical_path(*child);
visit_type_str(v, &path, name, errp);
visit_type_str(v, name, &path, errp);
g_free(path);
} else {
path = (gchar *)"";
visit_type_str(v, &path, name, errp);
visit_type_str(v, name, &path, errp);
}
}
@ -1165,7 +1165,7 @@ static int object_set_link_property(struct uc_struct *uc, Object *obj, Visitor *
Object *new_target = NULL;
char *path = NULL;
visit_type_str(v, &path, name, &local_err);
visit_type_str(v, name, &path, &local_err);
if (!local_err && strcmp(path, "") != 0) {
new_target = object_resolve_link(uc, obj, name, path, &local_err);
@ -1414,7 +1414,7 @@ static void property_get_str(struct uc_struct *uc, Object *obj, Visitor *v, void
return;
}
visit_type_str(v, &value, name, errp);
visit_type_str(v, name, &value, errp);
g_free(value);
}
@ -1425,7 +1425,7 @@ static int property_set_str(struct uc_struct *uc, Object *obj, Visitor *v, void
char *value;
Error *local_err = NULL;
visit_type_str(v, &value, name, &local_err);
visit_type_str(v, name, &value, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return -1;
@ -1479,7 +1479,7 @@ static void property_get_bool(struct uc_struct *uc, Object *obj, Visitor *v, voi
bool value;
value = prop->get(uc, obj, errp);
visit_type_bool(v, &value, name, errp);
visit_type_bool(v, name, &value, errp);
}
static int property_set_bool(struct uc_struct *uc, Object *obj, Visitor *v, void *opaque,
@ -1489,7 +1489,7 @@ static int property_set_bool(struct uc_struct *uc, Object *obj, Visitor *v, void
bool value;
Error *local_err = NULL;
visit_type_bool(v, &value, name, &local_err);
visit_type_bool(v, name, &value, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return -1;
@ -1537,7 +1537,7 @@ static void property_get_uint8_ptr(struct uc_struct *uc, Object *obj, Visitor *v
Error **errp)
{
uint8_t value = *(uint8_t *)opaque;
visit_type_uint8(v, &value, name, errp);
visit_type_uint8(v, name, &value, errp);
}
static void property_get_uint16_ptr(struct uc_struct *uc, Object *obj, Visitor *v,
@ -1545,7 +1545,7 @@ static void property_get_uint16_ptr(struct uc_struct *uc, Object *obj, Visitor *
Error **errp)
{
uint16_t value = *(uint16_t *)opaque;
visit_type_uint16(v, &value, name, errp);
visit_type_uint16(v, name, &value, errp);
}
static void property_get_uint32_ptr(struct uc_struct *uc, Object *obj, Visitor *v,
@ -1553,7 +1553,7 @@ static void property_get_uint32_ptr(struct uc_struct *uc, Object *obj, Visitor *
Error **errp)
{
uint32_t value = *(uint32_t *)opaque;
visit_type_uint32(v, &value, name, errp);
visit_type_uint32(v, name, &value, errp);
}
static void property_get_uint64_ptr(struct uc_struct *uc, Object *obj, Visitor *v,
@ -1561,7 +1561,7 @@ static void property_get_uint64_ptr(struct uc_struct *uc, Object *obj, Visitor *
Error **errp)
{
uint64_t value = *(uint64_t *)opaque;
visit_type_uint64(v, &value, name, errp);
visit_type_uint64(v, name, &value, errp);
}
void object_property_add_uint8_ptr(Object *obj, const char *name,

View file

@ -63,7 +63,7 @@ def gen_event_send(name, arg_type):
v = qmp_output_get_visitor(qov);
visit_start_struct(v, NULL, NULL, "%(name)s", 0, &err);
visit_start_struct(v, "%(name)s", NULL, NULL, 0, &err);
''',
name=name)
ret += gen_err_check()

View file

@ -186,7 +186,7 @@ void qapi_free_%(c_name)s(%(c_name)s *obj)
qdv = qapi_dealloc_visitor_new();
v = qapi_dealloc_get_visitor(qdv);
visit_type_%(c_name)s(v, &obj, NULL, NULL);
visit_type_%(c_name)s(v, NULL, &obj, NULL);
qapi_dealloc_visitor_cleanup(qdv);
}
''',

View file

@ -28,7 +28,7 @@ def gen_visit_decl(name, scalar=False):
if not scalar:
c_type += '*'
return mcgen('''
void visit_type_%(c_name)s(Visitor *v, %(c_type)sobj, const char *name, Error **errp);
void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_type)sobj, Error **errp);
''',
c_name=c_name(name), c_type=c_type)
@ -115,11 +115,11 @@ def gen_visit_struct(name, base, members):
# call qapi_free_FOO() to avoid a memory leak of the partial FOO.
ret += mcgen('''
void visit_type_%(c_name)s(Visitor *v, %(c_name)s **obj, const char *name, Error **errp)
void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj, Error **errp)
{
Error *err = NULL;
visit_start_struct(v, (void **)obj, "%(name)s", name, sizeof(%(c_name)s), &err);
visit_start_struct(v, name, (void **)obj, "%(name)s", sizeof(%(c_name)s), &err);
if (err) {
goto out;
@ -147,7 +147,7 @@ def gen_visit_list(name, element_type):
# call qapi_free_FOOList() to avoid a memory leak of the partial FOOList.
return mcgen('''
void visit_type_%(c_name)s(Visitor *v, %(c_name)s **obj, const char *name, Error **errp)
void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj, Error **errp)
{
Error *err = NULL;
GenericList *i, **prev;
@ -161,7 +161,7 @@ void visit_type_%(c_name)s(Visitor *v, %(c_name)s **obj, const char *name, Error
!err && (i = visit_next_list(v, prev)) != NULL;
prev = &i) {
%(c_name)s *native_i = (%(c_name)s *)i;
visit_type_%(c_elt_type)s(v, &native_i->value, NULL, &err);
visit_type_%(c_elt_type)s(v, NULL, &native_i->value, &err);
}
error_propagate(errp, err);
@ -177,10 +177,10 @@ out:
def gen_visit_enum(name):
return mcgen('''
void visit_type_%(c_name)s(Visitor *v, %(c_name)s *obj, const char *name, Error **errp)
void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s *obj, Error **errp)
{
int value = *obj;
visit_type_enum(v, &value, %(c_name)s_lookup, "%(name)s", name, errp);
visit_type_enum(v, name, &value, %(c_name)s_lookup, "%(name)s", errp);
*obj = value;
}
''',
@ -195,7 +195,7 @@ def gen_visit_alternate(name, variants):
ret = mcgen('''
void visit_type_%(c_name)s(Visitor *v, %(c_name)s **obj, const char *name, Error **errp)
void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj, Error **errp)
{
Error *err = NULL;
@ -203,7 +203,7 @@ void visit_type_%(c_name)s(Visitor *v, %(c_name)s **obj, const char *name, Error
if (err) {
goto out;
}
visit_get_next_type(v, &(*obj)->type, %(promote_int)s, name, &err);
visit_get_next_type(v, name, &(*obj)->type, %(promote_int)s, &err);
if (err) {
goto out_obj;
}
@ -214,7 +214,7 @@ void visit_type_%(c_name)s(Visitor *v, %(c_name)s **obj, const char *name, Error
for var in variants.variants:
ret += mcgen('''
case %(case)s:
visit_type_%(c_type)s(v, &(*obj)->u.%(c_name)s, name, &err);
visit_type_%(c_type)s(v, name, &(*obj)->u.%(c_name)s, &err);
break;
''',
case=var.type.alternate_qtype(),
@ -252,11 +252,11 @@ def gen_visit_union(name, base, variants):
ret += mcgen('''
void visit_type_%(c_name)s(Visitor *v, %(c_name)s **obj, const char *name, Error **errp)
void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj, Error **errp)
{
Error *err = NULL;
visit_start_struct(v, (void **)obj, "%(name)s", name, sizeof(%(c_name)s), &err);
visit_start_struct(v, name, (void **)obj, "%(name)s", sizeof(%(c_name)s), &err);
if (err) {
goto out;
}
@ -273,7 +273,7 @@ void visit_type_%(c_name)s(Visitor *v, %(c_name)s **obj, const char *name, Error
c_name=base.c_name())
else:
ret += mcgen('''
visit_type_%(c_type)s(v, &(*obj)->%(c_name)s, "%(name)s", &err);
visit_type_%(c_type)s(v, "%(name)s", &(*obj)->%(c_name)s, &err);
''',
c_type=variants.tag_member.type.c_name(),
c_name=c_name(variants.tag_member.name),
@ -297,7 +297,7 @@ void visit_type_%(c_name)s(Visitor *v, %(c_name)s **obj, const char *name, Error
var.name))
if simple_union_type:
ret += mcgen('''
visit_type_%(c_type)s(v, &(*obj)->u.%(c_name)s, "data", &err);
visit_type_%(c_type)s(v, "data", &(*obj)->u.%(c_name)s, &err);
''',
c_type=simple_union_type.c_name(),
c_name=c_name(var.name))

View file

@ -1647,7 +1647,7 @@ def gen_visit_fields(members, prefix='', need_cast=False, skiperr=False,
for memb in members:
if memb.optional:
ret += mcgen('''
if (visit_optional(v, &%(prefix)shas_%(c_name)s, "%(name)s")) {
if (visit_optional(v, "%(name)s", &%(prefix)shas_%(c_name)s)) {
''',
prefix=prefix, c_name=c_name(memb.name),
name=memb.name)
@ -1660,7 +1660,7 @@ def gen_visit_fields(members, prefix='', need_cast=False, skiperr=False,
cast = ''
ret += mcgen('''
visit_type_%(c_type)s(v, %(cast)s&%(prefix)s%(c_name)s, "%(name)s", %(errp)s);
visit_type_%(c_type)s(v, "%(name)s", %(cast)s&%(prefix)s%(c_name)s, %(errp)s);
''',
c_type=memb.type.c_name(), prefix=prefix, cast=cast,
c_name=c_name(memb.name), name=memb.name,

View file

@ -1544,7 +1544,7 @@ static void x86_cpuid_version_get_family(struct uc_struct *uc, Object *obj, Visi
if (value == 0xf) {
value += (env->cpuid_version >> 20) & 0xff;
}
visit_type_int(v, &value, name, errp);
visit_type_int(v, name, &value, errp);
}
static int x86_cpuid_version_set_family(struct uc_struct *uc, Object *obj, Visitor *v, void *opaque,
@ -1557,7 +1557,7 @@ static int x86_cpuid_version_set_family(struct uc_struct *uc, Object *obj, Visit
Error *local_err = NULL;
int64_t value;
visit_type_int(v, &value, name, &local_err);
visit_type_int(v, name, &value, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return -1;
@ -1587,7 +1587,7 @@ static void x86_cpuid_version_get_model(struct uc_struct *uc, Object *obj, Visit
value = (env->cpuid_version >> 4) & 0xf;
value |= ((env->cpuid_version >> 16) & 0xf) << 4;
visit_type_int(v, &value, name, errp);
visit_type_int(v, name, &value, errp);
}
static int x86_cpuid_version_set_model(struct uc_struct *uc, Object *obj, Visitor *v, void *opaque,
@ -1600,7 +1600,7 @@ static int x86_cpuid_version_set_model(struct uc_struct *uc, Object *obj, Visito
Error *local_err = NULL;
int64_t value;
visit_type_int(v, &value, name, &local_err);
visit_type_int(v, name, &value, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return -1;
@ -1626,7 +1626,7 @@ static void x86_cpuid_version_get_stepping(struct uc_struct *uc, Object *obj, Vi
int64_t value;
value = env->cpuid_version & 0xf;
visit_type_int(v, &value, name, errp);
visit_type_int(v, name, &value, errp);
}
static int x86_cpuid_version_set_stepping(struct uc_struct *uc, Object *obj, Visitor *v,
@ -1640,7 +1640,7 @@ static int x86_cpuid_version_set_stepping(struct uc_struct *uc, Object *obj, Vis
Error *local_err = NULL;
int64_t value;
visit_type_int(v, &value, name, &local_err);
visit_type_int(v, name, &value, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return -1;
@ -1740,7 +1740,7 @@ static void x86_cpuid_get_tsc_freq(struct uc_struct *uc, Object *obj, Visitor *v
int64_t value;
value = cpu->env.tsc_khz * 1000;
visit_type_int(v, &value, name, errp);
visit_type_int(v, name, &value, errp);
}
static int x86_cpuid_set_tsc_freq(struct uc_struct *uc, Object *obj, Visitor *v, void *opaque,
@ -1752,7 +1752,7 @@ static int x86_cpuid_set_tsc_freq(struct uc_struct *uc, Object *obj, Visitor *v,
Error *local_err = NULL;
int64_t value;
visit_type_int(v, &value, name, &local_err);
visit_type_int(v, name, &value, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return -1;
@ -1774,7 +1774,7 @@ static void x86_cpuid_get_apic_id(struct uc_struct *uc, Object *obj, Visitor *v,
X86CPU *cpu = X86_CPU(uc, obj);
int64_t value = cpu->apic_id;
visit_type_int(v, &value, name, errp);
visit_type_int(v, name, &value, errp);
}
static int x86_cpuid_set_apic_id(struct uc_struct *uc, Object *obj, Visitor *v, void *opaque,
@ -1793,7 +1793,7 @@ static int x86_cpuid_set_apic_id(struct uc_struct *uc, Object *obj, Visitor *v,
return -1;
}
visit_type_int(v, &value, name, &error);
visit_type_int(v, name, &value, &error);
if (error) {
error_propagate(errp, error);
return -1;
@ -1841,7 +1841,7 @@ static void x86_cpu_get_feature_words(struct uc_struct *uc, Object *obj, Visitor
list = &list_entries[w];
}
visit_type_X86CPUFeatureWordInfoList(v, &list, "feature-words", &err);
visit_type_X86CPUFeatureWordInfoList(v, "feature-words", &list, &err);
error_propagate(errp, err);
}