os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/generic/tclInt.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
/*
sl@0
     2
 * tclInt.h --
sl@0
     3
 *
sl@0
     4
 *	Declarations of things used internally by the Tcl interpreter.
sl@0
     5
 *
sl@0
     6
 * Copyright (c) 1987-1993 The Regents of the University of California.
sl@0
     7
 * Copyright (c) 1993-1997 Lucent Technologies.
sl@0
     8
 * Copyright (c) 1994-1998 Sun Microsystems, Inc.
sl@0
     9
 * Copyright (c) 1998-1999 by Scriptics Corporation.
sl@0
    10
 * Copyright (c) 2001, 2002 by Kevin B. Kenny.  All rights reserved.
sl@0
    11
 * Portions Copyright (c) 2007 Nokia Corporation and/or its subsidiaries. All rights reserved.  
sl@0
    12
 *
sl@0
    13
 * See the file "license.terms" for information on usage and redistribution
sl@0
    14
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
sl@0
    15
 *
sl@0
    16
 * RCS: @(#) $Id: tclInt.h,v 1.118.2.28 2007/05/10 21:32:17 dgp Exp $
sl@0
    17
 */
sl@0
    18
sl@0
    19
#ifndef _TCLINT
sl@0
    20
#define _TCLINT
sl@0
    21
sl@0
    22
/*
sl@0
    23
 * Common include files needed by most of the Tcl source files are
sl@0
    24
 * included here, so that system-dependent personalizations for the
sl@0
    25
 * include files only have to be made in once place.  This results
sl@0
    26
 * in a few extra includes, but greater modularity.  The order of
sl@0
    27
 * the three groups of #includes is important.	For example, stdio.h
sl@0
    28
 * is needed by tcl.h, and the _ANSI_ARGS_ declaration in tcl.h is
sl@0
    29
 * needed by stdlib.h in some configurations.
sl@0
    30
 */
sl@0
    31
sl@0
    32
#ifndef _TCL
sl@0
    33
#include "tcl.h"
sl@0
    34
#endif
sl@0
    35
sl@0
    36
#include <stdio.h>
sl@0
    37
sl@0
    38
#include <ctype.h>
sl@0
    39
#ifdef NO_LIMITS_H
sl@0
    40
#   include "../compat/limits.h"
sl@0
    41
#else
sl@0
    42
#   include <limits.h>
sl@0
    43
#endif
sl@0
    44
#ifdef NO_STDLIB_H
sl@0
    45
#   include "../compat/stdlib.h"
sl@0
    46
#else
sl@0
    47
#   include <stdlib.h>
sl@0
    48
#endif
sl@0
    49
#ifdef NO_STRING_H
sl@0
    50
#include "../compat/string.h"
sl@0
    51
#else
sl@0
    52
#include <string.h>
sl@0
    53
#endif
sl@0
    54
sl@0
    55
/*
sl@0
    56
 * Ensure WORDS_BIGENDIAN is defined correcly:
sl@0
    57
 * Needs to happen here in addition to configure to work with fat compiles on
sl@0
    58
 * Darwin (where configure runs only once for multiple architectures).
sl@0
    59
 */
sl@0
    60
sl@0
    61
#ifdef HAVE_SYS_TYPES_H
sl@0
    62
#    include <sys/types.h>
sl@0
    63
#endif
sl@0
    64
#ifdef HAVE_SYS_PARAM_H
sl@0
    65
#    include <sys/param.h>
sl@0
    66
#endif
sl@0
    67
#ifdef BYTE_ORDER
sl@0
    68
#    ifdef BIG_ENDIAN
sl@0
    69
#        if BYTE_ORDER == BIG_ENDIAN
sl@0
    70
#            undef WORDS_BIGENDIAN
sl@0
    71
#            define WORDS_BIGENDIAN
sl@0
    72
#        endif
sl@0
    73
#    endif
sl@0
    74
#    ifdef LITTLE_ENDIAN
sl@0
    75
#        if BYTE_ORDER == LITTLE_ENDIAN
sl@0
    76
#            undef WORDS_BIGENDIAN
sl@0
    77
#        endif
sl@0
    78
#    endif
sl@0
    79
#endif
sl@0
    80
sl@0
    81
/*
sl@0
    82
 * Used to tag functions that are only to be visible within the module being
sl@0
    83
 * built and not outside it (where this is supported by the linker).
sl@0
    84
 */
sl@0
    85
sl@0
    86
#ifndef MODULE_SCOPE
sl@0
    87
#   ifdef __cplusplus
sl@0
    88
#	define MODULE_SCOPE extern "C"
sl@0
    89
#   else
sl@0
    90
#	define MODULE_SCOPE extern
sl@0
    91
#   endif
sl@0
    92
#endif
sl@0
    93
sl@0
    94
#undef TCL_STORAGE_CLASS
sl@0
    95
#ifdef BUILD_tcl
sl@0
    96
# define TCL_STORAGE_CLASS DLLEXPORT
sl@0
    97
#else
sl@0
    98
# ifdef USE_TCL_STUBS
sl@0
    99
#  define TCL_STORAGE_CLASS
sl@0
   100
# else
sl@0
   101
#  define TCL_STORAGE_CLASS DLLIMPORT
sl@0
   102
# endif
sl@0
   103
#endif
sl@0
   104
sl@0
   105
/*
sl@0
   106
 * The following procedures allow namespaces to be customized to
sl@0
   107
 * support special name resolution rules for commands/variables.
sl@0
   108
 * 
sl@0
   109
 */
sl@0
   110
sl@0
   111
struct Tcl_ResolvedVarInfo;
sl@0
   112
sl@0
   113
typedef Tcl_Var (Tcl_ResolveRuntimeVarProc) _ANSI_ARGS_((
sl@0
   114
    Tcl_Interp* interp, struct Tcl_ResolvedVarInfo *vinfoPtr));
sl@0
   115
sl@0
   116
typedef void (Tcl_ResolveVarDeleteProc) _ANSI_ARGS_((
sl@0
   117
    struct Tcl_ResolvedVarInfo *vinfoPtr));
sl@0
   118
sl@0
   119
/*
sl@0
   120
 * The following structure encapsulates the routines needed to resolve a
sl@0
   121
 * variable reference at runtime.  Any variable specific state will typically
sl@0
   122
 * be appended to this structure.
sl@0
   123
 */
sl@0
   124
sl@0
   125
sl@0
   126
typedef struct Tcl_ResolvedVarInfo {
sl@0
   127
    Tcl_ResolveRuntimeVarProc *fetchProc;
sl@0
   128
    Tcl_ResolveVarDeleteProc *deleteProc;
sl@0
   129
} Tcl_ResolvedVarInfo;
sl@0
   130
sl@0
   131
sl@0
   132
sl@0
   133
typedef int (Tcl_ResolveCompiledVarProc) _ANSI_ARGS_((
sl@0
   134
    Tcl_Interp* interp, CONST84 char* name, int length,
sl@0
   135
    Tcl_Namespace *context, Tcl_ResolvedVarInfo **rPtr));
sl@0
   136
sl@0
   137
typedef int (Tcl_ResolveVarProc) _ANSI_ARGS_((
sl@0
   138
    Tcl_Interp* interp, CONST84 char* name, Tcl_Namespace *context,
sl@0
   139
    int flags, Tcl_Var *rPtr));
sl@0
   140
sl@0
   141
typedef int (Tcl_ResolveCmdProc) _ANSI_ARGS_((Tcl_Interp* interp,
sl@0
   142
    CONST84 char* name, Tcl_Namespace *context, int flags,
sl@0
   143
    Tcl_Command *rPtr));
sl@0
   144
 
sl@0
   145
typedef struct Tcl_ResolverInfo {
sl@0
   146
    Tcl_ResolveCmdProc *cmdResProc;	/* Procedure handling command name
sl@0
   147
					 * resolution. */
sl@0
   148
    Tcl_ResolveVarProc *varResProc;	/* Procedure handling variable name
sl@0
   149
					 * resolution for variables that
sl@0
   150
					 * can only be handled at runtime. */
sl@0
   151
    Tcl_ResolveCompiledVarProc *compiledVarResProc;
sl@0
   152
					/* Procedure handling variable name
sl@0
   153
					 * resolution at compile time. */
sl@0
   154
} Tcl_ResolverInfo;
sl@0
   155
sl@0
   156
/*
sl@0
   157
 *----------------------------------------------------------------
sl@0
   158
 * Data structures related to namespaces.
sl@0
   159
 *----------------------------------------------------------------
sl@0
   160
 */
sl@0
   161
sl@0
   162
/*
sl@0
   163
 * The structure below defines a namespace.
sl@0
   164
 * Note: the first five fields must match exactly the fields in a
sl@0
   165
 * Tcl_Namespace structure (see tcl.h). If you change one, be sure to
sl@0
   166
 * change the other.
sl@0
   167
 */
sl@0
   168
sl@0
   169
typedef struct Namespace {
sl@0
   170
    char *name;			 /* The namespace's simple (unqualified)
sl@0
   171
				  * name. This contains no ::'s. The name of
sl@0
   172
				  * the global namespace is "" although "::"
sl@0
   173
				  * is an synonym. */
sl@0
   174
    char *fullName;		 /* The namespace's fully qualified name.
sl@0
   175
				  * This starts with ::. */
sl@0
   176
    ClientData clientData;	 /* An arbitrary value associated with this
sl@0
   177
				  * namespace. */
sl@0
   178
    Tcl_NamespaceDeleteProc *deleteProc;
sl@0
   179
				 /* Procedure invoked when deleting the
sl@0
   180
				  * namespace to, e.g., free clientData. */
sl@0
   181
    struct Namespace *parentPtr; /* Points to the namespace that contains
sl@0
   182
				  * this one. NULL if this is the global
sl@0
   183
				  * namespace. */
sl@0
   184
    Tcl_HashTable childTable;	 /* Contains any child namespaces. Indexed
sl@0
   185
				  * by strings; values have type
sl@0
   186
				  * (Namespace *). */
sl@0
   187
    long nsId;			 /* Unique id for the namespace. */
sl@0
   188
    Tcl_Interp *interp;		 /* The interpreter containing this
sl@0
   189
				  * namespace. */
sl@0
   190
    int flags;			 /* OR-ed combination of the namespace
sl@0
   191
				  * status flags NS_DYING and NS_DEAD
sl@0
   192
				  * listed below. */
sl@0
   193
    int activationCount;	 /* Number of "activations" or active call
sl@0
   194
				  * frames for this namespace that are on
sl@0
   195
				  * the Tcl call stack. The namespace won't
sl@0
   196
				  * be freed until activationCount becomes
sl@0
   197
				  * zero. */
sl@0
   198
    int refCount;		 /* Count of references by namespaceName *
sl@0
   199
				  * objects. The namespace can't be freed
sl@0
   200
				  * until refCount becomes zero. */
sl@0
   201
    Tcl_HashTable cmdTable;	 /* Contains all the commands currently
sl@0
   202
				  * registered in the namespace. Indexed by
sl@0
   203
				  * strings; values have type (Command *).
sl@0
   204
				  * Commands imported by Tcl_Import have
sl@0
   205
				  * Command structures that point (via an
sl@0
   206
				  * ImportedCmdRef structure) to the
sl@0
   207
				  * Command structure in the source
sl@0
   208
				  * namespace's command table. */
sl@0
   209
    Tcl_HashTable varTable;	 /* Contains all the (global) variables
sl@0
   210
				  * currently in this namespace. Indexed
sl@0
   211
				  * by strings; values have type (Var *). */
sl@0
   212
    char **exportArrayPtr;	 /* Points to an array of string patterns
sl@0
   213
				  * specifying which commands are exported.
sl@0
   214
				  * A pattern may include "string match"
sl@0
   215
				  * style wildcard characters to specify
sl@0
   216
				  * multiple commands; however, no namespace
sl@0
   217
				  * qualifiers are allowed. NULL if no
sl@0
   218
				  * export patterns are registered. */
sl@0
   219
    int numExportPatterns;	 /* Number of export patterns currently
sl@0
   220
				  * registered using "namespace export". */
sl@0
   221
    int maxExportPatterns;	 /* Mumber of export patterns for which
sl@0
   222
				  * space is currently allocated. */
sl@0
   223
    int cmdRefEpoch;		 /* Incremented if a newly added command
sl@0
   224
				  * shadows a command for which this
sl@0
   225
				  * namespace has already cached a Command *
sl@0
   226
				  * pointer; this causes all its cached
sl@0
   227
				  * Command* pointers to be invalidated. */
sl@0
   228
    int resolverEpoch;		 /* Incremented whenever (a) the name resolution
sl@0
   229
				  * rules change for this namespace or (b) a 
sl@0
   230
				  * newly added command shadows a command that
sl@0
   231
				  * is compiled to bytecodes.
sl@0
   232
				  * This invalidates all byte codes compiled
sl@0
   233
				  * in the namespace, causing the code to be
sl@0
   234
				  * recompiled under the new rules.*/
sl@0
   235
    Tcl_ResolveCmdProc *cmdResProc;
sl@0
   236
				 /* If non-null, this procedure overrides
sl@0
   237
				  * the usual command resolution mechanism
sl@0
   238
				  * in Tcl.  This procedure is invoked
sl@0
   239
				  * within Tcl_FindCommand to resolve all
sl@0
   240
				  * command references within the namespace. */
sl@0
   241
    Tcl_ResolveVarProc *varResProc;
sl@0
   242
				 /* If non-null, this procedure overrides
sl@0
   243
				  * the usual variable resolution mechanism
sl@0
   244
				  * in Tcl.  This procedure is invoked
sl@0
   245
				  * within Tcl_FindNamespaceVar to resolve all
sl@0
   246
				  * variable references within the namespace
sl@0
   247
				  * at runtime. */
sl@0
   248
    Tcl_ResolveCompiledVarProc *compiledVarResProc;
sl@0
   249
				 /* If non-null, this procedure overrides
sl@0
   250
				  * the usual variable resolution mechanism
sl@0
   251
				  * in Tcl.  This procedure is invoked
sl@0
   252
				  * within LookupCompiledLocal to resolve
sl@0
   253
				  * variable references within the namespace
sl@0
   254
				  * at compile time. */
sl@0
   255
} Namespace;
sl@0
   256
sl@0
   257
/*
sl@0
   258
 * Flags used to represent the status of a namespace:
sl@0
   259
 *
sl@0
   260
 * NS_DYING -	1 means Tcl_DeleteNamespace has been called to delete the
sl@0
   261
 *		namespace but there are still active call frames on the Tcl
sl@0
   262
 *		stack that refer to the namespace. When the last call frame
sl@0
   263
 *		referring to it has been popped, it's variables and command
sl@0
   264
 *		will be destroyed and it will be marked "dead" (NS_DEAD).
sl@0
   265
 *		The namespace can no longer be looked up by name.
sl@0
   266
 * NS_DEAD -	1 means Tcl_DeleteNamespace has been called to delete the
sl@0
   267
 *		namespace and no call frames still refer to it. Its
sl@0
   268
 *		variables and command have already been destroyed. This bit
sl@0
   269
 *		allows the namespace resolution code to recognize that the
sl@0
   270
 *		namespace is "deleted". When the last namespaceName object
sl@0
   271
 *		in any byte code code unit that refers to the namespace has
sl@0
   272
 *		been freed (i.e., when the namespace's refCount is 0), the
sl@0
   273
 *		namespace's storage will be freed.
sl@0
   274
 * NS_KILLED    1 means that TclTeardownNamespace has already been called on
sl@0
   275
 *              this namespace and it should not be called again [Bug 1355942]
sl@0
   276
 */
sl@0
   277
sl@0
   278
#define NS_DYING	0x01
sl@0
   279
#define NS_DEAD		0x02
sl@0
   280
#define NS_KILLED       0x04
sl@0
   281
sl@0
   282
/*
sl@0
   283
 * Flag passed to TclGetNamespaceForQualName to have it create all namespace
sl@0
   284
 * components of a namespace-qualified name that cannot be found. The new
sl@0
   285
 * namespaces are created within their specified parent. Note that this
sl@0
   286
 * flag's value must not conflict with the values of the flags
sl@0
   287
 * TCL_GLOBAL_ONLY, TCL_NAMESPACE_ONLY, and FIND_ONLY_NS (defined in
sl@0
   288
 * tclNamesp.c).
sl@0
   289
 */
sl@0
   290
sl@0
   291
#define CREATE_NS_IF_UNKNOWN 0x800
sl@0
   292
sl@0
   293
/*
sl@0
   294
 *----------------------------------------------------------------
sl@0
   295
 * Data structures related to variables.   These are used primarily
sl@0
   296
 * in tclVar.c
sl@0
   297
 *----------------------------------------------------------------
sl@0
   298
 */
sl@0
   299
sl@0
   300
/*
sl@0
   301
 * The following structure defines a variable trace, which is used to
sl@0
   302
 * invoke a specific C procedure whenever certain operations are performed
sl@0
   303
 * on a variable.
sl@0
   304
 */
sl@0
   305
sl@0
   306
typedef struct VarTrace {
sl@0
   307
    Tcl_VarTraceProc *traceProc;/* Procedure to call when operations given
sl@0
   308
				 * by flags are performed on variable. */
sl@0
   309
    ClientData clientData;	/* Argument to pass to proc. */
sl@0
   310
    int flags;			/* What events the trace procedure is
sl@0
   311
				 * interested in:  OR-ed combination of
sl@0
   312
				 * TCL_TRACE_READS, TCL_TRACE_WRITES,
sl@0
   313
				 * TCL_TRACE_UNSETS and TCL_TRACE_ARRAY. */
sl@0
   314
    struct VarTrace *nextPtr;	/* Next in list of traces associated with
sl@0
   315
				 * a particular variable. */
sl@0
   316
} VarTrace;
sl@0
   317
sl@0
   318
/*
sl@0
   319
 * The following structure defines a command trace, which is used to
sl@0
   320
 * invoke a specific C procedure whenever certain operations are performed
sl@0
   321
 * on a command.
sl@0
   322
 */
sl@0
   323
sl@0
   324
typedef struct CommandTrace {
sl@0
   325
    Tcl_CommandTraceProc *traceProc;/* Procedure to call when operations given
sl@0
   326
				     * by flags are performed on command. */
sl@0
   327
    ClientData clientData;	    /* Argument to pass to proc. */
sl@0
   328
    int flags;			    /* What events the trace procedure is
sl@0
   329
				     * interested in:  OR-ed combination of
sl@0
   330
				     * TCL_TRACE_RENAME, TCL_TRACE_DELETE. */
sl@0
   331
    struct CommandTrace *nextPtr;   /* Next in list of traces associated with
sl@0
   332
				     * a particular command. */
sl@0
   333
    int refCount;                   /* Used to ensure this structure is
sl@0
   334
                                     * not deleted too early.  Keeps track
sl@0
   335
                                     * of how many pieces of code have
sl@0
   336
                                     * a pointer to this structure. */
sl@0
   337
} CommandTrace;
sl@0
   338
sl@0
   339
/*
sl@0
   340
 * When a command trace is active (i.e. its associated procedure is
sl@0
   341
 * executing), one of the following structures is linked into a list
sl@0
   342
 * associated with the command's interpreter.  The information in
sl@0
   343
 * the structure is needed in order for Tcl to behave reasonably
sl@0
   344
 * if traces are deleted while traces are active.
sl@0
   345
 */
sl@0
   346
sl@0
   347
typedef struct ActiveCommandTrace {
sl@0
   348
    struct Command *cmdPtr;	/* Command that's being traced. */
sl@0
   349
    struct ActiveCommandTrace *nextPtr;
sl@0
   350
				/* Next in list of all active command
sl@0
   351
				 * traces for the interpreter, or NULL
sl@0
   352
				 * if no more. */
sl@0
   353
    CommandTrace *nextTracePtr;	/* Next trace to check after current
sl@0
   354
				 * trace procedure returns;  if this
sl@0
   355
				 * trace gets deleted, must update pointer
sl@0
   356
				 * to avoid using free'd memory. */
sl@0
   357
    int reverseScan;		/* Boolean set true when the traces
sl@0
   358
				 * are scanning in reverse order. */
sl@0
   359
} ActiveCommandTrace;
sl@0
   360
sl@0
   361
/*
sl@0
   362
 * When a variable trace is active (i.e. its associated procedure is
sl@0
   363
 * executing), one of the following structures is linked into a list
sl@0
   364
 * associated with the variable's interpreter.	The information in
sl@0
   365
 * the structure is needed in order for Tcl to behave reasonably
sl@0
   366
 * if traces are deleted while traces are active.
sl@0
   367
 */
sl@0
   368
sl@0
   369
typedef struct ActiveVarTrace {
sl@0
   370
    struct Var *varPtr;		/* Variable that's being traced. */
sl@0
   371
    struct ActiveVarTrace *nextPtr;
sl@0
   372
				/* Next in list of all active variable
sl@0
   373
				 * traces for the interpreter, or NULL
sl@0
   374
				 * if no more. */
sl@0
   375
    VarTrace *nextTracePtr;	/* Next trace to check after current
sl@0
   376
				 * trace procedure returns;  if this
sl@0
   377
				 * trace gets deleted, must update pointer
sl@0
   378
				 * to avoid using free'd memory. */
sl@0
   379
} ActiveVarTrace;
sl@0
   380
sl@0
   381
/*
sl@0
   382
 * The following structure describes an enumerative search in progress on
sl@0
   383
 * an array variable;  this are invoked with options to the "array"
sl@0
   384
 * command.
sl@0
   385
 */
sl@0
   386
sl@0
   387
typedef struct ArraySearch {
sl@0
   388
    int id;			/* Integer id used to distinguish among
sl@0
   389
				 * multiple concurrent searches for the
sl@0
   390
				 * same array. */
sl@0
   391
    struct Var *varPtr;		/* Pointer to array variable that's being
sl@0
   392
				 * searched. */
sl@0
   393
    Tcl_HashSearch search;	/* Info kept by the hash module about
sl@0
   394
				 * progress through the array. */
sl@0
   395
    Tcl_HashEntry *nextEntry;	/* Non-null means this is the next element
sl@0
   396
				 * to be enumerated (it's leftover from
sl@0
   397
				 * the Tcl_FirstHashEntry call or from
sl@0
   398
				 * an "array anymore" command).	 NULL
sl@0
   399
				 * means must call Tcl_NextHashEntry
sl@0
   400
				 * to get value to return. */
sl@0
   401
    struct ArraySearch *nextPtr;/* Next in list of all active searches
sl@0
   402
				 * for this variable, or NULL if this is
sl@0
   403
				 * the last one. */
sl@0
   404
} ArraySearch;
sl@0
   405
sl@0
   406
/*
sl@0
   407
 * The structure below defines a variable, which associates a string name
sl@0
   408
 * with a Tcl_Obj value. These structures are kept in procedure call frames
sl@0
   409
 * (for local variables recognized by the compiler) or in the heap (for
sl@0
   410
 * global variables and any variable not known to the compiler). For each
sl@0
   411
 * Var structure in the heap, a hash table entry holds the variable name and
sl@0
   412
 * a pointer to the Var structure.
sl@0
   413
 */
sl@0
   414
sl@0
   415
typedef struct Var {
sl@0
   416
    union {
sl@0
   417
	Tcl_Obj *objPtr;	/* The variable's object value. Used for 
sl@0
   418
				 * scalar variables and array elements. */
sl@0
   419
	Tcl_HashTable *tablePtr;/* For array variables, this points to
sl@0
   420
				 * information about the hash table used
sl@0
   421
				 * to implement the associative array. 
sl@0
   422
				 * Points to malloc-ed data. */
sl@0
   423
	struct Var *linkPtr;	/* If this is a global variable being
sl@0
   424
				 * referred to in a procedure, or a variable
sl@0
   425
				 * created by "upvar", this field points to
sl@0
   426
				 * the referenced variable's Var struct. */
sl@0
   427
    } value;
sl@0
   428
    char *name;			/* NULL if the variable is in a hashtable,
sl@0
   429
				 * otherwise points to the variable's
sl@0
   430
				 * name. It is used, e.g., by TclLookupVar
sl@0
   431
				 * and "info locals". The storage for the
sl@0
   432
				 * characters of the name is not owned by
sl@0
   433
				 * the Var and must not be freed when
sl@0
   434
				 * freeing the Var. */
sl@0
   435
    Namespace *nsPtr;		/* Points to the namespace that contains
sl@0
   436
				 * this variable or NULL if the variable is
sl@0
   437
				 * a local variable in a Tcl procedure. */
sl@0
   438
    Tcl_HashEntry *hPtr;	/* If variable is in a hashtable, either the
sl@0
   439
				 * hash table entry that refers to this
sl@0
   440
				 * variable or NULL if the variable has been
sl@0
   441
				 * detached from its hash table (e.g. an
sl@0
   442
				 * array is deleted, but some of its
sl@0
   443
				 * elements are still referred to in
sl@0
   444
				 * upvars). NULL if the variable is not in a
sl@0
   445
				 * hashtable. This is used to delete an
sl@0
   446
				 * variable from its hashtable if it is no
sl@0
   447
				 * longer needed. */
sl@0
   448
    int refCount;		/* Counts number of active uses of this
sl@0
   449
				 * variable, not including its entry in the
sl@0
   450
				 * call frame or the hash table: 1 for each
sl@0
   451
				 * additional variable whose linkPtr points
sl@0
   452
				 * here, 1 for each nested trace active on
sl@0
   453
				 * variable, and 1 if the variable is a 
sl@0
   454
				 * namespace variable. This record can't be
sl@0
   455
				 * deleted until refCount becomes 0. */
sl@0
   456
    VarTrace *tracePtr;		/* First in list of all traces set for this
sl@0
   457
				 * variable. */
sl@0
   458
    ArraySearch *searchPtr;	/* First in list of all searches active
sl@0
   459
				 * for this variable, or NULL if none. */
sl@0
   460
    int flags;			/* Miscellaneous bits of information about
sl@0
   461
				 * variable. See below for definitions. */
sl@0
   462
} Var;
sl@0
   463
sl@0
   464
/*
sl@0
   465
 * Flag bits for variables. The first three (VAR_SCALAR, VAR_ARRAY, and
sl@0
   466
 * VAR_LINK) are mutually exclusive and give the "type" of the variable.
sl@0
   467
 * VAR_UNDEFINED is independent of the variable's type. 
sl@0
   468
 *
sl@0
   469
 * VAR_SCALAR -			1 means this is a scalar variable and not
sl@0
   470
 *				an array or link. The "objPtr" field points
sl@0
   471
 *				to the variable's value, a Tcl object.
sl@0
   472
 * VAR_ARRAY -			1 means this is an array variable rather
sl@0
   473
 *				than a scalar variable or link. The
sl@0
   474
 *				"tablePtr" field points to the array's
sl@0
   475
 *				hashtable for its elements.
sl@0
   476
 * VAR_LINK -			1 means this Var structure contains a
sl@0
   477
 *				pointer to another Var structure that
sl@0
   478
 *				either has the real value or is itself
sl@0
   479
 *				another VAR_LINK pointer. Variables like
sl@0
   480
 *				this come about through "upvar" and "global"
sl@0
   481
 *				commands, or through references to variables
sl@0
   482
 *				in enclosing namespaces.
sl@0
   483
 * VAR_UNDEFINED -		1 means that the variable is in the process
sl@0
   484
 *				of being deleted. An undefined variable
sl@0
   485
 *				logically does not exist and survives only
sl@0
   486
 *				while it has a trace, or if it is a global
sl@0
   487
 *				variable currently being used by some
sl@0
   488
 *				procedure.
sl@0
   489
 * VAR_IN_HASHTABLE -		1 means this variable is in a hashtable and
sl@0
   490
 *				the Var structure is malloced. 0 if it is
sl@0
   491
 *				a local variable that was assigned a slot
sl@0
   492
 *				in a procedure frame by	the compiler so the
sl@0
   493
 *				Var storage is part of the call frame.
sl@0
   494
 * VAR_TRACE_ACTIVE -		1 means that trace processing is currently
sl@0
   495
 *				underway for a read or write access, so
sl@0
   496
 *				new read or write accesses should not cause
sl@0
   497
 *				trace procedures to be called and the
sl@0
   498
 *				variable can't be deleted.
sl@0
   499
 * VAR_ARRAY_ELEMENT -		1 means that this variable is an array
sl@0
   500
 *				element, so it is not legal for it to be
sl@0
   501
 *				an array itself (the VAR_ARRAY flag had
sl@0
   502
 *				better not be set).
sl@0
   503
 * VAR_NAMESPACE_VAR -		1 means that this variable was declared
sl@0
   504
 *				as a namespace variable. This flag ensures
sl@0
   505
 *				it persists until its namespace is
sl@0
   506
 *				destroyed or until the variable is unset;
sl@0
   507
 *				it will persist even if it has not been
sl@0
   508
 *				initialized and is marked undefined.
sl@0
   509
 *				The variable's refCount is incremented to
sl@0
   510
 *				reflect the "reference" from its namespace.
sl@0
   511
 *
sl@0
   512
 * The following additional flags are used with the CompiledLocal type
sl@0
   513
 * defined below:
sl@0
   514
 *
sl@0
   515
 * VAR_ARGUMENT -		1 means that this variable holds a procedure
sl@0
   516
 *				argument. 
sl@0
   517
 * VAR_TEMPORARY -		1 if the local variable is an anonymous
sl@0
   518
 *				temporary variable. Temporaries have a NULL
sl@0
   519
 *				name.
sl@0
   520
 * VAR_RESOLVED -		1 if name resolution has been done for this
sl@0
   521
 *				variable.
sl@0
   522
 */
sl@0
   523
sl@0
   524
#define VAR_SCALAR		0x1
sl@0
   525
#define VAR_ARRAY		0x2
sl@0
   526
#define VAR_LINK		0x4
sl@0
   527
#define VAR_UNDEFINED		0x8
sl@0
   528
#define VAR_IN_HASHTABLE	0x10
sl@0
   529
#define VAR_TRACE_ACTIVE	0x20
sl@0
   530
#define VAR_ARRAY_ELEMENT	0x40
sl@0
   531
#define VAR_NAMESPACE_VAR	0x80
sl@0
   532
sl@0
   533
#define VAR_ARGUMENT		0x100
sl@0
   534
#define VAR_TEMPORARY		0x200
sl@0
   535
#define VAR_RESOLVED		0x400	
sl@0
   536
sl@0
   537
/*
sl@0
   538
 * Macros to ensure that various flag bits are set properly for variables.
sl@0
   539
 * The ANSI C "prototypes" for these macros are:
sl@0
   540
 *
sl@0
   541
 * EXTERN void	TclSetVarScalar _ANSI_ARGS_((Var *varPtr));
sl@0
   542
 * EXTERN void	TclSetVarArray _ANSI_ARGS_((Var *varPtr));
sl@0
   543
 * EXTERN void	TclSetVarLink _ANSI_ARGS_((Var *varPtr));
sl@0
   544
 * EXTERN void	TclSetVarArrayElement _ANSI_ARGS_((Var *varPtr));
sl@0
   545
 * EXTERN void	TclSetVarUndefined _ANSI_ARGS_((Var *varPtr));
sl@0
   546
 * EXTERN void	TclClearVarUndefined _ANSI_ARGS_((Var *varPtr));
sl@0
   547
 */
sl@0
   548
sl@0
   549
#define TclSetVarScalar(varPtr) \
sl@0
   550
    (varPtr)->flags = ((varPtr)->flags & ~(VAR_ARRAY|VAR_LINK)) | VAR_SCALAR
sl@0
   551
sl@0
   552
#define TclSetVarArray(varPtr) \
sl@0
   553
    (varPtr)->flags = ((varPtr)->flags & ~(VAR_SCALAR|VAR_LINK)) | VAR_ARRAY
sl@0
   554
sl@0
   555
#define TclSetVarLink(varPtr) \
sl@0
   556
    (varPtr)->flags = ((varPtr)->flags & ~(VAR_SCALAR|VAR_ARRAY)) | VAR_LINK
sl@0
   557
sl@0
   558
#define TclSetVarArrayElement(varPtr) \
sl@0
   559
    (varPtr)->flags = ((varPtr)->flags & ~VAR_ARRAY) | VAR_ARRAY_ELEMENT
sl@0
   560
sl@0
   561
#define TclSetVarUndefined(varPtr) \
sl@0
   562
    (varPtr)->flags |= VAR_UNDEFINED
sl@0
   563
sl@0
   564
#define TclClearVarUndefined(varPtr) \
sl@0
   565
    (varPtr)->flags &= ~VAR_UNDEFINED
sl@0
   566
sl@0
   567
/*
sl@0
   568
 * Macros to read various flag bits of variables.
sl@0
   569
 * The ANSI C "prototypes" for these macros are:
sl@0
   570
 *
sl@0
   571
 * EXTERN int	TclIsVarScalar _ANSI_ARGS_((Var *varPtr));
sl@0
   572
 * EXTERN int	TclIsVarLink _ANSI_ARGS_((Var *varPtr));
sl@0
   573
 * EXTERN int	TclIsVarArray _ANSI_ARGS_((Var *varPtr));
sl@0
   574
 * EXTERN int	TclIsVarUndefined _ANSI_ARGS_((Var *varPtr));
sl@0
   575
 * EXTERN int	TclIsVarArrayElement _ANSI_ARGS_((Var *varPtr));
sl@0
   576
 * EXTERN int	TclIsVarTemporary _ANSI_ARGS_((Var *varPtr));
sl@0
   577
 * EXTERN int	TclIsVarArgument _ANSI_ARGS_((Var *varPtr));
sl@0
   578
 * EXTERN int	TclIsVarResolved _ANSI_ARGS_((Var *varPtr));
sl@0
   579
 */
sl@0
   580
    
sl@0
   581
#define TclIsVarScalar(varPtr) \
sl@0
   582
    ((varPtr)->flags & VAR_SCALAR)
sl@0
   583
sl@0
   584
#define TclIsVarLink(varPtr) \
sl@0
   585
    ((varPtr)->flags & VAR_LINK)
sl@0
   586
sl@0
   587
#define TclIsVarArray(varPtr) \
sl@0
   588
    ((varPtr)->flags & VAR_ARRAY)
sl@0
   589
sl@0
   590
#define TclIsVarUndefined(varPtr) \
sl@0
   591
    ((varPtr)->flags & VAR_UNDEFINED)
sl@0
   592
sl@0
   593
#define TclIsVarArrayElement(varPtr) \
sl@0
   594
    ((varPtr)->flags & VAR_ARRAY_ELEMENT)
sl@0
   595
sl@0
   596
#define TclIsVarTemporary(varPtr) \
sl@0
   597
    ((varPtr)->flags & VAR_TEMPORARY)
sl@0
   598
    
sl@0
   599
#define TclIsVarArgument(varPtr) \
sl@0
   600
    ((varPtr)->flags & VAR_ARGUMENT)
sl@0
   601
    
sl@0
   602
#define TclIsVarResolved(varPtr) \
sl@0
   603
    ((varPtr)->flags & VAR_RESOLVED)
sl@0
   604
sl@0
   605
/*
sl@0
   606
 *----------------------------------------------------------------
sl@0
   607
 * Data structures related to procedures.  These are used primarily
sl@0
   608
 * in tclProc.c, tclCompile.c, and tclExecute.c.
sl@0
   609
 *----------------------------------------------------------------
sl@0
   610
 */
sl@0
   611
sl@0
   612
/*
sl@0
   613
 * Forward declaration to prevent an error when the forward reference to
sl@0
   614
 * Command is encountered in the Proc and ImportRef types declared below.
sl@0
   615
 */
sl@0
   616
sl@0
   617
struct Command;
sl@0
   618
sl@0
   619
/*
sl@0
   620
 * The variable-length structure below describes a local variable of a
sl@0
   621
 * procedure that was recognized by the compiler. These variables have a
sl@0
   622
 * name, an element in the array of compiler-assigned local variables in the
sl@0
   623
 * procedure's call frame, and various other items of information. If the
sl@0
   624
 * local variable is a formal argument, it may also have a default value.
sl@0
   625
 * The compiler can't recognize local variables whose names are
sl@0
   626
 * expressions (these names are only known at runtime when the expressions
sl@0
   627
 * are evaluated) or local variables that are created as a result of an
sl@0
   628
 * "upvar" or "uplevel" command. These other local variables are kept
sl@0
   629
 * separately in a hash table in the call frame.
sl@0
   630
 */
sl@0
   631
sl@0
   632
typedef struct CompiledLocal {
sl@0
   633
    struct CompiledLocal *nextPtr;
sl@0
   634
				/* Next compiler-recognized local variable
sl@0
   635
				 * for this procedure, or NULL if this is
sl@0
   636
				 * the last local. */
sl@0
   637
    int nameLength;		/* The number of characters in local
sl@0
   638
				 * variable's name. Used to speed up
sl@0
   639
				 * variable lookups. */
sl@0
   640
    int frameIndex;		/* Index in the array of compiler-assigned
sl@0
   641
				 * variables in the procedure call frame. */
sl@0
   642
    int flags;			/* Flag bits for the local variable. Same as
sl@0
   643
				 * the flags for the Var structure above,
sl@0
   644
				 * although only VAR_SCALAR, VAR_ARRAY, 
sl@0
   645
				 * VAR_LINK, VAR_ARGUMENT, VAR_TEMPORARY, and
sl@0
   646
				 * VAR_RESOLVED make sense. */
sl@0
   647
    Tcl_Obj *defValuePtr;	/* Pointer to the default value of an
sl@0
   648
				 * argument, if any. NULL if not an argument
sl@0
   649
				 * or, if an argument, no default value. */
sl@0
   650
    Tcl_ResolvedVarInfo *resolveInfo;
sl@0
   651
				/* Customized variable resolution info
sl@0
   652
				 * supplied by the Tcl_ResolveCompiledVarProc
sl@0
   653
				 * associated with a namespace. Each variable
sl@0
   654
				 * is marked by a unique ClientData tag
sl@0
   655
				 * during compilation, and that same tag
sl@0
   656
				 * is used to find the variable at runtime. */
sl@0
   657
    char name[4];		/* Name of the local variable starts here.
sl@0
   658
				 * If the name is NULL, this will just be
sl@0
   659
				 * '\0'. The actual size of this field will
sl@0
   660
				 * be large enough to hold the name. MUST
sl@0
   661
				 * BE THE LAST FIELD IN THE STRUCTURE! */
sl@0
   662
} CompiledLocal;
sl@0
   663
sl@0
   664
/*
sl@0
   665
 * The structure below defines a command procedure, which consists of a
sl@0
   666
 * collection of Tcl commands plus information about arguments and other
sl@0
   667
 * local variables recognized at compile time.
sl@0
   668
 */
sl@0
   669
sl@0
   670
typedef struct Proc {
sl@0
   671
    struct Interp *iPtr;	  /* Interpreter for which this command
sl@0
   672
				   * is defined. */
sl@0
   673
    int refCount;		  /* Reference count: 1 if still present
sl@0
   674
				   * in command table plus 1 for each call
sl@0
   675
				   * to the procedure that is currently
sl@0
   676
				   * active. This structure can be freed
sl@0
   677
				   * when refCount becomes zero. */
sl@0
   678
    struct Command *cmdPtr;	  /* Points to the Command structure for
sl@0
   679
				   * this procedure. This is used to get
sl@0
   680
				   * the namespace in which to execute
sl@0
   681
				   * the procedure. */
sl@0
   682
    Tcl_Obj *bodyPtr;		  /* Points to the ByteCode object for
sl@0
   683
				   * procedure's body command. */
sl@0
   684
    int numArgs;		  /* Number of formal parameters. */
sl@0
   685
    int numCompiledLocals;	  /* Count of local variables recognized by
sl@0
   686
				   * the compiler including arguments and
sl@0
   687
				   * temporaries. */
sl@0
   688
    CompiledLocal *firstLocalPtr; /* Pointer to first of the procedure's
sl@0
   689
				   * compiler-allocated local variables, or
sl@0
   690
				   * NULL if none. The first numArgs entries
sl@0
   691
				   * in this list describe the procedure's
sl@0
   692
				   * formal arguments. */
sl@0
   693
    CompiledLocal *lastLocalPtr;  /* Pointer to the last allocated local
sl@0
   694
				   * variable or NULL if none. This has
sl@0
   695
				   * frame index (numCompiledLocals-1). */
sl@0
   696
} Proc;
sl@0
   697
sl@0
   698
/*
sl@0
   699
 * The structure below defines a command trace.	 This is used to allow Tcl
sl@0
   700
 * clients to find out whenever a command is about to be executed.
sl@0
   701
 */
sl@0
   702
sl@0
   703
typedef struct Trace {
sl@0
   704
    int level;			/* Only trace commands at nesting level
sl@0
   705
				 * less than or equal to this. */
sl@0
   706
    Tcl_CmdObjTraceProc *proc;	/* Procedure to call to trace command. */
sl@0
   707
    ClientData clientData;	/* Arbitrary value to pass to proc. */
sl@0
   708
    struct Trace *nextPtr;	/* Next in list of traces for this interp. */
sl@0
   709
    int flags;			/* Flags governing the trace - see
sl@0
   710
				 * Tcl_CreateObjTrace for details */
sl@0
   711
    Tcl_CmdObjTraceDeleteProc* delProc;
sl@0
   712
				/* Procedure to call when trace is deleted */
sl@0
   713
} Trace;
sl@0
   714
sl@0
   715
/*
sl@0
   716
 * When an interpreter trace is active (i.e. its associated procedure
sl@0
   717
 * is executing), one of the following structures is linked into a list
sl@0
   718
 * associated with the interpreter.  The information in the structure
sl@0
   719
 * is needed in order for Tcl to behave reasonably if traces are
sl@0
   720
 * deleted while traces are active.
sl@0
   721
 */
sl@0
   722
sl@0
   723
typedef struct ActiveInterpTrace {
sl@0
   724
    struct ActiveInterpTrace *nextPtr;
sl@0
   725
				/* Next in list of all active command
sl@0
   726
				 * traces for the interpreter, or NULL
sl@0
   727
				 * if no more. */
sl@0
   728
    Trace *nextTracePtr;	/* Next trace to check after current
sl@0
   729
				 * trace procedure returns;  if this
sl@0
   730
				 * trace gets deleted, must update pointer
sl@0
   731
				 * to avoid using free'd memory. */
sl@0
   732
    int reverseScan;		/* Boolean set true when the traces
sl@0
   733
				 * are scanning in reverse order. */
sl@0
   734
} ActiveInterpTrace;
sl@0
   735
sl@0
   736
/*
sl@0
   737
 * The structure below defines an entry in the assocData hash table which
sl@0
   738
 * is associated with an interpreter. The entry contains a pointer to a
sl@0
   739
 * function to call when the interpreter is deleted, and a pointer to
sl@0
   740
 * a user-defined piece of data.
sl@0
   741
 */
sl@0
   742
sl@0
   743
typedef struct AssocData {
sl@0
   744
    Tcl_InterpDeleteProc *proc;	/* Proc to call when deleting. */
sl@0
   745
    ClientData clientData;	/* Value to pass to proc. */
sl@0
   746
} AssocData;	
sl@0
   747
sl@0
   748
/*
sl@0
   749
 * The structure below defines a call frame. A call frame defines a naming
sl@0
   750
 * context for a procedure call: its local naming scope (for local
sl@0
   751
 * variables) and its global naming scope (a namespace, perhaps the global
sl@0
   752
 * :: namespace). A call frame can also define the naming context for a
sl@0
   753
 * namespace eval or namespace inscope command: the namespace in which the
sl@0
   754
 * command's code should execute. The Tcl_CallFrame structures exist only
sl@0
   755
 * while procedures or namespace eval/inscope's are being executed, and
sl@0
   756
 * provide a kind of Tcl call stack.
sl@0
   757
 * 
sl@0
   758
 * WARNING!! The structure definition must be kept consistent with the
sl@0
   759
 * Tcl_CallFrame structure in tcl.h. If you change one, change the other.
sl@0
   760
 */
sl@0
   761
sl@0
   762
typedef struct CallFrame {
sl@0
   763
    Namespace *nsPtr;		/* Points to the namespace used to resolve
sl@0
   764
				 * commands and global variables. */
sl@0
   765
    int isProcCallFrame;	/* If nonzero, the frame was pushed to
sl@0
   766
				 * execute a Tcl procedure and may have
sl@0
   767
				 * local vars. If 0, the frame was pushed
sl@0
   768
				 * to execute a namespace command and var
sl@0
   769
				 * references are treated as references to
sl@0
   770
				 * namespace vars; varTablePtr and
sl@0
   771
				 * compiledLocals are ignored. */
sl@0
   772
    int objc;			/* This and objv below describe the
sl@0
   773
				 * arguments for this procedure call. */
sl@0
   774
    Tcl_Obj *CONST *objv;	/* Array of argument objects. */
sl@0
   775
    struct CallFrame *callerPtr;
sl@0
   776
				/* Value of interp->framePtr when this
sl@0
   777
				 * procedure was invoked (i.e. next higher
sl@0
   778
				 * in stack of all active procedures). */
sl@0
   779
    struct CallFrame *callerVarPtr;
sl@0
   780
				/* Value of interp->varFramePtr when this
sl@0
   781
				 * procedure was invoked (i.e. determines
sl@0
   782
				 * variable scoping within caller). Same
sl@0
   783
				 * as callerPtr unless an "uplevel" command
sl@0
   784
				 * or something equivalent was active in
sl@0
   785
				 * the caller). */
sl@0
   786
    int level;			/* Level of this procedure, for "uplevel"
sl@0
   787
				 * purposes (i.e. corresponds to nesting of
sl@0
   788
				 * callerVarPtr's, not callerPtr's). 1 for
sl@0
   789
				 * outermost procedure, 0 for top-level. */
sl@0
   790
    Proc *procPtr;		/* Points to the structure defining the
sl@0
   791
				 * called procedure. Used to get information
sl@0
   792
				 * such as the number of compiled local
sl@0
   793
				 * variables (local variables assigned
sl@0
   794
				 * entries ["slots"] in the compiledLocals
sl@0
   795
				 * array below). */
sl@0
   796
    Tcl_HashTable *varTablePtr;	/* Hash table containing local variables not
sl@0
   797
				 * recognized by the compiler, or created at
sl@0
   798
				 * execution time through, e.g., upvar.
sl@0
   799
				 * Initially NULL and created if needed. */
sl@0
   800
    int numCompiledLocals;	/* Count of local variables recognized by
sl@0
   801
				 * the compiler including arguments. */
sl@0
   802
    Var* compiledLocals;	/* Points to the array of local variables
sl@0
   803
				 * recognized by the compiler. The compiler
sl@0
   804
				 * emits code that refers to these variables
sl@0
   805
				 * using an index into this array. */
sl@0
   806
} CallFrame;
sl@0
   807
sl@0
   808
#ifdef TCL_TIP280
sl@0
   809
/*
sl@0
   810
 * TIP #280
sl@0
   811
 * The structure below defines a command frame. A command frame
sl@0
   812
 * provides location information for all commands executing a tcl
sl@0
   813
 * script (source, eval, uplevel, procedure bodies, ...). The runtime
sl@0
   814
 * structure essentially contains the stack trace as it would be if
sl@0
   815
 * the currently executing command were to throw an error.
sl@0
   816
 *
sl@0
   817
 * For commands where it makes sense it refers to the associated
sl@0
   818
 * CallFrame as well.
sl@0
   819
 *
sl@0
   820
 * The structures are chained in a single list, with the top of the
sl@0
   821
 * stack anchored in the Interp structure.
sl@0
   822
 *
sl@0
   823
 * Instances can be allocated on the C stack, or the heap, the former
sl@0
   824
 * making cleanup a bit simpler.
sl@0
   825
 */
sl@0
   826
sl@0
   827
typedef struct CmdFrame {
sl@0
   828
  /* General data. Always available. */
sl@0
   829
sl@0
   830
  int              type;     /* Values see below */
sl@0
   831
  int              level;    /* #Frames in stack, prevent O(n) scan of list */
sl@0
   832
  int*             line;     /* Lines the words of the command start on */
sl@0
   833
  int              nline;
sl@0
   834
sl@0
   835
  CallFrame*       framePtr; /* Procedure activation record, may be NULL */
sl@0
   836
  struct CmdFrame* nextPtr;  /* Link to calling frame */
sl@0
   837
sl@0
   838
  /* Data needed for Eval vs TEBC
sl@0
   839
   *
sl@0
   840
   * EXECUTION CONTEXTS and usage of CmdFrame
sl@0
   841
   *
sl@0
   842
   * Field      TEBC            EvalEx          EvalObjEx
sl@0
   843
   * =======    ====            ======          =========
sl@0
   844
   * level      yes             yes             yes
sl@0
   845
   * type       BC/PREBC        SRC/EVAL        EVAL_LIST
sl@0
   846
   * line0      yes             yes             yes
sl@0
   847
   * framePtr   yes             yes             yes
sl@0
   848
   * =======    ====            ======          =========
sl@0
   849
   *
sl@0
   850
   * =======    ====            ======          ========= union data
sl@0
   851
   * line1      -               yes             -
sl@0
   852
   * line3      -               yes             -
sl@0
   853
   * path       -               yes             -
sl@0
   854
   * -------    ----            ------          ---------
sl@0
   855
   * codePtr    yes             -               -
sl@0
   856
   * pc         yes             -               -
sl@0
   857
   * =======    ====            ======          =========
sl@0
   858
   *
sl@0
   859
   * =======    ====            ======          ========= | union cmd
sl@0
   860
   * listPtr    -               -               yes       |
sl@0
   861
   * -------    ----            ------          --------- |
sl@0
   862
   * cmd        yes             yes             -         |
sl@0
   863
   * cmdlen     yes             yes             -         |
sl@0
   864
   * -------    ----            ------          --------- |
sl@0
   865
   */
sl@0
   866
sl@0
   867
  union {
sl@0
   868
    struct {
sl@0
   869
      Tcl_Obj*     path;     /* Path of the sourced file the command
sl@0
   870
			      * is in. */
sl@0
   871
    } eval;
sl@0
   872
    struct {
sl@0
   873
      CONST void*  codePtr;  /* Byte code currently executed */
sl@0
   874
      CONST char*  pc;       /* and instruction pointer.     */
sl@0
   875
    } tebc;
sl@0
   876
  } data;
sl@0
   877
sl@0
   878
  union {
sl@0
   879
    struct {
sl@0
   880
      CONST char*  cmd;      /* The executed command, if possible */
sl@0
   881
      int          len;      /* And its length */
sl@0
   882
    } str;
sl@0
   883
    Tcl_Obj*       listPtr;  /* Tcl_EvalObjEx, cmd list */
sl@0
   884
  } cmd;
sl@0
   885
sl@0
   886
} CmdFrame;
sl@0
   887
sl@0
   888
/* The following macros define the allowed values for the type field
sl@0
   889
 * of the CmdFrame structure above. Some of the values occur only in
sl@0
   890
 * the extended location data referenced via the 'baseLocPtr'.
sl@0
   891
 *
sl@0
   892
 * TCL_LOCATION_EVAL      : Frame is for a script evaluated by EvalEx.
sl@0
   893
 * TCL_LOCATION_EVAL_LIST : Frame is for a script evaluated by the list
sl@0
   894
 *                          optimization path of EvalObjEx.
sl@0
   895
 * TCL_LOCATION_BC        : Frame is for bytecode. 
sl@0
   896
 * TCL_LOCATION_PREBC     : Frame is for precompiled bytecode.
sl@0
   897
 * TCL_LOCATION_SOURCE    : Frame is for a script evaluated by EvalEx,
sl@0
   898
 *                          from a sourced file.
sl@0
   899
 * TCL_LOCATION_PROC      : Frame is for bytecode of a procedure.
sl@0
   900
 *
sl@0
   901
 * A TCL_LOCATION_BC type in a frame can be overridden by _SOURCE and
sl@0
   902
 * _PROC types, per the context of the byte code in execution.
sl@0
   903
 */
sl@0
   904
sl@0
   905
#define TCL_LOCATION_EVAL      (0) /* Location in a dynamic eval script */
sl@0
   906
#define TCL_LOCATION_EVAL_LIST (1) /* Location in a dynamic eval script, list-path */
sl@0
   907
#define TCL_LOCATION_BC        (2) /* Location in byte code */
sl@0
   908
#define TCL_LOCATION_PREBC     (3) /* Location in precompiled byte code, no location */
sl@0
   909
#define TCL_LOCATION_SOURCE    (4) /* Location in a file */
sl@0
   910
#define TCL_LOCATION_PROC      (5) /* Location in a dynamic proc */
sl@0
   911
sl@0
   912
#define TCL_LOCATION_LAST      (6) /* Number of values in the enum */
sl@0
   913
#endif
sl@0
   914
sl@0
   915
/*
sl@0
   916
 *----------------------------------------------------------------
sl@0
   917
 * Data structures and procedures related to TclHandles, which
sl@0
   918
 * are a very lightweight method of preserving enough information
sl@0
   919
 * to determine if an arbitrary malloc'd block has been deleted.
sl@0
   920
 *----------------------------------------------------------------
sl@0
   921
 */
sl@0
   922
sl@0
   923
typedef VOID **TclHandle;
sl@0
   924
sl@0
   925
/*
sl@0
   926
 *----------------------------------------------------------------
sl@0
   927
 * Data structures related to expressions.  These are used only in
sl@0
   928
 * tclExpr.c.
sl@0
   929
 *----------------------------------------------------------------
sl@0
   930
 */
sl@0
   931
sl@0
   932
/*
sl@0
   933
 * The data structure below defines a math function (e.g. sin or hypot)
sl@0
   934
 * for use in Tcl expressions.
sl@0
   935
 */
sl@0
   936
sl@0
   937
#define MAX_MATH_ARGS 5
sl@0
   938
typedef struct MathFunc {
sl@0
   939
    int builtinFuncIndex;	/* If this is a builtin math function, its
sl@0
   940
				 * index in the array of builtin functions.
sl@0
   941
				 * (tclCompilation.h lists these indices.)
sl@0
   942
				 * The value is -1 if this is a new function
sl@0
   943
				 * defined by Tcl_CreateMathFunc. The value
sl@0
   944
				 * is also -1 if a builtin function is
sl@0
   945
				 * replaced by a Tcl_CreateMathFunc call. */
sl@0
   946
    int numArgs;		/* Number of arguments for function. */
sl@0
   947
    Tcl_ValueType argTypes[MAX_MATH_ARGS];
sl@0
   948
				/* Acceptable types for each argument. */
sl@0
   949
    Tcl_MathProc *proc;		/* Procedure that implements this function.
sl@0
   950
				 * NULL if isBuiltinFunc is 1. */
sl@0
   951
    ClientData clientData;	/* Additional argument to pass to the
sl@0
   952
				 * function when invoking it. NULL if
sl@0
   953
				 * isBuiltinFunc is 1. */
sl@0
   954
} MathFunc;
sl@0
   955
sl@0
   956
/*
sl@0
   957
 * These are a thin layer over TclpThreadKeyDataGet and TclpThreadKeyDataSet
sl@0
   958
 * when threads are used, or an emulation if there are no threads.  These
sl@0
   959
 * are really internal and Tcl clients should use Tcl_GetThreadData.
sl@0
   960
 */
sl@0
   961
sl@0
   962
EXTERN VOID *TclThreadDataKeyGet _ANSI_ARGS_((Tcl_ThreadDataKey *keyPtr));
sl@0
   963
EXTERN void TclThreadDataKeySet _ANSI_ARGS_((Tcl_ThreadDataKey *keyPtr, VOID *data));
sl@0
   964
sl@0
   965
/*
sl@0
   966
 * This is a convenience macro used to initialize a thread local storage ptr.
sl@0
   967
 */
sl@0
   968
#define TCL_TSD_INIT(keyPtr)	(ThreadSpecificData *)Tcl_GetThreadData((keyPtr), sizeof(ThreadSpecificData))
sl@0
   969
sl@0
   970
sl@0
   971
/*
sl@0
   972
 *----------------------------------------------------------------
sl@0
   973
 * Data structures related to bytecode compilation and execution.
sl@0
   974
 * These are used primarily in tclCompile.c, tclExecute.c, and
sl@0
   975
 * tclBasic.c.
sl@0
   976
 *----------------------------------------------------------------
sl@0
   977
 */
sl@0
   978
sl@0
   979
/*
sl@0
   980
 * Forward declaration to prevent errors when the forward references to
sl@0
   981
 * Tcl_Parse and CompileEnv are encountered in the procedure type
sl@0
   982
 * CompileProc declared below.
sl@0
   983
 */
sl@0
   984
sl@0
   985
struct CompileEnv;
sl@0
   986
sl@0
   987
/*
sl@0
   988
 * The type of procedures called by the Tcl bytecode compiler to compile
sl@0
   989
 * commands. Pointers to these procedures are kept in the Command structure
sl@0
   990
 * describing each command. When a CompileProc returns, the interpreter's
sl@0
   991
 * result is set to error information, if any. In addition, the CompileProc
sl@0
   992
 * returns an integer value, which is one of the following:
sl@0
   993
 *
sl@0
   994
 * TCL_OK		Compilation completed normally.
sl@0
   995
 * TCL_ERROR		Compilation failed because of an error;
sl@0
   996
 *			the interpreter's result describes what went wrong.
sl@0
   997
 * TCL_OUT_LINE_COMPILE	Compilation failed because, e.g., the command is
sl@0
   998
 *			too complex for effective inline compilation. The
sl@0
   999
 *			CompileProc believes the command is legal but 
sl@0
  1000
 *			should be compiled "out of line" by emitting code
sl@0
  1001
 *			to invoke its command procedure at runtime.
sl@0
  1002
 */
