On Sun, Nov 9, 2014 at 4:44 PM, Vlad Bogolin <vladbogo...@gmail.com> wrote: > Hi, > > I have a question regarding the whole command interpretation. After looking > in mged's code I found out that the command is build character by character > (mged.c/mged_process_char) but I've been struggling for a while to find what > happens after the command is complete. I mean there is a call to > Tcl_CommandComplete to check the command, then I see that the cmdline_hook > is NULL and finally the strings are clear but I can't see where is the > command executed. Any hints?
The command is executed by one of the wrapper functions - for example, try using gdb and breaking on ged_ls: gdb --args ./bin/mged share/db/moss.g ls break ged_ls run bt In this case cmd_ged_plain_wrapper in src/mged/cmd.c is what is called. The setup for this is in src/mged/setup.c near line 400, where the table of commands defined earlier in the file are registered as Tcl commands with Tcl_CreateCommand. One registered, it looks like it's then up to Tcl itself to do the actual launching. There are a couple of ways this particular problem can be tackled. This approach is integrated deeply into the machinery of the Tcl command interpretation, which does have advantages in that Tcl handles many things for us. Another possibility would be to use Tcl to "pre-process" arguments (like, say the regex character "*" if we're trying to list all objects in the database) and manage the actual function calling directly ourselves. This has the advantage of allowing us to decide on a per-command basis whether and when to expand expressions (the search command, for example, seldom wants Tcl to expand anything passed as an argument to it since regular expressions and shell globbing strings are valid arguments to be passed into search itself and having to heavily quote such strings is a significant user inconvenience.) Archer, IIRC, already takes a different approach than MGED for such things. Of course, some users might see this as an inconsistency and usability issue if they're expecting everything to be Tcl pre-processed and want to have to quote - things like the glob_compat_mode setting are an attempt to provide flexibility. I have some notions about how to handle this (mostly a "smart" command prompt that can become a pull-down menu to allow switching between no-language (straight argc/argv input to ged commands) and various interactive languages (starting with Tcl) with a right-click menu for different "modes" in that language) but it is not a simple problem. For MGED+Qt, I would say go with whatever looks simplest for you. I'm not sure in my own mind yet what the "best" way to do this is (with an eye towards being able to switch between different languages at the user command prompt at the user's option) but for MGED we can stick with Tcl and keep it as simple as possible. Hope that helps. Cheers, CY ------------------------------------------------------------------------------ _______________________________________________ BRL-CAD Developer mailing list brlcad-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/brlcad-devel