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

Generated on Mon Sep 18 01:24:44 2006 for BRL-CAD by  doxygen 1.4.6