sl@0
  1003
sl@0
  1004
#define TCL_OUT_LINE_COMPILE	(TCL_CONTINUE + 1)
sl@0
  1005
sl@0
  1006
typedef int (CompileProc) _ANSI_ARGS_((Tcl_Interp *interp,
sl@0
  1007
	Tcl_Parse *parsePtr, struct CompileEnv *compEnvPtr));
sl@0
  1008
sl@0
  1009
/*
sl@0
  1010
 * The type of procedure called from the compilation hook point in
sl@0
  1011
 * SetByteCodeFromAny.
sl@0
  1012
 */
sl@0
  1013
sl@0
  1014
typedef int (CompileHookProc) _ANSI_ARGS_((Tcl_Interp *interp,
sl@0
  1015
	struct CompileEnv *compEnvPtr, ClientData clientData));
sl@0
  1016
sl@0
  1017
/*
sl@0
  1018
 * The data structure defining the execution environment for ByteCode's.
sl@0
  1019
 * There is one ExecEnv structure per Tcl interpreter. It holds the
sl@0
  1020
 * evaluation stack that holds command operands and results. The stack grows
sl@0
  1021
 * towards increasing addresses. The "stackTop" member is cached by
sl@0
  1022
 * TclExecuteByteCode in a local variable: it must be set before calling
sl@0
  1023
 * TclExecuteByteCode and will be restored by TclExecuteByteCode before it
sl@0
  1024
 * returns.
sl@0
  1025
 */
sl@0
  1026
sl@0
  1027
typedef struct ExecEnv {
sl@0
  1028
    Tcl_Obj **stackPtr;		/* Points to the first item in the
sl@0
  1029
				 * evaluation stack on the heap. */
sl@0
  1030
    int stackTop;		/* Index of current top of stack; -1 when
sl@0
  1031
				 * the stack is empty. */
sl@0
  1032
    int stackEnd;		/* Index of last usable item in stack. */
sl@0
  1033
    Tcl_Obj *errorInfo;
sl@0
  1034
    Tcl_Obj *errorCode;
sl@0
  1035
} ExecEnv;
sl@0
  1036
sl@0
  1037
/*
sl@0
  1038
 * The definitions for the LiteralTable and LiteralEntry structures. Each
sl@0
  1039
 * interpreter contains a LiteralTable. It is used to reduce the storage
sl@0
  1040
 * needed for all the Tcl objects that hold the literals of scripts compiled
sl@0
  1041
 * by the interpreter. A literal's object is shared by all the ByteCodes
sl@0
  1042
 * that refer to the literal. Each distinct literal has one LiteralEntry
sl@0
  1043
 * entry in the LiteralTable. A literal table is a specialized hash table
sl@0
  1044
 * that is indexed by the literal's string representation, which may contain
sl@0
  1045
 * null characters.
sl@0
  1046
 *
sl@0
  1047
 * Note that we reduce the space needed for literals by sharing literal
sl@0
  1048
 * objects both within a ByteCode (each ByteCode contains a local
sl@0
  1049
 * LiteralTable) and across all an interpreter's ByteCodes (with the
sl@0
  1050
 * interpreter's global LiteralTable).
sl@0
  1051
 */
sl@0
  1052
sl@0
  1053
typedef struct LiteralEntry {
sl@0
  1054
    struct LiteralEntry *nextPtr;	/* Points to next entry in this
sl@0
  1055
					 * hash bucket or NULL if end of
sl@0
  1056
					 * chain. */
sl@0
  1057
    Tcl_Obj *objPtr;			/* Points to Tcl object that
sl@0
  1058
					 * holds the literal's bytes and
sl@0
  1059
					 * length. */
sl@0
  1060
    int refCount;			/* If in an interpreter's global
sl@0
  1061
					 * literal table, the number of
sl@0
  1062
					 * ByteCode structures that share
sl@0
  1063
					 * the literal object; the literal
sl@0
  1064
					 * entry can be freed when refCount
sl@0
  1065
					 * drops to 0. If in a local literal
sl@0
  1066
					 * table, -1. */
sl@0
  1067
} LiteralEntry;
sl@0
  1068
sl@0
  1069
typedef struct LiteralTable {
sl@0
  1070
    LiteralEntry **buckets;		/* Pointer to bucket array. Each
sl@0
  1071
					 * element points to first entry in
sl@0
  1072
					 * bucket's hash chain, or NULL. */
sl@0
  1073
    LiteralEntry *staticBuckets[TCL_SMALL_HASH_TABLE];
sl@0
  1074
					/* Bucket array used for small
sl@0
  1075
					 * tables to avoid mallocs and
sl@0
  1076
					 * frees. */
sl@0
  1077
    int numBuckets;			/* Total number of buckets allocated
sl@0
  1078
					 * at **buckets. */
sl@0
  1079
    int numEntries;			/* Total number of entries present
sl@0
  1080
					 * in table. */
sl@0
  1081
    int rebuildSize;			/* Enlarge table when numEntries
sl@0
  1082
					 * gets to be this large. */
sl@0
  1083
    int mask;				/* Mask value used in hashing
sl@0
  1084
					 * function. */
sl@0
  1085
} LiteralTable;
sl@0
  1086
sl@0
  1087
/*
sl@0
  1088
 * The following structure defines for each Tcl interpreter various
sl@0
  1089
 * statistics-related information about the bytecode compiler and
sl@0
  1090
 * interpreter's operation in that interpreter.
sl@0
  1091
 */
sl@0
  1092
sl@0
  1093
#ifdef TCL_COMPILE_STATS
sl@0
  1094
typedef struct ByteCodeStats {
sl@0
  1095
    long numExecutions;		  /* Number of ByteCodes executed. */
sl@0
  1096
    long numCompilations;	  /* Number of ByteCodes created. */
sl@0
  1097
    long numByteCodesFreed;	  /* Number of ByteCodes destroyed. */
sl@0
  1098
    long instructionCount[256];	  /* Number of times each instruction was
sl@0
  1099
				   * executed. */
sl@0
  1100
sl@0
  1101
    double totalSrcBytes;	  /* Total source bytes ever compiled. */
sl@0
  1102
    double totalByteCodeBytes;	  /* Total bytes for all ByteCodes. */
sl@0
  1103
    double currentSrcBytes;	  /* Src bytes for all current ByteCodes. */
sl@0
  1104
    double currentByteCodeBytes;  /* Code bytes in all current ByteCodes. */
sl@0
  1105
sl@0
  1106
    long srcCount[32];		  /* Source size distribution: # of srcs of
sl@0
  1107
				   * size [2**(n-1)..2**n), n in [0..32). */
sl@0
  1108
    long byteCodeCount[32];	  /* ByteCode size distribution. */
sl@0
  1109
    long lifetimeCount[32];	  /* ByteCode lifetime distribution (ms). */
sl@0
  1110
    
sl@0
  1111
    double currentInstBytes;	  /* Instruction bytes-current ByteCodes. */
sl@0
  1112
    double currentLitBytes;	  /* Current literal bytes. */
sl@0
  1113
    double currentExceptBytes;	  /* Current exception table bytes. */
sl@0
  1114
    double currentAuxBytes;	  /* Current auxiliary information bytes. */
sl@0
  1115
    double currentCmdMapBytes;	  /* Current src<->code map bytes. */
sl@0
  1116
    
sl@0
  1117
    long numLiteralsCreated;	  /* Total literal objects ever compiled. */
sl@0
  1118
    double totalLitStringBytes;	  /* Total string bytes in all literals. */
sl@0
  1119
    double currentLitStringBytes; /* String bytes in current literals. */
sl@0
  1120
    long literalCount[32];	  /* Distribution of literal string sizes. */
sl@0
  1121
} ByteCodeStats;
sl@0
  1122
#endif /* TCL_COMPILE_STATS */
sl@0
  1123
sl@0
  1124
/*
sl@0
  1125
 *----------------------------------------------------------------
sl@0
  1126
 * Data structures related to commands.
sl@0
  1127
 *----------------------------------------------------------------
sl@0
  1128
 */
sl@0
  1129
sl@0
  1130
/*
sl@0
  1131
 * An imported command is created in an namespace when it imports a "real"
sl@0
  1132
 * command from another namespace. An imported command has a Command
sl@0
  1133
 * structure that points (via its ClientData value) to the "real" Command
sl@0
  1134
 * structure in the source namespace's command table. The real command
sl@0
  1135
 * records all the imported commands that refer to it in a list of ImportRef
sl@0
  1136
 * structures so that they can be deleted when the real command is deleted.  */
sl@0
  1137
sl@0
  1138
typedef struct ImportRef {
sl@0
  1139
    struct Command *importedCmdPtr;
sl@0
  1140
				/* Points to the imported command created in
sl@0
  1141
				 * an importing namespace; this command
sl@0
  1142
				 * redirects its invocations to the "real"
sl@0
  1143
				 * command. */
sl@0
  1144
    struct ImportRef *nextPtr;	/* Next element on the linked list of
sl@0
  1145
				 * imported commands that refer to the
sl@0
  1146
				 * "real" command. The real command deletes
sl@0
  1147
				 * these imported commands on this list when
sl@0
  1148
				 * it is deleted. */
sl@0
  1149
} ImportRef;
sl@0
  1150
sl@0
  1151
/*
sl@0
  1152
 * Data structure used as the ClientData of imported commands: commands
sl@0
  1153
 * created in an namespace when it imports a "real" command from another
sl@0
  1154
 * namespace.
sl@0
  1155
 */
sl@0
  1156
sl@0
  1157
typedef struct ImportedCmdData {
sl@0
  1158
    struct Command *realCmdPtr;	/* "Real" command that this imported command
sl@0
  1159
				 * refers to. */
sl@0
  1160
    struct Command *selfPtr;	/* Pointer to this imported command. Needed
sl@0
  1161
				 * only when deleting it in order to remove
sl@0
  1162
				 * it from the real command's linked list of
sl@0
  1163
				 * imported commands that refer to it. */
sl@0
  1164
} ImportedCmdData;
sl@0
  1165
sl@0
  1166
/*
sl@0
  1167
 * A Command structure exists for each command in a namespace. The
sl@0
  1168
 * Tcl_Command opaque type actually refers to these structures.
sl@0
  1169
 */
sl@0
  1170
sl@0
  1171
typedef struct Command {
sl@0
  1172
    Tcl_HashEntry *hPtr;	/* Pointer to the hash table entry that
sl@0
  1173
				 * refers to this command. The hash table is
sl@0
  1174
				 * either a namespace's command table or an
sl@0
  1175
				 * interpreter's hidden command table. This
sl@0
  1176
				 * pointer is used to get a command's name
sl@0
  1177
				 * from its Tcl_Command handle. NULL means
sl@0
  1178
				 * that the hash table entry has been
sl@0
  1179
				 * removed already (this can happen if
sl@0
  1180
				 * deleteProc causes the command to be
sl@0
  1181
				 * deleted or recreated). */
sl@0
  1182
    Namespace *nsPtr;		/* Points to the namespace containing this
sl@0
  1183
				 * command. */
sl@0
  1184
    int refCount;		/* 1 if in command hashtable plus 1 for each
sl@0
  1185
				 * reference from a CmdName Tcl object
sl@0
  1186
				 * representing a command's name in a
sl@0
  1187
				 * ByteCode instruction sequence. This
sl@0
  1188
				 * structure can be freed when refCount
sl@0
  1189
				 * becomes zero. */
sl@0
  1190
    int cmdEpoch;		/* Incremented to invalidate any references
sl@0
  1191
				 * that point to this command when it is
sl@0
  1192
				 * renamed, deleted, hidden, or exposed. */
sl@0
  1193
    CompileProc *compileProc;	/* Procedure called to compile command. NULL
sl@0
  1194
				 * if no compile proc exists for command. */
sl@0
  1195
    Tcl_ObjCmdProc *objProc;	/* Object-based command procedure. */
sl@0
  1196
    ClientData objClientData;	/* Arbitrary value passed to object proc. */
sl@0
  1197
    Tcl_CmdProc *proc;		/* String-based command procedure. */
sl@0
  1198
    ClientData clientData;	/* Arbitrary value passed to string proc. */
sl@0
  1199
    Tcl_CmdDeleteProc *deleteProc;
sl@0
  1200
				/* Procedure invoked when deleting command
sl@0
  1201
				 * to, e.g., free all client data. */
sl@0
  1202
    ClientData deleteData;	/* Arbitrary value passed to deleteProc. */
sl@0
  1203
    int flags;			/* Miscellaneous bits of information about
sl@0
  1204
				 * command. See below for definitions. */
sl@0
  1205
    ImportRef *importRefPtr;	/* List of each imported Command created in
sl@0
  1206
				 * another namespace when this command is
sl@0
  1207
				 * imported. These imported commands
sl@0
  1208
				 * redirect invocations back to this
sl@0
  1209
				 * command. The list is used to remove all
sl@0
  1210
				 * those imported commands when deleting
sl@0
  1211
				 * this "real" command. */
sl@0
  1212
    CommandTrace *tracePtr;	/* First in list of all traces set for this
sl@0
  1213
				 * command. */
sl@0
  1214
} Command;
sl@0
  1215
sl@0
  1216
/*
sl@0
  1217
 * Flag bits for commands. 
sl@0
  1218
 *
sl@0
  1219
 * CMD_IS_DELETED -		Means that the command is in the process
sl@0
  1220
 *                              of being deleted (its deleteProc is
sl@0
  1221
 *                              currently executing). Other attempts to
sl@0
  1222
 *                              delete the command should be ignored.
sl@0
  1223
 * CMD_TRACE_ACTIVE -		1 means that trace processing is currently
sl@0
  1224
 *				underway for a rename/delete change.
sl@0
  1225
 *				See the two flags below for which is
sl@0
  1226
 *				currently being processed.
sl@0
  1227
 * CMD_HAS_EXEC_TRACES -	1 means that this command has at least
sl@0
  1228
 *                              one execution trace (as opposed to simple
sl@0
  1229
 *                              delete/rename traces) in its tracePtr list.
sl@0
  1230
 * TCL_TRACE_RENAME -           A rename trace is in progress. Further
sl@0
  1231
 *                              recursive renames will not be traced.
sl@0
  1232
 * TCL_TRACE_DELETE -           A delete trace is in progress. Further 
sl@0
  1233
 *                              recursive deletes will not be traced.
sl@0
  1234
 * (these last two flags are defined in tcl.h)
sl@0
  1235
 */
sl@0
  1236
#define CMD_IS_DELETED		0x1
sl@0
  1237
#define CMD_TRACE_ACTIVE	0x2
sl@0
  1238
#define CMD_HAS_EXEC_TRACES	0x4
sl@0
  1239
sl@0
  1240
/*
sl@0
  1241
 *----------------------------------------------------------------
sl@0
  1242
 * Data structures related to name resolution procedures.
sl@0
  1243
 *----------------------------------------------------------------
sl@0
  1244
 */
sl@0
  1245
sl@0
  1246
/*
sl@0
  1247
 * The interpreter keeps a linked list of name resolution schemes.
sl@0
  1248
 * The scheme for a namespace is consulted first, followed by the
sl@0
  1249
 * list of schemes in an interpreter, followed by the default
sl@0
  1250
 * name resolution in Tcl.  Schemes are added/removed from the
sl@0
  1251
 * interpreter's list by calling Tcl_AddInterpResolver and
sl@0
  1252
 * Tcl_RemoveInterpResolver.
sl@0
  1253
 */
sl@0
  1254
sl@0
  1255
typedef struct ResolverScheme {
sl@0
  1256
    char *name;			/* Name identifying this scheme. */
sl@0
  1257
    Tcl_ResolveCmdProc *cmdResProc;
sl@0
  1258
				/* Procedure handling command name
sl@0
  1259
				 * resolution. */
sl@0
  1260
    Tcl_ResolveVarProc *varResProc;
sl@0
  1261
				/* Procedure handling variable name
sl@0
  1262
				 * resolution for variables that
sl@0
  1263
				 * can only be handled at runtime. */
sl@0
  1264
    Tcl_ResolveCompiledVarProc *compiledVarResProc;
sl@0
  1265
				/* Procedure handling variable name
sl@0
  1266
				 * resolution at compile time. */
sl@0
  1267
sl@0
  1268
    struct ResolverScheme *nextPtr;
sl@0
  1269
				/* Pointer to next record in linked list. */
sl@0
  1270
} ResolverScheme;
sl@0
  1271
sl@0
  1272
#ifdef TCL_TIP268
sl@0
  1273
/*
sl@0
  1274
 * TIP #268.
sl@0
  1275
 * Values for the selection mode, i.e the package require preferences.
sl@0
  1276
 */
sl@0
  1277
sl@0
  1278
enum PkgPreferOptions {
sl@0
  1279
    PKG_PREFER_LATEST, PKG_PREFER_STABLE
sl@0
  1280
};
sl@0
  1281
#endif
sl@0
  1282
sl@0
  1283
/*
sl@0
  1284
 *----------------------------------------------------------------
sl@0
  1285
 * This structure defines an interpreter, which is a collection of
sl@0
  1286
 * commands plus other state information related to interpreting
sl@0
  1287
 * commands, such as variable storage. Primary responsibility for
sl@0
  1288
 * this data structure is in tclBasic.c, but almost every Tcl
sl@0
  1289
 * source file uses something in here.
sl@0
  1290
 *----------------------------------------------------------------
sl@0
  1291
 */
sl@0
  1292
sl@0
  1293
