sl@0: /* sl@0: * tclInt.h -- sl@0: * sl@0: * Declarations of things used internally by the Tcl interpreter. sl@0: * sl@0: * Copyright (c) 1987-1993 The Regents of the University of California. sl@0: * Copyright (c) 1993-1997 Lucent Technologies. sl@0: * Copyright (c) 1994-1998 Sun Microsystems, Inc. sl@0: * Copyright (c) 1998-1999 by Scriptics Corporation. sl@0: * Copyright (c) 2001, 2002 by Kevin B. Kenny. All rights reserved. sl@0: * Portions Copyright (c) 2007 Nokia Corporation and/or its subsidiaries. All rights reserved. sl@0: * sl@0: * See the file "license.terms" for information on usage and redistribution sl@0: * of this file, and for a DISCLAIMER OF ALL WARRANTIES. sl@0: * sl@0: * RCS: @(#) $Id: tclInt.h,v 1.118.2.28 2007/05/10 21:32:17 dgp Exp $ sl@0: */ sl@0: sl@0: #ifndef _TCLINT sl@0: #define _TCLINT sl@0: sl@0: /* sl@0: * Common include files needed by most of the Tcl source files are sl@0: * included here, so that system-dependent personalizations for the sl@0: * include files only have to be made in once place. This results sl@0: * in a few extra includes, but greater modularity. The order of sl@0: * the three groups of #includes is important. For example, stdio.h sl@0: * is needed by tcl.h, and the _ANSI_ARGS_ declaration in tcl.h is sl@0: * needed by stdlib.h in some configurations. sl@0: */ sl@0: sl@0: #ifndef _TCL sl@0: #include "tcl.h" sl@0: #endif sl@0: sl@0: #include sl@0: sl@0: #include sl@0: #ifdef NO_LIMITS_H sl@0: # include "../compat/limits.h" sl@0: #else sl@0: # include sl@0: #endif sl@0: #ifdef NO_STDLIB_H sl@0: # include "../compat/stdlib.h" sl@0: #else sl@0: # include sl@0: #endif sl@0: #ifdef NO_STRING_H sl@0: #include "../compat/string.h" sl@0: #else sl@0: #include sl@0: #endif sl@0: sl@0: /* sl@0: * Ensure WORDS_BIGENDIAN is defined correcly: sl@0: * Needs to happen here in addition to configure to work with fat compiles on sl@0: * Darwin (where configure runs only once for multiple architectures). sl@0: */ sl@0: sl@0: #ifdef HAVE_SYS_TYPES_H sl@0: # include sl@0: #endif sl@0: #ifdef HAVE_SYS_PARAM_H sl@0: # include sl@0: #endif sl@0: #ifdef BYTE_ORDER sl@0: # ifdef BIG_ENDIAN sl@0: # if BYTE_ORDER == BIG_ENDIAN sl@0: # undef WORDS_BIGENDIAN sl@0: # define WORDS_BIGENDIAN sl@0: # endif sl@0: # endif sl@0: # ifdef LITTLE_ENDIAN sl@0: # if BYTE_ORDER == LITTLE_ENDIAN sl@0: # undef WORDS_BIGENDIAN sl@0: # endif sl@0: # endif sl@0: #endif sl@0: sl@0: /* sl@0: * Used to tag functions that are only to be visible within the module being sl@0: * built and not outside it (where this is supported by the linker). sl@0: */ sl@0: sl@0: #ifndef MODULE_SCOPE sl@0: # ifdef __cplusplus sl@0: # define MODULE_SCOPE extern "C" sl@0: # else sl@0: # define MODULE_SCOPE extern sl@0: # endif sl@0: #endif sl@0: sl@0: #undef TCL_STORAGE_CLASS sl@0: #ifdef BUILD_tcl sl@0: # define TCL_STORAGE_CLASS DLLEXPORT sl@0: #else sl@0: # ifdef USE_TCL_STUBS sl@0: # define TCL_STORAGE_CLASS sl@0: # else sl@0: # define TCL_STORAGE_CLASS DLLIMPORT sl@0: # endif sl@0: #endif sl@0: sl@0: /* sl@0: * The following procedures allow namespaces to be customized to sl@0: * support special name resolution rules for commands/variables. sl@0: * sl@0: */ sl@0: sl@0: struct Tcl_ResolvedVarInfo; sl@0: sl@0: typedef Tcl_Var (Tcl_ResolveRuntimeVarProc) _ANSI_ARGS_(( sl@0: Tcl_Interp* interp, struct Tcl_ResolvedVarInfo *vinfoPtr)); sl@0: sl@0: typedef void (Tcl_ResolveVarDeleteProc) _ANSI_ARGS_(( sl@0: struct Tcl_ResolvedVarInfo *vinfoPtr)); sl@0: sl@0: /* sl@0: * The following structure encapsulates the routines needed to resolve a sl@0: * variable reference at runtime. Any variable specific state will typically sl@0: * be appended to this structure. sl@0: */ sl@0: sl@0: sl@0: typedef struct Tcl_ResolvedVarInfo { sl@0: Tcl_ResolveRuntimeVarProc *fetchProc; sl@0: Tcl_ResolveVarDeleteProc *deleteProc; sl@0: } Tcl_ResolvedVarInfo; sl@0: sl@0: sl@0: sl@0: typedef int (Tcl_ResolveCompiledVarProc) _ANSI_ARGS_(( sl@0: Tcl_Interp* interp, CONST84 char* name, int length, sl@0: Tcl_Namespace *context, Tcl_ResolvedVarInfo **rPtr)); sl@0: sl@0: typedef int (Tcl_ResolveVarProc) _ANSI_ARGS_(( sl@0: Tcl_Interp* interp, CONST84 char* name, Tcl_Namespace *context, sl@0: int flags, Tcl_Var *rPtr)); sl@0: sl@0: typedef int (Tcl_ResolveCmdProc) _ANSI_ARGS_((Tcl_Interp* interp, sl@0: CONST84 char* name, Tcl_Namespace *context, int flags, sl@0: Tcl_Command *rPtr)); sl@0: sl@0: typedef struct Tcl_ResolverInfo { sl@0: Tcl_ResolveCmdProc *cmdResProc; /* Procedure handling command name sl@0: * resolution. */ sl@0: Tcl_ResolveVarProc *varResProc; /* Procedure handling variable name sl@0: * resolution for variables that sl@0: * can only be handled at runtime. */ sl@0: Tcl_ResolveCompiledVarProc *compiledVarResProc; sl@0: /* Procedure handling variable name sl@0: * resolution at compile time. */ sl@0: } Tcl_ResolverInfo; sl@0: sl@0: /* sl@0: *---------------------------------------------------------------- sl@0: * Data structures related to namespaces. sl@0: *---------------------------------------------------------------- sl@0: */ sl@0: sl@0: /* sl@0: * The structure below defines a namespace. sl@0: * Note: the first five fields must match exactly the fields in a sl@0: * Tcl_Namespace structure (see tcl.h). If you change one, be sure to sl@0: * change the other. sl@0: */ sl@0: sl@0: typedef struct Namespace { sl@0: char *name; /* The namespace's simple (unqualified) sl@0: * name. This contains no ::'s. The name of sl@0: * the global namespace is "" although "::" sl@0: * is an synonym. */ sl@0: char *fullName; /* The namespace's fully qualified name. sl@0: * This starts with ::. */ sl@0: ClientData clientData; /* An arbitrary value associated with this sl@0: * namespace. */ sl@0: Tcl_NamespaceDeleteProc *deleteProc; sl@0: /* Procedure invoked when deleting the sl@0: * namespace to, e.g., free clientData. */ sl@0: struct Namespace *parentPtr; /* Points to the namespace that contains sl@0: * this one. NULL if this is the global sl@0: * namespace. */ sl@0: Tcl_HashTable childTable; /* Contains any child namespaces. Indexed sl@0: * by strings; values have type sl@0: * (Namespace *). */ sl@0: long nsId; /* Unique id for the namespace. */ sl@0: Tcl_Interp *interp; /* The interpreter containing this sl@0: * namespace. */ sl@0: int flags; /* OR-ed combination of the namespace sl@0: * status flags NS_DYING and NS_DEAD sl@0: * listed below. */ sl@0: int activationCount; /* Number of "activations" or active call sl@0: * frames for this namespace that are on sl@0: * the Tcl call stack. The namespace won't sl@0: * be freed until activationCount becomes sl@0: * zero. */ sl@0: int refCount; /* Count of references by namespaceName * sl@0: * objects. The namespace can't be freed sl@0: * until refCount becomes zero. */ sl@0: Tcl_HashTable cmdTable; /* Contains all the commands currently sl@0: * registered in the namespace. Indexed by sl@0: * strings; values have type (Command *). sl@0: * Commands imported by Tcl_Import have sl@0: * Command structures that point (via an sl@0: * ImportedCmdRef structure) to the sl@0: * Command structure in the source sl@0: * namespace's command table. */ sl@0: Tcl_HashTable varTable; /* Contains all the (global) variables sl@0: * currently in this namespace. Indexed sl@0: * by strings; values have type (Var *). */ sl@0: char **exportArrayPtr; /* Points to an array of string patterns sl@0: * specifying which commands are exported. sl@0: * A pattern may include "string match" sl@0: * style wildcard characters to specify sl@0: * multiple commands; however, no namespace sl@0: * qualifiers are allowed. NULL if no sl@0: * export patterns are registered. */ sl@0: int numExportPatterns; /* Number of export patterns currently sl@0: * registered using "namespace export". */ sl@0: int maxExportPatterns; /* Mumber of export patterns for which sl@0: * space is currently allocated. */ sl@0: int cmdRefEpoch; /* Incremented if a newly added command sl@0: * shadows a command for which this sl@0: * namespace has already cached a Command * sl@0: * pointer; this causes all its cached sl@0: * Command* pointers to be invalidated. */ sl@0: int resolverEpoch; /* Incremented whenever (a) the name resolution sl@0: * rules change for this namespace or (b) a sl@0: * newly added command shadows a command that sl@0: * is compiled to bytecodes. sl@0: * This invalidates all byte codes compiled sl@0: * in the namespace, causing the code to be sl@0: * recompiled under the new rules.*/ sl@0: Tcl_ResolveCmdProc *cmdResProc; sl@0: /* If non-null, this procedure overrides sl@0: * the usual command resolution mechanism sl@0: * in Tcl. This procedure is invoked sl@0: * within Tcl_FindCommand to resolve all sl@0: * command references within the namespace. */ sl@0: Tcl_ResolveVarProc *varResProc; sl@0: /* If non-null, this procedure overrides sl@0: * the usual variable resolution mechanism sl@0: * in Tcl. This procedure is invoked sl@0: * within Tcl_FindNamespaceVar to resolve all sl@0: * variable references within the namespace sl@0: * at runtime. */ sl@0: Tcl_ResolveCompiledVarProc *compiledVarResProc; sl@0: /* If non-null, this procedure overrides sl@0: * the usual variable resolution mechanism sl@0: * in Tcl. This procedure is invoked sl@0: * within LookupCompiledLocal to resolve sl@0: * variable references within the namespace sl@0: * at compile time. */ sl@0: } Namespace; sl@0: sl@0: /* sl@0: * Flags used to represent the status of a namespace: sl@0: * sl@0: * NS_DYING - 1 means Tcl_DeleteNamespace has been called to delete the sl@0: * namespace but there are still active call frames on the Tcl sl@0: * stack that refer to the namespace. When the last call frame sl@0: * referring to it has been popped, it's variables and command sl@0: * will be destroyed and it will be marked "dead" (NS_DEAD). sl@0: * The namespace can no longer be looked up by name. sl@0: * NS_DEAD - 1 means Tcl_DeleteNamespace has been called to delete the sl@0: * namespace and no call frames still refer to it. Its sl@0: * variables and command have already been destroyed. This bit sl@0: * allows the namespace resolution code to recognize that the sl@0: * namespace is "deleted". When the last namespaceName object sl@0: * in any byte code code unit that refers to the namespace has sl@0: * been freed (i.e., when the namespace's refCount is 0), the sl@0: * namespace's storage will be freed. sl@0: * NS_KILLED 1 means that TclTeardownNamespace has already been called on sl@0: * this namespace and it should not be called again [Bug 1355942] sl@0: */ sl@0: sl@0: #define NS_DYING 0x01 sl@0: #define NS_DEAD 0x02 sl@0: #define NS_KILLED 0x04 sl@0: sl@0: /* sl@0: * Flag passed to TclGetNamespaceForQualName to have it create all namespace sl@0: * components of a namespace-qualified name that cannot be found. The new sl@0: * namespaces are created within their specified parent. Note that this sl@0: * flag's value must not conflict with the values of the flags sl@0: * TCL_GLOBAL_ONLY, TCL_NAMESPACE_ONLY, and FIND_ONLY_NS (defined in sl@0: * tclNamesp.c). sl@0: */ sl@0: sl@0: #define CREATE_NS_IF_UNKNOWN 0x800 sl@0: sl@0: /* sl@0: *---------------------------------------------------------------- sl@0: * Data structures related to variables. These are used primarily sl@0: * in tclVar.c sl@0: *---------------------------------------------------------------- sl@0: */ sl@0: sl@0: /* sl@0: * The following structure defines a variable trace, which is used to sl@0: * invoke a specific C procedure whenever certain operations are performed sl@0: * on a variable. sl@0: */ sl@0: sl@0: typedef struct VarTrace { sl@0: Tcl_VarTraceProc *traceProc;/* Procedure to call when operations given sl@0: * by flags are performed on variable. */ sl@0: ClientData clientData; /* Argument to pass to proc. */ sl@0: int flags; /* What events the trace procedure is sl@0: * interested in: OR-ed combination of sl@0: * TCL_TRACE_READS, TCL_TRACE_WRITES, sl@0: * TCL_TRACE_UNSETS and TCL_TRACE_ARRAY. */ sl@0: struct VarTrace *nextPtr; /* Next in list of traces associated with sl@0: * a particular variable. */ sl@0: } VarTrace; sl@0: sl@0: /* sl@0: * The following structure defines a command trace, which is used to sl@0: * invoke a specific C procedure whenever certain operations are performed sl@0: * on a command. sl@0: */ sl@0: sl@0: typedef struct CommandTrace { sl@0: Tcl_CommandTraceProc *traceProc;/* Procedure to call when operations given sl@0: * by flags are performed on command. */ sl@0: ClientData clientData; /* Argument to pass to proc. */ sl@0: int flags; /* What events the trace procedure is sl@0: * interested in: OR-ed combination of sl@0: * TCL_TRACE_RENAME, TCL_TRACE_DELETE. */ sl@0: struct CommandTrace *nextPtr; /* Next in list of traces associated with sl@0: * a particular command. */ sl@0: int refCount; /* Used to ensure this structure is sl@0: * not deleted too early. Keeps track sl@0: * of how many pieces of code have sl@0: * a pointer to this structure. */ sl@0: } CommandTrace; sl@0: sl@0: /* sl@0: * When a command trace is active (i.e. its associated procedure is sl@0: * executing), one of the following structures is linked into a list sl@0: * associated with the command's interpreter. The information in sl@0: * the structure is needed in order for Tcl to behave reasonably sl@0: * if traces are deleted while traces are active. sl@0: */ sl@0: sl@0: typedef struct ActiveCommandTrace { sl@0: struct Command *cmdPtr; /* Command that's being traced. */ sl@0: struct ActiveCommandTrace *nextPtr; sl@0: /* Next in list of all active command sl@0: * traces for the interpreter, or NULL sl@0: * if no more. */ sl@0: CommandTrace *nextTracePtr; /* Next trace to check after current sl@0: * trace procedure returns; if this sl@0: * trace gets deleted, must update pointer sl@0: * to avoid using free'd memory. */ sl@0: int reverseScan; /* Boolean set true when the traces sl@0: * are scanning in reverse order. */ sl@0: } ActiveCommandTrace; sl@0: sl@0: /* sl@0: * When a variable trace is active (i.e. its associated procedure is sl@0: * executing), one of the following structures is linked into a list sl@0: * associated with the variable's interpreter. The information in sl@0: * the structure is needed in order for Tcl to behave reasonably sl@0: * if traces are deleted while traces are active. sl@0: */ sl@0: sl@0: typedef struct ActiveVarTrace { sl@0: struct Var *varPtr; /* Variable that's being traced. */ sl@0: struct ActiveVarTrace *nextPtr; sl@0: /* Next in list of all active variable sl@0: * traces for the interpreter, or NULL sl@0: * if no more. */ sl@0: VarTrace *nextTracePtr; /* Next trace to check after current sl@0: * trace procedure returns; if this sl@0: * trace gets deleted, must update pointer sl@0: * to avoid using free'd memory. */ sl@0: } ActiveVarTrace; sl@0: sl@0: /* sl@0: * The following structure describes an enumerative search in progress on sl@0: * an array variable; this are invoked with options to the "array" sl@0: * command. sl@0: */ sl@0: sl@0: typedef struct ArraySearch { sl@0: int id; /* Integer id used to distinguish among sl@0: * multiple concurrent searches for the sl@0: * same array. */ sl@0: struct Var *varPtr; /* Pointer to array variable that's being sl@0: * searched. */ sl@0: Tcl_HashSearch search; /* Info kept by the hash module about sl@0: * progress through the array. */ sl@0: Tcl_HashEntry *nextEntry; /* Non-null means this is the next element sl@0: * to be enumerated (it's leftover from sl@0: * the Tcl_FirstHashEntry call or from sl@0: * an "array anymore" command). NULL sl@0: * means must call Tcl_NextHashEntry sl@0: * to get value to return. */ sl@0: struct ArraySearch *nextPtr;/* Next in list of all active searches sl@0: * for this variable, or NULL if this is sl@0: * the last one. */ sl@0: } ArraySearch; sl@0: sl@0: /* sl@0: * The structure below defines a variable, which associates a string name sl@0: * with a Tcl_Obj value. These structures are kept in procedure call frames sl@0: * (for local variables recognized by the compiler) or in the heap (for sl@0: * global variables and any variable not known to the compiler). For each sl@0: * Var structure in the heap, a hash table entry holds the variable name and sl@0: * a pointer to the Var structure. sl@0: */ sl@0: sl@0: typedef struct Var { sl@0: union { sl@0: Tcl_Obj *objPtr; /* The variable's object value. Used for sl@0: * scalar variables and array elements. */ sl@0: Tcl_HashTable *tablePtr;/* For array variables, this points to sl@0: * information about the hash table used sl@0: * to implement the associative array. sl@0: * Points to malloc-ed data. */ sl@0: struct Var *linkPtr; /* If this is a global variable being sl@0: * referred to in a procedure, or a variable sl@0: * created by "upvar", this field points to sl@0: * the referenced variable's Var struct. */ sl@0: } value; sl@0: char *name; /* NULL if the variable is in a hashtable, sl@0: * otherwise points to the variable's sl@0: * name. It is used, e.g., by TclLookupVar sl@0: * and "info locals". The storage for the sl@0: * characters of the name is not owned by sl@0: * the Var and must not be freed when sl@0: * freeing the Var. */ sl@0: Namespace *nsPtr; /* Points to the namespace that contains sl@0: * this variable or NULL if the variable is sl@0: * a local variable in a Tcl procedure. */ sl@0: Tcl_HashEntry *hPtr; /* If variable is in a hashtable, either the sl@0: * hash table entry that refers to this sl@0: * variable or NULL if the variable has been sl@0: * detached from its hash table (e.g. an sl@0: * array is deleted, but some of its sl@0: * elements are still referred to in sl@0: * upvars). NULL if the variable is not in a sl@0: * hashtable. This is used to delete an sl@0: * variable from its hashtable if it is no sl@0: * longer needed. */ sl@0: int refCount; /* Counts number of active uses of this sl@0: * variable, not including its entry in the sl@0: * call frame or the hash table: 1 for each sl@0: * additional variable whose linkPtr points sl@0: * here, 1 for each nested trace active on sl@0: * variable, and 1 if the variable is a sl@0: * namespace variable. This record can't be sl@0: * deleted until refCount becomes 0. */ sl@0: VarTrace *tracePtr; /* First in list of all traces set for this sl@0: * variable. */ sl@0: ArraySearch *searchPtr; /* First in list of all searches active sl@0: * for this variable, or NULL if none. */ sl@0: int flags; /* Miscellaneous bits of information about sl@0: * variable. See below for definitions. */ sl@0: } Var; sl@0: sl@0: /* sl@0: * Flag bits for variables. The first three (VAR_SCALAR, VAR_ARRAY, and sl@0: * VAR_LINK) are mutually exclusive and give the "type" of the variable. sl@0: * VAR_UNDEFINED is independent of the variable's type. sl@0: * sl@0: * VAR_SCALAR - 1 means this is a scalar variable and not sl@0: * an array or link. The "objPtr" field points sl@0: * to the variable's value, a Tcl object. sl@0: * VAR_ARRAY - 1 means this is an array variable rather sl@0: * than a scalar variable or link. The sl@0: * "tablePtr" field points to the array's sl@0: * hashtable for its elements. sl@0: * VAR_LINK - 1 means this Var structure contains a sl@0: * pointer to another Var structure that sl@0: * either has the real value or is itself sl@0: * another VAR_LINK pointer. Variables like sl@0: * this come about through "upvar" and "global" sl@0: * commands, or through references to variables sl@0: * in enclosing namespaces. sl@0: * VAR_UNDEFINED - 1 means that the variable is in the process sl@0: * of being deleted. An undefined variable sl@0: * logically does not exist and survives only sl@0: * while it has a trace, or if it is a global sl@0: * variable currently being used by some sl@0: * procedure. sl@0: * VAR_IN_HASHTABLE - 1 means this variable is in a hashtable and sl@0: * the Var structure is malloced. 0 if it is sl@0: * a local variable that was assigned a slot sl@0: * in a procedure frame by the compiler so the sl@0: * Var storage is part of the call frame. sl@0: * VAR_TRACE_ACTIVE - 1 means that trace processing is currently sl@0: * underway for a read or write access, so sl@0: * new read or write accesses should not cause sl@0: * trace procedures to be called and the sl@0: * variable can't be deleted. sl@0: * VAR_ARRAY_ELEMENT - 1 means that this variable is an array sl@0: * element, so it is not legal for it to be sl@0: * an array itself (the VAR_ARRAY flag had sl@0: * better not be set). sl@0: * VAR_NAMESPACE_VAR - 1 means that this variable was declared sl@0: * as a namespace variable. This flag ensures sl@0: * it persists until its namespace is sl@0: * destroyed or until the variable is unset; sl@0: * it will persist even if it has not been sl@0: * initialized and is marked undefined. sl@0: * The variable's refCount is incremented to sl@0: * reflect the "reference" from its namespace. sl@0: * sl@0: * The following additional flags are used with the CompiledLocal type sl@0: * defined below: sl@0: * sl@0: * VAR_ARGUMENT - 1 means that this variable holds a procedure sl@0: * argument. sl@0: * VAR_TEMPORARY - 1 if the local variable is an anonymous sl@0: * temporary variable. Temporaries have a NULL sl@0: * name. sl@0: * VAR_RESOLVED - 1 if name resolution has been done for this sl@0: * variable. sl@0: */ sl@0: sl@0: #define VAR_SCALAR 0x1 sl@0: #define VAR_ARRAY 0x2 sl@0: #define VAR_LINK 0x4 sl@0: #define VAR_UNDEFINED 0x8 sl@0: #define VAR_IN_HASHTABLE 0x10 sl@0: #define VAR_TRACE_ACTIVE 0x20 sl@0: #define VAR_ARRAY_ELEMENT 0x40 sl@0: #define VAR_NAMESPACE_VAR 0x80 sl@0: sl@0: #define VAR_ARGUMENT 0x100 sl@0: #define VAR_TEMPORARY 0x200 sl@0: #define VAR_RESOLVED 0x400 sl@0: sl@0: /* sl@0: * Macros to ensure that various flag bits are set properly for variables. sl@0: * The ANSI C "prototypes" for these macros are: sl@0: * sl@0: * EXTERN void TclSetVarScalar _ANSI_ARGS_((Var *varPtr)); sl@0: * EXTERN void TclSetVarArray _ANSI_ARGS_((Var *varPtr)); sl@0: * EXTERN void TclSetVarLink _ANSI_ARGS_((Var *varPtr)); sl@0: * EXTERN void TclSetVarArrayElement _ANSI_ARGS_((Var *varPtr)); sl@0: * EXTERN void TclSetVarUndefined _ANSI_ARGS_((Var *varPtr)); sl@0: * EXTERN void TclClearVarUndefined _ANSI_ARGS_((Var *varPtr)); sl@0: */ sl@0: sl@0: #define TclSetVarScalar(varPtr) \ sl@0: (varPtr)->flags = ((varPtr)->flags & ~(VAR_ARRAY|VAR_LINK)) | VAR_SCALAR sl@0: sl@0: #define TclSetVarArray(varPtr) \ sl@0: (varPtr)->flags = ((varPtr)->flags & ~(VAR_SCALAR|VAR_LINK)) | VAR_ARRAY sl@0: sl@0: #define TclSetVarLink(varPtr) \ sl@0: (varPtr)->flags = ((varPtr)->flags & ~(VAR_SCALAR|VAR_ARRAY)) | VAR_LINK sl@0: sl@0: #define TclSetVarArrayElement(varPtr) \ sl@0: (varPtr)->flags = ((varPtr)->flags & ~VAR_ARRAY) | VAR_ARRAY_ELEMENT sl@0: sl@0: #define TclSetVarUndefined(varPtr) \ sl@0: (varPtr)->flags |= VAR_UNDEFINED sl@0: sl@0: #define TclClearVarUndefined(varPtr) \ sl@0: (varPtr)->flags &= ~VAR_UNDEFINED sl@0: sl@0: /* sl@0: * Macros to read various flag bits of variables. sl@0: * The ANSI C "prototypes" for these macros are: sl@0: * sl@0: * EXTERN int TclIsVarScalar _ANSI_ARGS_((Var *varPtr)); sl@0: * EXTERN int TclIsVarLink _ANSI_ARGS_((Var *varPtr)); sl@0: * EXTERN int TclIsVarArray _ANSI_ARGS_((Var *varPtr)); sl@0: * EXTERN int TclIsVarUndefined _ANSI_ARGS_((Var *varPtr)); sl@0: * EXTERN int TclIsVarArrayElement _ANSI_ARGS_((Var *varPtr)); sl@0: * EXTERN int TclIsVarTemporary _ANSI_ARGS_((Var *varPtr)); sl@0: * EXTERN int TclIsVarArgument _ANSI_ARGS_((Var *varPtr)); sl@0: * EXTERN int TclIsVarResolved _ANSI_ARGS_((Var *varPtr)); sl@0: */ sl@0: sl@0: #define TclIsVarScalar(varPtr) \ sl@0: ((varPtr)->flags & VAR_SCALAR) sl@0: sl@0: #define TclIsVarLink(varPtr) \ sl@0: ((varPtr)->flags & VAR_LINK) sl@0: sl@0: #define TclIsVarArray(varPtr) \ sl@0: ((varPtr)->flags & VAR_ARRAY) sl@0: sl@0: #define TclIsVarUndefined(varPtr) \ sl@0: ((varPtr)->flags & VAR_UNDEFINED) sl@0: sl@0: #define TclIsVarArrayElement(varPtr) \ sl@0: ((varPtr)->flags & VAR_ARRAY_ELEMENT) sl@0: sl@0: #define TclIsVarTemporary(varPtr) \ sl@0: ((varPtr)->flags & VAR_TEMPORARY) sl@0: sl@0: #define TclIsVarArgument(varPtr) \ sl@0: ((varPtr)->flags & VAR_ARGUMENT) sl@0: sl@0: #define TclIsVarResolved(varPtr) \ sl@0: ((varPtr)->flags & VAR_RESOLVED) sl@0: sl@0: /* sl@0: *---------------------------------------------------------------- sl@0: * Data structures related to procedures. These are used primarily sl@0: * in tclProc.c, tclCompile.c, and tclExecute.c. sl@0: *---------------------------------------------------------------- sl@0: */ sl@0: sl@0: /* sl@0: * Forward declaration to prevent an error when the forward reference to sl@0: * Command is encountered in the Proc and ImportRef types declared below. sl@0: */ sl@0: sl@0: struct Command; sl@0: sl@0: /* sl@0: * The variable-length structure below describes a local variable of a sl@0: * procedure that was recognized by the compiler. These variables have a sl@0: * name, an element in the array of compiler-assigned local variables in the sl@0: * procedure's call frame, and various other items of information. If the sl@0: * local variable is a formal argument, it may also have a default value. sl@0: * The compiler can't recognize local variables whose names are sl@0: * expressions (these names are only known at runtime when the expressions sl@0: * are evaluated) or local variables that are created as a result of an sl@0: * "upvar" or "uplevel" command. These other local variables are kept sl@0: * separately in a hash table in the call frame. sl@0: */ sl@0: sl@0: typedef struct CompiledLocal { sl@0: struct CompiledLocal *nextPtr; sl@0: /* Next compiler-recognized local variable sl@0: * for this procedure, or NULL if this is sl@0: * the last local. */ sl@0: int nameLength; /* The number of characters in local sl@0: * variable's name. Used to speed up sl@0: * variable lookups. */ sl@0: int frameIndex; /* Index in the array of compiler-assigned sl@0: * variables in the procedure call frame. */ sl@0: int flags; /* Flag bits for the local variable. Same as sl@0: * the flags for the Var structure above, sl@0: * although only VAR_SCALAR, VAR_ARRAY, sl@0: * VAR_LINK, VAR_ARGUMENT, VAR_TEMPORARY, and sl@0: * VAR_RESOLVED make sense. */ sl@0: Tcl_Obj *defValuePtr; /* Pointer to the default value of an sl@0: * argument, if any. NULL if not an argument sl@0: * or, if an argument, no default value. */ sl@0: Tcl_ResolvedVarInfo *resolveInfo; sl@0: /* Customized variable resolution info sl@0: * supplied by the Tcl_ResolveCompiledVarProc sl@0: * associated with a namespace. Each variable sl@0: * is marked by a unique ClientData tag sl@0: * during compilation, and that same tag sl@0: * is used to find the variable at runtime. */ sl@0: char name[4]; /* Name of the local variable starts here. sl@0: * If the name is NULL, this will just be sl@0: * '\0'. The actual size of this field will sl@0: * be large enough to hold the name. MUST sl@0: * BE THE LAST FIELD IN THE STRUCTURE! */ sl@0: } CompiledLocal; sl@0: sl@0: /* sl@0: * The structure below defines a command procedure, which consists of a sl@0: * collection of Tcl commands plus information about arguments and other sl@0: * local variables recognized at compile time. sl@0: */ sl@0: sl@0: typedef struct Proc { sl@0: struct Interp *iPtr; /* Interpreter for which this command sl@0: * is defined. */ sl@0: int refCount; /* Reference count: 1 if still present sl@0: * in command table plus 1 for each call sl@0: * to the procedure that is currently sl@0: * active. This structure can be freed sl@0: * when refCount becomes zero. */ sl@0: struct Command *cmdPtr; /* Points to the Command structure for sl@0: * this procedure. This is used to get sl@0: * the namespace in which to execute sl@0: * the procedure. */ sl@0: Tcl_Obj *bodyPtr; /* Points to the ByteCode object for sl@0: * procedure's body command. */ sl@0: int numArgs; /* Number of formal parameters. */ sl@0: int numCompiledLocals; /* Count of local variables recognized by sl@0: * the compiler including arguments and sl@0: * temporaries. */ sl@0: CompiledLocal *firstLocalPtr; /* Pointer to first of the procedure's sl@0: * compiler-allocated local variables, or sl@0: * NULL if none. The first numArgs entries sl@0: * in this list describe the procedure's sl@0: * formal arguments. */ sl@0: CompiledLocal *lastLocalPtr; /* Pointer to the last allocated local sl@0: * variable or NULL if none. This has sl@0: * frame index (numCompiledLocals-1). */ sl@0: } Proc; sl@0: sl@0: /* sl@0: * The structure below defines a command trace. This is used to allow Tcl sl@0: * clients to find out whenever a command is about to be executed. sl@0: */ sl@0: sl@0: typedef struct Trace { sl@0: int level; /* Only trace commands at nesting level sl@0: * less than or equal to this. */ sl@0: Tcl_CmdObjTraceProc *proc; /* Procedure to call to trace command. */ sl@0: ClientData clientData; /* Arbitrary value to pass to proc. */ sl@0: struct Trace *nextPtr; /* Next in list of traces for this interp. */ sl@0: int flags; /* Flags governing the trace - see sl@0: * Tcl_CreateObjTrace for details */ sl@0: Tcl_CmdObjTraceDeleteProc* delProc; sl@0: /* Procedure to call when trace is deleted */ sl@0: } Trace; sl@0: sl@0: /* sl@0: * When an interpreter trace is active (i.e. its associated procedure sl@0: * is executing), one of the following structures is linked into a list sl@0: * associated with the interpreter. The information in the structure sl@0: * is needed in order for Tcl to behave reasonably if traces are sl@0: * deleted while traces are active. sl@0: */ sl@0: sl@0: typedef struct ActiveInterpTrace { sl@0: struct ActiveInterpTrace *nextPtr; sl@0: /* Next in list of all active command sl@0: * traces for the interpreter, or NULL sl@0: * if no more. */ sl@0: Trace *nextTracePtr; /* Next trace to check after current sl@0: * trace procedure returns; if this sl@0: * trace gets deleted, must update pointer sl@0: * to avoid using free'd memory. */ sl@0: int reverseScan; /* Boolean set true when the traces sl@0: * are scanning in reverse order. */ sl@0: } ActiveInterpTrace; sl@0: sl@0: /* sl@0: * The structure below defines an entry in the assocData hash table which sl@0: * is associated with an interpreter. The entry contains a pointer to a sl@0: * function to call when the interpreter is deleted, and a pointer to sl@0: * a user-defined piece of data. sl@0: */ sl@0: sl@0: typedef struct AssocData { sl@0: Tcl_InterpDeleteProc *proc; /* Proc to call when deleting. */ sl@0: ClientData clientData; /* Value to pass to proc. */ sl@0: } AssocData; sl@0: sl@0: /* sl@0: * The structure below defines a call frame. A call frame defines a naming sl@0: * context for a procedure call: its local naming scope (for local sl@0: * variables) and its global naming scope (a namespace, perhaps the global sl@0: * :: namespace). A call frame can also define the naming context for a sl@0: * namespace eval or namespace inscope command: the namespace in which the sl@0: * command's code should execute. The Tcl_CallFrame structures exist only sl@0: * while procedures or namespace eval/inscope's are being executed, and sl@0: * provide a kind of Tcl call stack. sl@0: * sl@0: * WARNING!! The structure definition must be kept consistent with the sl@0: * Tcl_CallFrame structure in tcl.h. If you change one, change the other. sl@0: */ sl@0: sl@0: typedef struct CallFrame { sl@0: Namespace *nsPtr; /* Points to the namespace used to resolve sl@0: * commands and global variables. */ sl@0: int isProcCallFrame; /* If nonzero, the frame was pushed to sl@0: * execute a Tcl procedure and may have sl@0: * local vars. If 0, the frame was pushed sl@0: * to execute a namespace command and var sl@0: * references are treated as references to sl@0: * namespace vars; varTablePtr and sl@0: * compiledLocals are ignored. */ sl@0: int objc; /* This and objv below describe the sl@0: * arguments for this procedure call. */ sl@0: Tcl_Obj *CONST *objv; /* Array of argument objects. */ sl@0: struct CallFrame *callerPtr; sl@0: /* Value of interp->framePtr when this sl@0: * procedure was invoked (i.e. next higher sl@0: * in stack of all active procedures). */ sl@0: struct CallFrame *callerVarPtr; sl@0: /* Value of interp->varFramePtr when this sl@0: * procedure was invoked (i.e. determines sl@0: * variable scoping within caller). Same sl@0: * as callerPtr unless an "uplevel" command sl@0: * or something equivalent was active in sl@0: * the caller). */ sl@0: int level; /* Level of this procedure, for "uplevel" sl@0: * purposes (i.e. corresponds to nesting of sl@0: * callerVarPtr's, not callerPtr's). 1 for sl@0: * outermost procedure, 0 for top-level. */ sl@0: Proc *procPtr; /* Points to the structure defining the sl@0: * called procedure. Used to get information sl@0: * such as the number of compiled local sl@0: * variables (local variables assigned sl@0: * entries ["slots"] in the compiledLocals sl@0: * array below). */ sl@0: Tcl_HashTable *varTablePtr; /* Hash table containing local variables not sl@0: * recognized by the compiler, or created at sl@0: * execution time through, e.g., upvar. sl@0: * Initially NULL and created if needed. */ sl@0: int numCompiledLocals; /* Count of local variables recognized by sl@0: * the compiler including arguments. */ sl@0: Var* compiledLocals; /* Points to the array of local variables sl@0: * recognized by the compiler. The compiler sl@0: * emits code that refers to these variables sl@0: * using an index into this array. */ sl@0: } CallFrame; sl@0: sl@0: #ifdef TCL_TIP280 sl@0: /* sl@0: * TIP #280 sl@0: * The structure below defines a command frame. A command frame sl@0: * provides location information for all commands executing a tcl sl@0: * script (source, eval, uplevel, procedure bodies, ...). The runtime sl@0: * structure essentially contains the stack trace as it would be if sl@0: * the currently executing command were to throw an error. sl@0: * sl@0: * For commands where it makes sense it refers to the associated sl@0: * CallFrame as well. sl@0: * sl@0: * The structures are chained in a single list, with the top of the sl@0: * stack anchored in the Interp structure. sl@0: * sl@0: * Instances can be allocated on the C stack, or the heap, the former sl@0: * making cleanup a bit simpler. sl@0: */ sl@0: sl@0: typedef struct CmdFrame { sl@0: /* General data. Always available. */ sl@0: sl@0: int type; /* Values see below */ sl@0: int level; /* #Frames in stack, prevent O(n) scan of list */ sl@0: int* line; /* Lines the words of the command start on */ sl@0: int nline; sl@0: sl@0: CallFrame* framePtr; /* Procedure activation record, may be NULL */ sl@0: struct CmdFrame* nextPtr; /* Link to calling frame */ sl@0: sl@0: /* Data needed for Eval vs TEBC sl@0: * sl@0: * EXECUTION CONTEXTS and usage of CmdFrame sl@0: * sl@0: * Field TEBC EvalEx EvalObjEx sl@0: * ======= ==== ====== ========= sl@0: * level yes yes yes sl@0: * type BC/PREBC SRC/EVAL EVAL_LIST sl@0: * line0 yes yes yes sl@0: * framePtr yes yes yes sl@0: * ======= ==== ====== ========= sl@0: * sl@0: * ======= ==== ====== ========= union data sl@0: * line1 - yes - sl@0: * line3 - yes - sl@0: * path - yes - sl@0: * ------- ---- ------ --------- sl@0: * codePtr yes - - sl@0: * pc yes - - sl@0: * ======= ==== ====== ========= sl@0: * sl@0: * ======= ==== ====== ========= | union cmd sl@0: * listPtr - - yes | sl@0: * ------- ---- ------ --------- | sl@0: * cmd yes yes - | sl@0: * cmdlen yes yes - | sl@0: * ------- ---- ------ --------- | sl@0: */ sl@0: sl@0: union { sl@0: struct { sl@0: Tcl_Obj* path; /* Path of the sourced file the command sl@0: * is in. */ sl@0: } eval; sl@0: struct { sl@0: CONST void* codePtr; /* Byte code currently executed */ sl@0: CONST char* pc; /* and instruction pointer. */ sl@0: } tebc; sl@0: } data; sl@0: sl@0: union { sl@0: struct { sl@0: CONST char* cmd; /* The executed command, if possible */ sl@0: int len; /* And its length */ sl@0: } str; sl@0: Tcl_Obj* listPtr; /* Tcl_EvalObjEx, cmd list */ sl@0: } cmd; sl@0: sl@0: } CmdFrame; sl@0: sl@0: /* The following macros define the allowed values for the type field sl@0: * of the CmdFrame structure above. Some of the values occur only in sl@0: * the extended location data referenced via the 'baseLocPtr'. sl@0: * sl@0: * TCL_LOCATION_EVAL : Frame is for a script evaluated by EvalEx. sl@0: * TCL_LOCATION_EVAL_LIST : Frame is for a script evaluated by the list sl@0: * optimization path of EvalObjEx. sl@0: * TCL_LOCATION_BC : Frame is for bytecode. sl@0: * TCL_LOCATION_PREBC : Frame is for precompiled bytecode. sl@0: * TCL_LOCATION_SOURCE : Frame is for a script evaluated by EvalEx, sl@0: * from a sourced file. sl@0: * TCL_LOCATION_PROC : Frame is for bytecode of a procedure. sl@0: * sl@0: * A TCL_LOCATION_BC type in a frame can be overridden by _SOURCE and sl@0: * _PROC types, per the context of the byte code in execution. sl@0: */ sl@0: sl@0: #define TCL_LOCATION_EVAL (0) /* Location in a dynamic eval script */ sl@0: #define TCL_LOCATION_EVAL_LIST (1) /* Location in a dynamic eval script, list-path */ sl@0: #define TCL_LOCATION_BC (2) /* Location in byte code */ sl@0: #define TCL_LOCATION_PREBC (3) /* Location in precompiled byte code, no location */ sl@0: #define TCL_LOCATION_SOURCE (4) /* Location in a file */ sl@0: #define TCL_LOCATION_PROC (5) /* Location in a dynamic proc */ sl@0: sl@0: #define TCL_LOCATION_LAST (6) /* Number of values in the enum */ sl@0: #endif sl@0: sl@0: /* sl@0: *---------------------------------------------------------------- sl@0: * Data structures and procedures related to TclHandles, which sl@0: * are a very lightweight method of preserving enough information sl@0: * to determine if an arbitrary malloc'd block has been deleted. sl@0: *---------------------------------------------------------------- sl@0: */ sl@0: sl@0: typedef VOID **TclHandle; sl@0: sl@0: /* sl@0: *---------------------------------------------------------------- sl@0: * Data structures related to expressions. These are used only in sl@0: * tclExpr.c. sl@0: *---------------------------------------------------------------- sl@0: */ sl@0: sl@0: /* sl@0: * The data structure below defines a math function (e.g. sin or hypot) sl@0: * for use in Tcl expressions. sl@0: */ sl@0: sl@0: #define MAX_MATH_ARGS 5 sl@0: typedef struct MathFunc { sl@0: int builtinFuncIndex; /* If this is a builtin math function, its sl@0: * index in the array of builtin functions. sl@0: * (tclCompilation.h lists these indices.) sl@0: * The value is -1 if this is a new function sl@0: * defined by Tcl_CreateMathFunc. The value sl@0: * is also -1 if a builtin function is sl@0: * replaced by a Tcl_CreateMathFunc call. */ sl@0: int numArgs; /* Number of arguments for function. */ sl@0: Tcl_ValueType argTypes[MAX_MATH_ARGS]; sl@0: /* Acceptable types for each argument. */ sl@0: Tcl_MathProc *proc; /* Procedure that implements this function. sl@0: * NULL if isBuiltinFunc is 1. */ sl@0: ClientData clientData; /* Additional argument to pass to the sl@0: * function when invoking it. NULL if sl@0: * isBuiltinFunc is 1. */ sl@0: } MathFunc; sl@0: sl@0: /* sl@0: * These are a thin layer over TclpThreadKeyDataGet and TclpThreadKeyDataSet sl@0: * when threads are used, or an emulation if there are no threads. These sl@0: * are really internal and Tcl clients should use Tcl_GetThreadData. sl@0: */ sl@0: sl@0: EXTERN VOID *TclThreadDataKeyGet _ANSI_ARGS_((Tcl_ThreadDataKey *keyPtr)); sl@0: EXTERN void TclThreadDataKeySet _ANSI_ARGS_((Tcl_ThreadDataKey *keyPtr, VOID *data)); sl@0: sl@0: /* sl@0: * This is a convenience macro used to initialize a thread local storage ptr. sl@0: */ sl@0: #define TCL_TSD_INIT(keyPtr) (ThreadSpecificData *)Tcl_GetThreadData((keyPtr), sizeof(ThreadSpecificData)) sl@0: sl@0: sl@0: /* sl@0: *---------------------------------------------------------------- sl@0: * Data structures related to bytecode compilation and execution. sl@0: * These are used primarily in tclCompile.c, tclExecute.c, and sl@0: * tclBasic.c. sl@0: *---------------------------------------------------------------- sl@0: */ sl@0: sl@0: /* sl@0: * Forward declaration to prevent errors when the forward references to sl@0: * Tcl_Parse and CompileEnv are encountered in the procedure type sl@0: * CompileProc declared below. sl@0: */ sl@0: sl@0: struct CompileEnv; sl@0: sl@0: /* sl@0: * The type of procedures called by the Tcl bytecode compiler to compile sl@0: * commands. Pointers to these procedures are kept in the Command structure sl@0: * describing each command. When a CompileProc returns, the interpreter's sl@0: * result is set to error information, if any. In addition, the CompileProc sl@0: * returns an integer value, which is one of the following: sl@0: * sl@0: * TCL_OK Compilation completed normally. sl@0: * TCL_ERROR Compilation failed because of an error; sl@0: * the interpreter's result describes what went wrong. sl@0: * TCL_OUT_LINE_COMPILE Compilation failed because, e.g., the command is sl@0: * too complex for effective inline compilation. The sl@0: * CompileProc believes the command is legal but sl@0: * should be compiled "out of line" by emitting code sl@0: * to invoke its command procedure at runtime. sl@0: */ sl@0: sl@0: #define TCL_OUT_LINE_COMPILE (TCL_CONTINUE + 1) sl@0: sl@0: typedef int (CompileProc) _ANSI_ARGS_((Tcl_Interp *interp, sl@0: Tcl_Parse *parsePtr, struct CompileEnv *compEnvPtr)); sl@0: sl@0: /* sl@0: * The type of procedure called from the compilation hook point in sl@0: * SetByteCodeFromAny. sl@0: */ sl@0: sl@0: typedef int (CompileHookProc) _ANSI_ARGS_((Tcl_Interp *interp, sl@0: struct CompileEnv *compEnvPtr, ClientData clientData)); sl@0: sl@0: /* sl@0: * The data structure defining the execution environment for ByteCode's. sl@0: * There is one ExecEnv structure per Tcl interpreter. It holds the sl@0: * evaluation stack that holds command operands and results. The stack grows sl@0: * towards increasing addresses. The "stackTop" member is cached by sl@0: * TclExecuteByteCode in a local variable: it must be set before calling sl@0: * TclExecuteByteCode and will be restored by TclExecuteByteCode before it sl@0: * returns. sl@0: */ sl@0: sl@0: typedef struct ExecEnv { sl@0: Tcl_Obj **stackPtr; /* Points to the first item in the sl@0: * evaluation stack on the heap. */ sl@0: int stackTop; /* Index of current top of stack; -1 when sl@0: * the stack is empty. */ sl@0: int stackEnd; /* Index of last usable item in stack. */ sl@0: Tcl_Obj *errorInfo; sl@0: Tcl_Obj *errorCode; sl@0: } ExecEnv; sl@0: sl@0: /* sl@0: * The definitions for the LiteralTable and LiteralEntry structures. Each sl@0: * interpreter contains a LiteralTable. It is used to reduce the storage sl@0: * needed for all the Tcl objects that hold the literals of scripts compiled sl@0: * by the interpreter. A literal's object is shared by all the ByteCodes sl@0: * that refer to the literal. Each distinct literal has one LiteralEntry sl@0: * entry in the LiteralTable. A literal table is a specialized hash table sl@0: * that is indexed by the literal's string representation, which may contain sl@0: * null characters. sl@0: * sl@0: * Note that we reduce the space needed for literals by sharing literal sl@0: * objects both within a ByteCode (each ByteCode contains a local sl@0: * LiteralTable) and across all an interpreter's ByteCodes (with the sl@0: * interpreter's global LiteralTable). sl@0: */ sl@0: sl@0: typedef struct LiteralEntry { sl@0: struct LiteralEntry *nextPtr; /* Points to next entry in this sl@0: * hash bucket or NULL if end of sl@0: * chain. */ sl@0: Tcl_Obj *objPtr; /* Points to Tcl object that sl@0: * holds the literal's bytes and sl@0: * length. */ sl@0: int refCount; /* If in an interpreter's global sl@0: * literal table, the number of sl@0: * ByteCode structures that share sl@0: * the literal object; the literal sl@0: * entry can be freed when refCount sl@0: * drops to 0. If in a local literal sl@0: * table, -1. */ sl@0: } LiteralEntry; sl@0: sl@0: typedef struct LiteralTable { sl@0: LiteralEntry **buckets; /* Pointer to bucket array. Each sl@0: * element points to first entry in sl@0: * bucket's hash chain, or NULL. */ sl@0: LiteralEntry *staticBuckets[TCL_SMALL_HASH_TABLE]; sl@0: /* Bucket array used for small sl@0: * tables to avoid mallocs and sl@0: * frees. */ sl@0: int numBuckets; /* Total number of buckets allocated sl@0: * at **buckets. */ sl@0: int numEntries; /* Total number of entries present sl@0: * in table. */ sl@0: int rebuildSize; /* Enlarge table when numEntries sl@0: * gets to be this large. */ sl@0: int mask; /* Mask value used in hashing sl@0: * function. */ sl@0: } LiteralTable; sl@0: sl@0: /* sl@0: * The following structure defines for each Tcl interpreter various sl@0: * statistics-related information about the bytecode compiler and sl@0: * interpreter's operation in that interpreter. sl@0: */ sl@0: sl@0: #ifdef TCL_COMPILE_STATS sl@0: typedef struct ByteCodeStats { sl@0: long numExecutions; /* Number of ByteCodes executed. */ sl@0: long numCompilations; /* Number of ByteCodes created. */ sl@0: long numByteCodesFreed; /* Number of ByteCodes destroyed. */ sl@0: long instructionCount[256]; /* Number of times each instruction was sl@0: * executed. */ sl@0: sl@0: double totalSrcBytes; /* Total source bytes ever compiled. */ sl@0: double totalByteCodeBytes; /* Total bytes for all ByteCodes. */ sl@0: double currentSrcBytes; /* Src bytes for all current ByteCodes. */ sl@0: double currentByteCodeBytes; /* Code bytes in all current ByteCodes. */ sl@0: sl@0: long srcCount[32]; /* Source size distribution: # of srcs of sl@0: * size [2**(n-1)..2**n), n in [0..32). */ sl@0: long byteCodeCount[32]; /* ByteCode size distribution. */ sl@0: long lifetimeCount[32]; /* ByteCode lifetime distribution (ms). */ sl@0: sl@0: double currentInstBytes; /* Instruction bytes-current ByteCodes. */ sl@0: double currentLitBytes; /* Current literal bytes. */ sl@0: double currentExceptBytes; /* Current exception table bytes. */ sl@0: double currentAuxBytes; /* Current auxiliary information bytes. */ sl@0: double currentCmdMapBytes; /* Current src<->code map bytes. */ sl@0: sl@0: long numLiteralsCreated; /* Total literal objects ever compiled. */ sl@0: double totalLitStringBytes; /* Total string bytes in all literals. */ sl@0: double currentLitStringBytes; /* String bytes in current literals. */ sl@0: long literalCount[32]; /* Distribution of literal string sizes. */ sl@0: } ByteCodeStats; sl@0: #endif /* TCL_COMPILE_STATS */ sl@0: sl@0: /* sl@0: *---------------------------------------------------------------- sl@0: * Data structures related to commands. sl@0: *---------------------------------------------------------------- sl@0: */ sl@0: sl@0: /* sl@0: * An imported command is created in an namespace when it imports a "real" sl@0: * command from another namespace. An imported command has a Command sl@0: * structure that points (via its ClientData value) to the "real" Command sl@0: * structure in the source namespace's command table. The real command sl@0: * records all the imported commands that refer to it in a list of ImportRef sl@0: * structures so that they can be deleted when the real command is deleted. */ sl@0: sl@0: typedef struct ImportRef { sl@0: struct Command *importedCmdPtr; sl@0: /* Points to the imported command created in sl@0: * an importing namespace; this command sl@0: * redirects its invocations to the "real" sl@0: * command. */ sl@0: struct ImportRef *nextPtr; /* Next element on the linked list of sl@0: * imported commands that refer to the sl@0: * "real" command. The real command deletes sl@0: * these imported commands on this list when sl@0: * it is deleted. */ sl@0: } ImportRef; sl@0: sl@0: /* sl@0: * Data structure used as the ClientData of imported commands: commands sl@0: * created in an namespace when it imports a "real" command from another sl@0: * namespace. sl@0: */ sl@0: sl@0: typedef struct ImportedCmdData { sl@0: struct Command *realCmdPtr; /* "Real" command that this imported command sl@0: * refers to. */ sl@0: struct Command *selfPtr; /* Pointer to this imported command. Needed sl@0: * only when deleting it in order to remove sl@0: * it from the real command's linked list of sl@0: * imported commands that refer to it. */ sl@0: } ImportedCmdData; sl@0: sl@0: /* sl@0: * A Command structure exists for each command in a namespace. The sl@0: * Tcl_Command opaque type actually refers to these structures. sl@0: */ sl@0: sl@0: typedef struct Command { sl@0: Tcl_HashEntry *hPtr; /* Pointer to the hash table entry that sl@0: * refers to this command. The hash table is sl@0: * either a namespace's command table or an sl@0: * interpreter's hidden command table. This sl@0: * pointer is used to get a command's name sl@0: * from its Tcl_Command handle. NULL means sl@0: * that the hash table entry has been sl@0: * removed already (this can happen if sl@0: * deleteProc causes the command to be sl@0: * deleted or recreated). */ sl@0: Namespace *nsPtr; /* Points to the namespace containing this sl@0: * command. */ sl@0: int refCount; /* 1 if in command hashtable plus 1 for each sl@0: * reference from a CmdName Tcl object sl@0: * representing a command's name in a sl@0: * ByteCode instruction sequence. This sl@0: * structure can be freed when refCount sl@0: * becomes zero. */ sl@0: int cmdEpoch; /* Incremented to invalidate any references sl@0: * that point to this command when it is sl@0: * renamed, deleted, hidden, or exposed. */ sl@0: CompileProc *compileProc; /* Procedure called to compile command. NULL sl@0: * if no compile proc exists for command. */ sl@0: Tcl_ObjCmdProc *objProc; /* Object-based command procedure. */ sl@0: ClientData objClientData; /* Arbitrary value passed to object proc. */ sl@0: Tcl_CmdProc *proc; /* String-based command procedure. */ sl@0: ClientData clientData; /* Arbitrary value passed to string proc. */ sl@0: Tcl_CmdDeleteProc *deleteProc; sl@0: /* Procedure invoked when deleting command sl@0: * to, e.g., free all client data. */ sl@0: ClientData deleteData; /* Arbitrary value passed to deleteProc. */ sl@0: int flags; /* Miscellaneous bits of information about sl@0: * command. See below for definitions. */ sl@0: ImportRef *importRefPtr; /* List of each imported Command created in sl@0: * another namespace when this command is sl@0: * imported. These imported commands sl@0: * redirect invocations back to this sl@0: * command. The list is used to remove all sl@0: * those imported commands when deleting sl@0: * this "real" command. */ sl@0: CommandTrace *tracePtr; /* First in list of all traces set for this sl@0: * command. */ sl@0: } Command; sl@0: sl@0: /* sl@0: * Flag bits for commands. sl@0: * sl@0: * CMD_IS_DELETED - Means that the command is in the process sl@0: * of being deleted (its deleteProc is sl@0: * currently executing). Other attempts to sl@0: * delete the command should be ignored. sl@0: * CMD_TRACE_ACTIVE - 1 means that trace processing is currently sl@0: * underway for a rename/delete change. sl@0: * See the two flags below for which is sl@0: * currently being processed. sl@0: * CMD_HAS_EXEC_TRACES - 1 means that this command has at least sl@0: * one execution trace (as opposed to simple sl@0: * delete/rename traces) in its tracePtr list. sl@0: * TCL_TRACE_RENAME - A rename trace is in progress. Further sl@0: * recursive renames will not be traced. sl@0: * TCL_TRACE_DELETE - A delete trace is in progress. Further sl@0: * recursive deletes will not be traced. sl@0: * (these last two flags are defined in tcl.h) sl@0: */ sl@0: #define CMD_IS_DELETED 0x1 sl@0: #define CMD_TRACE_ACTIVE 0x2 sl@0: #define CMD_HAS_EXEC_TRACES 0x4 sl@0: sl@0: /* sl@0: *---------------------------------------------------------------- sl@0: * Data structures related to name resolution procedures. sl@0: *---------------------------------------------------------------- sl@0: */ sl@0: sl@0: /* sl@0: * The interpreter keeps a linked list of name resolution schemes. sl@0: * The scheme for a namespace is consulted first, followed by the sl@0: * list of schemes in an interpreter, followed by the default sl@0: * name resolution in Tcl. Schemes are added/removed from the sl@0: * interpreter's list by calling Tcl_AddInterpResolver and sl@0: * Tcl_RemoveInterpResolver. sl@0: */ sl@0: sl@0: typedef struct ResolverScheme { sl@0: char *name; /* Name identifying this scheme. */ sl@0: Tcl_ResolveCmdProc *cmdResProc; sl@0: /* Procedure handling command name sl@0: * resolution. */ sl@0: Tcl_ResolveVarProc *varResProc; sl@0: /* Procedure handling variable name sl@0: * resolution for variables that sl@0: * can only be handled at runtime. */ sl@0: Tcl_ResolveCompiledVarProc *compiledVarResProc; sl@0: /* Procedure handling variable name sl@0: * resolution at compile time. */ sl@0: sl@0: struct ResolverScheme *nextPtr; sl@0: /* Pointer to next record in linked list. */ sl@0: } ResolverScheme; sl@0: sl@0: #ifdef TCL_TIP268 sl@0: /* sl@0: * TIP #268. sl@0: * Values for the selection mode, i.e the package require preferences. sl@0: */ sl@0: sl@0: enum PkgPreferOptions { sl@0: PKG_PREFER_LATEST, PKG_PREFER_STABLE sl@0: }; sl@0: #endif sl@0: sl@0: /* sl@0: *---------------------------------------------------------------- sl@0: * This structure defines an interpreter, which is a collection of sl@0: * commands plus other state information related to interpreting sl@0: * commands, such as variable storage. Primary responsibility for sl@0: * this data structure is in tclBasic.c, but almost every Tcl sl@0: * source file uses something in here. sl@0: *---------------------------------------------------------------- sl@0: */ sl@0: sl@0: typedef struct Interp { sl@0: sl@0: /* sl@0: * Note: the first three fields must match exactly the fields in sl@0: * a Tcl_Interp struct (see tcl.h). If you change one, be sure to sl@0: * change the other. sl@0: * sl@0: * The interpreter's result is held in both the string and the sl@0: * objResultPtr fields. These fields hold, respectively, the result's sl@0: * string or object value. The interpreter's result is always in the sl@0: * result field if that is non-empty, otherwise it is in objResultPtr. sl@0: * The two fields are kept consistent unless some C code sets sl@0: * interp->result directly. Programs should not access result and sl@0: * objResultPtr directly; instead, they should always get and set the sl@0: * result using procedures such as Tcl_SetObjResult, Tcl_GetObjResult, sl@0: * and Tcl_GetStringResult. See the SetResult man page for details. sl@0: */ sl@0: sl@0: char *result; /* If the last command returned a string sl@0: * result, this points to it. Should not be sl@0: * accessed directly; see comment above. */ sl@0: Tcl_FreeProc *freeProc; /* Zero means a string result is statically sl@0: * allocated. TCL_DYNAMIC means string sl@0: * result was allocated with ckalloc and sl@0: * should be freed with ckfree. Other values sl@0: * give address of procedure to invoke to sl@0: * free the string result. Tcl_Eval must sl@0: * free it before executing next command. */ sl@0: int errorLine; /* When TCL_ERROR is returned, this gives sl@0: * the line number in the command where the sl@0: * error occurred (1 means first line). */ sl@0: struct TclStubs *stubTable; sl@0: /* Pointer to the exported Tcl stub table. sl@0: * On previous versions of Tcl this is a sl@0: * pointer to the objResultPtr or a pointer sl@0: * to a buckets array in a hash table. We sl@0: * therefore have to do some careful checking sl@0: * before we can use this. */ sl@0: sl@0: TclHandle handle; /* Handle used to keep track of when this sl@0: * interp is deleted. */ sl@0: sl@0: Namespace *globalNsPtr; /* The interpreter's global namespace. */ sl@0: Tcl_HashTable *hiddenCmdTablePtr; sl@0: /* Hash table used by tclBasic.c to keep sl@0: * track of hidden commands on a per-interp sl@0: * basis. */ sl@0: ClientData interpInfo; /* Information used by tclInterp.c to keep sl@0: * track of master/slave interps on sl@0: * a per-interp basis. */ sl@0: Tcl_HashTable mathFuncTable;/* Contains all the math functions currently sl@0: * defined for the interpreter. Indexed by sl@0: * strings (function names); values have sl@0: * type (MathFunc *). */ sl@0: sl@0: sl@0: sl@0: /* sl@0: * Information related to procedures and variables. See tclProc.c sl@0: * and tclVar.c for usage. sl@0: */ sl@0: sl@0: int numLevels; /* Keeps track of how many nested calls to sl@0: * Tcl_Eval are in progress for this sl@0: * interpreter. It's used to delay deletion sl@0: * of the table until all Tcl_Eval sl@0: * invocations are completed. */ sl@0: int maxNestingDepth; /* If numLevels exceeds this value then Tcl sl@0: * assumes that infinite recursion has sl@0: * occurred and it generates an error. */ sl@0: CallFrame *framePtr; /* Points to top-most in stack of all nested sl@0: * procedure invocations. NULL means there sl@0: * are no active procedures. */ sl@0: CallFrame *varFramePtr; /* Points to the call frame whose variables sl@0: * are currently in use (same as framePtr sl@0: * unless an "uplevel" command is sl@0: * executing). NULL means no procedure is sl@0: * active or "uplevel 0" is executing. */ sl@0: ActiveVarTrace *activeVarTracePtr; sl@0: /* First in list of active traces for sl@0: * interp, or NULL if no active traces. */ sl@0: int returnCode; /* Completion code to return if current sl@0: * procedure exits with TCL_RETURN code. */ sl@0: char *errorInfo; /* Value to store in errorInfo if returnCode sl@0: * is TCL_ERROR. Malloc'ed, may be NULL */ sl@0: char *errorCode; /* Value to store in errorCode if returnCode sl@0: * is TCL_ERROR. Malloc'ed, may be NULL */ sl@0: sl@0: /* sl@0: * Information used by Tcl_AppendResult to keep track of partial sl@0: * results. See Tcl_AppendResult code for details. sl@0: */ sl@0: sl@0: char *appendResult; /* Storage space for results generated sl@0: * by Tcl_AppendResult. Malloc-ed. NULL sl@0: * means not yet allocated. */ sl@0: int appendAvl; /* Total amount of space available at sl@0: * partialResult. */ sl@0: int appendUsed; /* Number of non-null bytes currently sl@0: * stored at partialResult. */ sl@0: sl@0: /* sl@0: * Information about packages. Used only in tclPkg.c. sl@0: */ sl@0: sl@0: Tcl_HashTable packageTable; /* Describes all of the packages loaded sl@0: * in or available to this interpreter. sl@0: * Keys are package names, values are sl@0: * (Package *) pointers. */ sl@0: char *packageUnknown; /* Command to invoke during "package sl@0: * require" commands for packages that sl@0: * aren't described in packageTable. sl@0: * Malloc'ed, may be NULL. */ sl@0: sl@0: /* sl@0: * Miscellaneous information: sl@0: */ sl@0: sl@0: int cmdCount; /* Total number of times a command procedure sl@0: * has been called for this interpreter. */ sl@0: int evalFlags; /* Flags to control next call to Tcl_Eval. sl@0: * Normally zero, but may be set before sl@0: * calling Tcl_Eval. See below for valid sl@0: * values. */ sl@0: int termOffset; /* Offset of character just after last one sl@0: * compiled or executed by Tcl_EvalObj. */ sl@0: LiteralTable literalTable; /* Contains LiteralEntry's describing all sl@0: * Tcl objects holding literals of scripts sl@0: * compiled by the interpreter. Indexed by sl@0: * the string representations of literals. sl@0: * Used to avoid creating duplicate sl@0: * objects. */ sl@0: int compileEpoch; /* Holds the current "compilation epoch" sl@0: * for this interpreter. This is sl@0: * incremented to invalidate existing sl@0: * ByteCodes when, e.g., a command with a sl@0: * compile procedure is redefined. */ sl@0: Proc *compiledProcPtr; /* If a procedure is being compiled, a sl@0: * pointer to its Proc structure; otherwise, sl@0: * this is NULL. Set by ObjInterpProc in sl@0: * tclProc.c and used by tclCompile.c to sl@0: * process local variables appropriately. */ sl@0: ResolverScheme *resolverPtr; sl@0: /* Linked list of name resolution schemes sl@0: * added to this interpreter. Schemes sl@0: * are added/removed by calling sl@0: * Tcl_AddInterpResolvers and sl@0: * Tcl_RemoveInterpResolver. */ sl@0: Tcl_Obj *scriptFile; /* NULL means there is no nested source sl@0: * command active; otherwise this points to sl@0: * pathPtr of the file being sourced. */ sl@0: int flags; /* Various flag bits. See below. */ sl@0: long randSeed; /* Seed used for rand() function. */ sl@0: Trace *tracePtr; /* List of traces for this interpreter. */ sl@0: Tcl_HashTable *assocData; /* Hash table for associating data with sl@0: * this interpreter. Cleaned up when sl@0: * this interpreter is deleted. */ sl@0: struct ExecEnv *execEnvPtr; /* Execution environment for Tcl bytecode sl@0: * execution. Contains a pointer to the sl@0: * Tcl evaluation stack. */ sl@0: Tcl_Obj *emptyObjPtr; /* Points to an object holding an empty sl@0: * string. Returned by Tcl_ObjSetVar2 when sl@0: * variable traces change a variable in a sl@0: * gross way. */ sl@0: char resultSpace[TCL_RESULT_SIZE+1]; sl@0: /* Static space holding small results. */ sl@0: Tcl_Obj *objResultPtr; /* If the last command returned an object sl@0: * result, this points to it. Should not be sl@0: * accessed directly; see comment above. */ sl@0: Tcl_ThreadId threadId; /* ID of thread that owns the interpreter */ sl@0: sl@0: ActiveCommandTrace *activeCmdTracePtr; sl@0: /* First in list of active command traces for sl@0: * interp, or NULL if no active traces. */ sl@0: ActiveInterpTrace *activeInterpTracePtr; sl@0: /* First in list of active traces for sl@0: * interp, or NULL if no active traces. */ sl@0: sl@0: int tracesForbiddingInline; /* Count of traces (in the list headed by sl@0: * tracePtr) that forbid inline bytecode sl@0: * compilation */ sl@0: #ifdef TCL_TIP280 sl@0: /* TIP #280 */ sl@0: CmdFrame* cmdFramePtr; /* Points to the command frame containing sl@0: * the location information for the current sl@0: * command. */ sl@0: CONST CmdFrame* invokeCmdFramePtr; /* Points to the command frame which is the sl@0: * invoking context of the bytecode compiler. sl@0: * NULL when the byte code compiler is not sl@0: * active */ sl@0: int invokeWord; /* Index of the word in the command which sl@0: * is getting compiled. */ sl@0: Tcl_HashTable* linePBodyPtr; sl@0: /* This table remembers for each sl@0: * statically defined procedure the sl@0: * location information for its sl@0: * body. It is keyed by the address of sl@0: * the Proc structure for a procedure. sl@0: */ sl@0: Tcl_HashTable* lineBCPtr; sl@0: /* This table remembers for each sl@0: * ByteCode object the location sl@0: * information for its body. It is sl@0: * keyed by the address of the Proc sl@0: * structure for a procedure. sl@0: */ sl@0: #endif sl@0: #ifdef TCL_TIP268 sl@0: /* sl@0: * TIP #268. sl@0: * The currently active selection mode, sl@0: * i.e the package require preferences. sl@0: */ sl@0: sl@0: int packagePrefer; /* Current package selection mode. */ sl@0: #endif sl@0: /* sl@0: * Statistical information about the bytecode compiler and interpreter's sl@0: * operation. sl@0: */ sl@0: sl@0: #ifdef TCL_COMPILE_STATS sl@0: ByteCodeStats stats; /* Holds compilation and execution sl@0: * statistics for this interpreter. */ sl@0: #endif /* TCL_COMPILE_STATS */ sl@0: } Interp; sl@0: sl@0: /* sl@0: * EvalFlag bits for Interp structures: sl@0: * sl@0: * TCL_BRACKET_TERM 1 means that the current script is terminated by sl@0: * a close bracket rather than the end of the string. sl@0: * TCL_ALLOW_EXCEPTIONS 1 means it's OK for the script to terminate with sl@0: * a code other than TCL_OK or TCL_ERROR; 0 means sl@0: * codes other than these should be turned into errors. sl@0: */ sl@0: sl@0: #define TCL_BRACKET_TERM 1 sl@0: #define TCL_ALLOW_EXCEPTIONS 4 sl@0: #ifdef TCL_TIP280 sl@0: #define TCL_EVAL_FILE 2 sl@0: #define TCL_EVAL_CTX 8 sl@0: #endif sl@0: sl@0: /* sl@0: * Flag bits for Interp structures: sl@0: * sl@0: * DELETED: Non-zero means the interpreter has been deleted: sl@0: * don't process any more commands for it, and destroy sl@0: * the structure as soon as all nested invocations of sl@0: * Tcl_Eval are done. sl@0: * ERR_IN_PROGRESS: Non-zero means an error unwind is already in sl@0: * progress. Zero means a command proc has been sl@0: * invoked since last error occured. sl@0: * ERR_ALREADY_LOGGED: Non-zero means information has already been logged sl@0: * in $errorInfo for the current Tcl_Eval instance, sl@0: * so Tcl_Eval needn't log it (used to implement the sl@0: * "error message log" command). sl@0: * ERROR_CODE_SET: Non-zero means that Tcl_SetErrorCode has been sl@0: * called to record information for the current sl@0: * error. Zero means Tcl_Eval must clear the sl@0: * errorCode variable if an error is returned. sl@0: * EXPR_INITIALIZED: Non-zero means initialization specific to sl@0: * expressions has been carried out. sl@0: * DONT_COMPILE_CMDS_INLINE: Non-zero means that the bytecode compiler sl@0: * should not compile any commands into an inline sl@0: * sequence of instructions. This is set 1, for sl@0: * example, when command traces are requested. sl@0: * RAND_SEED_INITIALIZED: Non-zero means that the randSeed value of the sl@0: * interp has not be initialized. This is set 1 sl@0: * when we first use the rand() or srand() functions. sl@0: * SAFE_INTERP: Non zero means that the current interp is a sl@0: * safe interp (ie it has only the safe commands sl@0: * installed, less priviledge than a regular interp). sl@0: * USE_EVAL_DIRECT: Non-zero means don't use the compiler or byte-code sl@0: * interpreter; instead, have Tcl_EvalObj call sl@0: * Tcl_EvalEx. Used primarily for testing the sl@0: * new parser. sl@0: * INTERP_TRACE_IN_PROGRESS: Non-zero means that an interp trace is currently sl@0: * active; so no further trace callbacks should be sl@0: * invoked. sl@0: */ sl@0: sl@0: #define DELETED 1 sl@0: #define ERR_IN_PROGRESS 2 sl@0: #define ERR_ALREADY_LOGGED 4 sl@0: #define ERROR_CODE_SET 8 sl@0: #define EXPR_INITIALIZED 0x10 sl@0: #define DONT_COMPILE_CMDS_INLINE 0x20 sl@0: #define RAND_SEED_INITIALIZED 0x40 sl@0: #define SAFE_INTERP 0x80 sl@0: #define USE_EVAL_DIRECT 0x100 sl@0: #define INTERP_TRACE_IN_PROGRESS 0x200 sl@0: sl@0: /* sl@0: * Maximum number of levels of nesting permitted in Tcl commands (used sl@0: * to catch infinite recursion). sl@0: */ sl@0: sl@0: #define MAX_NESTING_DEPTH 1000 sl@0: sl@0: /* sl@0: * The macro below is used to modify a "char" value (e.g. by casting sl@0: * it to an unsigned character) so that it can be used safely with sl@0: * macros such as isspace. sl@0: */ sl@0: sl@0: #define UCHAR(c) ((unsigned char) (c)) sl@0: sl@0: /* sl@0: * This macro is used to determine the offset needed to safely allocate any sl@0: * data structure in memory. Given a starting offset or size, it "rounds up" sl@0: * or "aligns" the offset to the next 8-byte boundary so that any data sl@0: * structure can be placed at the resulting offset without fear of an sl@0: * alignment error. sl@0: * sl@0: * WARNING!! DO NOT USE THIS MACRO TO ALIGN POINTERS: it will produce sl@0: * the wrong result on platforms that allocate addresses that are divisible sl@0: * by 4 or 2. Only use it for offsets or sizes. sl@0: */ sl@0: sl@0: #define TCL_ALIGN(x) (((int)(x) + 7) & ~7) sl@0: sl@0: /* sl@0: * The following enum values are used to specify the runtime platform sl@0: * setting of the tclPlatform variable. sl@0: */ sl@0: sl@0: typedef enum { sl@0: TCL_PLATFORM_UNIX, /* Any Unix-like OS. */ sl@0: TCL_PLATFORM_MAC, /* MacOS. */ sl@0: TCL_PLATFORM_WINDOWS /* Any Microsoft Windows OS. */ sl@0: } TclPlatformType; sl@0: sl@0: /* sl@0: * The following enum values are used to indicate the translation sl@0: * of a Tcl channel. Declared here so that each platform can define sl@0: * TCL_PLATFORM_TRANSLATION to the native translation on that platform sl@0: */ sl@0: sl@0: typedef enum TclEolTranslation { sl@0: TCL_TRANSLATE_AUTO, /* Eol == \r, \n and \r\n. */ sl@0: TCL_TRANSLATE_CR, /* Eol == \r. */ sl@0: TCL_TRANSLATE_LF, /* Eol == \n. */ sl@0: TCL_TRANSLATE_CRLF /* Eol == \r\n. */ sl@0: } TclEolTranslation; sl@0: sl@0: /* sl@0: * Flags for TclInvoke: sl@0: * sl@0: * TCL_INVOKE_HIDDEN Invoke a hidden command; if not set, sl@0: * invokes an exposed command. sl@0: * TCL_INVOKE_NO_UNKNOWN If set, "unknown" is not invoked if sl@0: * the command to be invoked is not found. sl@0: * Only has an effect if invoking an exposed sl@0: * command, i.e. if TCL_INVOKE_HIDDEN is not sl@0: * also set. sl@0: * TCL_INVOKE_NO_TRACEBACK Does not record traceback information if sl@0: * the invoked command returns an error. Used sl@0: * if the caller plans on recording its own sl@0: * traceback information. sl@0: */ sl@0: sl@0: #define TCL_INVOKE_HIDDEN (1<<0) sl@0: #define TCL_INVOKE_NO_UNKNOWN (1<<1) sl@0: #define TCL_INVOKE_NO_TRACEBACK (1<<2) sl@0: sl@0: /* sl@0: * The structure used as the internal representation of Tcl list sl@0: * objects. This is an array of pointers to the element objects. This array sl@0: * is grown (reallocated and copied) as necessary to hold all the list's sl@0: * element pointers. The array might contain more slots than currently used sl@0: * to hold all element pointers. This is done to make append operations sl@0: * faster. sl@0: */ sl@0: sl@0: typedef struct List { sl@0: int maxElemCount; /* Total number of element array slots. */ sl@0: int elemCount; /* Current number of list elements. */ sl@0: Tcl_Obj **elements; /* Array of pointers to element objects. */ sl@0: } List; sl@0: sl@0: sl@0: /* sl@0: * The following types are used for getting and storing platform-specific sl@0: * file attributes in tclFCmd.c and the various platform-versions of sl@0: * that file. This is done to have as much common code as possible sl@0: * in the file attributes code. For more information about the callbacks, sl@0: * see TclFileAttrsCmd in tclFCmd.c. sl@0: */ sl@0: sl@0: typedef int (TclGetFileAttrProc) _ANSI_ARGS_((Tcl_Interp *interp, sl@0: int objIndex, Tcl_Obj *fileName, Tcl_Obj **attrObjPtrPtr)); sl@0: typedef int (TclSetFileAttrProc) _ANSI_ARGS_((Tcl_Interp *interp, sl@0: int objIndex, Tcl_Obj *fileName, Tcl_Obj *attrObjPtr)); sl@0: sl@0: typedef struct TclFileAttrProcs { sl@0: TclGetFileAttrProc *getProc; /* The procedure for getting attrs. */ sl@0: TclSetFileAttrProc *setProc; /* The procedure for setting attrs. */ sl@0: } TclFileAttrProcs; sl@0: sl@0: /* sl@0: * Opaque handle used in pipeline routines to encapsulate platform-dependent sl@0: * state. sl@0: */ sl@0: sl@0: typedef struct TclFile_ *TclFile; sl@0: sl@0: /* sl@0: * Opaque names for platform specific types. sl@0: */ sl@0: sl@0: typedef struct TclpTime_t_ *TclpTime_t; sl@0: typedef struct TclpTime_t_ *CONST TclpTime_t_CONST; sl@0: sl@0: /* sl@0: * The "globParameters" argument of the function TclGlob is an sl@0: * or'ed combination of the following values: sl@0: */ sl@0: sl@0: #define TCL_GLOBMODE_NO_COMPLAIN 1 sl@0: #define TCL_GLOBMODE_JOIN 2 sl@0: #define TCL_GLOBMODE_DIR 4 sl@0: #define TCL_GLOBMODE_TAILS 8 sl@0: sl@0: /* sl@0: *---------------------------------------------------------------- sl@0: * Data structures related to obsolete filesystem hooks sl@0: *---------------------------------------------------------------- sl@0: */ sl@0: sl@0: typedef int (TclStatProc_) _ANSI_ARGS_((CONST char *path, struct stat *buf)); sl@0: typedef int (TclAccessProc_) _ANSI_ARGS_((CONST char *path, int mode)); sl@0: typedef Tcl_Channel (TclOpenFileChannelProc_) _ANSI_ARGS_((Tcl_Interp *interp, sl@0: CONST char *fileName, CONST char *modeString, sl@0: int permissions)); sl@0: sl@0: sl@0: /* sl@0: *---------------------------------------------------------------- sl@0: * Data structures related to procedures sl@0: *---------------------------------------------------------------- sl@0: */ sl@0: sl@0: typedef Tcl_CmdProc *TclCmdProcType; sl@0: typedef Tcl_ObjCmdProc *TclObjCmdProcType; sl@0: sl@0: /* sl@0: *---------------------------------------------------------------- sl@0: * Variables shared among Tcl modules but not used by the outside world. sl@0: *---------------------------------------------------------------- sl@0: */ sl@0: sl@0: extern Tcl_Time tclBlockTime; sl@0: extern int tclBlockTimeSet; sl@0: extern char * tclExecutableName; sl@0: extern char * tclNativeExecutableName; sl@0: extern char * tclDefaultEncodingDir; sl@0: extern Tcl_ChannelType tclFileChannelType; sl@0: extern char * tclMemDumpFileName; sl@0: extern TclPlatformType tclPlatform; sl@0: extern Tcl_NotifierProcs tclOriginalNotifier; sl@0: sl@0: /* sl@0: * Variables denoting the Tcl object types defined in the core. sl@0: */ sl@0: sl@0: extern Tcl_ObjType tclBooleanType; sl@0: extern Tcl_ObjType tclByteArrayType; sl@0: extern Tcl_ObjType tclByteCodeType; sl@0: extern Tcl_ObjType tclDoubleType; sl@0: extern Tcl_ObjType tclEndOffsetType; sl@0: extern Tcl_ObjType tclIntType; sl@0: extern Tcl_ObjType tclListType; sl@0: extern Tcl_ObjType tclProcBodyType; sl@0: extern Tcl_ObjType tclStringType; sl@0: extern Tcl_ObjType tclArraySearchType; sl@0: extern Tcl_ObjType tclIndexType; sl@0: extern Tcl_ObjType tclNsNameType; sl@0: extern Tcl_ObjType tclWideIntType; sl@0: sl@0: /* sl@0: * Variables denoting the hash key types defined in the core. sl@0: */ sl@0: sl@0: extern Tcl_HashKeyType tclArrayHashKeyType; sl@0: extern Tcl_HashKeyType tclOneWordHashKeyType; sl@0: extern Tcl_HashKeyType tclStringHashKeyType; sl@0: extern Tcl_HashKeyType tclObjHashKeyType; sl@0: sl@0: /* sl@0: * The head of the list of free Tcl objects, and the total number of Tcl sl@0: * objects ever allocated and freed. sl@0: */ sl@0: sl@0: extern Tcl_Obj * tclFreeObjList; sl@0: sl@0: #ifdef TCL_COMPILE_STATS sl@0: extern long tclObjsAlloced; sl@0: extern long tclObjsFreed; sl@0: #define TCL_MAX_SHARED_OBJ_STATS 5 sl@0: extern long tclObjsShared[TCL_MAX_SHARED_OBJ_STATS]; sl@0: #endif /* TCL_COMPILE_STATS */ sl@0: sl@0: /* sl@0: * Pointer to a heap-allocated string of length zero that the Tcl core uses sl@0: * as the value of an empty string representation for an object. This value sl@0: * is shared by all new objects allocated by Tcl_NewObj. sl@0: */ sl@0: sl@0: extern char * tclEmptyStringRep; sl@0: extern char tclEmptyString; sl@0: sl@0: /* sl@0: *---------------------------------------------------------------- sl@0: * Procedures shared among Tcl modules but not used by the outside sl@0: * world: sl@0: *---------------------------------------------------------------- sl@0: */ sl@0: sl@0: #ifdef TCL_TIP280 sl@0: EXTERN void TclAdvanceLines _ANSI_ARGS_((int* line, CONST char* start, sl@0: CONST char* end)); sl@0: #endif sl@0: EXTERN int TclArraySet _ANSI_ARGS_((Tcl_Interp *interp, sl@0: Tcl_Obj *arrayNameObj, Tcl_Obj *arrayElemObj)); sl@0: EXTERN int TclCheckBadOctal _ANSI_ARGS_((Tcl_Interp *interp, sl@0: CONST char *value)); sl@0: EXTERN void TclDeleteNamespaceVars _ANSI_ARGS_((Namespace *nsPtr)); sl@0: sl@0: #ifdef TCL_TIP280 sl@0: EXTERN int TclEvalObjEx _ANSI_ARGS_((Tcl_Interp *interp, sl@0: register Tcl_Obj *objPtr, sl@0: int flags, sl@0: CONST CmdFrame* invoker, sl@0: int word)); sl@0: #endif sl@0: sl@0: EXTERN void TclExpandTokenArray _ANSI_ARGS_(( sl@0: Tcl_Parse *parsePtr)); sl@0: EXTERN int TclFileAttrsCmd _ANSI_ARGS_((Tcl_Interp *interp, sl@0: int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int TclFileCopyCmd _ANSI_ARGS_((Tcl_Interp *interp, sl@0: int objc, Tcl_Obj *CONST objv[])) ; sl@0: EXTERN int TclFileDeleteCmd _ANSI_ARGS_((Tcl_Interp *interp, sl@0: int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int TclFileMakeDirsCmd _ANSI_ARGS_((Tcl_Interp *interp, sl@0: int objc, Tcl_Obj *CONST objv[])) ; sl@0: EXTERN int TclFileRenameCmd _ANSI_ARGS_((Tcl_Interp *interp, sl@0: int objc, Tcl_Obj *CONST objv[])) ; sl@0: EXTERN void TclFinalizeAllocSubsystem _ANSI_ARGS_((void)); sl@0: EXTERN void TclFinalizeAsync _ANSI_ARGS_((void)); sl@0: EXTERN void TclFinalizeCompilation _ANSI_ARGS_((void)); sl@0: EXTERN void TclFinalizeEncodingSubsystem _ANSI_ARGS_((void)); sl@0: EXTERN void TclFinalizeEnvironment _ANSI_ARGS_((void)); sl@0: EXTERN void TclFinalizeExecution _ANSI_ARGS_((void)); sl@0: EXTERN void TclFinalizeIOSubsystem _ANSI_ARGS_((void)); sl@0: EXTERN void TclFinalizeFilesystem _ANSI_ARGS_((void)); sl@0: EXTERN void TclResetFilesystem _ANSI_ARGS_((void)); sl@0: EXTERN void TclFinalizeLoad _ANSI_ARGS_((void)); sl@0: EXTERN void TclFinalizeLock _ANSI_ARGS_((void)); sl@0: EXTERN void TclFinalizeMemorySubsystem _ANSI_ARGS_((void)); sl@0: EXTERN void TclFinalizeNotifier _ANSI_ARGS_((void)); sl@0: EXTERN void TclFinalizeObjects _ANSI_ARGS_((void)); sl@0: EXTERN void TclFinalizePreserve _ANSI_ARGS_((void)); sl@0: EXTERN void TclFinalizeSynchronization _ANSI_ARGS_((void)); sl@0: EXTERN void TclFinalizeThreadAlloc _ANSI_ARGS_((void)); sl@0: EXTERN void TclFinalizeThreadData _ANSI_ARGS_((void)); sl@0: EXTERN int TclGetEncodingFromObj _ANSI_ARGS_((Tcl_Interp *interp, sl@0: Tcl_Obj *objPtr, Tcl_Encoding *encodingPtr)); sl@0: #ifdef TCL_TIP280 sl@0: EXTERN void TclGetSrcInfoForPc _ANSI_ARGS_((CmdFrame* cfPtr)); sl@0: #endif sl@0: EXTERN int TclGlob _ANSI_ARGS_((Tcl_Interp *interp, sl@0: char *pattern, Tcl_Obj *unquotedPrefix, sl@0: int globFlags, Tcl_GlobTypeData* types)); sl@0: EXTERN void TclInitAlloc _ANSI_ARGS_((void)); sl@0: EXTERN void TclInitDbCkalloc _ANSI_ARGS_((void)); sl@0: EXTERN void TclInitEncodingSubsystem _ANSI_ARGS_((void)); sl@0: EXTERN void TclInitIOSubsystem _ANSI_ARGS_((void)); sl@0: EXTERN void TclInitNamespaceSubsystem _ANSI_ARGS_((void)); sl@0: EXTERN void TclInitNotifier _ANSI_ARGS_((void)); sl@0: EXTERN void TclInitObjSubsystem _ANSI_ARGS_((void)); sl@0: EXTERN void TclInitSubsystems _ANSI_ARGS_((CONST char *argv0)); sl@0: EXTERN int TclIsLocalScalar _ANSI_ARGS_((CONST char *src, sl@0: int len)); sl@0: EXTERN int TclJoinThread _ANSI_ARGS_((Tcl_ThreadId id, sl@0: int* result)); sl@0: EXTERN Tcl_Obj * TclLindexList _ANSI_ARGS_((Tcl_Interp* interp, sl@0: Tcl_Obj* listPtr, sl@0: Tcl_Obj* argPtr )); sl@0: EXTERN Tcl_Obj * TclLindexFlat _ANSI_ARGS_((Tcl_Interp* interp, sl@0: Tcl_Obj* listPtr, sl@0: int indexCount, sl@0: Tcl_Obj *CONST indexArray[] sl@0: )); sl@0: EXTERN Tcl_Obj * TclLsetList _ANSI_ARGS_((Tcl_Interp* interp, sl@0: Tcl_Obj* listPtr, sl@0: Tcl_Obj* indexPtr, sl@0: Tcl_Obj* valuePtr sl@0: )); sl@0: EXTERN Tcl_Obj * TclLsetFlat _ANSI_ARGS_((Tcl_Interp* interp, sl@0: Tcl_Obj* listPtr, sl@0: int indexCount, sl@0: Tcl_Obj *CONST indexArray[], sl@0: Tcl_Obj* valuePtr sl@0: )); sl@0: EXTERN int TclParseBackslash _ANSI_ARGS_((CONST char *src, sl@0: int numBytes, int *readPtr, char *dst)); sl@0: EXTERN int TclParseHex _ANSI_ARGS_((CONST char *src, int numBytes, sl@0: Tcl_UniChar *resultPtr)); sl@0: EXTERN int TclParseInteger _ANSI_ARGS_((CONST char *string, sl@0: int numBytes)); sl@0: EXTERN int TclParseWhiteSpace _ANSI_ARGS_((CONST char *src, sl@0: int numBytes, Tcl_Parse *parsePtr, char *typePtr)); sl@0: #ifdef TCL_TIP280 sl@0: EXTERN int TclWordKnownAtCompileTime _ANSI_ARGS_((Tcl_Token* token)); sl@0: #endif sl@0: EXTERN int TclpObjAccess _ANSI_ARGS_((Tcl_Obj *filename, sl@0: int mode)); sl@0: EXTERN int TclpObjLstat _ANSI_ARGS_((Tcl_Obj *pathPtr, sl@0: Tcl_StatBuf *buf)); sl@0: EXTERN int TclpCheckStackSpace _ANSI_ARGS_((void)); sl@0: EXTERN Tcl_Obj* TclpTempFileName _ANSI_ARGS_((void)); sl@0: EXTERN Tcl_Obj* TclNewFSPathObj _ANSI_ARGS_((Tcl_Obj *dirPtr, sl@0: CONST char *addStrRep, int len)); sl@0: EXTERN int TclpDeleteFile _ANSI_ARGS_((CONST char *path)); sl@0: EXTERN void TclpFinalizeCondition _ANSI_ARGS_(( sl@0: Tcl_Condition *condPtr)); sl@0: EXTERN void TclpFinalizeMutex _ANSI_ARGS_((Tcl_Mutex *mutexPtr)); sl@0: EXTERN void TclpFinalizePipes _ANSI_ARGS_((void)); sl@0: EXTERN void TclpFinalizeSockets _ANSI_ARGS_((void)); sl@0: EXTERN void TclpFinalizeThreadData _ANSI_ARGS_(( sl@0: Tcl_ThreadDataKey *keyPtr)); sl@0: EXTERN void TclpFinalizeThreadDataKey _ANSI_ARGS_(( sl@0: Tcl_ThreadDataKey *keyPtr)); sl@0: EXTERN char * TclpFindExecutable _ANSI_ARGS_(( sl@0: CONST char *argv0)); sl@0: EXTERN int TclpFindVariable _ANSI_ARGS_((CONST char *name, sl@0: int *lengthPtr)); sl@0: EXTERN int TclpInitLibraryPath _ANSI_ARGS_((CONST char *argv0)); sl@0: EXTERN void TclpInitLock _ANSI_ARGS_((void)); sl@0: EXTERN void TclpInitPlatform _ANSI_ARGS_((void)); sl@0: EXTERN void TclpInitUnlock _ANSI_ARGS_((void)); sl@0: EXTERN int TclpLoadFile _ANSI_ARGS_((Tcl_Interp *interp, sl@0: Tcl_Obj *pathPtr, sl@0: CONST char *sym1, CONST char *sym2, sl@0: Tcl_PackageInitProc **proc1Ptr, sl@0: Tcl_PackageInitProc **proc2Ptr, sl@0: ClientData *clientDataPtr, sl@0: Tcl_FSUnloadFileProc **unloadProcPtr)); sl@0: EXTERN Tcl_Obj* TclpObjListVolumes _ANSI_ARGS_((void)); sl@0: EXTERN void TclpMasterLock _ANSI_ARGS_((void)); sl@0: EXTERN void TclpMasterUnlock _ANSI_ARGS_((void)); sl@0: EXTERN int TclpMatchFiles _ANSI_ARGS_((Tcl_Interp *interp, sl@0: char *separators, Tcl_DString *dirPtr, sl@0: char *pattern, char *tail)); sl@0: EXTERN int TclpObjNormalizePath _ANSI_ARGS_((Tcl_Interp *interp, sl@0: Tcl_Obj *pathPtr, int nextCheckpoint)); sl@0: EXTERN int TclpObjCreateDirectory _ANSI_ARGS_((Tcl_Obj *pathPtr)); sl@0: EXTERN void TclpNativeJoinPath _ANSI_ARGS_((Tcl_Obj *prefix, sl@0: char *joining)); sl@0: EXTERN Tcl_Obj* TclpNativeSplitPath _ANSI_ARGS_((Tcl_Obj *pathPtr, sl@0: int *lenPtr)); sl@0: EXTERN Tcl_PathType TclpGetNativePathType _ANSI_ARGS_((Tcl_Obj *pathObjPtr, sl@0: int *driveNameLengthPtr, Tcl_Obj **driveNameRef)); sl@0: EXTERN int TclCrossFilesystemCopy _ANSI_ARGS_((Tcl_Interp *interp, sl@0: Tcl_Obj *source, Tcl_Obj *target)); sl@0: EXTERN int TclpObjDeleteFile _ANSI_ARGS_((Tcl_Obj *pathPtr)); sl@0: EXTERN int TclpObjCopyDirectory _ANSI_ARGS_((Tcl_Obj *srcPathPtr, sl@0: Tcl_Obj *destPathPtr, Tcl_Obj **errorPtr)); sl@0: EXTERN int TclpObjCopyFile _ANSI_ARGS_((Tcl_Obj *srcPathPtr, sl@0: Tcl_Obj *destPathPtr)); sl@0: EXTERN int TclpObjRemoveDirectory _ANSI_ARGS_((Tcl_Obj *pathPtr, sl@0: int recursive, Tcl_Obj **errorPtr)); sl@0: EXTERN int TclpObjRenameFile _ANSI_ARGS_((Tcl_Obj *srcPathPtr, sl@0: Tcl_Obj *destPathPtr)); sl@0: EXTERN int TclpMatchInDirectory _ANSI_ARGS_((Tcl_Interp *interp, sl@0: Tcl_Obj *resultPtr, Tcl_Obj *pathPtr, sl@0: CONST char *pattern, Tcl_GlobTypeData *types)); sl@0: EXTERN Tcl_Obj* TclpObjGetCwd _ANSI_ARGS_((Tcl_Interp *interp)); sl@0: EXTERN Tcl_FSDupInternalRepProc TclNativeDupInternalRep; sl@0: EXTERN Tcl_Obj* TclpObjLink _ANSI_ARGS_((Tcl_Obj *pathPtr, sl@0: Tcl_Obj *toPtr, int linkType)); sl@0: EXTERN int TclpObjChdir _ANSI_ARGS_((Tcl_Obj *pathPtr)); sl@0: EXTERN Tcl_Obj* TclFileDirname _ANSI_ARGS_((Tcl_Interp *interp, sl@0: Tcl_Obj*pathPtr)); sl@0: EXTERN int TclpObjStat _ANSI_ARGS_((Tcl_Obj *pathPtr, Tcl_StatBuf *buf)); sl@0: EXTERN Tcl_Channel TclpOpenFileChannel _ANSI_ARGS_((Tcl_Interp *interp, sl@0: Tcl_Obj *pathPtr, int mode, sl@0: int permissions)); sl@0: EXTERN void TclpPanic _ANSI_ARGS_(TCL_VARARGS(CONST char *, sl@0: format)); sl@0: EXTERN char * TclpReadlink _ANSI_ARGS_((CONST char *fileName, sl@0: Tcl_DString *linkPtr)); sl@0: EXTERN void TclpReleaseFile _ANSI_ARGS_((TclFile file)); sl@0: EXTERN void TclpSetVariables _ANSI_ARGS_((Tcl_Interp *interp)); sl@0: EXTERN void TclpUnloadFile _ANSI_ARGS_((Tcl_LoadHandle loadHandle)); sl@0: EXTERN VOID * TclpThreadDataKeyGet _ANSI_ARGS_(( sl@0: Tcl_ThreadDataKey *keyPtr)); sl@0: EXTERN void TclpThreadDataKeyInit _ANSI_ARGS_(( sl@0: Tcl_ThreadDataKey *keyPtr)); sl@0: EXTERN void TclpThreadDataKeySet _ANSI_ARGS_(( sl@0: Tcl_ThreadDataKey *keyPtr, VOID *data)); sl@0: EXTERN int TclpThreadCreate _ANSI_ARGS_(( sl@0: Tcl_ThreadId *idPtr, sl@0: Tcl_ThreadCreateProc proc, sl@0: ClientData clientData, sl@0: int stackSize, int flags)); sl@0: EXTERN void TclpThreadExit _ANSI_ARGS_((int status)); sl@0: EXTERN void TclRememberCondition _ANSI_ARGS_((Tcl_Condition *mutex)); sl@0: EXTERN void TclRememberDataKey _ANSI_ARGS_((Tcl_ThreadDataKey *mutex)); sl@0: EXTERN VOID TclRememberJoinableThread _ANSI_ARGS_((Tcl_ThreadId id)); sl@0: EXTERN void TclRememberMutex _ANSI_ARGS_((Tcl_Mutex *mutex)); sl@0: EXTERN VOID TclSignalExitThread _ANSI_ARGS_((Tcl_ThreadId id, sl@0: int result)); sl@0: EXTERN void TclTransferResult _ANSI_ARGS_((Tcl_Interp *sourceInterp, sl@0: int result, Tcl_Interp *targetInterp)); sl@0: EXTERN Tcl_Obj* TclpNativeToNormalized sl@0: _ANSI_ARGS_((ClientData clientData)); sl@0: EXTERN Tcl_Obj* TclpFilesystemPathType sl@0: _ANSI_ARGS_((Tcl_Obj* pathObjPtr)); sl@0: EXTERN Tcl_PackageInitProc* TclpFindSymbol _ANSI_ARGS_((Tcl_Interp *interp, sl@0: Tcl_LoadHandle loadHandle, CONST char *symbol)); sl@0: EXTERN int TclpDlopen _ANSI_ARGS_((Tcl_Interp *interp, sl@0: Tcl_Obj *pathPtr, sl@0: Tcl_LoadHandle *loadHandle, sl@0: Tcl_FSUnloadFileProc **unloadProcPtr)); sl@0: EXTERN int TclpUtime _ANSI_ARGS_((Tcl_Obj *pathPtr, sl@0: struct utimbuf *tval)); sl@0: sl@0: #ifdef TCL_LOAD_FROM_MEMORY sl@0: EXTERN void* TclpLoadMemoryGetBuffer _ANSI_ARGS_(( sl@0: Tcl_Interp *interp, int size)); sl@0: EXTERN int TclpLoadMemory _ANSI_ARGS_((Tcl_Interp *interp, sl@0: void *buffer, int size, int codeSize, sl@0: Tcl_LoadHandle *loadHandle, sl@0: Tcl_FSUnloadFileProc **unloadProcPtr)); sl@0: #endif sl@0: sl@0: #ifdef __SYMBIAN32__ sl@0: EXTERN int SetupStdFile _ANSI_ARGS_((TclFile file, int type)); sl@0: #endif sl@0: /* sl@0: *---------------------------------------------------------------- sl@0: * Command procedures in the generic core: sl@0: *---------------------------------------------------------------- sl@0: */ sl@0: sl@0: EXTERN int Tcl_AfterObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_AppendObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_ArrayObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_BinaryObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_BreakObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_CaseObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_CatchObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_CdObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_ClockObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_CloseObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_ConcatObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_ContinueObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_EncodingObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_EofObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_ErrorObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_EvalObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_ExecObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_ExitObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_ExprObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_FblockedObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_FconfigureObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_FcopyObjCmd _ANSI_ARGS_((ClientData dummy, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_FileObjCmd _ANSI_ARGS_((ClientData dummy, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_FileEventObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_FlushObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_ForObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_ForeachObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_FormatObjCmd _ANSI_ARGS_((ClientData dummy, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_GetsObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_GlobalObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_GlobObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_IfObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_IncrObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_InfoObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_InterpObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int argc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_JoinObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_LappendObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_LindexObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_LinsertObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_LlengthObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_ListObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_LoadObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_LrangeObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_LreplaceObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_LsearchObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_LsetObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp* interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_LsortObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_NamespaceObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_OpenObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_PackageObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_PidObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_PutsObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_PwdObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_ReadObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_RegexpObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_RegsubObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_RenameObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_ReturnObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_ScanObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_SeekObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_SetObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_SplitObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_SocketObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_SourceObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_StringObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_SubstObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_SwitchObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_TellObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_TimeObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_TraceObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_UnsetObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_UpdateObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_UplevelObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_UpvarObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_VariableObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_VwaitObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_WhileObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: sl@0: /* sl@0: *---------------------------------------------------------------- sl@0: * Command procedures found only in the Mac version of the core: sl@0: *---------------------------------------------------------------- sl@0: */ sl@0: sl@0: #ifdef MAC_TCL sl@0: EXTERN int Tcl_EchoCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int argc, CONST84 char **argv)); sl@0: EXTERN int Tcl_LsObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_BeepObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_MacSourceObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: EXTERN int Tcl_ResourceObjCmd _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); sl@0: #endif sl@0: sl@0: /* sl@0: *---------------------------------------------------------------- sl@0: * Compilation procedures for commands in the generic core: sl@0: *---------------------------------------------------------------- sl@0: */ sl@0: sl@0: EXTERN int TclCompileAppendCmd _ANSI_ARGS_((Tcl_Interp *interp, sl@0: Tcl_Parse *parsePtr, struct CompileEnv *envPtr)); sl@0: EXTERN int TclCompileBreakCmd _ANSI_ARGS_((Tcl_Interp *interp, sl@0: Tcl_Parse *parsePtr, struct CompileEnv *envPtr)); sl@0: EXTERN int TclCompileCatchCmd _ANSI_ARGS_((Tcl_Interp *interp, sl@0: Tcl_Parse *parsePtr, struct CompileEnv *envPtr)); sl@0: EXTERN int TclCompileContinueCmd _ANSI_ARGS_((Tcl_Interp *interp, sl@0: Tcl_Parse *parsePtr, struct CompileEnv *envPtr)); sl@0: EXTERN int TclCompileExprCmd _ANSI_ARGS_((Tcl_Interp *interp, sl@0: Tcl_Parse *parsePtr, struct CompileEnv *envPtr)); sl@0: EXTERN int TclCompileForCmd _ANSI_ARGS_((Tcl_Interp *interp, sl@0: Tcl_Parse *parsePtr, struct CompileEnv *envPtr)); sl@0: EXTERN int TclCompileForeachCmd _ANSI_ARGS_((Tcl_Interp *interp, sl@0: Tcl_Parse *parsePtr, struct CompileEnv *envPtr)); sl@0: EXTERN int TclCompileIfCmd _ANSI_ARGS_((Tcl_Interp *interp, sl@0: Tcl_Parse *parsePtr, struct CompileEnv *envPtr)); sl@0: EXTERN int TclCompileIncrCmd _ANSI_ARGS_((Tcl_Interp *interp, sl@0: Tcl_Parse *parsePtr, struct CompileEnv *envPtr)); sl@0: EXTERN int TclCompileLappendCmd _ANSI_ARGS_((Tcl_Interp *interp, sl@0: Tcl_Parse *parsePtr, struct CompileEnv *envPtr)); sl@0: EXTERN int TclCompileLindexCmd _ANSI_ARGS_((Tcl_Interp *interp, sl@0: Tcl_Parse *parsePtr, struct CompileEnv *envPtr)); sl@0: EXTERN int TclCompileListCmd _ANSI_ARGS_((Tcl_Interp *interp, sl@0: Tcl_Parse *parsePtr, struct CompileEnv *envPtr)); sl@0: EXTERN int TclCompileLlengthCmd _ANSI_ARGS_((Tcl_Interp *interp, sl@0: Tcl_Parse *parsePtr, struct CompileEnv *envPtr)); sl@0: EXTERN int TclCompileLsetCmd _ANSI_ARGS_((Tcl_Interp* interp, sl@0: Tcl_Parse* parsePtr, struct CompileEnv* envPtr)); sl@0: EXTERN int TclCompileRegexpCmd _ANSI_ARGS_((Tcl_Interp* interp, sl@0: Tcl_Parse* parsePtr, struct CompileEnv* envPtr)); sl@0: EXTERN int TclCompileReturnCmd _ANSI_ARGS_((Tcl_Interp *interp, sl@0: Tcl_Parse *parsePtr, struct CompileEnv *envPtr)); sl@0: EXTERN int TclCompileSetCmd _ANSI_ARGS_((Tcl_Interp *interp, sl@0: Tcl_Parse *parsePtr, struct CompileEnv *envPtr)); sl@0: EXTERN int TclCompileStringCmd _ANSI_ARGS_((Tcl_Interp *interp, sl@0: Tcl_Parse *parsePtr, struct CompileEnv *envPtr)); sl@0: EXTERN int TclCompileWhileCmd _ANSI_ARGS_((Tcl_Interp *interp, sl@0: Tcl_Parse *parsePtr, struct CompileEnv *envPtr)); sl@0: sl@0: /* sl@0: * Functions defined in generic/tclVar.c and currenttly exported only sl@0: * for use by the bytecode compiler and engine. Some of these could later sl@0: * be placed in the public interface. sl@0: */ sl@0: sl@0: EXTERN Var * TclLookupArrayElement _ANSI_ARGS_((Tcl_Interp *interp, sl@0: CONST char *arrayName, CONST char *elName, CONST int flags, sl@0: CONST char *msg, CONST int createPart1, sl@0: CONST int createPart2, Var *arrayPtr)); sl@0: EXTERN Var * TclObjLookupVar _ANSI_ARGS_((Tcl_Interp *interp, sl@0: Tcl_Obj *part1Ptr, CONST char *part2, int flags, sl@0: CONST char *msg, CONST int createPart1, sl@0: CONST int createPart2, Var **arrayPtrPtr)); sl@0: EXTERN Tcl_Obj *TclPtrGetVar _ANSI_ARGS_((Tcl_Interp *interp, Var *varPtr, sl@0: Var *arrayPtr, CONST char *part1, CONST char *part2, sl@0: CONST int flags)); sl@0: EXTERN Tcl_Obj *TclPtrSetVar _ANSI_ARGS_((Tcl_Interp *interp, Var *varPtr, sl@0: Var *arrayPtr, CONST char *part1, CONST char *part2, sl@0: Tcl_Obj *newValuePtr, CONST int flags)); sl@0: EXTERN Tcl_Obj *TclPtrIncrVar _ANSI_ARGS_((Tcl_Interp *interp, Var *varPtr, sl@0: Var *arrayPtr, CONST char *part1, CONST char *part2, sl@0: CONST long i, CONST int flags)); sl@0: sl@0: /* sl@0: *---------------------------------------------------------------- sl@0: * Macros used by the Tcl core to create and release Tcl objects. sl@0: * TclNewObj(objPtr) creates a new object denoting an empty string. sl@0: * TclDecrRefCount(objPtr) decrements the object's reference count, sl@0: * and frees the object if its reference count is zero. sl@0: * These macros are inline versions of Tcl_NewObj() and sl@0: * Tcl_DecrRefCount(). Notice that the names differ in not having sl@0: * a "_" after the "Tcl". Notice also that these macros reference sl@0: * their argument more than once, so you should avoid calling them sl@0: * with an expression that is expensive to compute or has sl@0: * side effects. The ANSI C "prototypes" for these macros are: sl@0: * sl@0: * EXTERN void TclNewObj _ANSI_ARGS_((Tcl_Obj *objPtr)); sl@0: * EXTERN void TclDecrRefCount _ANSI_ARGS_((Tcl_Obj *objPtr)); sl@0: * sl@0: * These macros are defined in terms of two macros that depend on sl@0: * memory allocator in use: TclAllocObjStorage, TclFreeObjStorage. sl@0: * They are defined below. sl@0: *---------------------------------------------------------------- sl@0: */ sl@0: sl@0: #ifdef TCL_COMPILE_STATS sl@0: # define TclIncrObjsAllocated() \ sl@0: tclObjsAlloced++ sl@0: # define TclIncrObjsFreed() \ sl@0: tclObjsFreed++ sl@0: #else sl@0: # define TclIncrObjsAllocated() sl@0: # define TclIncrObjsFreed() sl@0: #endif /* TCL_COMPILE_STATS */ sl@0: sl@0: #define TclNewObj(objPtr) \ sl@0: TclAllocObjStorage(objPtr); \ sl@0: TclIncrObjsAllocated(); \ sl@0: (objPtr)->refCount = 0; \ sl@0: (objPtr)->bytes = tclEmptyStringRep; \ sl@0: (objPtr)->length = 0; \ sl@0: (objPtr)->typePtr = NULL sl@0: sl@0: sl@0: #ifdef TCL_MEM_DEBUG sl@0: # define TclDecrRefCount(objPtr) \ sl@0: Tcl_DbDecrRefCount(objPtr, __FILE__, __LINE__) sl@0: #else sl@0: # define TclDecrRefCount(objPtr) \ sl@0: if (--(objPtr)->refCount <= 0) { \ sl@0: if (((objPtr)->typePtr != NULL) \ sl@0: && ((objPtr)->typePtr->freeIntRepProc != NULL)) { \ sl@0: (objPtr)->typePtr->freeIntRepProc(objPtr); \ sl@0: } \ sl@0: if (((objPtr)->bytes != NULL) \ sl@0: && ((objPtr)->bytes != tclEmptyStringRep)) { \ sl@0: ckfree((char *) (objPtr)->bytes); \ sl@0: } \ sl@0: TclFreeObjStorage(objPtr); \ sl@0: TclIncrObjsFreed(); \ sl@0: } sl@0: #endif sl@0: sl@0: #ifdef TCL_MEM_DEBUG sl@0: # define TclAllocObjStorage(objPtr) \ sl@0: (objPtr) = (Tcl_Obj *) \ sl@0: Tcl_DbCkalloc(sizeof(Tcl_Obj), __FILE__, __LINE__) sl@0: sl@0: # define TclFreeObjStorage(objPtr) \ sl@0: if ((objPtr)->refCount < -1) { \ sl@0: panic("Reference count for %lx was negative: %s line %d", \ sl@0: (objPtr), __FILE__, __LINE__); \ sl@0: } \ sl@0: ckfree((char *) (objPtr)) sl@0: sl@0: # define TclDbNewObj(objPtr, file, line) \ sl@0: (objPtr) = (Tcl_Obj *) Tcl_DbCkalloc(sizeof(Tcl_Obj), (file), (line)); \ sl@0: (objPtr)->refCount = 0; \ sl@0: (objPtr)->bytes = tclEmptyStringRep; \ sl@0: (objPtr)->length = 0; \ sl@0: (objPtr)->typePtr = NULL; \ sl@0: TclIncrObjsAllocated() sl@0: sl@0: #elif defined(PURIFY) sl@0: sl@0: /* sl@0: * The PURIFY mode is like the regular mode, but instead of doing block sl@0: * Tcl_Obj allocation and keeping a freed list for efficiency, it always sl@0: * allocates and frees a single Tcl_Obj so that tools like Purify can sl@0: * better track memory leaks sl@0: */ sl@0: sl@0: # define TclAllocObjStorage(objPtr) \ sl@0: (objPtr) = (Tcl_Obj *) Tcl_Ckalloc(sizeof(Tcl_Obj)) sl@0: sl@0: # define TclFreeObjStorage(objPtr) \ sl@0: ckfree((char *) (objPtr)) sl@0: sl@0: #elif defined(TCL_THREADS) && defined(USE_THREAD_ALLOC) sl@0: sl@0: /* sl@0: * The TCL_THREADS mode is like the regular mode but allocates Tcl_Obj's sl@0: * from per-thread caches. sl@0: */ sl@0: sl@0: EXTERN Tcl_Obj *TclThreadAllocObj _ANSI_ARGS_((void)); sl@0: EXTERN void TclThreadFreeObj _ANSI_ARGS_((Tcl_Obj *)); sl@0: EXTERN void TclFreeAllocCache _ANSI_ARGS_((void *)); sl@0: EXTERN void TclpFreeAllocMutex _ANSI_ARGS_((Tcl_Mutex* mutex)); sl@0: EXTERN void TclpFreeAllocCache _ANSI_ARGS_((void *)); sl@0: sl@0: sl@0: # define TclAllocObjStorage(objPtr) \ sl@0: (objPtr) = TclThreadAllocObj() sl@0: sl@0: # define TclFreeObjStorage(objPtr) \ sl@0: TclThreadFreeObj((objPtr)) sl@0: sl@0: #else /* not TCL_MEM_DEBUG */ sl@0: sl@0: #ifdef TCL_THREADS sl@0: /* declared in tclObj.c */ sl@0: extern Tcl_Mutex tclObjMutex; sl@0: #endif sl@0: sl@0: # define TclAllocObjStorage(objPtr) \ sl@0: Tcl_MutexLock(&tclObjMutex); \ sl@0: if (tclFreeObjList == NULL) { \ sl@0: TclAllocateFreeObjects(); \ sl@0: } \ sl@0: (objPtr) = tclFreeObjList; \ sl@0: tclFreeObjList = (Tcl_Obj *) \ sl@0: tclFreeObjList->internalRep.otherValuePtr; \ sl@0: Tcl_MutexUnlock(&tclObjMutex) sl@0: sl@0: # define TclFreeObjStorage(objPtr) \ sl@0: Tcl_MutexLock(&tclObjMutex); \ sl@0: (objPtr)->internalRep.otherValuePtr = (VOID *) tclFreeObjList; \ sl@0: tclFreeObjList = (objPtr); \ sl@0: Tcl_MutexUnlock(&tclObjMutex) sl@0: sl@0: #endif /* TCL_MEM_DEBUG */ sl@0: sl@0: /* sl@0: *---------------------------------------------------------------- sl@0: * Macro used by the Tcl core to set a Tcl_Obj's string representation sl@0: * to a copy of the "len" bytes starting at "bytePtr". This code sl@0: * works even if the byte array contains NULLs as long as the length sl@0: * is correct. Because "len" is referenced multiple times, it should sl@0: * be as simple an expression as possible. The ANSI C "prototype" for sl@0: * this macro is: sl@0: * sl@0: * EXTERN void TclInitStringRep _ANSI_ARGS_((Tcl_Obj *objPtr, sl@0: * char *bytePtr, int len)); sl@0: *---------------------------------------------------------------- sl@0: */ sl@0: sl@0: #define TclInitStringRep(objPtr, bytePtr, len) \ sl@0: if ((len) == 0) { \ sl@0: (objPtr)->bytes = tclEmptyStringRep; \ sl@0: (objPtr)->length = 0; \ sl@0: } else { \ sl@0: (objPtr)->bytes = (char *) ckalloc((unsigned) ((len) + 1)); \ sl@0: memcpy((VOID *) (objPtr)->bytes, (VOID *) (bytePtr), \ sl@0: (unsigned) (len)); \ sl@0: (objPtr)->bytes[len] = '\0'; \ sl@0: (objPtr)->length = (len); \ sl@0: } sl@0: sl@0: /* sl@0: *---------------------------------------------------------------- sl@0: * Macro used by the Tcl core to get the string representation's sl@0: * byte array pointer from a Tcl_Obj. This is an inline version sl@0: * of Tcl_GetString(). The macro's expression result is the string sl@0: * rep's byte pointer which might be NULL. The bytes referenced by sl@0: * this pointer must not be modified by the caller. sl@0: * The ANSI C "prototype" for this macro is: sl@0: * sl@0: * EXTERN char * TclGetString _ANSI_ARGS_((Tcl_Obj *objPtr)); sl@0: *---------------------------------------------------------------- sl@0: */ sl@0: sl@0: #define TclGetString(objPtr) \ sl@0: ((objPtr)->bytes? (objPtr)->bytes : Tcl_GetString((objPtr))) sl@0: sl@0: /* sl@0: *---------------------------------------------------------------- sl@0: * Macro used by the Tcl core to get a Tcl_WideInt value out of sl@0: * a Tcl_Obj of the "wideInt" type. Different implementation on sl@0: * different platforms depending whether TCL_WIDE_INT_IS_LONG. sl@0: *---------------------------------------------------------------- sl@0: */ sl@0: sl@0: #ifdef TCL_WIDE_INT_IS_LONG sl@0: # define TclGetWide(resultVar, objPtr) \ sl@0: (resultVar) = (objPtr)->internalRep.longValue sl@0: # define TclGetLongFromWide(resultVar, objPtr) \ sl@0: (resultVar) = (objPtr)->internalRep.longValue sl@0: #else sl@0: # define TclGetWide(resultVar, objPtr) \ sl@0: (resultVar) = (objPtr)->internalRep.wideValue sl@0: # define TclGetLongFromWide(resultVar, objPtr) \ sl@0: (resultVar) = Tcl_WideAsLong((objPtr)->internalRep.wideValue) sl@0: #endif sl@0: sl@0: /* sl@0: *---------------------------------------------------------------- sl@0: * Macro used by the Tcl core get a unicode char from a utf string. sl@0: * It checks to see if we have a one-byte utf char before calling sl@0: * the real Tcl_UtfToUniChar, as this will save a lot of time for sl@0: * primarily ascii string handling. The macro's expression result sl@0: * is 1 for the 1-byte case or the result of Tcl_UtfToUniChar. sl@0: * The ANSI C "prototype" for this macro is: sl@0: * sl@0: * EXTERN int TclUtfToUniChar _ANSI_ARGS_((CONST char *string, sl@0: * Tcl_UniChar *ch)); sl@0: *---------------------------------------------------------------- sl@0: */ sl@0: sl@0: #define TclUtfToUniChar(str, chPtr) \ sl@0: ((((unsigned char) *(str)) < 0xC0) ? \ sl@0: ((*(chPtr) = (Tcl_UniChar) *(str)), 1) \ sl@0: : Tcl_UtfToUniChar(str, chPtr)) sl@0: sl@0: /* sl@0: *---------------------------------------------------------------- sl@0: * Macro used by the Tcl core to compare Unicode strings. On sl@0: * big-endian systems we can use the more efficient memcmp, but sl@0: * this would not be lexically correct on little-endian systems. sl@0: * The ANSI C "prototype" for this macro is: sl@0: * sl@0: * EXTERN int TclUniCharNcmp _ANSI_ARGS_((CONST Tcl_UniChar *cs, sl@0: * CONST Tcl_UniChar *ct, unsigned long n)); sl@0: *---------------------------------------------------------------- sl@0: */ sl@0: #ifdef WORDS_BIGENDIAN sl@0: # define TclUniCharNcmp(cs,ct,n) memcmp((cs),(ct),(n)*sizeof(Tcl_UniChar)) sl@0: #else /* !WORDS_BIGENDIAN */ sl@0: # define TclUniCharNcmp Tcl_UniCharNcmp sl@0: #endif /* WORDS_BIGENDIAN */ sl@0: sl@0: #ifdef __SYMBIAN32__ sl@0: /* sl@0: * Struct to keep records of synchronization objects (used in tclThread.c) sl@0: */ sl@0: typedef struct SyncObjRecord { sl@0: int num; /* Number of objects remembered */ sl@0: int max; /* Max size of the array */ sl@0: char **list; /* List of pointers */ sl@0: } SyncObjRecord; sl@0: #endif sl@0: sl@0: #include "tclIntDecls.h" sl@0: sl@0: # undef TCL_STORAGE_CLASS sl@0: # define TCL_STORAGE_CLASS DLLIMPORT sl@0: sl@0: #endif /* _TCLINT */ sl@0: