1. 01 Dec, 2009 3 commits
    • Zachary T Welch's avatar
      do not extern 'interp' from command.c · 7b2906de
      Zachary T Welch authored
      Adds 'interp' field to command_context, chasing the few remaining
      references to the global variable outside of the command module.
    • Zachary T Welch's avatar
      move improperly located documentation · 3d204ec6
      Zachary T Welch authored
      Somehow, the comment block for command handlers ended up associated
      with the output_handler.  Move it to the command_handler_t declaration.
    • Zachary T Welch's avatar
      improve command_done() API and docs · bc9ae740
      Zachary T Welch authored
      command_done() does not need to return an error, but it needed
      Doxygen comment.  Provide some for copy_command_context as well.
      Note: this audit revealed some potential bugs with the command context
      implementation.  There was a reason that commands were added at the
      end of the list.  Shallow copying of command_context means that
      the list is shared between them.  And commands added at the top-level
      before the pre-existing commands will not be available in the shared
      context as they were before.  Yikes!
      Fortunately, this does not seem to occur in general use, as
      'add_help_text' gets registered in startup.tcl and claims the first slot
      in my own test cases.  Thus, it seems that we have been masking the issue
      for now, but it shows the need for further architectural improvement in
      the core command module.
  2. 28 Nov, 2009 1 commit
    • Zachary T Welch's avatar
      add command private data setter/accessor · 933b4579
      Zachary T Welch authored
      Presently, commands registration taks a static handler data pointer.
      This patch adds support for commands that require a dynamic pointer,
      such as those registered in a dynamic context (e.g. subcommands for a
      user-created 'foo.cpu' command).  The command_set_handler_data will
      update a command (group) to use a new context pointer, while the
      CMD_DATA macro allows command handlers to access the value.
      Jim handlers should find this value in interp->cmdPrivData.
  3. 25 Nov, 2009 7 commits
    • Zachary T Welch's avatar
      add jim_handler to command_registration · 17a9dea5
      Zachary T Welch authored
      Adding jim_handler field to command_registration allows removing the
      register_jim helper.  All command registrations now go through the
      register_command{,s}() functions.
    • Zachary T Welch's avatar
      add public API for locating commands · 769fbfa0
      Zachary T Welch authored
      Allow other modules to find a command, primarily for the purpose of
      registering and unregistering subcommands.
    • Zachary T Welch's avatar
      add command registration chaining · 60ba4641
      Zachary T Welch authored
      Adds the ability to chain registration structures.  Modules can define a
      command with the 'chain' and 'num_chain' fields defined in their
      registration table, and the register_commands() function will initialize
      these commands.  If the registration record creates a new command, then
      the chained commands are created under it; otherwise, they are created
      in the same context as the other commands (i.e. the parent argument).
    • Zachary T Welch's avatar
      add command usage, separate from help · d107f71c
      Zachary T Welch authored
      Adds the usage command, to display usage information for commands.
      The output for this command will remain erronenously empty until
      commands are updated to use these new coventions.
    • Zachary T Welch's avatar
      add register_commands for batch registration · 24618554
      Zachary T Welch authored
      The register_commands API takes multiple commands in one call, allowing
      modules to declare and pass a much simpler (and more explicit) array of
      command_registration records.
    • Zachary T Welch's avatar
      add struct command_registration · 69076057
      Zachary T Welch authored
      Add a structure to encapsulate command registration information, rather
      than passing them all as parameters.  Enables further API changes that
      require additional required or optional parameters.
      Updates the register_command API and COMMAND_REGISTER macro to use it,
      along with their documentation.
    • Zachary T Welch's avatar
      add COMMAND_REGISTER macro · f7e1f2df
      Zachary T Welch authored
      Provides a migration path for the widely used register_command API,
      which needs to be updated to provide new functionality.
      This macro allows the API to change without having to update all of its
      callers at the same time.
  4. 20 Nov, 2009 2 commits
    • Zachary T Welch's avatar
      improve 'help' command · 5458fef4
      Zachary T Welch authored
      Rewrites 'help' command in C, using new 'cmd_help' for display.  Adds the
      built-in 'help' COMMAND_HANDLER to provide better output than the
      TCL-based script command (e.g. heirarchical listing of commands).
      The help string is stored in the command structure, though it conitnues
      to be pushed into the Jim environment.  The current idiomatic usage
      suggests the addition of a usage field as well, to provide two levels
      of detail for users to consume (i.e. terse usage list, or verbose help).
    • Zachary T Welch's avatar
      refactor command registration · 9e9633c6
      Zachary T Welch authored
      Refactors the command registration to use helpers to simplify the code.
      The unregistration routines were made more flexible by allowing them
      to operate on a single command, such that one can remove all of a
      commands children in one step (perhaps before adding back a 'config'
      subcommand that allows getting the others back).  Eliminates a bit
      of duplicated code and adds full API documentation for these routines.
  5. 18 Nov, 2009 5 commits
    • Zachary T Welch's avatar
      remove fast command and jim_global_long · c0d14dc7
      Zachary T Welch authored
      Removing the fast command eliminates the fast_and_dangerous global,
      which was used only by arm7_9_common as an initializer.  The command
      is not called in the tree; instead, more explicit commands are used.
      The jim_global_long function was not used anywhere in the tree.
    • Zachary T Welch's avatar
      change all bool parsers to accept any value · 4d8d1d32
      Zachary T Welch authored
      This patch changes the behavior of all boolean parsing callers to
      accept any one of "true/enable/on/yes/1" or "false/disable/off/no/0".
      Since one particular pair will be most appropriate in any given
      situation, the specific macros should continue to be used in
      order to display the most informative error messages possible.
    • Zachary T Welch's avatar
      add handle_command_parse_bool command helper · 7e4adfe1
      Zachary T Welch authored
      Rewrite arm11_handle_bool to provide a generic on/off command helper.
      Refactors COMMAND_PARSE_BOOL to use new command_parse_bool helper,
      which gets reused by the new command_parse_bool_any helper.
      This later helper is called by the new command helper function to
      accepts any on/off, enable/disable, true/false, yes/no, or 0/1 parameter.
    • Zachary T Welch's avatar
      add COMMAND_PARSE_BOOL macro and friends · bd5a1799
      Zachary T Welch authored
      Adds several macros similar to COMMAND_PARSE_NUMBER, but for parsing
      boolean command arguments.  Two flavors are provided to provide
      drop-in compatibility with existing code, allow for the elimination
      of a lot of code bloat while improving the error checking and reporting.
      COMMAND_PARSE_ON_OFF parses "on"/"off" command parameters.
      COMMAND_PARSE_ENABLE parses "enable"/"disable" command parameters.
      Both print the error and return an error out of the calling function.
    • Zachary T Welch's avatar
      pass startup_tcl to command_init · 5e229bbf
      Zachary T Welch authored
      Removes external linkage from helper module, making the startup
      code a parameter to a new command context's initialization routine.
  6. 17 Nov, 2009 4 commits
    • Zachary T Welch's avatar
      add CMD_NAME variable in command_invocation · cffc98ad
      Zachary T Welch authored
      Update CMD_NAME from its migratory home in CMD_ARGV[-1] to cmd->name.
      Allows CMD_ARGV++ idiom to be used safely in command handlers.
    • Zachary T Welch's avatar
      add struct command_invocation for COMMAND_HANDLER · be084414
      Zachary T Welch authored
      Adds the command_invocation structure to encapsulate parameters for
      all COMMAND_HANDLER routines.  Rather than passing several arguments
      to each successive subroutine, a single pointer may be passed around.
      Changes the CMD_* macros to reference the new fields.
      Updates run_command to create an instance and pass it to the handler.
    • Zachary T Welch's avatar
      command_handler: change 'cmd_ctx' to CMD_CTX · 2861877b
      Zachary T Welch authored
      Convert all command handler 'cmd_ctx' parameter usage with CMD_CTX.
    • Zachary T Welch's avatar
      add more command_handler conversion macros · 5b9899d6
      Zachary T Welch authored
      Add additional macros to allow command handling to be migrated easily:
      CMD_CTX, CMD_ARGC, and CMD_ARGV.  Updates CMD_NAME to use CMD_ARGV.
      In addition to making the remaining patches of this series cleaner,
      this introduces easily sed-able symbols that could allow us to retire
      these once the command handler infrastructure matures (i.e. pre-1.0).
  7. 16 Nov, 2009 1 commit
  8. 13 Nov, 2009 10 commits
    • Zachary T Welch's avatar
      command_t -> struct command · ef746e27
      Zachary T Welch authored
      Remove misleading typedef and redundant suffix from struct command.
    • Zachary T Welch's avatar
      command_context_t -> struct command_context · 98723c4e
      Zachary T Welch authored
      Remove misleading typedef and redundant suffix from struct command_context.
    • Zachary T Welch's avatar
      command_handler_t: make cmd an indirect parameter · f973320c
      Zachary T Welch authored
      This patch removes 'cmd' from the list of direct parameters, moving
      that pointer to args[-1] (by way of the new CMD_NAME macro).
    • Zachary T Welch's avatar
      command_handler_t: make args parameter const · deede35c
      Zachary T Welch authored
      This patch prevents command handlers from modifying the strings passed
      in the 'args' array.
    • Zachary T Welch's avatar
      command_handler_t: make cmd parameter const · cc63d6e7
      Zachary T Welch authored
      Prevents the command name from being modified in command handlers.
      Again, this has cascading effects, but the patches are fairly minimal.
    • Zachary T Welch's avatar
      command_handler_t: make argc unsigned · d22270e0
      Zachary T Welch authored
      The number of command arguments will always be 0 or more, so use
      the right type in handlers.  This has a cascading effect up through
      the layers, but the new COMMAND_HANDLER macros prevented total chaos.
    • Zachary T Welch's avatar
      add CMD_NAME macro for command handlers · a585bdf7
      Zachary T Welch authored
      By introducing the CMD_NAME macro, this parameter may be integrated
      as args[-1] in command.[ch], without touching any other call sites.
    • Zachary T Welch's avatar
      add command_handler_t type · ddb6138e
      Zachary T Welch authored
      This patch adds new typedefs for command handler callback functions.
      Users of this type signature were updated to use these new types.
      It uses the new __COMMAND_HANDLER macro to prevent duplication.
    • Zachary T Welch's avatar
      add COMMAND_HANDLER and COMMAND_HELPER macros · 3f9fd4e2
      Zachary T Welch authored
      The COMMAND_HANDLER and COMMAND_HELPER macros allow commands to be
      defined in a manner that decouples them from the exact order and type of
      their parameters.  Once converted, incremental changes to the command
      handler type can be addressed in incremental patches that do not need to
      touch the entire tree.
      These macros' implementation, __COMMAND_HANDLER, is used to define the
      new command_handler_t type, and additional patches will use it to derive
      new macros to define extended command types (e.g. flash, nand, pld).
      The CALL_COMMAND_HANDLER provides a means of calling helpers or nested
      handlers from withing a command handler.
      This patch uses C99 varadic macro expansion.  Please report compilers
      that cannot handle this code.
    • Zachary T Welch's avatar
      add command_output_handler_t · 1ae4d93c
      Zachary T Welch authored
      Add a typedef for command output handler function type, simplifying
      the appearance of functions that use it and eliminating duplicate code.
  9. 11 Nov, 2009 2 commits
    • Zachary T Welch's avatar
      add command_name helper · 2d3cc1ea
      Zachary T Welch authored
      The command_name function returns a malloced string for a given
      command and its parents.  This can be used to display a message
      to the user, but it is used internally to handle registration
      and syntax errors.  This helps permit arbitrary command nesting.
    • Zachary T Welch's avatar
      script_debug(): improve types · e09d8938
      Zachary T Welch authored
      Use unsigned type for number of arguments.
  10. 09 Nov, 2009 1 commit
  11. 06 Nov, 2009 1 commit
    • Zachary T Welch's avatar
      Add macro for parsing numeric command arguments. · 36a3646c
      Zachary T Welch authored
      This helper eliminates significant amount of redundant code in command
      handler functions throughout the system.  It wraps the lower-level
      parse_* macros to implement a policy for reporting parse errors to the
      active command context (cmd_ctx).  If errors do occur, this macro causes
      the calling function to abort with the proper return code.
  12. 19 Oct, 2009 1 commit
    • Redirect 'Slash' NIL's avatar
      corrective fix for MinGW GNU C99 printf compliance · 113679ff
      Redirect 'Slash' NIL authored
      Compilation on cygwin, using gcc v3 with option -mno-cygwin,
      currently produces a large number of the following warnings:
         warning: `gnu_printf' is an unrecognized format function type
      These have been introduced with the recent MinGW GNU C99 printf
      compliance patch, as gnu_printf was only introduced with gcc v4.4
      and is not recognized with earlier versions.
      The attached fix adds gcc version detection to the previous patch
      to avoid the problem.
  13. 18 Oct, 2009 1 commit
    • Redirect 'Slash' NIL's avatar
      More MinGW C99 printf compliance · 73349dc5
      Redirect 'Slash' NIL authored
      Passing "--std=gun99" is unfortunately not sufficient to make current
      MinGW compilers conform with respect to checking printf format strings.
      (The C runtime seems not to have problems.)
      Fix by using a "gnu_printf" format specifier not "printf".
  14. 17 Jul, 2009 1 commit