diff mbox

qapi: escaping the dots in c_var

Message ID 1331819618-12481-1-git-send-email-fsimonce@redhat.com
State New
Headers show

Commit Message

Federico Simoncelli March 15, 2012, 1:53 p.m. UTC
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(-)

Comments

Michael Roth March 15, 2012, 2:51 p.m. UTC | #1
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. UTC | #2
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. UTC | #3
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>
diff mbox

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