Re: [RFC/RFA] add struct parse_context to all command functions

Tom Tromey
2008-10-09T16:13:50Z

>>>>> "Joel" == Joel Brobecker <brobecker@adacore.com> writes:

Joel> I'd like to start working on adding a struct parse_context again.
Joel> The ultimate goal is to pass this structure as an argument to all
Joel> the "parse..." routines, rather than rely on the current_language
Joel> and input_radix globals. In addition to being cleaner, it will also
Joel> help fix a bug where the current_language is switched under us while
Joel> trying to do parse an expression.

I looked for the previous thread, and found this:

http://sourceware.org/ml/gdb-patches/2007-12/msg00255.html

... but I didn't see an explanation of the problem. Would you mind
repeating it?

Joel> The next step for this task is to add a struct parse_context parameter
Joel> to the "command" functions (the functions being called when the user
Joel> calls a function in the UI). When the user enters a command, we know
Joel> that we can use the current language and input radix to parse the
Joel> arguments.

I'm all in favor of this kind of cleanup.

struct cmd_list_element already has some support for multiple styles
of callback. It seems to me that you could limit your change to a
subset of all the commands by adding a new field to the 'function'
union. (That would mean more add_* functions, though.)

Joel> 1. The prototypes for the various add_* functions are duplicated.
Joel> There is a copy in command.h, and another in cli/cli-decode.h.
Joel> Is there a specific reason why we can't keep only one copy?
Joel> For instance, only keep the copy in cli/cli-decode.h?
[ and 2 and 3]

I have wondered about these myself.

Tom