tclInt.h

Go to the documentation of this file.
00001 /*
00002  * tclInt.h --
00003  *
00004  *      Declarations of things used internally by the Tcl interpreter.
00005  *
00006  * Copyright (c) 1987-1993 The Regents of the University of California.
00007  * Copyright (c) 1993-1997 Lucent Technologies.
00008  * Copyright (c) 1994-1998 Sun Microsystems, Inc.
00009  * Copyright (c) 1998-1999 by Scriptics Corporation.
00010  *
00011  * See the file "license.terms" for information on usage and redistribution
00012  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
00013  *
00014  * RCS: @(#) $Id: tclInt.h,v 1.3 2003/02/14 23:02:11 fmk Exp $
00015  */
00016 
00017 #ifndef _TCLINT
00018 #define _TCLINT
00019 
00020 /*
00021  * Common include files needed by most of the Tcl source files are
00022  * included here, so that system-dependent personalizations for the
00023  * include files only have to be made in once place.  This results
00024  * in a few extra includes, but greater modularity.  The order of
00025  * the three groups of #includes is important.  For example, stdio.h
00026  * is needed by tcl.h, and the _ANSI_ARGS_ declaration in tcl.h is
00027  * needed by stdlib.h in some configurations.
00028  */
00029 
00030 #include <stdio.h>
00031 
00032 #ifndef _TCL
00033 #include "tcl.h"
00034 #endif
00035 
00036 #include <ctype.h>
00037 #ifdef NO_LIMITS_H
00038 #   include "../compat/limits.h"
00039 #else
00040 #   include <limits.h>
00041 #endif
00042 #ifdef NO_STDLIB_H
00043 #   include "../compat/stdlib.h"
00044 #else
00045 #   include <stdlib.h>
00046 #endif
00047 #ifdef NO_STRING_H
00048 #include "../compat/string.h"
00049 #else
00050 #include <string.h>
00051 #endif
00052 
00053 #undef TCL_STORAGE_CLASS
00054 #ifdef BUILD_tcl
00055 # define TCL_STORAGE_CLASS DLLEXPORT
00056 #else
00057 # ifdef USE_TCL_STUBS
00058 #  define TCL_STORAGE_CLASS
00059 # else
00060 #  define TCL_STORAGE_CLASS DLLIMPORT
00061 # endif
00062 #endif
00063 
00064 /*
00065  * The following procedures allow namespaces to be customized to
00066  * support special name resolution rules for commands/variables.
00067  * 
00068  */
00069 
00070 struct Tcl_ResolvedVarInfo;
00071 
00072 typedef Tcl_Var (Tcl_ResolveRuntimeVarProc) _ANSI_ARGS_((
00073     Tcl_Interp* interp, struct Tcl_ResolvedVarInfo *vinfoPtr));
00074 
00075 typedef void (Tcl_ResolveVarDeleteProc) _ANSI_ARGS_((
00076     struct Tcl_ResolvedVarInfo *vinfoPtr));
00077 
00078 /*
00079  * The following structure encapsulates the routines needed to resolve a
00080  * variable reference at runtime.  Any variable specific state will typically
00081  * be appended to this structure.
00082  */
00083 
00084 
00085 typedef struct Tcl_ResolvedVarInfo {
00086     Tcl_ResolveRuntimeVarProc *fetchProc;
00087     Tcl_ResolveVarDeleteProc *deleteProc;
00088 } Tcl_ResolvedVarInfo;
00089 
00090 
00091 
00092 typedef int (Tcl_ResolveCompiledVarProc) _ANSI_ARGS_((
00093     Tcl_Interp* interp, char* name, int length,
00094     Tcl_Namespace *context, Tcl_ResolvedVarInfo **rPtr));
00095 
00096 typedef int (Tcl_ResolveVarProc) _ANSI_ARGS_((
00097     Tcl_Interp* interp, char* name, Tcl_Namespace *context,
00098     int flags, Tcl_Var *rPtr));
00099 
00100 typedef int (Tcl_ResolveCmdProc) _ANSI_ARGS_((Tcl_Interp* interp,
00101     char* name, Tcl_Namespace *context, int flags,
00102     Tcl_Command *rPtr));
00103  
00104 typedef struct Tcl_ResolverInfo {
00105     Tcl_ResolveCmdProc *cmdResProc;     /* Procedure handling command name
00106                                          * resolution. */
00107     Tcl_ResolveVarProc *varResProc;     /* Procedure handling variable name
00108                                          * resolution for variables that
00109                                          * can only be handled at runtime. */
00110     Tcl_ResolveCompiledVarProc *compiledVarResProc;
00111                                         /* Procedure handling variable name
00112                                          * resolution at compile time. */
00113 } Tcl_ResolverInfo;
00114 
00115 /*
00116  *----------------------------------------------------------------
00117  * Data structures related to namespaces.
00118  *----------------------------------------------------------------
00119  */
00120 
00121 /*
00122  * The structure below defines a namespace.
00123  * Note: the first five fields must match exactly the fields in a
00124  * Tcl_Namespace structure (see tcl.h). If you change one, be sure to
00125  * change the other.
00126  */
00127 
00128 typedef struct Namespace {
00129     char *name;                  /* The namespace's simple (unqualified)
00130                                   * name. This contains no ::'s. The name of
00131                                   * the global namespace is "" although "::"
00132                                   * is an synonym. */
00133     char *fullName;              /* The namespace's fully qualified name.
00134                                   * This starts with ::. */
00135     ClientData clientData;       /* An arbitrary value associated with this
00136                                   * namespace. */
00137     Tcl_NamespaceDeleteProc *deleteProc;
00138                                  /* Procedure invoked when deleting the
00139                                   * namespace to, e.g., free clientData. */
00140     struct Namespace *parentPtr; /* Points to the namespace that contains
00141                                   * this one. NULL if this is the global
00142                                   * namespace. */
00143     Tcl_HashTable childTable;    /* Contains any child namespaces. Indexed
00144                                   * by strings; values have type
00145                                   * (Namespace *). */
00146     long nsId;                   /* Unique id for the namespace. */
00147     Tcl_Interp *interp;          /* The interpreter containing this
00148                                   * namespace. */
00149     int flags;                   /* OR-ed combination of the namespace
00150                                   * status flags NS_DYING and NS_DEAD
00151                                   * listed below. */
00152     int activationCount;         /* Number of "activations" or active call
00153                                   * frames for this namespace that are on
00154                                   * the Tcl call stack. The namespace won't
00155                                   * be freed until activationCount becomes
00156                                   * zero. */
00157     int refCount;                /* Count of references by namespaceName *
00158                                   * objects. The namespace can't be freed
00159                                   * until refCount becomes zero. */
00160     Tcl_HashTable cmdTable;      /* Contains all the commands currently
00161                                   * registered in the namespace. Indexed by
00162                                   * strings; values have type (Command *).
00163                                   * Commands imported by Tcl_Import have
00164                                   * Command structures that point (via an
00165                                   * ImportedCmdRef structure) to the
00166                                   * Command structure in the source
00167                                   * namespace's command table. */
00168     Tcl_HashTable varTable;      /* Contains all the (global) variables
00169                                   * currently in this namespace. Indexed
00170                                   * by strings; values have type (Var *). */
00171     char **exportArrayPtr;       /* Points to an array of string patterns
00172                                   * specifying which commands are exported.
00173                                   * A pattern may include "string match"
00174                                   * style wildcard characters to specify
00175                                   * multiple commands; however, no namespace
00176                                   * qualifiers are allowed. NULL if no
00177                                   * export patterns are registered. */
00178     int numExportPatterns;       /* Number of export patterns currently
00179                                   * registered using "namespace export". */
00180     int maxExportPatterns;       /* Mumber of export patterns for which
00181                                   * space is currently allocated. */
00182     int cmdRefEpoch;             /* Incremented if a newly added command
00183                                   * shadows a command for which this
00184                                   * namespace has already cached a Command *
00185                                   * pointer; this causes all its cached
00186                                   * Command* pointers to be invalidated. */
00187     int resolverEpoch;           /* Incremented whenever the name resolution
00188                                   * rules change for this namespace; this
00189                                   * invalidates all byte codes compiled in
00190                                   * the namespace, causing the code to be
00191                                   * recompiled under the new rules. */
00192     Tcl_ResolveCmdProc *cmdResProc;
00193                                  /* If non-null, this procedure overrides
00194                                   * the usual command resolution mechanism
00195                                   * in Tcl.  This procedure is invoked
00196                                   * within Tcl_FindCommand to resolve all
00197                                   * command references within the namespace. */
00198     Tcl_ResolveVarProc *varResProc;
00199                                  /* If non-null, this procedure overrides
00200                                   * the usual variable resolution mechanism
00201                                   * in Tcl.  This procedure is invoked
00202                                   * within Tcl_FindNamespaceVar to resolve all
00203                                   * variable references within the namespace
00204                                   * at runtime. */
00205     Tcl_ResolveCompiledVarProc *compiledVarResProc;
00206                                  /* If non-null, this procedure overrides
00207                                   * the usual variable resolution mechanism
00208                                   * in Tcl.  This procedure is invoked
00209                                   * within LookupCompiledLocal to resolve
00210                                   * variable references within the namespace
00211                                   * at compile time. */
00212 } Namespace;
00213 
00214 /*
00215  * Flags used to represent the status of a namespace:
00216  *
00217  * NS_DYING -   1 means Tcl_DeleteNamespace has been called to delete the
00218  *              namespace but there are still active call frames on the Tcl
00219  *              stack that refer to the namespace. When the last call frame
00220  *              referring to it has been popped, it's variables and command
00221  *              will be destroyed and it will be marked "dead" (NS_DEAD).
00222  *              The namespace can no longer be looked up by name.
00223  * NS_DEAD -    1 means Tcl_DeleteNamespace has been called to delete the
00224  *              namespace and no call frames still refer to it. Its
00225  *              variables and command have already been destroyed. This bit
00226  *              allows the namespace resolution code to recognize that the
00227  *              namespace is "deleted". When the last namespaceName object
00228  *              in any byte code code unit that refers to the namespace has
00229  *              been freed (i.e., when the namespace's refCount is 0), the
00230  *              namespace's storage will be freed.
00231  */
00232 
00233 #define NS_DYING        0x01
00234 #define NS_DEAD         0x02
00235 
00236 /*
00237  * Flag passed to TclGetNamespaceForQualName to have it create all namespace
00238  * components of a namespace-qualified name that cannot be found. The new
00239  * namespaces are created within their specified parent. Note that this
00240  * flag's value must not conflict with the values of the flags
00241  * TCL_GLOBAL_ONLY, TCL_NAMESPACE_ONLY, and FIND_ONLY_NS (defined in
00242  * tclNamesp.c).
00243  */
00244 
00245 #define CREATE_NS_IF_UNKNOWN 0x800
00246 
00247 /*
00248  *----------------------------------------------------------------
00249  * Data structures related to variables.   These are used primarily
00250  * in tclVar.c
00251  *----------------------------------------------------------------
00252  */
00253 
00254 /*
00255  * The following structure defines a variable trace, which is used to
00256  * invoke a specific C procedure whenever certain operations are performed
00257  * on a variable.
00258  */
00259 
00260 typedef struct VarTrace {
00261     Tcl_VarTraceProc *traceProc;/* Procedure to call when operations given
00262                                  * by flags are performed on variable. */
00263     ClientData clientData;      /* Argument to pass to proc. */
00264     int flags;                  /* What events the trace procedure is
00265                                  * interested in:  OR-ed combination of
00266                                  * TCL_TRACE_READS, TCL_TRACE_WRITES,
00267                                  * TCL_TRACE_UNSETS and TCL_TRACE_ARRAY. */
00268     struct VarTrace *nextPtr;   /* Next in list of traces associated with
00269                                  * a particular variable. */
00270 } VarTrace;
00271 
00272 /*
00273  * When a variable trace is active (i.e. its associated procedure is
00274  * executing), one of the following structures is linked into a list
00275  * associated with the variable's interpreter.  The information in
00276  * the structure is needed in order for Tcl to behave reasonably
00277  * if traces are deleted while traces are active.
00278  */
00279 
00280 typedef struct ActiveVarTrace {
00281     struct Var *varPtr;         /* Variable that's being traced. */
00282     struct ActiveVarTrace *nextPtr;
00283                                 /* Next in list of all active variable
00284                                  * traces for the interpreter, or NULL
00285                                  * if no more. */
00286     VarTrace *nextTracePtr;     /* Next trace to check after current
00287                                  * trace procedure returns;  if this
00288                                  * trace gets deleted, must update pointer
00289                                  * to avoid using free'd memory. */
00290 } ActiveVarTrace;
00291 
00292 /*
00293  * The following structure describes an enumerative search in progress on
00294  * an array variable;  this are invoked with options to the "array"
00295  * command.
00296  */
00297 
00298 typedef struct ArraySearch {
00299     int id;                     /* Integer id used to distinguish among
00300                                  * multiple concurrent searches for the
00301                                  * same array. */
00302     struct Var *varPtr;         /* Pointer to array variable that's being
00303                                  * searched. */
00304     Tcl_HashSearch search;      /* Info kept by the hash module about
00305                                  * progress through the array. */
00306     Tcl_HashEntry *nextEntry;   /* Non-null means this is the next element
00307                                  * to be enumerated (it's leftover from
00308                                  * the Tcl_FirstHashEntry call or from
00309                                  * an "array anymore" command).  NULL
00310                                  * means must call Tcl_NextHashEntry
00311                                  * to get value to return. */
00312     struct ArraySearch *nextPtr;/* Next in list of all active searches
00313                                  * for this variable, or NULL if this is
00314                                  * the last one. */
00315 } ArraySearch;
00316 
00317 /*
00318  * The structure below defines a variable, which associates a string name
00319  * with a Tcl_Obj value. These structures are kept in procedure call frames
00320  * (for local variables recognized by the compiler) or in the heap (for
00321  * global variables and any variable not known to the compiler). For each
00322  * Var structure in the heap, a hash table entry holds the variable name and
00323  * a pointer to the Var structure.
00324  */
00325 
00326 typedef struct Var {
00327     union {
00328         Tcl_Obj *objPtr;        /* The variable's object value. Used for 
00329                                  * scalar variables and array elements. */
00330         Tcl_HashTable *tablePtr;/* For array variables, this points to
00331                                  * information about the hash table used
00332                                  * to implement the associative array. 
00333                                  * Points to malloc-ed data. */
00334         struct Var *linkPtr;    /* If this is a global variable being
00335                                  * referred to in a procedure, or a variable
00336                                  * created by "upvar", this field points to
00337                                  * the referenced variable's Var struct. */
00338     } value;
00339     char *name;                 /* NULL if the variable is in a hashtable,
00340                                  * otherwise points to the variable's
00341                                  * name. It is used, e.g., by TclLookupVar
00342                                  * and "info locals". The storage for the
00343                                  * characters of the name is not owned by
00344                                  * the Var and must not be freed when
00345                                  * freeing the Var. */
00346     Namespace *nsPtr;           /* Points to the namespace that contains
00347                                  * this variable or NULL if the variable is
00348                                  * a local variable in a Tcl procedure. */
00349     Tcl_HashEntry *hPtr;        /* If variable is in a hashtable, either the
00350                                  * hash table entry that refers to this
00351                                  * variable or NULL if the variable has been
00352                                  * detached from its hash table (e.g. an
00353                                  * array is deleted, but some of its
00354                                  * elements are still referred to in
00355                                  * upvars). NULL if the variable is not in a
00356                                  * hashtable. This is used to delete an
00357                                  * variable from its hashtable if it is no
00358                                  * longer needed. */
00359     int refCount;               /* Counts number of active uses of this
00360                                  * variable, not including its entry in the
00361                                  * call frame or the hash table: 1 for each
00362                                  * additional variable whose linkPtr points
00363                                  * here, 1 for each nested trace active on
00364                                  * variable, and 1 if the variable is a 
00365                                  * namespace variable. This record can't be
00366                                  * deleted until refCount becomes 0. */
00367     VarTrace *tracePtr;         /* First in list of all traces set for this
00368                                  * variable. */
00369     ArraySearch *searchPtr;     /* First in list of all searches active
00370                                  * for this variable, or NULL if none. */
00371     int flags;                  /* Miscellaneous bits of information about
00372                                  * variable. See below for definitions. */
00373 } Var;
00374 
00375 /*
00376  * Flag bits for variables. The first three (VAR_SCALAR, VAR_ARRAY, and
00377  * VAR_LINK) are mutually exclusive and give the "type" of the variable.
00378  * VAR_UNDEFINED is independent of the variable's type. 
00379  *
00380  * VAR_SCALAR -                 1 means this is a scalar variable and not
00381  *                              an array or link. The "objPtr" field points
00382  *                              to the variable's value, a Tcl object.
00383  * VAR_ARRAY -                  1 means this is an array variable rather
00384  *                              than a scalar variable or link. The
00385  *                              "tablePtr" field points to the array's
00386  *                              hashtable for its elements.
00387  * VAR_LINK -                   1 means this Var structure contains a
00388  *                              pointer to another Var structure that
00389  *                              either has the real value or is itself
00390  *                              another VAR_LINK pointer. Variables like
00391  *                              this come about through "upvar" and "global"
00392  *                              commands, or through references to variables
00393  *                              in enclosing namespaces.
00394  * VAR_UNDEFINED -              1 means that the variable is in the process
00395  *                              of being deleted. An undefined variable
00396  *                              logically does not exist and survives only
00397  *                              while it has a trace, or if it is a global
00398  *                              variable currently being used by some
00399  *                              procedure.
00400  * VAR_IN_HASHTABLE -           1 means this variable is in a hashtable and
00401  *                              the Var structure is malloced. 0 if it is
00402  *                              a local variable that was assigned a slot
00403  *                              in a procedure frame by the compiler so the
00404  *                              Var storage is part of the call frame.
00405  * VAR_TRACE_ACTIVE -           1 means that trace processing is currently
00406  *                              underway for a read or write access, so
00407  *                              new read or write accesses should not cause
00408  *                              trace procedures to be called and the
00409  *                              variable can't be deleted.
00410  * VAR_ARRAY_ELEMENT -          1 means that this variable is an array
00411  *                              element, so it is not legal for it to be
00412  *                              an array itself (the VAR_ARRAY flag had
00413  *                              better not be set).
00414  * VAR_NAMESPACE_VAR -          1 means that this variable was declared
00415  *                              as a namespace variable. This flag ensures
00416  *                              it persists until its namespace is
00417  *                              destroyed or until the variable is unset;
00418  *                              it will persist even if it has not been
00419  *                              initialized and is marked undefined.
00420  *                              The variable's refCount is incremented to
00421  *                              reflect the "reference" from its namespace.
00422  *
00423  * The following additional flags are used with the CompiledLocal type
00424  * defined below:
00425  *
00426  * VAR_ARGUMENT -               1 means that this variable holds a procedure
00427  *                              argument. 
00428  * VAR_TEMPORARY -              1 if the local variable is an anonymous
00429  *                              temporary variable. Temporaries have a NULL
00430  *                              name.
00431  * VAR_RESOLVED -               1 if name resolution has been done for this
00432  *                              variable.
00433  */
00434 
00435 #define VAR_SCALAR              0x1
00436 #define VAR_ARRAY               0x2
00437 #define VAR_LINK                0x4
00438 #define VAR_UNDEFINED           0x8
00439 #define VAR_IN_HASHTABLE        0x10
00440 #define VAR_TRACE_ACTIVE        0x20
00441 #define VAR_ARRAY_ELEMENT       0x40
00442 #define VAR_NAMESPACE_VAR       0x80
00443 
00444 #define VAR_ARGUMENT            0x100
00445 #define VAR_TEMPORARY           0x200
00446 #define VAR_RESOLVED            0x400   
00447 
00448 /*
00449  * Macros to ensure that various flag bits are set properly for variables.
00450  * The ANSI C "prototypes" for these macros are:
00451  *
00452  * EXTERN void  TclSetVarScalar _ANSI_ARGS_((Var *varPtr));
00453  * EXTERN void  TclSetVarArray _ANSI_ARGS_((Var *varPtr));
00454  * EXTERN void  TclSetVarLink _ANSI_ARGS_((Var *varPtr));
00455  * EXTERN void  TclSetVarArrayElement _ANSI_ARGS_((Var *varPtr));
00456  * EXTERN void  TclSetVarUndefined _ANSI_ARGS_((Var *varPtr));
00457  * EXTERN void  TclClearVarUndefined _ANSI_ARGS_((Var *varPtr));
00458  */
00459 
00460 #define TclSetVarScalar(varPtr) \
00461     (varPtr)->flags = ((varPtr)->flags & ~(VAR_ARRAY|VAR_LINK)) | VAR_SCALAR
00462 
00463 #define TclSetVarArray(varPtr) \
00464     (varPtr)->flags = ((varPtr)->flags & ~(VAR_SCALAR|VAR_LINK)) | VAR_ARRAY
00465 
00466 #define TclSetVarLink(varPtr) \
00467     (varPtr)->flags = ((varPtr)->flags & ~(VAR_SCALAR|VAR_ARRAY)) | VAR_LINK
00468 
00469 #define TclSetVarArrayElement(varPtr) \
00470     (varPtr)->flags = ((varPtr)->flags & ~VAR_ARRAY) | VAR_ARRAY_ELEMENT
00471 
00472 #define TclSetVarUndefined(varPtr) \
00473     (varPtr)->flags |= VAR_UNDEFINED
00474 
00475 #define TclClearVarUndefined(varPtr) \
00476     (varPtr)->flags &= ~VAR_UNDEFINED
00477 
00478 /*
00479  * Macros to read various flag bits of variables.
00480  * The ANSI C "prototypes" for these macros are:
00481  *
00482  * EXTERN int   TclIsVarScalar _ANSI_ARGS_((Var *varPtr));
00483  * EXTERN int   TclIsVarLink _ANSI_ARGS_((Var *varPtr));
00484  * EXTERN int   TclIsVarArray _ANSI_ARGS_((Var *varPtr));
00485  * EXTERN int   TclIsVarUndefined _ANSI_ARGS_((Var *varPtr));
00486  * EXTERN int   TclIsVarArrayElement _ANSI_ARGS_((Var *varPtr));
00487  * EXTERN int   TclIsVarTemporary _ANSI_ARGS_((Var *varPtr));
00488  * EXTERN int   TclIsVarArgument _ANSI_ARGS_((Var *varPtr));
00489  * EXTERN int   TclIsVarResolved _ANSI_ARGS_((Var *varPtr));
00490  */
00491     
00492 #define TclIsVarScalar(varPtr) \
00493     ((varPtr)->flags & VAR_SCALAR)
00494 
00495 #define TclIsVarLink(varPtr) \
00496     ((varPtr)->flags & VAR_LINK)
00497 
00498 #define TclIsVarArray(varPtr) \
00499     ((varPtr)->flags & VAR_ARRAY)
00500 
00501 #define TclIsVarUndefined(varPtr) \
00502     ((varPtr)->flags & VAR_UNDEFINED)
00503 
00504 #define TclIsVarArrayElement(varPtr) \
00505     ((varPtr)->flags & VAR_ARRAY_ELEMENT)
00506 
00507 #define TclIsVarTemporary(varPtr) \
00508     ((varPtr)->flags & VAR_TEMPORARY)
00509     
00510 #define TclIsVarArgument(varPtr) \
00511     ((varPtr)->flags & VAR_ARGUMENT)
00512     
00513 #define TclIsVarResolved(varPtr) \
00514     ((varPtr)->flags & VAR_RESOLVED)
00515 
00516 /*
00517  *----------------------------------------------------------------
00518  * Data structures related to procedures.  These are used primarily
00519  * in tclProc.c, tclCompile.c, and tclExecute.c.
00520  *----------------------------------------------------------------
00521  */
00522 
00523 /*
00524  * Forward declaration to prevent an error when the forward reference to
00525  * Command is encountered in the Proc and ImportRef types declared below.
00526  */
00527 
00528 struct Command;
00529 
00530 /*
00531  * The variable-length structure below describes a local variable of a
00532  * procedure that was recognized by the compiler. These variables have a
00533  * name, an element in the array of compiler-assigned local variables in the
00534  * procedure's call frame, and various other items of information. If the
00535  * local variable is a formal argument, it may also have a default value.
00536  * The compiler can't recognize local variables whose names are
00537  * expressions (these names are only known at runtime when the expressions
00538  * are evaluated) or local variables that are created as a result of an
00539  * "upvar" or "uplevel" command. These other local variables are kept
00540  * separately in a hash table in the call frame.
00541  */
00542 
00543 typedef struct CompiledLocal {
00544     struct CompiledLocal *nextPtr;
00545                                 /* Next compiler-recognized local variable
00546                                  * for this procedure, or NULL if this is
00547                                  * the last local. */
00548     int nameLength;             /* The number of characters in local
00549                                  * variable's name. Used to speed up
00550                                  * variable lookups. */
00551     int frameIndex;             /* Index in the array of compiler-assigned
00552                                  * variables in the procedure call frame. */
00553     int flags;                  /* Flag bits for the local variable. Same as
00554                                  * the flags for the Var structure above,
00555                                  * although only VAR_SCALAR, VAR_ARRAY, 
00556                                  * VAR_LINK, VAR_ARGUMENT, VAR_TEMPORARY, and
00557                                  * VAR_RESOLVED make sense. */
00558     Tcl_Obj *defValuePtr;       /* Pointer to the default value of an
00559                                  * argument, if any. NULL if not an argument
00560                                  * or, if an argument, no default value. */
00561     Tcl_ResolvedVarInfo *resolveInfo;
00562                                 /* Customized variable resolution info
00563                                  * supplied by the Tcl_ResolveCompiledVarProc
00564                                  * associated with a namespace. Each variable
00565                                  * is marked by a unique ClientData tag
00566                                  * during compilation, and that same tag
00567                                  * is used to find the variable at runtime. */
00568     char name[4];               /* Name of the local variable starts here.
00569                                  * If the name is NULL, this will just be
00570                                  * '\0'. The actual size of this field will
00571                                  * be large enough to hold the name. MUST
00572                                  * BE THE LAST FIELD IN THE STRUCTURE! */
00573 } CompiledLocal;
00574 
00575 /*
00576  * The structure below defines a command procedure, which consists of a
00577  * collection of Tcl commands plus information about arguments and other
00578  * local variables recognized at compile time.
00579  */
00580 
00581 typedef struct Proc {
00582     struct Interp *iPtr;          /* Interpreter for which this command
00583                                    * is defined. */
00584     int refCount;                 /* Reference count: 1 if still present
00585                                    * in command table plus 1 for each call
00586                                    * to the procedure that is currently
00587                                    * active. This structure can be freed
00588                                    * when refCount becomes zero. */
00589     struct Command *cmdPtr;       /* Points to the Command structure for
00590                                    * this procedure. This is used to get
00591                                    * the namespace in which to execute
00592                                    * the procedure. */
00593     Tcl_Obj *bodyPtr;             /* Points to the ByteCode object for
00594                                    * procedure's body command. */
00595     int numArgs;                  /* Number of formal parameters. */
00596     int numCompiledLocals;        /* Count of local variables recognized by
00597                                    * the compiler including arguments and
00598                                    * temporaries. */
00599     CompiledLocal *firstLocalPtr; /* Pointer to first of the procedure's
00600                                    * compiler-allocated local variables, or
00601                                    * NULL if none. The first numArgs entries
00602                                    * in this list describe the procedure's
00603                                    * formal arguments. */
00604     CompiledLocal *lastLocalPtr;  /* Pointer to the last allocated local
00605                                    * variable or NULL if none. This has
00606                                    * frame index (numCompiledLocals-1). */
00607 } Proc;
00608 
00609 /*
00610  * The structure below defines a command trace.  This is used to allow Tcl
00611  * clients to find out whenever a command is about to be executed.
00612  */
00613 
00614 typedef struct Trace {
00615     int level;                  /* Only trace commands at nesting level
00616                                  * less than or equal to this. */
00617     Tcl_CmdTraceProc *proc;     /* Procedure to call to trace command. */
00618     ClientData clientData;      /* Arbitrary value to pass to proc. */
00619     struct Trace *nextPtr;      /* Next in list of traces for this interp. */
00620 } Trace;
00621 
00622 /*
00623  * The structure below defines an entry in the assocData hash table which
00624  * is associated with an interpreter. The entry contains a pointer to a
00625  * function to call when the interpreter is deleted, and a pointer to
00626  * a user-defined piece of data.
00627  */
00628 
00629 typedef struct AssocData {
00630     Tcl_InterpDeleteProc *proc; /* Proc to call when deleting. */
00631     ClientData clientData;      /* Value to pass to proc. */
00632 } AssocData;    
00633 
00634 /*
00635  * The structure below defines a call frame. A call frame defines a naming
00636  * context for a procedure call: its local naming scope (for local
00637  * variables) and its global naming scope (a namespace, perhaps the global
00638  * :: namespace). A call frame can also define the naming context for a
00639  * namespace eval or namespace inscope command: the namespace in which the
00640  * command's code should execute. The Tcl_CallFrame structures exist only
00641  * while procedures or namespace eval/inscope's are being executed, and
00642  * provide a kind of Tcl call stack.
00643  * 
00644  * WARNING!! The structure definition must be kept consistent with the
00645  * Tcl_CallFrame structure in tcl.h. If you change one, change the other.
00646  */
00647 
00648 typedef struct CallFrame {
00649     Namespace *nsPtr;           /* Points to the namespace used to resolve
00650                                  * commands and global variables. */
00651     int isProcCallFrame;        /* If nonzero, the frame was pushed to
00652                                  * execute a Tcl procedure and may have
00653                                  * local vars. If 0, the frame was pushed
00654                                  * to execute a namespace command and var
00655                                  * references are treated as references to
00656                                  * namespace vars; varTablePtr and
00657                                  * compiledLocals are ignored. */
00658     int objc;                   /* This and objv below describe the
00659                                  * arguments for this procedure call. */
00660     Tcl_Obj *CONST *objv;       /* Array of argument objects. */
00661     struct CallFrame *callerPtr;
00662                                 /* Value of interp->framePtr when this
00663                                  * procedure was invoked (i.e. next higher
00664                                  * in stack of all active procedures). */
00665     struct CallFrame *callerVarPtr;
00666                                 /* Value of interp->varFramePtr when this
00667                                  * procedure was invoked (i.e. determines
00668                                  * variable scoping within caller). Same
00669                                  * as callerPtr unless an "uplevel" command
00670                                  * or something equivalent was active in
00671                                  * the caller). */
00672     int level;                  /* Level of this procedure, for "uplevel"
00673                                  * purposes (i.e. corresponds to nesting of
00674                                  * callerVarPtr's, not callerPtr's). 1 for
00675                                  * outermost procedure, 0 for top-level. */
00676     Proc *procPtr;              /* Points to the structure defining the
00677                                  * called procedure. Used to get information
00678                                  * such as the number of compiled local
00679                                  * variables (local variables assigned
00680                                  * entries ["slots"] in the compiledLocals
00681                                  * array below). */
00682     Tcl_HashTable *varTablePtr; /* Hash table containing local variables not
00683                                  * recognized by the compiler, or created at
00684                                  * execution time through, e.g., upvar.
00685                                  * Initially NULL and created if needed. */
00686     int numCompiledLocals;      /* Count of local variables recognized by
00687                                  * the compiler including arguments. */
00688     Var* compiledLocals;        /* Points to the array of local variables
00689                                  * recognized by the compiler. The compiler
00690                                  * emits code that refers to these variables
00691                                  * using an index into this array. */
00692 } CallFrame;
00693 
00694 /*
00695  *----------------------------------------------------------------
00696  * Data structures and procedures related to TclHandles, which
00697  * are a very lightweight method of preserving enough information
00698  * to determine if an arbitrary malloc'd block has been deleted.
00699  *----------------------------------------------------------------
00700  */
00701 
00702 typedef VOID **TclHandle;
00703 
00704 EXTERN TclHandle        TclHandleCreate _ANSI_ARGS_((VOID *ptr));
00705 EXTERN void             TclHandleFree _ANSI_ARGS_((TclHandle handle));
00706 EXTERN TclHandle        TclHandlePreserve _ANSI_ARGS_((TclHandle handle));
00707 EXTERN void             TclHandleRelease _ANSI_ARGS_((TclHandle handle)); 
00708 
00709 /*
00710  *----------------------------------------------------------------
00711  * Data structures related to history.   These are used primarily
00712  * in tclHistory.c
00713  *----------------------------------------------------------------
00714  */
00715 
00716 /*
00717  * The structure below defines one history event (a previously-executed
00718  * command that can be re-executed in whole or in part).
00719  */
00720 
00721 typedef struct {
00722     char *command;              /* String containing previously-executed
00723                                  * command. */
00724     int bytesAvl;               /* Total # of bytes available at *event (not
00725                                  * all are necessarily in use now). */
00726 } HistoryEvent;
00727 
00728 /*
00729  * The structure below defines a pending revision to the most recent
00730  * history event.  Changes are linked together into a list and applied
00731  * during the next call to Tcl_RecordHistory.  See the comments at the
00732  * beginning of tclHistory.c for information on revisions.
00733  */
00734 
00735 typedef struct HistoryRev {
00736     int firstIndex;             /* Index of the first byte to replace in
00737                                  * current history event. */
00738     int lastIndex;              /* Index of last byte to replace in
00739                                  * current history event. */
00740     int newSize;                /* Number of bytes in newBytes. */
00741     char *newBytes;             /* Replacement for the range given by
00742                                  * firstIndex and lastIndex (malloced). */
00743     struct HistoryRev *nextPtr; /* Next in chain of revisions to apply, or
00744                                  * NULL for end of list. */
00745 } HistoryRev;
00746 
00747 /*
00748  *----------------------------------------------------------------
00749  * Data structures related to expressions.  These are used only in
00750  * tclExpr.c.
00751  *----------------------------------------------------------------
00752  */
00753 
00754 /*
00755  * The data structure below defines a math function (e.g. sin or hypot)
00756  * for use in Tcl expressions.
00757  */
00758 
00759 #define MAX_MATH_ARGS 5
00760 typedef struct MathFunc {
00761     int builtinFuncIndex;       /* If this is a builtin math function, its
00762                                  * index in the array of builtin functions.
00763                                  * (tclCompilation.h lists these indices.)
00764                                  * The value is -1 if this is a new function
00765                                  * defined by Tcl_CreateMathFunc. The value
00766                                  * is also -1 if a builtin function is
00767                                  * replaced by a Tcl_CreateMathFunc call. */
00768     int numArgs;                /* Number of arguments for function. */
00769     Tcl_ValueType argTypes[MAX_MATH_ARGS];
00770                                 /* Acceptable types for each argument. */
00771     Tcl_MathProc *proc;         /* Procedure that implements this function.
00772                                  * NULL if isBuiltinFunc is 1. */
00773     ClientData clientData;      /* Additional argument to pass to the
00774                                  * function when invoking it. NULL if
00775                                  * isBuiltinFunc is 1. */
00776 } MathFunc;
00777 
00778 /*
00779  * These are a thin layer over TclpThreadKeyDataGet and TclpThreadKeyDataSet
00780  * when threads are used, or an emulation if there are no threads.  These
00781  * are really internal and Tcl clients should use Tcl_GetThreadData.
00782  */
00783 
00784 EXTERN VOID *TclThreadDataKeyGet _ANSI_ARGS_((Tcl_ThreadDataKey *keyPtr));
00785 EXTERN void TclThreadDataKeySet _ANSI_ARGS_((Tcl_ThreadDataKey *keyPtr, VOID *data));
00786 
00787 /*
00788  * This is a convenience macro used to initialize a thread local storage ptr.
00789  */
00790 #define TCL_TSD_INIT(keyPtr)    (ThreadSpecificData *)Tcl_GetThreadData((keyPtr), sizeof(ThreadSpecificData))
00791 
00792 
00793 /*
00794  *----------------------------------------------------------------
00795  * Data structures related to bytecode compilation and execution.
00796  * These are used primarily in tclCompile.c, tclExecute.c, and
00797  * tclBasic.c.
00798  *----------------------------------------------------------------
00799  */
00800 
00801 /*
00802  * Forward declaration to prevent errors when the forward references to
00803  * Tcl_Parse and CompileEnv are encountered in the procedure type
00804  * CompileProc declared below.
00805  */
00806 
00807 struct CompileEnv;
00808 
00809 /*
00810  * The type of procedures called by the Tcl bytecode compiler to compile
00811  * commands. Pointers to these procedures are kept in the Command structure
00812  * describing each command. When a CompileProc returns, the interpreter's
00813  * result is set to error information, if any. In addition, the CompileProc
00814  * returns an integer value, which is one of the following:
00815  *
00816  * TCL_OK               Compilation completed normally.
00817  * TCL_ERROR            Compilation failed because of an error;
00818  *                      the interpreter's result describes what went wrong.
00819  * TCL_OUT_LINE_COMPILE Compilation failed because, e.g., the command is
00820  *                      too complex for effective inline compilation. The
00821  *                      CompileProc believes the command is legal but 
00822  *                      should be compiled "out of line" by emitting code
00823  *                      to invoke its command procedure at runtime.
00824  */
00825 
00826 #define TCL_OUT_LINE_COMPILE    (TCL_CONTINUE + 1)
00827 
00828 typedef int (CompileProc) _ANSI_ARGS_((Tcl_Interp *interp,
00829         Tcl_Parse *parsePtr, struct CompileEnv *compEnvPtr));
00830 
00831 /*
00832  * The type of procedure called from the compilation hook point in
00833  * SetByteCodeFromAny.
00834  */
00835 
00836 typedef int (CompileHookProc) _ANSI_ARGS_((Tcl_Interp *interp,
00837         struct CompileEnv *compEnvPtr, ClientData clientData));
00838 
00839 /*
00840  * The data structure defining the execution environment for ByteCode's.
00841  * There is one ExecEnv structure per Tcl interpreter. It holds the
00842  * evaluation stack that holds command operands and results. The stack grows
00843  * towards increasing addresses. The "stackTop" member is cached by
00844  * TclExecuteByteCode in a local variable: it must be set before calling
00845  * TclExecuteByteCode and will be restored by TclExecuteByteCode before it
00846  * returns.
00847  */
00848 
00849 typedef struct ExecEnv {
00850     Tcl_Obj **stackPtr;         /* Points to the first item in the
00851                                  * evaluation stack on the heap. */
00852     int stackTop;               /* Index of current top of stack; -1 when
00853                                  * the stack is empty. */
00854     int stackEnd;               /* Index of last usable item in stack. */
00855 } ExecEnv;
00856 
00857 /*
00858  * The definitions for the LiteralTable and LiteralEntry structures. Each
00859  * interpreter contains a LiteralTable. It is used to reduce the storage
00860  * needed for all the Tcl objects that hold the literals of scripts compiled
00861  * by the interpreter. A literal's object is shared by all the ByteCodes
00862  * that refer to the literal. Each distinct literal has one LiteralEntry
00863  * entry in the LiteralTable. A literal table is a specialized hash table
00864  * that is indexed by the literal's string representation, which may contain
00865  * null characters.
00866  *
00867  * Note that we reduce the space needed for literals by sharing literal
00868  * objects both within a ByteCode (each ByteCode contains a local
00869  * LiteralTable) and across all an interpreter's ByteCodes (with the
00870  * interpreter's global LiteralTable).
00871  */
00872 
00873 typedef struct LiteralEntry {
00874     struct LiteralEntry *nextPtr;       /* Points to next entry in this
00875                                          * hash bucket or NULL if end of
00876                                          * chain. */
00877     Tcl_Obj *objPtr;                    /* Points to Tcl object that
00878                                          * holds the literal's bytes and
00879                                          * length. */
00880     int refCount;                       /* If in an interpreter's global
00881                                          * literal table, the number of
00882                                          * ByteCode structures that share
00883                                          * the literal object; the literal
00884                                          * entry can be freed when refCount
00885                                          * drops to 0. If in a local literal
00886                                          * table, -1. */
00887 } LiteralEntry;
00888 
00889 typedef struct LiteralTable {
00890     LiteralEntry **buckets;             /* Pointer to bucket array. Each
00891                                          * element points to first entry in
00892                                          * bucket's hash chain, or NULL. */
00893     LiteralEntry *staticBuckets[TCL_SMALL_HASH_TABLE];
00894                                         /* Bucket array used for small
00895                                          * tables to avoid mallocs and
00896                                          * frees. */
00897     int numBuckets;                     /* Total number of buckets allocated
00898                                          * at **buckets. */
00899     int numEntries;                     /* Total number of entries present
00900                                          * in table. */
00901     int rebuildSize;                    /* Enlarge table when numEntries
00902                                          * gets to be this large. */
00903     int mask;                           /* Mask value used in hashing
00904                                          * function. */
00905 } LiteralTable;
00906 
00907 /*
00908  * The following structure defines for each Tcl interpreter various
00909  * statistics-related information about the bytecode compiler and
00910  * interpreter's operation in that interpreter.
00911  */
00912 
00913 #ifdef TCL_COMPILE_STATS
00914 typedef struct ByteCodeStats {
00915     long numExecutions;           /* Number of ByteCodes executed. */
00916     long numCompilations;         /* Number of ByteCodes created. */
00917     long numByteCodesFreed;       /* Number of ByteCodes destroyed. */
00918     long instructionCount[256];   /* Number of times each instruction was
00919                                    * executed. */
00920 
00921     double totalSrcBytes;         /* Total source bytes ever compiled. */
00922     double totalByteCodeBytes;    /* Total bytes for all ByteCodes. */
00923     double currentSrcBytes;       /* Src bytes for all current ByteCodes. */
00924     double currentByteCodeBytes;  /* Code bytes in all current ByteCodes. */
00925 
00926     long srcCount[32];            /* Source size distribution: # of srcs of
00927                                    * size [2**(n-1)..2**n), n in [0..32). */
00928     long byteCodeCount[32];       /* ByteCode size distribution. */
00929     long lifetimeCount[32];       /* ByteCode lifetime distribution (ms). */
00930     
00931     double currentInstBytes;      /* Instruction bytes-current ByteCodes. */
00932     double currentLitBytes;       /* Current literal bytes. */
00933     double currentExceptBytes;    /* Current exception table bytes. */
00934     double currentAuxBytes;       /* Current auxiliary information bytes. */
00935     double currentCmdMapBytes;    /* Current src<->code map bytes. */
00936     
00937     long numLiteralsCreated;      /* Total literal objects ever compiled. */
00938     double totalLitStringBytes;   /* Total string bytes in all literals. */
00939     double currentLitStringBytes; /* String bytes in current literals. */
00940     long literalCount[32];        /* Distribution of literal string sizes. */
00941 } ByteCodeStats;
00942 #endif /* TCL_COMPILE_STATS */
00943 
00944 /*
00945  *----------------------------------------------------------------
00946  * Data structures related to commands.
00947  *----------------------------------------------------------------
00948  */
00949 
00950 /*
00951  * An imported command is created in an namespace when it imports a "real"
00952  * command from another namespace. An imported command has a Command
00953  * structure that points (via its ClientData value) to the "real" Command
00954  * structure in the source namespace's command table. The real command
00955  * records all the imported commands that refer to it in a list of ImportRef
00956  * structures so that they can be deleted when the real command is deleted.  */
00957 
00958 typedef struct ImportRef {
00959     struct Command *importedCmdPtr;
00960                                 /* Points to the imported command created in
00961                                  * an importing namespace; this command
00962                                  * redirects its invocations to the "real"
00963                                  * command. */
00964     struct ImportRef *nextPtr;  /* Next element on the linked list of
00965                                  * imported commands that refer to the
00966                                  * "real" command. The real command deletes
00967                                  * these imported commands on this list when
00968                                  * it is deleted. */
00969 } ImportRef;
00970 
00971 /*
00972  * Data structure used as the ClientData of imported commands: commands
00973  * created in an namespace when it imports a "real" command from another
00974  * namespace.
00975  */
00976 
00977 typedef struct ImportedCmdData {
00978     struct Command *realCmdPtr; /* "Real" command that this imported command
00979                                  * refers to. */
00980     struct Command *selfPtr;    /* Pointer to this imported command. Needed
00981                                  * only when deleting it in order to remove
00982                                  * it from the real command's linked list of
00983                                  * imported commands that refer to it. */
00984 } ImportedCmdData;
00985 
00986 /*
00987  * A Command structure exists for each command in a namespace. The
00988  * Tcl_Command opaque type actually refers to these structures.
00989  */
00990 
00991 typedef struct Command {
00992     Tcl_HashEntry *hPtr;        /* Pointer to the hash table entry that
00993                                  * refers to this command. The hash table is
00994                                  * either a namespace's command table or an
00995                                  * interpreter's hidden command table. This
00996                                  * pointer is used to get a command's name
00997                                  * from its Tcl_Command handle. NULL means
00998                                  * that the hash table entry has been
00999                                  * removed already (this can happen if
01000                                  * deleteProc causes the command to be
01001                                  * deleted or recreated). */
01002     Namespace *nsPtr;           /* Points to the namespace containing this
01003                                  * command. */
01004     int refCount;               /* 1 if in command hashtable plus 1 for each
01005                                  * reference from a CmdName Tcl object
01006                                  * representing a command's name in a
01007                                  * ByteCode instruction sequence. This
01008                                  * structure can be freed when refCount
01009                                  * becomes zero. */
01010     int cmdEpoch;               /* Incremented to invalidate any references
01011                                  * that point to this command when it is
01012                                  * renamed, deleted, hidden, or exposed. */
01013     CompileProc *compileProc;   /* Procedure called to compile command. NULL
01014                                  * if no compile proc exists for command. */
01015     Tcl_ObjCmdProc *objProc;    /* Object-based command procedure. */
01016     ClientData objClientData;   /* Arbitrary value passed to object proc. */
01017     Tcl_CmdProc *proc;          /* String-based command procedure. */
01018     ClientData clientData;      /* Arbitrary value passed to string proc. */
01019     Tcl_CmdDeleteProc *deleteProc;
01020                                 /* Procedure invoked when deleting command
01021                                  * to, e.g., free all client data. */
01022     ClientData deleteData;      /* Arbitrary value passed to deleteProc. */
01023     int deleted;                /* Means that the command is in the process
01024                                  * of being deleted (its deleteProc is
01025                                  * currently executing). Other attempts to
01026                                  * delete the command should be ignored. */
01027     ImportRef *importRefPtr;    /* List of each imported Command created in
01028                                  * another namespace when this command is
01029                                  * imported. These imported commands
01030                                  * redirect invocations back to this
01031                                  * command. The list is used to remove all
01032                                  * those imported commands when deleting
01033                                  * this "real" command. */
01034 } Command;
01035 
01036 /*
01037  *----------------------------------------------------------------
01038  * Data structures related to name resolution procedures.
01039  *----------------------------------------------------------------
01040  */
01041 
01042 /*
01043  * The interpreter keeps a linked list of name resolution schemes.
01044  * The scheme for a namespace is consulted first, followed by the
01045  * list of schemes in an interpreter, followed by the default
01046  * name resolution in Tcl.  Schemes are added/removed from the
01047  * interpreter's list by calling Tcl_AddInterpResolver and
01048  * Tcl_RemoveInterpResolver.
01049  */
01050 
01051 typedef struct ResolverScheme {
01052     char *name;                 /* Name identifying this scheme. */
01053     Tcl_ResolveCmdProc *cmdResProc;
01054                                 /* Procedure handling command name
01055                                  * resolution. */
01056     Tcl_ResolveVarProc *varResProc;
01057                                 /* Procedure handling variable name
01058                                  * resolution for variables that
01059                                  * can only be handled at runtime. */
01060     Tcl_ResolveCompiledVarProc *compiledVarResProc;
01061                                 /* Procedure handling variable name
01062                                  * resolution at compile time. */
01063 
01064     struct ResolverScheme *nextPtr;
01065                                 /* Pointer to next record in linked list. */
01066 } ResolverScheme;
01067 
01068 /*
01069  *----------------------------------------------------------------
01070  * This structure defines an interpreter, which is a collection of
01071  * commands plus other state information related to interpreting
01072  * commands, such as variable storage. Primary responsibility for
01073  * this data structure is in tclBasic.c, but almost every Tcl
01074  * source file uses something in here.
01075  *----------------------------------------------------------------
01076  */
01077 
01078 typedef struct Interp {
01079 
01080     /*
01081      * Note:  the first three fields must match exactly the fields in
01082      * a Tcl_Interp struct (see tcl.h).  If you change one, be sure to
01083      * change the other.
01084      *
01085      * The interpreter's result is held in both the string and the
01086      * objResultPtr fields. These fields hold, respectively, the result's
01087      * string or object value. The interpreter's result is always in the
01088      * result field if that is non-empty, otherwise it is in objResultPtr.
01089      * The two fields are kept consistent unless some C code sets
01090      * blah->result directly. Programs should not access result and
01091      * objResultPtr directly; instead, they should always get and set the
01092      * result using procedures such as Tcl_SetObjResult, Tcl_GetObjResult,
01093      * and Tcl_GetStringResult. See the SetResult man page for details.
01094      */
01095 
01096     char *result;               /* If the last command returned a string
01097                                  * result, this points to it. Should not be
01098                                  * accessed directly; see comment above. */
01099     Tcl_FreeProc *freeProc;     /* Zero means a string result is statically
01100                                  * allocated. TCL_DYNAMIC means string
01101                                  * result was allocated with ckalloc and
01102                                  * should be freed with ckfree. Other values
01103                                  * give address of procedure to invoke to
01104                                  * free the string result. Tcl_Eval must
01105                                  * free it before executing next command. */
01106     int errorLine;              /* When TCL_ERROR is returned, this gives
01107                                  * the line number in the command where the
01108                                  * error occurred (1 means first line). */
01109     struct TclStubs *stubTable;
01110                                 /* Pointer to the exported Tcl stub table.
01111                                  * On previous versions of Tcl this is a
01112                                  * pointer to the objResultPtr or a pointer
01113                                  * to a buckets array in a hash table. We
01114                                  * therefore have to do some careful checking
01115                                  * before we can use this. */
01116 
01117     TclHandle handle;           /* Handle used to keep track of when this
01118                                  * interp is deleted. */
01119 
01120     Namespace *globalNsPtr;     /* The interpreter's global namespace. */
01121     Tcl_HashTable *hiddenCmdTablePtr;
01122                                 /* Hash table used by tclBasic.c to keep
01123                                  * track of hidden commands on a per-interp
01124                                  * basis. */
01125     ClientData interpInfo;      /* Information used by tclInterp.c to keep
01126                                  * track of master/slave interps on
01127                                  * a per-interp basis. */
01128     Tcl_HashTable mathFuncTable;/* Contains all the math functions currently
01129                                  * defined for the interpreter.  Indexed by
01130                                  * strings (function names); values have
01131                                  * type (MathFunc *). */
01132 
01133 
01134 
01135     /*
01136      * Information related to procedures and variables. See tclProc.c
01137      * and tclvar.c for usage.
01138      */
01139 
01140     int numLevels;              /* Keeps track of how many nested calls to
01141                                  * Tcl_Eval are in progress for this
01142                                  * interpreter.  It's used to delay deletion
01143                                  * of the table until all Tcl_Eval
01144                                  * invocations are completed. */
01145     int maxNestingDepth;        /* If numLevels exceeds this value then Tcl
01146                                  * assumes that infinite recursion has
01147                                  * occurred and it generates an error. */
01148     CallFrame *framePtr;        /* Points to top-most in stack of all nested
01149                                  * procedure invocations.  NULL means there
01150                                  * are no active procedures. */
01151     CallFrame *varFramePtr;     /* Points to the call frame whose variables
01152                                  * are currently in use (same as framePtr
01153                                  * unless an "uplevel" command is
01154                                  * executing). NULL means no procedure is
01155                                  * active or "uplevel 0" is executing. */
01156     ActiveVarTrace *activeTracePtr;
01157                                 /* First in list of active traces for
01158                                  * interp, or NULL if no active traces. */
01159     int returnCode;             /* Completion code to return if current
01160                                  * procedure exits with TCL_RETURN code. */
01161     char *errorInfo;            /* Value to store in errorInfo if returnCode
01162                                  * is TCL_ERROR.  Malloc'ed, may be NULL */
01163     char *errorCode;            /* Value to store in errorCode if returnCode
01164                                  * is TCL_ERROR.  Malloc'ed, may be NULL */
01165 
01166     /*
01167      * Information used by Tcl_AppendResult to keep track of partial
01168      * results.  See Tcl_AppendResult code for details.
01169      */
01170 
01171     char *appendResult;         /* Storage space for results generated
01172                                  * by Tcl_AppendResult.  Malloc-ed.  NULL
01173                                  * means not yet allocated. */
01174     int appendAvl;              /* Total amount of space available at
01175                                  * partialResult. */
01176     int appendUsed;             /* Number of non-null bytes currently
01177                                  * stored at partialResult. */
01178 
01179     /*
01180      * Information about packages.  Used only in tclPkg.c.
01181      */
01182 
01183     Tcl_HashTable packageTable; /* Describes all of the packages loaded
01184                                  * in or available to this interpreter.
01185                                  * Keys are package names, values are
01186                                  * (Package *) pointers. */
01187     char *packageUnknown;       /* Command to invoke during "package
01188                                  * require" commands for packages that
01189                                  * aren't described in packageTable. 
01190                                  * Malloc'ed, may be NULL. */
01191 
01192     /*
01193      * Miscellaneous information:
01194      */
01195 
01196     int cmdCount;               /* Total number of times a command procedure
01197                                  * has been called for this interpreter. */
01198     int evalFlags;              /* Flags to control next call to Tcl_Eval.
01199                                  * Normally zero, but may be set before
01200                                  * calling Tcl_Eval.  See below for valid
01201                                  * values. */
01202     int termOffset;             /* Offset of character just after last one
01203                                  * compiled or executed by Tcl_EvalObj. */
01204     LiteralTable literalTable;  /* Contains LiteralEntry's describing all
01205                                  * Tcl objects holding literals of scripts
01206                                  * compiled by the interpreter. Indexed by
01207                                  * the string representations of literals.
01208                                  * Used to avoid creating duplicate
01209                                  * objects. */
01210     int compileEpoch;           /* Holds the current "compilation epoch"
01211                                  * for this interpreter. This is
01212                                  * incremented to invalidate existing
01213                                  * ByteCodes when, e.g., a command with a
01214                                  * compile procedure is redefined. */
01215     Proc *compiledProcPtr;      /* If a procedure is being compiled, a
01216                                  * pointer to its Proc structure; otherwise,
01217                                  * this is NULL. Set by ObjInterpProc in
01218                                  * tclProc.c and used by tclCompile.c to
01219                                  * process local variables appropriately. */
01220     ResolverScheme *resolverPtr;
01221                                 /* Linked list of name resolution schemes
01222                                  * added to this interpreter.  Schemes
01223                                  * are added/removed by calling
01224                                  * Tcl_AddInterpResolvers and
01225                                  * Tcl_RemoveInterpResolver. */
01226     char *scriptFile;           /* NULL means there is no nested source
01227                                  * command active;  otherwise this points to
01228                                  * the name of the file being sourced (it's
01229                                  * not malloc-ed:  it points to an argument
01230                                  * to Tcl_EvalFile. */
01231     int flags;                  /* Various flag bits.  See below. */
01232     long randSeed;              /* Seed used for rand() function. */
01233     Trace *tracePtr;            /* List of traces for this interpreter. */
01234     Tcl_HashTable *assocData;   /* Hash table for associating data with
01235                                  * this interpreter. Cleaned up when
01236                                  * this interpreter is deleted. */
01237     struct ExecEnv *execEnvPtr; /* Execution environment for Tcl bytecode
01238                                  * execution. Contains a pointer to the
01239                                  * Tcl evaluation stack. */
01240     Tcl_Obj *emptyObjPtr;       /* Points to an object holding an empty
01241                                  * string. Returned by Tcl_ObjSetVar2 when
01242                                  * variable traces change a variable in a
01243                                  * gross way. */
01244     char resultSpace[TCL_RESULT_SIZE+1];
01245                                 /* Static space holding small results. */
01246     Tcl_Obj *objResultPtr;      /* If the last command returned an object
01247                                  * result, this points to it. Should not be
01248                                  * accessed directly; see comment above. */
01249     Tcl_ThreadId threadId;      /* ID of thread that owns the interpreter */
01250 
01251     /*
01252      * Statistical information about the bytecode compiler and interpreter's
01253      * operation.
01254      */
01255 
01256 #ifdef TCL_COMPILE_STATS
01257     ByteCodeStats stats;        /* Holds compilation and execution
01258                                  * statistics for this interpreter. */
01259 #endif /* TCL_COMPILE_STATS */    
01260 } Interp;
01261 
01262 /*
01263  * EvalFlag bits for Interp structures:
01264  *
01265  * TCL_BRACKET_TERM     1 means that the current script is terminated by
01266  *                      a close bracket rather than the end of the string.
01267  * TCL_ALLOW_EXCEPTIONS 1 means it's OK for the script to terminate with
01268  *                      a code other than TCL_OK or TCL_ERROR;  0 means
01269  *                      codes other than these should be turned into errors.
01270  */
01271 
01272 #define TCL_BRACKET_TERM          1
01273 #define TCL_ALLOW_EXCEPTIONS      4
01274 
01275 /*
01276  * Flag bits for Interp structures:
01277  *
01278  * DELETED:             Non-zero means the interpreter has been deleted:
01279  *                      don't process any more commands for it, and destroy
01280  *                      the structure as soon as all nested invocations of
01281  *                      Tcl_Eval are done.
01282  * ERR_IN_PROGRESS:     Non-zero means an error unwind is already in
01283  *                      progress. Zero means a command proc has been
01284  *                      invoked since last error occured.
01285  * ERR_ALREADY_LOGGED:  Non-zero means information has already been logged
01286  *                      in $errorInfo for the current Tcl_Eval instance,
01287  *                      so Tcl_Eval needn't log it (used to implement the
01288  *                      "error message log" command).
01289  * ERROR_CODE_SET:      Non-zero means that Tcl_SetErrorCode has been
01290  *                      called to record information for the current
01291  *                      error.  Zero means Tcl_Eval must clear the
01292  *                      errorCode variable if an error is returned.
01293  * EXPR_INITIALIZED:    Non-zero means initialization specific to
01294  *                      expressions has been carried out.
01295  * DONT_COMPILE_CMDS_INLINE: Non-zero means that the bytecode compiler
01296  *                      should not compile any commands into an inline
01297  *                      sequence of instructions. This is set 1, for
01298  *                      example, when command traces are requested.
01299  * RAND_SEED_INITIALIZED: Non-zero means that the randSeed value of the
01300  *                      interp has not be initialized.  This is set 1
01301  *                      when we first use the rand() or srand() functions.
01302  * SAFE_INTERP:         Non zero means that the current interp is a
01303  *                      safe interp (ie it has only the safe commands
01304  *                      installed, less priviledge than a regular interp).
01305  * USE_EVAL_DIRECT:     Non-zero means don't use the compiler or byte-code
01306  *                      interpreter; instead, have Tcl_EvalObj call
01307  *                      Tcl_EvalEx. Used primarily for testing the
01308  *                      new parser.
01309  */
01310 
01311 #define DELETED                             1
01312 #define ERR_IN_PROGRESS                     2
01313 #define ERR_ALREADY_LOGGED                  4
01314 #define ERROR_CODE_SET                      8
01315 #define EXPR_INITIALIZED                 0x10
01316 #define DONT_COMPILE_CMDS_INLINE         0x20
01317 #define RAND_SEED_INITIALIZED            0x40
01318 #define SAFE_INTERP                      0x80
01319 #define USE_EVAL_DIRECT                 0x100
01320 
01321 /*
01322  *----------------------------------------------------------------
01323  * Data structures related to command parsing. These are used in
01324  * tclParse.c and its clients.
01325  *----------------------------------------------------------------
01326  */
01327 
01328 /*
01329  * The following data structure is used by various parsing procedures
01330  * to hold information about where to store the results of parsing
01331  * (e.g. the substituted contents of a quoted argument, or the result
01332  * of a nested command).  At any given time, the space available
01333  * for output is fixed, but a procedure may be called to expand the
01334  * space available if the current space runs out.
01335  */
01336 
01337 typedef struct ParseValue {
01338     char *buffer;               /* Address of first character in
01339                                  * output buffer. */
01340     char *next;                 /* Place to store next character in
01341                                  * output buffer. */
01342     char *end;                  /* Address of the last usable character
01343                                  * in the buffer. */
01344     void (*expandProc) _ANSI_ARGS_((struct ParseValue *pvPtr, int needed));
01345                                 /* Procedure to call when space runs out;
01346                                  * it will make more space. */
01347     ClientData clientData;      /* Arbitrary information for use of
01348                                  * expandProc. */
01349 } ParseValue;
01350 
01351 
01352 /*
01353  * Maximum number of levels of nesting permitted in Tcl commands (used
01354  * to catch infinite recursion).
01355  */
01356 
01357 #define MAX_NESTING_DEPTH       1000
01358 
01359 /*
01360  * The macro below is used to modify a "char" value (e.g. by casting
01361  * it to an unsigned character) so that it can be used safely with
01362  * macros such as isspace.
01363  */
01364 
01365 #define UCHAR(c) ((unsigned char) (c))
01366 
01367 /*
01368  * This macro is used to determine the offset needed to safely allocate any
01369  * data structure in memory. Given a starting offset or size, it "rounds up"
01370  * or "aligns" the offset to the next 8-byte boundary so that any data
01371  * structure can be placed at the resulting offset without fear of an
01372  * alignment error.
01373  *
01374  * WARNING!! DO NOT USE THIS MACRO TO ALIGN POINTERS: it will produce
01375  * the wrong result on platforms that allocate addresses that are divisible
01376  * by 4 or 2. Only use it for offsets or sizes.
01377  */
01378 
01379 #define TCL_ALIGN(x) (((int)(x) + 7) & ~7)
01380 
01381 /*
01382  * The following macros are used to specify the runtime platform
01383  * setting of the tclPlatform variable.
01384  */
01385 
01386 typedef enum {
01387     TCL_PLATFORM_UNIX,          /* Any Unix-like OS. */
01388     TCL_PLATFORM_MAC,           /* MacOS. */
01389     TCL_PLATFORM_WINDOWS        /* Any Microsoft Windows OS. */
01390 } TclPlatformType;
01391 
01392 /*
01393  * Flags for TclInvoke:
01394  *
01395  * TCL_INVOKE_HIDDEN            Invoke a hidden command; if not set,
01396  *                              invokes an exposed command.
01397  * TCL_INVOKE_NO_UNKNOWN        If set, "unknown" is not invoked if
01398  *                              the command to be invoked is not found.
01399  *                              Only has an effect if invoking an exposed
01400  *                              command, i.e. if TCL_INVOKE_HIDDEN is not
01401  *                              also set.
01402  * TCL_INVOKE_NO_TRACEBACK      Does not record traceback information if
01403  *                              the invoked command returns an error.  Used
01404  *                              if the caller plans on recording its own
01405  *                              traceback information.
01406  */
01407 
01408 #define TCL_INVOKE_HIDDEN       (1<<0)
01409 #define TCL_INVOKE_NO_UNKNOWN   (1<<1)
01410 #define TCL_INVOKE_NO_TRACEBACK (1<<2)
01411 
01412 /*
01413  * The structure used as the internal representation of Tcl list
01414  * objects. This is an array of pointers to the element objects. This array
01415  * is grown (reallocated and copied) as necessary to hold all the list's
01416  * element pointers. The array might contain more slots than currently used
01417  * to hold all element pointers. This is done to make append operations
01418  * faster.
01419  */
01420 
01421 typedef struct List {
01422     int maxElemCount;           /* Total number of element array slots. */
01423     int elemCount;              /* Current number of list elements. */
01424     Tcl_Obj **elements;         /* Array of pointers to element objects. */
01425 } List;
01426 
01427 
01428 /*
01429  * The following types are used for getting and storing platform-specific
01430  * file attributes in tclFCmd.c and the various platform-versions of
01431  * that file. This is done to have as much common code as possible
01432  * in the file attributes code. For more information about the callbacks,
01433  * see TclFileAttrsCmd in tclFCmd.c.
01434  */
01435 
01436 typedef int (TclGetFileAttrProc) _ANSI_ARGS_((Tcl_Interp *interp,
01437         int objIndex, CONST char *fileName, Tcl_Obj **attrObjPtrPtr));
01438 typedef int (TclSetFileAttrProc) _ANSI_ARGS_((Tcl_Interp *interp,
01439         int objIndex, CONST char *fileName, Tcl_Obj *attrObjPtr));
01440 
01441 typedef struct TclFileAttrProcs {
01442     TclGetFileAttrProc *getProc;        /* The procedure for getting attrs. */
01443     TclSetFileAttrProc *setProc;        /* The procedure for setting attrs. */
01444 } TclFileAttrProcs;
01445 
01446 /*
01447  * Opaque handle used in pipeline routines to encapsulate platform-dependent
01448  * state. 
01449  */
01450 
01451 typedef struct TclFile_ *TclFile;
01452     
01453 /*
01454  *----------------------------------------------------------------
01455  * Data structures related to hooking 'TclStat(...)' and
01456  * 'TclAccess(...)'.
01457  *----------------------------------------------------------------
01458  */
01459 
01460 typedef int (TclStatProc_) _ANSI_ARGS_((CONST char *path, struct stat *buf));
01461 typedef int (TclAccessProc_) _ANSI_ARGS_((CONST char *path, int mode));
01462 typedef Tcl_Channel (TclOpenFileChannelProc_) _ANSI_ARGS_((Tcl_Interp *interp,
01463         char *fileName, char *modeString,
01464         int permissions));
01465 
01466 typedef int (*TclCmdProcType) _ANSI_ARGS_((ClientData clientData,
01467         Tcl_Interp *interp, int argc, char *argv[]));
01468 typedef int (*TclObjCmdProcType) _ANSI_ARGS_((ClientData clientData,
01469         Tcl_Interp *interp, int objc, struct Tcl_Obj * CONST objv[]));
01470 
01471 /*
01472  * Opaque names for platform specific types.
01473  */
01474 
01475 typedef struct TclpTime_t_ *TclpTime_t;
01476 
01477 /* 
01478  * The following structure is used to pass glob type data amongst
01479  * the various glob routines and TclpMatchFilesTypes.  Currently
01480  * most of the fields are ignored.  However they will be used in
01481  * a future release to implement glob's ability to find files
01482  * of particular types/permissions/etc only.
01483  */
01484 typedef struct GlobTypeData {
01485     /* Corresponds to bcdpfls as in 'find -t' */
01486     int type;
01487     /* Corresponds to file permissions */
01488     int perm;
01489     /* Acceptable mac type */
01490     Tcl_Obj* macType;
01491     /* Acceptable mac creator */
01492     Tcl_Obj* macCreator;
01493 } GlobTypeData;
01494 
01495 /*
01496  * type and permission definitions for glob command
01497  */
01498 #define TCL_GLOB_TYPE_BLOCK             (1<<0)
01499 #define TCL_GLOB_TYPE_CHAR              (1<<1)
01500 #define TCL_GLOB_TYPE_DIR               (1<<2)
01501 #define TCL_GLOB_TYPE_PIPE              (1<<3)
01502 #define TCL_GLOB_TYPE_FILE              (1<<4)
01503 #define TCL_GLOB_TYPE_LINK              (1<<5)
01504 #define TCL_GLOB_TYPE_SOCK              (1<<6)
01505 
01506 #define TCL_GLOB_PERM_RONLY             (1<<0)
01507 #define TCL_GLOB_PERM_HIDDEN            (1<<1)
01508 #define TCL_GLOB_PERM_R                 (1<<2)
01509 #define TCL_GLOB_PERM_W                 (1<<3)
01510 #define TCL_GLOB_PERM_X                 (1<<4)
01511 
01512 /*
01513  *----------------------------------------------------------------
01514  * Variables shared among Tcl modules but not used by the outside world.
01515  *----------------------------------------------------------------
01516  */
01517 
01518 extern Tcl_Time                 tclBlockTime;
01519 extern int                      tclBlockTimeSet;
01520 extern char *                   tclExecutableName;
01521 extern char *                   tclNativeExecutableName;
01522 extern char *                   tclDefaultEncodingDir;
01523 extern Tcl_ChannelType          tclFileChannelType;
01524 extern char *                   tclMemDumpFileName;
01525 extern TclPlatformType          tclPlatform;
01526 extern char *                   tclpFileAttrStrings[];
01527 extern CONST TclFileAttrProcs   tclpFileAttrProcs[];
01528 
01529 /*
01530  * Variables denoting the Tcl object types defined in the core.
01531  */
01532 
01533 extern Tcl_ObjType      tclBooleanType;
01534 extern Tcl_ObjType      tclByteArrayType;
01535 extern Tcl_ObjType      tclByteCodeType;
01536 extern Tcl_ObjType      tclDoubleType;
01537 extern Tcl_ObjType      tclIntType;
01538 extern Tcl_ObjType      tclListType;
01539 extern Tcl_ObjType      tclProcBodyType;
01540 extern Tcl_ObjType      tclStringType;
01541 
01542 /*
01543  * The head of the list of free Tcl objects, and the total number of Tcl
01544  * objects ever allocated and freed.
01545  */
01546 
01547 extern Tcl_Obj *        tclFreeObjList;
01548 
01549 #ifdef TCL_COMPILE_STATS
01550 extern long             tclObjsAlloced;
01551 extern long             tclObjsFreed;
01552 #endif /* TCL_COMPILE_STATS */
01553 
01554 /*
01555  * Pointer to a heap-allocated string of length zero that the Tcl core uses
01556  * as the value of an empty string representation for an object. This value
01557  * is shared by all new objects allocated by Tcl_NewObj.
01558  */
01559 
01560 extern char *           tclEmptyStringRep;
01561 
01562 /*
01563  *----------------------------------------------------------------
01564  * Procedures shared among Tcl modules but not used by the outside
01565  * world:
01566  *----------------------------------------------------------------
01567  */
01568 
01569 EXTERN int              TclAccess _ANSI_ARGS_((CONST char *path,
01570                             int mode));
01571 EXTERN int              TclAccessDeleteProc _ANSI_ARGS_((TclAccessProc_ *proc));
01572 EXTERN int              TclAccessInsertProc _ANSI_ARGS_((TclAccessProc_ *proc));
01573 EXTERN void             TclAllocateFreeObjects _ANSI_ARGS_((void));
01574 EXTERN int              TclArraySet _ANSI_ARGS_((Tcl_Interp *interp,
01575                             Tcl_Obj *arrayNameObj, Tcl_Obj *arrayElemObj));
01576 EXTERN int              TclCheckBadOctal _ANSI_ARGS_((Tcl_Interp *interp,
01577                             char *value));
01578 EXTERN int              TclCleanupChildren _ANSI_ARGS_((Tcl_Interp *interp,
01579                             int numPids, Tcl_Pid *pidPtr,
01580                             Tcl_Channel errorChan));
01581 EXTERN void             TclCleanupCommand _ANSI_ARGS_((Command *cmdPtr));
01582 EXTERN int              TclCopyChannel _ANSI_ARGS_((Tcl_Interp *interp,
01583                             Tcl_Channel inChan, Tcl_Channel outChan,
01584                             int toRead, Tcl_Obj *cmdPtr));
01585 /*
01586  * TclCreatePipeline unofficially exported for use by BLT.
01587  */
01588 EXTERN int              TclCreatePipeline _ANSI_ARGS_((Tcl_Interp *interp,
01589                             int argc, char **argv, Tcl_Pid **pidArrayPtr,
01590                             TclFile *inPipePtr, TclFile *outPipePtr,
01591                             TclFile *errFilePtr));
01592 EXTERN int              TclCreateProc _ANSI_ARGS_((Tcl_Interp *interp,
01593                             Namespace *nsPtr, char *procName,
01594                             Tcl_Obj *argsPtr, Tcl_Obj *bodyPtr,
01595                             Proc **procPtrPtr));
01596 EXTERN void             TclDeleteCompiledLocalVars _ANSI_ARGS_((
01597                             Interp *iPtr, CallFrame *framePtr));
01598 EXTERN void             TclDeleteVars _ANSI_ARGS_((Interp *iPtr,
01599                             Tcl_HashTable *tablePtr));
01600 EXTERN int              TclDoGlob _ANSI_ARGS_((Tcl_Interp *interp,
01601                             char *separators, Tcl_DString *headPtr,
01602                             char *tail, GlobTypeData *types));
01603 EXTERN void             TclDumpMemoryInfo _ANSI_ARGS_((FILE *outFile));
01604 EXTERN void             TclExpandTokenArray _ANSI_ARGS_((
01605                             Tcl_Parse *parsePtr));
01606 EXTERN void             TclExprFloatError _ANSI_ARGS_((Tcl_Interp *interp,
01607                             double value));
01608 EXTERN int              TclFileAttrsCmd _ANSI_ARGS_((Tcl_Interp *interp,
01609                             int objc, Tcl_Obj *CONST objv[]));
01610 EXTERN int              TclFileCopyCmd _ANSI_ARGS_((Tcl_Interp *interp, 
01611                             int argc, char **argv)) ;
01612 EXTERN int              TclFileDeleteCmd _ANSI_ARGS_((Tcl_Interp *interp,
01613                             int argc, char **argv));
01614 EXTERN int              TclFileMakeDirsCmd _ANSI_ARGS_((Tcl_Interp *interp,
01615                             int argc, char **argv)) ;
01616 EXTERN int              TclFileRenameCmd _ANSI_ARGS_((Tcl_Interp *interp,
01617                             int argc, char **argv)) ;
01618 EXTERN void             TclFinalizeAllocSubsystem _ANSI_ARGS_((void));
01619 EXTERN void             TclFinalizeCompExecEnv _ANSI_ARGS_((void));
01620 EXTERN void             TclFinalizeCompilation _ANSI_ARGS_((void));
01621 EXTERN void             TclFinalizeEncodingSubsystem _ANSI_ARGS_((void));
01622 EXTERN void             TclFinalizeEnvironment _ANSI_ARGS_((void));
01623 EXTERN void             TclFinalizeExecution _ANSI_ARGS_((void));
01624 EXTERN void             TclFinalizeIOSubsystem _ANSI_ARGS_((void));
01625 EXTERN void             TclFinalizeLoad _ANSI_ARGS_((void));
01626 EXTERN void             TclFinalizeMemorySubsystem _ANSI_ARGS_((void));
01627 EXTERN void             TclFinalizeNotifier _ANSI_ARGS_((void));
01628 EXTERN void             TclFinalizeSynchronization _ANSI_ARGS_((void));
01629 EXTERN void             TclFinalizeThreadData _ANSI_ARGS_((void));
01630 EXTERN void             TclFindEncodings _ANSI_ARGS_((CONST char *argv0));
01631 EXTERN Proc *           TclFindProc _ANSI_ARGS_((Interp *iPtr,
01632                             char *procName));
01633 EXTERN int              TclFormatInt _ANSI_ARGS_((char *buffer, long n));
01634 EXTERN void             TclFreePackageInfo _ANSI_ARGS_((Interp *iPtr));
01635 EXTERN int              TclGetDate _ANSI_ARGS_((char *p,
01636                             unsigned long now, long zone,
01637                             unsigned long *timePtr));
01638 EXTERN Tcl_Obj *        TclGetElementOfIndexedArray _ANSI_ARGS_((
01639                             Tcl_Interp *interp, int localIndex,
01640                             Tcl_Obj *elemPtr, int leaveErrorMsg));
01641 EXTERN char *           TclGetExtension _ANSI_ARGS_((char *name));
01642 EXTERN int              TclGetFrame _ANSI_ARGS_((Tcl_Interp *interp,
01643                             char *string, CallFrame **framePtrPtr));
01644 EXTERN TclCmdProcType   TclGetInterpProc _ANSI_ARGS_((void));
01645 EXTERN int              TclGetIntForIndex _ANSI_ARGS_((Tcl_Interp *interp,
01646                             Tcl_Obj *objPtr, int endValue, int *indexPtr));
01647 EXTERN Tcl_Obj *        TclGetIndexedScalar _ANSI_ARGS_((Tcl_Interp *interp,
01648                             int localIndex, int leaveErrorMsg));
01649 EXTERN int              TclGetLong _ANSI_ARGS_((Tcl_Interp *interp,
01650                             char *string, long *longPtr));
01651 EXTERN int              TclGetLoadedPackages _ANSI_ARGS_((
01652                             Tcl_Interp *interp, char *targetName));
01653 EXTERN int              TclGetNamespaceForQualName _ANSI_ARGS_((
01654                             Tcl_Interp *interp, char *qualName,
01655                             Namespace *cxtNsPtr, int flags,
01656                             Namespace **nsPtrPtr, Namespace **altNsPtrPtr,
01657                             Namespace **actualCxtPtrPtr,
01658                             char **simpleNamePtr));
01659 EXTERN TclObjCmdProcType TclGetObjInterpProc _ANSI_ARGS_((void));
01660 EXTERN int              TclGetOpenMode _ANSI_ARGS_((Tcl_Interp *interp,
01661                             char *string, int *seekFlagPtr));
01662 EXTERN Tcl_Command      TclGetOriginalCommand _ANSI_ARGS_((
01663                             Tcl_Command command));
01664 EXTERN int              TclGlob _ANSI_ARGS_((Tcl_Interp *interp,
01665                             char *pattern, char *unquotedPrefix, 
01666                             int globFlags, GlobTypeData* types));
01667 EXTERN int              TclGlobalInvoke _ANSI_ARGS_((Tcl_Interp *interp,
01668                             int argc, char **argv, int flags));
01669 EXTERN int              TclGuessPackageName _ANSI_ARGS_((char *fileName,
01670                             Tcl_DString *bufPtr));
01671 EXTERN int              TclHideUnsafeCommands _ANSI_ARGS_((
01672                             Tcl_Interp *interp));
01673 EXTERN int              TclInExit _ANSI_ARGS_((void));
01674 EXTERN Tcl_Obj *        TclIncrElementOfIndexedArray _ANSI_ARGS_((
01675                             Tcl_Interp *interp, int localIndex,
01676                             Tcl_Obj *elemPtr, long incrAmount));
01677 EXTERN Tcl_Obj *        TclIncrIndexedScalar _ANSI_ARGS_((
01678                             Tcl_Interp *interp, int localIndex,
01679                             long incrAmount));
01680 EXTERN Tcl_Obj *        TclIncrVar2 _ANSI_ARGS_((Tcl_Interp *interp,
01681                             Tcl_Obj *part1Ptr, Tcl_Obj *part2Ptr,
01682                             long incrAmount, int flags));
01683 EXTERN void             TclInitAlloc _ANSI_ARGS_((void));
01684 EXTERN void             TclInitCompiledLocals _ANSI_ARGS_((
01685                             Tcl_Interp *interp, CallFrame *framePtr,
01686                             Namespace *nsPtr));
01687 EXTERN void             TclInitDbCkalloc _ANSI_ARGS_((void));
01688 EXTERN void             TclInitEncodingSubsystem _ANSI_ARGS_((void));
01689 EXTERN void             TclInitIOSubsystem _ANSI_ARGS_((void));
01690 EXTERN void             TclInitNamespaceSubsystem _ANSI_ARGS_((void));
01691 EXTERN void             TclInitNotifier _ANSI_ARGS_((void));
01692 EXTERN void             TclInitObjSubsystem _ANSI_ARGS_((void));
01693 EXTERN void             TclInitSubsystems _ANSI_ARGS_((CONST char *argv0));
01694 EXTERN int              TclInvoke _ANSI_ARGS_((Tcl_Interp *interp,
01695                             int argc, char **argv, int flags));
01696 EXTERN int              TclInvokeObjectCommand _ANSI_ARGS_((
01697                             ClientData clientData, Tcl_Interp *interp,
01698                             int argc, char **argv));
01699 EXTERN int              TclInvokeStringCommand _ANSI_ARGS_((
01700                             ClientData clientData, Tcl_Interp *interp,
01701                             int objc, Tcl_Obj *CONST objv[]));
01702 EXTERN int              TclIsLocalScalar _ANSI_ARGS_((CONST char *src,
01703                             int len));
01704 EXTERN Proc *           TclIsProc _ANSI_ARGS_((Command *cmdPtr));
01705 EXTERN Var *            TclLookupVar _ANSI_ARGS_((Tcl_Interp *interp,
01706                             char *part1, char *part2, int flags, char *msg,
01707                             int createPart1, int createPart2,
01708                             Var **arrayPtrPtr));
01709 EXTERN int              TclMathInProgress _ANSI_ARGS_((void));
01710 EXTERN int              TclNeedSpace _ANSI_ARGS_((char *start, char *end));
01711 EXTERN Tcl_Obj *        TclNewProcBodyObj _ANSI_ARGS_((Proc *procPtr));
01712 EXTERN int              TclObjCommandComplete _ANSI_ARGS_((Tcl_Obj *cmdPtr));
01713 EXTERN int              TclObjInterpProc _ANSI_ARGS_((ClientData clientData,
01714                             Tcl_Interp *interp, int objc,
01715                             Tcl_Obj *CONST objv[]));
01716 EXTERN int              TclObjInvoke _ANSI_ARGS_((Tcl_Interp *interp,
01717                             int objc, Tcl_Obj *CONST objv[], int flags));
01718 EXTERN int              TclObjInvokeGlobal _ANSI_ARGS_((Tcl_Interp *interp,
01719                             int objc, Tcl_Obj *CONST objv[], int flags));
01720 EXTERN int              TclOpenFileChannelDeleteProc _ANSI_ARGS_((
01721                             TclOpenFileChannelProc_ *proc));
01722 EXTERN int              TclOpenFileChannelInsertProc _ANSI_ARGS_((
01723                             TclOpenFileChannelProc_ *proc));
01724 EXTERN int              TclpAccess _ANSI_ARGS_((CONST char *filename,
01725                             int mode));
01726 EXTERN char *           TclpAlloc _ANSI_ARGS_((unsigned int size));
01727 EXTERN int              TclpCheckStackSpace _ANSI_ARGS_((void));
01728 EXTERN int              TclpCopyFile _ANSI_ARGS_((CONST char *source,
01729                             CONST char *dest));
01730 EXTERN int              TclpCopyDirectory _ANSI_ARGS_((CONST char *source,
01731                             CONST char *dest, Tcl_DString *errorPtr));
01732 EXTERN int              TclpCreateDirectory _ANSI_ARGS_((CONST char *path));
01733 EXTERN int              TclpDeleteFile _ANSI_ARGS_((CONST char *path));
01734 EXTERN void             TclpExit _ANSI_ARGS_((int status));
01735 EXTERN void             TclpFinalizeCondition _ANSI_ARGS_((
01736                             Tcl_Condition *condPtr));
01737 EXTERN void             TclpFinalizeMutex _ANSI_ARGS_((Tcl_Mutex *mutexPtr));
01738 EXTERN void             TclpFinalizeThreadData _ANSI_ARGS_((
01739                             Tcl_ThreadDataKey *keyPtr));
01740 EXTERN void             TclpFinalizeThreadDataKey _ANSI_ARGS_((
01741                             Tcl_ThreadDataKey *keyPtr));
01742 EXTERN char *           TclpFindExecutable _ANSI_ARGS_((
01743                             CONST char *argv0));
01744 EXTERN int              TclpFindVariable _ANSI_ARGS_((CONST char *name,
01745                             int *lengthPtr));
01746 EXTERN void             TclpFree _ANSI_ARGS_((char *ptr));
01747 EXTERN unsigned long    TclpGetClicks _ANSI_ARGS_((void));
01748 EXTERN Tcl_Channel      TclpGetDefaultStdChannel _ANSI_ARGS_((int type));
01749 EXTERN unsigned long    TclpGetSeconds _ANSI_ARGS_((void));
01750 EXTERN void             TclpGetTime _ANSI_ARGS_((Tcl_Time *time));
01751 EXTERN int              TclpGetTimeZone _ANSI_ARGS_((unsigned long time));
01752 EXTERN char *           TclpGetUserHome _ANSI_ARGS_((CONST char *name,
01753                             Tcl_DString *bufferPtr));
01754 EXTERN int              TclpHasSockets _ANSI_ARGS_((Tcl_Interp *interp));
01755 EXTERN void             TclpInitLibraryPath _ANSI_ARGS_((CONST char *argv0));
01756 EXTERN void             TclpInitLock _ANSI_ARGS_((void));
01757 EXTERN void             TclpInitPlatform _ANSI_ARGS_((void));
01758 EXTERN void             TclpInitUnlock _ANSI_ARGS_((void));
01759 EXTERN int              TclpListVolumes _ANSI_ARGS_((Tcl_Interp *interp));
01760 EXTERN void             TclpMasterLock _ANSI_ARGS_((void));
01761 EXTERN void             TclpMasterUnlock _ANSI_ARGS_((void));
01762 EXTERN int              TclpMatchFiles _ANSI_ARGS_((Tcl_Interp *interp,
01763                             char *separators, Tcl_DString *dirPtr,
01764                             char *pattern, char *tail));
01765 EXTERN Tcl_Channel      TclpOpenFileChannel _ANSI_ARGS_((Tcl_Interp *interp,
01766                             char *fileName, char *modeString,
01767                             int permissions));
01768 EXTERN char *           TclpReadlink _ANSI_ARGS_((CONST char *fileName,
01769                             Tcl_DString *linkPtr));
01770 EXTERN char *           TclpRealloc _ANSI_ARGS_((char *ptr,
01771                             unsigned int size));
01772 EXTERN void             TclpReleaseFile _ANSI_ARGS_((TclFile file));
01773 EXTERN int              TclpRemoveDirectory _ANSI_ARGS_((CONST char *path,
01774                             int recursive, Tcl_DString *errorPtr));
01775 EXTERN int              TclpRenameFile _ANSI_ARGS_((CONST char *source,
01776                             CONST char *dest));
01777 EXTERN void             TclpSetInitialEncodings _ANSI_ARGS_((void));
01778 EXTERN void             TclpSetVariables _ANSI_ARGS_((Tcl_Interp *interp));
01779 EXTERN VOID *           TclpSysAlloc _ANSI_ARGS_((long size, int isBin));
01780 EXTERN void             TclpSysFree _ANSI_ARGS_((VOID *ptr));
01781 EXTERN VOID *           TclpSysRealloc _ANSI_ARGS_((VOID *cp,
01782                             unsigned int size));
01783 EXTERN void             TclpUnloadFile _ANSI_ARGS_((ClientData clientData));
01784 EXTERN char *           TclPrecTraceProc _ANSI_ARGS_((ClientData clientData,
01785                             Tcl_Interp *interp, char *name1, char *name2,
01786                             int flags));
01787 EXTERN int              TclPreventAliasLoop _ANSI_ARGS_((Tcl_Interp *interp,
01788                             Tcl_Interp *cmdInterp, Tcl_Command cmd));
01789 EXTERN void             TclProcCleanupProc _ANSI_ARGS_((Proc *procPtr));
01790 EXTERN int              TclProcCompileProc _ANSI_ARGS_((Tcl_Interp *interp,
01791                             Proc *procPtr, Tcl_Obj *bodyPtr, Namespace *nsPtr,
01792                             CONST char *description, CONST char *procName));
01793 EXTERN void             TclProcDeleteProc _ANSI_ARGS_((ClientData clientData));
01794 EXTERN int              TclProcInterpProc _ANSI_ARGS_((ClientData clientData,
01795                             Tcl_Interp *interp, int argc, char **argv));
01796 EXTERN VOID *           TclpThreadDataKeyGet _ANSI_ARGS_((
01797                             Tcl_ThreadDataKey *keyPtr));
01798 EXTERN void             TclpThreadDataKeyInit _ANSI_ARGS_((
01799                             Tcl_ThreadDataKey *keyPtr));
01800 EXTERN void             TclpThreadDataKeySet _ANSI_ARGS_((
01801                             Tcl_ThreadDataKey *keyPtr, VOID *data));
01802 EXTERN void             TclpThreadExit _ANSI_ARGS_((int status));
01803 EXTERN void             TclRememberCondition _ANSI_ARGS_((Tcl_Condition *mutex));
01804 EXTERN void             TclRememberDataKey _ANSI_ARGS_((Tcl_ThreadDataKey *mutex));
01805 EXTERN void             TclRememberMutex _ANSI_ARGS_((Tcl_Mutex *mutex));
01806 EXTERN int              TclRenameCommand _ANSI_ARGS_((Tcl_Interp *interp,
01807                             char *oldName, char *newName)) ;
01808 EXTERN void             TclResetShadowedCmdRefs _ANSI_ARGS_((
01809                             Tcl_Interp *interp, Command *newCmdPtr));
01810 EXTERN int              TclServiceIdle _ANSI_ARGS_((void));
01811 EXTERN Tcl_Obj *        TclSetElementOfIndexedArray _ANSI_ARGS_((
01812                             Tcl_Interp *interp, int localIndex,
01813                             Tcl_Obj *elemPtr, Tcl_Obj *objPtr,
01814                             int leaveErrorMsg));
01815 EXTERN Tcl_Obj *        TclSetIndexedScalar _ANSI_ARGS_((Tcl_Interp *interp,
01816                             int localIndex, Tcl_Obj *objPtr,
01817                             int leaveErrorMsg));
01818 EXTERN char *           TclSetPreInitScript _ANSI_ARGS_((char *string));
01819 EXTERN void             TclSetupEnv _ANSI_ARGS_((Tcl_Interp *interp));
01820 EXTERN int              TclSockGetPort _ANSI_ARGS_((Tcl_Interp *interp,
01821                             char *string, char *proto, int *portPtr));
01822 EXTERN int              TclSockMinimumBuffers _ANSI_ARGS_((int sock,
01823                             int size));
01824 EXTERN int              TclStat _ANSI_ARGS_((CONST char *path,
01825                             struct stat *buf));
01826 EXTERN int              TclStatDeleteProc _ANSI_ARGS_((TclStatProc_ *proc));
01827 EXTERN int              TclStatInsertProc _ANSI_ARGS_((TclStatProc_ *proc));
01828 EXTERN void             TclTeardownNamespace _ANSI_ARGS_((Namespace *nsPtr));
01829 EXTERN void             TclTransferResult _ANSI_ARGS_((Tcl_Interp *sourceInterp,
01830                             int result, Tcl_Interp *targetInterp));
01831 EXTERN int              TclUpdateReturnInfo _ANSI_ARGS_((Interp *iPtr));
01832 
01833 /*
01834  *----------------------------------------------------------------
01835  * Command procedures in the generic core:
01836  *----------------------------------------------------------------
01837  */
01838 
01839 EXTERN int      Tcl_AfterObjCmd _ANSI_ARGS_((ClientData clientData,
01840                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01841 EXTERN int      Tcl_AppendObjCmd _ANSI_ARGS_((ClientData clientData,
01842                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01843 EXTERN int      Tcl_ArrayObjCmd _ANSI_ARGS_((ClientData clientData,
01844                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01845 EXTERN int      Tcl_BinaryObjCmd _ANSI_ARGS_((ClientData clientData,
01846                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01847 EXTERN int      Tcl_BreakObjCmd _ANSI_ARGS_((ClientData clientData,
01848                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01849 EXTERN int      Tcl_CaseObjCmd _ANSI_ARGS_((ClientData clientData,
01850                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01851 EXTERN int      Tcl_CatchObjCmd _ANSI_ARGS_((ClientData clientData,
01852                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01853 EXTERN int      Tcl_CdObjCmd _ANSI_ARGS_((ClientData clientData,
01854                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01855 EXTERN int      Tcl_ClockObjCmd _ANSI_ARGS_((ClientData clientData,
01856                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01857 EXTERN int      Tcl_CloseObjCmd _ANSI_ARGS_((ClientData clientData,
01858                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01859 EXTERN int      Tcl_ConcatObjCmd _ANSI_ARGS_((ClientData clientData,
01860                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01861 EXTERN int      Tcl_ContinueObjCmd _ANSI_ARGS_((ClientData clientData,
01862                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01863 EXTERN int      Tcl_EncodingObjCmd _ANSI_ARGS_((ClientData clientData,
01864                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01865 EXTERN int      Tcl_EofObjCmd _ANSI_ARGS_((ClientData clientData,
01866                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01867 EXTERN int      Tcl_ErrorObjCmd _ANSI_ARGS_((ClientData clientData,
01868                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01869 EXTERN int      Tcl_EvalObjCmd _ANSI_ARGS_((ClientData clientData,
01870                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01871 EXTERN int      Tcl_ExecObjCmd _ANSI_ARGS_((ClientData clientData,
01872                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01873 EXTERN int      Tcl_ExitObjCmd _ANSI_ARGS_((ClientData clientData,
01874                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01875 EXTERN int      Tcl_ExprObjCmd _ANSI_ARGS_((ClientData clientData,
01876                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01877 EXTERN int      Tcl_FblockedObjCmd _ANSI_ARGS_((ClientData clientData,
01878                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01879 EXTERN int      Tcl_FconfigureObjCmd _ANSI_ARGS_((ClientData clientData,
01880                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01881 EXTERN int      Tcl_FcopyObjCmd _ANSI_ARGS_((ClientData dummy,
01882                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01883 EXTERN int      Tcl_FileObjCmd _ANSI_ARGS_((ClientData dummy,
01884                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01885 EXTERN int      Tcl_FileEventObjCmd _ANSI_ARGS_((ClientData clientData,
01886                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01887 EXTERN int      Tcl_FlushObjCmd _ANSI_ARGS_((ClientData clientData,
01888                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01889 EXTERN int      Tcl_ForObjCmd _ANSI_ARGS_((ClientData clientData,
01890                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01891 EXTERN int      Tcl_ForeachObjCmd _ANSI_ARGS_((ClientData clientData,
01892                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01893 EXTERN int      Tcl_FormatObjCmd _ANSI_ARGS_((ClientData dummy,
01894                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01895 EXTERN int      Tcl_GetsObjCmd _ANSI_ARGS_((ClientData clientData,
01896                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01897 EXTERN int      Tcl_GlobalObjCmd _ANSI_ARGS_((ClientData clientData,
01898                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01899 EXTERN int      Tcl_GlobObjCmd _ANSI_ARGS_((ClientData clientData,
01900                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01901 EXTERN int      Tcl_IfObjCmd _ANSI_ARGS_((ClientData clientData,
01902                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01903 EXTERN int      Tcl_IncrObjCmd _ANSI_ARGS_((ClientData clientData,
01904                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01905 EXTERN int      Tcl_InfoObjCmd _ANSI_ARGS_((ClientData clientData,
01906                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01907 EXTERN int      Tcl_InterpObjCmd _ANSI_ARGS_((ClientData clientData,
01908                     Tcl_Interp *interp, int argc, Tcl_Obj *CONST objv[]));
01909 EXTERN int      Tcl_JoinObjCmd _ANSI_ARGS_((ClientData clientData,
01910                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01911 EXTERN int      Tcl_LappendObjCmd _ANSI_ARGS_((ClientData clientData,
01912                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01913 EXTERN int      Tcl_LindexObjCmd _ANSI_ARGS_((ClientData clientData,
01914                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01915 EXTERN int      Tcl_LinsertObjCmd _ANSI_ARGS_((ClientData clientData,
01916                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01917 EXTERN int      Tcl_LlengthObjCmd _ANSI_ARGS_((ClientData clientData,
01918                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01919 EXTERN int      Tcl_ListObjCmd _ANSI_ARGS_((ClientData clientData,
01920                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01921 EXTERN int      Tcl_LoadObjCmd _ANSI_ARGS_((ClientData clientData,
01922                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01923 EXTERN int      Tcl_LrangeObjCmd _ANSI_ARGS_((ClientData clientData,
01924                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01925 EXTERN int      Tcl_LreplaceObjCmd _ANSI_ARGS_((ClientData clientData,
01926                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01927 EXTERN int      Tcl_LsearchObjCmd _ANSI_ARGS_((ClientData clientData,
01928                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01929 EXTERN int      Tcl_LsortObjCmd _ANSI_ARGS_((ClientData clientData,
01930                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01931 EXTERN int      Tcl_NamespaceObjCmd _ANSI_ARGS_((ClientData clientData,
01932                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01933 EXTERN int      Tcl_OpenObjCmd _ANSI_ARGS_((ClientData clientData,
01934                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01935 EXTERN int      Tcl_PackageObjCmd _ANSI_ARGS_((ClientData clientData,
01936                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01937 EXTERN int      Tcl_PidObjCmd _ANSI_ARGS_((ClientData clientData,
01938                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01939 EXTERN int      Tcl_PutsObjCmd _ANSI_ARGS_((ClientData clientData,
01940                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01941 EXTERN int      Tcl_PwdObjCmd _ANSI_ARGS_((ClientData clientData,
01942                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01943 EXTERN int      Tcl_ReadObjCmd _ANSI_ARGS_((ClientData clientData,
01944                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01945 EXTERN int      Tcl_RegexpObjCmd _ANSI_ARGS_((ClientData clientData,
01946                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01947 EXTERN int      Tcl_RegsubObjCmd _ANSI_ARGS_((ClientData clientData,
01948                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01949 EXTERN int      Tcl_RenameObjCmd _ANSI_ARGS_((ClientData clientData,
01950                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01951 EXTERN int      Tcl_ReturnObjCmd _ANSI_ARGS_((ClientData clientData,
01952                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01953 EXTERN int      Tcl_ScanObjCmd _ANSI_ARGS_((ClientData clientData,
01954                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01955 EXTERN int      Tcl_SeekObjCmd _ANSI_ARGS_((ClientData clientData,
01956                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01957 EXTERN int      Tcl_SetObjCmd _ANSI_ARGS_((ClientData clientData,
01958                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01959 EXTERN int      Tcl_SplitObjCmd _ANSI_ARGS_((ClientData clientData,
01960                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01961 EXTERN int      Tcl_SocketObjCmd _ANSI_ARGS_((ClientData clientData,
01962                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01963 EXTERN int      Tcl_SourceObjCmd _ANSI_ARGS_((ClientData clientData,
01964                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01965 EXTERN int      Tcl_StringObjCmd _ANSI_ARGS_((ClientData clientData,
01966                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01967 EXTERN int      Tcl_SubstObjCmd _ANSI_ARGS_((ClientData clientData,
01968                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01969 EXTERN int      Tcl_SwitchObjCmd _ANSI_ARGS_((ClientData clientData,
01970                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01971 EXTERN int      Tcl_TellObjCmd _ANSI_ARGS_((ClientData clientData,
01972                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01973 EXTERN int      Tcl_TimeObjCmd _ANSI_ARGS_((ClientData clientData,
01974                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01975 EXTERN int      Tcl_TraceObjCmd _ANSI_ARGS_((ClientData clientData,
01976                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01977 EXTERN int      Tcl_UnsetObjCmd _ANSI_ARGS_((ClientData clientData,
01978                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01979 EXTERN int      Tcl_UpdateObjCmd _ANSI_ARGS_((ClientData clientData,
01980                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01981 EXTERN int      Tcl_UplevelObjCmd _ANSI_ARGS_((ClientData clientData,
01982                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01983 EXTERN int      Tcl_UpvarObjCmd _ANSI_ARGS_((ClientData clientData,
01984                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01985 EXTERN int      Tcl_VariableObjCmd _ANSI_ARGS_((ClientData clientData,
01986                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01987 EXTERN int      Tcl_VwaitObjCmd _ANSI_ARGS_((ClientData clientData,
01988                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01989 EXTERN int      Tcl_WhileObjCmd _ANSI_ARGS_((ClientData clientData,
01990                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
01991 
01992 /*
01993  *----------------------------------------------------------------
01994  * Command procedures found only in the Mac version of the core:
01995  *----------------------------------------------------------------
01996  */
01997 
01998 #ifdef MAC_TCL
01999 EXTERN int      Tcl_EchoCmd _ANSI_ARGS_((ClientData clientData,
02000                     Tcl_Interp *interp, int argc, char **argv));
02001 EXTERN int      Tcl_LsObjCmd _ANSI_ARGS_((ClientData clientData,
02002                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
02003 EXTERN int      Tcl_BeepObjCmd _ANSI_ARGS_((ClientData clientData,
02004                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
02005 EXTERN int      Tcl_MacSourceObjCmd _ANSI_ARGS_((ClientData clientData,
02006                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
02007 EXTERN int      Tcl_ResourceObjCmd _ANSI_ARGS_((ClientData clientData,
02008                     Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
02009 #endif
02010 
02011 /*
02012  *----------------------------------------------------------------
02013  * Compilation procedures for commands in the generic core:
02014  *----------------------------------------------------------------
02015  */
02016 
02017 EXTERN int      TclCompileBreakCmd _ANSI_ARGS_((Tcl_Interp *interp,
02018                     Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
02019 EXTERN int      TclCompileCatchCmd _ANSI_ARGS_((Tcl_Interp *interp,
02020                     Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
02021 EXTERN int      TclCompileContinueCmd _ANSI_ARGS_((Tcl_Interp *interp,
02022                     Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
02023 EXTERN int      TclCompileExprCmd _ANSI_ARGS_((Tcl_Interp *interp,
02024                     Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
02025 EXTERN int      TclCompileForCmd _ANSI_ARGS_((Tcl_Interp *interp,
02026                     Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
02027 EXTERN int      TclCompileForeachCmd _ANSI_ARGS_((Tcl_Interp *interp,
02028                     Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
02029 EXTERN int      TclCompileIfCmd _ANSI_ARGS_((Tcl_Interp *interp,
02030                     Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
02031 EXTERN int      TclCompileIncrCmd _ANSI_ARGS_((Tcl_Interp *interp,
02032                     Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
02033 EXTERN int      TclCompileSetCmd _ANSI_ARGS_((Tcl_Interp *interp,
02034                     Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
02035 EXTERN int      TclCompileWhileCmd _ANSI_ARGS_((Tcl_Interp *interp,
02036                     Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
02037 
02038 /*
02039  *----------------------------------------------------------------
02040  * Macros used by the Tcl core to create and release Tcl objects.
02041  * TclNewObj(objPtr) creates a new object denoting an empty string.
02042  * TclDecrRefCount(objPtr) decrements the object's reference count,
02043  * and frees the object if its reference count is zero.
02044  * These macros are inline versions of Tcl_NewObj() and
02045  * Tcl_DecrRefCount(). Notice that the names differ in not having
02046  * a "_" after the "Tcl". Notice also that these macros reference
02047  * their argument more than once, so you should avoid calling them
02048  * with an expression that is expensive to compute or has
02049  * side effects. The ANSI C "prototypes" for these macros are:
02050  *
02051  * EXTERN void  TclNewObj _ANSI_ARGS_((Tcl_Obj *objPtr));
02052  * EXTERN void  TclDecrRefCount _ANSI_ARGS_((Tcl_Obj *objPtr));
02053  *----------------------------------------------------------------
02054  */
02055 
02056 #ifdef TCL_COMPILE_STATS
02057 #  define TclIncrObjsAllocated() \
02058     tclObjsAlloced++
02059 #  define TclIncrObjsFreed() \
02060     tclObjsFreed++
02061 #else
02062 #  define TclIncrObjsAllocated()
02063 #  define TclIncrObjsFreed()
02064 #endif /* TCL_COMPILE_STATS */
02065 
02066 #ifdef TCL_MEM_DEBUG
02067 #  define TclNewObj(objPtr) \
02068     (objPtr) = (Tcl_Obj *) \
02069          Tcl_DbCkalloc(sizeof(Tcl_Obj), __FILE__, __LINE__); \
02070     (objPtr)->refCount = 0; \
02071     (objPtr)->bytes    = tclEmptyStringRep; \
02072     (objPtr)->length   = 0; \
02073     (objPtr)->typePtr  = NULL; \
02074     TclIncrObjsAllocated()
02075      
02076 #  define TclDbNewObj(objPtr, file, line) \
02077     (objPtr) = (Tcl_Obj *) Tcl_DbCkalloc(sizeof(Tcl_Obj), (file), (line)); \
02078     (objPtr)->refCount = 0; \
02079     (objPtr)->bytes    = tclEmptyStringRep; \
02080     (objPtr)->length   = 0; \
02081     (objPtr)->typePtr  = NULL; \
02082     TclIncrObjsAllocated()
02083      
02084 #  define TclDecrRefCount(objPtr) \
02085     if (--(objPtr)->refCount <= 0) { \
02086         if ((objPtr)->refCount < -1) \
02087             panic("Reference count for %lx was negative: %s line %d", \
02088                   (objPtr), __FILE__, __LINE__); \
02089         if (((objPtr)->bytes != NULL) \
02090                 && ((objPtr)->bytes != tclEmptyStringRep)) { \
02091             ckfree((char *) (objPtr)->bytes); \
02092         } \
02093         if (((objPtr)->typePtr != NULL) \
02094                 && ((objPtr)->typePtr->freeIntRepProc != NULL)) { \
02095             (objPtr)->typePtr->freeIntRepProc(objPtr); \
02096         } \
02097         ckfree((char *) (objPtr)); \
02098         TclIncrObjsFreed(); \
02099     }
02100 
02101 #else /* not TCL_MEM_DEBUG */
02102 
02103 #ifdef TCL_THREADS
02104 extern Tcl_Mutex tclObjMutex;
02105 #endif
02106 
02107 #  define TclNewObj(objPtr) \
02108     Tcl_MutexLock(&tclObjMutex); \
02109     if (tclFreeObjList == NULL) { \
02110         TclAllocateFreeObjects(); \
02111     } \
02112     (objPtr) = tclFreeObjList; \
02113     tclFreeObjList = (Tcl_Obj *) \
02114         tclFreeObjList->internalRep.otherValuePtr; \
02115     (objPtr)->refCount = 0; \
02116     (objPtr)->bytes    = tclEmptyStringRep; \
02117     (objPtr)->length   = 0; \
02118     (objPtr)->typePtr  = NULL; \
02119     TclIncrObjsAllocated(); \
02120     Tcl_MutexUnlock(&tclObjMutex)
02121 
02122 #  define TclDecrRefCount(objPtr) \
02123     if (--(objPtr)->refCount <= 0) { \
02124         if (((objPtr)->bytes != NULL) \
02125                 && ((objPtr)->bytes != tclEmptyStringRep)) { \
02126             ckfree((char *) (objPtr)->bytes); \
02127         } \
02128         if (((objPtr)->typePtr != NULL) \
02129                 && ((objPtr)->typePtr->freeIntRepProc != NULL)) { \
02130             (objPtr)->typePtr->freeIntRepProc(objPtr); \
02131         } \
02132         Tcl_MutexLock(&tclObjMutex); \
02133         (objPtr)->internalRep.otherValuePtr = (VOID *) tclFreeObjList; \
02134         tclFreeObjList = (objPtr); \
02135         TclIncrObjsFreed(); \
02136         Tcl_MutexUnlock(&tclObjMutex); \
02137     }
02138 #endif /* TCL_MEM_DEBUG */
02139 
02140 /*
02141  *----------------------------------------------------------------
02142  * Macro used by the Tcl core to set a Tcl_Obj's string representation
02143  * to a copy of the "len" bytes starting at "bytePtr". This code
02144  * works even if the byte array contains NULLs as long as the length
02145  * is correct. Because "len" is referenced multiple times, it should
02146  * be as simple an expression as possible. The ANSI C "prototype" for
02147  * this macro is:
02148  *
02149  * EXTERN void  TclInitStringRep _ANSI_ARGS_((Tcl_Obj *objPtr,
02150  *                  char *bytePtr, int len));
02151  *----------------------------------------------------------------
02152  */
02153 
02154 #define TclInitStringRep(objPtr, bytePtr, len) \
02155     if ((len) == 0) { \
02156         (objPtr)->bytes  = tclEmptyStringRep; \
02157         (objPtr)->length = 0; \
02158     } else { \
02159         (objPtr)->bytes = (char *) ckalloc((unsigned) ((len) + 1)); \
02160         memcpy((VOID *) (objPtr)->bytes, (VOID *) (bytePtr), \
02161                 (unsigned) (len)); \
02162         (objPtr)->bytes[len] = '\0'; \
02163         (objPtr)->length = (len); \
02164     }
02165 
02166 /*
02167  *----------------------------------------------------------------
02168  * Macro used by the Tcl core to get the string representation's
02169  * byte array pointer from a Tcl_Obj. This is an inline version
02170  * of Tcl_GetString(). The macro's expression result is the string
02171  * rep's byte pointer which might be NULL. The bytes referenced by 
02172  * this pointer must not be modified by the caller.
02173  * The ANSI C "prototype" for this macro is:
02174  *
02175  * EXTERN char *  TclGetString _ANSI_ARGS_((Tcl_Obj *objPtr));
02176  *----------------------------------------------------------------
02177  */
02178 
02179 #define TclGetString(objPtr) \
02180     ((objPtr)->bytes? (objPtr)->bytes : Tcl_GetString((objPtr)))
02181 
02182 #include "tclIntDecls.h"
02183 
02184 # undef TCL_STORAGE_CLASS
02185 # define TCL_STORAGE_CLASS DLLIMPORT
02186 
02187 #endif /* _TCLINT */
02188 

Generated on Mon Oct 23 15:05:31 2006 for OpenSees by doxygen 1.5.0