From: Tom Tromey <tromey@redhat.com>
To: Pierre <p.vittet@laposte.net>
Cc: gcc-patches@gcc.gnu.org, joseph@codesourcery.com
Subject: Re: [PATCH] c-pragma: adding a data field to pragma_handler
Date: Thu, 02 Jun 2011 17:52:00 -0000 [thread overview]
Message-ID: <m31uzcnmtc.fsf@fleche.redhat.com> (raw)
In-Reply-To: <4DE66ECE.5030102@laposte.net> (Pierre's message of "Wed, 01 Jun 2011 18:54:38 +0200")
>>>>> "Pierre" == Pierre <p.vittet@laposte.net> writes:
Pierre> I have changed this handler in order to accept a second parameter
Pierre> which is a void *, allowing to give extra datas to the handler. I
Pierre> think this data field might be of general use: we can have condition
Pierre> or data at register time that we want to express in the handler. I
Pierre> guess this is a common way to pass data to an handler function.
I can't approve or reject this patch, but the idea seems reasonable
enough to me.
Pierre> I would like your opinion on this patch! Thanks!
It has a number of formatting issues.
Pierre> +typedef void (*pragma_handler)(struct cpp_reader *, void * );
No space after the final "*".
Pierre> +/* Internally use to keep the data of the handler. */
Pierre> +struct internal_pragma_handler_d{
Space before the "{".
Pierre> + pragma_handler handler;
Pierre> + void * data;
No space. Lots of instances of this.
Pierre> /* A vector of registered pragma callbacks. */
Pierre> +/*This is never freed as we need it during the whole execution */
Coalesce the two comments. The comment formatting is wrong, see GNU
standards.
Pierre> ns_name.space = space;
Pierre> ns_name.name = name;
Pierre> +
Pierre> VEC_safe_push (pragma_ns_name, heap, registered_pp_pragmas, &ns_name);
Gratuitous newline addition.
Pierre> + ihandler->handler = handler;
Pierre> + ihandler->data = data;
I didn't see anything that initialized ihandler.
Pierre> + VEC_safe_push (internal_pragma_handler, heap, registered_pragmas,
Pierre> + &ihandler);
I think you wanted just `internal_pragma_handler ihandler', no "*", for
the definition.
Pierre> +c_register_pragma (const char *space, const char *name, pragma_handler handler,
Pierre> + void * data)
There are lots of calls to this that you did not update.
Do a recursive grep to see.
One way to avoid a massive change is to add a new "overload" that passes
in the data to c_register_pragma_1; and then change the "legacy"
functions to pass NULL.
I don't know if that approach is ok (it is typical in gdb...), so if
not, you have to update all callers.
Tom
next prev parent reply other threads:[~2011-06-02 17:52 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-01 16:55 Pierre
2011-06-01 17:54 ` Basile Starynkevitch
2011-06-02 17:52 ` Tom Tromey [this message]
2011-06-03 15:32 ` Pierre Vittet
2011-06-03 15:48 ` Basile Starynkevitch
2011-06-03 20:25 ` Pierre Vittet
2011-06-08 21:35 ` Pierre Vittet
2011-06-09 7:21 ` Basile Starynkevitch
2011-06-09 9:08 ` Pierre Vittet
2011-06-09 14:53 ` Joseph S. Myers
2011-06-10 9:17 ` Pierre Vittet
2011-06-10 14:02 ` Joseph S. Myers
2011-06-10 16:15 ` Pierre Vittet
2011-06-15 15:10 ` Joseph S. Myers
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=m31uzcnmtc.fsf@fleche.redhat.com \
--to=tromey@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=joseph@codesourcery.com \
--cc=p.vittet@laposte.net \
/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 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 read-only IMAP folder(s) and NNTP newsgroup(s).