* [Qemu-devel] [PATCH] qapi: escaping the dots in c_var
@ 2012-03-15 13:53 Federico Simoncelli
2012-03-15 14:51 ` Michael Roth
2012-03-15 15:45 ` [Qemu-devel] [PATCH v2] qapi: escaping dots in c_var and in de_camel_case Federico Simoncelli
0 siblings, 2 replies; 9+ messages in thread
From: Federico Simoncelli @ 2012-03-15 13:53 UTC (permalink / raw)
To: qemu-devel; +Cc: pbonzini, Federico Simoncelli, lcapitulino
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('*')
def c_list_type(name):
return '%sList' % name
--
1.7.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] qapi: escaping the dots in c_var
2012-03-15 13:53 [Qemu-devel] [PATCH] qapi: escaping the dots in c_var Federico Simoncelli
@ 2012-03-15 14:51 ` Michael Roth
2012-03-15 15:03 ` Luiz Capitulino
2012-03-15 15:45 ` [Qemu-devel] [PATCH v2] qapi: escaping dots in c_var and in de_camel_case Federico Simoncelli
1 sibling, 1 reply; 9+ messages in thread
From: Michael Roth @ 2012-03-15 14:51 UTC (permalink / raw)
To: Federico Simoncelli; +Cc: pbonzini, qemu-devel, lcapitulino
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
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] qapi: escaping the dots in c_var
2012-03-15 14:51 ` Michael Roth
@ 2012-03-15 15:03 ` Luiz Capitulino
2012-03-15 15:42 ` Michael Roth
0 siblings, 1 reply; 9+ messages in thread
From: Luiz Capitulino @ 2012-03-15 15:03 UTC (permalink / raw)
To: Michael Roth; +Cc: pbonzini, Federico Simoncelli, qemu-devel
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.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] qapi: escaping the dots in c_var
2012-03-15 15:03 ` Luiz Capitulino
@ 2012-03-15 15:42 ` Michael Roth
0 siblings, 0 replies; 9+ messages in thread
From: Michael Roth @ 2012-03-15 15:42 UTC (permalink / raw)
To: Luiz Capitulino; +Cc: pbonzini, Federico Simoncelli, qemu-devel
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>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH v2] qapi: escaping dots in c_var and in de_camel_case
2012-03-15 13:53 [Qemu-devel] [PATCH] qapi: escaping the dots in c_var Federico Simoncelli
2012-03-15 14:51 ` Michael Roth
@ 2012-03-15 15:45 ` Federico Simoncelli
2012-03-16 19:16 ` Luiz Capitulino
1 sibling, 1 reply; 9+ messages in thread
From: Federico Simoncelli @ 2012-03-15 15:45 UTC (permalink / raw)
To: qemu-devel; +Cc: pbonzini, Federico Simoncelli, lcapitulino
This allows qapi commands and types with dots (downstream QMP extensions
containing fully qualified domain names).
Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
---
scripts/qapi.py | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/qapi.py b/scripts/qapi.py
index 6e05469..b1173bf 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -111,7 +111,7 @@ def de_camel_case(name):
for ch in name:
if ch.isupper() and new_name:
new_name += '_'
- if ch == '-':
+ if ch == '-' or ch == '.':
new_name += '_'
else:
new_name += ch.lower()
@@ -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
--
1.7.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH v2] qapi: escaping dots in c_var and in de_camel_case
2012-03-15 15:45 ` [Qemu-devel] [PATCH v2] qapi: escaping dots in c_var and in de_camel_case Federico Simoncelli
@ 2012-03-16 19:16 ` Luiz Capitulino
2012-03-20 13:54 ` [Qemu-devel] [PATCH v3] qapi: add c_fun to escape function names Federico Simoncelli
0 siblings, 1 reply; 9+ messages in thread
From: Luiz Capitulino @ 2012-03-16 19:16 UTC (permalink / raw)
To: Federico Simoncelli; +Cc: pbonzini, qemu-devel
On Thu, 15 Mar 2012 15:45:59 +0000
Federico Simoncelli <fsimonce@redhat.com> wrote:
> This allows qapi commands and types with dots (downstream QMP extensions
> containing fully qualified domain names).
>
> Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
> ---
> scripts/qapi.py | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/qapi.py b/scripts/qapi.py
> index 6e05469..b1173bf 100644
> --- a/scripts/qapi.py
> +++ b/scripts/qapi.py
> @@ -111,7 +111,7 @@ def de_camel_case(name):
> for ch in name:
> if ch.isupper() and new_name:
> new_name += '_'
> - if ch == '-':
> + if ch == '-' or ch == '.':
> new_name += '_'
> else:
> new_name += ch.lower()
> @@ -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('*')
This changes a struct member access from 'foo.bar' to 'foo_bar' in the
generated qapi-visit.c.
Please, test build your patches against master before posting.
>
> def c_list_type(name):
> return '%sList' % name
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH v3] qapi: add c_fun to escape function names
2012-03-16 19:16 ` Luiz Capitulino
@ 2012-03-20 13:54 ` Federico Simoncelli
2012-03-23 20:38 ` Luiz Capitulino
2012-03-26 20:07 ` Anthony Liguori
0 siblings, 2 replies; 9+ messages in thread
From: Federico Simoncelli @ 2012-03-20 13:54 UTC (permalink / raw)
To: qemu-devel; +Cc: pbonzini, Federico Simoncelli, lcapitulino
Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
---
scripts/qapi-commands.py | 14 +++++++-------
scripts/qapi-types.py | 4 ++--
scripts/qapi-visit.py | 4 ++--
scripts/qapi.py | 5 ++++-
4 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py
index 3aabf61..30a24d2 100644
--- a/scripts/qapi-commands.py
+++ b/scripts/qapi-commands.py
@@ -42,7 +42,7 @@ def generate_command_decl(name, args, ret_type):
return mcgen('''
%(ret_type)s qmp_%(name)s(%(args)sError **errp);
''',
- ret_type=c_type(ret_type), name=c_var(name), args=arglist).strip()
+ ret_type=c_type(ret_type), name=c_fun(name), args=arglist).strip()
def gen_sync_call(name, args, ret_type, indent=0):
ret = ""
@@ -59,7 +59,7 @@ def gen_sync_call(name, args, ret_type, indent=0):
%(retval)sqmp_%(name)s(%(args)serrp);
''',
- name=c_var(name), args=arglist, retval=retval).rstrip()
+ name=c_fun(name), args=arglist, retval=retval).rstrip()
if ret_type:
ret += "\n" + mcgen(''''
if (!error_is_set(errp)) {
@@ -74,7 +74,7 @@ if (!error_is_set(errp)) {
def gen_marshal_output_call(name, ret_type):
if not ret_type:
return ""
- return "qmp_marshal_output_%s(retval, ret, errp);" % c_var(name)
+ return "qmp_marshal_output_%s(retval, ret, errp);" % c_fun(name)
def gen_visitor_output_containers_decl(ret_type):
ret = ""
@@ -198,16 +198,16 @@ static void qmp_marshal_output_%(c_name)s(%(c_ret_type)s ret_in, QObject **ret_o
qapi_dealloc_visitor_cleanup(md);
}
''',
- c_ret_type=c_type(ret_type), c_name=c_var(name),
+ c_ret_type=c_type(ret_type), c_name=c_fun(name),
visitor=type_visitor(ret_type))
return ret
def gen_marshal_input_decl(name, args, ret_type, middle_mode):
if middle_mode:
- return 'int qmp_marshal_input_%s(Monitor *mon, const QDict *qdict, QObject **ret)' % c_var(name)
+ return 'int qmp_marshal_input_%s(Monitor *mon, const QDict *qdict, QObject **ret)' % c_fun(name)
else:
- return 'static void qmp_marshal_input_%s(QDict *args, QObject **ret, Error **errp)' % c_var(name)
+ return 'static void qmp_marshal_input_%s(QDict *args, QObject **ret, Error **errp)' % c_fun(name)
@@ -298,7 +298,7 @@ def gen_registry(commands):
registry += mcgen('''
qmp_register_command("%(name)s", qmp_marshal_input_%(c_name)s);
''',
- name=cmd['command'], c_name=c_var(cmd['command']))
+ name=cmd['command'], c_name=c_fun(cmd['command']))
pop_indent()
ret = mcgen('''
static void qmp_init_marshal(void)
diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
index 727fb77..4a734f5 100644
--- a/scripts/qapi-types.py
+++ b/scripts/qapi-types.py
@@ -100,7 +100,7 @@ typedef enum %(name)s
%(abbrev)s_%(value)s = %(i)d,
''',
abbrev=de_camel_case(name).upper(),
- value=c_var(value).upper(),
+ value=c_fun(value).upper(),
i=i)
i += 1
@@ -126,7 +126,7 @@ struct %(name)s
%(c_type)s %(c_name)s;
''',
c_type=c_type(typeinfo[key]),
- c_name=c_var(key))
+ c_name=c_fun(key))
ret += mcgen('''
};
diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
index 54117d4..78c947c 100644
--- a/scripts/qapi-visit.py
+++ b/scripts/qapi-visit.py
@@ -129,9 +129,9 @@ void visit_type_%(name)s(Visitor *m, %(name)s ** obj, const char *name, Error **
break;
''',
abbrev = de_camel_case(name).upper(),
- enum = de_camel_case(key).upper(),
+ enum = c_fun(de_camel_case(key)).upper(),
c_type=members[key],
- c_name=c_var(key))
+ c_name=c_fun(key))
ret += mcgen('''
default:
diff --git a/scripts/qapi.py b/scripts/qapi.py
index 6e05469..e062336 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -131,7 +131,10 @@ def camel_case(name):
return new_name
def c_var(name):
- return '_'.join(name.split('-')).lstrip("*")
+ return name.replace('-', '_').lstrip("*")
+
+def c_fun(name):
+ return c_var(name).replace('.', '_')
def c_list_type(name):
return '%sList' % name
--
1.7.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH v3] qapi: add c_fun to escape function names
2012-03-20 13:54 ` [Qemu-devel] [PATCH v3] qapi: add c_fun to escape function names Federico Simoncelli
@ 2012-03-23 20:38 ` Luiz Capitulino
2012-03-26 20:07 ` Anthony Liguori
1 sibling, 0 replies; 9+ messages in thread
From: Luiz Capitulino @ 2012-03-23 20:38 UTC (permalink / raw)
To: Federico Simoncelli; +Cc: pbonzini, qemu-devel
On Tue, 20 Mar 2012 13:54:35 +0000
Federico Simoncelli <fsimonce@redhat.com> wrote:
> Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
This looks good now, it's only missing a good description.
> ---
> scripts/qapi-commands.py | 14 +++++++-------
> scripts/qapi-types.py | 4 ++--
> scripts/qapi-visit.py | 4 ++--
> scripts/qapi.py | 5 ++++-
> 4 files changed, 15 insertions(+), 12 deletions(-)
>
> diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py
> index 3aabf61..30a24d2 100644
> --- a/scripts/qapi-commands.py
> +++ b/scripts/qapi-commands.py
> @@ -42,7 +42,7 @@ def generate_command_decl(name, args, ret_type):
> return mcgen('''
> %(ret_type)s qmp_%(name)s(%(args)sError **errp);
> ''',
> - ret_type=c_type(ret_type), name=c_var(name), args=arglist).strip()
> + ret_type=c_type(ret_type), name=c_fun(name), args=arglist).strip()
>
> def gen_sync_call(name, args, ret_type, indent=0):
> ret = ""
> @@ -59,7 +59,7 @@ def gen_sync_call(name, args, ret_type, indent=0):
> %(retval)sqmp_%(name)s(%(args)serrp);
>
> ''',
> - name=c_var(name), args=arglist, retval=retval).rstrip()
> + name=c_fun(name), args=arglist, retval=retval).rstrip()
> if ret_type:
> ret += "\n" + mcgen(''''
> if (!error_is_set(errp)) {
> @@ -74,7 +74,7 @@ if (!error_is_set(errp)) {
> def gen_marshal_output_call(name, ret_type):
> if not ret_type:
> return ""
> - return "qmp_marshal_output_%s(retval, ret, errp);" % c_var(name)
> + return "qmp_marshal_output_%s(retval, ret, errp);" % c_fun(name)
>
> def gen_visitor_output_containers_decl(ret_type):
> ret = ""
> @@ -198,16 +198,16 @@ static void qmp_marshal_output_%(c_name)s(%(c_ret_type)s ret_in, QObject **ret_o
> qapi_dealloc_visitor_cleanup(md);
> }
> ''',
> - c_ret_type=c_type(ret_type), c_name=c_var(name),
> + c_ret_type=c_type(ret_type), c_name=c_fun(name),
> visitor=type_visitor(ret_type))
>
> return ret
>
> def gen_marshal_input_decl(name, args, ret_type, middle_mode):
> if middle_mode:
> - return 'int qmp_marshal_input_%s(Monitor *mon, const QDict *qdict, QObject **ret)' % c_var(name)
> + return 'int qmp_marshal_input_%s(Monitor *mon, const QDict *qdict, QObject **ret)' % c_fun(name)
> else:
> - return 'static void qmp_marshal_input_%s(QDict *args, QObject **ret, Error **errp)' % c_var(name)
> + return 'static void qmp_marshal_input_%s(QDict *args, QObject **ret, Error **errp)' % c_fun(name)
>
>
>
> @@ -298,7 +298,7 @@ def gen_registry(commands):
> registry += mcgen('''
> qmp_register_command("%(name)s", qmp_marshal_input_%(c_name)s);
> ''',
> - name=cmd['command'], c_name=c_var(cmd['command']))
> + name=cmd['command'], c_name=c_fun(cmd['command']))
> pop_indent()
> ret = mcgen('''
> static void qmp_init_marshal(void)
> diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
> index 727fb77..4a734f5 100644
> --- a/scripts/qapi-types.py
> +++ b/scripts/qapi-types.py
> @@ -100,7 +100,7 @@ typedef enum %(name)s
> %(abbrev)s_%(value)s = %(i)d,
> ''',
> abbrev=de_camel_case(name).upper(),
> - value=c_var(value).upper(),
> + value=c_fun(value).upper(),
> i=i)
> i += 1
>
> @@ -126,7 +126,7 @@ struct %(name)s
> %(c_type)s %(c_name)s;
> ''',
> c_type=c_type(typeinfo[key]),
> - c_name=c_var(key))
> + c_name=c_fun(key))
>
> ret += mcgen('''
> };
> diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
> index 54117d4..78c947c 100644
> --- a/scripts/qapi-visit.py
> +++ b/scripts/qapi-visit.py
> @@ -129,9 +129,9 @@ void visit_type_%(name)s(Visitor *m, %(name)s ** obj, const char *name, Error **
> break;
> ''',
> abbrev = de_camel_case(name).upper(),
> - enum = de_camel_case(key).upper(),
> + enum = c_fun(de_camel_case(key)).upper(),
> c_type=members[key],
> - c_name=c_var(key))
> + c_name=c_fun(key))
>
> ret += mcgen('''
> default:
> diff --git a/scripts/qapi.py b/scripts/qapi.py
> index 6e05469..e062336 100644
> --- a/scripts/qapi.py
> +++ b/scripts/qapi.py
> @@ -131,7 +131,10 @@ def camel_case(name):
> return new_name
>
> def c_var(name):
> - return '_'.join(name.split('-')).lstrip("*")
> + return name.replace('-', '_').lstrip("*")
> +
> +def c_fun(name):
> + return c_var(name).replace('.', '_')
>
> def c_list_type(name):
> return '%sList' % name
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH v3] qapi: add c_fun to escape function names
2012-03-20 13:54 ` [Qemu-devel] [PATCH v3] qapi: add c_fun to escape function names Federico Simoncelli
2012-03-23 20:38 ` Luiz Capitulino
@ 2012-03-26 20:07 ` Anthony Liguori
1 sibling, 0 replies; 9+ messages in thread
From: Anthony Liguori @ 2012-03-26 20:07 UTC (permalink / raw)
To: Federico Simoncelli; +Cc: pbonzini, qemu-devel, lcapitulino
On 03/20/2012 08:54 AM, Federico Simoncelli wrote:
> Signed-off-by: Federico Simoncelli<fsimonce@redhat.com>
Applied. Thanks.
Regards,
Anthony Liguori
> ---
> scripts/qapi-commands.py | 14 +++++++-------
> scripts/qapi-types.py | 4 ++--
> scripts/qapi-visit.py | 4 ++--
> scripts/qapi.py | 5 ++++-
> 4 files changed, 15 insertions(+), 12 deletions(-)
>
> diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py
> index 3aabf61..30a24d2 100644
> --- a/scripts/qapi-commands.py
> +++ b/scripts/qapi-commands.py
> @@ -42,7 +42,7 @@ def generate_command_decl(name, args, ret_type):
> return mcgen('''
> %(ret_type)s qmp_%(name)s(%(args)sError **errp);
> ''',
> - ret_type=c_type(ret_type), name=c_var(name), args=arglist).strip()
> + ret_type=c_type(ret_type), name=c_fun(name), args=arglist).strip()
>
> def gen_sync_call(name, args, ret_type, indent=0):
> ret = ""
> @@ -59,7 +59,7 @@ def gen_sync_call(name, args, ret_type, indent=0):
> %(retval)sqmp_%(name)s(%(args)serrp);
>
> ''',
> - name=c_var(name), args=arglist, retval=retval).rstrip()
> + name=c_fun(name), args=arglist, retval=retval).rstrip()
> if ret_type:
> ret += "\n" + mcgen(''''
> if (!error_is_set(errp)) {
> @@ -74,7 +74,7 @@ if (!error_is_set(errp)) {
> def gen_marshal_output_call(name, ret_type):
> if not ret_type:
> return ""
> - return "qmp_marshal_output_%s(retval, ret, errp);" % c_var(name)
> + return "qmp_marshal_output_%s(retval, ret, errp);" % c_fun(name)
>
> def gen_visitor_output_containers_decl(ret_type):
> ret = ""
> @@ -198,16 +198,16 @@ static void qmp_marshal_output_%(c_name)s(%(c_ret_type)s ret_in, QObject **ret_o
> qapi_dealloc_visitor_cleanup(md);
> }
> ''',
> - c_ret_type=c_type(ret_type), c_name=c_var(name),
> + c_ret_type=c_type(ret_type), c_name=c_fun(name),
> visitor=type_visitor(ret_type))
>
> return ret
>
> def gen_marshal_input_decl(name, args, ret_type, middle_mode):
> if middle_mode:
> - return 'int qmp_marshal_input_%s(Monitor *mon, const QDict *qdict, QObject **ret)' % c_var(name)
> + return 'int qmp_marshal_input_%s(Monitor *mon, const QDict *qdict, QObject **ret)' % c_fun(name)
> else:
> - return 'static void qmp_marshal_input_%s(QDict *args, QObject **ret, Error **errp)' % c_var(name)
> + return 'static void qmp_marshal_input_%s(QDict *args, QObject **ret, Error **errp)' % c_fun(name)
>
>
>
> @@ -298,7 +298,7 @@ def gen_registry(commands):
> registry += mcgen('''
> qmp_register_command("%(name)s", qmp_marshal_input_%(c_name)s);
> ''',
> - name=cmd['command'], c_name=c_var(cmd['command']))
> + name=cmd['command'], c_name=c_fun(cmd['command']))
> pop_indent()
> ret = mcgen('''
> static void qmp_init_marshal(void)
> diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
> index 727fb77..4a734f5 100644
> --- a/scripts/qapi-types.py
> +++ b/scripts/qapi-types.py
> @@ -100,7 +100,7 @@ typedef enum %(name)s
> %(abbrev)s_%(value)s = %(i)d,
> ''',
> abbrev=de_camel_case(name).upper(),
> - value=c_var(value).upper(),
> + value=c_fun(value).upper(),
> i=i)
> i += 1
>
> @@ -126,7 +126,7 @@ struct %(name)s
> %(c_type)s %(c_name)s;
> ''',
> c_type=c_type(typeinfo[key]),
> - c_name=c_var(key))
> + c_name=c_fun(key))
>
> ret += mcgen('''
> };
> diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
> index 54117d4..78c947c 100644
> --- a/scripts/qapi-visit.py
> +++ b/scripts/qapi-visit.py
> @@ -129,9 +129,9 @@ void visit_type_%(name)s(Visitor *m, %(name)s ** obj, const char *name, Error **
> break;
> ''',
> abbrev = de_camel_case(name).upper(),
> - enum = de_camel_case(key).upper(),
> + enum = c_fun(de_camel_case(key)).upper(),
> c_type=members[key],
> - c_name=c_var(key))
> + c_name=c_fun(key))
>
> ret += mcgen('''
> default:
> diff --git a/scripts/qapi.py b/scripts/qapi.py
> index 6e05469..e062336 100644
> --- a/scripts/qapi.py
> +++ b/scripts/qapi.py
> @@ -131,7 +131,10 @@ def camel_case(name):
> return new_name
>
> def c_var(name):
> - return '_'.join(name.split('-')).lstrip("*")
> + return name.replace('-', '_').lstrip("*")
> +
> +def c_fun(name):
> + return c_var(name).replace('.', '_')
>
> def c_list_type(name):
> return '%sList' % name
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2012-03-26 20:07 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-15 13:53 [Qemu-devel] [PATCH] qapi: escaping the dots in c_var Federico Simoncelli
2012-03-15 14:51 ` Michael Roth
2012-03-15 15:03 ` Luiz Capitulino
2012-03-15 15:42 ` Michael Roth
2012-03-15 15:45 ` [Qemu-devel] [PATCH v2] qapi: escaping dots in c_var and in de_camel_case Federico Simoncelli
2012-03-16 19:16 ` Luiz Capitulino
2012-03-20 13:54 ` [Qemu-devel] [PATCH v3] qapi: add c_fun to escape function names Federico Simoncelli
2012-03-23 20:38 ` Luiz Capitulino
2012-03-26 20:07 ` Anthony Liguori
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).