mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2024-12-23 14:05:34 +00:00
qapi: Support downstream structs
Enhance the testsuite to cover downstream structs, including struct members and base structs. Update the generator to mangle the struct names in the appropriate places. Backports commit 83a02706bb1fd31c93eab755de543dfe228682d4 from qemu
This commit is contained in:
parent
1a5b6a48d1
commit
2d14039f98
|
@ -45,7 +45,7 @@ typedef struct %(name)sList
|
|||
struct %(name)sList *next;
|
||||
} %(name)sList;
|
||||
''',
|
||||
name=name)
|
||||
name=c_name(name))
|
||||
|
||||
def generate_fwd_enum_struct(name, members):
|
||||
return mcgen('''
|
||||
|
@ -87,7 +87,7 @@ def generate_struct(expr):
|
|||
struct %(name)s
|
||||
{
|
||||
''',
|
||||
name=structname)
|
||||
name=c_name(structname))
|
||||
|
||||
if base:
|
||||
ret += generate_struct_fields({'base': base})
|
||||
|
|
|
@ -56,7 +56,7 @@ static void visit_type_%(name)s_fields(Visitor *m, %(name)s **obj, Error **errp)
|
|||
{
|
||||
Error *err = NULL;
|
||||
''',
|
||||
name=name)
|
||||
name=c_name(name))
|
||||
push_indent()
|
||||
|
||||
if base:
|
||||
|
@ -111,17 +111,17 @@ def generate_visit_struct_body(name, members):
|
|||
ret = mcgen('''
|
||||
Error *err = NULL;
|
||||
|
||||
visit_start_struct(m, (void **)obj, "%(name)s", name, sizeof(%(name)s), &err);
|
||||
visit_start_struct(m, (void **)obj, "%(name)s", name, sizeof(%(c_name)s), &err);
|
||||
|
||||
if (!err) {
|
||||
if (*obj) {
|
||||
visit_type_%(name)s_fields(m, obj, errp);
|
||||
visit_type_%(c_name)s_fields(m, obj, errp);
|
||||
}
|
||||
visit_end_struct(m, &err);
|
||||
}
|
||||
error_propagate(errp, err);
|
||||
''',
|
||||
name=name)
|
||||
name=name, c_name=c_name(name))
|
||||
|
||||
return ret
|
||||
|
||||
|
@ -138,7 +138,7 @@ def generate_visit_struct(expr):
|
|||
void visit_type_%(name)s(Visitor *m, %(name)s **obj, const char *name, Error **errp)
|
||||
{
|
||||
''',
|
||||
name=name)
|
||||
name=c_name(name))
|
||||
|
||||
ret += generate_visit_struct_body(name, members)
|
||||
|
||||
|
@ -348,6 +348,7 @@ out:
|
|||
def generate_declaration(name, members, builtin_type=False):
|
||||
ret = ""
|
||||
if not builtin_type:
|
||||
name = c_name(name)
|
||||
ret += mcgen('''
|
||||
|
||||
void visit_type_%(name)s(Visitor *m, %(name)s **obj, const char *name, Error **errp);
|
||||
|
|
Loading…
Reference in a new issue