summaryrefslogtreecommitdiff
path: root/src/helper/command.c
diff options
context:
space:
mode:
authorØyvind Harboe <oyvind.harboe@zylin.com>2009-12-01 08:41:41 +0100
committerØyvind Harboe <oyvind.harboe@zylin.com>2009-12-01 09:53:23 +0100
commit5576a6240a103879e1a8d9d4c2b6ff4aee0d23fa (patch)
tree7f817159a2a8c6dea9dee3cb9f0cc84b90b8eb86 /src/helper/command.c
parent63dc352876259562948b5d814de197ba534897b9 (diff)
downloadopenocd+libswd-5576a6240a103879e1a8d9d4c2b6ff4aee0d23fa.tar.gz
openocd+libswd-5576a6240a103879e1a8d9d4c2b6ff4aee0d23fa.tar.bz2
openocd+libswd-5576a6240a103879e1a8d9d4c2b6ff4aee0d23fa.tar.xz
openocd+libswd-5576a6240a103879e1a8d9d4c2b6ff4aee0d23fa.zip
command: the Jim interpreter can now be provided rather than created
In embedded hosts, the Jim interpreter can come from the existing context rather than be created by OpenOCD. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Diffstat (limited to 'src/helper/command.c')
-rw-r--r--src/helper/command.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/helper/command.c b/src/helper/command.c
index dcad6a19..d6576684 100644
--- a/src/helper/command.c
+++ b/src/helper/command.c
@@ -1272,7 +1272,7 @@ static const struct command_registration command_builtin_handlers[] = {
COMMAND_REGISTRATION_DONE
};
-struct command_context* command_init(const char *startup_tcl)
+struct command_context* command_init(const char *startup_tcl, Jim_Interp *interp)
{
struct command_context* context = malloc(sizeof(struct command_context));
const char *HostOs;
@@ -1284,14 +1284,18 @@ struct command_context* command_init(const char *startup_tcl)
context->output_handler_priv = NULL;
#if !BUILD_ECOSBOARD
- Jim_InitEmbedded();
- /* Create an interpreter */
- context->interp = Jim_CreateInterp();
- /* Add all the Jim core commands */
- Jim_RegisterCoreCommands(context->interp);
+ /* Create a jim interpreter if we were not handed one */
+ if (interp == NULL)
+ {
+ Jim_InitEmbedded();
+ /* Create an interpreter */
+ interp = Jim_CreateInterp();
+ /* Add all the Jim core commands */
+ Jim_RegisterCoreCommands(interp);
+ }
#endif
+ context->interp = interp;
- Jim_Interp *interp = context->interp;
#if defined(_MSC_VER)
/* WinXX - is generic, the forward
* looking problem is this: