qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 02/18] qapi-types.py: Implement 'base' for union


From: Kevin Wolf
Subject: Re: [Qemu-devel] [PATCH 02/18] qapi-types.py: Implement 'base' for unions
Date: Tue, 27 Aug 2013 17:58:59 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

Am 21.08.2013 um 05:38 hat Amos Kong geschrieben:
> On Tue, Jul 23, 2013 at 03:03:10PM +0200, Kevin Wolf wrote:
> > The new 'base' key in a union definition refers to a struct type, which
> > is inlined into the union definition and can represent fields common to
> > all kinds.
> > 
> > For example the following schema definition...
> > 
> >     { 'type': 'BlockOptionsBase', 'data': { 'read-only': 'bool' } }
> > 
> >     { 'union': 'BlockOptions',
> >       'base': 'BlockOptionsBase',
> >       'data': {
> >           'raw': 'BlockOptionsRaw'
> >           'qcow2': 'BlockOptionsQcow2'
> >       } }
> > 
> > ...would result in this generated C struct:
> > 
> >     struct BlockOptions
> >     {
> >         BlockOptionsKind kind;
> >         union {
> >             void *data;
> >             BlockOptionsRaw * raw;
> >             BlockOptionsQcow2 * qcow2;
> >         };
> >         bool read_only;
> >     };
> > 
> > Signed-off-by: Kevin Wolf <address@hidden>
> > ---
> >  scripts/qapi-types.py | 16 ++++++++++++++--
> >  1 file changed, 14 insertions(+), 2 deletions(-)
> > 
> > diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
> > index e1239e1..9882b95 100644
> > --- a/scripts/qapi-types.py
> > +++ b/scripts/qapi-types.py
> > @@ -157,7 +157,12 @@ typedef enum %(name)s
> >  
> >      return lookup_decl + enum_decl
> >  
> > -def generate_union(name, typeinfo):
> > +def generate_union(expr):
> > +
> > +    name = expr['union']
> > +    typeinfo = expr['data']
> > +    base = expr.get('base')
> > +
> >      ret = mcgen('''
> >  struct %(name)s
> >  {
> > @@ -176,6 +181,13 @@ struct %(name)s
> >  
> >      ret += mcgen('''
> >      };
> > +''')
> > +
> > +    if base:
> > +        struct = find_struct(base)
> > +        ret += generate_struct_fields(struct['data'])
> 
> 
> generate_struct_fields() doesn't exist in upstream.
> 
> [qemu-upstream]$ grep generate_struct_fields -r *
> scripts/qapi-types.py:        ret += generate_struct_fields(struct['data'])
> [qemu-upstream]$

Yup, something went wrong while applying the series, that patch was
simply dropped (and interestingly it didn't result in any conflicts or
compile errors). I'll include it in my next pull request.

If you need it before that, you can apply the patch manually from the
mailing list, its subject line is:

    qapi-types.py: Split off generate_struct_fields()

Kevin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]