mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 04:13:53 -06:00
qapi-types/visit.py: Inheritance for structs
This introduces a new 'base' key for struct definitions that refers to another struct type. On the JSON level, the fields of the base type are included directly into the same namespace as the fields of the defined type, like with unions. On the C level, a pointer to a struct of the base type is included. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
14d36307ff
commit
622f557f5a
3 changed files with 37 additions and 2 deletions
|
@ -86,6 +86,7 @@ def generate_struct(expr):
|
|||
structname = expr.get('type', "")
|
||||
fieldname = expr.get('field', "")
|
||||
members = expr['data']
|
||||
base = expr.get('base')
|
||||
|
||||
ret = mcgen('''
|
||||
struct %(name)s
|
||||
|
@ -93,6 +94,9 @@ struct %(name)s
|
|||
''',
|
||||
name=structname)
|
||||
|
||||
if base:
|
||||
ret += generate_struct_fields({'base': base})
|
||||
|
||||
ret += generate_struct_fields(members)
|
||||
|
||||
if len(fieldname):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue