Patchwork qapi: escaping the dots in c_var

login
register
mail settings
Submitter Federico Simoncelli
Date March 15, 2012, 1:53 p.m.
Message ID <1331819618-12481-1-git-send-email-fsimonce@redhat.com>
Download mbox | patch
Permalink /patch/146969/
State New
Headers show

Comments

Federico Simoncelli - March 15, 2012, 1:53 p.m.
This allows qapi commands and types with dots.

Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
---
 scripts/qapi.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Michael Roth - March 15, 2012, 2:51 p.m.
On Thu, Mar 15, 2012 at 01:53:38PM +0000, Federico Simoncelli wrote:
> This allows qapi commands and types with dots.
> 
> Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
> ---
>  scripts/qapi.py |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/scripts/qapi.py b/scripts/qapi.py
> index 6e05469..4090c55 100644
> --- a/scripts/qapi.py
> +++ b/scripts/qapi.py
> @@ -131,7 +131,7 @@ def camel_case(name):
>      return new_name
> 
>  def c_var(name):
> -    return '_'.join(name.split('-')).lstrip("*")
> +    return name.replace('-', '_').replace('.', '_').lstrip('*')

What are you looking to use this for? The general rule so far has been to
always use "-" as the word delimiter.

> 
>  def c_list_type(name):
>      return '%sList' % name
> -- 
> 1.7.1
> 
>
Luiz Capitulino - March 15, 2012, 3:03 p.m.
On Thu, 15 Mar 2012 09:51:10 -0500
Michael Roth <mdroth@linux.vnet.ibm.com> wrote:

> On Thu, Mar 15, 2012 at 01:53:38PM +0000, Federico Simoncelli wrote:
> > This allows qapi commands and types with dots.
> > 
> > Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
> > ---
> >  scripts/qapi.py |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> > 
> > diff --git a/scripts/qapi.py b/scripts/qapi.py
> > index 6e05469..4090c55 100644
> > --- a/scripts/qapi.py
> > +++ b/scripts/qapi.py
> > @@ -131,7 +131,7 @@ def camel_case(name):
> >      return new_name
> > 
> >  def c_var(name):
> > -    return '_'.join(name.split('-')).lstrip("*")
> > +    return name.replace('-', '_').replace('.', '_').lstrip('*')
> 
> What are you looking to use this for? The general rule so far has been to
> always use "-" as the word delimiter.

Downstream extensions of QMP (commands, events, etc) are fully qualified
domain names, and hence contain dots.
Michael Roth - March 15, 2012, 3:42 p.m.
On Thu, Mar 15, 2012 at 12:03:30PM -0300, Luiz Capitulino wrote:
> On Thu, 15 Mar 2012 09:51:10 -0500
> Michael Roth <mdroth@linux.vnet.ibm.com> wrote:
> 
> > On Thu, Mar 15, 2012 at 01:53:38PM +0000, Federico Simoncelli wrote:
> > > This allows qapi commands and types with dots.
> > > 
> > > Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
> > > ---
> > >  scripts/qapi.py |    2 +-
> > >  1 files changed, 1 insertions(+), 1 deletions(-)
> > > 
> > > diff --git a/scripts/qapi.py b/scripts/qapi.py
> > > index 6e05469..4090c55 100644
> > > --- a/scripts/qapi.py
> > > +++ b/scripts/qapi.py
> > > @@ -131,7 +131,7 @@ def camel_case(name):
> > >      return new_name
> > > 
> > >  def c_var(name):
> > > -    return '_'.join(name.split('-')).lstrip("*")
> > > +    return name.replace('-', '_').replace('.', '_').lstrip('*')
> > 
> > What are you looking to use this for? The general rule so far has been to
> > always use "-" as the word delimiter.
> 
> Downstream extensions of QMP (commands, events, etc) are fully qualified
> domain names, and hence contain dots.
> 

Ahh, thanks. Patch looks good :)

Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>

Patch

diff --git a/scripts/qapi.py b/scripts/qapi.py
index 6e05469..4090c55 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -131,7 +131,7 @@  def camel_case(name):
     return new_name
 
 def c_var(name):
-    return '_'.join(name.split('-')).lstrip("*")
+    return name.replace('-', '_').replace('.', '_').lstrip('*')
 
 def c_list_type(name):
     return '%sList' % name