typedef struct Interp {
sl@0
  1294
sl@0
  1295
    /*
sl@0
  1296
     * Note:  the first three fields must match exactly the fields in
sl@0
  1297
     * a Tcl_Interp struct (see tcl.h).	 If you change one, be sure to
sl@0
  1298
     * change the other.
sl@0
  1299
     *
sl@0
  1300
     * The interpreter's result is held in both the string and the
sl@0
  1301
     * objResultPtr fields. These fields hold, respectively, the result's
sl@0
  1302
     * string or object value. The interpreter's result is always in the
sl@0
  1303
     * result field if that is non-empty, otherwise it is in objResultPtr.
sl@0
  1304
     * The two fields are kept consistent unless some C code sets
sl@0
  1305
     * interp->result directly. Programs should not access result and
sl@0
  1306
     * objResultPtr directly; instead, they should always get and set the
sl@0
  1307
     * result using procedures such as Tcl_SetObjResult, Tcl_GetObjResult,
sl@0
  1308
     * and Tcl_GetStringResult. See the SetResult man page for details.
sl@0
  1309
     */
sl@0
  1310
sl@0
  1311
    char *result;		/* If the last command returned a string
sl@0
  1312
				 * result, this points to it. Should not be
sl@0
  1313
				 * accessed directly; see comment above. */
sl@0
  1314
    Tcl_FreeProc *freeProc;	/* Zero means a string result is statically
sl@0
  1315
				 * allocated. TCL_DYNAMIC means string
sl@0
  1316
				 * result was allocated with ckalloc and
sl@0
  1317
				 * should be freed with ckfree. Other values
sl@0
  1318
				 * give address of procedure to invoke to
sl@0
  1319
				 * free the string result. Tcl_Eval must
sl@0
  1320
				 * free it before executing next command. */
sl@0
  1321
    int errorLine;		/* When TCL_ERROR is returned, this gives
sl@0
  1322
				 * the line number in the command where the
sl@0
  1323
				 * error occurred (1 means first line). */
sl@0
  1324
    struct TclStubs *stubTable;
sl@0
  1325
				/* Pointer to the exported Tcl stub table.
sl@0
  1326
				 * On previous versions of Tcl this is a
sl@0
  1327
				 * pointer to the objResultPtr or a pointer
sl@0
  1328
				 * to a buckets array in a hash table. We
sl@0
  1329
				 * therefore have to do some careful checking
sl@0
  1330
				 * before we can use this. */
sl@0
  1331
sl@0
  1332
    TclHandle handle;		/* Handle used to keep track of when this
sl@0
  1333
				 * interp is deleted. */
sl@0
  1334
sl@0
  1335
    Namespace *globalNsPtr;	/* The interpreter's global namespace. */
sl@0
  1336
    Tcl_HashTable *hiddenCmdTablePtr;
sl@0
  1337
				/* Hash table used by tclBasic.c to keep
sl@0
  1338
				 * track of hidden commands on a per-interp
sl@0
  1339
				 * basis. */
sl@0
  1340
    ClientData interpInfo;	/* Information used by tclInterp.c to keep
sl@0
  1341
				 * track of master/slave interps on
sl@0
  1342
				 * a per-interp basis. */
sl@0
  1343
    Tcl_HashTable mathFuncTable;/* Contains all the math functions currently
sl@0
  1344
				 * defined for the interpreter.	 Indexed by
sl@0
  1345
				 * strings (function names); values have
sl@0
  1346
				 * type (MathFunc *). */
sl@0
  1347
sl@0
  1348
sl@0
  1349
sl@0
  1350
    /*
sl@0
  1351
     * Information related to procedures and variables. See tclProc.c
sl@0
  1352
     * and tclVar.c for usage.
sl@0
  1353
     */
sl@0
  1354
sl@0
  1355
    int numLevels;		/* Keeps track of how many nested calls to
sl@0
  1356
				 * Tcl_Eval are in progress for this
sl@0
  1357
				 * interpreter.	 It's used to delay deletion
sl@0
  1358
				 * of the table until all Tcl_Eval
sl@0
  1359
				 * invocations are completed. */
sl@0
  1360
    int maxNestingDepth;	/* If numLevels exceeds this value then Tcl
sl@0
  1361
				 * assumes that infinite recursion has
sl@0
  1362
				 * occurred and it generates an error. */
sl@0
  1363
    CallFrame *framePtr;	/* Points to top-most in stack of all nested
sl@0
  1364
				 * procedure invocations.  NULL means there
sl@0
  1365
				 * are no active procedures. */
sl@0
  1366
    CallFrame *varFramePtr;	/* Points to the call frame whose variables
sl@0
  1367
				 * are currently in use (same as framePtr
sl@0
  1368
				 * unless an "uplevel" command is
sl@0
  1369
				 * executing). NULL means no procedure is
sl@0
  1370
				 * active or "uplevel 0" is executing. */
sl@0
  1371
    ActiveVarTrace *activeVarTracePtr;
sl@0
  1372
				/* First in list of active traces for
sl@0
  1373
				 * interp, or NULL if no active traces. */
sl@0
  1374
    int returnCode;		/* Completion code to return if current
sl@0
  1375
				 * procedure exits with TCL_RETURN code. */
sl@0
  1376
    char *errorInfo;		/* Value to store in errorInfo if returnCode
sl@0
  1377
				 * is TCL_ERROR.  Malloc'ed, may be NULL */
sl@0
  1378
    char *errorCode;		/* Value to store in errorCode if returnCode
sl@0
  1379
				 * is TCL_ERROR.  Malloc'ed, may be NULL */
sl@0
  1380
sl@0
  1381
    /*
sl@0
  1382
     * Information used by Tcl_AppendResult to keep track of partial
sl@0
  1383
     * results.	 See Tcl_AppendResult code for details.
sl@0
  1384
     */
sl@0
  1385
sl@0
  1386
    char *appendResult;		/* Storage space for results generated
sl@0
  1387
				 * by Tcl_AppendResult.	 Malloc-ed.  NULL
sl@0
  1388
				 * means not yet allocated. */
sl@0
  1389
    int appendAvl;		/* Total amount of space available at
sl@0
  1390
				 * partialResult. */
sl@0
  1391
    int appendUsed;		/* Number of non-null bytes currently
sl@0
  1392
				 * stored at partialResult. */
sl@0
  1393
sl@0
  1394
    /*
sl@0
  1395
     * Information about packages.  Used only in tclPkg.c.
sl@0
  1396
     */
sl@0
  1397
sl@0
  1398
    Tcl_HashTable packageTable;	/* Describes all of the packages loaded
sl@0
  1399
				 * in or available to this interpreter.
sl@0
  1400
				 * Keys are package names, values are
sl@0
  1401
				 * (Package *) pointers. */
sl@0
  1402
    char *packageUnknown;	/* Command to invoke during "package
sl@0
  1403
				 * require" commands for packages that
sl@0
  1404
				 * aren't described in packageTable. 
sl@0
  1405
				 * Malloc'ed, may be NULL. */
sl@0
  1406
sl@0
  1407
    /*
sl@0
  1408
     * Miscellaneous information:
sl@0
  1409
     */
sl@0
  1410
sl@0
  1411
    int cmdCount;		/* Total number of times a command procedure
sl@0
  1412
				 * has been called for this interpreter. */
sl@0
  1413
    int evalFlags;		/* Flags to control next call to Tcl_Eval.
sl@0
  1414
				 * Normally zero, but may be set before
sl@0
  1415
				 * calling Tcl_Eval.  See below for valid
sl@0
  1416
				 * values. */
sl@0
  1417
    int termOffset;		/* Offset of character just after last one
sl@0
  1418
				 * compiled or executed by Tcl_EvalObj. */
sl@0
  1419
    LiteralTable literalTable;	/* Contains LiteralEntry's describing all
sl@0
  1420
				 * Tcl objects holding literals of scripts
sl@0
  1421
				 * compiled by the interpreter. Indexed by
sl@0
  1422
				 * the string representations of literals.
sl@0
  1423
				 * Used to avoid creating duplicate
sl@0
  1424
				 * objects. */
sl@0
  1425
    int compileEpoch;		/* Holds the current "compilation epoch"
sl@0
  1426
				 * for this interpreter. This is
sl@0
  1427
				 * incremented to invalidate existing
sl@0
  1428
				 * ByteCodes when, e.g., a command with a
sl@0
  1429
				 * compile procedure is redefined. */
sl@0
  1430
    Proc *compiledProcPtr;	/* If a procedure is being compiled, a
sl@0
  1431
				 * pointer to its Proc structure; otherwise,
sl@0
  1432
				 * this is NULL. Set by ObjInterpProc in
sl@0
  1433
				 * tclProc.c and used by tclCompile.c to
sl@0
  1434
				 * process local variables appropriately. */
sl@0
  1435
    ResolverScheme *resolverPtr;
sl@0
  1436
				/* Linked list of name resolution schemes
sl@0
  1437
				 * added to this interpreter.  Schemes
sl@0
  1438
				 * are added/removed by calling
sl@0
  1439
				 * Tcl_AddInterpResolvers and
sl@0
  1440
				 * Tcl_RemoveInterpResolver. */
sl@0
  1441
    Tcl_Obj *scriptFile;	/* NULL means there is no nested source
sl@0
  1442
				 * command active;  otherwise this points to
sl@0
  1443
				 * pathPtr of the file being sourced. */
sl@0
  1444
    int flags;			/* Various flag bits.  See below. */
sl@0
  1445
    long randSeed;		/* Seed used for rand() function. */
sl@0
  1446
    Trace *tracePtr;		/* List of traces for this interpreter. */
sl@0
  1447
    Tcl_HashTable *assocData;	/* Hash table for associating data with
sl@0
  1448
				 * this interpreter. Cleaned up when
sl@0
  1449
				 * this interpreter is deleted. */
sl@0
  1450
    struct ExecEnv *execEnvPtr;	/* Execution environment for Tcl bytecode
sl@0
  1451
				 * execution. Contains a pointer to the
sl@0
  1452
				 * Tcl evaluation stack. */
sl@0
  1453
    Tcl_Obj *emptyObjPtr;	/* Points to an object holding an empty
sl@0
  1454
				 * string. Returned by Tcl_ObjSetVar2 when
sl@0
  1455
				 * variable traces change a variable in a
sl@0
  1456
				 * gross way. */
sl@0
  1457
    char resultSpace[TCL_RESULT_SIZE+1];
sl@0
  1458
				/* Static space holding small results. */
sl@0
  1459
    Tcl_Obj *objResultPtr;	/* If the last command returned an object
sl@0
  1460
				 * result, this points to it. Should not be
sl@0
  1461
				 * accessed directly; see comment above. */
sl@0
  1462
    Tcl_ThreadId threadId;	/* ID of thread that owns the interpreter */
sl@0
  1463
sl@0
  1464
    ActiveCommandTrace *activeCmdTracePtr;
sl@0
  1465
				/* First in list of active command traces for
sl@0
  1466
				 * interp, or NULL if no active traces. */
sl@0
  1467
    ActiveInterpTrace *activeInterpTracePtr;
sl@0
  1468
				/* First in list of active traces for
sl@0
  1469
				 * interp, or NULL if no active traces. */
sl@0
  1470
sl@0
  1471
    int tracesForbiddingInline; /* Count of traces (in the list headed by
sl@0
  1472
				 * tracePtr) that forbid inline bytecode
sl@0
  1473
				 * compilation */
sl@0
  1474
#ifdef TCL_TIP280
sl@0
  1475
    /* TIP #280 */
sl@0
  1476
    CmdFrame* cmdFramePtr;      /* Points to the command frame containing
sl@0
  1477
				 * the location information for the current
sl@0
  1478
				 * command. */
sl@0
  1479
    CONST CmdFrame* invokeCmdFramePtr; /* Points to the command frame which is the
sl@0
  1480
				  * invoking context of the bytecode compiler.
sl@0
  1481
				  * NULL when the byte code compiler is not
sl@0
  1482
				  * active */
sl@0
  1483
    int invokeWord;             /* Index of the word in the command which
sl@0
  1484
				 * is getting compiled. */
sl@0
  1485
    Tcl_HashTable* linePBodyPtr;
sl@0
  1486
                                /* This table remembers for each
sl@0
  1487
				 * statically defined procedure the
sl@0
  1488
				 * location information for its
sl@0
  1489
				 * body. It is keyed by the address of
sl@0
  1490
				 * the Proc structure for a procedure.
sl@0
  1491
				 */
sl@0
  1492
    Tcl_HashTable* lineBCPtr;
sl@0
  1493
                                /* This table remembers for each
sl@0
  1494
				 * ByteCode object the location
sl@0
  1495
				 * information for its body. It is
sl@0
  1496
				 * keyed by the address of the Proc
sl@0
  1497
				 * structure for a procedure.
sl@0
  1498
				 */
sl@0
  1499
#endif
sl@0
  1500
#ifdef TCL_TIP268
sl@0
  1501
    /*
sl@0
  1502
     * TIP #268.
sl@0
  1503
     * The currently active selection mode,
sl@0
  1504
     * i.e the package require preferences.
sl@0
  1505
     */
sl@0
  1506
sl@0
  1507
    int packagePrefer;          /* Current package selection mode. */
sl@0
  1508
#endif
sl@0
  1509
    /*
sl@0
  1510
     * Statistical information about the bytecode compiler and interpreter's
sl@0
  1511
     * operation.
sl@0
  1512
     */
sl@0
  1513
sl@0
  1514
#ifdef TCL_COMPILE_STATS
sl@0
  1515
    ByteCodeStats stats;	/* Holds compilation and execution
sl@0
  1516
				 * statistics for this interpreter. */
sl@0
  1517
#endif /* TCL_COMPILE_STATS */	  
sl@0
  1518
} Interp;
sl@0
  1519
sl@0
  1520
/*
sl@0
  1521
 * EvalFlag bits for Interp structures:
sl@0
  1522
 *
sl@0
  1523
 * TCL_BRACKET_TERM	1 means that the current script is terminated by
sl@0
  1524
 *			a close bracket rather than the end of the string.
sl@0
  1525
 * TCL_ALLOW_EXCEPTIONS	1 means it's OK for the script to terminate with
sl@0
  1526
 *			a code other than TCL_OK or TCL_ERROR;	0 means
sl@0
  1527
 *			codes other than these should be turned into errors.
sl@0
  1528
 */
sl@0
  1529
sl@0
  1530
#define TCL_BRACKET_TERM	  1
sl@0
  1531
#define TCL_ALLOW_EXCEPTIONS	  4
sl@0
  1532
#ifdef TCL_TIP280
sl@0
  1533
#define TCL_EVAL_FILE             2
sl@0
  1534
#define TCL_EVAL_CTX              8
sl@0
  1535
#endif
sl@0
  1536
sl@0
  1537
/*
sl@0
  1538
 * Flag bits for Interp structures:
sl@0
  1539
 *
sl@0
  1540
 * DELETED:		Non-zero means the interpreter has been deleted:
sl@0
  1541
 *			don't process any more commands for it, and destroy
sl@0
  1542
 *			the structure as soon as all nested invocations of
sl@0
  1543
 *			Tcl_Eval are done.
sl@0
  1544
 * ERR_IN_PROGRESS:	Non-zero means an error unwind is already in
sl@0
  1545
 *			progress. Zero means a command proc has been
sl@0
  1546
 *			invoked since last error occured.
sl@0
  1547
 * ERR_ALREADY_LOGGED:	Non-zero means information has already been logged
sl@0
  1548
 *			in $errorInfo for the current Tcl_Eval instance,
sl@0
  1549
 *			so Tcl_Eval needn't log it (used to implement the
sl@0
  1550
 *			"error message log" command).
sl@0
  1551
 * ERROR_CODE_SET:	Non-zero means that Tcl_SetErrorCode has been
sl@0
  1552
 *			called to record information for the current
sl@0
  1553
 *			error.	Zero means Tcl_Eval must clear the
sl@0
  1554
 *			errorCode variable if an error is returned.
sl@0
  1555
 * EXPR_INITIALIZED:	Non-zero means initialization specific to
sl@0
  1556
 *			expressions has	been carried out.
sl@0
  1557
 * DONT_COMPILE_CMDS_INLINE: Non-zero means that the bytecode compiler
sl@0
  1558
 *			should not compile any commands into an inline
sl@0
  1559
 *			sequence of instructions. This is set 1, for
sl@0
  1560
 *			example, when command traces are requested.
sl@0
  1561
 * RAND_SEED_INITIALIZED: Non-zero means that the randSeed value of the
sl@0
  1562
 *			interp has not be initialized.	This is set 1
sl@0
  1563
 *			when we first use the rand() or srand() functions.
sl@0
  1564
 * SAFE_INTERP:		Non zero means that the current interp is a
sl@0
  1565
 *			safe interp (ie it has only the safe commands
sl@0
  1566
 *			installed, less priviledge than a regular interp).
sl@0
  1567
 * USE_EVAL_DIRECT:	Non-zero means don't use the compiler or byte-code
sl@0
  1568
 *			interpreter; instead, have Tcl_EvalObj call
sl@0
  1569
 *			Tcl_EvalEx. Used primarily for testing the
sl@0
  1570
 *			new parser.
sl@0
  1571
 * INTERP_TRACE_IN_PROGRESS: Non-zero means that an interp trace is currently
sl@0
  1572
 *			active; so no further trace callbacks should be
sl@0
  1573
 *			invoked.
sl@0
  1574
 */
sl@0
  1575
sl@0
  1576
#define DELETED				    1
sl@0
  1577
#define ERR_IN_PROGRESS			    2
sl@0
  1578
#define ERR_ALREADY_LOGGED		    4
sl@0
  1579
#define ERROR_CODE_SET			    8
sl@0
  1580
#define EXPR_INITIALIZED		 0x10
sl@0
  1581
#define DONT_COMPILE_CMDS_INLINE	 0x20
sl@0
  1582
#define RAND_SEED_INITIALIZED		 0x40
sl@0
  1583
#define SAFE_INTERP			 0x80
sl@0
  1584
#define USE_EVAL_DIRECT			0x100
sl@0
  1585
#define INTERP_TRACE_IN_PROGRESS	0x200
sl@0
  1586
sl@0
  1587
/*
sl@0
  1588
 * Maximum number of levels of nesting permitted in Tcl commands (used
sl@0
  1589
 * to catch infinite recursion).
sl@0
  1590
 */
sl@0
  1591
sl@0
  1592
#define MAX_NESTING_DEPTH	1000
sl@0
  1593
sl@0
  1594
/*
sl@0
  1595
 * The macro below is used to modify a "char" value (e.g. by casting
sl@0
  1596
 * it to an unsigned character) so that it can be used safely with
sl@0
  1597
 * macros such as isspace.
sl@0
  1598
 */
sl@0
  1599
sl@0
  1600
#define UCHAR(c) ((unsigned char) (c))
sl@0
  1601
sl@0
  1602
/*
sl@0
  1603
 * This macro is used to determine the offset needed to safely allocate any
sl@0
  1604
 * data structure in memory. Given a starting offset or size, it "rounds up"
sl@0
  1605
 * or "aligns" the offset to the next 8-byte boundary so that any data
sl@0
  1606
 * structure can be placed at the resulting offset without fear of an
sl@0
  1607
 * alignment error.
sl@0
  1608
 *
sl@0
  1609
 * WARNING!! DO NOT USE THIS MACRO TO ALIGN POINTERS: it will produce
sl@0
  1610
 * the wrong result on platforms that allocate addresses that are divisible
sl@0
  1611
 * by 4 or 2. Only use it for offsets or sizes.
sl@0
  1612
 */
sl@0
  1613
sl@0
  1614
#define TCL_ALIGN(x) (((int)(x) + 7) & ~7)
sl@0
  1615
sl@0
  1616
/*
sl@0
  1617
 * The following enum values are used to specify the runtime platform
sl@0
  1618
 * setting of the tclPlatform variable.
sl@0
  1619
 */
sl@0
  1620
sl@0
  1621
typedef enum {
sl@0
  1622
    TCL_PLATFORM_UNIX,		/* Any Unix-like OS. */
sl@0
  1623
    TCL_PLATFORM_MAC,		/* MacOS. */
sl@0
  1624
    TCL_PLATFORM_WINDOWS	/* Any Microsoft Windows OS. */
sl@0
  1625
} TclPlatformType;
sl@0
  1626
sl@0
  1627
/*
sl@0
  1628
 *  The following enum values are used to indicate the translation
sl@0
  1629
 *  of a Tcl channel.  Declared here so that each platform can define
sl@0
  1630
 *  TCL_PLATFORM_TRANSLATION to the native translation on that platform
sl@0
  1631
 */
sl@0
  1632
sl@0
  1633
typedef enum TclEolTranslation {
sl@0
  1634
    TCL_TRANSLATE_AUTO,                 /* Eol == \r, \n and \r\n. */
sl@0
  1635
    TCL_TRANSLATE_CR,                   /* Eol == \r. */
sl@0
  1636
    TCL_TRANSLATE_LF,                   /* Eol == \n. */
sl@0
  1637
    TCL_TRANSLATE_CRLF                  /* Eol == \r\n. */
sl@0
  1638
} TclEolTranslation;
sl@0
  1639
sl@0
  1640
