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