Jim Tcl
Diff
Not logged in

Differences From Artifact [78d44fa0ea02ded4]:

To Artifact [4cff5508d19252b6]:


1 /* Jim - A small embeddable Tcl interpreter 1 /* Jim - A small embeddable Tcl interpreter 2 * 2 * 3 * Copyright 2005 Salvatore Sanfilippo <antirez@invece.org> 3 * Copyright 2005 Salvatore Sanfilippo <antirez@invece.org> 4 * Copyright 2005 Clemens Hintze <c.hintze@gmx.net> 4 * Copyright 2005 Clemens Hintze <c.hintze@gmx.net> 5 * Copyright 2005 patthoyts - Pat Thoyts <patthoyts@users.sf.net> | 5 * Copyright 2005 patthoyts - Pat Thoyts <patthoyts@users.sf.net> 6 * Copyright 2008 oharboe - Øyvind Harboe - oyvind.harboe@zylin.com 6 * Copyright 2008 oharboe - Øyvind Harboe - oyvind.harboe@zylin.com 7 * Copyright 2008 Andrew Lunn <andrew@lunn.ch> 7 * Copyright 2008 Andrew Lunn <andrew@lunn.ch> 8 * Copyright 2008 Duane Ellis <openocd@duaneellis.com> 8 * Copyright 2008 Duane Ellis <openocd@duaneellis.com> 9 * Copyright 2008 Uwe Klein <uklein@klein-messgeraete.de> 9 * Copyright 2008 Uwe Klein <uklein@klein-messgeraete.de> 10 * | 10 * 11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions 13 * are met: 13 * are met: 14 * | 14 * 15 * 1. Redistributions of source code must retain the above copyright 15 * 1. Redistributions of source code must retain the above copyright 16 * notice, this list of conditions and the following disclaimer. 16 * notice, this list of conditions and the following disclaimer. 17 * 2. Redistributions in binary form must reproduce the above 17 * 2. Redistributions in binary form must reproduce the above 18 * copyright notice, this list of conditions and the following 18 * copyright notice, this list of conditions and the following 19 * disclaimer in the documentation and/or other materials 19 * disclaimer in the documentation and/or other materials 20 * provided with the distribution. 20 * provided with the distribution. 21 * | 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE JIM TCL PROJECT ``AS IS'' AND ANY 22 * THIS SOFTWARE IS PROVIDED BY THE JIM TCL PROJECT ``AS IS'' AND ANY 23 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 24 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 25 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 * JIM TCL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 26 * JIM TCL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 27 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 27 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 31 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 * | 34 * 35 * The views and conclusions contained in the software and documentation 35 * The views and conclusions contained in the software and documentation 36 * are those of the authors and should not be interpreted as representing 36 * are those of the authors and should not be interpreted as representing 37 * official policies, either expressed or implied, of the Jim Tcl Project. 37 * official policies, either expressed or implied, of the Jim Tcl Project. 38 * 38 * 39 *--- Inline Header File Documentation --- | 39 *--- Inline Header File Documentation --- 40 * [By Duane Ellis, openocd@duaneellis.com, 8/18/8] 40 * [By Duane Ellis, openocd@duaneellis.com, 8/18/8] 41 * 41 * 42 * Belief is "Jim" would greatly benifit if Jim Internals where 42 * Belief is "Jim" would greatly benifit if Jim Internals where 43 * documented in some way - form whatever, and perhaps - the package: 43 * documented in some way - form whatever, and perhaps - the package: 44 * 'doxygen' is the correct approach to do that. 44 * 'doxygen' is the correct approach to do that. 45 * 45 * 46 * Details, see: http://www.stack.nl/~dimitri/doxygen/ 46 * Details, see: http://www.stack.nl/~dimitri/doxygen/ ................................................................................................................................................................................ 407 struct Jim_Interp; 407 struct Jim_Interp; 408 408 409 typedef void (Jim_FreeInternalRepProc)(struct Jim_Interp *interp, 409 typedef void (Jim_FreeInternalRepProc)(struct Jim_Interp *interp, 410 struct Jim_Obj *objPtr); 410 struct Jim_Obj *objPtr); 411 typedef void (Jim_DupInternalRepProc)(struct Jim_Interp *interp, 411 typedef void (Jim_DupInternalRepProc)(struct Jim_Interp *interp, 412 struct Jim_Obj *srcPtr, Jim_Obj *dupPtr); 412 struct Jim_Obj *srcPtr, Jim_Obj *dupPtr); 413 typedef void (Jim_UpdateStringProc)(struct Jim_Obj *objPtr); 413 typedef void (Jim_UpdateStringProc)(struct Jim_Obj *objPtr); 414 | 414 415 typedef struct Jim_ObjType { 415 typedef struct Jim_ObjType { 416 const char *name; /* The name of the type. */ 416 const char *name; /* The name of the type. */ 417 Jim_FreeInternalRepProc *freeIntRepProc; 417 Jim_FreeInternalRepProc *freeIntRepProc; 418 Jim_DupInternalRepProc *dupIntRepProc; 418 Jim_DupInternalRepProc *dupIntRepProc; 419 Jim_UpdateStringProc *updateStringProc; 419 Jim_UpdateStringProc *updateStringProc; 420 int flags; 420 int flags; 421 } Jim_ObjType; 421 } Jim_ObjType; ................................................................................................................................................................................ 529 unsigned jim_wide procEpoch; /* Incremented every time the result 529 unsigned jim_wide procEpoch; /* Incremented every time the result 530 of procedures names lookup caching 530 of procedures names lookup caching 531 may no longer be valid. */ 531 may no longer be valid. */ 532 unsigned jim_wide callFrameEpoch; /* Incremented every time a new 532 unsigned jim_wide callFrameEpoch; /* Incremented every time a new 533 callframe is created. This id is used for the 533 callframe is created. This id is used for the 534 'ID' field contained in the Jim_CallFrame 534 'ID' field contained in the Jim_CallFrame 535 structure. */ 535 structure. */ 536 int local; /* If 'local' is in effect, newly defined procs keep a reference | 536 int local; /* If 'local' is in effect, newly defined procs keep a reference 537 Jim_Obj *liveList; /* Linked list of all the live objects. */ 537 Jim_Obj *liveList; /* Linked list of all the live objects. */ 538 Jim_Obj *freeList; /* Linked list of all the unused objects. */ 538 Jim_Obj *freeList; /* Linked list of all the unused objects. */ 539 Jim_Obj *currentScriptObj; /* Script currently in execution. */ 539 Jim_Obj *currentScriptObj; /* Script currently in execution. */ 540 Jim_Obj *emptyObj; /* Shared empty string object. */ 540 Jim_Obj *emptyObj; /* Shared empty string object. */ 541 Jim_Obj *trueObj; /* Shared true int object. */ 541 Jim_Obj *trueObj; /* Shared true int object. */ 542 Jim_Obj *falseObj; /* Shared false int object. */ 542 Jim_Obj *falseObj; /* Shared false int object. */ 543 unsigned jim_wide referenceNextId; /* Next id for reference. */ 543 unsigned jim_wide referenceNextId; /* Next id for reference. */ ................................................................................................................................................................................ 736 JIM_EXPORT void Jim_FreeInterp (Jim_Interp *i); 736 JIM_EXPORT void Jim_FreeInterp (Jim_Interp *i); 737 JIM_EXPORT int Jim_GetExitCode (Jim_Interp *interp); 737 JIM_EXPORT int Jim_GetExitCode (Jim_Interp *interp); 738 JIM_EXPORT const char *Jim_ReturnCode(int code); 738 JIM_EXPORT const char *Jim_ReturnCode(int code); 739 JIM_EXPORT void Jim_SetResultFormatted(Jim_Interp *interp, const char *format, . 739 JIM_EXPORT void Jim_SetResultFormatted(Jim_Interp *interp, const char *format, . 740 740 741 /* commands */ 741 /* commands */ 742 JIM_EXPORT void Jim_RegisterCoreCommands (Jim_Interp *interp); 742 JIM_EXPORT void Jim_RegisterCoreCommands (Jim_Interp *interp); 743 JIM_EXPORT int Jim_CreateCommand (Jim_Interp *interp, | 743 JIM_EXPORT int Jim_CreateCommand (Jim_Interp *interp, 744 const char *cmdName, Jim_CmdProc cmdProc, void *privData, 744 const char *cmdName, Jim_CmdProc cmdProc, void *privData, 745 Jim_DelCmdProc delProc); 745 Jim_DelCmdProc delProc); 746 JIM_EXPORT int Jim_DeleteCommand (Jim_Interp *interp, 746 JIM_EXPORT int Jim_DeleteCommand (Jim_Interp *interp, 747 const char *cmdName); 747 const char *cmdName); 748 JIM_EXPORT int Jim_RenameCommand (Jim_Interp *interp, | 748 JIM_EXPORT int Jim_RenameCommand (Jim_Interp *interp, 749 const char *oldName, const char *newName); 749 const char *oldName, const char *newName); 750 JIM_EXPORT Jim_Cmd * Jim_GetCommand (Jim_Interp *interp, 750 JIM_EXPORT Jim_Cmd * Jim_GetCommand (Jim_Interp *interp, 751 Jim_Obj *objPtr, int flags); 751 Jim_Obj *objPtr, int flags); 752 JIM_EXPORT int Jim_SetVariable (Jim_Interp *interp, 752 JIM_EXPORT int Jim_SetVariable (Jim_Interp *interp, 753 Jim_Obj *nameObjPtr, Jim_Obj *valObjPtr); 753 Jim_Obj *nameObjPtr, Jim_Obj *valObjPtr); 754 JIM_EXPORT int Jim_SetVariableStr (Jim_Interp *interp, 754 JIM_EXPORT int Jim_SetVariableStr (Jim_Interp *interp, 755 const char *name, Jim_Obj *objPtr); 755 const char *name, Jim_Obj *objPtr); ................................................................................................................................................................................ 842 JIM_EXPORT int Jim_GetDouble(Jim_Interp *interp, Jim_Obj *objPtr, 842 JIM_EXPORT int Jim_GetDouble(Jim_Interp *interp, Jim_Obj *objPtr, 843 double *doublePtr); 843 double *doublePtr); 844 JIM_EXPORT void Jim_SetDouble(Jim_Interp *interp, Jim_Obj *objPtr, 844 JIM_EXPORT void Jim_SetDouble(Jim_Interp *interp, Jim_Obj *objPtr, 845 double doubleValue); 845 double doubleValue); 846 JIM_EXPORT Jim_Obj * Jim_NewDoubleObj(Jim_Interp *interp, double doubleValue); 846 JIM_EXPORT Jim_Obj * Jim_NewDoubleObj(Jim_Interp *interp, double doubleValue); 847 847 848 /* shared strings */ 848 /* shared strings */ 849 JIM_EXPORT const char * Jim_GetSharedString (Jim_Interp *interp, | 849 JIM_EXPORT const char * Jim_GetSharedString (Jim_Interp *interp, 850 const char *str); 850 const char *str); 851 JIM_EXPORT void Jim_ReleaseSharedString (Jim_Interp *interp, 851 JIM_EXPORT void Jim_ReleaseSharedString (Jim_Interp *interp, 852 const char *str); 852 const char *str); 853 853 854 /* commands utilities */ 854 /* commands utilities */ 855 JIM_EXPORT void Jim_WrongNumArgs (Jim_Interp *interp, int argc, 855 JIM_EXPORT void Jim_WrongNumArgs (Jim_Interp *interp, int argc, 856 Jim_Obj *const *argv, const char *msg); 856 Jim_Obj *const *argv, const char *msg); 857 JIM_EXPORT int Jim_GetEnum (Jim_Interp *interp, Jim_Obj *objPtr, 857 JIM_EXPORT int Jim_GetEnum (Jim_Interp *interp, Jim_Obj *objPtr, 858 const char * const *tablePtr, int *indexPtr, const char *name, int flags 858 const char * const *tablePtr, int *indexPtr, const char *name, int flags 859 JIM_EXPORT int Jim_ScriptIsComplete (const char *s, int len, 859 JIM_EXPORT int Jim_ScriptIsComplete (const char *s, int len, 860 char *stateCharPtr); 860 char *stateCharPtr); 861 /** 861 /** 862 * Find a matching name in the array of the given length. 862 * Find a matching name in the array of the given length. 863 * | 863 * 864 * NULL entries are ignored. 864 * NULL entries are ignored. 865 * 865 * 866 * Returns the matching index if found, or -1 if not. 866 * Returns the matching index if found, or -1 if not. 867 */ 867 */ 868 JIM_EXPORT int Jim_FindByName(const char *name, const char * const array[], size 868 JIM_EXPORT int Jim_FindByName(const char *name, const char * const array[], size 869 869 870 /* package utilities */ 870 /* package utilities */