/*
sl@0
  1641
 * Flags for TclInvoke:
sl@0
  1642
 *
sl@0
  1643
 * TCL_INVOKE_HIDDEN		Invoke a hidden command; if not set,
sl@0
  1644
 *				invokes an exposed command.
sl@0
  1645
 * TCL_INVOKE_NO_UNKNOWN	If set, "unknown" is not invoked if
sl@0
  1646
 *				the command to be invoked is not found.
sl@0
  1647
 *				Only has an effect if invoking an exposed
sl@0
  1648
 *				command, i.e. if TCL_INVOKE_HIDDEN is not
sl@0
  1649
 *				also set.
sl@0
  1650
 * TCL_INVOKE_NO_TRACEBACK	Does not record traceback information if
sl@0
  1651
 *				the invoked command returns an error.  Used
sl@0
  1652
 *				if the caller plans on recording its own
sl@0
  1653
 *				traceback information.
sl@0
  1654
 */
sl@0
  1655
sl@0
  1656
#define	TCL_INVOKE_HIDDEN	(1<<0)
sl@0
  1657
#define TCL_INVOKE_NO_UNKNOWN	(1<<1)
sl@0
  1658
#define TCL_INVOKE_NO_TRACEBACK	(1<<2)
sl@0
  1659
sl@0
  1660
/*
sl@0
  1661
 * The structure used as the internal representation of Tcl list
sl@0
  1662
 * objects. This is an array of pointers to the element objects. This array
sl@0
  1663
 * is grown (reallocated and copied) as necessary to hold all the list's
sl@0
  1664
 * element pointers. The array might contain more slots than currently used
sl@0
  1665
 * to hold all element pointers. This is done to make append operations
sl@0
  1666
 * faster.
sl@0
  1667
 */
sl@0
  1668
sl@0
  1669
typedef struct List {
sl@0
  1670
    int maxElemCount;		/* Total number of element array slots. */
sl@0
  1671
    int elemCount;		/* Current number of list elements. */
sl@0
  1672
    Tcl_Obj **elements;		/* Array of pointers to element objects. */
sl@0
  1673
} List;
sl@0
  1674
sl@0
  1675
sl@0
  1676
/*
sl@0
  1677
 * The following types are used for getting and storing platform-specific
sl@0
  1678
 * file attributes in tclFCmd.c and the various platform-versions of
sl@0
  1679
 * that file. This is done to have as much common code as possible
sl@0
  1680
 * in the file attributes code. For more information about the callbacks,
sl@0
  1681
 * see TclFileAttrsCmd in tclFCmd.c.
sl@0
  1682
 */
sl@0
  1683
sl@0
  1684
typedef int (TclGetFileAttrProc) _ANSI_ARGS_((Tcl_Interp *interp,
sl@0
  1685
	int objIndex, Tcl_Obj *fileName, Tcl_Obj **attrObjPtrPtr));
sl@0
  1686
typedef int (TclSetFileAttrProc) _ANSI_ARGS_((Tcl_Interp *interp,
sl@0
  1687
	int objIndex, Tcl_Obj *fileName, Tcl_Obj *attrObjPtr));
sl@0
  1688
sl@0
  1689
typedef struct TclFileAttrProcs {
sl@0
  1690
    TclGetFileAttrProc *getProc;	/* The procedure for getting attrs. */
sl@0
  1691
    TclSetFileAttrProc *setProc;	/* The procedure for setting attrs. */
sl@0
  1692
} TclFileAttrProcs;
sl@0
  1693
sl@0
  1694
/*
sl@0
  1695
 * Opaque handle used in pipeline routines to encapsulate platform-dependent
sl@0
  1696
 * state. 
sl@0
  1697
 */
sl@0
  1698
sl@0
  1699
typedef struct TclFile_ *TclFile;
sl@0
  1700
    
sl@0
  1701
/*
sl@0
  1702
 * Opaque names for platform specific types.
sl@0
  1703
 */
sl@0
  1704
sl@0
  1705
typedef struct TclpTime_t_    *TclpTime_t;
sl@0
  1706
typedef struct TclpTime_t_    *CONST TclpTime_t_CONST;
sl@0
  1707
sl@0
  1708
/*
sl@0
  1709
 * The "globParameters" argument of the function TclGlob is an
sl@0
  1710
 * or'ed combination of the following values:
sl@0
  1711
 */
sl@0
  1712
sl@0
  1713
#define TCL_GLOBMODE_NO_COMPLAIN      1
sl@0
  1714
#define TCL_GLOBMODE_JOIN             2
sl@0
  1715
#define TCL_GLOBMODE_DIR              4
sl@0
  1716
#define TCL_GLOBMODE_TAILS            8
sl@0
  1717
sl@0
  1718
/*
sl@0
  1719
 *----------------------------------------------------------------
sl@0
  1720
 * Data structures related to obsolete filesystem hooks
sl@0
  1721
 *----------------------------------------------------------------
sl@0
  1722
 */
sl@0
  1723
sl@0
  1724
typedef int (TclStatProc_) _ANSI_ARGS_((CONST char *path, struct stat *buf));
sl@0
  1725
typedef int (TclAccessProc_) _ANSI_ARGS_((CONST char *path, int mode));
sl@0
  1726
typedef Tcl_Channel (TclOpenFileChannelProc_) _ANSI_ARGS_((Tcl_Interp *interp,
sl@0
  1727
	CONST char *fileName, CONST char *modeString,
sl@0
  1728
	int permissions));
sl@0
  1729
sl@0
  1730
sl@0
  1731
/*
sl@0
  1732
 *----------------------------------------------------------------
sl@0
  1733
 * Data structures related to procedures
sl@0
  1734
 *----------------------------------------------------------------
sl@0
  1735
 */
sl@0
  1736
sl@0
  1737
typedef Tcl_CmdProc *TclCmdProcType;
sl@0
  1738
typedef Tcl_ObjCmdProc *TclObjCmdProcType;
sl@0
  1739
sl@0
  1740
/*
sl@0
  1741
 *----------------------------------------------------------------
sl@0
  1742
 * Variables shared among Tcl modules but not used by the outside world.
sl@0
  1743
 *----------------------------------------------------------------
sl@0
  1744
 */
sl@0
  1745
sl@0
  1746
extern Tcl_Time			tclBlockTime;
sl@0
  1747
extern int			tclBlockTimeSet;
sl@0
  1748
extern char *			tclExecutableName;
sl@0
  1749
extern char *			tclNativeExecutableName;
sl@0
  1750
extern char *			tclDefaultEncodingDir;
sl@0
  1751
extern Tcl_ChannelType		tclFileChannelType;
sl@0
  1752
extern char *			tclMemDumpFileName;
sl@0
  1753
extern TclPlatformType		tclPlatform;
sl@0
  1754
extern Tcl_NotifierProcs	tclOriginalNotifier;
sl@0
  1755
sl@0
  1756
/*
sl@0
  1757
 * Variables denoting the Tcl object types defined in the core.
sl@0
  1758
 */
sl@0
  1759
sl@0
  1760
extern Tcl_ObjType	tclBooleanType;
sl@0
  1761
extern Tcl_ObjType	tclByteArrayType;
sl@0
  1762
extern Tcl_ObjType	tclByteCodeType;
sl@0
  1763
extern Tcl_ObjType	tclDoubleType;
sl@0
  1764
extern Tcl_ObjType	tclEndOffsetType;
sl@0
  1765
extern Tcl_ObjType	tclIntType;
sl@0
  1766
extern Tcl_ObjType	tclListType;
sl@0
  1767
extern Tcl_ObjType	tclProcBodyType;
sl@0
  1768
extern Tcl_ObjType	tclStringType;
sl@0
  1769
extern Tcl_ObjType	tclArraySearchType;
sl@0
  1770
extern Tcl_ObjType	tclIndexType;
sl@0
  1771
extern Tcl_ObjType	tclNsNameType;
sl@0
  1772
extern Tcl_ObjType	tclWideIntType;
sl@0
  1773
sl@0
  1774
/*
sl@0
  1775
 * Variables denoting the hash key types defined in the core.
sl@0
  1776
 */
sl@0
  1777
sl@0
  1778
extern Tcl_HashKeyType tclArrayHashKeyType;
sl@0
  1779
extern Tcl_HashKeyType tclOneWordHashKeyType;
sl@0
  1780
extern Tcl_HashKeyType tclStringHashKeyType;
sl@0
  1781
extern Tcl_HashKeyType tclObjHashKeyType;
sl@0
  1782
sl@0
  1783
/*
sl@0
  1784
 * The head of the list of free Tcl objects, and the total number of Tcl
sl@0
  1785
 * objects ever allocated and freed.
sl@0
  1786
 */
sl@0
  1787
sl@0
  1788
extern Tcl_Obj *	tclFreeObjList;
sl@0
  1789
sl@0
  1790
#ifdef TCL_COMPILE_STATS
sl@0
  1791
extern long		tclObjsAlloced;
sl@0
  1792
extern long		tclObjsFreed;
sl@0
  1793
#define TCL_MAX_SHARED_OBJ_STATS 5
sl@0
  1794
extern long		tclObjsShared[TCL_MAX_SHARED_OBJ_STATS];
sl@0
  1795
#endif /* TCL_COMPILE_STATS */
sl@0
  1796
sl@0
  1797
/*
sl@0
  1798
 * Pointer to a heap-allocated string of length zero that the Tcl core uses
sl@0
  1799
 * as the value of an empty string representation for an object. This value
sl@0
  1800
 * is shared by all new objects allocated by Tcl_NewObj.
sl@0
  1801
 */
sl@0
  1802
sl@0
  1803
extern char *		tclEmptyStringRep;
sl@0
  1804
extern char		tclEmptyString;
sl@0
  1805
sl@0
  1806
/*
sl@0
  1807
 *----------------------------------------------------------------
sl@0
  1808
 * Procedures shared among Tcl modules but not used by the outside
sl@0
  1809
 * world:
sl@0
  1810
 *----------------------------------------------------------------
sl@0
  1811
 */
sl@0
  1812
sl@0
  1813
#ifdef TCL_TIP280
sl@0
  1814
EXTERN void             TclAdvanceLines _ANSI_ARGS_((int* line, CONST char* start,
sl@0
  1815
						     CONST char* end));
sl@0
  1816
#endif
sl@0
  1817
EXTERN int		TclArraySet _ANSI_ARGS_((Tcl_Interp *interp,
sl@0
  1818
			    Tcl_Obj *arrayNameObj, Tcl_Obj *arrayElemObj));
sl@0
  1819
EXTERN int		TclCheckBadOctal _ANSI_ARGS_((Tcl_Interp *interp,
sl@0
  1820
			    CONST char *value));
sl@0
  1821
EXTERN void		TclDeleteNamespaceVars _ANSI_ARGS_((Namespace *nsPtr));
sl@0
  1822
sl@0
  1823
#ifdef TCL_TIP280
sl@0
  1824
EXTERN int              TclEvalObjEx _ANSI_ARGS_((Tcl_Interp *interp,
sl@0
  1825
						  register Tcl_Obj *objPtr,
sl@0
  1826
						  int flags,
sl@0
  1827
						  CONST CmdFrame* invoker,
sl@0
  1828
						  int word));
sl@0
  1829
#endif
sl@0
  1830
sl@0
  1831
EXTERN void		TclExpandTokenArray _ANSI_ARGS_((
sl@0
  1832
			    Tcl_Parse *parsePtr));
sl@0
  1833
EXTERN int		TclFileAttrsCmd _ANSI_ARGS_((Tcl_Interp *interp,
sl@0
  1834
			    int objc, Tcl_Obj *CONST objv[]));
sl@0
  1835
EXTERN int		TclFileCopyCmd _ANSI_ARGS_((Tcl_Interp *interp, 
sl@0
  1836
			    int objc, Tcl_Obj *CONST objv[])) ;
sl@0
  1837
EXTERN int		TclFileDeleteCmd _ANSI_ARGS_((Tcl_Interp *interp,
sl@0
  1838
			    int objc, Tcl_Obj *CONST objv[]));
sl@0
  1839
EXTERN int		TclFileMakeDirsCmd _ANSI_ARGS_((Tcl_Interp *interp,
sl@0
  1840
			    int objc, Tcl_Obj *CONST objv[])) ;
sl@0
  1841
EXTERN int		TclFileRenameCmd _ANSI_ARGS_((Tcl_Interp *interp,
sl@0
  1842
			    int objc, Tcl_Obj *CONST objv[])) ;
sl@0
  1843
EXTERN void		TclFinalizeAllocSubsystem _ANSI_ARGS_((void));
sl@0
  1844
EXTERN void		TclFinalizeAsync _ANSI_ARGS_((void));
sl@0
  1845
EXTERN void		TclFinalizeCompilation _ANSI_ARGS_((void));
sl@0
  1846
EXTERN void		TclFinalizeEncodingSubsystem _ANSI_ARGS_((void));
sl@0
  1847
EXTERN void		TclFinalizeEnvironment _ANSI_ARGS_((void));
sl@0
  1848
EXTERN void		TclFinalizeExecution _ANSI_ARGS_((void));
sl@0
  1849
EXTERN void		TclFinalizeIOSubsystem _ANSI_ARGS_((void));
sl@0
  1850
EXTERN void		TclFinalizeFilesystem _ANSI_ARGS_((void));
sl@0
  1851
EXTERN void		TclResetFilesystem _ANSI_ARGS_((void));
sl@0
  1852
EXTERN void		TclFinalizeLoad _ANSI_ARGS_((void));
sl@0
  1853
EXTERN void		TclFinalizeLock _ANSI_ARGS_((void));
sl@0
  1854
EXTERN void		TclFinalizeMemorySubsystem _ANSI_ARGS_((void));
sl@0
  1855
EXTERN void		TclFinalizeNotifier _ANSI_ARGS_((void));
sl@0
  1856
EXTERN void		TclFinalizeObjects _ANSI_ARGS_((void));
sl@0
  1857
EXTERN void		TclFinalizePreserve _ANSI_ARGS_((void));
sl@0
  1858
EXTERN void		TclFinalizeSynchronization _ANSI_ARGS_((void));
sl@0
  1859
EXTERN void		TclFinalizeThreadAlloc _ANSI_ARGS_((void));
sl@0
  1860
EXTERN void		TclFinalizeThreadData _ANSI_ARGS_((void));
sl@0
  1861
EXTERN int		TclGetEncodingFromObj _ANSI_ARGS_((Tcl_Interp *interp,
sl@0
  1862
			    Tcl_Obj *objPtr, Tcl_Encoding *encodingPtr));
sl@0
  1863
#ifdef TCL_TIP280
sl@0
  1864
EXTERN void             TclGetSrcInfoForPc _ANSI_ARGS_((CmdFrame* cfPtr));
sl@0
  1865
#endif
sl@0
  1866
EXTERN int		TclGlob _ANSI_ARGS_((Tcl_Interp *interp,
sl@0
  1867
			    char *pattern, Tcl_Obj *unquotedPrefix, 
sl@0
  1868
			    int globFlags, Tcl_GlobTypeData* types));
sl@0
  1869
EXTERN void		TclInitAlloc _ANSI_ARGS_((void));
sl@0
  1870
EXTERN void		TclInitDbCkalloc _ANSI_ARGS_((void));
sl@0
  1871
EXTERN void		TclInitEncodingSubsystem _ANSI_ARGS_((void));
sl@0
  1872
EXTERN void		TclInitIOSubsystem _ANSI_ARGS_((void));
sl@0
  1873
EXTERN void		TclInitNamespaceSubsystem _ANSI_ARGS_((void));
sl@0
  1874
EXTERN void		TclInitNotifier _ANSI_ARGS_((void));
sl@0
  1875
EXTERN void		TclInitObjSubsystem _ANSI_ARGS_((void));
sl@0
  1876
EXTERN void		TclInitSubsystems _ANSI_ARGS_((CONST char *argv0));
sl@0
  1877
EXTERN int		TclIsLocalScalar _ANSI_ARGS_((CONST char *src,
sl@0
  1878
			    int len));
sl@0
  1879
EXTERN int              TclJoinThread _ANSI_ARGS_((Tcl_ThreadId id,
sl@0
  1880
			    int* result));
sl@0
  1881
EXTERN Tcl_Obj *	TclLindexList _ANSI_ARGS_((Tcl_Interp* interp,
sl@0
  1882
						   Tcl_Obj* listPtr,
sl@0
  1883
						   Tcl_Obj* argPtr ));
sl@0
  1884
EXTERN Tcl_Obj *	TclLindexFlat _ANSI_ARGS_((Tcl_Interp* interp,
sl@0
  1885
						   Tcl_Obj* listPtr,
sl@0
  1886
						   int indexCount,
sl@0
  1887
						   Tcl_Obj *CONST indexArray[]
sl@0
  1888
						   ));
sl@0
  1889
EXTERN Tcl_Obj *	TclLsetList _ANSI_ARGS_((Tcl_Interp* interp,
sl@0
  1890
						 Tcl_Obj* listPtr,
sl@0
  1891
						 Tcl_Obj* indexPtr,
sl@0
  1892
						 Tcl_Obj* valuePtr  
sl@0
  1893
						 ));
sl@0
  1894
EXTERN Tcl_Obj *	TclLsetFlat _ANSI_ARGS_((Tcl_Interp* interp,
sl@0
  1895
						 Tcl_Obj* listPtr,
sl@0
  1896
						 int indexCount,
sl@0
  1897
						 Tcl_Obj *CONST indexArray[],
sl@0
  1898
						 Tcl_Obj* valuePtr
sl@0
  1899
						 ));
sl@0
  1900
EXTERN int              TclParseBackslash _ANSI_ARGS_((CONST char *src,
sl@0
  1901
                            int numBytes, int *readPtr, char *dst));
sl@0
  1902
EXTERN int		TclParseHex _ANSI_ARGS_((CONST char *src, int numBytes,
sl@0
  1903
                            Tcl_UniChar *resultPtr));
sl@0
  1904
EXTERN int		TclParseInteger _ANSI_ARGS_((CONST char *string,
sl@0
  1905
			    int numBytes));
sl@0
  1906
EXTERN int		TclParseWhiteSpace _ANSI_ARGS_((CONST char *src,
sl@0
  1907
			    int numBytes, Tcl_Parse *parsePtr, char *typePtr));
sl@0
  1908
#ifdef TCL_TIP280
sl@0
  1909
EXTERN int              TclWordKnownAtCompileTime _ANSI_ARGS_((Tcl_Token* token));
sl@0
  1910
#endif
sl@0
  1911
EXTERN int		TclpObjAccess _ANSI_ARGS_((Tcl_Obj *filename,
sl@0
  1912
			    int mode));
sl@0
  1913
EXTERN int              TclpObjLstat _ANSI_ARGS_((Tcl_Obj *pathPtr, 
sl@0
  1914
			    Tcl_StatBuf *buf));
sl@0
  1915
EXTERN int		TclpCheckStackSpace _ANSI_ARGS_((void));
sl@0
  1916
EXTERN Tcl_Obj*         TclpTempFileName _ANSI_ARGS_((void));
sl@0
  1917
EXTERN Tcl_Obj*         TclNewFSPathObj _ANSI_ARGS_((Tcl_Obj *dirPtr, 
sl@0
  1918
			    CONST char *addStrRep, int len));
sl@0
  1919
EXTERN int              TclpDeleteFile _ANSI_ARGS_((CONST char *path));
sl@0
  1920
EXTERN void		TclpFinalizeCondition _ANSI_ARGS_((
sl@0
  1921
			    Tcl_Condition *condPtr));
