From: Anthony Liguori <anthony@codemonkey.ws>
To: Federico Simoncelli <fsimonce@redhat.com>
Cc: pbonzini@redhat.com, qemu-devel@nongnu.org, lcapitulino@redhat.com
Subject: Re: [Qemu-devel] [PATCH v3] qapi: add c_fun to escape function names
Date: Mon, 26 Mar 2012 15:07:25 -0500 [thread overview]
Message-ID: <4F70CC7D.8030103@redhat.com> (raw)
In-Reply-To: <1332251675-26352-1-git-send-email-fsimonce@redhat.com>
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
prev parent reply other threads:[~2012-03-26 20:07 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F70CC7D.8030103@redhat.com \
--to=anthony@codemonkey.ws \
--cc=fsimonce@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.