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