sl@0
  1922
EXTERN void		TclpFinalizeMutex _ANSI_ARGS_((Tcl_Mutex *mutexPtr));
sl@0
  1923
EXTERN void		TclpFinalizePipes _ANSI_ARGS_((void));
sl@0
  1924
EXTERN void		TclpFinalizeSockets _ANSI_ARGS_((void));
sl@0
  1925
EXTERN void		TclpFinalizeThreadData _ANSI_ARGS_((
sl@0
  1926
			    Tcl_ThreadDataKey *keyPtr));
sl@0
  1927
EXTERN void		TclpFinalizeThreadDataKey _ANSI_ARGS_((
sl@0
  1928
			    Tcl_ThreadDataKey *keyPtr));
sl@0
  1929
EXTERN char *		TclpFindExecutable _ANSI_ARGS_((
sl@0
  1930
			    CONST char *argv0));
sl@0
  1931
EXTERN int		TclpFindVariable _ANSI_ARGS_((CONST char *name,
sl@0
  1932
			    int *lengthPtr));
sl@0
  1933
EXTERN int		TclpInitLibraryPath _ANSI_ARGS_((CONST char *argv0));
sl@0
  1934
EXTERN void		TclpInitLock _ANSI_ARGS_((void));
sl@0
  1935
EXTERN void		TclpInitPlatform _ANSI_ARGS_((void));
sl@0
  1936
EXTERN void		TclpInitUnlock _ANSI_ARGS_((void));
sl@0
  1937
EXTERN int              TclpLoadFile _ANSI_ARGS_((Tcl_Interp *interp, 
sl@0
  1938
				Tcl_Obj *pathPtr,
sl@0
  1939
				CONST char *sym1, CONST char *sym2, 
sl@0
  1940
				Tcl_PackageInitProc **proc1Ptr,
sl@0
  1941
				Tcl_PackageInitProc **proc2Ptr, 
sl@0
  1942
				ClientData *clientDataPtr,
sl@0
  1943
				Tcl_FSUnloadFileProc **unloadProcPtr));
sl@0
  1944
EXTERN Tcl_Obj*		TclpObjListVolumes _ANSI_ARGS_((void));
sl@0
  1945
EXTERN void		TclpMasterLock _ANSI_ARGS_((void));
sl@0
  1946
EXTERN void		TclpMasterUnlock _ANSI_ARGS_((void));
sl@0
  1947
EXTERN int		TclpMatchFiles _ANSI_ARGS_((Tcl_Interp *interp,
sl@0
  1948
			    char *separators, Tcl_DString *dirPtr,
sl@0
  1949
			    char *pattern, char *tail));
sl@0
  1950
EXTERN int              TclpObjNormalizePath _ANSI_ARGS_((Tcl_Interp *interp, 
sl@0
  1951
			    Tcl_Obj *pathPtr, int nextCheckpoint));
sl@0
  1952
EXTERN int		TclpObjCreateDirectory _ANSI_ARGS_((Tcl_Obj *pathPtr));
sl@0
  1953
EXTERN void             TclpNativeJoinPath _ANSI_ARGS_((Tcl_Obj *prefix, 
sl@0
  1954
							char *joining));
sl@0
  1955
EXTERN Tcl_Obj*         TclpNativeSplitPath _ANSI_ARGS_((Tcl_Obj *pathPtr, 
sl@0
  1956
							 int *lenPtr));
sl@0
  1957
EXTERN Tcl_PathType     TclpGetNativePathType _ANSI_ARGS_((Tcl_Obj *pathObjPtr,
sl@0
  1958
			    int *driveNameLengthPtr, Tcl_Obj **driveNameRef));
sl@0
  1959
EXTERN int 		TclCrossFilesystemCopy _ANSI_ARGS_((Tcl_Interp *interp, 
sl@0
  1960
			    Tcl_Obj *source, Tcl_Obj *target));
sl@0
  1961
EXTERN int		TclpObjDeleteFile _ANSI_ARGS_((Tcl_Obj *pathPtr));
sl@0
  1962
EXTERN int		TclpObjCopyDirectory _ANSI_ARGS_((Tcl_Obj *srcPathPtr, 
sl@0
  1963
				Tcl_Obj *destPathPtr, Tcl_Obj **errorPtr));
sl@0
  1964
EXTERN int		TclpObjCopyFile _ANSI_ARGS_((Tcl_Obj *srcPathPtr, 
sl@0
  1965
				Tcl_Obj *destPathPtr));
sl@0
  1966
EXTERN int		TclpObjRemoveDirectory _ANSI_ARGS_((Tcl_Obj *pathPtr, 
sl@0
  1967
				int recursive, Tcl_Obj **errorPtr));
sl@0
  1968
EXTERN int		TclpObjRenameFile _ANSI_ARGS_((Tcl_Obj *srcPathPtr, 
sl@0
  1969
				Tcl_Obj *destPathPtr));
sl@0
  1970
EXTERN int		TclpMatchInDirectory _ANSI_ARGS_((Tcl_Interp *interp, 
sl@0
  1971
			        Tcl_Obj *resultPtr, Tcl_Obj *pathPtr, 
sl@0
  1972
				CONST char *pattern, Tcl_GlobTypeData *types));
sl@0
  1973
EXTERN Tcl_Obj*		TclpObjGetCwd _ANSI_ARGS_((Tcl_Interp *interp));
sl@0
  1974
EXTERN Tcl_FSDupInternalRepProc TclNativeDupInternalRep;
sl@0
  1975
EXTERN Tcl_Obj*		TclpObjLink _ANSI_ARGS_((Tcl_Obj *pathPtr, 
sl@0
  1976
				Tcl_Obj *toPtr, int linkType));
sl@0
  1977
EXTERN int		TclpObjChdir _ANSI_ARGS_((Tcl_Obj *pathPtr));
sl@0
  1978
EXTERN Tcl_Obj*         TclFileDirname _ANSI_ARGS_((Tcl_Interp *interp, 
sl@0
  1979
						    Tcl_Obj*pathPtr));
sl@0
  1980
EXTERN int		TclpObjStat _ANSI_ARGS_((Tcl_Obj *pathPtr, Tcl_StatBuf *buf));
sl@0
  1981
EXTERN Tcl_Channel	TclpOpenFileChannel _ANSI_ARGS_((Tcl_Interp *interp,
sl@0
  1982
			    Tcl_Obj *pathPtr, int mode,
sl@0
  1983
			    int permissions));
sl@0
  1984
EXTERN void		TclpPanic _ANSI_ARGS_(TCL_VARARGS(CONST char *,
sl@0
  1985
			    format));
sl@0
  1986
EXTERN char *		TclpReadlink _ANSI_ARGS_((CONST char *fileName,
sl@0
  1987
			    Tcl_DString *linkPtr));
sl@0
  1988
EXTERN void		TclpReleaseFile _ANSI_ARGS_((TclFile file));
sl@0
  1989
EXTERN void		TclpSetVariables _ANSI_ARGS_((Tcl_Interp *interp));
sl@0
  1990
EXTERN void		TclpUnloadFile _ANSI_ARGS_((Tcl_LoadHandle loadHandle));
sl@0
  1991
EXTERN VOID *		TclpThreadDataKeyGet _ANSI_ARGS_((
sl@0
  1992
			    Tcl_ThreadDataKey *keyPtr));
sl@0
  1993
EXTERN void		TclpThreadDataKeyInit _ANSI_ARGS_((
sl@0
  1994
			    Tcl_ThreadDataKey *keyPtr));
sl@0
  1995
EXTERN void		TclpThreadDataKeySet _ANSI_ARGS_((
sl@0
  1996
			    Tcl_ThreadDataKey *keyPtr, VOID *data));
sl@0
  1997
EXTERN int		TclpThreadCreate _ANSI_ARGS_((
sl@0
  1998
			    Tcl_ThreadId *idPtr,
sl@0
  1999
			    Tcl_ThreadCreateProc proc,
sl@0
  2000
			    ClientData clientData,
sl@0
  2001
			    int stackSize, int flags));
sl@0
  2002
EXTERN void		TclpThreadExit _ANSI_ARGS_((int status));
sl@0
  2003
EXTERN void		TclRememberCondition _ANSI_ARGS_((Tcl_Condition *mutex));
sl@0
  2004
EXTERN void		TclRememberDataKey _ANSI_ARGS_((Tcl_ThreadDataKey *mutex));
sl@0
  2005
EXTERN VOID             TclRememberJoinableThread _ANSI_ARGS_((Tcl_ThreadId id));
sl@0
  2006
EXTERN void		TclRememberMutex _ANSI_ARGS_((Tcl_Mutex *mutex));
sl@0
  2007
EXTERN VOID             TclSignalExitThread _ANSI_ARGS_((Tcl_ThreadId id,
sl@0
  2008
			     int result));
sl@0
  2009
EXTERN void		TclTransferResult _ANSI_ARGS_((Tcl_Interp *sourceInterp,
sl@0
  2010
			    int result, Tcl_Interp *targetInterp));
sl@0
  2011
EXTERN Tcl_Obj*         TclpNativeToNormalized 
sl@0
  2012
                            _ANSI_ARGS_((ClientData clientData));
sl@0
  2013
EXTERN Tcl_Obj*	        TclpFilesystemPathType
sl@0
  2014
					_ANSI_ARGS_((Tcl_Obj* pathObjPtr));
sl@0
  2015
EXTERN Tcl_PackageInitProc* TclpFindSymbol _ANSI_ARGS_((Tcl_Interp *interp,
sl@0
  2016
			    Tcl_LoadHandle loadHandle, CONST char *symbol));
sl@0
  2017
EXTERN int              TclpDlopen _ANSI_ARGS_((Tcl_Interp *interp, 
sl@0
  2018
			    Tcl_Obj *pathPtr, 
sl@0
  2019
	                    Tcl_LoadHandle *loadHandle, 
sl@0
  2020
		            Tcl_FSUnloadFileProc **unloadProcPtr));
sl@0
  2021
EXTERN int              TclpUtime _ANSI_ARGS_((Tcl_Obj *pathPtr,
sl@0
  2022
					       struct utimbuf *tval));
sl@0
  2023
sl@0
  2024
#ifdef TCL_LOAD_FROM_MEMORY
sl@0
  2025
EXTERN void*	        TclpLoadMemoryGetBuffer _ANSI_ARGS_((
sl@0
  2026
			    Tcl_Interp *interp, int size));
sl@0
  2027
EXTERN int	        TclpLoadMemory _ANSI_ARGS_((Tcl_Interp *interp, 
sl@0
  2028
			    void *buffer, int size, int codeSize, 
sl@0
  2029
			    Tcl_LoadHandle *loadHandle, 
sl@0
  2030
			    Tcl_FSUnloadFileProc **unloadProcPtr));
sl@0
  2031
#endif
sl@0
  2032
sl@0
  2033
#ifdef __SYMBIAN32__
sl@0
  2034
EXTERN int	SetupStdFile _ANSI_ARGS_((TclFile file, int type));
sl@0
  2035
#endif
sl@0
  2036
/*
sl@0
  2037
 *----------------------------------------------------------------
sl@0
  2038
 * Command procedures in the generic core:
sl@0
  2039
 *----------------------------------------------------------------
sl@0
  2040
 */
sl@0
  2041
sl@0
  2042
