home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tcltk805.zip / tcl805s.zip / tcl8.0.5 / os2 / tclInt.h < prev    next >
C/C++ Source or Header  |  1999-04-23  |  89KB  |  2,149 lines

  1. /*
  2.  * tclInt.h --
  3.  *
  4.  *    Declarations of things used internally by the Tcl interpreter.
  5.  *
  6.  * Copyright (c) 1987-1993 The Regents of the University of California.
  7.  * Copyright (c) 1994-1997 Sun Microsystems, Inc.
  8.  * Copyright (c) 1993-1997 Lucent Technologies.
  9.  * Copyright (c) 1998-1999 by Scriptics Corporation.
  10.  *
  11.  * See the file "license.terms" for information on usage and redistribution
  12.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  13.  *
  14.  * RCS: @(#) $Id: tclInt.h,v 1.23 1999/02/03 21:28:00 stanton Exp $
  15.  */
  16.  
  17. #ifndef _TCLINT
  18. #define _TCLINT
  19.  
  20. /*
  21.  * Common include files needed by most of the Tcl source files are
  22.  * included here, so that system-dependent personalizations for the
  23.  * include files only have to be made in once place.  This results
  24.  * in a few extra includes, but greater modularity.  The order of
  25.  * the three groups of #includes is important.    For example, stdio.h
  26.  * is needed by tcl.h, and the _ANSI_ARGS_ declaration in tcl.h is
  27.  * needed by stdlib.h in some configurations.
  28.  */
  29.  
  30. #include <stdio.h>
  31.  
  32. #ifndef _TCL
  33. #include "tcl.h"
  34. #endif
  35. #ifndef _REGEXP
  36. #include "tclRegexp.h"
  37. #endif
  38.  
  39. #include <ctype.h>
  40. #ifdef NO_LIMITS_H
  41. #   include "../compat/limits.h"
  42. #else
  43. #   include <limits.h>
  44. #endif
  45. #ifdef NO_STDLIB_H
  46. #   include "../compat/stdlib.h"
  47. #else
  48. #   include <stdlib.h>
  49. #endif
  50. #ifdef NO_STRING_H
  51. #include "../compat/string.h"
  52. #else
  53. #include <string.h>
  54. #endif
  55. #if defined(__STDC__) || defined(HAS_STDARG)
  56. #   include <stdarg.h>
  57. #else
  58. #   include <varargs.h>
  59. #endif
  60.  
  61. #ifdef BUILD_tcl
  62. # undef TCL_STORAGE_CLASS
  63. # define TCL_STORAGE_CLASS DLLEXPORT
  64. #endif
  65.  
  66. /*
  67.  * The following procedures allow namespaces to be customized to
  68.  * support special name resolution rules for commands/variables.
  69.  * 
  70.  */
  71.  
  72. struct Tcl_ResolvedVarInfo;
  73.  
  74. typedef Tcl_Var (Tcl_ResolveRuntimeVarProc) _ANSI_ARGS_((
  75.     Tcl_Interp* interp, struct Tcl_ResolvedVarInfo *vinfoPtr));
  76.  
  77. typedef void (Tcl_ResolveVarDeleteProc) _ANSI_ARGS_((
  78.     struct Tcl_ResolvedVarInfo *vinfoPtr));
  79.  
  80. /*
  81.  * The following structure encapsulates the routines needed to resolve a
  82.  * variable reference at runtime.  Any variable specific state will typically
  83.  * be appended to this structure.
  84.  */
  85.  
  86.  
  87. typedef struct Tcl_ResolvedVarInfo {
  88.     Tcl_ResolveRuntimeVarProc *fetchProc;
  89.     Tcl_ResolveVarDeleteProc *deleteProc;
  90. } Tcl_ResolvedVarInfo;
  91.  
  92.  
  93.  
  94. typedef int (Tcl_ResolveCompiledVarProc) _ANSI_ARGS_((
  95.     Tcl_Interp* interp, char* name, int length,
  96.     Tcl_Namespace *context, Tcl_ResolvedVarInfo **rPtr));
  97.  
  98. typedef int (Tcl_ResolveVarProc) _ANSI_ARGS_((
  99.     Tcl_Interp* interp, char* name, Tcl_Namespace *context,
  100.     int flags, Tcl_Var *rPtr));
  101.  
  102. typedef int (Tcl_ResolveCmdProc) _ANSI_ARGS_((Tcl_Interp* interp,
  103.     char* name, Tcl_Namespace *context, int flags,
  104.     Tcl_Command *rPtr));
  105.  
  106. typedef struct Tcl_ResolverInfo {
  107.     Tcl_ResolveCmdProc *cmdResProc;    /* Procedure handling command name
  108.                      * resolution. */
  109.     Tcl_ResolveVarProc *varResProc;    /* Procedure handling variable name
  110.                      * resolution for variables that
  111.                      * can only be handled at runtime. */
  112.     Tcl_ResolveCompiledVarProc *compiledVarResProc;
  113.                     /* Procedure handling variable name
  114.                      * resolution at compile time. */
  115. } Tcl_ResolverInfo;
  116.  
  117. /*
  118.  *----------------------------------------------------------------
  119.  * Data structures related to namespaces.
  120.  *----------------------------------------------------------------
  121.  */
  122.  
  123. /*
  124.  * The structure below defines a namespace.
  125.  * Note: the first five fields must match exactly the fields in a
  126.  * Tcl_Namespace structure (see tcl.h). If you change one, be sure to
  127.  * change the other.
  128.  */
  129.  
  130. typedef struct Namespace {
  131.     char *name;             /* The namespace's simple (unqualified)
  132.                   * name. This contains no ::'s. The name of
  133.                   * the global namespace is "" although "::"
  134.                   * is an synonym. */
  135.     char *fullName;         /* The namespace's fully qualified name.
  136.                   * This starts with ::. */
  137.     ClientData clientData;     /* An arbitrary value associated with this
  138.                   * namespace. */
  139.     Tcl_NamespaceDeleteProc *deleteProc;
  140.                  /* Procedure invoked when deleting the
  141.                   * namespace to, e.g., free clientData. */
  142.     struct Namespace *parentPtr; /* Points to the namespace that contains
  143.                   * this one. NULL if this is the global
  144.                   * namespace. */
  145.     Tcl_HashTable childTable;     /* Contains any child namespaces. Indexed
  146.                   * by strings; values have type
  147.                   * (Namespace *). */
  148.     long nsId;             /* Unique id for the namespace. */
  149.     Tcl_Interp *interp;         /* The interpreter containing this
  150.                   * namespace. */
  151.     int flags;             /* OR-ed combination of the namespace
  152.                   * status flags NS_DYING and NS_DEAD
  153.                   * listed below. */
  154.     int activationCount;     /* Number of "activations" or active call
  155.                   * frames for this namespace that are on
  156.                   * the Tcl call stack. The namespace won't
  157.                   * be freed until activationCount becomes
  158.                   * zero. */
  159.     int refCount;         /* Count of references by namespaceName *
  160.                   * objects. The namespace can't be freed
  161.                   * until refCount becomes zero. */
  162.     Tcl_HashTable cmdTable;     /* Contains all the commands currently
  163.                   * registered in the namespace. Indexed by
  164.                   * strings; values have type (Command *).
  165.                   * Commands imported by Tcl_Import have
  166.                   * Command structures that point (via an
  167.                   * ImportedCmdRef structure) to the
  168.                   * Command structure in the source
  169.                   * namespace's command table. */
  170.     Tcl_HashTable varTable;     /* Contains all the (global) variables
  171.                   * currently in this namespace. Indexed
  172.                   * by strings; values have type (Var *). */
  173.     char **exportArrayPtr;     /* Points to an array of string patterns
  174.                   * specifying which commands are exported.
  175.                   * A pattern may include "string match"
  176.                   * style wildcard characters to specify
  177.                   * multiple commands; however, no namespace
  178.                   * qualifiers are allowed. NULL if no
  179.                   * export patterns are registered. */
  180.     int numExportPatterns;     /* Number of export patterns currently
  181.                   * registered using "namespace export". */
  182.     int maxExportPatterns;     /* Mumber of export patterns for which
  183.                   * space is currently allocated. */
  184.     int cmdRefEpoch;         /* Incremented if a newly added command
  185.                   * shadows a command for which this
  186.                   * namespace has already cached a Command *
  187.                   * pointer; this causes all its cached
  188.                   * Command* pointers to be invalidated. */
  189.     int resolverEpoch;         /* Incremented whenever the name resolution
  190.                   * rules change for this namespace; this
  191.                   * invalidates all byte codes compiled in
  192.                   * the namespace, causing the code to be
  193.                   * recompiled under the new rules. */
  194.     Tcl_ResolveCmdProc *cmdResProc;
  195.                  /* If non-null, this procedure overrides
  196.                   * the usual command resolution mechanism
  197.                   * in Tcl.  This procedure is invoked
  198.                   * within Tcl_FindCommand to resolve all
  199.                   * command references within the namespace. */
  200.     Tcl_ResolveVarProc *varResProc;
  201.                  /* If non-null, this procedure overrides
  202.                   * the usual variable resolution mechanism
  203.                   * in Tcl.  This procedure is invoked
  204.                   * within Tcl_FindNamespaceVar to resolve all
  205.                   * variable references within the namespace
  206.                   * at runtime. */
  207.     Tcl_ResolveCompiledVarProc *compiledVarResProc;
  208.                  /* If non-null, this procedure overrides
  209.                   * the usual variable resolution mechanism
  210.                   * in Tcl.  This procedure is invoked
  211.                   * within LookupCompiledLocal to resolve
  212.                   * variable references within the namespace
  213.                   * at compile time. */
  214. } Namespace;
  215.  
  216. /*
  217.  * Flags used to represent the status of a namespace:
  218.  *
  219.  * NS_DYING -    1 means Tcl_DeleteNamespace has been called to delete the
  220.  *        namespace but there are still active call frames on the Tcl
  221.  *        stack that refer to the namespace. When the last call frame
  222.  *        referring to it has been popped, it's variables and command
  223.  *        will be destroyed and it will be marked "dead" (NS_DEAD).
  224.  *        The namespace can no longer be looked up by name.
  225.  * NS_DEAD -    1 means Tcl_DeleteNamespace has been called to delete the
  226.  *        namespace and no call frames still refer to it. Its
  227.  *        variables and command have already been destroyed. This bit
  228.  *        allows the namespace resolution code to recognize that the
  229.  *        namespace is "deleted". When the last namespaceName object
  230.  *        in any byte code code unit that refers to the namespace has
  231.  *        been freed (i.e., when the namespace's refCount is 0), the
  232.  *        namespace's storage will be freed.
  233.  */
  234.  
  235. #define NS_DYING    0x01
  236. #define NS_DEAD        0x02
  237.  
  238. /*
  239.  * Flag passed to TclGetNamespaceForQualName to have it create all namespace
  240.  * components of a namespace-qualified name that cannot be found. The new
  241.  * namespaces are created within their specified parent. Note that this
  242.  * flag's value must not conflict with the values of the flags
  243.  * TCL_GLOBAL_ONLY, TCL_NAMESPACE_ONLY, and FIND_ONLY_NS (defined in
  244.  * tclNamesp.c).
  245.  */
  246.  
  247. #define CREATE_NS_IF_UNKNOWN 0x800
  248.  
  249. /*
  250.  *----------------------------------------------------------------
  251.  * Data structures related to variables.   These are used primarily
  252.  * in tclVar.c
  253.  *----------------------------------------------------------------
  254.  */
  255.  
  256. /*
  257.  * The following structure defines a variable trace, which is used to
  258.  * invoke a specific C procedure whenever certain operations are performed
  259.  * on a variable.
  260.  */
  261.  
  262. typedef struct VarTrace {
  263.     Tcl_VarTraceProc *traceProc;/* Procedure to call when operations given
  264.                  * by flags are performed on variable. */
  265.     ClientData clientData;    /* Argument to pass to proc. */
  266.     int flags;            /* What events the trace procedure is
  267.                  * interested in:  OR-ed combination of
  268.                  * TCL_TRACE_READS, TCL_TRACE_WRITES, and
  269.                  * TCL_TRACE_UNSETS. */
  270.     struct VarTrace *nextPtr;    /* Next in list of traces associated with
  271.                  * a particular variable. */
  272. } VarTrace;
  273.  
  274. /*
  275.  * When a variable trace is active (i.e. its associated procedure is
  276.  * executing), one of the following structures is linked into a list
  277.  * associated with the variable's interpreter.    The information in
  278.  * the structure is needed in order for Tcl to behave reasonably
  279.  * if traces are deleted while traces are active.
  280.  */
  281.  
  282. typedef struct ActiveVarTrace {
  283.     struct Var *varPtr;        /* Variable that's being traced. */
  284.     struct ActiveVarTrace *nextPtr;
  285.                 /* Next in list of all active variable
  286.                  * traces for the interpreter, or NULL
  287.                  * if no more. */
  288.     VarTrace *nextTracePtr;    /* Next trace to check after current
  289.                  * trace procedure returns;  if this
  290.                  * trace gets deleted, must update pointer
  291.                  * to avoid using free'd memory. */
  292. } ActiveVarTrace;
  293.  
  294. /*
  295.  * The following structure describes an enumerative search in progress on
  296.  * an array variable;  this are invoked with options to the "array"
  297.  * command.
  298.  */
  299.  
  300. typedef struct ArraySearch {
  301.     int id;            /* Integer id used to distinguish among
  302.                  * multiple concurrent searches for the
  303.                  * same array. */
  304.     struct Var *varPtr;        /* Pointer to array variable that's being
  305.                  * searched. */
  306.     Tcl_HashSearch search;    /* Info kept by the hash module about
  307.                  * progress through the array. */
  308.     Tcl_HashEntry *nextEntry;    /* Non-null means this is the next element
  309.                  * to be enumerated (it's leftover from
  310.                  * the Tcl_FirstHashEntry call or from
  311.                  * an "array anymore" command).     NULL
  312.                  * means must call Tcl_NextHashEntry
  313.                  * to get value to return. */
  314.     struct ArraySearch *nextPtr;/* Next in list of all active searches
  315.                  * for this variable, or NULL if this is
  316.                  * the last one. */
  317. } ArraySearch;
  318.  
  319. /*
  320.  * The structure below defines a variable, which associates a string name
  321.  * with a Tcl_Obj value. These structures are kept in procedure call frames
  322.  * (for local variables recognized by the compiler) or in the heap (for
  323.  * global variables and any variable not known to the compiler). For each
  324.  * Var structure in the heap, a hash table entry holds the variable name and
  325.  * a pointer to the Var structure.
  326.  */
  327.  
  328. typedef struct Var {
  329.     union {
  330.     Tcl_Obj *objPtr;    /* The variable's object value. Used for 
  331.                  * scalar variables and array elements. */
  332.     Tcl_HashTable *tablePtr;/* For array variables, this points to
  333.                  * information about the hash table used
  334.                  * to implement the associative array. 
  335.                  * Points to malloc-ed data. */
  336.     struct Var *linkPtr;    /* If this is a global variable being
  337.                  * referred to in a procedure, or a variable
  338.                  * created by "upvar", this field points to
  339.                  * the referenced variable's Var struct. */
  340.     } value;
  341.     char *name;            /* NULL if the variable is in a hashtable,
  342.                  * otherwise points to the variable's
  343.                  * name. It is used, e.g., by TclLookupVar
  344.                  * and "info locals". The storage for the
  345.                  * characters of the name is not owned by
  346.                  * the Var and must not be freed when
  347.                  * freeing the Var. */
  348.     Namespace *nsPtr;        /* Points to the namespace that contains
  349.                  * this variable or NULL if the variable is
  350.                  * a local variable in a Tcl procedure. */
  351.     Tcl_HashEntry *hPtr;    /* If variable is in a hashtable, either the
  352.                  * hash table entry that refers to this
  353.                  * variable or NULL if the variable has been
  354.                  * detached from its hash table (e.g. an
  355.                  * array is deleted, but some of its
  356.                  * elements are still referred to in
  357.                  * upvars). NULL if the variable is not in a
  358.                  * hashtable. This is used to delete an
  359.                  * variable from its hashtable if it is no
  360.                  * longer needed. */
  361.     int refCount;        /* Counts number of active uses of this
  362.                  * variable, not including its entry in the
  363.                  * call frame or the hash table: 1 for each
  364.                  * additional variable whose linkPtr points
  365.                  * here, 1 for each nested trace active on
  366.                  * variable, and 1 if the variable is a 
  367.                  * namespace variable. This record can't be
  368.                  * deleted until refCount becomes 0. */
  369.     VarTrace *tracePtr;        /* First in list of all traces set for this
  370.                  * variable. */
  371.     ArraySearch *searchPtr;    /* First in list of all searches active
  372.                  * for this variable, or NULL if none. */
  373.     int flags;            /* Miscellaneous bits of information about
  374.                  * variable. See below for definitions. */
  375. } Var;
  376.  
  377. /*
  378.  * Flag bits for variables. The first three (VAR_SCALAR, VAR_ARRAY, and
  379.  * VAR_LINK) are mutually exclusive and give the "type" of the variable.
  380.  * VAR_UNDEFINED is independent of the variable's type. 
  381.  *
  382.  * VAR_SCALAR -            1 means this is a scalar variable and not
  383.  *                an array or link. The "objPtr" field points
  384.  *                to the variable's value, a Tcl object.
  385.  * VAR_ARRAY -            1 means this is an array variable rather
  386.  *                than a scalar variable or link. The
  387.  *                "tablePtr" field points to the array's
  388.  *                hashtable for its elements.
  389.  * VAR_LINK -            1 means this Var structure contains a
  390.  *                pointer to another Var structure that
  391.  *                either has the real value or is itself
  392.  *                another VAR_LINK pointer. Variables like
  393.  *                this come about through "upvar" and "global"
  394.  *                commands, or through references to variables
  395.  *                in enclosing namespaces.
  396.  * VAR_UNDEFINED -        1 means that the variable is in the process
  397.  *                of being deleted. An undefined variable
  398.  *                logically does not exist and survives only
  399.  *                while it has a trace, or if it is a global
  400.  *                variable currently being used by some
  401.  *                procedure.
  402.  * VAR_IN_HASHTABLE -        1 means this variable is in a hashtable and
  403.  *                the Var structure is malloced. 0 if it is
  404.  *                a local variable that was assigned a slot
  405.  *                in a procedure frame by    the compiler so the
  406.  *                Var storage is part of the call frame.
  407.  * VAR_TRACE_ACTIVE -        1 means that trace processing is currently
  408.  *                underway for a read or write access, so
  409.  *                new read or write accesses should not cause
  410.  *                trace procedures to be called and the
  411.  *                variable can't be deleted.
  412.  * VAR_ARRAY_ELEMENT -        1 means that this variable is an array
  413.  *                element, so it is not legal for it to be
  414.  *                an array itself (the VAR_ARRAY flag had
  415.  *                better not be set).
  416.  * VAR_NAMESPACE_VAR -        1 means that this variable was declared
  417.  *                as a namespace variable. This flag ensures
  418.  *                it persists until its namespace is
  419.  *                destroyed or until the variable is unset;
  420.  *                it will persist even if it has not been
  421.  *                initialized and is marked undefined.
  422.  *                The variable's refCount is incremented to
  423.  *                reflect the "reference" from its namespace.
  424.  *
  425.  * The following additional flags are used with the CompiledLocal type
  426.  * defined below:
  427.  *
  428.  * VAR_ARGUMENT -        1 means that this variable holds a procedure
  429.  *                argument. 
  430.  * VAR_TEMPORARY -        1 if the local variable is an anonymous
  431.  *                temporary variable. Temporaries have a NULL
  432.  *                name.
  433.  * VAR_RESOLVED -        1 if name resolution has been done for this
  434.  *                variable.
  435.  */
  436.  
  437. #define VAR_SCALAR        0x1
  438. #define VAR_ARRAY        0x2
  439. #define VAR_LINK        0x4
  440. #define VAR_UNDEFINED        0x8
  441. #define VAR_IN_HASHTABLE    0x10
  442. #define VAR_TRACE_ACTIVE    0x20
  443. #define VAR_ARRAY_ELEMENT    0x40
  444. #define VAR_NAMESPACE_VAR    0x80
  445.  
  446. #define VAR_ARGUMENT        0x100
  447. #define VAR_TEMPORARY        0x200
  448. #define VAR_RESOLVED        0x400    
  449.  
  450. /*
  451.  * Macros to ensure that various flag bits are set properly for variables.
  452.  * The ANSI C "prototypes" for these macros are:
  453.  *
  454.  * EXTERN void    TclSetVarScalar _ANSI_ARGS_((Var *varPtr));
  455.  * EXTERN void    TclSetVarArray _ANSI_ARGS_((Var *varPtr));
  456.  * EXTERN void    TclSetVarLink _ANSI_ARGS_((Var *varPtr));
  457.  * EXTERN void    TclSetVarArrayElement _ANSI_ARGS_((Var *varPtr));
  458.  * EXTERN void    TclSetVarUndefined _ANSI_ARGS_((Var *varPtr));
  459.  * EXTERN void    TclClearVarUndefined _ANSI_ARGS_((Var *varPtr));
  460.  */
  461.  
  462. #define TclSetVarScalar(varPtr) \
  463.     (varPtr)->flags = ((varPtr)->flags & ~(VAR_ARRAY|VAR_LINK)) | VAR_SCALAR
  464.  
  465. #define TclSetVarArray(varPtr) \
  466.     (varPtr)->flags = ((varPtr)->flags & ~(VAR_SCALAR|VAR_LINK)) | VAR_ARRAY
  467.  
  468. #define TclSetVarLink(varPtr) \
  469.     (varPtr)->flags = ((varPtr)->flags & ~(VAR_SCALAR|VAR_ARRAY)) | VAR_LINK
  470.  
  471. #define TclSetVarArrayElement(varPtr) \
  472.     (varPtr)->flags = ((varPtr)->flags & ~VAR_ARRAY) | VAR_ARRAY_ELEMENT
  473.  
  474. #define TclSetVarUndefined(varPtr) \
  475.     (varPtr)->flags |= VAR_UNDEFINED
  476.  
  477. #define TclClearVarUndefined(varPtr) \
  478.     (varPtr)->flags &= ~VAR_UNDEFINED
  479.  
  480. /*
  481.  * Macros to read various flag bits of variables.
  482.  * The ANSI C "prototypes" for these macros are:
  483.  *
  484.  * EXTERN int    TclIsVarScalar _ANSI_ARGS_((Var *varPtr));
  485.  * EXTERN int    TclIsVarLink _ANSI_ARGS_((Var *varPtr));
  486.  * EXTERN int    TclIsVarArray _ANSI_ARGS_((Var *varPtr));
  487.  * EXTERN int    TclIsVarUndefined _ANSI_ARGS_((Var *varPtr));
  488.  * EXTERN int    TclIsVarArrayElement _ANSI_ARGS_((Var *varPtr));
  489.  * EXTERN int    TclIsVarTemporary _ANSI_ARGS_((Var *varPtr));
  490.  * EXTERN int    TclIsVarArgument _ANSI_ARGS_((Var *varPtr));
  491.  * EXTERN int    TclIsVarResolved _ANSI_ARGS_((Var *varPtr));
  492.  */
  493.     
  494. #define TclIsVarScalar(varPtr) \
  495.     ((varPtr)->flags & VAR_SCALAR)
  496.  
  497. #define TclIsVarLink(varPtr) \
  498.     ((varPtr)->flags & VAR_LINK)
  499.  
  500. #define TclIsVarArray(varPtr) \
  501.     ((varPtr)->flags & VAR_ARRAY)
  502.  
  503. #define TclIsVarUndefined(varPtr) \
  504.     ((varPtr)->flags & VAR_UNDEFINED)
  505.  
  506. #define TclIsVarArrayElement(varPtr) \
  507.     ((varPtr)->flags & VAR_ARRAY_ELEMENT)
  508.  
  509. #define TclIsVarTemporary(varPtr) \
  510.     ((varPtr)->flags & VAR_TEMPORARY)
  511.     
  512. #define TclIsVarArgument(varPtr) \
  513.     ((varPtr)->flags & VAR_ARGUMENT)
  514.     
  515. #define TclIsVarResolved(varPtr) \
  516.     ((varPtr)->flags & VAR_RESOLVED)
  517.  
  518. /*
  519.  *----------------------------------------------------------------
  520.  * Data structures related to procedures.  These are used primarily
  521.  * in tclProc.c, tclCompile.c, and tclExecute.c.
  522.  *----------------------------------------------------------------
  523.  */
  524.  
  525. /*
  526.  * Forward declaration to prevent an error when the forward reference to
  527.  * Command is encountered in the Proc and ImportRef types declared below.
  528.  */
  529.  
  530. struct Command;
  531.  
  532. /*
  533.  * The variable-length structure below describes a local variable of a
  534.  * procedure that was recognized by the compiler. These variables have a
  535.  * name, an element in the array of compiler-assigned local variables in the
  536.  * procedure's call frame, and various other items of information. If the
  537.  * local variable is a formal argument, it may also have a default value.
  538.  * The compiler can't recognize local variables whose names are
  539.  * expressions (these names are only known at runtime when the expressions
  540.  * are evaluated) or local variables that are created as a result of an
  541.  * "upvar" or "uplevel" command. These other local variables are kept
  542.  * separately in a hash table in the call frame.
  543.  */
  544.  
  545. typedef struct CompiledLocal {
  546.     struct CompiledLocal *nextPtr;
  547.                 /* Next compiler-recognized local variable
  548.                  * for this procedure, or NULL if this is
  549.                  * the last local. */
  550.     int nameLength;        /* The number of characters in local
  551.                  * variable's name. Used to speed up
  552.                  * variable lookups. */
  553.     int frameIndex;        /* Index in the array of compiler-assigned
  554.                  * variables in the procedure call frame. */
  555.     int flags;            /* Flag bits for the local variable. Same as
  556.                  * the flags for the Var structure above,
  557.                  * although only VAR_SCALAR, VAR_ARRAY, 
  558.                  * VAR_LINK, VAR_ARGUMENT, VAR_TEMPORARY, and
  559.                  * VAR_RESOLVED make sense. */
  560.     Tcl_Obj *defValuePtr;    /* Pointer to the default value of an
  561.                  * argument, if any. NULL if not an argument
  562.                  * or, if an argument, no default value. */
  563.     Tcl_ResolvedVarInfo *resolveInfo;
  564.                 /* Customized variable resolution info
  565.                  * supplied by the Tcl_ResolveCompiledVarProc
  566.                  * associated with a namespace. Each variable
  567.                  * is marked by a unique ClientData tag
  568.                  * during compilation, and that same tag
  569.                  * is used to find the variable at runtime. */
  570.     char name[4];        /* Name of the local variable starts here.
  571.                  * If the name is NULL, this will just be
  572.                  * '\0'. The actual size of this field will
  573.                  * be large enough to hold the name. MUST
  574.                  * BE THE LAST FIELD IN THE STRUCTURE! */
  575. } CompiledLocal;
  576.  
  577. /*
  578.  * The structure below defines a command procedure, which consists of a
  579.  * collection of Tcl commands plus information about arguments and other
  580.  * local variables recognized at compile time.
  581.  */
  582.  
  583. typedef struct Proc {
  584.     struct Interp *iPtr;      /* Interpreter for which this command
  585.                    * is defined. */
  586.     int refCount;          /* Reference count: 1 if still present
  587.                    * in command table plus 1 for each call
  588.                    * to the procedure that is currently
  589.                    * active. This structure can be freed
  590.                    * when refCount becomes zero. */
  591.     struct Command *cmdPtr;      /* Points to the Command structure for
  592.                    * this procedure. This is used to get
  593.                    * the namespace in which to execute
  594.                    * the procedure. */
  595.     Tcl_Obj *bodyPtr;          /* Points to the ByteCode object for
  596.                    * procedure's body command. */
  597.     int numArgs;          /* Number of formal parameters. */
  598.     int numCompiledLocals;      /* Count of local variables recognized by
  599.                    * the compiler including arguments and
  600.                    * temporaries. */
  601.     CompiledLocal *firstLocalPtr; /* Pointer to first of the procedure's
  602.                    * compiler-allocated local variables, or
  603.                    * NULL if none. The first numArgs entries
  604.                    * in this list describe the procedure's
  605.                    * formal arguments. */
  606.     CompiledLocal *lastLocalPtr;  /* Pointer to the last allocated local
  607.                    * variable or NULL if none. This has
  608.                    * frame index (numCompiledLocals-1). */
  609. } Proc;
  610.  
  611. /*
  612.  * The structure below defines a command trace.     This is used to allow Tcl
  613.  * clients to find out whenever a command is about to be executed.
  614.  */
  615.  
  616. typedef struct Trace {
  617.     int level;            /* Only trace commands at nesting level
  618.                  * less than or equal to this. */
  619.     Tcl_CmdTraceProc *proc;    /* Procedure to call to trace command. */
  620.     ClientData clientData;    /* Arbitrary value to pass to proc. */
  621.     struct Trace *nextPtr;    /* Next in list of traces for this interp. */
  622. } Trace;
  623.  
  624. /*
  625.  * The structure below defines an entry in the assocData hash table which
  626.  * is associated with an interpreter. The entry contains a pointer to a
  627.  * function to call when the interpreter is deleted, and a pointer to
  628.  * a user-defined piece of data.
  629.  */
  630.  
  631. typedef struct AssocData {
  632.     Tcl_InterpDeleteProc *proc;    /* Proc to call when deleting. */
  633.     ClientData clientData;    /* Value to pass to proc. */
  634. } AssocData;    
  635.  
  636. /*
  637.  * The structure below defines a call frame. A call frame defines a naming
  638.  * context for a procedure call: its local naming scope (for local
  639.  * variables) and its global naming scope (a namespace, perhaps the global
  640.  * :: namespace). A call frame can also define the naming context for a
  641.  * namespace eval or namespace inscope command: the namespace in which the
  642.  * command's code should execute. The Tcl_CallFrame structures exist only
  643.  * while procedures or namespace eval/inscope's are being executed, and
  644.  * provide a kind of Tcl call stack.
  645.  * 
  646.  * WARNING!! The structure definition must be kept consistent with the
  647.  * Tcl_CallFrame structure in tcl.h. If you change one, change the other.
  648.  */
  649.  
  650. typedef struct CallFrame {
  651.     Namespace *nsPtr;        /* Points to the namespace used to resolve
  652.                  * commands and global variables. */
  653.     int isProcCallFrame;    /* If nonzero, the frame was pushed to
  654.                  * execute a Tcl procedure and may have
  655.                  * local vars. If 0, the frame was pushed
  656.                  * to execute a namespace command and var
  657.                  * references are treated as references to
  658.                  * namespace vars; varTablePtr and
  659.                  * compiledLocals are ignored. */
  660.     int objc;            /* This and objv below describe the
  661.                  * arguments for this procedure call. */
  662.     Tcl_Obj *CONST *objv;    /* Array of argument objects. */
  663.     struct CallFrame *callerPtr;
  664.                 /* Value of interp->framePtr when this
  665.                  * procedure was invoked (i.e. next higher
  666.                  * in stack of all active procedures). */
  667.     struct CallFrame *callerVarPtr;
  668.                 /* Value of interp->varFramePtr when this
  669.                  * procedure was invoked (i.e. determines
  670.                  * variable scoping within caller). Same
  671.                  * as callerPtr unless an "uplevel" command
  672.                  * or something equivalent was active in
  673.                  * the caller). */
  674.     int level;            /* Level of this procedure, for "uplevel"
  675.                  * purposes (i.e. corresponds to nesting of
  676.                  * callerVarPtr's, not callerPtr's). 1 for
  677.                  * outermost procedure, 0 for top-level. */
  678.     Proc *procPtr;        /* Points to the structure defining the
  679.                  * called procedure. Used to get information
  680.                  * such as the number of compiled local
  681.                  * variables (local variables assigned
  682.                  * entries ["slots"] in the compiledLocals
  683.                  * array below). */
  684.     Tcl_HashTable *varTablePtr;    /* Hash table containing local variables not
  685.                  * recognized by the compiler, or created at
  686.                  * execution time through, e.g., upvar.
  687.                  * Initially NULL and created if needed. */
  688.     int numCompiledLocals;    /* Count of local variables recognized by
  689.                  * the compiler including arguments. */
  690.     Var* compiledLocals;    /* Points to the array of local variables
  691.                  * recognized by the compiler. The compiler
  692.                  * emits code that refers to these variables
  693.                  * using an index into this array. */
  694. } CallFrame;
  695.  
  696. /*
  697.  *----------------------------------------------------------------
  698.  * Data structures related to history.     These are used primarily
  699.  * in tclHistory.c
  700.  *----------------------------------------------------------------
  701.  */
  702.  
  703. /*
  704.  * The structure below defines one history event (a previously-executed
  705.  * command that can be re-executed in whole or in part).
  706.  */
  707.  
  708. typedef struct {
  709.     char *command;        /* String containing previously-executed
  710.                  * command. */
  711.     int bytesAvl;        /* Total # of bytes available at *event (not
  712.                  * all are necessarily in use now). */
  713. } HistoryEvent;
  714.  
  715. /*
  716.  * The structure below defines a pending revision to the most recent
  717.  * history event.  Changes are linked together into a list and applied
  718.  * during the next call to Tcl_RecordHistory.  See the comments at the
  719.  * beginning of tclHistory.c for information on revisions.
  720.  */
  721.  
  722. typedef struct HistoryRev {
  723.     int firstIndex;        /* Index of the first byte to replace in
  724.                  * current history event. */
  725.     int lastIndex;        /* Index of last byte to replace in
  726.                  * current history event. */
  727.     int newSize;        /* Number of bytes in newBytes. */
  728.     char *newBytes;        /* Replacement for the range given by
  729.                  * firstIndex and lastIndex (malloced). */
  730.     struct HistoryRev *nextPtr;    /* Next in chain of revisions to apply, or
  731.                  * NULL for end of list. */
  732. } HistoryRev;
  733.  
  734. /*
  735.  *----------------------------------------------------------------
  736.  * Data structures related to expressions.  These are used only in
  737.  * tclExpr.c.
  738.  *----------------------------------------------------------------
  739.  */
  740.  
  741. /*
  742.  * The data structure below defines a math function (e.g. sin or hypot)
  743.  * for use in Tcl expressions.
  744.  */
  745.  
  746. #define MAX_MATH_ARGS 5
  747. typedef struct MathFunc {
  748.     int builtinFuncIndex;    /* If this is a builtin math function, its
  749.                  * index in the array of builtin functions.
  750.                  * (tclCompilation.h lists these indices.)
  751.                  * The value is -1 if this is a new function
  752.                  * defined by Tcl_CreateMathFunc. The value
  753.                  * is also -1 if a builtin function is
  754.                  * replaced by a Tcl_CreateMathFunc call. */
  755.     int numArgs;        /* Number of arguments for function. */
  756.     Tcl_ValueType argTypes[MAX_MATH_ARGS];
  757.                 /* Acceptable types for each argument. */
  758.     Tcl_MathProc *proc;        /* Procedure that implements this function.
  759.                  * NULL if isBuiltinFunc is 1. */
  760.     ClientData clientData;    /* Additional argument to pass to the
  761.                  * function when invoking it. NULL if
  762.                  * isBuiltinFunc is 1. */
  763. } MathFunc;
  764.  
  765. /*
  766.  *----------------------------------------------------------------
  767.  * Data structures related to bytecode compilation and execution.
  768.  * These are used primarily in tclCompile.c, tclExecute.c, and
  769.  * tclBasic.c.
  770.  *----------------------------------------------------------------
  771.  */
  772.  
  773. /*
  774.  * Forward declaration to prevent an error when the forward reference to
  775.  * CompileEnv is encountered in the procedure type CompileProc declared
  776.  * below.
  777.  */
  778.  
  779. struct CompileEnv;
  780.  
  781. /*
  782.  * The type of procedures called by the Tcl bytecode compiler to compile
  783.  * commands. Pointers to these procedures are kept in the Command structure
  784.  * describing each command. When a CompileProc returns, the interpreter's
  785.  * result is set to error information, if any. In addition, the CompileProc
  786.  * returns an integer value, which is one of the following:
  787.  *
  788.  * TCL_OK        Compilation completed normally.
  789.  * TCL_ERROR        Compilation failed because of an error;
  790.  *            the interpreter's result describes what went wrong.
  791.  * TCL_OUT_LINE_COMPILE    Compilation failed because, e.g., the command is
  792.  *            too complex for effective inline compilation. The
  793.  *            CompileProc believes the command is legal but 
  794.  *            should be compiled "out of line" by emitting code
  795.  *            to invoke its command procedure at runtime.
  796.  */
  797.  
  798. #define TCL_OUT_LINE_COMPILE    (TCL_CONTINUE + 1)
  799.  
  800. typedef int (CompileProc) _ANSI_ARGS_((Tcl_Interp *interp, char *string,
  801.     char *lastChar, int compileFlags, struct CompileEnv *compEnvPtr));
  802.  
  803. /*
  804.  * The data structure defining the execution environment for ByteCode's.
  805.  * There is one ExecEnv structure per Tcl interpreter. It holds the
  806.  * evaluation stack that holds command operands and results. The stack grows
  807.  * towards increasing addresses. The "stackTop" member is cached by
  808.  * TclExecuteByteCode in a local variable: it must be set before calling
  809.  * TclExecuteByteCode and will be restored by TclExecuteByteCode before it
  810.  * returns.
  811.  */
  812.  
  813. typedef union StackItem {
  814.     Tcl_Obj *o;            /* Stack item as a pointer to a Tcl_Obj. */
  815.     int         i;            /* Stack item as an integer. */
  816.     VOID    *p;            /* Stack item as an arbitrary pointer. */
  817. } StackItem;
  818.  
  819. typedef struct ExecEnv {
  820.     StackItem *stackPtr;    /* Points to the first item in the
  821.                  * evaluation stack on the heap. */
  822.     int stackTop;        /* Index of current top of stack; -1 when
  823.                  * the stack is empty. */
  824.     int stackEnd;        /* Index of last usable item in stack. */
  825. } ExecEnv;
  826.  
  827. /*
  828.  *----------------------------------------------------------------
  829.  * Data structures related to commands.
  830.  *----------------------------------------------------------------
  831.  */
  832.  
  833. /*
  834.  * An imported command is created in an namespace when it imports a "real"
  835.  * command from another namespace. An imported command has a Command
  836.  * structure that points (via its ClientData value) to the "real" Command
  837.  * structure in the source namespace's command table. The real command
  838.  * records all the imported commands that refer to it in a list of ImportRef
  839.  * structures so that they can be deleted when the real command is deleted.  */
  840.  
  841. typedef struct ImportRef {
  842.     struct Command *importedCmdPtr;
  843.                 /* Points to the imported command created in
  844.                  * an importing namespace; this command
  845.                  * redirects its invocations to the "real"
  846.                  * command. */
  847.     struct ImportRef *nextPtr;    /* Next element on the linked list of
  848.                  * imported commands that refer to the
  849.                  * "real" command. The real command deletes
  850.                  * these imported commands on this list when
  851.                  * it is deleted. */
  852. } ImportRef;
  853.  
  854. /*
  855.  * Data structure used as the ClientData of imported commands: commands
  856.  * created in an namespace when it imports a "real" command from another
  857.  * namespace.
  858.  */
  859.  
  860. typedef struct ImportedCmdData {
  861.     struct Command *realCmdPtr;    /* "Real" command that this imported command
  862.                  * refers to. */
  863.     struct Command *selfPtr;    /* Pointer to this imported command. Needed
  864.                  * only when deleting it in order to remove
  865.                  * it from the real command's linked list of
  866.                  * imported commands that refer to it. */
  867. } ImportedCmdData;
  868.  
  869. /*
  870.  * A Command structure exists for each command in a namespace. The
  871.  * Tcl_Command opaque type actually refers to these structures.
  872.  */
  873.  
  874. typedef struct Command {
  875.     Tcl_HashEntry *hPtr;    /* Pointer to the hash table entry that
  876.                  * refers to this command. The hash table is
  877.                  * either a namespace's command table or an
  878.                  * interpreter's hidden command table. This
  879.                  * pointer is used to get a command's name
  880.                  * from its Tcl_Command handle. NULL means
  881.                  * that the hash table entry has been
  882.                  * removed already (this can happen if
  883.                  * deleteProc causes the command to be
  884.                  * deleted or recreated). */
  885.     Namespace *nsPtr;        /* Points to the namespace containing this
  886.                  * command. */
  887.     int refCount;        /* 1 if in command hashtable plus 1 for each
  888.                  * reference from a CmdName Tcl object
  889.                  * representing a command's name in a
  890.                  * ByteCode instruction sequence. This
  891.                  * structure can be freed when refCount
  892.                  * becomes zero. */
  893.     int cmdEpoch;        /* Incremented to invalidate any references
  894.                  * that point to this command when it is
  895.                  * renamed, deleted, hidden, or exposed. */
  896.     CompileProc *compileProc;    /* Procedure called to compile command. NULL
  897.                  * if no compile proc exists for command. */
  898.     Tcl_ObjCmdProc *objProc;    /* Object-based command procedure. */
  899.     ClientData objClientData;    /* Arbitrary value passed to object proc. */
  900.     Tcl_CmdProc *proc;        /* String-based command procedure. */
  901.     ClientData clientData;    /* Arbitrary value passed to string proc. */
  902.     Tcl_CmdDeleteProc *deleteProc;
  903.                 /* Procedure invoked when deleting command
  904.                  * to, e.g., free all client data. */
  905.     ClientData deleteData;    /* Arbitrary value passed to deleteProc. */
  906.     int deleted;        /* Means that the command is in the process
  907.                  * of being deleted (its deleteProc is
  908.                  * currently executing). Other attempts to
  909.                  * delete the command should be ignored. */
  910.     ImportRef *importRefPtr;    /* List of each imported Command created in
  911.                  * another namespace when this command is
  912.                  * imported. These imported commands
  913.                  * redirect invocations back to this
  914.                  * command. The list is used to remove all
  915.                  * those imported commands when deleting
  916.                  * this "real" command. */
  917. } Command;
  918.  
  919. /*
  920.  *----------------------------------------------------------------
  921.  * Data structures related to name resolution procedures.
  922.  *----------------------------------------------------------------
  923.  */
  924.  
  925. /*
  926.  * The interpreter keeps a linked list of name resolution schemes.
  927.  * The scheme for a namespace is consulted first, followed by the
  928.  * list of schemes in an interpreter, followed by the default
  929.  * name resolution in Tcl.  Schemes are added/removed from the
  930.  * interpreter's list by calling Tcl_AddInterpResolver and
  931.  * Tcl_RemoveInterpResolver.
  932.  */
  933.  
  934. typedef struct ResolverScheme {
  935.     char *name;            /* Name identifying this scheme. */
  936.     Tcl_ResolveCmdProc *cmdResProc;
  937.                 /* Procedure handling command name
  938.                  * resolution. */
  939.     Tcl_ResolveVarProc *varResProc;
  940.                 /* Procedure handling variable name
  941.                  * resolution for variables that
  942.                  * can only be handled at runtime. */
  943.     Tcl_ResolveCompiledVarProc *compiledVarResProc;
  944.                 /* Procedure handling variable name
  945.                  * resolution at compile time. */
  946.  
  947.     struct ResolverScheme *nextPtr;
  948.                 /* Pointer to next record in linked list. */
  949. } ResolverScheme;
  950.  
  951. /*
  952.  *----------------------------------------------------------------
  953.  * This structure defines an interpreter, which is a collection of
  954.  * commands plus other state information related to interpreting
  955.  * commands, such as variable storage. Primary responsibility for
  956.  * this data structure is in tclBasic.c, but almost every Tcl
  957.  * source file uses something in here.
  958.  *----------------------------------------------------------------
  959.  */
  960.  
  961. typedef struct Interp {
  962.  
  963.     /*
  964.      * Note:  the first three fields must match exactly the fields in
  965.      * a Tcl_Interp struct (see tcl.h).     If you change one, be sure to
  966.      * change the other.
  967.      *
  968.      * The interpreter's result is held in both the string and the
  969.      * objResultPtr fields. These fields hold, respectively, the result's
  970.      * string or object value. The interpreter's result is always in the
  971.      * result field if that is non-empty, otherwise it is in objResultPtr.
  972.      * The two fields are kept consistent unless some C code sets
  973.      * interp->result directly. Programs should not access result and
  974.      * objResultPtr directly; instead, they should always get and set the
  975.      * result using procedures such as Tcl_SetObjResult, Tcl_GetObjResult,
  976.      * and Tcl_GetStringResult. See the SetResult man page for details.
  977.      */
  978.  
  979.     char *result;        /* If the last command returned a string
  980.                  * result, this points to it. Should not be
  981.                  * accessed directly; see comment above. */
  982.     Tcl_FreeProc *freeProc;    /* Zero means a string result is statically
  983.                  * allocated. TCL_DYNAMIC means string
  984.                  * result was allocated with ckalloc and
  985.                  * should be freed with ckfree. Other values
  986.                  * give address of procedure to invoke to
  987.                  * free the string result. Tcl_Eval must
  988.                  * free it before executing next command. */
  989.     int errorLine;        /* When TCL_ERROR is returned, this gives
  990.                  * the line number in the command where the
  991.                  * error occurred (1 means first line). */
  992.     Tcl_Obj *objResultPtr;    /* If the last command returned an object
  993.                  * result, this points to it. Should not be
  994.                  * accessed directly; see comment above. */
  995.     Namespace *globalNsPtr;    /* The interpreter's global namespace. */
  996.     Tcl_HashTable mathFuncTable;/* Contains all the math functions currently
  997.                  * defined for the interpreter.     Indexed by
  998.                  * strings (function names); values have
  999.                  * type (MathFunc *). */
  1000.  
  1001.     /*
  1002.      * Information related to procedures and variables. See tclProc.c
  1003.      * and tclvar.c for usage.
  1004.      */
  1005.  
  1006.     int numLevels;        /* Keeps track of how many nested calls to
  1007.                  * Tcl_Eval are in progress for this
  1008.                  * interpreter.     It's used to delay deletion
  1009.                  * of the table until all Tcl_Eval
  1010.                  * invocations are completed. */
  1011.     int maxNestingDepth;    /* If numLevels exceeds this value then Tcl
  1012.                  * assumes that infinite recursion has
  1013.                  * occurred and it generates an error. */
  1014.     CallFrame *framePtr;    /* Points to top-most in stack of all nested
  1015.                  * procedure invocations.  NULL means there
  1016.                  * are no active procedures. */
  1017.     CallFrame *varFramePtr;    /* Points to the call frame whose variables
  1018.                  * are currently in use (same as framePtr
  1019.                  * unless an "uplevel" command is
  1020.                  * executing). NULL means no procedure is
  1021.                  * active or "uplevel 0" is executing. */
  1022.     ActiveVarTrace *activeTracePtr;
  1023.                 /* First in list of active traces for
  1024.                  * interp, or NULL if no active traces. */
  1025.     int returnCode;        /* Completion code to return if current
  1026.                  * procedure exits with TCL_RETURN code. */
  1027.     char *errorInfo;        /* Value to store in errorInfo if returnCode
  1028.                  * is TCL_ERROR.  Malloc'ed, may be NULL */
  1029.     char *errorCode;        /* Value to store in errorCode if returnCode
  1030.                  * is TCL_ERROR.  Malloc'ed, may be NULL */
  1031.  
  1032.     /*
  1033.      * Information used by Tcl_AppendResult to keep track of partial
  1034.      * results.     See Tcl_AppendResult code for details.
  1035.      */
  1036.  
  1037.     char *appendResult;        /* Storage space for results generated
  1038.                  * by Tcl_AppendResult.     Malloc-ed.  NULL
  1039.                  * means not yet allocated. */
  1040.     int appendAvl;        /* Total amount of space available at
  1041.                  * partialResult. */
  1042.     int appendUsed;        /* Number of non-null bytes currently
  1043.                  * stored at partialResult. */
  1044.  
  1045.     /*
  1046.      * A cache of compiled regular expressions.     See Tcl_RegExpCompile
  1047.      * in tclUtil.c for details.
  1048.      */
  1049.  
  1050. #define NUM_REGEXPS 5
  1051.     char *patterns[NUM_REGEXPS];/* Strings corresponding to compiled
  1052.                  * regular expression patterns.     NULL
  1053.                  * means that this slot isn't used.
  1054.                  * Malloc-ed. */
  1055.     int patLengths[NUM_REGEXPS];/* Number of non-null characters in
  1056.                  * corresponding entry in patterns.
  1057.                  * -1 means entry isn't used. */
  1058.     regexp *regexps[NUM_REGEXPS];
  1059.                 /* Compiled forms of above strings.  Also
  1060.                  * malloc-ed, or NULL if not in use yet. */
  1061.  
  1062.     /*
  1063.      * Information about packages.  Used only in tclPkg.c.
  1064.      */
  1065.  
  1066.     Tcl_HashTable packageTable;    /* Describes all of the packages loaded
  1067.                  * in or available to this interpreter.
  1068.                  * Keys are package names, values are
  1069.                  * (Package *) pointers. */
  1070.     char *packageUnknown;    /* Command to invoke during "package
  1071.                  * require" commands for packages that
  1072.                  * aren't described in packageTable. 
  1073.                  * Malloc'ed, may be NULL. */
  1074.  
  1075.     /*
  1076.      * Miscellaneous information:
  1077.      */
  1078.  
  1079.     int cmdCount;        /* Total number of times a command procedure
  1080.                  * has been called for this interpreter. */
  1081.     int evalFlags;        /* Flags to control next call to Tcl_Eval.
  1082.                  * Normally zero, but may be set before
  1083.                  * calling Tcl_Eval.  See below for valid
  1084.                  * values. */
  1085.     int termOffset;        /* Offset of character just after last one
  1086.                  * compiled or executed by Tcl_EvalObj. */
  1087.     int compileEpoch;        /* Holds the current "compilation epoch"
  1088.                  * for this interpreter. This is
  1089.                  * incremented to invalidate existing
  1090.                  * ByteCodes when, e.g., a command with a
  1091.                  * compile procedure is redefined. */
  1092.     Proc *compiledProcPtr;    /* If a procedure is being compiled, a
  1093.                  * pointer to its Proc structure; otherwise,
  1094.                  * this is NULL. Set by ObjInterpProc in
  1095.                  * tclProc.c and used by tclCompile.c to
  1096.                  * process local variables appropriately. */
  1097.     ResolverScheme *resolverPtr;
  1098.                 /* Linked list of name resolution schemes
  1099.                  * added to this interpreter.  Schemes
  1100.                  * are added/removed by calling
  1101.                  * Tcl_AddInterpResolver and
  1102.                  * Tcl_RemoveInterpResolver. */
  1103.     char *scriptFile;        /* NULL means there is no nested source
  1104.                  * command active;  otherwise this points to
  1105.                  * the name of the file being sourced (it's
  1106.                  * not malloc-ed:  it points to an argument
  1107.                  * to Tcl_EvalFile. */
  1108.     int flags;            /* Various flag bits.  See below. */
  1109.     long randSeed;        /* Seed used for rand() function. */
  1110.     Trace *tracePtr;        /* List of traces for this interpreter. */
  1111.     Tcl_HashTable *assocData;    /* Hash table for associating data with
  1112.                  * this interpreter. Cleaned up when
  1113.                  * this interpreter is deleted. */
  1114.     struct ExecEnv *execEnvPtr;    /* Execution environment for Tcl bytecode
  1115.                  * execution. Contains a pointer to the
  1116.                  * Tcl evaluation stack. */
  1117.     Tcl_Obj *emptyObjPtr;    /* Points to an object holding an empty
  1118.                  * string. Returned by Tcl_ObjSetVar2 when
  1119.                  * variable traces change a variable in a
  1120.                  * gross way. */
  1121.     char resultSpace[TCL_RESULT_SIZE+1];
  1122.                 /* Static space holding small results. */
  1123. } Interp;
  1124.  
  1125. /*
  1126.  * EvalFlag bits for Interp structures:
  1127.  *
  1128.  * TCL_BRACKET_TERM    1 means that the current script is terminated by
  1129.  *            a close bracket rather than the end of the string.
  1130.  * TCL_ALLOW_EXCEPTIONS    1 means it's OK for the script to terminate with
  1131.  *            a code other than TCL_OK or TCL_ERROR;    0 means
  1132.  *            codes other than these should be turned into errors.
  1133.  */
  1134.  
  1135. #define TCL_BRACKET_TERM      1
  1136. #define TCL_ALLOW_EXCEPTIONS      4
  1137.  
  1138. /*
  1139.  * Flag bits for Interp structures:
  1140.  *
  1141.  * DELETED:        Non-zero means the interpreter has been deleted:
  1142.  *            don't process any more commands for it, and destroy
  1143.  *            the structure as soon as all nested invocations of
  1144.  *            Tcl_Eval are done.
  1145.  * ERR_IN_PROGRESS:    Non-zero means an error unwind is already in
  1146.  *            progress. Zero means a command proc has been
  1147.  *            invoked since last error occured.
  1148.  * ERR_ALREADY_LOGGED:    Non-zero means information has already been logged
  1149.  *            in $errorInfo for the current Tcl_Eval instance,
  1150.  *            so Tcl_Eval needn't log it (used to implement the
  1151.  *            "error message log" command).
  1152.  * ERROR_CODE_SET:    Non-zero means that Tcl_SetErrorCode has been
  1153.  *            called to record information for the current
  1154.  *            error.    Zero means Tcl_Eval must clear the
  1155.  *            errorCode variable if an error is returned.
  1156.  * EXPR_INITIALIZED:    Non-zero means initialization specific to
  1157.  *            expressions has    been carried out.
  1158.  * DONT_COMPILE_CMDS_INLINE: Non-zero means that the bytecode compiler
  1159.  *            should not compile any commands into an inline
  1160.  *            sequence of instructions. This is set 1, for
  1161.  *            example, when command traces are requested.
  1162.  * RAND_SEED_INITIALIZED: Non-zero means that the randSeed value of the
  1163.  *            interp has not be initialized.    This is set 1
  1164.  *            when we first use the rand() or srand() functions.
  1165.  * SAFE_INTERP:        Non zero means that the current interp is a
  1166.  *            safe interp (ie it has only the safe commands
  1167.  *            installed, less priviledge than a regular interp).
  1168.  */
  1169.  
  1170. #define DELETED             1
  1171. #define ERR_IN_PROGRESS         2
  1172. #define ERR_ALREADY_LOGGED     4
  1173. #define ERROR_CODE_SET         8
  1174. #define EXPR_INITIALIZED     0x10
  1175. #define DONT_COMPILE_CMDS_INLINE 0x20
  1176. #define RAND_SEED_INITIALIZED     0x40
  1177. #define SAFE_INTERP         0x80
  1178.  
  1179. /*
  1180.  *----------------------------------------------------------------
  1181.  * Data structures related to command parsing. These are used in
  1182.  * tclParse.c and its clients.
  1183.  *----------------------------------------------------------------
  1184.  */
  1185.  
  1186. /*
  1187.  * The following data structure is used by various parsing procedures
  1188.  * to hold information about where to store the results of parsing
  1189.  * (e.g. the substituted contents of a quoted argument, or the result
  1190.  * of a nested command).  At any given time, the space available
  1191.  * for output is fixed, but a procedure may be called to expand the
  1192.  * space available if the current space runs out.
  1193.  */
  1194.  
  1195. typedef struct ParseValue {
  1196.     char *buffer;        /* Address of first character in
  1197.                  * output buffer. */
  1198.     char *next;            /* Place to store next character in
  1199.                  * output buffer. */
  1200.     char *end;            /* Address of the last usable character
  1201.                  * in the buffer. */
  1202.     void (*expandProc) _ANSI_ARGS_((struct ParseValue *pvPtr, int needed));
  1203.                 /* Procedure to call when space runs out;
  1204.                  * it will make more space. */
  1205.     ClientData clientData;    /* Arbitrary information for use of
  1206.                  * expandProc. */
  1207. } ParseValue;
  1208.  
  1209. /*
  1210.  * A table used to classify input characters to assist in parsing
  1211.  * Tcl commands.  The table should be indexed with a signed character
  1212.  * using the CHAR_TYPE macro.  The character may have a negative
  1213.  * value.  The CHAR_TYPE macro takes a pointer to a signed character
  1214.  * and a pointer to the last character in the source string.  If the
  1215.  * src pointer is pointing at the terminating null of the string,
  1216.  * CHAR_TYPE returns TCL_COMMAND_END.
  1217.  */
  1218.  
  1219. extern unsigned char tclTypeTable[];
  1220. #define CHAR_TYPE(src,last) \
  1221.     (((src)==(last))?TCL_COMMAND_END:(tclTypeTable)[(int)(*(src) + 128)])
  1222.  
  1223. /*
  1224.  * Possible values returned by CHAR_TYPE. Note that except for TCL_DOLLAR,
  1225.  * these are all one byte values with a single bit set 1. This means these
  1226.  * values may be bit-or'ed together (except for TCL_DOLLAR) to quickly test
  1227.  * whether a character is one of several different kinds of characters.
  1228.  *
  1229.  * TCL_NORMAL -        All characters that don't have special significance
  1230.  *            to the Tcl language.
  1231.  * TCL_SPACE -        Character is space, tab, or return.
  1232.  * TCL_COMMAND_END -    Character is newline or semicolon or close-bracket
  1233.  *            or terminating null.
  1234.  * TCL_QUOTE -        Character is a double-quote.
  1235.  * TCL_OPEN_BRACKET -    Character is a "[".
  1236.  * TCL_OPEN_BRACE -    Character is a "{".
  1237.  * TCL_CLOSE_BRACE -    Character is a "}".
  1238.  * TCL_BACKSLASH -    Character is a "\".
  1239.  * TCL_DOLLAR -        Character is a "$".
  1240.  */
  1241.  
  1242. #define TCL_NORMAL        0x01
  1243. #define TCL_SPACE        0x02
  1244. #define TCL_COMMAND_END        0x04
  1245. #define TCL_QUOTE        0x08
  1246. #define TCL_OPEN_BRACKET    0x10
  1247. #define TCL_OPEN_BRACE        0x20
  1248. #define TCL_CLOSE_BRACE        0x40
  1249. #define TCL_BACKSLASH        0x80
  1250. #define TCL_DOLLAR        0x00
  1251.  
  1252. /*
  1253.  * Maximum number of levels of nesting permitted in Tcl commands (used
  1254.  * to catch infinite recursion).
  1255.  */
  1256.  
  1257. #define MAX_NESTING_DEPTH    1000
  1258.  
  1259. /*
  1260.  * The macro below is used to modify a "char" value (e.g. by casting
  1261.  * it to an unsigned character) so that it can be used safely with
  1262.  * macros such as isspace.
  1263.  */
  1264.  
  1265. #define UCHAR(c) ((unsigned char) (c))
  1266.  
  1267. /*
  1268.  * This macro is used to determine the offset needed to safely allocate any
  1269.  * data structure in memory. Given a starting offset or size, it "rounds up"
  1270.  * or "aligns" the offset to the next 8-byte boundary so that any data
  1271.  * structure can be placed at the resulting offset without fear of an
  1272.  * alignment error.
  1273.  *
  1274.  * WARNING!! DO NOT USE THIS MACRO TO ALIGN POINTERS: it will produce
  1275.  * the wrong result on platforms that allocate addresses that are divisible
  1276.  * by 4 or 2. Only use it for offsets or sizes.
  1277.  */
  1278.  
  1279. #define TCL_ALIGN(x) (((int)(x) + 7) & ~7)
  1280.  
  1281. /*
  1282.  * The following macros are used to specify the runtime platform
  1283.  * setting of the tclPlatform variable.
  1284.  */
  1285.  
  1286. typedef enum {
  1287.     TCL_PLATFORM_UNIX,        /* Any Unix-like OS. */
  1288.     TCL_PLATFORM_MAC,        /* MacOS. */
  1289.     TCL_PLATFORM_WINDOWS,    /* Any Microsoft Windows OS. */
  1290.     TCL_PLATFORM_OS2            /* OS/2. */
  1291. } TclPlatformType;
  1292.  
  1293. /*
  1294.  * Flags for TclInvoke:
  1295.  *
  1296.  * TCL_INVOKE_HIDDEN        Invoke a hidden command; if not set,
  1297.  *                invokes an exposed command.
  1298.  * TCL_INVOKE_NO_UNKNOWN    If set, "unknown" is not invoked if
  1299.  *                the command to be invoked is not found.
  1300.  *                Only has an effect if invoking an exposed
  1301.  *                command, i.e. if TCL_INVOKE_HIDDEN is not
  1302.  *                also set.
  1303.  */
  1304.  
  1305. #define    TCL_INVOKE_HIDDEN    (1<<0)
  1306. #define TCL_INVOKE_NO_UNKNOWN    (1<<1)
  1307.  
  1308. /*
  1309.  * The structure used as the internal representation of Tcl list
  1310.  * objects. This is an array of pointers to the element objects. This array
  1311.  * is grown (reallocated and copied) as necessary to hold all the list's
  1312.  * element pointers. The array might contain more slots than currently used
  1313.  * to hold all element pointers. This is done to make append operations
  1314.  * faster.
  1315.  */
  1316.  
  1317. typedef struct List {
  1318.     int maxElemCount;        /* Total number of element array slots. */
  1319.     int elemCount;        /* Current number of list elements. */
  1320.     Tcl_Obj **elements;        /* Array of pointers to element objects. */
  1321. } List;
  1322.  
  1323. /*
  1324.  * The following types are used for getting and storing platform-specific
  1325.  * file attributes in tclFCmd.c and the various platform-versions of
  1326.  * that file. This is done to have as much common code as possible
  1327.  * in the file attributes code. For more information about the callbacks,
  1328.  * see TclFileAttrsCmd in tclFCmd.c.
  1329.  */
  1330.  
  1331. typedef int (TclGetFileAttrProc) _ANSI_ARGS_((Tcl_Interp *interp,
  1332.     int objIndex, char *fileName, 
  1333.     Tcl_Obj **attrObjPtrPtr));
  1334. typedef int (TclSetFileAttrProc) _ANSI_ARGS_((Tcl_Interp *interp,
  1335.     int objIndex, char *fileName, 
  1336.     Tcl_Obj *attrObjPtr));
  1337.  
  1338. typedef struct TclFileAttrProcs {
  1339.     TclGetFileAttrProc *getProc;    /* The procedure for getting attrs. */
  1340.     TclSetFileAttrProc *setProc;    /* The procedure for setting attrs. */
  1341. } TclFileAttrProcs;
  1342.  
  1343. /*
  1344.  * Opaque handle used in pipeline routines to encapsulate platform-dependent
  1345.  * state. 
  1346.  */
  1347.  
  1348. typedef struct TclFile_ *TclFile;
  1349.     
  1350. /*
  1351.  *----------------------------------------------------------------
  1352.  * Data structures related to hooking 'TclStat(...)' and
  1353.  * 'TclAccess(...)'.
  1354.  *----------------------------------------------------------------
  1355.  */
  1356.  
  1357. typedef struct stat TclStat_;
  1358. typedef int (TclStatProc_) _ANSI_ARGS_((CONST char *path, TclStat_ *buf));
  1359. typedef int (TclAccessProc_) _ANSI_ARGS_((CONST char *path, int mode));
  1360. typedef Tcl_Channel (TclOpenFileChannelProc_) _ANSI_ARGS_((Tcl_Interp *interp,
  1361.     char *fileName, char *modeString,
  1362.     int permissions));
  1363.  
  1364. typedef int (*TclCmdProcType) _ANSI_ARGS_((ClientData clientData,
  1365.     Tcl_Interp *interp, int argc, char *argv[]));
  1366. typedef int (*TclObjCmdProcType) _ANSI_ARGS_((ClientData clientData,
  1367.     Tcl_Interp *interp, int objc, struct Tcl_Obj * CONST objv[]));
  1368.  
  1369. /*
  1370.  *----------------------------------------------------------------
  1371.  * Variables shared among Tcl modules but not used by the outside world.
  1372.  *----------------------------------------------------------------
  1373.  */
  1374.  
  1375. extern Tcl_Time            tclBlockTime;
  1376. extern int            tclBlockTimeSet;
  1377. extern char *            tclExecutableName;
  1378. extern Tcl_ChannelType        tclFileChannelType;
  1379. extern char *            tclMemDumpFileName;
  1380. extern TclPlatformType        tclPlatform;
  1381. extern char *            tclpFileAttrStrings[];
  1382. extern CONST TclFileAttrProcs    tclpFileAttrProcs[];
  1383.  
  1384. /*
  1385.  * Variables denoting the Tcl object types defined in the core.
  1386.  */
  1387.  
  1388. extern Tcl_ObjType    tclBooleanType;
  1389. extern Tcl_ObjType    tclByteCodeType;
  1390. extern Tcl_ObjType    tclDoubleType;
  1391. extern Tcl_ObjType    tclIntType;
  1392. extern Tcl_ObjType    tclListType;
  1393. extern Tcl_ObjType    tclProcBodyType;
  1394. extern Tcl_ObjType    tclStringType;
  1395.  
  1396. /*
  1397.  * The head of the list of free Tcl objects, and the total number of Tcl
  1398.  * objects ever allocated and freed.
  1399.  */
  1400.  
  1401. extern Tcl_Obj *    tclFreeObjList;
  1402.  
  1403. #ifdef TCL_COMPILE_STATS
  1404. extern long        tclObjsAlloced;
  1405. extern long        tclObjsFreed;
  1406. #endif /* TCL_COMPILE_STATS */
  1407.  
  1408. /*
  1409.  * Pointer to a heap-allocated string of length zero that the Tcl core uses
  1410.  * as the value of an empty string representation for an object. This value
  1411.  * is shared by all new objects allocated by Tcl_NewObj.
  1412.  */
  1413.  
  1414. extern char *        tclEmptyStringRep;
  1415.  
  1416. /*
  1417.  *----------------------------------------------------------------
  1418.  * Procedures shared among Tcl modules but not used by the outside
  1419.  * world:
  1420.  *----------------------------------------------------------------
  1421.  */
  1422.  
  1423. EXTERN void        panic _ANSI_ARGS_(TCL_VARARGS(char *,format));
  1424. EXTERN int        TclAccess _ANSI_ARGS_((CONST char *path,
  1425.                 int mode));
  1426. EXTERN int        TclAccessDeleteProc _ANSI_ARGS_((TclAccessProc_ *proc));
  1427. EXTERN int        TclAccessInsertProc _ANSI_ARGS_((TclAccessProc_ *proc));
  1428. EXTERN void        TclAllocateFreeObjects _ANSI_ARGS_((void));
  1429. EXTERN int        TclChdir _ANSI_ARGS_((Tcl_Interp *interp,
  1430.                 char *dirName));
  1431. EXTERN int        TclCleanupChildren _ANSI_ARGS_((Tcl_Interp *interp,
  1432.                 int numPids, Tcl_Pid *pidPtr,
  1433.                 Tcl_Channel errorChan));
  1434. EXTERN void        TclCleanupCommand _ANSI_ARGS_((Command *cmdPtr));
  1435. EXTERN int        TclCopyAndCollapse _ANSI_ARGS_((int count,
  1436.                 char *src, char *dst));
  1437. EXTERN int        TclCopyChannel _ANSI_ARGS_((Tcl_Interp *interp,
  1438.                 Tcl_Channel inChan, Tcl_Channel outChan,
  1439.                 int toRead, Tcl_Obj *cmdPtr));
  1440. /*
  1441.  * TclCreatePipeline unofficially exported for use by BLT.
  1442.  */
  1443. EXTERN int        TclCreatePipeline _ANSI_ARGS_((Tcl_Interp *interp,
  1444.                 int argc, char **argv, Tcl_Pid **pidArrayPtr,
  1445.                 TclFile *inPipePtr, TclFile *outPipePtr,
  1446.                 TclFile *errFilePtr));
  1447. EXTERN int        TclCreateProc _ANSI_ARGS_((Tcl_Interp *interp,
  1448.                 Namespace *nsPtr, char *procName,
  1449.                 Tcl_Obj *argsPtr, Tcl_Obj *bodyPtr,
  1450.                 Proc **procPtrPtr));
  1451. EXTERN void        TclDeleteCompiledLocalVars _ANSI_ARGS_((
  1452.                 Interp *iPtr, CallFrame *framePtr));
  1453. EXTERN void        TclDeleteVars _ANSI_ARGS_((Interp *iPtr,
  1454.                 Tcl_HashTable *tablePtr));
  1455. EXTERN int        TclDoGlob _ANSI_ARGS_((Tcl_Interp *interp,
  1456.                 char *separators, Tcl_DString *headPtr,
  1457.                 char *tail));
  1458. EXTERN void        TclDumpMemoryInfo _ANSI_ARGS_((FILE *outFile));
  1459. EXTERN void        TclExpandParseValue _ANSI_ARGS_((ParseValue *pvPtr,
  1460.                 int needed));
  1461. EXTERN void        TclExprFloatError _ANSI_ARGS_((Tcl_Interp *interp,
  1462.                 double value));
  1463. EXTERN int        TclFileAttrsCmd _ANSI_ARGS_((Tcl_Interp *interp,
  1464.                 int objc, Tcl_Obj *CONST objv[]));
  1465. EXTERN int        TclFileCopyCmd _ANSI_ARGS_((Tcl_Interp *interp, 
  1466.                 int argc, char **argv)) ;
  1467. EXTERN int        TclFileDeleteCmd _ANSI_ARGS_((Tcl_Interp *interp,
  1468.                 int argc, char **argv));
  1469. EXTERN int        TclFileMakeDirsCmd _ANSI_ARGS_((Tcl_Interp *interp,
  1470.                 int argc, char **argv)) ;
  1471. EXTERN int        TclFileRenameCmd _ANSI_ARGS_((Tcl_Interp *interp,
  1472.                 int argc, char **argv)) ;
  1473. EXTERN void        TclFinalizeCompExecEnv _ANSI_ARGS_((void));
  1474. EXTERN void        TclFinalizeEnvironment _ANSI_ARGS_((void));
  1475. EXTERN void        TclFinalizeExecEnv _ANSI_ARGS_((void));
  1476. EXTERN int        TclFindElement _ANSI_ARGS_((Tcl_Interp *interp,
  1477.                 char *list, int listLength, char **elementPtr,
  1478.                 char **nextPtr, int *sizePtr, int *bracePtr));
  1479. EXTERN Proc *        TclFindProc _ANSI_ARGS_((Interp *iPtr,
  1480.                 char *procName));
  1481. EXTERN int        TclFormatInt _ANSI_ARGS_((char *buffer, long n));
  1482. EXTERN void        TclFreePackageInfo _ANSI_ARGS_((Interp *iPtr));
  1483. EXTERN void        TclGetAndDetachPids _ANSI_ARGS_((Tcl_Interp *interp,
  1484.                 Tcl_Channel chan));
  1485. EXTERN char *        TclGetCwd _ANSI_ARGS_((Tcl_Interp *interp));
  1486. EXTERN int        TclGetDate _ANSI_ARGS_((char *p,
  1487.                 unsigned long now, long zone,
  1488.                 unsigned long *timePtr));
  1489. EXTERN Tcl_Channel    TclGetDefaultStdChannel _ANSI_ARGS_((int type));
  1490. EXTERN Tcl_Obj *    TclGetElementOfIndexedArray _ANSI_ARGS_((
  1491.                 Tcl_Interp *interp, int localIndex,
  1492.                 Tcl_Obj *elemPtr, int leaveErrorMsg));
  1493. EXTERN char *        TclGetEnv _ANSI_ARGS_((CONST char *name));
  1494. EXTERN char *        TclGetExtension _ANSI_ARGS_((char *name));
  1495. EXTERN int        TclGetFrame _ANSI_ARGS_((Tcl_Interp *interp,
  1496.                 char *string, CallFrame **framePtrPtr));
  1497. EXTERN TclCmdProcType    TclGetInterpProc _ANSI_ARGS_((void));
  1498. EXTERN int        TclGetIntForIndex _ANSI_ARGS_((Tcl_Interp *interp,
  1499.                 Tcl_Obj *objPtr, int endValue, int *indexPtr));
  1500. EXTERN Tcl_Obj *    TclGetIndexedScalar _ANSI_ARGS_((Tcl_Interp *interp,
  1501.                 int localIndex, int leaveErrorMsg));
  1502. EXTERN int        TclGetLong _ANSI_ARGS_((Tcl_Interp *interp,
  1503.                 char *string, long *longPtr));
  1504. EXTERN int        TclGetLoadedPackages _ANSI_ARGS_((
  1505.                 Tcl_Interp *interp, char *targetName));
  1506. EXTERN int        TclGetNamespaceForQualName _ANSI_ARGS_((
  1507.                 Tcl_Interp *interp, char *qualName,
  1508.                 Namespace *cxtNsPtr, int flags,
  1509.                 Namespace **nsPtrPtr, Namespace **altNsPtrPtr,
  1510.                 Namespace **actualCxtPtrPtr,
  1511.                 char **simpleNamePtr));
  1512. EXTERN TclObjCmdProcType TclGetObjInterpProc _ANSI_ARGS_((void));
  1513. EXTERN int        TclGetOpenMode _ANSI_ARGS_((Tcl_Interp *interp,
  1514.                     char *string, int *seekFlagPtr));
  1515. EXTERN Tcl_Command    TclGetOriginalCommand _ANSI_ARGS_((
  1516.                 Tcl_Command command));
  1517. EXTERN char *        TclGetUserHome _ANSI_ARGS_((char *name,
  1518.                 Tcl_DString *bufferPtr));
  1519. EXTERN int        TclGlobalInvoke _ANSI_ARGS_((Tcl_Interp *interp,
  1520.                     int argc, char **argv, int flags));
  1521. EXTERN int        TclGuessPackageName _ANSI_ARGS_((char *fileName,
  1522.                 Tcl_DString *bufPtr));
  1523. EXTERN int        TclHasSockets _ANSI_ARGS_((Tcl_Interp *interp));
  1524. EXTERN int        TclHideUnsafeCommands _ANSI_ARGS_((
  1525.                     Tcl_Interp *interp));
  1526. EXTERN int        TclInExit _ANSI_ARGS_((void));
  1527. EXTERN Tcl_Obj *    TclIncrElementOfIndexedArray _ANSI_ARGS_((
  1528.                             Tcl_Interp *interp, int localIndex,
  1529.                 Tcl_Obj *elemPtr, long incrAmount));
  1530. EXTERN Tcl_Obj *    TclIncrIndexedScalar _ANSI_ARGS_((
  1531.                             Tcl_Interp *interp, int localIndex,
  1532.                 long incrAmount));
  1533. EXTERN Tcl_Obj *    TclIncrVar2 _ANSI_ARGS_((Tcl_Interp *interp,
  1534.                 Tcl_Obj *part1Ptr, Tcl_Obj *part2Ptr,
  1535.                 long incrAmount, int part1NotParsed));
  1536. EXTERN void        TclInitCompiledLocals _ANSI_ARGS_((
  1537.                 Tcl_Interp *interp, CallFrame *framePtr,
  1538.                 Namespace *nsPtr));
  1539. EXTERN void        TclInitNamespaces _ANSI_ARGS_((void));
  1540. EXTERN int        TclInterpInit _ANSI_ARGS_((Tcl_Interp *interp));
  1541. EXTERN int        TclInvoke _ANSI_ARGS_((Tcl_Interp *interp,
  1542.                     int argc, char **argv, int flags));
  1543. EXTERN int        TclInvokeObjectCommand _ANSI_ARGS_((
  1544.                             ClientData clientData, Tcl_Interp *interp,
  1545.                             int argc, char **argv));
  1546. EXTERN int        TclInvokeStringCommand _ANSI_ARGS_((
  1547.                             ClientData clientData, Tcl_Interp *interp,
  1548.                             int objc, Tcl_Obj *CONST objv[]));
  1549. EXTERN Proc *        TclIsProc _ANSI_ARGS_((Command *cmdPtr));
  1550. EXTERN int        TclLoadFile _ANSI_ARGS_((Tcl_Interp *interp,
  1551.                 char *fileName, char *sym1, char *sym2,
  1552.                 Tcl_PackageInitProc **proc1Ptr,
  1553.                 Tcl_PackageInitProc **proc2Ptr));
  1554. EXTERN int        TclLooksLikeInt _ANSI_ARGS_((char *p));
  1555. EXTERN Var *        TclLookupVar _ANSI_ARGS_((Tcl_Interp *interp,
  1556.                 char *part1, char *part2, int flags, char *msg,
  1557.                 int createPart1, int createPart2,
  1558.                 Var **arrayPtrPtr));
  1559. EXTERN int        TclMatchFiles _ANSI_ARGS_((Tcl_Interp *interp,
  1560.                 char *separators, Tcl_DString *dirPtr,
  1561.                 char *pattern, char *tail));
  1562. EXTERN int        TclNeedSpace _ANSI_ARGS_((char *start, char *end));
  1563. EXTERN Tcl_Obj *    TclNewProcBodyObj _ANSI_ARGS_((Proc *procPtr));
  1564. EXTERN int        TclObjCommandComplete _ANSI_ARGS_((Tcl_Obj *cmdPtr));
  1565. EXTERN int        TclObjInterpProc _ANSI_ARGS_((ClientData clientData,
  1566.                     Tcl_Interp *interp, int objc,
  1567.                 Tcl_Obj *CONST objv[]));
  1568. EXTERN int        TclObjInvoke _ANSI_ARGS_((Tcl_Interp *interp,
  1569.                     int objc, Tcl_Obj *CONST objv[], int flags));
  1570. EXTERN int        TclObjInvokeGlobal _ANSI_ARGS_((Tcl_Interp *interp,
  1571.                     int objc, Tcl_Obj *CONST objv[], int flags));
  1572. EXTERN int        TclOpenFileChannelDeleteProc _ANSI_ARGS_((
  1573.                 TclOpenFileChannelProc_ *proc));
  1574. EXTERN int        TclOpenFileChannelInsertProc _ANSI_ARGS_((
  1575.                 TclOpenFileChannelProc_ *proc));
  1576. EXTERN char *        TclpAlloc _ANSI_ARGS_((unsigned int size));
  1577.  
  1578. /*
  1579.  * On a Mac, we can exit gracefully if the stack gets too small.
  1580.  */
  1581.  
  1582. #ifdef MAC_TCL
  1583. EXTERN int        TclpCheckStackSpace _ANSI_ARGS_((void));
  1584. #else
  1585. #define TclpCheckStackSpace() (1)
  1586. #endif
  1587.  
  1588. EXTERN int        TclpCloseFile _ANSI_ARGS_((TclFile file));
  1589. EXTERN int        TclpCopyFile _ANSI_ARGS_((char *source, char *dest));
  1590. EXTERN int              TclpCopyDirectory _ANSI_ARGS_((char *source,
  1591.                 char *dest, Tcl_DString *errorPtr));
  1592. EXTERN Tcl_Channel    TclpCreateCommandChannel _ANSI_ARGS_((
  1593.                     TclFile readFile, TclFile writeFile,
  1594.                 TclFile errorFile, int numPids, Tcl_Pid *pidPtr));
  1595. EXTERN int              TclpCreateDirectory _ANSI_ARGS_((char *path));
  1596. EXTERN int              TclpCreatePipe _ANSI_ARGS_((TclFile *readPipe,
  1597.                 TclFile *writePipe));
  1598. EXTERN int        TclpCreateProcess _ANSI_ARGS_((Tcl_Interp *interp,
  1599.                 int argc, char **argv, TclFile inputFile, 
  1600.                 TclFile outputFile, TclFile errorFile,
  1601.                 Tcl_Pid *pidPtr));
  1602. EXTERN TclFile        TclpCreateTempFile _ANSI_ARGS_((char *contents, 
  1603.                 Tcl_DString *namePtr));
  1604. EXTERN int              TclpDeleteFile _ANSI_ARGS_((char *path));
  1605. EXTERN void        TclpFinalize _ANSI_ARGS_((void));
  1606. EXTERN void        TclpFree _ANSI_ARGS_((char *ptr));
  1607. EXTERN unsigned long    TclpGetClicks _ANSI_ARGS_((void));
  1608. EXTERN unsigned long    TclpGetSeconds _ANSI_ARGS_((void));
  1609. EXTERN void        TclpGetTime _ANSI_ARGS_((Tcl_Time *time));
  1610. EXTERN int        TclpGetTimeZone _ANSI_ARGS_((unsigned long time));
  1611. EXTERN char *        TclpGetTZName _ANSI_ARGS_((void));
  1612. EXTERN int        TclpListVolumes _ANSI_ARGS_((Tcl_Interp *interp));
  1613. EXTERN TclFile        TclpMakeFile _ANSI_ARGS_((Tcl_Channel channel,
  1614.                 int direction));
  1615. EXTERN TclFile        TclpOpenFile _ANSI_ARGS_((char *fname, int mode));
  1616. EXTERN Tcl_Channel    TclpOpenFileChannel _ANSI_ARGS_((Tcl_Interp *interp,
  1617.                 char *fileName, char *modeString,
  1618.                 int permissions));
  1619. EXTERN char *        TclpRealloc _ANSI_ARGS_((char *ptr,
  1620.                 unsigned int size));
  1621. EXTERN int              TclpRemoveDirectory _ANSI_ARGS_((char *path,
  1622.                 int recursive, Tcl_DString *errorPtr));
  1623. EXTERN int              TclpRenameFile _ANSI_ARGS_((char *source, char *dest));
  1624. #ifndef TclpSysAlloc
  1625. EXTERN VOID *         TclpSysAlloc _ANSI_ARGS_((long size, int isBin));
  1626. #endif
  1627. #ifndef TclpSysFree
  1628. EXTERN void         TclpSysFree _ANSI_ARGS_((VOID *ptr));
  1629. #endif
  1630. #ifndef TclpSysRealloc
  1631. EXTERN VOID *         TclpSysRealloc _ANSI_ARGS_((VOID *cp,
  1632.                 unsigned int size));
  1633. #endif
  1634. EXTERN int        TclParseBraces _ANSI_ARGS_((Tcl_Interp *interp,
  1635.                 char *string, char **termPtr, ParseValue *pvPtr));
  1636. EXTERN int        TclParseNestedCmd _ANSI_ARGS_((Tcl_Interp *interp,
  1637.                 char *string, int flags, char **termPtr,
  1638.                 ParseValue *pvPtr));
  1639. EXTERN int        TclParseQuotes _ANSI_ARGS_((Tcl_Interp *interp,
  1640.                 char *string, int termChar, int flags,
  1641.                 char **termPtr, ParseValue *pvPtr));
  1642. EXTERN void        TclPlatformExit _ANSI_ARGS_((int status));
  1643. EXTERN void        TclPlatformInit _ANSI_ARGS_((Tcl_Interp *interp));
  1644. EXTERN char *        TclPrecTraceProc _ANSI_ARGS_((ClientData clientData,
  1645.                 Tcl_Interp *interp, char *name1, char *name2,
  1646.                 int flags));
  1647. EXTERN int        TclPreventAliasLoop _ANSI_ARGS_((Tcl_Interp *interp,
  1648.                     Tcl_Interp *cmdInterp, Tcl_Command cmd));
  1649. EXTERN void        TclPrintByteCodeObj _ANSI_ARGS_((Tcl_Interp *interp,
  1650.                     Tcl_Obj *objPtr));
  1651. EXTERN void        TclProcCleanupProc _ANSI_ARGS_((Proc *procPtr));
  1652. EXTERN int        TclProcCompileProc _ANSI_ARGS_((Tcl_Interp *interp,
  1653.                  Proc *procPtr, Tcl_Obj *bodyPtr, Namespace *nsPtr,
  1654.                  CONST char *description, CONST char *procName));
  1655. EXTERN void        TclProcDeleteProc _ANSI_ARGS_((ClientData clientData));
  1656. EXTERN int        TclProcInterpProc _ANSI_ARGS_((ClientData clientData,
  1657.                     Tcl_Interp *interp, int argc, char **argv));
  1658. EXTERN int        TclRenameCommand _ANSI_ARGS_((Tcl_Interp *interp,
  1659.                 char *oldName, char *newName)) ;
  1660. EXTERN void        TclResetShadowedCmdRefs _ANSI_ARGS_((
  1661.                 Tcl_Interp *interp, Command *newCmdPtr));
  1662. EXTERN int        TclServiceIdle _ANSI_ARGS_((void));
  1663. EXTERN Tcl_Obj *    TclSetElementOfIndexedArray _ANSI_ARGS_((
  1664.                             Tcl_Interp *interp, int localIndex,
  1665.                 Tcl_Obj *elemPtr, Tcl_Obj *objPtr,
  1666.                 int leaveErrorMsg));
  1667. EXTERN Tcl_Obj *    TclSetIndexedScalar _ANSI_ARGS_((Tcl_Interp *interp,
  1668.                 int localIndex, Tcl_Obj *objPtr,
  1669.                 int leaveErrorMsg));
  1670. EXTERN char *        TclSetPreInitScript _ANSI_ARGS_((char *string));
  1671. EXTERN void        TclSetupEnv _ANSI_ARGS_((Tcl_Interp *interp));
  1672. EXTERN int        TclSockGetPort _ANSI_ARGS_((Tcl_Interp *interp,
  1673.                     char *string, char *proto, int *portPtr));
  1674. EXTERN int        TclSockMinimumBuffers _ANSI_ARGS_((int sock,
  1675.                     int size));
  1676. EXTERN int        TclStat _ANSI_ARGS_((CONST char *path,
  1677.                 TclStat_ *buf));
  1678. EXTERN int        TclStatDeleteProc _ANSI_ARGS_((TclStatProc_ *proc));
  1679. EXTERN int        TclStatInsertProc _ANSI_ARGS_((TclStatProc_ *proc));
  1680. EXTERN void        TclTeardownNamespace _ANSI_ARGS_((Namespace *nsPtr));
  1681. EXTERN int        TclTestChannelCmd _ANSI_ARGS_((ClientData clientData,
  1682.                 Tcl_Interp *interp, int argc, char **argv));
  1683. EXTERN int        TclTestChannelEventCmd _ANSI_ARGS_((
  1684.                     ClientData clientData, Tcl_Interp *interp,
  1685.                             int argc, char **argv));
  1686. EXTERN int        TclUpdateReturnInfo _ANSI_ARGS_((Interp *iPtr));
  1687. EXTERN char *        TclWordEnd _ANSI_ARGS_((char *start, char *lastChar,
  1688.                 int nested, int *semiPtr));
  1689.  
  1690. /*
  1691.  *----------------------------------------------------------------
  1692.  * Command procedures in the generic core:
  1693.  *----------------------------------------------------------------
  1694.  */
  1695.  
  1696. EXTERN int    Tcl_AfterObjCmd _ANSI_ARGS_((ClientData clientData,
  1697.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1698. EXTERN int    Tcl_AppendObjCmd _ANSI_ARGS_((ClientData clientData,
  1699.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1700. EXTERN int    Tcl_ArrayObjCmd _ANSI_ARGS_((ClientData clientData,
  1701.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1702. EXTERN int    Tcl_BinaryObjCmd _ANSI_ARGS_((ClientData clientData,
  1703.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1704. EXTERN int    Tcl_BreakCmd _ANSI_ARGS_((ClientData clientData,
  1705.             Tcl_Interp *interp, int argc, char **argv));
  1706. EXTERN int    Tcl_CaseObjCmd _ANSI_ARGS_((ClientData clientData,
  1707.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1708. EXTERN int    Tcl_CatchObjCmd _ANSI_ARGS_((ClientData clientData,
  1709.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1710. EXTERN int    Tcl_CdObjCmd _ANSI_ARGS_((ClientData clientData,
  1711.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1712. EXTERN int    Tcl_ClockObjCmd _ANSI_ARGS_((ClientData clientData,
  1713.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1714. EXTERN int    Tcl_CloseObjCmd _ANSI_ARGS_((ClientData clientData,
  1715.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1716. EXTERN int    Tcl_ConcatObjCmd _ANSI_ARGS_((ClientData clientData,
  1717.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1718. EXTERN int    Tcl_ContinueCmd _ANSI_ARGS_((ClientData clientData,
  1719.             Tcl_Interp *interp, int argc, char **argv));
  1720. EXTERN int    Tcl_EofObjCmd _ANSI_ARGS_((ClientData clientData,
  1721.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1722. EXTERN int    Tcl_ErrorObjCmd _ANSI_ARGS_((ClientData clientData,
  1723.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1724. EXTERN int    Tcl_EvalObjCmd _ANSI_ARGS_((ClientData clientData,
  1725.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1726. EXTERN int    Tcl_ExecCmd _ANSI_ARGS_((ClientData clientData,
  1727.             Tcl_Interp *interp, int argc, char **argv));
  1728. EXTERN int    Tcl_ExitObjCmd _ANSI_ARGS_((ClientData clientData,
  1729.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1730. EXTERN int    Tcl_ExprObjCmd _ANSI_ARGS_((ClientData clientData,
  1731.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1732. EXTERN int    Tcl_FblockedObjCmd _ANSI_ARGS_((ClientData clientData,
  1733.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1734. EXTERN int    Tcl_FconfigureCmd _ANSI_ARGS_((ClientData clientData,
  1735.             Tcl_Interp *interp, int argc, char **argv));
  1736. EXTERN int    Tcl_FcopyObjCmd _ANSI_ARGS_((ClientData dummy,
  1737.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1738. EXTERN int    Tcl_FileObjCmd _ANSI_ARGS_((ClientData dummy,
  1739.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1740. EXTERN int    Tcl_FileEventCmd _ANSI_ARGS_((ClientData clientData,
  1741.             Tcl_Interp *interp, int argc, char **argv));
  1742. EXTERN int    Tcl_FlushObjCmd _ANSI_ARGS_((ClientData clientData,
  1743.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1744. EXTERN int    Tcl_ForCmd _ANSI_ARGS_((ClientData clientData,
  1745.             Tcl_Interp *interp, int argc, char **argv));
  1746. EXTERN int    Tcl_ForeachObjCmd _ANSI_ARGS_((ClientData clientData,
  1747.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1748. EXTERN int    Tcl_FormatObjCmd _ANSI_ARGS_((ClientData dummy,
  1749.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1750. EXTERN int    Tcl_GetsObjCmd _ANSI_ARGS_((ClientData clientData,
  1751.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1752. EXTERN int    Tcl_GlobalObjCmd _ANSI_ARGS_((ClientData clientData,
  1753.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1754. EXTERN int    Tcl_GlobCmd _ANSI_ARGS_((ClientData clientData,
  1755.             Tcl_Interp *interp, int argc, char **argv));
  1756. EXTERN int    Tcl_IfCmd _ANSI_ARGS_((ClientData clientData,
  1757.             Tcl_Interp *interp, int argc, char **argv));
  1758. EXTERN int    Tcl_IncrCmd _ANSI_ARGS_((ClientData clientData,
  1759.             Tcl_Interp *interp, int argc, char **argv));
  1760. EXTERN int    Tcl_InfoObjCmd _ANSI_ARGS_((ClientData clientData,
  1761.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1762. EXTERN int    Tcl_InterpObjCmd _ANSI_ARGS_((ClientData clientData,
  1763.             Tcl_Interp *interp, int argc, Tcl_Obj *CONST objv[]));
  1764. EXTERN int    Tcl_JoinObjCmd _ANSI_ARGS_((ClientData clientData,
  1765.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1766. EXTERN int    Tcl_LappendObjCmd _ANSI_ARGS_((ClientData clientData,
  1767.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1768. EXTERN int    Tcl_LindexObjCmd _ANSI_ARGS_((ClientData clientData,
  1769.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1770. EXTERN int    Tcl_LinsertObjCmd _ANSI_ARGS_((ClientData clientData,
  1771.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1772. EXTERN int    Tcl_LlengthObjCmd _ANSI_ARGS_((ClientData clientData,
  1773.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1774. EXTERN int    Tcl_ListObjCmd _ANSI_ARGS_((ClientData clientData,
  1775.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1776. EXTERN int    Tcl_LoadCmd _ANSI_ARGS_((ClientData clientData,
  1777.             Tcl_Interp *interp, int argc, char **argv));
  1778. EXTERN int    Tcl_LrangeObjCmd _ANSI_ARGS_((ClientData clientData,
  1779.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1780. EXTERN int    Tcl_LreplaceObjCmd _ANSI_ARGS_((ClientData clientData,
  1781.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1782. EXTERN int    Tcl_LsearchObjCmd _ANSI_ARGS_((ClientData clientData,
  1783.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1784. EXTERN int    Tcl_LsortObjCmd _ANSI_ARGS_((ClientData clientData,
  1785.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1786. EXTERN int    Tcl_NamespaceObjCmd _ANSI_ARGS_((ClientData clientData,
  1787.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1788. EXTERN int    Tcl_OpenObjCmd _ANSI_ARGS_((ClientData clientData,
  1789.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1790. EXTERN int    Tcl_PackageCmd _ANSI_ARGS_((ClientData clientData,
  1791.             Tcl_Interp *interp, int argc, char **argv));
  1792. EXTERN int    Tcl_PidObjCmd _ANSI_ARGS_((ClientData clientData,
  1793.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1794. EXTERN int    Tcl_ProcObjCmd _ANSI_ARGS_((ClientData clientData,
  1795.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1796. EXTERN int    Tcl_PutsObjCmd _ANSI_ARGS_((ClientData clientData,
  1797.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1798. EXTERN int    Tcl_PwdCmd _ANSI_ARGS_((ClientData clientData,
  1799.             Tcl_Interp *interp, int argc, char **argv));
  1800. EXTERN int    Tcl_ReadObjCmd _ANSI_ARGS_((ClientData clientData,
  1801.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1802. EXTERN int    Tcl_RegexpCmd _ANSI_ARGS_((ClientData clientData,
  1803.             Tcl_Interp *interp, int argc, char **argv));
  1804. EXTERN int    Tcl_RegsubCmd _ANSI_ARGS_((ClientData clientData,
  1805.             Tcl_Interp *interp, int argc, char **argv));
  1806. EXTERN int    Tcl_RenameObjCmd _ANSI_ARGS_((ClientData clientData,
  1807.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1808. EXTERN int    Tcl_ReturnObjCmd _ANSI_ARGS_((ClientData clientData,
  1809.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1810. EXTERN int    Tcl_ScanCmd _ANSI_ARGS_((ClientData clientData,
  1811.             Tcl_Interp *interp, int argc, char **argv));
  1812. EXTERN int    Tcl_SeekCmd _ANSI_ARGS_((ClientData clientData,
  1813.             Tcl_Interp *interp, int argc, char **argv));
  1814. EXTERN int    Tcl_SetCmd _ANSI_ARGS_((ClientData clientData,
  1815.             Tcl_Interp *interp, int argc, char **argv));
  1816. EXTERN int    Tcl_SplitObjCmd _ANSI_ARGS_((ClientData clientData,
  1817.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1818. EXTERN int    Tcl_SocketCmd _ANSI_ARGS_((ClientData clientData,
  1819.             Tcl_Interp *interp, int argc, char **argv));
  1820. EXTERN int    Tcl_SourceObjCmd _ANSI_ARGS_((ClientData clientData,
  1821.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1822. EXTERN int    Tcl_StringObjCmd _ANSI_ARGS_((ClientData clientData,
  1823.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1824. EXTERN int    Tcl_SubstCmd _ANSI_ARGS_((ClientData clientData,
  1825.             Tcl_Interp *interp, int argc, char **argv));
  1826. EXTERN int    Tcl_SwitchObjCmd _ANSI_ARGS_((ClientData clientData,
  1827.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1828. EXTERN int    Tcl_TellCmd _ANSI_ARGS_((ClientData clientData,
  1829.             Tcl_Interp *interp, int argc, char **argv));
  1830. EXTERN int    Tcl_TimeObjCmd _ANSI_ARGS_((ClientData clientData,
  1831.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1832. EXTERN int    Tcl_TraceCmd _ANSI_ARGS_((ClientData clientData,
  1833.             Tcl_Interp *interp, int argc, char **argv));
  1834. EXTERN int    Tcl_UnsetObjCmd _ANSI_ARGS_((ClientData clientData,
  1835.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1836. EXTERN int    Tcl_UpdateCmd _ANSI_ARGS_((ClientData clientData,
  1837.             Tcl_Interp *interp, int argc, char **argv));
  1838. EXTERN int    Tcl_UplevelObjCmd _ANSI_ARGS_((ClientData clientData,
  1839.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1840. EXTERN int    Tcl_UpvarObjCmd _ANSI_ARGS_((ClientData clientData,
  1841.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1842. EXTERN int    Tcl_VariableObjCmd _ANSI_ARGS_((ClientData clientData,
  1843.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1844. EXTERN int    Tcl_VwaitCmd _ANSI_ARGS_((ClientData clientData,
  1845.             Tcl_Interp *interp, int argc, char **argv));
  1846. EXTERN int    Tcl_WhileCmd _ANSI_ARGS_((ClientData clientData,
  1847.             Tcl_Interp *interp, int argc, char **argv));
  1848.  
  1849. /*
  1850.  *----------------------------------------------------------------
  1851.  * Command procedures found only in the Mac version of the core:
  1852.  *----------------------------------------------------------------
  1853.  */
  1854.  
  1855. #ifdef MAC_TCL
  1856. EXTERN int     Tcl_EchoCmd _ANSI_ARGS_((ClientData clientData,
  1857.             Tcl_Interp *interp, int argc, char **argv));
  1858. EXTERN int     Tcl_LsCmd _ANSI_ARGS_((ClientData clientData,
  1859.             Tcl_Interp *interp, int argc, char **argv));
  1860. EXTERN int     Tcl_BeepObjCmd _ANSI_ARGS_((ClientData clientData,
  1861.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1862. EXTERN int     Tcl_MacSourceObjCmd _ANSI_ARGS_((ClientData clientData,
  1863.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1864. EXTERN int    Tcl_ResourceObjCmd _ANSI_ARGS_((ClientData clientData,
  1865.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1866. #endif
  1867.  
  1868. /*
  1869.  *----------------------------------------------------------------
  1870.  * Compilation procedures for commands in the generic core:
  1871.  *----------------------------------------------------------------
  1872.  */
  1873.  
  1874. EXTERN int    TclCompileBreakCmd _ANSI_ARGS_((Tcl_Interp *interp,
  1875.             char *string, char *lastChar, int compileFlags,
  1876.             struct CompileEnv *compileEnvPtr));
  1877. EXTERN int    TclCompileCatchCmd _ANSI_ARGS_((Tcl_Interp *interp,
  1878.             char *string, char *lastChar, int compileFlags,
  1879.             struct CompileEnv *compileEnvPtr));
  1880. EXTERN int    TclCompileContinueCmd _ANSI_ARGS_((Tcl_Interp *interp,
  1881.             char *string, char *lastChar, int compileFlags,
  1882.             struct CompileEnv *compileEnvPtr));
  1883. EXTERN int    TclCompileExprCmd _ANSI_ARGS_((Tcl_Interp *interp,
  1884.             char *string, char *lastChar, int compileFlags,
  1885.             struct CompileEnv *compileEnvPtr));
  1886. EXTERN int    TclCompileForCmd _ANSI_ARGS_((Tcl_Interp *interp,
  1887.             char *string, char *lastChar, int compileFlags,
  1888.             struct CompileEnv *compileEnvPtr));
  1889. EXTERN int    TclCompileForeachCmd _ANSI_ARGS_((Tcl_Interp *interp,
  1890.             char *string, char *lastChar, int compileFlags,
  1891.             struct CompileEnv *compileEnvPtr));
  1892. EXTERN int    TclCompileIfCmd _ANSI_ARGS_((Tcl_Interp *interp,
  1893.             char *string, char *lastChar, int compileFlags,
  1894.             struct CompileEnv *compileEnvPtr));
  1895. EXTERN int    TclCompileIncrCmd _ANSI_ARGS_((Tcl_Interp *interp,
  1896.             char *string, char *lastChar, int compileFlags,
  1897.             struct CompileEnv *compileEnvPtr));
  1898. EXTERN int    TclCompileSetCmd _ANSI_ARGS_((Tcl_Interp *interp,
  1899.             char *string, char *lastChar, int compileFlags,
  1900.             struct CompileEnv *compileEnvPtr));
  1901. EXTERN int    TclCompileWhileCmd _ANSI_ARGS_((Tcl_Interp *interp,
  1902.             char *string, char *lastChar, int compileFlags,
  1903.             struct CompileEnv *compileEnvPtr));
  1904.  
  1905. /*
  1906.  *----------------------------------------------------------------
  1907.  * Macros used by the Tcl core to create and release Tcl objects.
  1908.  * TclNewObj(objPtr) creates a new object denoting an empty string.
  1909.  * TclDecrRefCount(objPtr) decrements the object's reference count,
  1910.  * and frees the object if its reference count is zero.
  1911.  * These macros are inline versions of Tcl_NewObj() and
  1912.  * Tcl_DecrRefCount(). Notice that the names differ in not having
  1913.  * a "_" after the "Tcl". Notice also that these macros reference
  1914.  * their argument more than once, so you should avoid calling them
  1915.  * with an expression that is expensive to compute or has
  1916.  * side effects. The ANSI C "prototypes" for these macros are:
  1917.  *
  1918.  * EXTERN void    TclNewObj _ANSI_ARGS_((Tcl_Obj *objPtr));
  1919.  * EXTERN void    TclDecrRefCount _ANSI_ARGS_((Tcl_Obj *objPtr));
  1920.  *----------------------------------------------------------------
  1921.  */
  1922.  
  1923. #ifdef TCL_COMPILE_STATS
  1924. #  define TclIncrObjsAllocated() \
  1925.     tclObjsAlloced++
  1926. #  define TclIncrObjsFreed() \
  1927.     tclObjsFreed++
  1928. #else
  1929. #  define TclIncrObjsAllocated()
  1930. #  define TclIncrObjsFreed()
  1931. #endif /* TCL_COMPILE_STATS */
  1932.  
  1933. #ifdef TCL_MEM_DEBUG
  1934. #  define TclNewObj(objPtr) \
  1935.     (objPtr) = (Tcl_Obj *) Tcl_DbCkalloc(sizeof(Tcl_Obj), __FILE__, __LINE__); \
  1936.     (objPtr)->refCount = 0; \
  1937.     (objPtr)->bytes    = tclEmptyStringRep; \
  1938.     (objPtr)->length   = 0; \
  1939.     (objPtr)->typePtr  = NULL; \
  1940.     TclIncrObjsAllocated()
  1941. #  define TclDbNewObj(objPtr, file, line) \
  1942.     (objPtr) = (Tcl_Obj *) Tcl_DbCkalloc(sizeof(Tcl_Obj), (file), (line)); \
  1943.     (objPtr)->refCount = 0; \
  1944.     (objPtr)->bytes    = tclEmptyStringRep; \
  1945.     (objPtr)->length   = 0; \
  1946.     (objPtr)->typePtr  = NULL; \
  1947.     TclIncrObjsAllocated()
  1948. #  define TclDecrRefCount(objPtr) \
  1949.     if (--(objPtr)->refCount <= 0) { \
  1950.      if ((objPtr)->refCount < -1) \
  1951.             panic("Reference count for %lx was negative: %s line %d", \
  1952.           (objPtr), __FILE__, __LINE__); \
  1953.         if (((objPtr)->bytes != NULL) \
  1954.             && ((objPtr)->bytes != tclEmptyStringRep)) { \
  1955.         ckfree((char *) (objPtr)->bytes); \
  1956.         } \
  1957.         if (((objPtr)->typePtr != NULL) \
  1958.             && ((objPtr)->typePtr->freeIntRepProc != NULL)) { \
  1959.         (objPtr)->typePtr->freeIntRepProc(objPtr); \
  1960.         } \
  1961.         ckfree((char *) (objPtr)); \
  1962.         TclIncrObjsFreed(); \
  1963.     }
  1964. #else /* not TCL_MEM_DEBUG */
  1965. #  define TclNewObj(objPtr) \
  1966.     if (tclFreeObjList == NULL) { \
  1967.     TclAllocateFreeObjects(); \
  1968.     } \
  1969.     (objPtr) = tclFreeObjList; \
  1970.     tclFreeObjList = (Tcl_Obj *) \
  1971.     tclFreeObjList->internalRep.otherValuePtr; \
  1972.     (objPtr)->refCount = 0; \
  1973.     (objPtr)->bytes    = tclEmptyStringRep; \
  1974.     (objPtr)->length   = 0; \
  1975.     (objPtr)->typePtr  = NULL; \
  1976.     TclIncrObjsAllocated()
  1977. #  define TclDecrRefCount(objPtr) \
  1978.     if (--(objPtr)->refCount <= 0) { \
  1979.         if (((objPtr)->bytes != NULL) \
  1980.             && ((objPtr)->bytes != tclEmptyStringRep)) { \
  1981.         ckfree((char *) (objPtr)->bytes); \
  1982.         } \
  1983.         if (((objPtr)->typePtr != NULL) \
  1984.             && ((objPtr)->typePtr->freeIntRepProc != NULL)) { \
  1985.         (objPtr)->typePtr->freeIntRepProc(objPtr); \
  1986.         } \
  1987.         (objPtr)->internalRep.otherValuePtr = (VOID *) tclFreeObjList; \
  1988.         tclFreeObjList = (objPtr); \
  1989.         TclIncrObjsFreed(); \
  1990.     }
  1991. #endif /* TCL_MEM_DEBUG */
  1992.  
  1993. /*
  1994.  *----------------------------------------------------------------
  1995.  * Macro used by the Tcl core to set a Tcl_Obj's string representation
  1996.  * to a copy of the "len" bytes starting at "bytePtr". This code
  1997.  * works even if the byte array contains NULLs as long as the length
  1998.  * is correct. Because "len" is referenced multiple times, it should
  1999.  * be as simple an expression as possible. The ANSI C "prototype" for
  2000.  * this macro is:
  2001.  *
  2002.  * EXTERN void    TclInitStringRep _ANSI_ARGS_((Tcl_Obj *objPtr,
  2003.  *            char *bytePtr, int len));
  2004.  *----------------------------------------------------------------
  2005.  */
  2006.  
  2007. #define TclInitStringRep(objPtr, bytePtr, len) \
  2008.     if ((len) == 0) { \
  2009.         (objPtr)->bytes  = tclEmptyStringRep; \
  2010.     (objPtr)->length = 0; \
  2011.     } else { \
  2012.     (objPtr)->bytes = (char *) ckalloc((unsigned) ((len) + 1)); \
  2013.     memcpy((VOID *) (objPtr)->bytes, (VOID *) (bytePtr), \
  2014.             (unsigned) (len)); \
  2015.     (objPtr)->bytes[len] = '\0'; \
  2016.     (objPtr)->length = (len); \
  2017.     }
  2018.  
  2019. /*
  2020.  *----------------------------------------------------------------
  2021.  * Macro used by the Tcl core to get the string representation's
  2022.  * byte array pointer and length from a Tcl_Obj. This is an inline
  2023.  * version of Tcl_GetStringFromObj(). "lengthPtr" must be the
  2024.  * address of an integer variable or NULL; If non-NULL, that variable
  2025.  * will be set to the string rep's length. The macro's expression
  2026.  * result is the string rep's byte pointer which might be NULL.
  2027.  * Note that the bytes referenced by this pointer must not be modified
  2028.  * by the caller. The ANSI C "prototype" for this macro is:
  2029.  *
  2030.  * EXTERN char *  TclGetStringFromObj _ANSI_ARGS_((Tcl_Obj *objPtr,
  2031.  *               int *lengthPtr));
  2032.  *----------------------------------------------------------------
  2033.  */
  2034.  
  2035. #define TclGetStringFromObj(objPtr, lengthPtr) \
  2036.     ((objPtr)->bytes? \
  2037.         ((lengthPtr)? \
  2038.         ((*(lengthPtr) = (objPtr)->length), (objPtr)->bytes) : \
  2039.         (objPtr)->bytes) : \
  2040.         Tcl_GetStringFromObj((objPtr), (lengthPtr)))
  2041.  
  2042. /*
  2043.  *----------------------------------------------------------------
  2044.  * Macro used by the Tcl core to reset an interpreter's Tcl object
  2045.  * result to an unshared empty string object with ref count one.
  2046.  * This does not clear any error information for the interpreter.
  2047.  * The ANSI C "prototype" for this macro is:
  2048.  *
  2049.  * EXTERN void    TclResetObjResult _ANSI_ARGS_((Tcl_Interp *interp));
  2050.  *---------------------------------------------------------------
  2051.  */
  2052.  
  2053. #define TclResetObjResult(interp) \
  2054.     { \
  2055.         register Tcl_Obj *objResultPtr = ((Interp *) interp)->objResultPtr; \
  2056.         if (Tcl_IsShared(objResultPtr)) { \
  2057.         TclDecrRefCount(objResultPtr); \
  2058.         TclNewObj(objResultPtr); \
  2059.         Tcl_IncrRefCount(objResultPtr); \
  2060.         ((Interp *) interp)->objResultPtr = objResultPtr; \
  2061.         } else { \
  2062.         if ((objResultPtr->bytes != NULL) \
  2063.             && (objResultPtr->bytes != tclEmptyStringRep)) { \
  2064.             ckfree((char *) objResultPtr->bytes); \
  2065.         } \
  2066.         objResultPtr->bytes  = tclEmptyStringRep; \
  2067.         objResultPtr->length = 0; \
  2068.         if ((objResultPtr->typePtr != NULL) \
  2069.                 && (objResultPtr->typePtr->freeIntRepProc != NULL)) { \
  2070.             objResultPtr->typePtr->freeIntRepProc(objResultPtr); \
  2071.         } \
  2072.         objResultPtr->typePtr = (Tcl_ObjType *) NULL; \
  2073.         } \
  2074.     }
  2075.  
  2076. /*
  2077.  *----------------------------------------------------------------
  2078.  * Procedures used in conjunction with Tcl namespaces. They are
  2079.  * defined here instead of in tcl.h since they are not stable yet.
  2080.  *----------------------------------------------------------------
  2081.  */
  2082.  
  2083. EXTERN void        Tcl_AddInterpResolvers _ANSI_ARGS_((Tcl_Interp *interp,
  2084.                  char *name, Tcl_ResolveCmdProc *cmdProc,
  2085.                  Tcl_ResolveVarProc *varProc,
  2086.                  Tcl_ResolveCompiledVarProc *compiledVarProc));
  2087. EXTERN int        Tcl_AppendExportList _ANSI_ARGS_((
  2088.                 Tcl_Interp *interp, Tcl_Namespace *nsPtr,
  2089.                 Tcl_Obj *objPtr));
  2090. EXTERN Tcl_Namespace *    Tcl_CreateNamespace _ANSI_ARGS_((Tcl_Interp *interp,
  2091.                 char *name, ClientData clientData,
  2092.                 Tcl_NamespaceDeleteProc *deleteProc));
  2093. EXTERN void        Tcl_DeleteNamespace _ANSI_ARGS_((
  2094.                 Tcl_Namespace *nsPtr));
  2095. EXTERN int        Tcl_Export _ANSI_ARGS_((Tcl_Interp *interp,
  2096.                 Tcl_Namespace *nsPtr, char *pattern,
  2097.                 int resetListFirst));
  2098. EXTERN Tcl_Command    Tcl_FindCommand _ANSI_ARGS_((Tcl_Interp *interp,
  2099.                 char *name, Tcl_Namespace *contextNsPtr,
  2100.                 int flags));
  2101. EXTERN Tcl_Namespace *    Tcl_FindNamespace _ANSI_ARGS_((Tcl_Interp *interp,
  2102.                 char *name, Tcl_Namespace *contextNsPtr,
  2103.                 int flags));
  2104. EXTERN int              Tcl_GetInterpResolvers _ANSI_ARGS_((Tcl_Interp *interp,
  2105.                             char *name, Tcl_ResolverInfo *resInfo));
  2106. EXTERN int              Tcl_GetNamespaceResolvers _ANSI_ARGS_((
  2107.                 Tcl_Namespace *namespacePtr,
  2108.                 Tcl_ResolverInfo *resInfo));
  2109. EXTERN void        Tcl_GetVariableFullName _ANSI_ARGS_((
  2110.                 Tcl_Interp *interp, Tcl_Var variable,
  2111.                   Tcl_Obj *objPtr));
  2112. EXTERN Tcl_Var        Tcl_FindNamespaceVar _ANSI_ARGS_((
  2113.                 Tcl_Interp *interp, char *name,
  2114.                 Tcl_Namespace *contextNsPtr, int flags));
  2115. EXTERN int        Tcl_ForgetImport _ANSI_ARGS_((Tcl_Interp *interp,
  2116.                 Tcl_Namespace *nsPtr, char *pattern));
  2117. EXTERN Tcl_Command    Tcl_GetCommandFromObj _ANSI_ARGS_((
  2118.                 Tcl_Interp *interp, Tcl_Obj *objPtr));
  2119. EXTERN void        Tcl_GetCommandFullName _ANSI_ARGS_((
  2120.                 Tcl_Interp *interp, Tcl_Command command,
  2121.                 Tcl_Obj *objPtr));
  2122. EXTERN Tcl_Namespace *    Tcl_GetCurrentNamespace _ANSI_ARGS_((
  2123.                 Tcl_Interp *interp));
  2124. EXTERN Tcl_Namespace *    Tcl_GetGlobalNamespace _ANSI_ARGS_((
  2125.                 Tcl_Interp *interp));
  2126. EXTERN void        Tcl_GetVariableFullName _ANSI_ARGS_((
  2127.                 Tcl_Interp *interp, Tcl_Var variable,
  2128.                 Tcl_Obj *objPtr));
  2129. EXTERN int        Tcl_Import _ANSI_ARGS_((Tcl_Interp *interp,
  2130.                 Tcl_Namespace *nsPtr, char *pattern,
  2131.                 int allowOverwrite));
  2132. EXTERN void        Tcl_PopCallFrame _ANSI_ARGS_((Tcl_Interp* interp));
  2133. EXTERN int        Tcl_PushCallFrame _ANSI_ARGS_((Tcl_Interp* interp,
  2134.                 Tcl_CallFrame *framePtr, Tcl_Namespace *nsPtr,
  2135.                 int isProcCallFrame)); 
  2136. EXTERN int        Tcl_RemoveInterpResolvers _ANSI_ARGS_((
  2137.                 Tcl_Interp *interp, char *name));
  2138. EXTERN void        Tcl_SetNamespaceResolvers _ANSI_ARGS_((
  2139.                 Tcl_Namespace *namespacePtr,
  2140.                 Tcl_ResolveCmdProc *cmdProc,
  2141.                 Tcl_ResolveVarProc *varProc,
  2142.                 Tcl_ResolveCompiledVarProc *compiledVarProc));
  2143.  
  2144. # undef TCL_STORAGE_CLASS
  2145. # define TCL_STORAGE_CLASS DLLIMPORT
  2146.  
  2147. #endif /* _TCLINT */
  2148.  
  2149.