Message ID | 1407287673-20308-9-git-send-email-eblake@redhat.com |
---|---|
State | New |
Headers | show |
Eric Blake <eblake@redhat.com> writes: > Now that we know every expression has a known meta-type, we > can add a helper function that retrieves the name of an > arbitrary expression, for use in future error messages. > > * scripts/qapi.py (expr_name): New function. > > Signed-off-by: Eric Blake <eblake@redhat.com> > --- > scripts/qapi.py | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/scripts/qapi.py b/scripts/qapi.py > index 910e422..e02fa0b 100644 > --- a/scripts/qapi.py > +++ b/scripts/qapi.py > @@ -248,6 +248,19 @@ def discriminator_find_enum_define(expr): > > return find_enum(discriminator_type) > > +def expr_name(expr): > + if expr.has_key('union'): > + return expr['union'] > + if expr.has_key('type'): > + return expr['type'] > + if expr.has_key('enum'): > + return expr['enum'] > + if expr.has_key('command'): > + return expr['command'] > + if expr.has_key('event'): > + return expr['event'] > + return None > + > def check_event(expr, expr_info): > params = expr.get('data') > if params: Squash into the next commit?
diff --git a/scripts/qapi.py b/scripts/qapi.py index 910e422..e02fa0b 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -248,6 +248,19 @@ def discriminator_find_enum_define(expr): return find_enum(discriminator_type) +def expr_name(expr): + if expr.has_key('union'): + return expr['union'] + if expr.has_key('type'): + return expr['type'] + if expr.has_key('enum'): + return expr['enum'] + if expr.has_key('command'): + return expr['command'] + if expr.has_key('event'): + return expr['event'] + return None + def check_event(expr, expr_info): params = expr.get('data') if params:
Now that we know every expression has a known meta-type, we can add a helper function that retrieves the name of an arbitrary expression, for use in future error messages. * scripts/qapi.py (expr_name): New function. Signed-off-by: Eric Blake <eblake@redhat.com> --- scripts/qapi.py | 13 +++++++++++++ 1 file changed, 13 insertions(+)