EXTERN int	Tcl_AfterObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2043
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2044
EXTERN int	Tcl_AppendObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2045
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2046
EXTERN int	Tcl_ArrayObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2047
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2048
EXTERN int	Tcl_BinaryObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2049
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2050
EXTERN int	Tcl_BreakObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2051
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2052
EXTERN int	Tcl_CaseObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2053
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2054
EXTERN int	Tcl_CatchObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2055
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2056
EXTERN int	Tcl_CdObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2057
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2058
EXTERN int	Tcl_ClockObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2059
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2060
EXTERN int	Tcl_CloseObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2061
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2062
EXTERN int	Tcl_ConcatObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2063
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2064
EXTERN int	Tcl_ContinueObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2065
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2066
EXTERN int	Tcl_EncodingObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2067
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2068
EXTERN int	Tcl_EofObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2069
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2070
EXTERN int	Tcl_ErrorObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2071
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2072
EXTERN int	Tcl_EvalObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2073
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2074
EXTERN int	Tcl_ExecObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2075
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2076
EXTERN int	Tcl_ExitObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2077
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2078
EXTERN int	Tcl_ExprObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2079
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2080
EXTERN int	Tcl_FblockedObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2081
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2082
EXTERN int	Tcl_FconfigureObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2083
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2084
EXTERN int	Tcl_FcopyObjCmd _ANSI_ARGS_((ClientData dummy,
sl@0
  2085
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2086
EXTERN int	Tcl_FileObjCmd _ANSI_ARGS_((ClientData dummy,
sl@0
  2087
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2088
EXTERN int	Tcl_FileEventObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2089
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2090
EXTERN int	Tcl_FlushObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2091
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2092
EXTERN int	Tcl_ForObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2093
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2094
EXTERN int	Tcl_ForeachObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2095
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2096
EXTERN int	Tcl_FormatObjCmd _ANSI_ARGS_((ClientData dummy,
sl@0
  2097
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2098
EXTERN int	Tcl_GetsObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2099
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2100
EXTERN int	Tcl_GlobalObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2101
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2102
EXTERN int	Tcl_GlobObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2103
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2104
EXTERN int	Tcl_IfObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2105
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2106
EXTERN int	Tcl_IncrObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2107
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2108
EXTERN int	Tcl_InfoObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2109
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2110
EXTERN int	Tcl_InterpObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2111
		    Tcl_Interp *interp, int argc, Tcl_Obj *CONST objv[]));
sl@0
  2112
EXTERN int	Tcl_JoinObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2113
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2114
EXTERN int	Tcl_LappendObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2115
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2116
EXTERN int	Tcl_LindexObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2117
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2118
EXTERN int	Tcl_LinsertObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2119
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2120
EXTERN int	Tcl_LlengthObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2121
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2122
EXTERN int	Tcl_ListObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2123
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2124
EXTERN int	Tcl_LoadObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2125
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2126
EXTERN int	Tcl_LrangeObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2127
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2128
EXTERN int	Tcl_LreplaceObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2129
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2130
EXTERN int	Tcl_LsearchObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2131
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2132
EXTERN int	Tcl_LsetObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2133
                    Tcl_Interp* interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2134
EXTERN int	Tcl_LsortObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2135
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2136
EXTERN int	Tcl_NamespaceObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2137
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2138
EXTERN int	Tcl_OpenObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2139
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2140
EXTERN int	Tcl_PackageObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2141
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2142
EXTERN int	Tcl_PidObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2143
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2144
EXTERN int	Tcl_PutsObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2145
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2146
EXTERN int	Tcl_PwdObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2147
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2148
EXTERN int	Tcl_ReadObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2149
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2150
EXTERN int	Tcl_RegexpObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2151
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2152
EXTERN int	Tcl_RegsubObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2153
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2154
EXTERN int	Tcl_RenameObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2155
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2156
EXTERN int	Tcl_ReturnObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2157
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2158
EXTERN int	Tcl_ScanObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2159
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2160
EXTERN int	Tcl_SeekObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2161
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2162
EXTERN int	Tcl_SetObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2163
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2164
EXTERN int	Tcl_SplitObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2165
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2166
EXTERN int	Tcl_SocketObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2167
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2168
EXTERN int	Tcl_SourceObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2169
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2170
EXTERN int	Tcl_StringObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2171
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2172
EXTERN int	Tcl_SubstObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2173
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2174
EXTERN int	Tcl_SwitchObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2175
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2176
EXTERN int	Tcl_TellObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2177
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2178
EXTERN int	Tcl_TimeObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2179
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2180
EXTERN int	Tcl_TraceObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2181
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2182
EXTERN int	Tcl_UnsetObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2183
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2184
EXTERN int	Tcl_UpdateObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2185
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2186
EXTERN int	Tcl_UplevelObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2187
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2188
EXTERN int	Tcl_UpvarObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2189
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2190
EXTERN int	Tcl_VariableObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2191
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2192
EXTERN int	Tcl_VwaitObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2193
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2194
EXTERN int	Tcl_WhileObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2195
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2196
sl@0
  2197
/*
sl@0
  2198
 *----------------------------------------------------------------
sl@0
  2199
 * Command procedures found only in the Mac version of the core:
sl@0
  2200
 *----------------------------------------------------------------
sl@0
  2201
 */
sl@0
  2202
sl@0
  2203
#ifdef MAC_TCL
sl@0
  2204
EXTERN int	Tcl_EchoCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2205
		    Tcl_Interp *interp, int argc, CONST84 char **argv));
sl@0
  2206
EXTERN int	Tcl_LsObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2207
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2208
EXTERN int	Tcl_BeepObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2209
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2210
EXTERN int	Tcl_MacSourceObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2211
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2212
EXTERN int	Tcl_ResourceObjCmd _ANSI_ARGS_((ClientData clientData,
sl@0
  2213
		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
sl@0
  2214
#endif
sl@0
  2215
sl@0
  2216
/*
sl@0
  2217
 *----------------------------------------------------------------
sl@0
  2218
 * Compilation procedures for commands in the generic core:
sl@0
  2219
 *----------------------------------------------------------------
sl@0
  2220
 */
sl@0
  2221
sl@0
  2222
EXTERN int	TclCompileAppendCmd _ANSI_ARGS_((Tcl_Interp *interp,
sl@0
  2223
		    Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
sl@0
  2224
EXTERN int	TclCompileBreakCmd _ANSI_ARGS_((Tcl_Interp *interp,
sl@0
  2225
		    Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
sl@0
  2226
EXTERN int	TclCompileCatchCmd _ANSI_ARGS_((Tcl_Interp *interp,
sl@0
  2227
		    Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
sl@0
  2228
EXTERN int	TclCompileContinueCmd _ANSI_ARGS_((Tcl_Interp *interp,
sl@0
  2229
		    Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
sl@0
  2230
EXTERN int	TclCompileExprCmd _ANSI_ARGS_((Tcl_Interp *interp,
sl@0
  2231
		    Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
sl@0
  2232
EXTERN int	TclCompileForCmd _ANSI_ARGS_((Tcl_Interp *interp,
sl@0
  2233
		    Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
sl@0
  2234
EXTERN int	TclCompileForeachCmd _ANSI_ARGS_((Tcl_Interp *interp,
sl@0
  2235
		    Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
sl@0
  2236
EXTERN int	TclCompileIfCmd _ANSI_ARGS_((Tcl_Interp *interp,
sl@0
  2237
		    Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
sl@0
  2238
EXTERN int	TclCompileIncrCmd _ANSI_ARGS_((Tcl_Interp *interp,
sl@0
  2239
		    Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
sl@0
  2240
EXTERN int	TclCompileLappendCmd _ANSI_ARGS_((Tcl_Interp *interp,
sl@0
  2241
		    Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
sl@0
  2242
EXTERN int	TclCompileLindexCmd _ANSI_ARGS_((Tcl_Interp *interp,
sl@0
  2243
		    Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
sl@0
  2244
EXTERN int	TclCompileListCmd _ANSI_ARGS_((Tcl_Interp *interp,
sl@0
  2245
		    Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
sl@0
  2246
EXTERN int	TclCompileLlengthCmd _ANSI_ARGS_((Tcl_Interp *interp,
sl@0
  2247
		    Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
sl@0
  2248
EXTERN int	TclCompileLsetCmd _ANSI_ARGS_((Tcl_Interp* interp,
sl@0
  2249
		    Tcl_Parse* parsePtr, struct CompileEnv* envPtr));
sl@0
  2250
EXTERN int	TclCompileRegexpCmd _ANSI_ARGS_((Tcl_Interp* interp,
sl@0
  2251
		    Tcl_Parse* parsePtr, struct CompileEnv* envPtr));
sl@0
  2252
EXTERN int	TclCompileReturnCmd _ANSI_ARGS_((Tcl_Interp *interp,
sl@0
  2253
		    Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
sl@0
  2254
EXTERN int	TclCompileSetCmd _ANSI_ARGS_((Tcl_Interp *interp,
sl@0
  2255
		    Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
sl@0
  2256
EXTERN int	TclCompileStringCmd _ANSI_ARGS_((Tcl_Interp *interp,
sl@0
  2257
		    Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
sl@0
  2258
EXTERN int	TclCompileWhileCmd _ANSI_ARGS_((Tcl_Interp *interp,
sl@0
  2259
		    Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
sl@0
  2260
sl@0
  2261
/*
sl@0
  2262
 * Functions defined in generic/tclVar.c and currenttly exported only 
sl@0
  2263
 * for use by the bytecode compiler and engine. Some of these could later 
sl@0
  2264
 * be placed in the public interface.
sl@0
  2265
 */
sl@0
  2266
sl@0
  2267
EXTERN Var *	TclLookupArrayElement _ANSI_ARGS_((Tcl_Interp *interp,
sl@0
  2268
		    CONST char *arrayName, CONST char *elName, CONST int flags,
sl@0
  2269
		    CONST char *msg, CONST int createPart1,
sl@0
  2270
		    CONST int createPart2, Var *arrayPtr));	
sl@0
  2271
EXTERN Var *    TclObjLookupVar _ANSI_ARGS_((Tcl_Interp *interp,
sl@0
  2272
		    Tcl_Obj *part1Ptr, CONST char *part2, int flags,
sl@0
  2273
		    CONST char *msg, CONST int createPart1,
sl@0
  2274
		    CONST int createPart2, Var **arrayPtrPtr));
sl@0
  2275
EXTERN Tcl_Obj *TclPtrGetVar _ANSI_ARGS_((Tcl_Interp *interp, Var *varPtr,
sl@0
  2276
		    Var *arrayPtr, CONST char *part1, CONST char *part2,
sl@0
  2277
		    CONST int flags));
sl@0
  2278
EXTERN Tcl_Obj *TclPtrSetVar _ANSI_ARGS_((Tcl_Interp *interp, Var *varPtr,
sl@0
  2279
		    Var *arrayPtr, CONST char *part1, CONST char *part2,
sl@0
  2280
		    Tcl_Obj *newValuePtr, CONST int flags));
sl@0
  2281
EXTERN Tcl_Obj *TclPtrIncrVar _ANSI_ARGS_((Tcl_Interp *interp, Var *varPtr,
sl@0
  2282
		    Var *arrayPtr, CONST char *part1, CONST char *part2,
sl@0
  2283
		    CONST long i, CONST int flags));
sl@0
  2284
sl@0
  2285
/*
sl@0
  2286
 *----------------------------------------------------------------
sl@0
  2287
 * Macros used by the Tcl core to create and release Tcl objects.
sl@0
  2288
 * TclNewObj(objPtr) creates a new object denoting an empty string.
sl@0
  2289
 * TclDecrRefCount(objPtr) decrements the object's reference count,
sl@0
  2290
 * and frees the object if its reference count is zero.
sl@0
  2291
 * These macros are inline versions of Tcl_NewObj() and
sl@0
  2292
 * Tcl_DecrRefCount(). Notice that the names differ in not having
sl@0
  2293
 * a "_" after the "Tcl". Notice also that these macros reference
sl@0
  2294
 * their argument more than once, so you should avoid calling them
sl@0
  2295
 * with an expression that is expensive to compute or has
sl@0
  2296
 * side effects. The ANSI C "prototypes" for these macros are:
sl@0
  2297
 *
sl@0
  2298
 * EXTERN void	TclNewObj _ANSI_ARGS_((Tcl_Obj *objPtr));
sl@0
  2299
 * EXTERN void	TclDecrRefCount _ANSI_ARGS_((Tcl_Obj *objPtr));
sl@0
  2300
 *
sl@0
  2301
 * These macros are defined in terms of two macros that depend on 
sl@0
  2302
 * memory allocator in use: TclAllocObjStorage, TclFreeObjStorage.
sl@0
  2303
 * They are defined below.
sl@0
  2304
 *----------------------------------------------------------------
sl@0
  2305
 */
sl@0
  2306
sl@0
  2307
#ifdef TCL_COMPILE_STATS
sl@0
  2308
#  define TclIncrObjsAllocated() \
sl@0
  2309
    tclObjsAlloced++
sl@0
  2310
#  define TclIncrObjsFreed() \
sl@0
  2311
    tclObjsFreed++
sl@0
  2312
#else
sl@0
  2313
#  define TclIncrObjsAllocated()
sl@0
  2314
#  define TclIncrObjsFreed()
sl@0
  2315
#endif /* TCL_COMPILE_STATS */
sl@0
  2316
sl@0
  2317
#define TclNewObj(objPtr) \
sl@0
  2318
    TclAllocObjStorage(objPtr); \
sl@0
  2319
    TclIncrObjsAllocated(); \
sl@0
  2320
    (objPtr)->refCount = 0; \
sl@0
  2321
    (objPtr)->bytes    = tclEmptyStringRep; \
sl@0
  2322
    (objPtr)->length   = 0; \
sl@0
  2323
    (objPtr)->typePtr  = NULL
sl@0
  2324
sl@0
  2325
sl@0
  2326
#ifdef TCL_MEM_DEBUG
sl@0
  2327
#   define TclDecrRefCount(objPtr) \
sl@0
  2328
	Tcl_DbDecrRefCount(objPtr, __FILE__, __LINE__)
sl@0
  2329
#else
sl@0
  2330
#   define TclDecrRefCount(objPtr) \
sl@0
  2331
    if (--(objPtr)->refCount <= 0) { \
sl@0
  2332
	if (((objPtr)->typePtr != NULL) \
sl@0
  2333
		&& ((objPtr)->typePtr->freeIntRepProc != NULL)) { \
sl@0
  2334
	    (objPtr)->typePtr->freeIntRepProc(objPtr); \
sl@0
  2335
	} \
sl@0
  2336
	if (((objPtr)->bytes != NULL) \
sl@0
  2337
		&& ((objPtr)->bytes != tclEmptyStringRep)) { \
sl@0
  2338
	    ckfree((char *) (objPtr)->bytes); \
sl@0
  2339
	} \
sl@0
  2340
        TclFreeObjStorage(objPtr); \
sl@0
  2341
	TclIncrObjsFreed(); \
sl@0
  2342
    }
sl@0
  2343
#endif
sl@0
  2344
sl@0
  2345
#ifdef TCL_MEM_DEBUG
sl@0
  2346
#  define TclAllocObjStorage(objPtr) \
sl@0
  2347
       (objPtr) = (Tcl_Obj *) \
sl@0
  2348
           Tcl_DbCkalloc(sizeof(Tcl_Obj), __FILE__, __LINE__)
sl@0
  2349
sl@0
  2350
#  define TclFreeObjStorage(objPtr) \
sl@0
  2351
       if ((objPtr)->refCount < -1) { \
sl@0
  2352
           panic("Reference count for %lx was negative: %s line %d", \
sl@0
  2353
	           (objPtr), __FILE__, __LINE__); \
sl@0
  2354
       } \
sl@0
  2355
       ckfree((char *) (objPtr))
sl@0
  2356
     
sl@0
  2357
#  define TclDbNewObj(objPtr, file, line) \
sl@0
  2358
       (objPtr) = (Tcl_Obj *) Tcl_DbCkalloc(sizeof(Tcl_Obj), (file), (line)); \
sl@0
  2359
       (objPtr)->refCount = 0; \
sl@0
  2360
       (objPtr)->bytes    = tclEmptyStringRep; \
sl@0
  2361
       (objPtr)->length   = 0; \
sl@0
  2362
       (objPtr)->typePtr  = NULL; \
sl@0
  2363
       TclIncrObjsAllocated()
sl@0
  2364
     
sl@0
  2365
#elif defined(PURIFY)
sl@0
  2366
sl@0
  2367
/*
sl@0
  2368
 * The PURIFY mode is like the regular mode, but instead of doing block
sl@0
  2369
 * Tcl_Obj allocation and keeping a freed list for efficiency, it always
sl@0
  2370
 * allocates and frees a single Tcl_Obj so that tools like Purify can
sl@0
  2371
 * better track memory leaks
sl@0
  2372
 */
sl@0
  2373
sl@0
  2374
#  define TclAllocObjStorage(objPtr) \
sl@0
  2375
       (objPtr) = (Tcl_Obj *) Tcl_Ckalloc(sizeof(Tcl_Obj))
sl@0
  2376
sl@0
  2377
#  define TclFreeObjStorage(objPtr) \
sl@0
  2378
       ckfree((char *) (objPtr))
sl@0
  2379
sl@0
  2380
#elif defined(TCL_THREADS) && defined(USE_THREAD_ALLOC)
sl@0
  2381
sl@0
  2382
/*
sl@0
  2383
 * The TCL_THREADS mode is like the regular mode but allocates Tcl_Obj's
sl@0
  2384
 * from per-thread caches.
sl@0
  2385
 */
sl@0
  2386
sl@0
  2387
EXTERN Tcl_Obj *TclThreadAllocObj _ANSI_ARGS_((void));
sl@0
  2388
EXTERN void TclThreadFreeObj _ANSI_ARGS_((Tcl_Obj *));
sl@0
  2389
EXTERN void TclFreeAllocCache _ANSI_ARGS_((void *));
sl@0
  2390
EXTERN void TclpFreeAllocMutex _ANSI_ARGS_((Tcl_Mutex* mutex));
sl@0
  2391
EXTERN void TclpFreeAllocCache _ANSI_ARGS_((void *));
sl@0
  2392
sl@0
  2393
sl@0
  2394
#  define TclAllocObjStorage(objPtr) \
sl@0
  2395
       (objPtr) = TclThreadAllocObj()
sl@0
  2396
sl@0
  2397
#  define TclFreeObjStorage(objPtr) \
sl@0
  2398
       TclThreadFreeObj((objPtr))
sl@0
  2399
sl@0
  2400
#else /* not TCL_MEM_DEBUG */
sl@0
  2401
sl@0
  2402
#ifdef TCL_THREADS
sl@0
  2403
/* declared in tclObj.c */
sl@0
  2404
extern Tcl_Mutex tclObjMutex;
sl@0
  2405
#endif
sl@0
  2406
sl@0
  2407
#  define TclAllocObjStorage(objPtr) \
sl@0
  2408
       Tcl_MutexLock(&tclObjMutex); \
sl@0
  2409
       if (tclFreeObjList == NULL) { \
sl@0
  2410
	   TclAllocateFreeObjects(); \
sl@0
  2411
       } \
sl@0
  2412
       (objPtr) = tclFreeObjList; \
sl@0
  2413
       tclFreeObjList = (Tcl_Obj *) \
sl@0
  2414
	   tclFreeObjList->internalRep.otherValuePtr; \
sl@0
  2415
       Tcl_MutexUnlock(&tclObjMutex)
sl@0
  2416
sl@0
  2417
#  define TclFreeObjStorage(objPtr) \
sl@0
  2418
       Tcl_MutexLock(&tclObjMutex); \
sl@0
  2419
       (objPtr)->internalRep.otherValuePtr = (VOID *) tclFreeObjList; \
sl@0
  2420
       tclFreeObjList = (objPtr); \
sl@0
  2421
       Tcl_MutexUnlock(&tclObjMutex)
sl@0
  2422
sl@0
  2423
#endif /* TCL_MEM_DEBUG */
sl@0
  2424
sl@0
  2425
/*
sl@0
  2426
 *----------------------------------------------------------------
sl@0
  2427
 * Macro used by the Tcl core to set a Tcl_Obj's string representation
sl@0
  2428
 * to a copy of the "len" bytes starting at "bytePtr". This code
sl@0
  2429
 * works even if the byte array contains NULLs as long as the length
sl@0
  2430
 * is correct. Because "len" is referenced multiple times, it should
sl@0
  2431
 * be as simple an expression as possible. The ANSI C "prototype" for
sl@0
  2432
 * this macro is:
sl@0
  2433
 *
sl@0
  2434
 * EXTERN void	TclInitStringRep _ANSI_ARGS_((Tcl_Obj *objPtr,
sl@0
  2435
 *		    char *bytePtr, int len));
sl@0
  2436
 *----------------------------------------------------------------
sl@0
  2437
 */
sl@0
  2438
sl@0
  2439
#define TclInitStringRep(objPtr, bytePtr, len) \
sl@0
  2440
    if ((len) == 0) { \
sl@0
  2441
	(objPtr)->bytes	 = tclEmptyStringRep; \
sl@0
  2442
	(objPtr)->length = 0; \
sl@0
  2443
    } else { \
sl@0
  2444
	(objPtr)->bytes = (char *) ckalloc((unsigned) ((len) + 1)); \
sl@0
  2445
	memcpy((VOID *) (objPtr)->bytes, (VOID *) (bytePtr), \
sl@0
  2446
		(unsigned) (len)); \
sl@0
  2447
	(objPtr)->bytes[len] = '\0'; \
sl@0
  2448
	(objPtr)->length = (len); \
sl@0
  2449
    }
sl@0
  2450
sl@0
  2451
/*
sl@0
  2452
 *----------------------------------------------------------------
sl@0
  2453
 * Macro used by the Tcl core to get the string representation's
sl@0
  2454
 * byte array pointer from a Tcl_Obj. This is an inline version
sl@0
  2455
 * of Tcl_GetString(). The macro's expression result is the string
sl@0
  2456
 * rep's byte pointer which might be NULL. The bytes referenced by 
sl@0
  2457
 * this pointer must not be modified by the caller.
sl@0
  2458
 * The ANSI C "prototype" for this macro is:
sl@0
  2459
 *
sl@0
  2460
 * EXTERN char *  TclGetString _ANSI_ARGS_((Tcl_Obj *objPtr));
sl@0
  2461
 *----------------------------------------------------------------
sl@0
  2462
 */
sl@0
  2463
sl@0
  2464
#define TclGetString(objPtr) \
sl@0
  2465
    ((objPtr)->bytes? (objPtr)->bytes : Tcl_GetString((objPtr)))
sl@0
  2466
sl@0
  2467
/*
sl@0
  2468
 *----------------------------------------------------------------
sl@0
  2469
 * Macro used by the Tcl core to get a Tcl_WideInt value out of
sl@0
  2470
 * a Tcl_Obj of the "wideInt" type.  Different implementation on
sl@0
  2471
 * different platforms depending whether TCL_WIDE_INT_IS_LONG.
sl@0
  2472
 *----------------------------------------------------------------
sl@0
  2473
 */
sl@0
  2474
sl@0
  2475
#ifdef TCL_WIDE_INT_IS_LONG
sl@0
  2476
#    define TclGetWide(resultVar, objPtr) \
sl@0
  2477
	(resultVar) = (objPtr)->internalRep.longValue
sl@0
  2478
#    define TclGetLongFromWide(resultVar, objPtr) \
sl@0
  2479
	(resultVar) = (objPtr)->internalRep.longValue
sl@0
  2480
#else
sl@0
  2481
#    define TclGetWide(resultVar, objPtr) \
sl@0
  2482
	(resultVar) = (objPtr)->internalRep.wideValue
sl@0
  2483
#    define TclGetLongFromWide(resultVar, objPtr) \
sl@0
  2484
	(resultVar) = Tcl_WideAsLong((objPtr)->internalRep.wideValue)
sl@0
  2485
#endif
sl@0
  2486
sl@0
  2487
/*
sl@0
  2488
 *----------------------------------------------------------------
sl@0
  2489
 * Macro used by the Tcl core get a unicode char from a utf string.
sl@0
  2490
 * It checks to see if we have a one-byte utf char before calling
sl@0
  2491
 * the real Tcl_UtfToUniChar, as this will save a lot of time for
sl@0
  2492
 * primarily ascii string handling. The macro's expression result
sl@0
  2493
 * is 1 for the 1-byte case or the result of Tcl_UtfToUniChar.
sl@0
  2494
 * The ANSI C "prototype" for this macro is:
sl@0
  2495
 *
sl@0
  2496
 * EXTERN int TclUtfToUniChar _ANSI_ARGS_((CONST char *string,
sl@0
  2497
 *					   Tcl_UniChar *ch));
sl@0
  2498
 *----------------------------------------------------------------
sl@0
  2499
 */
sl@0
  2500
sl@0
  2501
#define TclUtfToUniChar(str, chPtr) \
sl@0
  2502
	((((unsigned char) *(str)) < 0xC0) ? \
sl@0
  2503
	    ((*(chPtr) = (Tcl_UniChar) *(str)), 1) \
sl@0
  2504
	    : Tcl_UtfToUniChar(str, chPtr))
sl@0
  2505
sl@0
  2506
/*
sl@0
  2507
 *----------------------------------------------------------------
sl@0
  2508
 * Macro used by the Tcl core to compare Unicode strings.  On
sl@0
  2509
 * big-endian systems we can use the more efficient memcmp, but
sl@0
  2510
 * this would not be lexically correct on little-endian systems.
sl@0
  2511
 * The ANSI C "prototype" for this macro is:
sl@0
  2512
 *
sl@0
  2513
 * EXTERN int TclUniCharNcmp _ANSI_ARGS_((CONST Tcl_UniChar *cs,
sl@0
  2514
 *         CONST Tcl_UniChar *ct, unsigned long n));
sl@0
  2515
 *----------------------------------------------------------------
sl@0
  2516
 */
sl@0
  2517
#ifdef WORDS_BIGENDIAN
sl@0
  2518
#   define TclUniCharNcmp(cs,ct,n) memcmp((cs),(ct),(n)*sizeof(Tcl_UniChar))
sl@0
  2519
#else /* !WORDS_BIGENDIAN */
sl@0
  2520
#   define TclUniCharNcmp Tcl_UniCharNcmp
sl@0
  2521
#endif /* WORDS_BIGENDIAN */
sl@0
  2522
sl@0
  2523
#ifdef __SYMBIAN32__  
sl@0
  2524
/*
sl@0
  2525
 * Struct to keep records of synchronization objects (used in tclThread.c)
sl@0
  2526
 */
sl@0
  2527
typedef struct SyncObjRecord {
sl@0
  2528
	int num;		/* Number of objects remembered */
sl@0
  2529
	int max;		/* Max size of the array */
sl@0
  2530
	char **list;	/* List of pointers */
sl@0
  2531
} SyncObjRecord;
sl@0
  2532
#endif
sl@0
  2533
sl@0
  2534
#include "tclIntDecls.h"
sl@0
  2535
sl@0
  2536
# undef TCL_STORAGE_CLASS
sl@0
  2537
# define TCL_STORAGE_CLASS DLLIMPORT
sl@0
  2538
sl@0
  2539
#endif /* _TCLINT */
sl@0
  2540