1 |
/* $Header$ */
|
2 |
/*
|
3 |
* tcl.h --
|
4 |
*
|
5 |
* This header file describes the externally-visible facilities
|
6 |
* of the Tcl interpreter.
|
7 |
*
|
8 |
* Copyright (c) 1987-1994 The Regents of the University of California.
|
9 |
* Copyright (c) 1993-1996 Lucent Technologies.
|
10 |
* Copyright (c) 1994-1998 Sun Microsystems, Inc.
|
11 |
* Copyright (c) 1998-2000 by Scriptics Corporation.
|
12 |
*
|
13 |
* See the file "license.terms" for information on usage and redistribution
|
14 |
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
15 |
*
|
16 |
* RCS: @(#) $Id: tcl.h,v 1.1.1.1 2001/06/13 04:32:55 dtashley Exp $
|
17 |
*/
|
18 |
|
19 |
#ifndef _TCL
|
20 |
#define _TCL
|
21 |
|
22 |
/*
|
23 |
* For C++ compilers, use extern "C"
|
24 |
*/
|
25 |
|
26 |
#ifdef __cplusplus
|
27 |
extern "C" {
|
28 |
#endif
|
29 |
|
30 |
/*
|
31 |
* The following defines are used to indicate the various release levels.
|
32 |
*/
|
33 |
|
34 |
#define TCL_ALPHA_RELEASE 0
|
35 |
#define TCL_BETA_RELEASE 1
|
36 |
#define TCL_FINAL_RELEASE 2
|
37 |
|
38 |
/*
|
39 |
* When version numbers change here, must also go into the following files
|
40 |
* and update the version numbers:
|
41 |
*
|
42 |
* library/init.tcl (only if Major.minor changes, not patchlevel) 1 LOC
|
43 |
* unix/configure.in (2 LOC Major, 2 LOC minor, 1 LOC patch)
|
44 |
* win/configure.in (as above)
|
45 |
* win/tcl.m4 (not patchlevel)
|
46 |
* win/makefile.vc (not patchlevel) 2 LOC
|
47 |
* win/pkgIndex.tcl (not patchlevel, for tclregNN.dll)
|
48 |
* README (sections 0 and 2)
|
49 |
* mac/README (2 LOC, not patchlevel)
|
50 |
* win/README.binary (sections 0-4)
|
51 |
* win/README (not patchlevel) (sections 0 and 2)
|
52 |
* unix/README (not patchlevel) (part (h))
|
53 |
* unix/tcl.spec (2 LOC Major/Minor, 1 LOC patch)
|
54 |
* tests/basic.test (not patchlevel) (version checks)
|
55 |
* tools/tcl.hpj.in (not patchlevel, for windows installer)
|
56 |
* tools/tcl.wse.in (for windows installer)
|
57 |
* tools/tclSplash.bmp (not patchlevel)
|
58 |
*/
|
59 |
|
60 |
#define TCL_MAJOR_VERSION 8
|
61 |
#define TCL_MINOR_VERSION 3
|
62 |
#define TCL_RELEASE_LEVEL TCL_FINAL_RELEASE
|
63 |
#define TCL_RELEASE_SERIAL 1
|
64 |
|
65 |
#define TCL_VERSION "8.3"
|
66 |
#define TCL_PATCH_LEVEL "8.3.1"
|
67 |
|
68 |
/*
|
69 |
* The following definitions set up the proper options for Windows
|
70 |
* compilers. We use this method because there is no autoconf equivalent.
|
71 |
*/
|
72 |
|
73 |
#ifndef __WIN32__
|
74 |
# if defined(_WIN32) || defined(WIN32)
|
75 |
# define __WIN32__
|
76 |
# endif
|
77 |
#endif
|
78 |
|
79 |
#ifdef __WIN32__
|
80 |
# ifndef STRICT
|
81 |
# define STRICT
|
82 |
# endif
|
83 |
# ifndef USE_PROTOTYPE
|
84 |
# define USE_PROTOTYPE 1
|
85 |
# endif
|
86 |
# ifndef HAS_STDARG
|
87 |
# define HAS_STDARG 1
|
88 |
# endif
|
89 |
# ifndef USE_PROTOTYPE
|
90 |
# define USE_PROTOTYPE 1
|
91 |
# endif
|
92 |
|
93 |
/*
|
94 |
* Under Windows we need to call Tcl_Alloc in all cases to avoid competing
|
95 |
* C run-time library issues.
|
96 |
*/
|
97 |
|
98 |
# ifndef USE_TCLALLOC
|
99 |
# define USE_TCLALLOC 0
|
100 |
/* Changed to 0 so could swap in new alloc module, DTA,
|
101 |
** 07/06/00.
|
102 |
*/
|
103 |
# endif
|
104 |
#endif /* __WIN32__ */
|
105 |
|
106 |
/*
|
107 |
* The following definitions set up the proper options for Macintosh
|
108 |
* compilers. We use this method because there is no autoconf equivalent.
|
109 |
*/
|
110 |
|
111 |
#ifdef MAC_TCL
|
112 |
# ifndef HAS_STDARG
|
113 |
# define HAS_STDARG 1
|
114 |
# endif
|
115 |
# ifndef USE_TCLALLOC
|
116 |
# define USE_TCLALLOC 1
|
117 |
# endif
|
118 |
# ifndef NO_STRERROR
|
119 |
# define NO_STRERROR 1
|
120 |
# endif
|
121 |
# define INLINE
|
122 |
#endif
|
123 |
|
124 |
/*
|
125 |
* Utility macros: STRINGIFY takes an argument and wraps it in "" (double
|
126 |
* quotation marks), JOIN joins two arguments.
|
127 |
*/
|
128 |
|
129 |
#define VERBATIM(x) x
|
130 |
#ifdef _MSC_VER
|
131 |
# define STRINGIFY(x) STRINGIFY1(x)
|
132 |
# define STRINGIFY1(x) #x
|
133 |
# define JOIN(a,b) JOIN1(a,b)
|
134 |
# define JOIN1(a,b) a##b
|
135 |
#else
|
136 |
# ifdef RESOURCE_INCLUDED
|
137 |
# define STRINGIFY(x) STRINGIFY1(x)
|
138 |
# define STRINGIFY1(x) #x
|
139 |
# define JOIN(a,b) JOIN1(a,b)
|
140 |
# define JOIN1(a,b) a##b
|
141 |
# else
|
142 |
# ifdef __STDC__
|
143 |
# define STRINGIFY(x) #x
|
144 |
# define JOIN(a,b) a##b
|
145 |
# else
|
146 |
# define STRINGIFY(x) "x"
|
147 |
# define JOIN(a,b) VERBATIM(a)VERBATIM(b)
|
148 |
# endif
|
149 |
# endif
|
150 |
#endif
|
151 |
|
152 |
/*
|
153 |
* Special macro to define mutexes, that doesn't do anything
|
154 |
* if we are not using threads.
|
155 |
*/
|
156 |
|
157 |
#ifdef TCL_THREADS
|
158 |
#define TCL_DECLARE_MUTEX(name) static Tcl_Mutex name;
|
159 |
#else
|
160 |
#define TCL_DECLARE_MUTEX(name)
|
161 |
#endif
|
162 |
|
163 |
/*
|
164 |
* Macros that eliminate the overhead of the thread synchronization
|
165 |
* functions when compiling without thread support.
|
166 |
*/
|
167 |
|
168 |
#ifndef TCL_THREADS
|
169 |
#define Tcl_MutexLock(mutexPtr)
|
170 |
#define Tcl_MutexUnlock(mutexPtr)
|
171 |
#define Tcl_MutexFinalize(mutexPtr)
|
172 |
#define Tcl_ConditionNotify(condPtr)
|
173 |
#define Tcl_ConditionWait(condPtr, mutexPtr, timePtr)
|
174 |
#define Tcl_ConditionFinalize(condPtr)
|
175 |
#endif /* TCL_THREADS */
|
176 |
|
177 |
/*
|
178 |
* A special definition used to allow this header file to be included
|
179 |
* in resource files so that they can get obtain version information from
|
180 |
* this file. Resource compilers don't like all the C stuff, like typedefs
|
181 |
* and procedure declarations, that occur below.
|
182 |
*/
|
183 |
|
184 |
#ifndef RESOURCE_INCLUDED
|
185 |
|
186 |
#ifndef BUFSIZ
|
187 |
#include <stdio.h>
|
188 |
#endif
|
189 |
|
190 |
/*
|
191 |
* Definitions that allow Tcl functions with variable numbers of
|
192 |
* arguments to be used with either varargs.h or stdarg.h. TCL_VARARGS
|
193 |
* is used in procedure prototypes. TCL_VARARGS_DEF is used to declare
|
194 |
* the arguments in a function definiton: it takes the type and name of
|
195 |
* the first argument and supplies the appropriate argument declaration
|
196 |
* string for use in the function definition. TCL_VARARGS_START
|
197 |
* initializes the va_list data structure and returns the first argument.
|
198 |
*/
|
199 |
|
200 |
#if defined(__STDC__) || defined(HAS_STDARG)
|
201 |
# include <stdarg.h>
|
202 |
|
203 |
# define TCL_VARARGS(type, name) (type name, ...)
|
204 |
# define TCL_VARARGS_DEF(type, name) (type name, ...)
|
205 |
# define TCL_VARARGS_START(type, name, list) (va_start(list, name), name)
|
206 |
#else
|
207 |
# include <varargs.h>
|
208 |
|
209 |
# ifdef __cplusplus
|
210 |
# define TCL_VARARGS(type, name) (type name, ...)
|
211 |
# define TCL_VARARGS_DEF(type, name) (type va_alist, ...)
|
212 |
# else
|
213 |
# define TCL_VARARGS(type, name) ()
|
214 |
# define TCL_VARARGS_DEF(type, name) (va_alist)
|
215 |
# endif
|
216 |
# define TCL_VARARGS_START(type, name, list) \
|
217 |
(va_start(list), va_arg(list, type))
|
218 |
#endif
|
219 |
|
220 |
/*
|
221 |
* Macros used to declare a function to be exported by a DLL.
|
222 |
* Used by Windows, maps to no-op declarations on non-Windows systems.
|
223 |
* The default build on windows is for a DLL, which causes the DLLIMPORT
|
224 |
* and DLLEXPORT macros to be nonempty. To build a static library, the
|
225 |
* macro STATIC_BUILD should be defined.
|
226 |
*/
|
227 |
|
228 |
#ifdef STATIC_BUILD
|
229 |
# define DLLIMPORT
|
230 |
# define DLLEXPORT
|
231 |
#else
|
232 |
# if defined(__WIN32__) && (defined(_MSC_VER) || (defined(__GNUC__) && defined(__declspec)))
|
233 |
# define DLLIMPORT __declspec(dllimport)
|
234 |
# define DLLEXPORT __declspec(dllexport)
|
235 |
# else
|
236 |
# define DLLIMPORT
|
237 |
# define DLLEXPORT
|
238 |
# endif
|
239 |
#endif
|
240 |
|
241 |
/*
|
242 |
* These macros are used to control whether functions are being declared for
|
243 |
* import or export. If a function is being declared while it is being built
|
244 |
* to be included in a shared library, then it should have the DLLEXPORT
|
245 |
* storage class. If is being declared for use by a module that is going to
|
246 |
* link against the shared library, then it should have the DLLIMPORT storage
|
247 |
* class. If the symbol is beind declared for a static build or for use from a
|
248 |
* stub library, then the storage class should be empty.
|
249 |
*
|
250 |
* The convention is that a macro called BUILD_xxxx, where xxxx is the
|
251 |
* name of a library we are building, is set on the compile line for sources
|
252 |
* that are to be placed in the library. When this macro is set, the
|
253 |
* storage class will be set to DLLEXPORT. At the end of the header file, the
|
254 |
* storage class will be reset to DLLIMPORt.
|
255 |
*/
|
256 |
|
257 |
#undef TCL_STORAGE_CLASS
|
258 |
#ifdef BUILD_tcl
|
259 |
# define TCL_STORAGE_CLASS DLLEXPORT
|
260 |
#else
|
261 |
# ifdef USE_TCL_STUBS
|
262 |
# define TCL_STORAGE_CLASS
|
263 |
# else
|
264 |
# define TCL_STORAGE_CLASS DLLIMPORT
|
265 |
# endif
|
266 |
#endif
|
267 |
|
268 |
/*
|
269 |
* Definitions that allow this header file to be used either with or
|
270 |
* without ANSI C features like function prototypes.
|
271 |
*/
|
272 |
|
273 |
#undef _ANSI_ARGS_
|
274 |
#undef CONST
|
275 |
#ifndef INLINE
|
276 |
# define INLINE
|
277 |
#endif
|
278 |
|
279 |
#if ((defined(__STDC__) || defined(SABER)) && !defined(NO_PROTOTYPE)) || defined(__cplusplus) || defined(USE_PROTOTYPE)
|
280 |
# define _USING_PROTOTYPES_ 1
|
281 |
# define _ANSI_ARGS_(x) x
|
282 |
# define CONST const
|
283 |
#else
|
284 |
# define _ANSI_ARGS_(x) ()
|
285 |
# define CONST
|
286 |
#endif
|
287 |
|
288 |
/*
|
289 |
* Make sure EXTERN isn't defined elsewhere
|
290 |
*/
|
291 |
#ifdef EXTERN
|
292 |
#undef EXTERN
|
293 |
#endif /* EXTERN */
|
294 |
|
295 |
#ifdef __cplusplus
|
296 |
# define EXTERN extern "C" TCL_STORAGE_CLASS
|
297 |
#else
|
298 |
# define EXTERN extern TCL_STORAGE_CLASS
|
299 |
#endif
|
300 |
|
301 |
/*
|
302 |
* Macro to use instead of "void" for arguments that must have
|
303 |
* type "void *" in ANSI C; maps them to type "char *" in
|
304 |
* non-ANSI systems.
|
305 |
*/
|
306 |
#ifndef __WIN32__
|
307 |
#ifndef VOID
|
308 |
# ifdef __STDC__
|
309 |
# define VOID void
|
310 |
# else
|
311 |
# define VOID char
|
312 |
# endif
|
313 |
#endif
|
314 |
#else /* __WIN32__ */
|
315 |
/*
|
316 |
* The following code is copied from winnt.h
|
317 |
*/
|
318 |
#ifndef VOID
|
319 |
#define VOID void
|
320 |
typedef char CHAR;
|
321 |
typedef short SHORT;
|
322 |
typedef long LONG;
|
323 |
#endif
|
324 |
#endif /* __WIN32__ */
|
325 |
|
326 |
/*
|
327 |
* Miscellaneous declarations.
|
328 |
*/
|
329 |
|
330 |
#ifndef NULL
|
331 |
#define NULL 0
|
332 |
#endif
|
333 |
|
334 |
#ifndef _CLIENTDATA
|
335 |
# if defined(__STDC__) || defined(__cplusplus)
|
336 |
typedef void *ClientData;
|
337 |
# else
|
338 |
typedef int *ClientData;
|
339 |
# endif /* __STDC__ */
|
340 |
#define _CLIENTDATA
|
341 |
#endif
|
342 |
|
343 |
/*
|
344 |
* Data structures defined opaquely in this module. The definitions below
|
345 |
* just provide dummy types. A few fields are made visible in Tcl_Interp
|
346 |
* structures, namely those used for returning a string result from
|
347 |
* commands. Direct access to the result field is discouraged in Tcl 8.0.
|
348 |
* The interpreter result is either an object or a string, and the two
|
349 |
* values are kept consistent unless some C code sets interp->result
|
350 |
* directly. Programmers should use either the procedure Tcl_GetObjResult()
|
351 |
* or Tcl_GetStringResult() to read the interpreter's result. See the
|
352 |
* SetResult man page for details.
|
353 |
*
|
354 |
* Note: any change to the Tcl_Interp definition below must be mirrored
|
355 |
* in the "real" definition in tclInt.h.
|
356 |
*
|
357 |
* Note: Tcl_ObjCmdProc procedures do not directly set result and freeProc.
|
358 |
* Instead, they set a Tcl_Obj member in the "real" structure that can be
|
359 |
* accessed with Tcl_GetObjResult() and Tcl_SetObjResult().
|
360 |
*/
|
361 |
|
362 |
typedef struct Tcl_Interp {
|
363 |
char *result; /* If the last command returned a string
|
364 |
* result, this points to it. */
|
365 |
void (*freeProc) _ANSI_ARGS_((char *blockPtr));
|
366 |
/* Zero means the string result is
|
367 |
* statically allocated. TCL_DYNAMIC means
|
368 |
* it was allocated with ckalloc and should
|
369 |
* be freed with ckfree. Other values give
|
370 |
* the address of procedure to invoke to
|
371 |
* free the result. Tcl_Eval must free it
|
372 |
* before executing next command. */
|
373 |
int errorLine; /* When TCL_ERROR is returned, this gives
|
374 |
* the line number within the command where
|
375 |
* the error occurred (1 if first line). */
|
376 |
} Tcl_Interp;
|
377 |
|
378 |
typedef struct Tcl_AsyncHandler_ *Tcl_AsyncHandler;
|
379 |
typedef struct Tcl_Channel_ *Tcl_Channel;
|
380 |
typedef struct Tcl_Command_ *Tcl_Command;
|
381 |
typedef struct Tcl_Condition_ *Tcl_Condition;
|
382 |
typedef struct Tcl_EncodingState_ *Tcl_EncodingState;
|
383 |
typedef struct Tcl_Encoding_ *Tcl_Encoding;
|
384 |
typedef struct Tcl_Event Tcl_Event;
|
385 |
typedef struct Tcl_Mutex_ *Tcl_Mutex;
|
386 |
typedef struct Tcl_Pid_ *Tcl_Pid;
|
387 |
typedef struct Tcl_RegExp_ *Tcl_RegExp;
|
388 |
typedef struct Tcl_ThreadDataKey_ *Tcl_ThreadDataKey;
|
389 |
typedef struct Tcl_ThreadId_ *Tcl_ThreadId;
|
390 |
typedef struct Tcl_TimerToken_ *Tcl_TimerToken;
|
391 |
typedef struct Tcl_Trace_ *Tcl_Trace;
|
392 |
typedef struct Tcl_Var_ *Tcl_Var;
|
393 |
|
394 |
/*
|
395 |
* Definition of the interface to procedures implementing threads.
|
396 |
* A procedure following this definition is given to each call of
|
397 |
* 'Tcl_CreateThread' and will be called as the main fuction of
|
398 |
* the new thread created by that call.
|
399 |
*/
|
400 |
|
401 |
#ifdef MAC_TCL
|
402 |
typedef pascal void *(Tcl_ThreadCreateProc) _ANSI_ARGS_((ClientData clientData));
|
403 |
#elif defined __WIN32__
|
404 |
typedef unsigned (__stdcall Tcl_ThreadCreateProc) _ANSI_ARGS_((ClientData clientData));
|
405 |
#else
|
406 |
typedef void (Tcl_ThreadCreateProc) _ANSI_ARGS_((ClientData clientData));
|
407 |
#endif
|
408 |
|
409 |
|
410 |
/*
|
411 |
* Threading function return types used for abstracting away platform
|
412 |
* differences when writing a Tcl_ThreadCreateProc. See the NewThread
|
413 |
* function in generic/tclThreadTest.c for it's usage.
|
414 |
*/
|
415 |
#ifdef MAC_TCL
|
416 |
# define Tcl_ThreadCreateType pascal void *
|
417 |
# define TCL_THREAD_CREATE_RETURN return NULL
|
418 |
#elif defined __WIN32__
|
419 |
# define Tcl_ThreadCreateType unsigned __stdcall
|
420 |
# define TCL_THREAD_CREATE_RETURN return 0
|
421 |
#else
|
422 |
# define Tcl_ThreadCreateType void
|
423 |
# define TCL_THREAD_CREATE_RETURN
|
424 |
#endif
|
425 |
|
426 |
|
427 |
|
428 |
/*
|
429 |
* Definition of values for default stacksize and the possible flags to be
|
430 |
* given to Tcl_CreateThread.
|
431 |
*/
|
432 |
|
433 |
#define TCL_THREAD_STACK_DEFAULT (0) /* Use default size for stack */
|
434 |
#define TCL_THREAD_NOFLAGS (0000) /* Standard flags, default behaviour */
|
435 |
#define TCL_THREAD_JOINABLE (0001) /* Mark the thread as joinable */
|
436 |
|
437 |
/*
|
438 |
* Flag values passed to Tcl_GetRegExpFromObj.
|
439 |
*/
|
440 |
|
441 |
#define TCL_REG_BASIC 000000 /* BREs (convenience) */
|
442 |
#define TCL_REG_EXTENDED 000001 /* EREs */
|
443 |
#define TCL_REG_ADVF 000002 /* advanced features in EREs */
|
444 |
#define TCL_REG_ADVANCED 000003 /* AREs (which are also EREs) */
|
445 |
#define TCL_REG_QUOTE 000004 /* no special characters, none */
|
446 |
#define TCL_REG_NOCASE 000010 /* ignore case */
|
447 |
#define TCL_REG_NOSUB 000020 /* don't care about subexpressions */
|
448 |
#define TCL_REG_EXPANDED 000040 /* expanded format, white space &
|
449 |
* comments */
|
450 |
#define TCL_REG_NLSTOP 000100 /* \n doesn't match . or [^ ] */
|
451 |
#define TCL_REG_NLANCH 000200 /* ^ matches after \n, $ before */
|
452 |
#define TCL_REG_NEWLINE 000300 /* newlines are line terminators */
|
453 |
#define TCL_REG_CANMATCH 001000 /* report details on partial/limited
|
454 |
* matches */
|
455 |
|
456 |
/*
|
457 |
* The following flag is experimental and only intended for use by Expect. It
|
458 |
* will probably go away in a later release.
|
459 |
*/
|
460 |
|
461 |
#define TCL_REG_BOSONLY 002000 /* prepend \A to pattern so it only
|
462 |
* matches at the beginning of the
|
463 |
* string. */
|
464 |
|
465 |
/*
|
466 |
* Flags values passed to Tcl_RegExpExecObj.
|
467 |
*/
|
468 |
|
469 |
#define TCL_REG_NOTBOL 0001 /* Beginning of string does not match ^. */
|
470 |
#define TCL_REG_NOTEOL 0002 /* End of string does not match $. */
|
471 |
|
472 |
/*
|
473 |
* Structures filled in by Tcl_RegExpInfo. Note that all offset values are
|
474 |
* relative to the start of the match string, not the beginning of the
|
475 |
* entire string.
|
476 |
*/
|
477 |
|
478 |
typedef struct Tcl_RegExpIndices {
|
479 |
long start; /* character offset of first character in match */
|
480 |
long end; /* character offset of first character after the
|
481 |
* match. */
|
482 |
} Tcl_RegExpIndices;
|
483 |
|
484 |
typedef struct Tcl_RegExpInfo {
|
485 |
int nsubs; /* number of subexpressions in the
|
486 |
* compiled expression */
|
487 |
Tcl_RegExpIndices *matches; /* array of nsubs match offset
|
488 |
* pairs */
|
489 |
long extendStart; /* The offset at which a subsequent
|
490 |
* match might begin. */
|
491 |
long reserved; /* Reserved for later use. */
|
492 |
} Tcl_RegExpInfo;
|
493 |
|
494 |
/*
|
495 |
* Picky compilers complain if this typdef doesn't appear before the
|
496 |
* struct's reference in tclDecls.h.
|
497 |
*/
|
498 |
|
499 |
typedef struct stat *Tcl_Stat_;
|
500 |
|
501 |
/*
|
502 |
* When a TCL command returns, the interpreter contains a result from the
|
503 |
* command. Programmers are strongly encouraged to use one of the
|
504 |
* procedures Tcl_GetObjResult() or Tcl_GetStringResult() to read the
|
505 |
* interpreter's result. See the SetResult man page for details. Besides
|
506 |
* this result, the command procedure returns an integer code, which is
|
507 |
* one of the following:
|
508 |
*
|
509 |
* TCL_OK Command completed normally; the interpreter's
|
510 |
* result contains the command's result.
|
511 |
* TCL_ERROR The command couldn't be completed successfully;
|
512 |
* the interpreter's result describes what went wrong.
|
513 |
* TCL_RETURN The command requests that the current procedure
|
514 |
* return; the interpreter's result contains the
|
515 |
* procedure's return value.
|
516 |
* TCL_BREAK The command requests that the innermost loop
|
517 |
* be exited; the interpreter's result is meaningless.
|
518 |
* TCL_CONTINUE Go on to the next iteration of the current loop;
|
519 |
* the interpreter's result is meaningless.
|
520 |
*/
|
521 |
|
522 |
#define TCL_OK 0
|
523 |
#define TCL_ERROR 1
|
524 |
#define TCL_RETURN 2
|
525 |
#define TCL_BREAK 3
|
526 |
#define TCL_CONTINUE 4
|
527 |
|
528 |
#define TCL_RESULT_SIZE 200
|
529 |
|
530 |
/*
|
531 |
* Argument descriptors for math function callbacks in expressions:
|
532 |
*/
|
533 |
|
534 |
typedef enum {TCL_INT, TCL_DOUBLE, TCL_EITHER} Tcl_ValueType;
|
535 |
typedef struct Tcl_Value {
|
536 |
Tcl_ValueType type; /* Indicates intValue or doubleValue is
|
537 |
* valid, or both. */
|
538 |
long intValue; /* Integer value. */
|
539 |
double doubleValue; /* Double-precision floating value. */
|
540 |
} Tcl_Value;
|
541 |
|
542 |
/*
|
543 |
* Forward declaration of Tcl_Obj to prevent an error when the forward
|
544 |
* reference to Tcl_Obj is encountered in the procedure types declared
|
545 |
* below.
|
546 |
*/
|
547 |
|
548 |
struct Tcl_Obj;
|
549 |
|
550 |
/*
|
551 |
* Procedure types defined by Tcl:
|
552 |
*/
|
553 |
|
554 |
typedef int (Tcl_AppInitProc) _ANSI_ARGS_((Tcl_Interp *interp));
|
555 |
typedef int (Tcl_AsyncProc) _ANSI_ARGS_((ClientData clientData,
|
556 |
Tcl_Interp *interp, int code));
|
557 |
typedef void (Tcl_ChannelProc) _ANSI_ARGS_((ClientData clientData, int mask));
|
558 |
typedef void (Tcl_CloseProc) _ANSI_ARGS_((ClientData data));
|
559 |
typedef void (Tcl_CmdDeleteProc) _ANSI_ARGS_((ClientData clientData));
|
560 |
typedef int (Tcl_CmdProc) _ANSI_ARGS_((ClientData clientData,
|
561 |
Tcl_Interp *interp, int argc, char *argv[]));
|
562 |
typedef void (Tcl_CmdTraceProc) _ANSI_ARGS_((ClientData clientData,
|
563 |
Tcl_Interp *interp, int level, char *command, Tcl_CmdProc *proc,
|
564 |
ClientData cmdClientData, int argc, char *argv[]));
|
565 |
typedef void (Tcl_DupInternalRepProc) _ANSI_ARGS_((struct Tcl_Obj *srcPtr,
|
566 |
struct Tcl_Obj *dupPtr));
|
567 |
typedef int (Tcl_EncodingConvertProc)_ANSI_ARGS_((ClientData clientData,
|
568 |
CONST char *src, int srcLen, int flags, Tcl_EncodingState *statePtr,
|
569 |
char *dst, int dstLen, int *srcReadPtr, int *dstWrotePtr,
|
570 |
int *dstCharsPtr));
|
571 |
typedef void (Tcl_EncodingFreeProc)_ANSI_ARGS_((ClientData clientData));
|
572 |
typedef int (Tcl_EventProc) _ANSI_ARGS_((Tcl_Event *evPtr, int flags));
|
573 |
typedef void (Tcl_EventCheckProc) _ANSI_ARGS_((ClientData clientData,
|
574 |
int flags));
|
575 |
typedef int (Tcl_EventDeleteProc) _ANSI_ARGS_((Tcl_Event *evPtr,
|
576 |
ClientData clientData));
|
577 |
typedef void (Tcl_EventSetupProc) _ANSI_ARGS_((ClientData clientData,
|
578 |
int flags));
|
579 |
typedef void (Tcl_ExitProc) _ANSI_ARGS_((ClientData clientData));
|
580 |
typedef void (Tcl_FileProc) _ANSI_ARGS_((ClientData clientData, int mask));
|
581 |
typedef void (Tcl_FileFreeProc) _ANSI_ARGS_((ClientData clientData));
|
582 |
typedef void (Tcl_FreeInternalRepProc) _ANSI_ARGS_((struct Tcl_Obj *objPtr));
|
583 |
typedef void (Tcl_FreeProc) _ANSI_ARGS_((char *blockPtr));
|
584 |
typedef void (Tcl_IdleProc) _ANSI_ARGS_((ClientData clientData));
|
585 |
typedef void (Tcl_InterpDeleteProc) _ANSI_ARGS_((ClientData clientData,
|
586 |
Tcl_Interp *interp));
|
587 |
typedef int (Tcl_MathProc) _ANSI_ARGS_((ClientData clientData,
|
588 |
Tcl_Interp *interp, Tcl_Value *args, Tcl_Value *resultPtr));
|
589 |
typedef void (Tcl_NamespaceDeleteProc) _ANSI_ARGS_((ClientData clientData));
|
590 |
typedef int (Tcl_ObjCmdProc) _ANSI_ARGS_((ClientData clientData,
|
591 |
Tcl_Interp *interp, int objc, struct Tcl_Obj *CONST objv[]));
|
592 |
typedef int (Tcl_PackageInitProc) _ANSI_ARGS_((Tcl_Interp *interp));
|
593 |
typedef void (Tcl_PanicProc) _ANSI_ARGS_(TCL_VARARGS(char *, format));
|
594 |
typedef void (Tcl_TcpAcceptProc) _ANSI_ARGS_((ClientData callbackData,
|
595 |
Tcl_Channel chan, char *address, int port));
|
596 |
typedef void (Tcl_TimerProc) _ANSI_ARGS_((ClientData clientData));
|
597 |
typedef int (Tcl_SetFromAnyProc) _ANSI_ARGS_((Tcl_Interp *interp,
|
598 |
struct Tcl_Obj *objPtr));
|
599 |
typedef void (Tcl_UpdateStringProc) _ANSI_ARGS_((struct Tcl_Obj *objPtr));
|
600 |
typedef char *(Tcl_VarTraceProc) _ANSI_ARGS_((ClientData clientData,
|
601 |
Tcl_Interp *interp, char *part1, char *part2, int flags));
|
602 |
typedef void (Tcl_CreateFileHandlerProc) _ANSI_ARGS_((int fd, int mask,
|
603 |
Tcl_FileProc *proc, ClientData clientData));
|
604 |
typedef void (Tcl_DeleteFileHandlerProc) _ANSI_ARGS_((int fd));
|
605 |
|
606 |
/*
|
607 |
* The following structure represents a type of object, which is a
|
608 |
* particular internal representation for an object plus a set of
|
609 |
* procedures that provide standard operations on objects of that type.
|
610 |
*/
|
611 |
|
612 |
typedef struct Tcl_ObjType {
|
613 |
char *name; /* Name of the type, e.g. "int". */
|
614 |
Tcl_FreeInternalRepProc *freeIntRepProc;
|
615 |
/* Called to free any storage for the type's
|
616 |
* internal rep. NULL if the internal rep
|
617 |
* does not need freeing. */
|
618 |
Tcl_DupInternalRepProc *dupIntRepProc;
|
619 |
/* Called to create a new object as a copy
|
620 |
* of an existing object. */
|
621 |
Tcl_UpdateStringProc *updateStringProc;
|
622 |
/* Called to update the string rep from the
|
623 |
* type's internal representation. */
|
624 |
Tcl_SetFromAnyProc *setFromAnyProc;
|
625 |
/* Called to convert the object's internal
|
626 |
* rep to this type. Frees the internal rep
|
627 |
* of the old type. Returns TCL_ERROR on
|
628 |
* failure. */
|
629 |
} Tcl_ObjType;
|
630 |
|
631 |
/*
|
632 |
* One of the following structures exists for each object in the Tcl
|
633 |
* system. An object stores a value as either a string, some internal
|
634 |
* representation, or both.
|
635 |
*/
|
636 |
|
637 |
typedef struct Tcl_Obj {
|
638 |
int refCount; /* When 0 the object will be freed. */
|
639 |
char *bytes; /* This points to the first byte of the
|
640 |
* object's string representation. The array
|
641 |
* must be followed by a null byte (i.e., at
|
642 |
* offset length) but may also contain
|
643 |
* embedded null characters. The array's
|
644 |
* storage is allocated by ckalloc. NULL
|
645 |
* means the string rep is invalid and must
|
646 |
* be regenerated from the internal rep.
|
647 |
* Clients should use Tcl_GetStringFromObj
|
648 |
* or Tcl_GetString to get a pointer to the
|
649 |
* byte array as a readonly value. */
|
650 |
int length; /* The number of bytes at *bytes, not
|
651 |
* including the terminating null. */
|
652 |
Tcl_ObjType *typePtr; /* Denotes the object's type. Always
|
653 |
* corresponds to the type of the object's
|
654 |
* internal rep. NULL indicates the object
|
655 |
* has no internal rep (has no type). */
|
656 |
union { /* The internal representation: */
|
657 |
long longValue; /* - an long integer value */
|
658 |
double doubleValue; /* - a double-precision floating value */
|
659 |
VOID *otherValuePtr; /* - another, type-specific value */
|
660 |
struct { /* - internal rep as two pointers */
|
661 |
VOID *ptr1;
|
662 |
VOID *ptr2;
|
663 |
} twoPtrValue;
|
664 |
} internalRep;
|
665 |
} Tcl_Obj;
|
666 |
|
667 |
/*
|
668 |
* Macros to increment and decrement a Tcl_Obj's reference count, and to
|
669 |
* test whether an object is shared (i.e. has reference count > 1).
|
670 |
* Note: clients should use Tcl_DecrRefCount() when they are finished using
|
671 |
* an object, and should never call TclFreeObj() directly. TclFreeObj() is
|
672 |
* only defined and made public in tcl.h to support Tcl_DecrRefCount's macro
|
673 |
* definition. Note also that Tcl_DecrRefCount() refers to the parameter
|
674 |
* "obj" twice. This means that you should avoid calling it with an
|
675 |
* expression that is expensive to compute or has side effects.
|
676 |
*/
|
677 |
|
678 |
void Tcl_IncrRefCount _ANSI_ARGS_((Tcl_Obj *objPtr));
|
679 |
void Tcl_DecrRefCount _ANSI_ARGS_((Tcl_Obj *objPtr));
|
680 |
int Tcl_IsShared _ANSI_ARGS_((Tcl_Obj *objPtr));
|
681 |
|
682 |
#ifdef TCL_MEM_DEBUG
|
683 |
# define Tcl_IncrRefCount(objPtr) \
|
684 |
Tcl_DbIncrRefCount(objPtr, __FILE__, __LINE__)
|
685 |
# define Tcl_DecrRefCount(objPtr) \
|
686 |
Tcl_DbDecrRefCount(objPtr, __FILE__, __LINE__)
|
687 |
# define Tcl_IsShared(objPtr) \
|
688 |
Tcl_DbIsShared(objPtr, __FILE__, __LINE__)
|
689 |
#else
|
690 |
# define Tcl_IncrRefCount(objPtr) \
|
691 |
++(objPtr)->refCount
|
692 |
# define Tcl_DecrRefCount(objPtr) \
|
693 |
if (--(objPtr)->refCount <= 0) TclFreeObj(objPtr)
|
694 |
# define Tcl_IsShared(objPtr) \
|
695 |
((objPtr)->refCount > 1)
|
696 |
#endif
|
697 |
|
698 |
/*
|
699 |
* Macros and definitions that help to debug the use of Tcl objects.
|
700 |
* When TCL_MEM_DEBUG is defined, the Tcl_New declarations are
|
701 |
* overridden to call debugging versions of the object creation procedures.
|
702 |
*/
|
703 |
|
704 |
#ifdef TCL_MEM_DEBUG
|
705 |
# define Tcl_NewBooleanObj(val) \
|
706 |
Tcl_DbNewBooleanObj(val, __FILE__, __LINE__)
|
707 |
# define Tcl_NewByteArrayObj(bytes, len) \
|
708 |
Tcl_DbNewByteArrayObj(bytes, len, __FILE__, __LINE__)
|
709 |
# define Tcl_NewDoubleObj(val) \
|
710 |
Tcl_DbNewDoubleObj(val, __FILE__, __LINE__)
|
711 |
# define Tcl_NewIntObj(val) \
|
712 |
Tcl_DbNewLongObj(val, __FILE__, __LINE__)
|
713 |
# define Tcl_NewListObj(objc, objv) \
|
714 |
Tcl_DbNewListObj(objc, objv, __FILE__, __LINE__)
|
715 |
# define Tcl_NewLongObj(val) \
|
716 |
Tcl_DbNewLongObj(val, __FILE__, __LINE__)
|
717 |
# define Tcl_NewObj() \
|
718 |
Tcl_DbNewObj(__FILE__, __LINE__)
|
719 |
# define Tcl_NewStringObj(bytes, len) \
|
720 |
Tcl_DbNewStringObj(bytes, len, __FILE__, __LINE__)
|
721 |
#endif /* TCL_MEM_DEBUG */
|
722 |
|
723 |
/*
|
724 |
* The following structure contains the state needed by
|
725 |
* Tcl_SaveResult. No-one outside of Tcl should access any of these
|
726 |
* fields. This structure is typically allocated on the stack.
|
727 |
*/
|
728 |
|
729 |
typedef struct Tcl_SavedResult {
|
730 |
char *result;
|
731 |
Tcl_FreeProc *freeProc;
|
732 |
Tcl_Obj *objResultPtr;
|
733 |
char *appendResult;
|
734 |
int appendAvl;
|
735 |
int appendUsed;
|
736 |
char resultSpace[TCL_RESULT_SIZE+1];
|
737 |
} Tcl_SavedResult;
|
738 |
|
739 |
|
740 |
/*
|
741 |
* The following definitions support Tcl's namespace facility.
|
742 |
* Note: the first five fields must match exactly the fields in a
|
743 |
* Namespace structure (see tclInt.h).
|
744 |
*/
|
745 |
|
746 |
typedef struct Tcl_Namespace {
|
747 |
char *name; /* The namespace's name within its parent
|
748 |
* namespace. This contains no ::'s. The
|
749 |
* name of the global namespace is ""
|
750 |
* although "::" is an synonym. */
|
751 |
char *fullName; /* The namespace's fully qualified name.
|
752 |
* This starts with ::. */
|
753 |
ClientData clientData; /* Arbitrary value associated with this
|
754 |
* namespace. */
|
755 |
Tcl_NamespaceDeleteProc* deleteProc;
|
756 |
/* Procedure invoked when deleting the
|
757 |
* namespace to, e.g., free clientData. */
|
758 |
struct Tcl_Namespace* parentPtr;
|
759 |
/* Points to the namespace that contains
|
760 |
* this one. NULL if this is the global
|
761 |
* namespace. */
|
762 |
} Tcl_Namespace;
|
763 |
|
764 |
/*
|
765 |
* The following structure represents a call frame, or activation record.
|
766 |
* A call frame defines a naming context for a procedure call: its local
|
767 |
* scope (for local variables) and its namespace scope (used for non-local
|
768 |
* variables; often the global :: namespace). A call frame can also define
|
769 |
* the naming context for a namespace eval or namespace inscope command:
|
770 |
* the namespace in which the command's code should execute. The
|
771 |
* Tcl_CallFrame structures exist only while procedures or namespace
|
772 |
* eval/inscope's are being executed, and provide a Tcl call stack.
|
773 |
*
|
774 |
* A call frame is initialized and pushed using Tcl_PushCallFrame and
|
775 |
* popped using Tcl_PopCallFrame. Storage for a Tcl_CallFrame must be
|
776 |
* provided by the Tcl_PushCallFrame caller, and callers typically allocate
|
777 |
* them on the C call stack for efficiency. For this reason, Tcl_CallFrame
|
778 |
* is defined as a structure and not as an opaque token. However, most
|
779 |
* Tcl_CallFrame fields are hidden since applications should not access
|
780 |
* them directly; others are declared as "dummyX".
|
781 |
*
|
782 |
* WARNING!! The structure definition must be kept consistent with the
|
783 |
* CallFrame structure in tclInt.h. If you change one, change the other.
|
784 |
*/
|
785 |
|
786 |
typedef struct Tcl_CallFrame {
|
787 |
Tcl_Namespace *nsPtr;
|
788 |
int dummy1;
|
789 |
int dummy2;
|
790 |
char *dummy3;
|
791 |
char *dummy4;
|
792 |
char *dummy5;
|
793 |
int dummy6;
|
794 |
char *dummy7;
|
795 |
char *dummy8;
|
796 |
int dummy9;
|
797 |
char* dummy10;
|
798 |
} Tcl_CallFrame;
|
799 |
|
800 |
/*
|
801 |
* Information about commands that is returned by Tcl_GetCommandInfo and
|
802 |
* passed to Tcl_SetCommandInfo. objProc is an objc/objv object-based
|
803 |
* command procedure while proc is a traditional Tcl argc/argv
|
804 |
* string-based procedure. Tcl_CreateObjCommand and Tcl_CreateCommand
|
805 |
* ensure that both objProc and proc are non-NULL and can be called to
|
806 |
* execute the command. However, it may be faster to call one instead of
|
807 |
* the other. The member isNativeObjectProc is set to 1 if an
|
808 |
* object-based procedure was registered by Tcl_CreateObjCommand, and to
|
809 |
* 0 if a string-based procedure was registered by Tcl_CreateCommand.
|
810 |
* The other procedure is typically set to a compatibility wrapper that
|
811 |
* does string-to-object or object-to-string argument conversions then
|
812 |
* calls the other procedure.
|
813 |
*/
|
814 |
|
815 |
typedef struct Tcl_CmdInfo {
|
816 |
int isNativeObjectProc; /* 1 if objProc was registered by a call to
|
817 |
* Tcl_CreateObjCommand; 0 otherwise.
|
818 |
* Tcl_SetCmdInfo does not modify this
|
819 |
* field. */
|
820 |
Tcl_ObjCmdProc *objProc; /* Command's object-based procedure. */
|
821 |
ClientData objClientData; /* ClientData for object proc. */
|
822 |
Tcl_CmdProc *proc; /* Command's string-based procedure. */
|
823 |
ClientData clientData; /* ClientData for string proc. */
|
824 |
Tcl_CmdDeleteProc *deleteProc;
|
825 |
/* Procedure to call when command is
|
826 |
* deleted. */
|
827 |
ClientData deleteData; /* Value to pass to deleteProc (usually
|
828 |
* the same as clientData). */
|
829 |
Tcl_Namespace *namespacePtr; /* Points to the namespace that contains
|
830 |
* this command. Note that Tcl_SetCmdInfo
|
831 |
* will not change a command's namespace;
|
832 |
* use Tcl_RenameCommand to do that. */
|
833 |
|
834 |
} Tcl_CmdInfo;
|
835 |
|
836 |
/*
|
837 |
* The structure defined below is used to hold dynamic strings. The only
|
838 |
* field that clients should use is the string field, and they should
|
839 |
* never modify it.
|
840 |
*/
|
841 |
|
842 |
#define TCL_DSTRING_STATIC_SIZE 200
|
843 |
typedef struct Tcl_DString {
|
844 |
char *string; /* Points to beginning of string: either
|
845 |
* staticSpace below or a malloced array. */
|
846 |
int length; /* Number of non-NULL characters in the
|
847 |
* string. */
|
848 |
int spaceAvl; /* Total number of bytes available for the
|
849 |
* string and its terminating NULL char. */
|
850 |
char staticSpace[TCL_DSTRING_STATIC_SIZE];
|
851 |
/* Space to use in common case where string
|
852 |
* is small. */
|
853 |
} Tcl_DString;
|
854 |
|
855 |
#define Tcl_DStringLength(dsPtr) ((dsPtr)->length)
|
856 |
#define Tcl_DStringValue(dsPtr) ((dsPtr)->string)
|
857 |
#define Tcl_DStringTrunc Tcl_DStringSetLength
|
858 |
|
859 |
/*
|
860 |
* Definitions for the maximum number of digits of precision that may
|
861 |
* be specified in the "tcl_precision" variable, and the number of
|
862 |
* bytes of buffer space required by Tcl_PrintDouble.
|
863 |
*/
|
864 |
|
865 |
#define TCL_MAX_PREC 17
|
866 |
#define TCL_DOUBLE_SPACE (TCL_MAX_PREC+10)
|
867 |
|
868 |
/*
|
869 |
* Definition for a number of bytes of buffer space sufficient to hold the
|
870 |
* string representation of an integer in base 10 (assuming the existence
|
871 |
* of 64-bit integers).
|
872 |
*/
|
873 |
|
874 |
#define TCL_INTEGER_SPACE 24
|
875 |
|
876 |
/*
|
877 |
* Flag that may be passed to Tcl_ConvertElement to force it not to
|
878 |
* output braces (careful! if you change this flag be sure to change
|
879 |
* the definitions at the front of tclUtil.c).
|
880 |
*/
|
881 |
|
882 |
#define TCL_DONT_USE_BRACES 1
|
883 |
|
884 |
/*
|
885 |
* Flag that may be passed to Tcl_GetIndexFromObj to force it to disallow
|
886 |
* abbreviated strings.
|
887 |
*/
|
888 |
|
889 |
#define TCL_EXACT 1
|
890 |
|
891 |
/*
|
892 |
* Flag values passed to Tcl_RecordAndEval and/or Tcl_EvalObj.
|
893 |
* WARNING: these bit choices must not conflict with the bit choices
|
894 |
* for evalFlag bits in tclInt.h!!
|
895 |
*/
|
896 |
|
897 |
#define TCL_NO_EVAL 0x10000
|
898 |
#define TCL_EVAL_GLOBAL 0x20000
|
899 |
#define TCL_EVAL_DIRECT 0x40000
|
900 |
|
901 |
/*
|
902 |
* Special freeProc values that may be passed to Tcl_SetResult (see
|
903 |
* the man page for details):
|
904 |
*/
|
905 |
|
906 |
#define TCL_VOLATILE ((Tcl_FreeProc *) 1)
|
907 |
#define TCL_STATIC ((Tcl_FreeProc *) 0)
|
908 |
#define TCL_DYNAMIC ((Tcl_FreeProc *) 3)
|
909 |
|
910 |
/*
|
911 |
* Flag values passed to variable-related procedures.
|
912 |
*/
|
913 |
|
914 |
#define TCL_GLOBAL_ONLY 1
|
915 |
#define TCL_NAMESPACE_ONLY 2
|
916 |
#define TCL_APPEND_VALUE 4
|
917 |
#define TCL_LIST_ELEMENT 8
|
918 |
#define TCL_TRACE_READS 0x10
|
919 |
#define TCL_TRACE_WRITES 0x20
|
920 |
#define TCL_TRACE_UNSETS 0x40
|
921 |
#define TCL_TRACE_DESTROYED 0x80
|
922 |
#define TCL_INTERP_DESTROYED 0x100
|
923 |
#define TCL_LEAVE_ERR_MSG 0x200
|
924 |
#define TCL_TRACE_ARRAY 0x800
|
925 |
|
926 |
/*
|
927 |
* The TCL_PARSE_PART1 flag is deprecated and has no effect.
|
928 |
* The part1 is now always parsed whenever the part2 is NULL.
|
929 |
* (This is to avoid a common error when converting code to
|
930 |
* use the new object based APIs and forgetting to give the
|
931 |
* flag)
|
932 |
*/
|
933 |
#ifndef TCL_NO_DEPRECATED
|
934 |
#define TCL_PARSE_PART1 0x400
|
935 |
#endif
|
936 |
|
937 |
|
938 |
/*
|
939 |
* Types for linked variables:
|
940 |
*/
|
941 |
|
942 |
#define TCL_LINK_INT 1
|
943 |
#define TCL_LINK_DOUBLE 2
|
944 |
#define TCL_LINK_BOOLEAN 3
|
945 |
#define TCL_LINK_STRING 4
|
946 |
#define TCL_LINK_READ_ONLY 0x80
|
947 |
|
948 |
/*
|
949 |
* Forward declaration of Tcl_HashTable. Needed by some C++ compilers
|
950 |
* to prevent errors when the forward reference to Tcl_HashTable is
|
951 |
* encountered in the Tcl_HashEntry structure.
|
952 |
*/
|
953 |
|
954 |
#ifdef __cplusplus
|
955 |
struct Tcl_HashTable;
|
956 |
#endif
|
957 |
|
958 |
/*
|
959 |
* Structure definition for an entry in a hash table. No-one outside
|
960 |
* Tcl should access any of these fields directly; use the macros
|
961 |
* defined below.
|
962 |
*/
|
963 |
|
964 |
typedef struct Tcl_HashEntry {
|
965 |
struct Tcl_HashEntry *nextPtr; /* Pointer to next entry in this
|
966 |
* hash bucket, or NULL for end of
|
967 |
* chain. */
|
968 |
struct Tcl_HashTable *tablePtr; /* Pointer to table containing entry. */
|
969 |
struct Tcl_HashEntry **bucketPtr; /* Pointer to bucket that points to
|
970 |
* first entry in this entry's chain:
|
971 |
* used for deleting the entry. */
|
972 |
ClientData clientData; /* Application stores something here
|
973 |
* with Tcl_SetHashValue. */
|
974 |
union { /* Key has one of these forms: */
|
975 |
char *oneWordValue; /* One-word value for key. */
|
976 |
int words[1]; /* Multiple integer words for key.
|
977 |
* The actual size will be as large
|
978 |
* as necessary for this table's
|
979 |
* keys. */
|
980 |
char string[4]; /* String for key. The actual size
|
981 |
* will be as large as needed to hold
|
982 |
* the key. */
|
983 |
} key; /* MUST BE LAST FIELD IN RECORD!! */
|
984 |
} Tcl_HashEntry;
|
985 |
|
986 |
/*
|
987 |
* Structure definition for a hash table. Must be in tcl.h so clients
|
988 |
* can allocate space for these structures, but clients should never
|
989 |
* access any fields in this structure.
|
990 |
*/
|
991 |
|
992 |
#define TCL_SMALL_HASH_TABLE 4
|
993 |
typedef struct Tcl_HashTable {
|
994 |
Tcl_HashEntry **buckets; /* Pointer to bucket array. Each
|
995 |
* element points to first entry in
|
996 |
* bucket's hash chain, or NULL. */
|
997 |
Tcl_HashEntry *staticBuckets[TCL_SMALL_HASH_TABLE];
|
998 |
/* Bucket array used for small tables
|
999 |
* (to avoid mallocs and frees). */
|
1000 |
int numBuckets; /* Total number of buckets allocated
|
1001 |
* at **bucketPtr. */
|
1002 |
int numEntries; /* Total number of entries present
|
1003 |
* in table. */
|
1004 |
int rebuildSize; /* Enlarge table when numEntries gets
|
1005 |
* to be this large. */
|
1006 |
int downShift; /* Shift count used in hashing
|
1007 |
* function. Designed to use high-
|
1008 |
* order bits of randomized keys. */
|
1009 |
int mask; /* Mask value used in hashing
|
1010 |
* function. */
|
1011 |
int keyType; /* Type of keys used in this table.
|
1012 |
* It's either TCL_STRING_KEYS,
|
1013 |
* TCL_ONE_WORD_KEYS, or an integer
|
1014 |
* giving the number of ints that
|
1015 |
* is the size of the key.
|
1016 |
*/
|
1017 |
Tcl_HashEntry *(*findProc) _ANSI_ARGS_((struct Tcl_HashTable *tablePtr,
|
1018 |
CONST char *key));
|
1019 |
Tcl_HashEntry *(*createProc) _ANSI_ARGS_((struct Tcl_HashTable *tablePtr,
|
1020 |
CONST char *key, int *newPtr));
|
1021 |
} Tcl_HashTable;
|
1022 |
|
1023 |
/*
|
1024 |
* Structure definition for information used to keep track of searches
|
1025 |
* through hash tables:
|
1026 |
*/
|
1027 |
|
1028 |
typedef struct Tcl_HashSearch {
|
1029 |
Tcl_HashTable *tablePtr; /* Table being searched. */
|
1030 |
int nextIndex; /* Index of next bucket to be
|
1031 |
* enumerated after present one. */
|
1032 |
Tcl_HashEntry *nextEntryPtr; /* Next entry to be enumerated in the
|
1033 |
* the current bucket. */
|
1034 |
} Tcl_HashSearch;
|
1035 |
|
1036 |
/*
|
1037 |
* Acceptable key types for hash tables:
|
1038 |
*/
|
1039 |
|
1040 |
#define TCL_STRING_KEYS 0
|
1041 |
#define TCL_ONE_WORD_KEYS 1
|
1042 |
|
1043 |
/*
|
1044 |
* Macros for clients to use to access fields of hash entries:
|
1045 |
*/
|
1046 |
|
1047 |
#define Tcl_GetHashValue(h) ((h)->clientData)
|
1048 |
#define Tcl_SetHashValue(h, value) ((h)->clientData = (ClientData) (value))
|
1049 |
#define Tcl_GetHashKey(tablePtr, h) \
|
1050 |
((char *) (((tablePtr)->keyType == TCL_ONE_WORD_KEYS) ? (h)->key.oneWordValue \
|
1051 |
: (h)->key.string))
|
1052 |
|
1053 |
/*
|
1054 |
* Macros to use for clients to use to invoke find and create procedures
|
1055 |
* for hash tables:
|
1056 |
*/
|
1057 |
|
1058 |
#define Tcl_FindHashEntry(tablePtr, key) \
|
1059 |
(*((tablePtr)->findProc))(tablePtr, key)
|
1060 |
#define Tcl_CreateHashEntry(tablePtr, key, newPtr) \
|
1061 |
(*((tablePtr)->createProc))(tablePtr, key, newPtr)
|
1062 |
|
1063 |
/*
|
1064 |
* Flag values to pass to Tcl_DoOneEvent to disable searches
|
1065 |
* for some kinds of events:
|
1066 |
*/
|
1067 |
|
1068 |
#define TCL_DONT_WAIT (1<<1)
|
1069 |
#define TCL_WINDOW_EVENTS (1<<2)
|
1070 |
#define TCL_FILE_EVENTS (1<<3)
|
1071 |
#define TCL_TIMER_EVENTS (1<<4)
|
1072 |
#define TCL_IDLE_EVENTS (1<<5) /* WAS 0x10 ???? */
|
1073 |
#define TCL_ALL_EVENTS (~TCL_DONT_WAIT)
|
1074 |
|
1075 |
/*
|
1076 |
* The following structure defines a generic event for the Tcl event
|
1077 |
* system. These are the things that are queued in calls to Tcl_QueueEvent
|
1078 |
* and serviced later by Tcl_DoOneEvent. There can be many different
|
1079 |
* kinds of events with different fields, corresponding to window events,
|
1080 |
* timer events, etc. The structure for a particular event consists of
|
1081 |
* a Tcl_Event header followed by additional information specific to that
|
1082 |
* event.
|
1083 |
*/
|
1084 |
|
1085 |
struct Tcl_Event {
|
1086 |
Tcl_EventProc *proc; /* Procedure to call to service this event. */
|
1087 |
struct Tcl_Event *nextPtr; /* Next in list of pending events, or NULL. */
|
1088 |
};
|
1089 |
|
1090 |
/*
|
1091 |
* Positions to pass to Tcl_QueueEvent:
|
1092 |
*/
|
1093 |
|
1094 |
typedef enum {
|
1095 |
TCL_QUEUE_TAIL, TCL_QUEUE_HEAD, TCL_QUEUE_MARK
|
1096 |
} Tcl_QueuePosition;
|
1097 |
|
1098 |
/*
|
1099 |
* Values to pass to Tcl_SetServiceMode to specify the behavior of notifier
|
1100 |
* event routines.
|
1101 |
*/
|
1102 |
|
1103 |
#define TCL_SERVICE_NONE 0
|
1104 |
#define TCL_SERVICE_ALL 1
|
1105 |
|
1106 |
/*
|
1107 |
* The following structure keeps is used to hold a time value, either as
|
1108 |
* an absolute time (the number of seconds from the epoch) or as an
|
1109 |
* elapsed time. On Unix systems the epoch is Midnight Jan 1, 1970 GMT.
|
1110 |
* On Macintosh systems the epoch is Midnight Jan 1, 1904 GMT.
|
1111 |
*/
|
1112 |
|
1113 |
typedef struct Tcl_Time {
|
1114 |
long sec; /* Seconds. */
|
1115 |
long usec; /* Microseconds. */
|
1116 |
} Tcl_Time;
|
1117 |
|
1118 |
typedef void (Tcl_SetTimerProc) _ANSI_ARGS_((Tcl_Time *timePtr));
|
1119 |
typedef int (Tcl_WaitForEventProc) _ANSI_ARGS_((Tcl_Time *timePtr));
|
1120 |
|
1121 |
/*
|
1122 |
* Bits to pass to Tcl_CreateFileHandler and Tcl_CreateChannelHandler
|
1123 |
* to indicate what sorts of events are of interest:
|
1124 |
*/
|
1125 |
|
1126 |
#define TCL_READABLE (1<<1)
|
1127 |
#define TCL_WRITABLE (1<<2)
|
1128 |
#define TCL_EXCEPTION (1<<3)
|
1129 |
|
1130 |
/*
|
1131 |
* Flag values to pass to Tcl_OpenCommandChannel to indicate the
|
1132 |
* disposition of the stdio handles. TCL_STDIN, TCL_STDOUT, TCL_STDERR,
|
1133 |
* are also used in Tcl_GetStdChannel.
|
1134 |
*/
|
1135 |
|
1136 |
#define TCL_STDIN (1<<1)
|
1137 |
#define TCL_STDOUT (1<<2)
|
1138 |
#define TCL_STDERR (1<<3)
|
1139 |
#define TCL_ENFORCE_MODE (1<<4)
|
1140 |
|
1141 |
/*
|
1142 |
* Bits passed to Tcl_DriverClose2Proc to indicate which side of a channel
|
1143 |
* should be closed.
|
1144 |
*/
|
1145 |
|
1146 |
#define TCL_CLOSE_READ (1<<1)
|
1147 |
#define TCL_CLOSE_WRITE (1<<2)
|
1148 |
|
1149 |
/*
|
1150 |
* Value to use as the closeProc for a channel that supports the
|
1151 |
* close2Proc interface.
|
1152 |
*/
|
1153 |
|
1154 |
#define TCL_CLOSE2PROC ((Tcl_DriverCloseProc *)1)
|
1155 |
|
1156 |
/*
|
1157 |
* Typedefs for the various operations in a channel type:
|
1158 |
*/
|
1159 |
|
1160 |
typedef int (Tcl_DriverBlockModeProc) _ANSI_ARGS_((
|
1161 |
ClientData instanceData, int mode));
|
1162 |
typedef int (Tcl_DriverCloseProc) _ANSI_ARGS_((ClientData instanceData,
|
1163 |
Tcl_Interp *interp));
|
1164 |
typedef int (Tcl_DriverClose2Proc) _ANSI_ARGS_((ClientData instanceData,
|
1165 |
Tcl_Interp *interp, int flags));
|
1166 |
typedef int (Tcl_DriverInputProc) _ANSI_ARGS_((ClientData instanceData,
|
1167 |
char *buf, int toRead, int *errorCodePtr));
|
1168 |
typedef int (Tcl_DriverOutputProc) _ANSI_ARGS_((ClientData instanceData,
|
1169 |
char *buf, int toWrite, int *errorCodePtr));
|
1170 |
typedef int (Tcl_DriverSeekProc) _ANSI_ARGS_((ClientData instanceData,
|
1171 |
long offset, int mode, int *errorCodePtr));
|
1172 |
typedef int (Tcl_DriverSetOptionProc) _ANSI_ARGS_((
|
1173 |
ClientData instanceData, Tcl_Interp *interp,
|
1174 |
char *optionName, char *value));
|
1175 |
typedef int (Tcl_DriverGetOptionProc) _ANSI_ARGS_((
|
1176 |
ClientData instanceData, Tcl_Interp *interp,
|
1177 |
char *optionName, Tcl_DString *dsPtr));
|
1178 |
typedef void (Tcl_DriverWatchProc) _ANSI_ARGS_((
|
1179 |
ClientData instanceData, int mask));
|
1180 |
typedef int (Tcl_DriverGetHandleProc) _ANSI_ARGS_((
|
1181 |
ClientData instanceData, int direction,
|
1182 |
ClientData *handlePtr));
|
1183 |
|
1184 |
/*
|
1185 |
* The following declarations either map ckalloc and ckfree to
|
1186 |
* malloc and free, or they map them to procedures with all sorts
|
1187 |
* of debugging hooks defined in tclCkalloc.c.
|
1188 |
*/
|
1189 |
|
1190 |
#ifdef TCL_MEM_DEBUG
|
1191 |
|
1192 |
# define ckalloc(x) Tcl_DbCkalloc(x, __FILE__, __LINE__)
|
1193 |
# define ckfree(x) Tcl_DbCkfree(x, __FILE__, __LINE__)
|
1194 |
# define ckrealloc(x,y) Tcl_DbCkrealloc((x), (y),__FILE__, __LINE__)
|
1195 |
|
1196 |
#else /* !TCL_MEM_DEBUG */
|
1197 |
|
1198 |
/*
|
1199 |
* If we are not using the debugging allocator, we should call the
|
1200 |
* Tcl_Alloc, et al. routines in order to guarantee that every module
|
1201 |
* is using the same memory allocator both inside and outside of the
|
1202 |
* Tcl library.
|
1203 |
*/
|
1204 |
|
1205 |
# define ckalloc(x) Tcl_Alloc(x)
|
1206 |
# define ckfree(x) Tcl_Free(x)
|
1207 |
# define ckrealloc(x,y) Tcl_Realloc(x,y)
|
1208 |
# define Tcl_InitMemory(x)
|
1209 |
# define Tcl_DumpActiveMemory(x)
|
1210 |
# define Tcl_ValidateAllMemory(x,y)
|
1211 |
|
1212 |
#endif /* !TCL_MEM_DEBUG */
|
1213 |
|
1214 |
/*
|
1215 |
* Enum for different end of line translation and recognition modes.
|
1216 |
*/
|
1217 |
|
1218 |
typedef enum Tcl_EolTranslation {
|
1219 |
TCL_TRANSLATE_AUTO, /* Eol == \r, \n and \r\n. */
|
1220 |
TCL_TRANSLATE_CR, /* Eol == \r. */
|
1221 |
TCL_TRANSLATE_LF, /* Eol == \n. */
|
1222 |
TCL_TRANSLATE_CRLF /* Eol == \r\n. */
|
1223 |
} Tcl_EolTranslation;
|
1224 |
|
1225 |
/*
|
1226 |
* struct Tcl_ChannelType:
|
1227 |
*
|
1228 |
* One such structure exists for each type (kind) of channel.
|
1229 |
* It collects together in one place all the functions that are
|
1230 |
* part of the specific channel type.
|
1231 |
*/
|
1232 |
|
1233 |
typedef struct Tcl_ChannelType {
|
1234 |
char *typeName; /* The name of the channel type in Tcl
|
1235 |
* commands. This storage is owned by
|
1236 |
* channel type. */
|
1237 |
Tcl_DriverBlockModeProc *blockModeProc;
|
1238 |
/* Set blocking mode for the
|
1239 |
* raw channel. May be NULL. */
|
1240 |
Tcl_DriverCloseProc *closeProc; /* Procedure to call to close the
|
1241 |
* channel, or TCL_CLOSE2PROC if the
|
1242 |
* close2Proc should be used
|
1243 |
* instead. */
|
1244 |
Tcl_DriverInputProc *inputProc; /* Procedure to call for input
|
1245 |
* on channel. */
|
1246 |
Tcl_DriverOutputProc *outputProc; /* Procedure to call for output
|
1247 |
* on channel. */
|
1248 |
Tcl_DriverSeekProc *seekProc; /* Procedure to call to seek
|
1249 |
* on the channel. May be NULL. */
|
1250 |
Tcl_DriverSetOptionProc *setOptionProc;
|
1251 |
/* Set an option on a channel. */
|
1252 |
Tcl_DriverGetOptionProc *getOptionProc;
|
1253 |
/* Get an option from a channel. */
|
1254 |
Tcl_DriverWatchProc *watchProc; /* Set up the notifier to watch
|
1255 |
* for events on this channel. */
|
1256 |
Tcl_DriverGetHandleProc *getHandleProc;
|
1257 |
/* Get an OS handle from the channel
|
1258 |
* or NULL if not supported. */
|
1259 |
Tcl_DriverClose2Proc *close2Proc; /* Procedure to call to close the
|
1260 |
* channel if the device supports
|
1261 |
* closing the read & write sides
|
1262 |
* independently. */
|
1263 |
} Tcl_ChannelType;
|
1264 |
|
1265 |
/*
|
1266 |
* The following flags determine whether the blockModeProc above should
|
1267 |
* set the channel into blocking or nonblocking mode. They are passed
|
1268 |
* as arguments to the blockModeProc procedure in the above structure.
|
1269 |
*/
|
1270 |
|
1271 |
#define TCL_MODE_BLOCKING 0 /* Put channel into blocking mode. */
|
1272 |
#define TCL_MODE_NONBLOCKING 1 /* Put channel into nonblocking
|
1273 |
* mode. */
|
1274 |
|
1275 |
/*
|
1276 |
* Enum for different types of file paths.
|
1277 |
*/
|
1278 |
|
1279 |
typedef enum Tcl_PathType {
|
1280 |
TCL_PATH_ABSOLUTE,
|
1281 |
TCL_PATH_RELATIVE,
|
1282 |
TCL_PATH_VOLUME_RELATIVE
|
1283 |
} Tcl_PathType;
|
1284 |
|
1285 |
/*
|
1286 |
* The following structure represents the Notifier functions that
|
1287 |
* you can override with the Tcl_SetNotifier call.
|
1288 |
*/
|
1289 |
|
1290 |
typedef struct Tcl_NotifierProcs {
|
1291 |
Tcl_SetTimerProc *setTimerProc;
|
1292 |
Tcl_WaitForEventProc *waitForEventProc;
|
1293 |
Tcl_CreateFileHandlerProc *createFileHandlerProc;
|
1294 |
Tcl_DeleteFileHandlerProc *deleteFileHandlerProc;
|
1295 |
} Tcl_NotifierProcs;
|
1296 |
|
1297 |
/*
|
1298 |
* The following structure represents a user-defined encoding. It collects
|
1299 |
* together all the functions that are used by the specific encoding.
|
1300 |
*/
|
1301 |
|
1302 |
typedef struct Tcl_EncodingType {
|
1303 |
CONST char *encodingName; /* The name of the encoding, e.g. "euc-jp".
|
1304 |
* This name is the unique key for this
|
1305 |
* encoding type. */
|
1306 |
Tcl_EncodingConvertProc *toUtfProc;
|
1307 |
/* Procedure to convert from external
|
1308 |
* encoding into UTF-8. */
|
1309 |
Tcl_EncodingConvertProc *fromUtfProc;
|
1310 |
/* Procedure to convert from UTF-8 into
|
1311 |
* external encoding. */
|
1312 |
Tcl_EncodingFreeProc *freeProc;
|
1313 |
/* If non-NULL, procedure to call when this
|
1314 |
* encoding is deleted. */
|
1315 |
ClientData clientData; /* Arbitrary value associated with encoding
|
1316 |
* type. Passed to conversion procedures. */
|
1317 |
int nullSize; /* Number of zero bytes that signify
|
1318 |
* end-of-string in this encoding. This
|
1319 |
* number is used to determine the source
|
1320 |
* string length when the srcLen argument is
|
1321 |
* negative. Must be 1 or 2. */
|
1322 |
} Tcl_EncodingType;
|
1323 |
|
1324 |
/*
|
1325 |
* The following definitions are used as values for the conversion control
|
1326 |
* flags argument when converting text from one character set to another:
|
1327 |
*
|
1328 |
* TCL_ENCODING_START: Signifies that the source buffer is the first
|
1329 |
* block in a (potentially multi-block) input
|
1330 |
* stream. Tells the conversion procedure to
|
1331 |
* reset to an initial state and perform any
|
1332 |
* initialization that needs to occur before the
|
1333 |
* first byte is converted. If the source
|
1334 |
* buffer contains the entire input stream to be
|
1335 |
* converted, this flag should be set.
|
1336 |
*
|
1337 |
* TCL_ENCODING_END: Signifies that the source buffer is the last
|
1338 |
* block in a (potentially multi-block) input
|
1339 |
* stream. Tells the conversion routine to
|
1340 |
* perform any finalization that needs to occur
|
1341 |
* after the last byte is converted and then to
|
1342 |
* reset to an initial state. If the source
|
1343 |
* buffer contains the entire input stream to be
|
1344 |
* converted, this flag should be set.
|
1345 |
*
|
1346 |
* TCL_ENCODING_STOPONERROR: If set, then the converter will return
|
1347 |
* immediately upon encountering an invalid
|
1348 |
* byte sequence or a source character that has
|
1349 |
* no mapping in the target encoding. If clear,
|
1350 |
* then the converter will skip the problem,
|
1351 |
* substituting one or more "close" characters
|
1352 |
* in the destination buffer and then continue
|
1353 |
* to sonvert the source.
|
1354 |
*/
|
1355 |
|
1356 |
#define TCL_ENCODING_START 0x01
|
1357 |
#define TCL_ENCODING_END 0x02
|
1358 |
#define TCL_ENCODING_STOPONERROR 0x04
|
1359 |
|
1360 |
/*
|
1361 |
*----------------------------------------------------------------
|
1362 |
* The following data structures and declarations are for the new
|
1363 |
* Tcl parser. This stuff should all move to tcl.h eventually.
|
1364 |
*----------------------------------------------------------------
|
1365 |
*/
|
1366 |
|
1367 |
/*
|
1368 |
* For each word of a command, and for each piece of a word such as a
|
1369 |
* variable reference, one of the following structures is created to
|
1370 |
* describe the token.
|
1371 |
*/
|
1372 |
|
1373 |
typedef struct Tcl_Token {
|
1374 |
int type; /* Type of token, such as TCL_TOKEN_WORD;
|
1375 |
* see below for valid types. */
|
1376 |
char *start; /* First character in token. */
|
1377 |
int size; /* Number of bytes in token. */
|
1378 |
int numComponents; /* If this token is composed of other
|
1379 |
* tokens, this field tells how many of
|
1380 |
* them there are (including components of
|
1381 |
* components, etc.). The component tokens
|
1382 |
* immediately follow this one. */
|
1383 |
} Tcl_Token;
|
1384 |
|
1385 |
/*
|
1386 |
* Type values defined for Tcl_Token structures. These values are
|
1387 |
* defined as mask bits so that it's easy to check for collections of
|
1388 |
* types.
|
1389 |
*
|
1390 |
* TCL_TOKEN_WORD - The token describes one word of a command,
|
1391 |
* from the first non-blank character of
|
1392 |
* the word (which may be " or {) up to but
|
1393 |
* not including the space, semicolon, or
|
1394 |
* bracket that terminates the word.
|
1395 |
* NumComponents counts the total number of
|
1396 |
* sub-tokens that make up the word. This
|
1397 |
* includes, for example, sub-tokens of
|
1398 |
* TCL_TOKEN_VARIABLE tokens.
|
1399 |
* TCL_TOKEN_SIMPLE_WORD - This token is just like TCL_TOKEN_WORD
|
1400 |
* except that the word is guaranteed to
|
1401 |
* consist of a single TCL_TOKEN_TEXT
|
1402 |
* sub-token.
|
1403 |
* TCL_TOKEN_TEXT - The token describes a range of literal
|
1404 |
* text that is part of a word.
|
1405 |
* NumComponents is always 0.
|
1406 |
* TCL_TOKEN_BS - The token describes a backslash sequence
|
1407 |
* that must be collapsed. NumComponents
|
1408 |
* is always 0.
|
1409 |
* TCL_TOKEN_COMMAND - The token describes a command whose result
|
1410 |
* must be substituted into the word. The
|
1411 |
* token includes the enclosing brackets.
|
1412 |
* NumComponents is always 0.
|
1413 |
* TCL_TOKEN_VARIABLE - The token describes a variable
|
1414 |
* substitution, including the dollar sign,
|
1415 |
* variable name, and array index (if there
|
1416 |
* is one) up through the right
|
1417 |
* parentheses. NumComponents tells how
|
1418 |
* many additional tokens follow to
|
1419 |
* represent the variable name. The first
|
1420 |
* token will be a TCL_TOKEN_TEXT token
|
1421 |
* that describes the variable name. If
|
1422 |
* the variable is an array reference then
|
1423 |
* there will be one or more additional
|
1424 |
* tokens, of type TCL_TOKEN_TEXT,
|
1425 |
* TCL_TOKEN_BS, TCL_TOKEN_COMMAND, and
|
1426 |
* TCL_TOKEN_VARIABLE, that describe the
|
1427 |
* array index; numComponents counts the
|
1428 |
* total number of nested tokens that make
|
1429 |
* up the variable reference, including
|
1430 |
* sub-tokens of TCL_TOKEN_VARIABLE tokens.
|
1431 |
* TCL_TOKEN_SUB_EXPR - The token describes one subexpression of a
|
1432 |
* expression, from the first non-blank
|
1433 |
* character of the subexpression up to but not
|
1434 |
* including the space, brace, or bracket
|
1435 |
* that terminates the subexpression.
|
1436 |
* NumComponents counts the total number of
|
1437 |
* following subtokens that make up the
|
1438 |
* subexpression; this includes all subtokens
|
1439 |
* for any nested TCL_TOKEN_SUB_EXPR tokens.
|
1440 |
* For example, a numeric value used as a
|
1441 |
* primitive operand is described by a
|
1442 |
* TCL_TOKEN_SUB_EXPR token followed by a
|
1443 |
* TCL_TOKEN_TEXT token. A binary subexpression
|
1444 |
* is described by a TCL_TOKEN_SUB_EXPR token
|
1445 |
* followed by the TCL_TOKEN_OPERATOR token
|
1446 |
* for the operator, then TCL_TOKEN_SUB_EXPR
|
1447 |
* tokens for the left then the right operands.
|
1448 |
* TCL_TOKEN_OPERATOR - The token describes one expression operator.
|
1449 |
* An operator might be the name of a math
|
1450 |
* function such as "abs". A TCL_TOKEN_OPERATOR
|
1451 |
* token is always preceeded by one
|
1452 |
* TCL_TOKEN_SUB_EXPR token for the operator's
|
1453 |
* subexpression, and is followed by zero or
|
1454 |
* more TCL_TOKEN_SUB_EXPR tokens for the
|
1455 |
* operator's operands. NumComponents is
|
1456 |
* always 0.
|
1457 |
*/
|
1458 |
|
1459 |
#define TCL_TOKEN_WORD 1
|
1460 |
#define TCL_TOKEN_SIMPLE_WORD 2
|
1461 |
#define TCL_TOKEN_TEXT 4
|
1462 |
#define TCL_TOKEN_BS 8
|
1463 |
#define TCL_TOKEN_COMMAND 16
|
1464 |
#define TCL_TOKEN_VARIABLE 32
|
1465 |
#define TCL_TOKEN_SUB_EXPR 64
|
1466 |
#define TCL_TOKEN_OPERATOR 128
|
1467 |
|
1468 |
/*
|
1469 |
* Parsing error types. On any parsing error, one of these values
|
1470 |
* will be stored in the error field of the Tcl_Parse structure
|
1471 |
* defined below.
|
1472 |
*/
|
1473 |
|
1474 |
#define TCL_PARSE_SUCCESS 0
|
1475 |
#define TCL_PARSE_QUOTE_EXTRA 1
|
1476 |
#define TCL_PARSE_BRACE_EXTRA 2
|
1477 |
#define TCL_PARSE_MISSING_BRACE 3
|
1478 |
#define TCL_PARSE_MISSING_BRACKET 4
|
1479 |
#define TCL_PARSE_MISSING_PAREN 5
|
1480 |
#define TCL_PARSE_MISSING_QUOTE 6
|
1481 |
#define TCL_PARSE_MISSING_VAR_BRACE 7
|
1482 |
#define TCL_PARSE_SYNTAX 8
|
1483 |
#define TCL_PARSE_BAD_NUMBER 9
|
1484 |
|
1485 |
/*
|
1486 |
* A structure of the following type is filled in by Tcl_ParseCommand.
|
1487 |
* It describes a single command parsed from an input string.
|
1488 |
*/
|
1489 |
|
1490 |
#define NUM_STATIC_TOKENS 20
|
1491 |
|
1492 |
typedef struct Tcl_Parse {
|
1493 |
char *commentStart; /* Pointer to # that begins the first of
|
1494 |
* one or more comments preceding the
|
1495 |
* command. */
|
1496 |
int commentSize; /* Number of bytes in comments (up through
|
1497 |
* newline character that terminates the
|
1498 |
* last comment). If there were no
|
1499 |
* comments, this field is 0. */
|
1500 |
char *commandStart; /* First character in first word of command. */
|
1501 |
int commandSize; /* Number of bytes in command, including
|
1502 |
* first character of first word, up
|
1503 |
* through the terminating newline,
|
1504 |
* close bracket, or semicolon. */
|
1505 |
int numWords; /* Total number of words in command. May
|
1506 |
* be 0. */
|
1507 |
Tcl_Token *tokenPtr; /* Pointer to first token representing
|
1508 |
* the words of the command. Initially
|
1509 |
* points to staticTokens, but may change
|
1510 |
* to point to malloc-ed space if command
|
1511 |
* exceeds space in staticTokens. */
|
1512 |
int numTokens; /* Total number of tokens in command. */
|
1513 |
int tokensAvailable; /* Total number of tokens available at
|
1514 |
* *tokenPtr. */
|
1515 |
int errorType; /* One of the parsing error types defined
|
1516 |
* above. */
|
1517 |
|
1518 |
/*
|
1519 |
* The fields below are intended only for the private use of the
|
1520 |
* parser. They should not be used by procedures that invoke
|
1521 |
* Tcl_ParseCommand.
|
1522 |
*/
|
1523 |
|
1524 |
char *string; /* The original command string passed to
|
1525 |
* Tcl_ParseCommand. */
|
1526 |
char *end; /* Points to the character just after the
|
1527 |
* last one in the command string. */
|
1528 |
Tcl_Interp *interp; /* Interpreter to use for error reporting,
|
1529 |
* or NULL. */
|
1530 |
char *term; /* Points to character in string that
|
1531 |
* terminated most recent token. Filled in
|
1532 |
* by ParseTokens. If an error occurs,
|
1533 |
* points to beginning of region where the
|
1534 |
* error occurred (e.g. the open brace if
|
1535 |
* the close brace is missing). */
|
1536 |
int incomplete; /* This field is set to 1 by Tcl_ParseCommand
|
1537 |
* if the command appears to be incomplete.
|
1538 |
* This information is used by
|
1539 |
* Tcl_CommandComplete. */
|
1540 |
Tcl_Token staticTokens[NUM_STATIC_TOKENS];
|
1541 |
/* Initial space for tokens for command.
|
1542 |
* This space should be large enough to
|
1543 |
* accommodate most commands; dynamic
|
1544 |
* space is allocated for very large
|
1545 |
* commands that don't fit here. */
|
1546 |
} Tcl_Parse;
|
1547 |
|
1548 |
/*
|
1549 |
* The following definitions are the error codes returned by the conversion
|
1550 |
* routines:
|
1551 |
*
|
1552 |
* TCL_OK: All characters were converted.
|
1553 |
*
|
1554 |
* TCL_CONVERT_NOSPACE: The output buffer would not have been large
|
1555 |
* enough for all of the converted data; as many
|
1556 |
* characters as could fit were converted though.
|
1557 |
*
|
1558 |
* TCL_CONVERT_MULTIBYTE: The last few bytes in the source string were
|
1559 |
* the beginning of a multibyte sequence, but
|
1560 |
* more bytes were needed to complete this
|
1561 |
* sequence. A subsequent call to the conversion
|
1562 |
* routine should pass the beginning of this
|
1563 |
* unconverted sequence plus additional bytes
|
1564 |
* from the source stream to properly convert
|
1565 |
* the formerly split-up multibyte sequence.
|
1566 |
*
|
1567 |
* TCL_CONVERT_SYNTAX: The source stream contained an invalid
|
1568 |
* character sequence. This may occur if the
|
1569 |
* input stream has been damaged or if the input
|
1570 |
* encoding method was misidentified. This error
|
1571 |
* is reported only if TCL_ENCODING_STOPONERROR
|
1572 |
* was specified.
|
1573 |
*
|
1574 |
* TCL_CONVERT_UNKNOWN: The source string contained a character
|
1575 |
* that could not be represented in the target
|
1576 |
* encoding. This error is reported only if
|
1577 |
* TCL_ENCODING_STOPONERROR was specified.
|
1578 |
*/
|
1579 |
|
1580 |
#define TCL_CONVERT_MULTIBYTE -1
|
1581 |
#define TCL_CONVERT_SYNTAX -2
|
1582 |
#define TCL_CONVERT_UNKNOWN -3
|
1583 |
#define TCL_CONVERT_NOSPACE -4
|
1584 |
|
1585 |
/*
|
1586 |
* The maximum number of bytes that are necessary to represent a single
|
1587 |
* Unicode character in UTF-8.
|
1588 |
*/
|
1589 |
|
1590 |
#define TCL_UTF_MAX 3
|
1591 |
|
1592 |
/*
|
1593 |
* This represents a Unicode character.
|
1594 |
*/
|
1595 |
|
1596 |
typedef unsigned short Tcl_UniChar;
|
1597 |
|
1598 |
/*
|
1599 |
* Deprecated Tcl procedures:
|
1600 |
*/
|
1601 |
|
1602 |
#ifndef TCL_NO_DEPRECATED
|
1603 |
#define Tcl_EvalObj(interp,objPtr) Tcl_EvalObjEx((interp),(objPtr),0)
|
1604 |
#define Tcl_GlobalEvalObj(interp,objPtr) \
|
1605 |
Tcl_EvalObjEx((interp),(objPtr),TCL_EVAL_GLOBAL)
|
1606 |
#endif
|
1607 |
|
1608 |
/*
|
1609 |
* These function have been renamed. The old names are deprecated, but we
|
1610 |
* define these macros for backwards compatibilty.
|
1611 |
*/
|
1612 |
|
1613 |
#define Tcl_Ckalloc Tcl_Alloc
|
1614 |
#define Tcl_Ckfree Tcl_Free
|
1615 |
#define Tcl_Ckrealloc Tcl_Realloc
|
1616 |
#define Tcl_Return Tcl_SetResult
|
1617 |
#define Tcl_TildeSubst Tcl_TranslateFileName
|
1618 |
#define panic Tcl_Panic
|
1619 |
#define panicVA Tcl_PanicVA
|
1620 |
|
1621 |
/*
|
1622 |
* The following constant is used to test for older versions of Tcl
|
1623 |
* in the stubs tables.
|
1624 |
*
|
1625 |
* Jan Nijtman's plus patch uses 0xFCA1BACF, so we need to pick a different
|
1626 |
* value since the stubs tables don't match.
|
1627 |
*/
|
1628 |
|
1629 |
#define TCL_STUB_MAGIC 0xFCA3BACF
|
1630 |
|
1631 |
/*
|
1632 |
* The following function is required to be defined in all stubs aware
|
1633 |
* extensions. The function is actually implemented in the stub
|
1634 |
* library, not the main Tcl library, although there is a trivial
|
1635 |
* implementation in the main library in case an extension is statically
|
1636 |
* linked into an application.
|
1637 |
*/
|
1638 |
|
1639 |
EXTERN char * Tcl_InitStubs _ANSI_ARGS_((Tcl_Interp *interp,
|
1640 |
char *version, int exact));
|
1641 |
|
1642 |
#ifndef USE_TCL_STUBS
|
1643 |
|
1644 |
/*
|
1645 |
* When not using stubs, make it a macro.
|
1646 |
*/
|
1647 |
|
1648 |
#define Tcl_InitStubs(interp, version, exact) \
|
1649 |
Tcl_PkgRequire(interp, "Tcl", version, exact)
|
1650 |
|
1651 |
#endif
|
1652 |
|
1653 |
|
1654 |
/*
|
1655 |
* Include the public function declarations that are accessible via
|
1656 |
* the stubs table.
|
1657 |
*/
|
1658 |
|
1659 |
#include "tclDecls.h"
|
1660 |
|
1661 |
/*
|
1662 |
* Public functions that are not accessible via the stubs table.
|
1663 |
*/
|
1664 |
|
1665 |
EXTERN void Tcl_Main _ANSI_ARGS_((int argc, char **argv,
|
1666 |
Tcl_AppInitProc *appInitProc));
|
1667 |
|
1668 |
/*
|
1669 |
* Convenience declaration of Tcl_AppInit for backwards compatibility.
|
1670 |
* This function is not *implemented* by the tcl library, so the storage
|
1671 |
* class is neither DLLEXPORT nor DLLIMPORT
|
1672 |
*/
|
1673 |
|
1674 |
#undef TCL_STORAGE_CLASS
|
1675 |
#define TCL_STORAGE_CLASS
|
1676 |
|
1677 |
EXTERN int Tcl_AppInit _ANSI_ARGS_((Tcl_Interp *interp));
|
1678 |
|
1679 |
#endif /* RESOURCE_INCLUDED */
|
1680 |
|
1681 |
#undef TCL_STORAGE_CLASS
|
1682 |
#define TCL_STORAGE_CLASS DLLIMPORT
|
1683 |
|
1684 |
/*
|
1685 |
* end block for C++
|
1686 |
*/
|
1687 |
|
1688 |
#ifdef __cplusplus
|
1689 |
}
|
1690 |
#endif
|
1691 |
|
1692 |
#endif /* _TCL */
|
1693 |
|
1694 |
/* End of tcl.h */
|