Warning: That file was not part of the compilation database. It may have many parsing errors.
1 | /* |
---|---|
2 | * tcl.h -- |
3 | * |
4 | * This header file describes the externally-visible facilities of the |
5 | * Tcl interpreter. |
6 | * |
7 | * Copyright (c) 1987-1994 The Regents of the University of California. |
8 | * Copyright (c) 1993-1996 Lucent Technologies. |
9 | * Copyright (c) 1994-1998 Sun Microsystems, Inc. |
10 | * Copyright (c) 1998-2000 by Scriptics Corporation. |
11 | * Copyright (c) 2002 by Kevin B. Kenny. All rights reserved. |
12 | * |
13 | * See the file "license.terms" for information on usage and redistribution of |
14 | * this file, and for a DISCLAIMER OF ALL WARRANTIES. |
15 | */ |
16 | |
17 | #ifndef _TCL |
18 | #define _TCL |
19 | |
20 | /* |
21 | * For C++ compilers, use extern "C" |
22 | */ |
23 | |
24 | #ifdef __cplusplus |
25 | extern "C"{ |
26 | #endif |
27 | |
28 | /* |
29 | * The following defines are used to indicate the various release levels. |
30 | */ |
31 | |
32 | #define TCL_ALPHA_RELEASE 0 |
33 | #define TCL_BETA_RELEASE 1 |
34 | #define TCL_FINAL_RELEASE 2 |
35 | |
36 | /* |
37 | * When version numbers change here, must also go into the following files and |
38 | * update the version numbers: |
39 | * |
40 | * library/init.tcl (1 LOC patch) |
41 | * unix/configure.in (2 LOC Major, 2 LOC minor, 1 LOC patch) |
42 | * win/configure.in (as above) |
43 | * win/tcl.m4 (not patchlevel) |
44 | * win/makefile.bc (not patchlevel) 2 LOC |
45 | * README (sections 0 and 2, with and without separator) |
46 | * macosx/Tcl.pbproj/project.pbxproj (not patchlevel) 1 LOC |
47 | * macosx/Tcl.pbproj/default.pbxuser (not patchlevel) 1 LOC |
48 | * macosx/Tcl.xcode/project.pbxproj (not patchlevel) 2 LOC |
49 | * macosx/Tcl.xcode/default.pbxuser (not patchlevel) 1 LOC |
50 | * macosx/Tcl-Common.xcconfig (not patchlevel) 1 LOC |
51 | * win/README (not patchlevel) (sections 0 and 2) |
52 | * unix/tcl.spec (1 LOC patch) |
53 | * tools/tcl.hpj.in (not patchlevel, for windows installer) |
54 | */ |
55 | |
56 | #define TCL_MAJOR_VERSION 8 |
57 | #define TCL_MINOR_VERSION 6 |
58 | #define TCL_RELEASE_LEVEL TCL_FINAL_RELEASE |
59 | #define TCL_RELEASE_SERIAL 1 |
60 | |
61 | #define TCL_VERSION "8.6" |
62 | #define TCL_PATCH_LEVEL "8.6.1" |
63 | |
64 | /* |
65 | *---------------------------------------------------------------------------- |
66 | * The following definitions set up the proper options for Windows compilers. |
67 | * We use this method because there is no autoconf equivalent. |
68 | */ |
69 | |
70 | #ifndef __WIN32__ |
71 | # if defined(_WIN32) || defined(WIN32) || defined(__MINGW32__) || defined(__BORLANDC__) || (defined(__WATCOMC__) && defined(__WINDOWS_386__)) |
72 | # define __WIN32__ |
73 | # ifndef WIN32 |
74 | # define WIN32 |
75 | # endif |
76 | # ifndef _WIN32 |
77 | # define _WIN32 |
78 | # endif |
79 | # endif |
80 | #endif |
81 | |
82 | /* |
83 | * STRICT: See MSDN Article Q83456 |
84 | */ |
85 | |
86 | #ifdef __WIN32__ |
87 | # ifndef STRICT |
88 | # define STRICT |
89 | # endif |
90 | #endif /* __WIN32__ */ |
91 | |
92 | /* |
93 | * Utility macros: STRINGIFY takes an argument and wraps it in "" (double |
94 | * quotation marks), JOIN joins two arguments. |
95 | */ |
96 | |
97 | #ifndef STRINGIFY |
98 | # define STRINGIFY(x) STRINGIFY1(x) |
99 | # define STRINGIFY1(x) #x |
100 | #endif |
101 | #ifndef JOIN |
102 | # define JOIN(a,b) JOIN1(a,b) |
103 | # define JOIN1(a,b) a##b |
104 | #endif |
105 | |
106 | /* |
107 | * A special definition used to allow this header file to be included from |
108 | * windows resource files so that they can obtain version information. |
109 | * RC_INVOKED is defined by default by the windows RC tool. |
110 | * |
111 | * Resource compilers don't like all the C stuff, like typedefs and function |
112 | * declarations, that occur below, so block them out. |
113 | */ |
114 | |
115 | #ifndef RC_INVOKED |
116 | |
117 | /* |
118 | * Special macro to define mutexes, that doesn't do anything if we are not |
119 | * using threads. |
120 | */ |
121 | |
122 | #ifdef TCL_THREADS |
123 | #define TCL_DECLARE_MUTEX(name) static Tcl_Mutex name; |
124 | #else |
125 | #define TCL_DECLARE_MUTEX(name) |
126 | #endif |
127 | |
128 | /* |
129 | * Tcl's public routine Tcl_FSSeek() uses the values SEEK_SET, SEEK_CUR, and |
130 | * SEEK_END, all #define'd by stdio.h . |
131 | * |
132 | * Also, many extensions need stdio.h, and they've grown accustomed to tcl.h |
133 | * providing it for them rather than #include-ing it themselves as they |
134 | * should, so also for their sake, we keep the #include to be consistent with |
135 | * prior Tcl releases. |
136 | */ |
137 | |
138 | #include <stdio.h> |
139 | |
140 | /* |
141 | *---------------------------------------------------------------------------- |
142 | * Support for functions with a variable number of arguments. |
143 | * |
144 | * The following TCL_VARARGS* macros are to support old extensions |
145 | * written for older versions of Tcl where the macros permitted |
146 | * support for the varargs.h system as well as stdarg.h . |
147 | * |
148 | * New code should just directly be written to use stdarg.h conventions. |
149 | */ |
150 | |
151 | #include <stdarg.h> |
152 | #ifndef TCL_NO_DEPRECATED |
153 | # define TCL_VARARGS(type, name) (type name, ...) |
154 | # define TCL_VARARGS_DEF(type, name) (type name, ...) |
155 | # define TCL_VARARGS_START(type, name, list) (va_start(list, name), name) |
156 | #endif |
157 | #if defined(__GNUC__) && (__GNUC__ > 2) |
158 | # define TCL_FORMAT_PRINTF(a,b) __attribute__ ((__format__ (__printf__, a, b))) |
159 | #else |
160 | # define TCL_FORMAT_PRINTF(a,b) |
161 | #endif |
162 | |
163 | /* |
164 | * Allow a part of Tcl's API to be explicitly marked as deprecated. |
165 | * |
166 | * Used to make TIP 330/336 generate moans even if people use the |
167 | * compatibility macros. Change your code, guys! We won't support you forever. |
168 | */ |
169 | |
170 | #if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) |
171 | # if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC__MINOR__ >= 5)) |
172 | # define TCL_DEPRECATED_API(msg) __attribute__ ((__deprecated__ (msg))) |
173 | # else |
174 | # define TCL_DEPRECATED_API(msg) __attribute__ ((__deprecated__)) |
175 | # endif |
176 | #else |
177 | # define TCL_DEPRECATED_API(msg) /* nothing portable */ |
178 | #endif |
179 | |
180 | /* |
181 | *---------------------------------------------------------------------------- |
182 | * Macros used to declare a function to be exported by a DLL. Used by Windows, |
183 | * maps to no-op declarations on non-Windows systems. The default build on |
184 | * windows is for a DLL, which causes the DLLIMPORT and DLLEXPORT macros to be |
185 | * nonempty. To build a static library, the macro STATIC_BUILD should be |
186 | * defined. |
187 | * |
188 | * Note: when building static but linking dynamically to MSVCRT we must still |
189 | * correctly decorate the C library imported function. Use CRTIMPORT |
190 | * for this purpose. _DLL is defined by the compiler when linking to |
191 | * MSVCRT. |
192 | */ |
193 | |
194 | #if (defined(__WIN32__) && (defined(_MSC_VER) || (__BORLANDC__ >= 0x0550) || defined(__LCC__) || defined(__WATCOMC__) || (defined(__GNUC__) && defined(__declspec)))) |
195 | # define HAVE_DECLSPEC 1 |
196 | # ifdef STATIC_BUILD |
197 | # define DLLIMPORT |
198 | # define DLLEXPORT |
199 | # ifdef _DLL |
200 | # define CRTIMPORT __declspec(dllimport) |
201 | # else |
202 | # define CRTIMPORT |
203 | # endif |
204 | # else |
205 | # define DLLIMPORT __declspec(dllimport) |
206 | # define DLLEXPORT __declspec(dllexport) |
207 | # define CRTIMPORT __declspec(dllimport) |
208 | # endif |
209 | #else |
210 | # define DLLIMPORT |
211 | # if defined(__GNUC__) && __GNUC__ > 3 |
212 | # define DLLEXPORT __attribute__ ((visibility("default"))) |
213 | # else |
214 | # define DLLEXPORT |
215 | # endif |
216 | # define CRTIMPORT |
217 | #endif |
218 | |
219 | /* |
220 | * These macros are used to control whether functions are being declared for |
221 | * import or export. If a function is being declared while it is being built |
222 | * to be included in a shared library, then it should have the DLLEXPORT |
223 | * storage class. If is being declared for use by a module that is going to |
224 | * link against the shared library, then it should have the DLLIMPORT storage |
225 | * class. If the symbol is beind declared for a static build or for use from a |
226 | * stub library, then the storage class should be empty. |
227 | * |
228 | * The convention is that a macro called BUILD_xxxx, where xxxx is the name of |
229 | * a library we are building, is set on the compile line for sources that are |
230 | * to be placed in the library. When this macro is set, the storage class will |
231 | * be set to DLLEXPORT. At the end of the header file, the storage class will |
232 | * be reset to DLLIMPORT. |
233 | */ |
234 | |
235 | #undef TCL_STORAGE_CLASS |
236 | #ifdef BUILD_tcl |
237 | # define TCL_STORAGE_CLASS DLLEXPORT |
238 | #else |
239 | # ifdef USE_TCL_STUBS |
240 | # define TCL_STORAGE_CLASS |
241 | # else |
242 | # define TCL_STORAGE_CLASS DLLIMPORT |
243 | # endif |
244 | #endif |
245 | |
246 | /* |
247 | * The following _ANSI_ARGS_ macro is to support old extensions |
248 | * written for older versions of Tcl where it permitted support |
249 | * for compilers written in the pre-prototype era of C. |
250 | * |
251 | * New code should use prototypes. |
252 | */ |
253 | |
254 | #ifndef TCL_NO_DEPRECATED |
255 | # undef _ANSI_ARGS_ |
256 | # define _ANSI_ARGS_(x) x |
257 | #endif |
258 | |
259 | /* |
260 | * Definitions that allow this header file to be used either with or without |
261 | * ANSI C features. |
262 | */ |
263 | |
264 | #ifndef INLINE |
265 | # define INLINE |
266 | #endif |
267 | |
268 | #ifdef NO_CONST |
269 | # ifndef const |
270 | # define const |
271 | # endif |
272 | #endif |
273 | #ifndef CONST |
274 | # define CONST const |
275 | #endif |
276 | |
277 | #ifdef USE_NON_CONST |
278 | # ifdef USE_COMPAT_CONST |
279 | # error define at most one of USE_NON_CONST and USE_COMPAT_CONST |
280 | # endif |
281 | # define CONST84 |
282 | # define CONST84_RETURN |
283 | #else |
284 | # ifdef USE_COMPAT_CONST |
285 | # define CONST84 |
286 | # define CONST84_RETURN const |
287 | # else |
288 | # define CONST84 const |
289 | # define CONST84_RETURN const |
290 | # endif |
291 | #endif |
292 | |
293 | #ifndef CONST86 |
294 | # define CONST86 CONST84 |
295 | #endif |
296 | |
297 | /* |
298 | * Make sure EXTERN isn't defined elsewhere. |
299 | */ |
300 | |
301 | #ifdef EXTERN |
302 | # undef EXTERN |
303 | #endif /* EXTERN */ |
304 | |
305 | #ifdef __cplusplus |
306 | # define EXTERN extern "C" TCL_STORAGE_CLASS |
307 | #else |
308 | # define EXTERN extern TCL_STORAGE_CLASS |
309 | #endif |
310 | |
311 | /* |
312 | *---------------------------------------------------------------------------- |
313 | * The following code is copied from winnt.h. If we don't replicate it here, |
314 | * then <windows.h> can't be included after tcl.h, since tcl.h also defines |
315 | * VOID. This block is skipped under Cygwin and Mingw. |
316 | */ |
317 | |
318 | #if defined(__WIN32__) && !defined(HAVE_WINNT_IGNORE_VOID) |
319 | #ifndef VOID |
320 | #define VOID void |
321 | typedef char CHAR; |
322 | typedef short SHORT; |
323 | typedef long LONG; |
324 | #endif |
325 | #endif /* __WIN32__ && !HAVE_WINNT_IGNORE_VOID */ |
326 | |
327 | /* |
328 | * Macro to use instead of "void" for arguments that must have type "void *" |
329 | * in ANSI C; maps them to type "char *" in non-ANSI systems. |
330 | */ |
331 | |
332 | #ifndef __VXWORKS__ |
333 | # ifndef NO_VOID |
334 | # define VOID void |
335 | # else |
336 | # define VOID char |
337 | # endif |
338 | #endif |
339 | |
340 | /* |
341 | * Miscellaneous declarations. |
342 | */ |
343 | |
344 | #ifndef _CLIENTDATA |
345 | # ifndef NO_VOID |
346 | typedef void *ClientData; |
347 | # else |
348 | typedef int *ClientData; |
349 | # endif |
350 | # define _CLIENTDATA |
351 | #endif |
352 | |
353 | /* |
354 | * Darwin specific configure overrides (to support fat compiles, where |
355 | * configure runs only once for multiple architectures): |
356 | */ |
357 | |
358 | #ifdef __APPLE__ |
359 | # ifdef __LP64__ |
360 | # undef TCL_WIDE_INT_TYPE |
361 | # define TCL_WIDE_INT_IS_LONG 1 |
362 | # define TCL_CFG_DO64BIT 1 |
363 | # else /* !__LP64__ */ |
364 | # define TCL_WIDE_INT_TYPE long long |
365 | # undef TCL_WIDE_INT_IS_LONG |
366 | # undef TCL_CFG_DO64BIT |
367 | # endif /* __LP64__ */ |
368 | # undef HAVE_STRUCT_STAT64 |
369 | #endif /* __APPLE__ */ |
370 | |
371 | /* |
372 | * Define Tcl_WideInt to be a type that is (at least) 64-bits wide, and define |
373 | * Tcl_WideUInt to be the unsigned variant of that type (assuming that where |
374 | * we have one, we can have the other.) |
375 | * |
376 | * Also defines the following macros: |
377 | * TCL_WIDE_INT_IS_LONG - if wide ints are really longs (i.e. we're on a real |
378 | * 64-bit system.) |
379 | * Tcl_WideAsLong - forgetful converter from wideInt to long. |
380 | * Tcl_LongAsWide - sign-extending converter from long to wideInt. |
381 | * Tcl_WideAsDouble - converter from wideInt to double. |
382 | * Tcl_DoubleAsWide - converter from double to wideInt. |
383 | * |
384 | * The following invariant should hold for any long value 'longVal': |
385 | * longVal == Tcl_WideAsLong(Tcl_LongAsWide(longVal)) |
386 | * |
387 | * Note on converting between Tcl_WideInt and strings. This implementation (in |
388 | * tclObj.c) depends on the function |
389 | * sprintf(...,"%" TCL_LL_MODIFIER "d",...). |
390 | */ |
391 | |
392 | #if !defined(TCL_WIDE_INT_TYPE)&&!defined(TCL_WIDE_INT_IS_LONG) |
393 | # if defined(__WIN32__) |
394 | # define TCL_WIDE_INT_TYPE __int64 |
395 | # ifdef __BORLANDC__ |
396 | # define TCL_LL_MODIFIER "L" |
397 | # else /* __BORLANDC__ */ |
398 | # define TCL_LL_MODIFIER "I64" |
399 | # endif /* __BORLANDC__ */ |
400 | # elif defined(__GNUC__) |
401 | # define TCL_WIDE_INT_TYPE long long |
402 | # define TCL_LL_MODIFIER "ll" |
403 | # else /* ! __WIN32__ && ! __GNUC__ */ |
404 | /* |
405 | * Don't know what platform it is and configure hasn't discovered what is |
406 | * going on for us. Try to guess... |
407 | */ |
408 | # ifdef NO_LIMITS_H |
409 | # error please define either TCL_WIDE_INT_TYPE or TCL_WIDE_INT_IS_LONG |
410 | # else /* !NO_LIMITS_H */ |
411 | # include <limits.h> |
412 | # if (INT_MAX < LONG_MAX) |
413 | # define TCL_WIDE_INT_IS_LONG 1 |
414 | # else |
415 | # define TCL_WIDE_INT_TYPE long long |
416 | # endif |
417 | # endif /* NO_LIMITS_H */ |
418 | # endif /* __WIN32__ */ |
419 | #endif /* !TCL_WIDE_INT_TYPE & !TCL_WIDE_INT_IS_LONG */ |
420 | #ifdef TCL_WIDE_INT_IS_LONG |
421 | # undef TCL_WIDE_INT_TYPE |
422 | # define TCL_WIDE_INT_TYPE long |
423 | #endif /* TCL_WIDE_INT_IS_LONG */ |
424 | |
425 | typedef TCL_WIDE_INT_TYPE Tcl_WideInt; |
426 | typedef unsigned TCL_WIDE_INT_TYPE Tcl_WideUInt; |
427 | |
428 | #ifdef TCL_WIDE_INT_IS_LONG |
429 | # define Tcl_WideAsLong(val) ((long)(val)) |
430 | # define Tcl_LongAsWide(val) ((long)(val)) |
431 | # define Tcl_WideAsDouble(val) ((double)((long)(val))) |
432 | # define Tcl_DoubleAsWide(val) ((long)((double)(val))) |
433 | # ifndef TCL_LL_MODIFIER |
434 | # define TCL_LL_MODIFIER "l" |
435 | # endif /* !TCL_LL_MODIFIER */ |
436 | #else /* TCL_WIDE_INT_IS_LONG */ |
437 | /* |
438 | * The next short section of defines are only done when not running on Windows |
439 | * or some other strange platform. |
440 | */ |
441 | # ifndef TCL_LL_MODIFIER |
442 | # define TCL_LL_MODIFIER "ll" |
443 | # endif /* !TCL_LL_MODIFIER */ |
444 | # define Tcl_WideAsLong(val) ((long)((Tcl_WideInt)(val))) |
445 | # define Tcl_LongAsWide(val) ((Tcl_WideInt)((long)(val))) |
446 | # define Tcl_WideAsDouble(val) ((double)((Tcl_WideInt)(val))) |
447 | # define Tcl_DoubleAsWide(val) ((Tcl_WideInt)((double)(val))) |
448 | #endif /* TCL_WIDE_INT_IS_LONG */ |
449 | |
450 | #if defined(__WIN32__) |
451 | # ifdef __BORLANDC__ |
452 | typedef struct stati64 Tcl_StatBuf; |
453 | # elif defined(_WIN64) |
454 | typedef struct __stat64 Tcl_StatBuf; |
455 | # elif (defined(_MSC_VER) && (_MSC_VER < 1400)) || defined(_USE_32BIT_TIME_T) |
456 | typedef struct _stati64 Tcl_StatBuf; |
457 | # else |
458 | typedef struct _stat32i64 Tcl_StatBuf; |
459 | # endif /* _MSC_VER < 1400 */ |
460 | #elif defined(__CYGWIN__) |
461 | typedef struct _stat32i64 { |
462 | dev_t st_dev; |
463 | unsigned short st_ino; |
464 | unsigned short st_mode; |
465 | short st_nlink; |
466 | short st_uid; |
467 | short st_gid; |
468 | /* Here is a 2-byte gap */ |
469 | dev_t st_rdev; |
470 | /* Here is a 4-byte gap */ |
471 | long long st_size; |
472 | struct {long tv_sec;} st_atim; |
473 | struct {long tv_sec;} st_mtim; |
474 | struct {long tv_sec;} st_ctim; |
475 | /* Here is a 4-byte gap */ |
476 | } Tcl_StatBuf; |
477 | #elif defined(HAVE_STRUCT_STAT64) && !defined(__APPLE__) |
478 | typedef struct stat64 Tcl_StatBuf; |
479 | #else |
480 | typedef struct stat Tcl_StatBuf; |
481 | #endif |
482 | |
483 | /* |
484 | *---------------------------------------------------------------------------- |
485 | * Data structures defined opaquely in this module. The definitions below just |
486 | * provide dummy types. A few fields are made visible in Tcl_Interp |
487 | * structures, namely those used for returning a string result from commands. |
488 | * Direct access to the result field is discouraged in Tcl 8.0. The |
489 | * interpreter result is either an object or a string, and the two values are |
490 | * kept consistent unless some C code sets interp->result directly. |
491 | * Programmers should use either the function Tcl_GetObjResult() or |
492 | * Tcl_GetStringResult() to read the interpreter's result. See the SetResult |
493 | * man page for details. |
494 | * |
495 | * Note: any change to the Tcl_Interp definition below must be mirrored in the |
496 | * "real" definition in tclInt.h. |
497 | * |
498 | * Note: Tcl_ObjCmdProc functions do not directly set result and freeProc. |
499 | * Instead, they set a Tcl_Obj member in the "real" structure that can be |
500 | * accessed with Tcl_GetObjResult() and Tcl_SetObjResult(). |
501 | */ |
502 | |
503 | typedef struct Tcl_Interp |
504 | #ifndef TCL_NO_DEPRECATED |
505 | { |
506 | /* TIP #330: Strongly discourage extensions from using the string |
507 | * result. */ |
508 | #ifdef USE_INTERP_RESULT |
509 | char *result TCL_DEPRECATED_API("use Tcl_GetStringResult/Tcl_SetResult"); |
510 | /* If the last command returned a string |
511 | * result, this points to it. */ |
512 | void (*freeProc) (char *blockPtr) |
513 | TCL_DEPRECATED_API("use Tcl_GetStringResult/Tcl_SetResult"); |
514 | /* Zero means the string result is statically |
515 | * allocated. TCL_DYNAMIC means it was |
516 | * allocated with ckalloc and should be freed |
517 | * with ckfree. Other values give the address |
518 | * of function to invoke to free the result. |
519 | * Tcl_Eval must free it before executing next |
520 | * command. */ |
521 | #else |
522 | char *resultDontUse; /* Don't use in extensions! */ |
523 | void (*freeProcDontUse) (char *); /* Don't use in extensions! */ |
524 | #endif |
525 | #ifdef USE_INTERP_ERRORLINE |
526 | int errorLine TCL_DEPRECATED_API("use Tcl_GetErrorLine/Tcl_SetErrorLine"); |
527 | /* When TCL_ERROR is returned, this gives the |
528 | * line number within the command where the |
529 | * error occurred (1 if first line). */ |
530 | #else |
531 | int errorLineDontUse; /* Don't use in extensions! */ |
532 | #endif |
533 | } |
534 | #endif /* TCL_NO_DEPRECATED */ |
535 | Tcl_Interp; |
536 | |
537 | typedef struct Tcl_AsyncHandler_ *Tcl_AsyncHandler; |
538 | typedef struct Tcl_Channel_ *Tcl_Channel; |
539 | typedef struct Tcl_ChannelTypeVersion_ *Tcl_ChannelTypeVersion; |
540 | typedef struct Tcl_Command_ *Tcl_Command; |
541 | typedef struct Tcl_Condition_ *Tcl_Condition; |
542 | typedef struct Tcl_Dict_ *Tcl_Dict; |
543 | typedef struct Tcl_EncodingState_ *Tcl_EncodingState; |
544 | typedef struct Tcl_Encoding_ *Tcl_Encoding; |
545 | typedef struct Tcl_Event Tcl_Event; |
546 | typedef struct Tcl_InterpState_ *Tcl_InterpState; |
547 | typedef struct Tcl_LoadHandle_ *Tcl_LoadHandle; |
548 | typedef struct Tcl_Mutex_ *Tcl_Mutex; |
549 | typedef struct Tcl_Pid_ *Tcl_Pid; |
550 | typedef struct Tcl_RegExp_ *Tcl_RegExp; |
551 | typedef struct Tcl_ThreadDataKey_ *Tcl_ThreadDataKey; |
552 | typedef struct Tcl_ThreadId_ *Tcl_ThreadId; |
553 | typedef struct Tcl_TimerToken_ *Tcl_TimerToken; |
554 | typedef struct Tcl_Trace_ *Tcl_Trace; |
555 | typedef struct Tcl_Var_ *Tcl_Var; |
556 | typedef struct Tcl_ZLibStream_ *Tcl_ZlibStream; |
557 | |
558 | /* |
559 | *---------------------------------------------------------------------------- |
560 | * Definition of the interface to functions implementing threads. A function |
561 | * following this definition is given to each call of 'Tcl_CreateThread' and |
562 | * will be called as the main fuction of the new thread created by that call. |
563 | */ |
564 | |
565 | #if defined __WIN32__ |
566 | typedef unsigned (__stdcall Tcl_ThreadCreateProc) (ClientData clientData); |
567 | #else |
568 | typedef void (Tcl_ThreadCreateProc) (ClientData clientData); |
569 | #endif |
570 | |
571 | /* |
572 | * Threading function return types used for abstracting away platform |
573 | * differences when writing a Tcl_ThreadCreateProc. See the NewThread function |
574 | * in generic/tclThreadTest.c for it's usage. |
575 | */ |
576 | |
577 | #if defined __WIN32__ |
578 | # define Tcl_ThreadCreateType unsigned __stdcall |
579 | # define TCL_THREAD_CREATE_RETURN return 0 |
580 | #else |
581 | # define Tcl_ThreadCreateType void |
582 | # define TCL_THREAD_CREATE_RETURN |
583 | #endif |
584 | |
585 | /* |
586 | * Definition of values for default stacksize and the possible flags to be |
587 | * given to Tcl_CreateThread. |
588 | */ |
589 | |
590 | #define TCL_THREAD_STACK_DEFAULT (0) /* Use default size for stack. */ |
591 | #define TCL_THREAD_NOFLAGS (0000) /* Standard flags, default |
592 | * behaviour. */ |
593 | #define TCL_THREAD_JOINABLE (0001) /* Mark the thread as joinable. */ |
594 | |
595 | /* |
596 | * Flag values passed to Tcl_StringCaseMatch. |
597 | */ |
598 | |
599 | #define TCL_MATCH_NOCASE (1<<0) |
600 | |
601 | /* |
602 | * Flag values passed to Tcl_GetRegExpFromObj. |
603 | */ |
604 | |
605 | #define TCL_REG_BASIC 000000 /* BREs (convenience). */ |
606 | #define TCL_REG_EXTENDED 000001 /* EREs. */ |
607 | #define TCL_REG_ADVF 000002 /* Advanced features in EREs. */ |
608 | #define TCL_REG_ADVANCED 000003 /* AREs (which are also EREs). */ |
609 | #define TCL_REG_QUOTE 000004 /* No special characters, none. */ |
610 | #define TCL_REG_NOCASE 000010 /* Ignore case. */ |
611 | #define TCL_REG_NOSUB 000020 /* Don't care about subexpressions. */ |
612 | #define TCL_REG_EXPANDED 000040 /* Expanded format, white space & |
613 | * comments. */ |
614 | #define TCL_REG_NLSTOP 000100 /* \n doesn't match . or [^ ] */ |
615 | #define TCL_REG_NLANCH 000200 /* ^ matches after \n, $ before. */ |
616 | #define TCL_REG_NEWLINE 000300 /* Newlines are line terminators. */ |
617 | #define TCL_REG_CANMATCH 001000 /* Report details on partial/limited |
618 | * matches. */ |
619 | |
620 | /* |
621 | * Flags values passed to Tcl_RegExpExecObj. |
622 | */ |
623 | |
624 | #define TCL_REG_NOTBOL 0001 /* Beginning of string does not match ^. */ |
625 | #define TCL_REG_NOTEOL 0002 /* End of string does not match $. */ |
626 | |
627 | /* |
628 | * Structures filled in by Tcl_RegExpInfo. Note that all offset values are |
629 | * relative to the start of the match string, not the beginning of the entire |
630 | * string. |
631 | */ |
632 | |
633 | typedef struct Tcl_RegExpIndices { |
634 | long start; /* Character offset of first character in |
635 | * match. */ |
636 | long end; /* Character offset of first character after |
637 | * the match. */ |
638 | } Tcl_RegExpIndices; |
639 | |
640 | typedef struct Tcl_RegExpInfo { |
641 | int nsubs; /* Number of subexpressions in the compiled |
642 | * expression. */ |
643 | Tcl_RegExpIndices *matches; /* Array of nsubs match offset pairs. */ |
644 | long extendStart; /* The offset at which a subsequent match |
645 | * might begin. */ |
646 | long reserved; /* Reserved for later use. */ |
647 | } Tcl_RegExpInfo; |
648 | |
649 | /* |
650 | * Picky compilers complain if this typdef doesn't appear before the struct's |
651 | * reference in tclDecls.h. |
652 | */ |
653 | |
654 | typedef Tcl_StatBuf *Tcl_Stat_; |
655 | typedef struct stat *Tcl_OldStat_; |
656 | |
657 | /* |
658 | *---------------------------------------------------------------------------- |
659 | * When a TCL command returns, the interpreter contains a result from the |
660 | * command. Programmers are strongly encouraged to use one of the functions |
661 | * Tcl_GetObjResult() or Tcl_GetStringResult() to read the interpreter's |
662 | * result. See the SetResult man page for details. Besides this result, the |
663 | * command function returns an integer code, which is one of the following: |
664 | * |
665 | * TCL_OK Command completed normally; the interpreter's result |
666 | * contains the command's result. |
667 | * TCL_ERROR The command couldn't be completed successfully; the |
668 | * interpreter's result describes what went wrong. |
669 | * TCL_RETURN The command requests that the current function return; |
670 | * the interpreter's result contains the function's |
671 | * return value. |
672 | * TCL_BREAK The command requests that the innermost loop be |
673 | * exited; the interpreter's result is meaningless. |
674 | * TCL_CONTINUE Go on to the next iteration of the current loop; the |
675 | * interpreter's result is meaningless. |
676 | */ |
677 | |
678 | #define TCL_OK 0 |
679 | #define TCL_ERROR 1 |
680 | #define TCL_RETURN 2 |
681 | #define TCL_BREAK 3 |
682 | #define TCL_CONTINUE 4 |
683 | |
684 | #define TCL_RESULT_SIZE 200 |
685 | |
686 | /* |
687 | *---------------------------------------------------------------------------- |
688 | * Flags to control what substitutions are performed by Tcl_SubstObj(): |
689 | */ |
690 | |
691 | #define TCL_SUBST_COMMANDS 001 |
692 | #define TCL_SUBST_VARIABLES 002 |
693 | #define TCL_SUBST_BACKSLASHES 004 |
694 | #define TCL_SUBST_ALL 007 |
695 | |
696 | /* |
697 | * Argument descriptors for math function callbacks in expressions: |
698 | */ |
699 | |
700 | typedef enum { |
701 | TCL_INT, TCL_DOUBLE, TCL_EITHER, TCL_WIDE_INT |
702 | } Tcl_ValueType; |
703 | |
704 | typedef struct Tcl_Value { |
705 | Tcl_ValueType type; /* Indicates intValue or doubleValue is valid, |
706 | * or both. */ |
707 | long intValue; /* Integer value. */ |
708 | double doubleValue; /* Double-precision floating value. */ |
709 | Tcl_WideInt wideValue; /* Wide (min. 64-bit) integer value. */ |
710 | } Tcl_Value; |
711 | |
712 | /* |
713 | * Forward declaration of Tcl_Obj to prevent an error when the forward |
714 | * reference to Tcl_Obj is encountered in the function types declared below. |
715 | */ |
716 | |
717 | struct Tcl_Obj; |
718 | |
719 | /* |
720 | *---------------------------------------------------------------------------- |
721 | * Function types defined by Tcl: |
722 | */ |
723 | |
724 | typedef int (Tcl_AppInitProc) (Tcl_Interp *interp); |
725 | typedef int (Tcl_AsyncProc) (ClientData clientData, Tcl_Interp *interp, |
726 | int code); |
727 | typedef void (Tcl_ChannelProc) (ClientData clientData, int mask); |
728 | typedef void (Tcl_CloseProc) (ClientData data); |
729 | typedef void (Tcl_CmdDeleteProc) (ClientData clientData); |
730 | typedef int (Tcl_CmdProc) (ClientData clientData, Tcl_Interp *interp, |
731 | int argc, CONST84 char *argv[]); |
732 | typedef void (Tcl_CmdTraceProc) (ClientData clientData, Tcl_Interp *interp, |
733 | int level, char *command, Tcl_CmdProc *proc, |
734 | ClientData cmdClientData, int argc, CONST84 char *argv[]); |
735 | typedef int (Tcl_CmdObjTraceProc) (ClientData clientData, Tcl_Interp *interp, |
736 | int level, const char *command, Tcl_Command commandInfo, int objc, |
737 | struct Tcl_Obj *const *objv); |
738 | typedef void (Tcl_CmdObjTraceDeleteProc) (ClientData clientData); |
739 | typedef void (Tcl_DupInternalRepProc) (struct Tcl_Obj *srcPtr, |
740 | struct Tcl_Obj *dupPtr); |
741 | typedef int (Tcl_EncodingConvertProc) (ClientData clientData, const char *src, |
742 | int srcLen, int flags, Tcl_EncodingState *statePtr, char *dst, |
743 | int dstLen, int *srcReadPtr, int *dstWrotePtr, int *dstCharsPtr); |
744 | typedef void (Tcl_EncodingFreeProc) (ClientData clientData); |
745 | typedef int (Tcl_EventProc) (Tcl_Event *evPtr, int flags); |
746 | typedef void (Tcl_EventCheckProc) (ClientData clientData, int flags); |
747 | typedef int (Tcl_EventDeleteProc) (Tcl_Event *evPtr, ClientData clientData); |
748 | typedef void (Tcl_EventSetupProc) (ClientData clientData, int flags); |
749 | typedef void (Tcl_ExitProc) (ClientData clientData); |
750 | typedef void (Tcl_FileProc) (ClientData clientData, int mask); |
751 | typedef void (Tcl_FileFreeProc) (ClientData clientData); |
752 | typedef void (Tcl_FreeInternalRepProc) (struct Tcl_Obj *objPtr); |
753 | typedef void (Tcl_FreeProc) (char *blockPtr); |
754 | typedef void (Tcl_IdleProc) (ClientData clientData); |
755 | typedef void (Tcl_InterpDeleteProc) (ClientData clientData, |
756 | Tcl_Interp *interp); |
757 | typedef int (Tcl_MathProc) (ClientData clientData, Tcl_Interp *interp, |
758 | Tcl_Value *args, Tcl_Value *resultPtr); |
759 | typedef void (Tcl_NamespaceDeleteProc) (ClientData clientData); |
760 | typedef int (Tcl_ObjCmdProc) (ClientData clientData, Tcl_Interp *interp, |
761 | int objc, struct Tcl_Obj *const *objv); |
762 | typedef int (Tcl_PackageInitProc) (Tcl_Interp *interp); |
763 | typedef int (Tcl_PackageUnloadProc) (Tcl_Interp *interp, int flags); |
764 | typedef void (Tcl_PanicProc) (const char *format, ...); |
765 | typedef void (Tcl_TcpAcceptProc) (ClientData callbackData, Tcl_Channel chan, |
766 | char *address, int port); |
767 | typedef void (Tcl_TimerProc) (ClientData clientData); |
768 | typedef int (Tcl_SetFromAnyProc) (Tcl_Interp *interp, struct Tcl_Obj *objPtr); |
769 | typedef void (Tcl_UpdateStringProc) (struct Tcl_Obj *objPtr); |
770 | typedef char * (Tcl_VarTraceProc) (ClientData clientData, Tcl_Interp *interp, |
771 | CONST84 char *part1, CONST84 char *part2, int flags); |
772 | typedef void (Tcl_CommandTraceProc) (ClientData clientData, Tcl_Interp *interp, |
773 | const char *oldName, const char *newName, int flags); |
774 | typedef void (Tcl_CreateFileHandlerProc) (int fd, int mask, Tcl_FileProc *proc, |
775 | ClientData clientData); |
776 | typedef void (Tcl_DeleteFileHandlerProc) (int fd); |
777 | typedef void (Tcl_AlertNotifierProc) (ClientData clientData); |
778 | typedef void (Tcl_ServiceModeHookProc) (int mode); |
779 | typedef ClientData (Tcl_InitNotifierProc) (void); |
780 | typedef void (Tcl_FinalizeNotifierProc) (ClientData clientData); |
781 | typedef void (Tcl_MainLoopProc) (void); |
782 | |
783 | /* |
784 | *---------------------------------------------------------------------------- |
785 | * The following structure represents a type of object, which is a particular |
786 | * internal representation for an object plus a set of functions that provide |
787 | * standard operations on objects of that type. |
788 | */ |
789 | |
790 | typedef struct Tcl_ObjType { |
791 | const char *name; /* Name of the type, e.g. "int". */ |
792 | Tcl_FreeInternalRepProc *freeIntRepProc; |
793 | /* Called to free any storage for the type's |
794 | * internal rep. NULL if the internal rep does |
795 | * not need freeing. */ |
796 | Tcl_DupInternalRepProc *dupIntRepProc; |
797 | /* Called to create a new object as a copy of |
798 | * an existing object. */ |
799 | Tcl_UpdateStringProc *updateStringProc; |
800 | /* Called to update the string rep from the |
801 | * type's internal representation. */ |
802 | Tcl_SetFromAnyProc *setFromAnyProc; |
803 | /* Called to convert the object's internal rep |
804 | * to this type. Frees the internal rep of the |
805 | * old type. Returns TCL_ERROR on failure. */ |
806 | } Tcl_ObjType; |
807 | |
808 | /* |
809 | * One of the following structures exists for each object in the Tcl system. |
810 | * An object stores a value as either a string, some internal representation, |
811 | * or both. |
812 | */ |
813 | |
814 | typedef struct Tcl_Obj { |
815 | int refCount; /* When 0 the object will be freed. */ |
816 | char *bytes; /* This points to the first byte of the |
817 | * object's string representation. The array |
818 | * must be followed by a null byte (i.e., at |
819 | * offset length) but may also contain |
820 | * embedded null characters. The array's |
821 | * storage is allocated by ckalloc. NULL means |
822 | * the string rep is invalid and must be |
823 | * regenerated from the internal rep. Clients |
824 | * should use Tcl_GetStringFromObj or |
825 | * Tcl_GetString to get a pointer to the byte |
826 | * array as a readonly value. */ |
827 | int length; /* The number of bytes at *bytes, not |
828 | * including the terminating null. */ |
829 | const Tcl_ObjType *typePtr; /* Denotes the object's type. Always |
830 | * corresponds to the type of the object's |
831 | * internal rep. NULL indicates the object has |
832 | * no internal rep (has no type). */ |
833 | union { /* The internal representation: */ |
834 | long longValue; /* - an long integer value. */ |
835 | double doubleValue; /* - a double-precision floating value. */ |
836 | void *otherValuePtr; /* - another, type-specific value. */ |
837 | Tcl_WideInt wideValue; /* - a long long value. */ |
838 | struct { /* - internal rep as two pointers. */ |
839 | void *ptr1; |
840 | void *ptr2; |
841 | } twoPtrValue; |
842 | struct { /* - internal rep as a pointer and a long, |
843 | * the main use of which is a bignum's |
844 | * tightly packed fields, where the alloc, |
845 | * used and signum flags are packed into a |
846 | * single word with everything else hung |
847 | * off the pointer. */ |
848 | void *ptr; |
849 | unsigned long value; |
850 | } ptrAndLongRep; |
851 | } internalRep; |
852 | } Tcl_Obj; |
853 | |
854 | /* |
855 | * Macros to increment and decrement a Tcl_Obj's reference count, and to test |
856 | * whether an object is shared (i.e. has reference count > 1). Note: clients |
857 | * should use Tcl_DecrRefCount() when they are finished using an object, and |
858 | * should never call TclFreeObj() directly. TclFreeObj() is only defined and |
859 | * made public in tcl.h to support Tcl_DecrRefCount's macro definition. |
860 | */ |
861 | |
862 | void Tcl_IncrRefCount(Tcl_Obj *objPtr); |
863 | void Tcl_DecrRefCount(Tcl_Obj *objPtr); |
864 | int Tcl_IsShared(Tcl_Obj *objPtr); |
865 | |
866 | /* |
867 | *---------------------------------------------------------------------------- |
868 | * The following structure contains the state needed by Tcl_SaveResult. No-one |
869 | * outside of Tcl should access any of these fields. This structure is |
870 | * typically allocated on the stack. |
871 | */ |
872 | |
873 | typedef struct Tcl_SavedResult { |
874 | char *result; |
875 | Tcl_FreeProc *freeProc; |
876 | Tcl_Obj *objResultPtr; |
877 | char *appendResult; |
878 | int appendAvl; |
879 | int appendUsed; |
880 | char resultSpace[TCL_RESULT_SIZE+1]; |
881 | } Tcl_SavedResult; |
882 | |
883 | /* |
884 | *---------------------------------------------------------------------------- |
885 | * The following definitions support Tcl's namespace facility. Note: the first |
886 | * five fields must match exactly the fields in a Namespace structure (see |
887 | * tclInt.h). |
888 | */ |
889 | |
890 | typedef struct Tcl_Namespace { |
891 | char *name; /* The namespace's name within its parent |
892 | * namespace. This contains no ::'s. The name |
893 | * of the global namespace is "" although "::" |
894 | * is an synonym. */ |
895 | char *fullName; /* The namespace's fully qualified name. This |
896 | * starts with ::. */ |
897 | ClientData clientData; /* Arbitrary value associated with this |
898 | * namespace. */ |
899 | Tcl_NamespaceDeleteProc *deleteProc; |
900 | /* Function invoked when deleting the |
901 | * namespace to, e.g., free clientData. */ |
902 | struct Tcl_Namespace *parentPtr; |
903 | /* Points to the namespace that contains this |
904 | * one. NULL if this is the global |
905 | * namespace. */ |
906 | } Tcl_Namespace; |
907 | |
908 | /* |
909 | *---------------------------------------------------------------------------- |
910 | * The following structure represents a call frame, or activation record. A |
911 | * call frame defines a naming context for a procedure call: its local scope |
912 | * (for local variables) and its namespace scope (used for non-local |
913 | * variables; often the global :: namespace). A call frame can also define the |
914 | * naming context for a namespace eval or namespace inscope command: the |
915 | * namespace in which the command's code should execute. The Tcl_CallFrame |
916 | * structures exist only while procedures or namespace eval/inscope's are |
917 | * being executed, and provide a Tcl call stack. |
918 | * |
919 | * A call frame is initialized and pushed using Tcl_PushCallFrame and popped |
920 | * using Tcl_PopCallFrame. Storage for a Tcl_CallFrame must be provided by the |
921 | * Tcl_PushCallFrame caller, and callers typically allocate them on the C call |
922 | * stack for efficiency. For this reason, Tcl_CallFrame is defined as a |
923 | * structure and not as an opaque token. However, most Tcl_CallFrame fields |
924 | * are hidden since applications should not access them directly; others are |
925 | * declared as "dummyX". |
926 | * |
927 | * WARNING!! The structure definition must be kept consistent with the |
928 | * CallFrame structure in tclInt.h. If you change one, change the other. |
929 | */ |
930 | |
931 | typedef struct Tcl_CallFrame { |
932 | Tcl_Namespace *nsPtr; |
933 | int dummy1; |
934 | int dummy2; |
935 | void *dummy3; |
936 | void *dummy4; |
937 | void *dummy5; |
938 | int dummy6; |
939 | void *dummy7; |
940 | void *dummy8; |
941 | int dummy9; |
942 | void *dummy10; |
943 | void *dummy11; |
944 | void *dummy12; |
945 | void *dummy13; |
946 | } Tcl_CallFrame; |
947 | |
948 | /* |
949 | *---------------------------------------------------------------------------- |
950 | * Information about commands that is returned by Tcl_GetCommandInfo and |
951 | * passed to Tcl_SetCommandInfo. objProc is an objc/objv object-based command |
952 | * function while proc is a traditional Tcl argc/argv string-based function. |
953 | * Tcl_CreateObjCommand and Tcl_CreateCommand ensure that both objProc and |
954 | * proc are non-NULL and can be called to execute the command. However, it may |
955 | * be faster to call one instead of the other. The member isNativeObjectProc |
956 | * is set to 1 if an object-based function was registered by |
957 | * Tcl_CreateObjCommand, and to 0 if a string-based function was registered by |
958 | * Tcl_CreateCommand. The other function is typically set to a compatibility |
959 | * wrapper that does string-to-object or object-to-string argument conversions |
960 | * then calls the other function. |
961 | */ |
962 | |
963 | typedef struct Tcl_CmdInfo { |
964 | int isNativeObjectProc; /* 1 if objProc was registered by a call to |
965 | * Tcl_CreateObjCommand; 0 otherwise. |
966 | * Tcl_SetCmdInfo does not modify this |
967 | * field. */ |
968 | Tcl_ObjCmdProc *objProc; /* Command's object-based function. */ |
969 | ClientData objClientData; /* ClientData for object proc. */ |
970 | Tcl_CmdProc *proc; /* Command's string-based function. */ |
971 | ClientData clientData; /* ClientData for string proc. */ |
972 | Tcl_CmdDeleteProc *deleteProc; |
973 | /* Function to call when command is |
974 | * deleted. */ |
975 | ClientData deleteData; /* Value to pass to deleteProc (usually the |
976 | * same as clientData). */ |
977 | Tcl_Namespace *namespacePtr;/* Points to the namespace that contains this |
978 | * command. Note that Tcl_SetCmdInfo will not |
979 | * change a command's namespace; use |
980 | * TclRenameCommand or Tcl_Eval (of 'rename') |
981 | * to do that. */ |
982 | } Tcl_CmdInfo; |
983 | |
984 | /* |
985 | *---------------------------------------------------------------------------- |
986 | * The structure defined below is used to hold dynamic strings. The only |
987 | * fields that clients should use are string and length, accessible via the |
988 | * macros Tcl_DStringValue and Tcl_DStringLength. |
989 | */ |
990 | |
991 | #define TCL_DSTRING_STATIC_SIZE 200 |
992 | typedef struct Tcl_DString { |
993 | char *string; /* Points to beginning of string: either |
994 | * staticSpace below or a malloced array. */ |
995 | int length; /* Number of non-NULL characters in the |
996 | * string. */ |
997 | int spaceAvl; /* Total number of bytes available for the |
998 | * string and its terminating NULL char. */ |
999 | char staticSpace[TCL_DSTRING_STATIC_SIZE]; |
1000 | /* Space to use in common case where string is |
1001 | * small. */ |
1002 | } Tcl_DString; |
1003 | |
1004 | #define Tcl_DStringLength(dsPtr) ((dsPtr)->length) |
1005 | #define Tcl_DStringValue(dsPtr) ((dsPtr)->string) |
1006 | #define Tcl_DStringTrunc Tcl_DStringSetLength |
1007 | |
1008 | /* |
1009 | * Definitions for the maximum number of digits of precision that may be |
1010 | * specified in the "tcl_precision" variable, and the number of bytes of |
1011 | * buffer space required by Tcl_PrintDouble. |
1012 | */ |
1013 | |
1014 | #define TCL_MAX_PREC 17 |
1015 | #define TCL_DOUBLE_SPACE (TCL_MAX_PREC+10) |
1016 | |
1017 | /* |
1018 | * Definition for a number of bytes of buffer space sufficient to hold the |
1019 | * string representation of an integer in base 10 (assuming the existence of |
1020 | * 64-bit integers). |
1021 | */ |
1022 | |
1023 | #define TCL_INTEGER_SPACE 24 |
1024 | |
1025 | /* |
1026 | * Flag values passed to Tcl_ConvertElement. |
1027 | * TCL_DONT_USE_BRACES forces it not to enclose the element in braces, but to |
1028 | * use backslash quoting instead. |
1029 | * TCL_DONT_QUOTE_HASH disables the default quoting of the '#' character. It |
1030 | * is safe to leave the hash unquoted when the element is not the first |
1031 | * element of a list, and this flag can be used by the caller to indicate |
1032 | * that condition. |
1033 | */ |
1034 | |
1035 | #define TCL_DONT_USE_BRACES 1 |
1036 | #define TCL_DONT_QUOTE_HASH 8 |
1037 | |
1038 | /* |
1039 | * Flag that may be passed to Tcl_GetIndexFromObj to force it to disallow |
1040 | * abbreviated strings. |
1041 | */ |
1042 | |
1043 | #define TCL_EXACT 1 |
1044 | |
1045 | /* |
1046 | *---------------------------------------------------------------------------- |
1047 | * Flag values passed to Tcl_RecordAndEval, Tcl_EvalObj, Tcl_EvalObjv. |
1048 | * WARNING: these bit choices must not conflict with the bit choices for |
1049 | * evalFlag bits in tclInt.h! |
1050 | * |
1051 | * Meanings: |
1052 | * TCL_NO_EVAL: Just record this command |
1053 | * TCL_EVAL_GLOBAL: Execute script in global namespace |
1054 | * TCL_EVAL_DIRECT: Do not compile this script |
1055 | * TCL_EVAL_INVOKE: Magical Tcl_EvalObjv mode for aliases/ensembles |
1056 | * o Run in iPtr->lookupNsPtr or global namespace |
1057 | * o Cut out of error traces |
1058 | * o Don't reset the flags controlling ensemble |
1059 | * error message rewriting. |
1060 | * TCL_CANCEL_UNWIND: Magical Tcl_CancelEval mode that causes the |
1061 | * stack for the script in progress to be |
1062 | * completely unwound. |
1063 | * TCL_EVAL_NOERR: Do no exception reporting at all, just return |
1064 | * as the caller will report. |
1065 | */ |
1066 | |
1067 | #define TCL_NO_EVAL 0x010000 |
1068 | #define TCL_EVAL_GLOBAL 0x020000 |
1069 | #define TCL_EVAL_DIRECT 0x040000 |
1070 | #define TCL_EVAL_INVOKE 0x080000 |
1071 | #define TCL_CANCEL_UNWIND 0x100000 |
1072 | #define TCL_EVAL_NOERR 0x200000 |
1073 | |
1074 | /* |
1075 | * Special freeProc values that may be passed to Tcl_SetResult (see the man |
1076 | * page for details): |
1077 | */ |
1078 | |
1079 | #define TCL_VOLATILE ((Tcl_FreeProc *) 1) |
1080 | #define TCL_STATIC ((Tcl_FreeProc *) 0) |
1081 | #define TCL_DYNAMIC ((Tcl_FreeProc *) 3) |
1082 | |
1083 | /* |
1084 | * Flag values passed to variable-related functions. |
1085 | * WARNING: these bit choices must not conflict with the bit choice for |
1086 | * TCL_CANCEL_UNWIND, above. |
1087 | */ |
1088 | |
1089 | #define TCL_GLOBAL_ONLY 1 |
1090 | #define TCL_NAMESPACE_ONLY 2 |
1091 | #define TCL_APPEND_VALUE 4 |
1092 | #define TCL_LIST_ELEMENT 8 |
1093 | #define TCL_TRACE_READS 0x10 |
1094 | #define TCL_TRACE_WRITES 0x20 |
1095 | #define TCL_TRACE_UNSETS 0x40 |
1096 | #define TCL_TRACE_DESTROYED 0x80 |
1097 | #define TCL_INTERP_DESTROYED 0x100 |
1098 | #define TCL_LEAVE_ERR_MSG 0x200 |
1099 | #define TCL_TRACE_ARRAY 0x800 |
1100 | #ifndef TCL_REMOVE_OBSOLETE_TRACES |
1101 | /* Required to support old variable/vdelete/vinfo traces. */ |
1102 | #define TCL_TRACE_OLD_STYLE 0x1000 |
1103 | #endif |
1104 | /* Indicate the semantics of the result of a trace. */ |
1105 | #define TCL_TRACE_RESULT_DYNAMIC 0x8000 |
1106 | #define TCL_TRACE_RESULT_OBJECT 0x10000 |
1107 | |
1108 | /* |
1109 | * Flag values for ensemble commands. |
1110 | */ |
1111 | |
1112 | #define TCL_ENSEMBLE_PREFIX 0x02/* Flag value to say whether to allow |
1113 | * unambiguous prefixes of commands or to |
1114 | * require exact matches for command names. */ |
1115 | |
1116 | /* |
1117 | * Flag values passed to command-related functions. |
1118 | */ |
1119 | |
1120 | #define TCL_TRACE_RENAME 0x2000 |
1121 | #define TCL_TRACE_DELETE 0x4000 |
1122 | |
1123 | #define TCL_ALLOW_INLINE_COMPILATION 0x20000 |
1124 | |
1125 | /* |
1126 | * The TCL_PARSE_PART1 flag is deprecated and has no effect. The part1 is now |
1127 | * always parsed whenever the part2 is NULL. (This is to avoid a common error |
1128 | * when converting code to use the new object based APIs and forgetting to |
1129 | * give the flag) |
1130 | */ |
1131 | |
1132 | #ifndef TCL_NO_DEPRECATED |
1133 | # define TCL_PARSE_PART1 0x400 |
1134 | #endif |
1135 | |
1136 | /* |
1137 | * Types for linked variables: |
1138 | */ |
1139 | |
1140 | #define TCL_LINK_INT 1 |
1141 | #define TCL_LINK_DOUBLE 2 |
1142 | #define TCL_LINK_BOOLEAN 3 |
1143 | #define TCL_LINK_STRING 4 |
1144 | #define TCL_LINK_WIDE_INT 5 |
1145 | #define TCL_LINK_CHAR 6 |
1146 | #define TCL_LINK_UCHAR 7 |
1147 | #define TCL_LINK_SHORT 8 |
1148 | #define TCL_LINK_USHORT 9 |
1149 | #define TCL_LINK_UINT 10 |
1150 | #define TCL_LINK_LONG 11 |
1151 | #define TCL_LINK_ULONG 12 |
1152 | #define TCL_LINK_FLOAT 13 |
1153 | #define TCL_LINK_WIDE_UINT 14 |
1154 | #define TCL_LINK_READ_ONLY 0x80 |
1155 | |
1156 | /* |
1157 | *---------------------------------------------------------------------------- |
1158 | * Forward declarations of Tcl_HashTable and related types. |
1159 | */ |
1160 | |
1161 | typedef struct Tcl_HashKeyType Tcl_HashKeyType; |
1162 | typedef struct Tcl_HashTable Tcl_HashTable; |
1163 | typedef struct Tcl_HashEntry Tcl_HashEntry; |
1164 | |
1165 | typedef unsigned (Tcl_HashKeyProc) (Tcl_HashTable *tablePtr, void *keyPtr); |
1166 | typedef int (Tcl_CompareHashKeysProc) (void *keyPtr, Tcl_HashEntry *hPtr); |
1167 | typedef Tcl_HashEntry * (Tcl_AllocHashEntryProc) (Tcl_HashTable *tablePtr, |
1168 | void *keyPtr); |
1169 | typedef void (Tcl_FreeHashEntryProc) (Tcl_HashEntry *hPtr); |
1170 | |
1171 | /* |
1172 | * This flag controls whether the hash table stores the hash of a key, or |
1173 | * recalculates it. There should be no reason for turning this flag off as it |
1174 | * is completely binary and source compatible unless you directly access the |
1175 | * bucketPtr member of the Tcl_HashTableEntry structure. This member has been |
1176 | * removed and the space used to store the hash value. |
1177 | */ |
1178 | |
1179 | #ifndef TCL_HASH_KEY_STORE_HASH |
1180 | # define TCL_HASH_KEY_STORE_HASH 1 |
1181 | #endif |
1182 | |
1183 | /* |
1184 | * Structure definition for an entry in a hash table. No-one outside Tcl |
1185 | * should access any of these fields directly; use the macros defined below. |
1186 | */ |
1187 | |
1188 | struct Tcl_HashEntry { |
1189 | Tcl_HashEntry *nextPtr; /* Pointer to next entry in this hash bucket, |
1190 | * or NULL for end of chain. */ |
1191 | Tcl_HashTable *tablePtr; /* Pointer to table containing entry. */ |
1192 | #if TCL_HASH_KEY_STORE_HASH |
1193 | void *hash; /* Hash value, stored as pointer to ensure |
1194 | * that the offsets of the fields in this |
1195 | * structure are not changed. */ |
1196 | #else |
1197 | Tcl_HashEntry **bucketPtr; /* Pointer to bucket that points to first |
1198 | * entry in this entry's chain: used for |
1199 | * deleting the entry. */ |
1200 | #endif |
1201 | ClientData clientData; /* Application stores something here with |
1202 | * Tcl_SetHashValue. */ |
1203 | union { /* Key has one of these forms: */ |
1204 | char *oneWordValue; /* One-word value for key. */ |
1205 | Tcl_Obj *objPtr; /* Tcl_Obj * key value. */ |
1206 | int words[1]; /* Multiple integer words for key. The actual |
1207 | * size will be as large as necessary for this |
1208 | * table's keys. */ |
1209 | char string[1]; /* String for key. The actual size will be as |
1210 | * large as needed to hold the key. */ |
1211 | } key; /* MUST BE LAST FIELD IN RECORD!! */ |
1212 | }; |
1213 | |
1214 | /* |
1215 | * Flags used in Tcl_HashKeyType. |
1216 | * |
1217 | * TCL_HASH_KEY_RANDOMIZE_HASH - |
1218 | * There are some things, pointers for example |
1219 | * which don't hash well because they do not use |
1220 | * the lower bits. If this flag is set then the |
1221 | * hash table will attempt to rectify this by |
1222 | * randomising the bits and then using the upper |
1223 | * N bits as the index into the table. |
1224 | * TCL_HASH_KEY_SYSTEM_HASH - If this flag is set then all memory internally |
1225 | * allocated for the hash table that is not for an |
1226 | * entry will use the system heap. |
1227 | */ |
1228 | |
1229 | #define TCL_HASH_KEY_RANDOMIZE_HASH 0x1 |
1230 | #define TCL_HASH_KEY_SYSTEM_HASH 0x2 |
1231 | |
1232 | /* |
1233 | * Structure definition for the methods associated with a hash table key type. |
1234 | */ |
1235 | |
1236 | #define TCL_HASH_KEY_TYPE_VERSION 1 |
1237 | struct Tcl_HashKeyType { |
1238 | int version; /* Version of the table. If this structure is |
1239 | * extended in future then the version can be |
1240 | * used to distinguish between different |
1241 | * structures. */ |
1242 | int flags; /* Flags, see above for details. */ |
1243 | Tcl_HashKeyProc *hashKeyProc; |
1244 | /* Calculates a hash value for the key. If |
1245 | * this is NULL then the pointer itself is |
1246 | * used as a hash value. */ |
1247 | Tcl_CompareHashKeysProc *compareKeysProc; |
1248 | /* Compares two keys and returns zero if they |
1249 | * do not match, and non-zero if they do. If |
1250 | * this is NULL then the pointers are |
1251 | * compared. */ |
1252 | Tcl_AllocHashEntryProc *allocEntryProc; |
1253 | /* Called to allocate memory for a new entry, |
1254 | * i.e. if the key is a string then this could |
1255 | * allocate a single block which contains |
1256 | * enough space for both the entry and the |
1257 | * string. Only the key field of the allocated |
1258 | * Tcl_HashEntry structure needs to be filled |
1259 | * in. If something else needs to be done to |
1260 | * the key, i.e. incrementing a reference |
1261 | * count then that should be done by this |
1262 | * function. If this is NULL then Tcl_Alloc is |
1263 | * used to allocate enough space for a |
1264 | * Tcl_HashEntry and the key pointer is |
1265 | * assigned to key.oneWordValue. */ |
1266 | Tcl_FreeHashEntryProc *freeEntryProc; |
1267 | /* Called to free memory associated with an |
1268 | * entry. If something else needs to be done |
1269 | * to the key, i.e. decrementing a reference |
1270 | * count then that should be done by this |
1271 | * function. If this is NULL then Tcl_Free is |
1272 | * used to free the Tcl_HashEntry. */ |
1273 | }; |
1274 | |
1275 | /* |
1276 | * Structure definition for a hash table. Must be in tcl.h so clients can |
1277 | * allocate space for these structures, but clients should never access any |
1278 | * fields in this structure. |
1279 | */ |
1280 | |
1281 | #define TCL_SMALL_HASH_TABLE 4 |
1282 | struct Tcl_HashTable { |
1283 | Tcl_HashEntry **buckets; /* Pointer to bucket array. Each element |
1284 | * points to first entry in bucket's hash |
1285 | * chain, or NULL. */ |
1286 | Tcl_HashEntry *staticBuckets[TCL_SMALL_HASH_TABLE]; |
1287 | /* Bucket array used for small tables (to |
1288 | * avoid mallocs and frees). */ |
1289 | int numBuckets; /* Total number of buckets allocated at |
1290 | * **bucketPtr. */ |
1291 | int numEntries; /* Total number of entries present in |
1292 | * table. */ |
1293 | int rebuildSize; /* Enlarge table when numEntries gets to be |
1294 | * this large. */ |
1295 | int downShift; /* Shift count used in hashing function. |
1296 | * Designed to use high-order bits of |
1297 | * randomized keys. */ |
1298 | int mask; /* Mask value used in hashing function. */ |
1299 | int keyType; /* Type of keys used in this table. It's |
1300 | * either TCL_CUSTOM_KEYS, TCL_STRING_KEYS, |
1301 | * TCL_ONE_WORD_KEYS, or an integer giving the |
1302 | * number of ints that is the size of the |
1303 | * key. */ |
1304 | Tcl_HashEntry *(*findProc) (Tcl_HashTable *tablePtr, const char *key); |
1305 | Tcl_HashEntry *(*createProc) (Tcl_HashTable *tablePtr, const char *key, |
1306 | int *newPtr); |
1307 | const Tcl_HashKeyType *typePtr; |
1308 | /* Type of the keys used in the |
1309 | * Tcl_HashTable. */ |
1310 | }; |
1311 | |
1312 | /* |
1313 | * Structure definition for information used to keep track of searches through |
1314 | * hash tables: |
1315 | */ |
1316 | |
1317 | typedef struct Tcl_HashSearch { |
1318 | Tcl_HashTable *tablePtr; /* Table being searched. */ |
1319 | int nextIndex; /* Index of next bucket to be enumerated after |
1320 | * present one. */ |
1321 | Tcl_HashEntry *nextEntryPtr;/* Next entry to be enumerated in the current |
1322 | * bucket. */ |
1323 | } Tcl_HashSearch; |
1324 | |
1325 | /* |
1326 | * Acceptable key types for hash tables: |
1327 | * |
1328 | * TCL_STRING_KEYS: The keys are strings, they are copied into the |
1329 | * entry. |
1330 | * TCL_ONE_WORD_KEYS: The keys are pointers, the pointer is stored |
1331 | * in the entry. |
1332 | * TCL_CUSTOM_TYPE_KEYS: The keys are arbitrary types which are copied |
1333 | * into the entry. |
1334 | * TCL_CUSTOM_PTR_KEYS: The keys are pointers to arbitrary types, the |
1335 | * pointer is stored in the entry. |
1336 | * |
1337 | * While maintaining binary compatability the above have to be distinct values |
1338 | * as they are used to differentiate between old versions of the hash table |
1339 | * which don't have a typePtr and new ones which do. Once binary compatability |
1340 | * is discarded in favour of making more wide spread changes TCL_STRING_KEYS |
1341 | * can be the same as TCL_CUSTOM_TYPE_KEYS, and TCL_ONE_WORD_KEYS can be the |
1342 | * same as TCL_CUSTOM_PTR_KEYS because they simply determine how the key is |
1343 | * accessed from the entry and not the behaviour. |
1344 | */ |
1345 | |
1346 | #define TCL_STRING_KEYS (0) |
1347 | #define TCL_ONE_WORD_KEYS (1) |
1348 | #define TCL_CUSTOM_TYPE_KEYS (-2) |
1349 | #define TCL_CUSTOM_PTR_KEYS (-1) |
1350 | |
1351 | /* |
1352 | * Structure definition for information used to keep track of searches through |
1353 | * dictionaries. These fields should not be accessed by code outside |
1354 | * tclDictObj.c |
1355 | */ |
1356 | |
1357 | typedef struct { |
1358 | void *next; /* Search position for underlying hash |
1359 | * table. */ |
1360 | int epoch; /* Epoch marker for dictionary being searched, |
1361 | * or -1 if search has terminated. */ |
1362 | Tcl_Dict dictionaryPtr; /* Reference to dictionary being searched. */ |
1363 | } Tcl_DictSearch; |
1364 | |
1365 | /* |
1366 | *---------------------------------------------------------------------------- |
1367 | * Flag values to pass to Tcl_DoOneEvent to disable searches for some kinds of |
1368 | * events: |
1369 | */ |
1370 | |
1371 | #define TCL_DONT_WAIT (1<<1) |
1372 | #define TCL_WINDOW_EVENTS (1<<2) |
1373 | #define TCL_FILE_EVENTS (1<<3) |
1374 | #define TCL_TIMER_EVENTS (1<<4) |
1375 | #define TCL_IDLE_EVENTS (1<<5) /* WAS 0x10 ???? */ |
1376 | #define TCL_ALL_EVENTS (~TCL_DONT_WAIT) |
1377 | |
1378 | /* |
1379 | * The following structure defines a generic event for the Tcl event system. |
1380 | * These are the things that are queued in calls to Tcl_QueueEvent and |
1381 | * serviced later by Tcl_DoOneEvent. There can be many different kinds of |
1382 | * events with different fields, corresponding to window events, timer events, |
1383 | * etc. The structure for a particular event consists of a Tcl_Event header |
1384 | * followed by additional information specific to that event. |
1385 | */ |
1386 | |
1387 | struct Tcl_Event { |
1388 | Tcl_EventProc *proc; /* Function to call to service this event. */ |
1389 | struct Tcl_Event *nextPtr; /* Next in list of pending events, or NULL. */ |
1390 | }; |
1391 | |
1392 | /* |
1393 | * Positions to pass to Tcl_QueueEvent: |
1394 | */ |
1395 | |
1396 | typedef enum { |
1397 | TCL_QUEUE_TAIL, TCL_QUEUE_HEAD, TCL_QUEUE_MARK |
1398 | } Tcl_QueuePosition; |
1399 | |
1400 | /* |
1401 | * Values to pass to Tcl_SetServiceMode to specify the behavior of notifier |
1402 | * event routines. |
1403 | */ |
1404 | |
1405 | #define TCL_SERVICE_NONE 0 |
1406 | #define TCL_SERVICE_ALL 1 |
1407 | |
1408 | /* |
1409 | * The following structure keeps is used to hold a time value, either as an |
1410 | * absolute time (the number of seconds from the epoch) or as an elapsed time. |
1411 | * On Unix systems the epoch is Midnight Jan 1, 1970 GMT. |
1412 | */ |
1413 | |
1414 | typedef struct Tcl_Time { |
1415 | long sec; /* Seconds. */ |
1416 | long usec; /* Microseconds. */ |
1417 | } Tcl_Time; |
1418 | |
1419 | typedef void (Tcl_SetTimerProc) (CONST86 Tcl_Time *timePtr); |
1420 | typedef int (Tcl_WaitForEventProc) (CONST86 Tcl_Time *timePtr); |
1421 | |
1422 | /* |
1423 | * TIP #233 (Virtualized Time) |
1424 | */ |
1425 | |
1426 | typedef void (Tcl_GetTimeProc) (Tcl_Time *timebuf, ClientData clientData); |
1427 | typedef void (Tcl_ScaleTimeProc) (Tcl_Time *timebuf, ClientData clientData); |
1428 | |
1429 | /* |
1430 | *---------------------------------------------------------------------------- |
1431 | * Bits to pass to Tcl_CreateFileHandler and Tcl_CreateChannelHandler to |
1432 | * indicate what sorts of events are of interest: |
1433 | */ |
1434 | |
1435 | #define TCL_READABLE (1<<1) |
1436 | #define TCL_WRITABLE (1<<2) |
1437 | #define TCL_EXCEPTION (1<<3) |
1438 | |
1439 | /* |
1440 | * Flag values to pass to Tcl_OpenCommandChannel to indicate the disposition |
1441 | * of the stdio handles. TCL_STDIN, TCL_STDOUT, TCL_STDERR, are also used in |
1442 | * Tcl_GetStdChannel. |
1443 | */ |
1444 | |
1445 | #define TCL_STDIN (1<<1) |
1446 | #define TCL_STDOUT (1<<2) |
1447 | #define TCL_STDERR (1<<3) |
1448 | #define TCL_ENFORCE_MODE (1<<4) |
1449 | |
1450 | /* |
1451 | * Bits passed to Tcl_DriverClose2Proc to indicate which side of a channel |
1452 | * should be closed. |
1453 | */ |
1454 | |
1455 | #define TCL_CLOSE_READ (1<<1) |
1456 | #define TCL_CLOSE_WRITE (1<<2) |
1457 | |
1458 | /* |
1459 | * Value to use as the closeProc for a channel that supports the close2Proc |
1460 | * interface. |
1461 | */ |
1462 | |
1463 | #define TCL_CLOSE2PROC ((Tcl_DriverCloseProc *) 1) |
1464 | |
1465 | /* |
1466 | * Channel version tag. This was introduced in 8.3.2/8.4. |
1467 | */ |
1468 | |
1469 | #define TCL_CHANNEL_VERSION_1 ((Tcl_ChannelTypeVersion) 0x1) |
1470 | #define TCL_CHANNEL_VERSION_2 ((Tcl_ChannelTypeVersion) 0x2) |
1471 | #define TCL_CHANNEL_VERSION_3 ((Tcl_ChannelTypeVersion) 0x3) |
1472 | #define TCL_CHANNEL_VERSION_4 ((Tcl_ChannelTypeVersion) 0x4) |
1473 | #define TCL_CHANNEL_VERSION_5 ((Tcl_ChannelTypeVersion) 0x5) |
1474 | |
1475 | /* |
1476 | * TIP #218: Channel Actions, Ids for Tcl_DriverThreadActionProc. |
1477 | */ |
1478 | |
1479 | #define TCL_CHANNEL_THREAD_INSERT (0) |
1480 | #define TCL_CHANNEL_THREAD_REMOVE (1) |
1481 | |
1482 | /* |
1483 | * Typedefs for the various operations in a channel type: |
1484 | */ |
1485 | |
1486 | typedef int (Tcl_DriverBlockModeProc) (ClientData instanceData, int mode); |
1487 | typedef int (Tcl_DriverCloseProc) (ClientData instanceData, |
1488 | Tcl_Interp *interp); |
1489 | typedef int (Tcl_DriverClose2Proc) (ClientData instanceData, |
1490 | Tcl_Interp *interp, int flags); |
1491 | typedef int (Tcl_DriverInputProc) (ClientData instanceData, char *buf, |
1492 | int toRead, int *errorCodePtr); |
1493 | typedef int (Tcl_DriverOutputProc) (ClientData instanceData, |
1494 | CONST84 char *buf, int toWrite, int *errorCodePtr); |
1495 | typedef int (Tcl_DriverSeekProc) (ClientData instanceData, long offset, |
1496 | int mode, int *errorCodePtr); |
1497 | typedef int (Tcl_DriverSetOptionProc) (ClientData instanceData, |
1498 | Tcl_Interp *interp, const char *optionName, |
1499 | const char *value); |
1500 | typedef int (Tcl_DriverGetOptionProc) (ClientData instanceData, |
1501 | Tcl_Interp *interp, CONST84 char *optionName, |
1502 | Tcl_DString *dsPtr); |
1503 | typedef void (Tcl_DriverWatchProc) (ClientData instanceData, int mask); |
1504 | typedef int (Tcl_DriverGetHandleProc) (ClientData instanceData, |
1505 | int direction, ClientData *handlePtr); |
1506 | typedef int (Tcl_DriverFlushProc) (ClientData instanceData); |
1507 | typedef int (Tcl_DriverHandlerProc) (ClientData instanceData, |
1508 | int interestMask); |
1509 | typedef Tcl_WideInt (Tcl_DriverWideSeekProc) (ClientData instanceData, |
1510 | Tcl_WideInt offset, int mode, int *errorCodePtr); |
1511 | /* |
1512 | * TIP #218, Channel Thread Actions |
1513 | */ |
1514 | typedef void (Tcl_DriverThreadActionProc) (ClientData instanceData, |
1515 | int action); |
1516 | /* |
1517 | * TIP #208, File Truncation (etc.) |
1518 | */ |
1519 | typedef int (Tcl_DriverTruncateProc) (ClientData instanceData, |
1520 | Tcl_WideInt length); |
1521 | |
1522 | /* |
1523 | * struct Tcl_ChannelType: |
1524 | * |
1525 | * One such structure exists for each type (kind) of channel. It collects |
1526 | * together in one place all the functions that are part of the specific |
1527 | * channel type. |
1528 | * |
1529 | * It is recommend that the Tcl_Channel* functions are used to access elements |
1530 | * of this structure, instead of direct accessing. |
1531 | */ |
1532 | |
1533 | typedef struct Tcl_ChannelType { |
1534 | const char *typeName; /* The name of the channel type in Tcl |
1535 | * commands. This storage is owned by channel |
1536 | * type. */ |
1537 | Tcl_ChannelTypeVersion version; |
1538 | /* Version of the channel type. */ |
1539 | Tcl_DriverCloseProc *closeProc; |
1540 | /* Function to call to close the channel, or |
1541 | * TCL_CLOSE2PROC if the close2Proc should be |
1542 | * used instead. */ |
1543 | Tcl_DriverInputProc *inputProc; |
1544 | /* Function to call for input on channel. */ |
1545 | Tcl_DriverOutputProc *outputProc; |
1546 | /* Function to call for output on channel. */ |
1547 | Tcl_DriverSeekProc *seekProc; |
1548 | /* Function to call to seek on the channel. |
1549 | * May be NULL. */ |
1550 | Tcl_DriverSetOptionProc *setOptionProc; |
1551 | /* Set an option on a channel. */ |
1552 | Tcl_DriverGetOptionProc *getOptionProc; |
1553 | /* Get an option from a channel. */ |
1554 | Tcl_DriverWatchProc *watchProc; |
1555 | /* Set up the notifier to watch for events on |
1556 | * this channel. */ |
1557 | Tcl_DriverGetHandleProc *getHandleProc; |
1558 | /* Get an OS handle from the channel or NULL |
1559 | * if not supported. */ |
1560 | Tcl_DriverClose2Proc *close2Proc; |
1561 | /* Function to call to close the channel if |
1562 | * the device supports closing the read & |
1563 | * write sides independently. */ |
1564 | Tcl_DriverBlockModeProc *blockModeProc; |
1565 | /* Set blocking mode for the raw channel. May |
1566 | * be NULL. */ |
1567 | /* |
1568 | * Only valid in TCL_CHANNEL_VERSION_2 channels or later. |
1569 | */ |
1570 | Tcl_DriverFlushProc *flushProc; |
1571 | /* Function to call to flush a channel. May be |
1572 | * NULL. */ |
1573 | Tcl_DriverHandlerProc *handlerProc; |
1574 | /* Function to call to handle a channel event. |
1575 | * This will be passed up the stacked channel |
1576 | * chain. */ |
1577 | /* |
1578 | * Only valid in TCL_CHANNEL_VERSION_3 channels or later. |
1579 | */ |
1580 | Tcl_DriverWideSeekProc *wideSeekProc; |
1581 | /* Function to call to seek on the channel |
1582 | * which can handle 64-bit offsets. May be |
1583 | * NULL, and must be NULL if seekProc is |
1584 | * NULL. */ |
1585 | /* |
1586 | * Only valid in TCL_CHANNEL_VERSION_4 channels or later. |
1587 | * TIP #218, Channel Thread Actions. |
1588 | */ |
1589 | Tcl_DriverThreadActionProc *threadActionProc; |
1590 | /* Function to call to notify the driver of |
1591 | * thread specific activity for a channel. May |
1592 | * be NULL. */ |
1593 | /* |
1594 | * Only valid in TCL_CHANNEL_VERSION_5 channels or later. |
1595 | * TIP #208, File Truncation. |
1596 | */ |
1597 | Tcl_DriverTruncateProc *truncateProc; |
1598 | /* Function to call to truncate the underlying |
1599 | * file to a particular length. May be NULL if |
1600 | * the channel does not support truncation. */ |
1601 | } Tcl_ChannelType; |
1602 | |
1603 | /* |
1604 | * The following flags determine whether the blockModeProc above should set |
1605 | * the channel into blocking or nonblocking mode. They are passed as arguments |
1606 | * to the blockModeProc function in the above structure. |
1607 | */ |
1608 | |
1609 | #define TCL_MODE_BLOCKING 0 /* Put channel into blocking mode. */ |
1610 | #define TCL_MODE_NONBLOCKING 1 /* Put channel into nonblocking |
1611 | * mode. */ |
1612 | |
1613 | /* |
1614 | *---------------------------------------------------------------------------- |
1615 | * Enum for different types of file paths. |
1616 | */ |
1617 | |
1618 | typedef enum Tcl_PathType { |
1619 | TCL_PATH_ABSOLUTE, |
1620 | TCL_PATH_RELATIVE, |
1621 | TCL_PATH_VOLUME_RELATIVE |
1622 | } Tcl_PathType; |
1623 | |
1624 | /* |
1625 | * The following structure is used to pass glob type data amongst the various |
1626 | * glob routines and Tcl_FSMatchInDirectory. |
1627 | */ |
1628 | |
1629 | typedef struct Tcl_GlobTypeData { |
1630 | int type; /* Corresponds to bcdpfls as in 'find -t'. */ |
1631 | int perm; /* Corresponds to file permissions. */ |
1632 | Tcl_Obj *macType; /* Acceptable Mac type. */ |
1633 | Tcl_Obj *macCreator; /* Acceptable Mac creator. */ |
1634 | } Tcl_GlobTypeData; |
1635 | |
1636 | /* |
1637 | * Type and permission definitions for glob command. |
1638 | */ |
1639 | |
1640 | #define TCL_GLOB_TYPE_BLOCK (1<<0) |
1641 | #define TCL_GLOB_TYPE_CHAR (1<<1) |
1642 | #define TCL_GLOB_TYPE_DIR (1<<2) |
1643 | #define TCL_GLOB_TYPE_PIPE (1<<3) |
1644 | #define TCL_GLOB_TYPE_FILE (1<<4) |
1645 | #define TCL_GLOB_TYPE_LINK (1<<5) |
1646 | #define TCL_GLOB_TYPE_SOCK (1<<6) |
1647 | #define TCL_GLOB_TYPE_MOUNT (1<<7) |
1648 | |
1649 | #define TCL_GLOB_PERM_RONLY (1<<0) |
1650 | #define TCL_GLOB_PERM_HIDDEN (1<<1) |
1651 | #define TCL_GLOB_PERM_R (1<<2) |
1652 | #define TCL_GLOB_PERM_W (1<<3) |
1653 | #define TCL_GLOB_PERM_X (1<<4) |
1654 | |
1655 | /* |
1656 | * Flags for the unload callback function. |
1657 | */ |
1658 | |
1659 | #define TCL_UNLOAD_DETACH_FROM_INTERPRETER (1<<0) |
1660 | #define TCL_UNLOAD_DETACH_FROM_PROCESS (1<<1) |
1661 | |
1662 | /* |
1663 | * Typedefs for the various filesystem operations: |
1664 | */ |
1665 | |
1666 | typedef int (Tcl_FSStatProc) (Tcl_Obj *pathPtr, Tcl_StatBuf *buf); |
1667 | typedef int (Tcl_FSAccessProc) (Tcl_Obj *pathPtr, int mode); |
1668 | typedef Tcl_Channel (Tcl_FSOpenFileChannelProc) (Tcl_Interp *interp, |
1669 | Tcl_Obj *pathPtr, int mode, int permissions); |
1670 | typedef int (Tcl_FSMatchInDirectoryProc) (Tcl_Interp *interp, Tcl_Obj *result, |
1671 | Tcl_Obj *pathPtr, const char *pattern, Tcl_GlobTypeData *types); |
1672 | typedef Tcl_Obj * (Tcl_FSGetCwdProc) (Tcl_Interp *interp); |
1673 | typedef int (Tcl_FSChdirProc) (Tcl_Obj *pathPtr); |
1674 | typedef int (Tcl_FSLstatProc) (Tcl_Obj *pathPtr, Tcl_StatBuf *buf); |
1675 | typedef int (Tcl_FSCreateDirectoryProc) (Tcl_Obj *pathPtr); |
1676 | typedef int (Tcl_FSDeleteFileProc) (Tcl_Obj *pathPtr); |
1677 | typedef int (Tcl_FSCopyDirectoryProc) (Tcl_Obj *srcPathPtr, |
1678 | Tcl_Obj *destPathPtr, Tcl_Obj **errorPtr); |
1679 | typedef int (Tcl_FSCopyFileProc) (Tcl_Obj *srcPathPtr, Tcl_Obj *destPathPtr); |
1680 | typedef int (Tcl_FSRemoveDirectoryProc) (Tcl_Obj *pathPtr, int recursive, |
1681 | Tcl_Obj **errorPtr); |
1682 | typedef int (Tcl_FSRenameFileProc) (Tcl_Obj *srcPathPtr, Tcl_Obj *destPathPtr); |
1683 | typedef void (Tcl_FSUnloadFileProc) (Tcl_LoadHandle loadHandle); |
1684 | typedef Tcl_Obj * (Tcl_FSListVolumesProc) (void); |
1685 | /* We have to declare the utime structure here. */ |
1686 | struct utimbuf; |
1687 | typedef int (Tcl_FSUtimeProc) (Tcl_Obj *pathPtr, struct utimbuf *tval); |
1688 | typedef int (Tcl_FSNormalizePathProc) (Tcl_Interp *interp, Tcl_Obj *pathPtr, |
1689 | int nextCheckpoint); |
1690 | typedef int (Tcl_FSFileAttrsGetProc) (Tcl_Interp *interp, int index, |
1691 | Tcl_Obj *pathPtr, Tcl_Obj **objPtrRef); |
1692 | typedef const char *CONST86 * (Tcl_FSFileAttrStringsProc) (Tcl_Obj *pathPtr, |
1693 | Tcl_Obj **objPtrRef); |
1694 | typedef int (Tcl_FSFileAttrsSetProc) (Tcl_Interp *interp, int index, |
1695 | Tcl_Obj *pathPtr, Tcl_Obj *objPtr); |
1696 | typedef Tcl_Obj * (Tcl_FSLinkProc) (Tcl_Obj *pathPtr, Tcl_Obj *toPtr, |
1697 | int linkType); |
1698 | typedef int (Tcl_FSLoadFileProc) (Tcl_Interp *interp, Tcl_Obj *pathPtr, |
1699 | Tcl_LoadHandle *handlePtr, Tcl_FSUnloadFileProc **unloadProcPtr); |
1700 | typedef int (Tcl_FSPathInFilesystemProc) (Tcl_Obj *pathPtr, |
1701 | ClientData *clientDataPtr); |
1702 | typedef Tcl_Obj * (Tcl_FSFilesystemPathTypeProc) (Tcl_Obj *pathPtr); |
1703 | typedef Tcl_Obj * (Tcl_FSFilesystemSeparatorProc) (Tcl_Obj *pathPtr); |
1704 | typedef void (Tcl_FSFreeInternalRepProc) (ClientData clientData); |
1705 | typedef ClientData (Tcl_FSDupInternalRepProc) (ClientData clientData); |
1706 | typedef Tcl_Obj * (Tcl_FSInternalToNormalizedProc) (ClientData clientData); |
1707 | typedef ClientData (Tcl_FSCreateInternalRepProc) (Tcl_Obj *pathPtr); |
1708 | |
1709 | typedef struct Tcl_FSVersion_ *Tcl_FSVersion; |
1710 | |
1711 | /* |
1712 | *---------------------------------------------------------------------------- |
1713 | * Data structures related to hooking into the filesystem |
1714 | */ |
1715 | |
1716 | /* |
1717 | * Filesystem version tag. This was introduced in 8.4. |
1718 | */ |
1719 | |
1720 | #define TCL_FILESYSTEM_VERSION_1 ((Tcl_FSVersion) 0x1) |
1721 | |
1722 | /* |
1723 | * struct Tcl_Filesystem: |
1724 | * |
1725 | * One such structure exists for each type (kind) of filesystem. It collects |
1726 | * together in one place all the functions that are part of the specific |
1727 | * filesystem. Tcl always accesses the filesystem through one of these |
1728 | * structures. |
1729 | * |
1730 | * Not all entries need be non-NULL; any which are NULL are simply ignored. |
1731 | * However, a complete filesystem should provide all of these functions. The |
1732 | * explanations in the structure show the importance of each function. |
1733 | */ |
1734 | |
1735 | typedef struct Tcl_Filesystem { |
1736 | const char *typeName; /* The name of the filesystem. */ |
1737 | int structureLength; /* Length of this structure, so future binary |
1738 | * compatibility can be assured. */ |
1739 | Tcl_FSVersion version; /* Version of the filesystem type. */ |
1740 | Tcl_FSPathInFilesystemProc *pathInFilesystemProc; |
1741 | /* Function to check whether a path is in this |
1742 | * filesystem. This is the most important |
1743 | * filesystem function. */ |
1744 | Tcl_FSDupInternalRepProc *dupInternalRepProc; |
1745 | /* Function to duplicate internal fs rep. May |
1746 | * be NULL (but then fs is less efficient). */ |
1747 | Tcl_FSFreeInternalRepProc *freeInternalRepProc; |
1748 | /* Function to free internal fs rep. Must be |
1749 | * implemented if internal representations |
1750 | * need freeing, otherwise it can be NULL. */ |
1751 | Tcl_FSInternalToNormalizedProc *internalToNormalizedProc; |
1752 | /* Function to convert internal representation |
1753 | * to a normalized path. Only required if the |
1754 | * fs creates pure path objects with no |
1755 | * string/path representation. */ |
1756 | Tcl_FSCreateInternalRepProc *createInternalRepProc; |
1757 | /* Function to create a filesystem-specific |
1758 | * internal representation. May be NULL if |
1759 | * paths have no internal representation, or |
1760 | * if the Tcl_FSPathInFilesystemProc for this |
1761 | * filesystem always immediately creates an |
1762 | * internal representation for paths it |
1763 | * accepts. */ |
1764 | Tcl_FSNormalizePathProc *normalizePathProc; |
1765 | /* Function to normalize a path. Should be |
1766 | * implemented for all filesystems which can |
1767 | * have multiple string representations for |
1768 | * the same path object. */ |
1769 | Tcl_FSFilesystemPathTypeProc *filesystemPathTypeProc; |
1770 | /* Function to determine the type of a path in |
1771 | * this filesystem. May be NULL. */ |
1772 | Tcl_FSFilesystemSeparatorProc *filesystemSeparatorProc; |
1773 | /* Function to return the separator |
1774 | * character(s) for this filesystem. Must be |
1775 | * implemented. */ |
1776 | Tcl_FSStatProc *statProc; /* Function to process a 'Tcl_FSStat()' call. |
1777 | * Must be implemented for any reasonable |
1778 | * filesystem. */ |
1779 | Tcl_FSAccessProc *accessProc; |
1780 | /* Function to process a 'Tcl_FSAccess()' |
1781 | * call. Must be implemented for any |
1782 | * reasonable filesystem. */ |
1783 | Tcl_FSOpenFileChannelProc *openFileChannelProc; |
1784 | /* Function to process a |
1785 | * 'Tcl_FSOpenFileChannel()' call. Must be |
1786 | * implemented for any reasonable |
1787 | * filesystem. */ |
1788 | Tcl_FSMatchInDirectoryProc *matchInDirectoryProc; |
1789 | /* Function to process a |
1790 | * 'Tcl_FSMatchInDirectory()'. If not |
1791 | * implemented, then glob and recursive copy |
1792 | * functionality will be lacking in the |
1793 | * filesystem. */ |
1794 | Tcl_FSUtimeProc *utimeProc; /* Function to process a 'Tcl_FSUtime()' call. |
1795 | * Required to allow setting (not reading) of |
1796 | * times with 'file mtime', 'file atime' and |
1797 | * the open-r/open-w/fcopy implementation of |
1798 | * 'file copy'. */ |
1799 | Tcl_FSLinkProc *linkProc; /* Function to process a 'Tcl_FSLink()' call. |
1800 | * Should be implemented only if the |
1801 | * filesystem supports links (reading or |
1802 | * creating). */ |
1803 | Tcl_FSListVolumesProc *listVolumesProc; |
1804 | /* Function to list any filesystem volumes |
1805 | * added by this filesystem. Should be |
1806 | * implemented only if the filesystem adds |
1807 | * volumes at the head of the filesystem. */ |
1808 | Tcl_FSFileAttrStringsProc *fileAttrStringsProc; |
1809 | /* Function to list all attributes strings |
1810 | * which are valid for this filesystem. If not |
1811 | * implemented the filesystem will not support |
1812 | * the 'file attributes' command. This allows |
1813 | * arbitrary additional information to be |
1814 | * attached to files in the filesystem. */ |
1815 | Tcl_FSFileAttrsGetProc *fileAttrsGetProc; |
1816 | /* Function to process a |
1817 | * 'Tcl_FSFileAttrsGet()' call, used by 'file |
1818 | * attributes'. */ |
1819 | Tcl_FSFileAttrsSetProc *fileAttrsSetProc; |
1820 | /* Function to process a |
1821 | * 'Tcl_FSFileAttrsSet()' call, used by 'file |
1822 | * attributes'. */ |
1823 | Tcl_FSCreateDirectoryProc *createDirectoryProc; |
1824 | /* Function to process a |
1825 | * 'Tcl_FSCreateDirectory()' call. Should be |
1826 | * implemented unless the FS is read-only. */ |
1827 | Tcl_FSRemoveDirectoryProc *removeDirectoryProc; |
1828 | /* Function to process a |
1829 | * 'Tcl_FSRemoveDirectory()' call. Should be |
1830 | * implemented unless the FS is read-only. */ |
1831 | Tcl_FSDeleteFileProc *deleteFileProc; |
1832 | /* Function to process a 'Tcl_FSDeleteFile()' |
1833 | * call. Should be implemented unless the FS |
1834 | * is read-only. */ |
1835 | Tcl_FSCopyFileProc *copyFileProc; |
1836 | /* Function to process a 'Tcl_FSCopyFile()' |
1837 | * call. If not implemented Tcl will fall back |
1838 | * on open-r, open-w and fcopy as a copying |
1839 | * mechanism, for copying actions initiated in |
1840 | * Tcl (not C). */ |
1841 | Tcl_FSRenameFileProc *renameFileProc; |
1842 | /* Function to process a 'Tcl_FSRenameFile()' |
1843 | * call. If not implemented, Tcl will fall |
1844 | * back on a copy and delete mechanism, for |
1845 | * rename actions initiated in Tcl (not C). */ |
1846 | Tcl_FSCopyDirectoryProc *copyDirectoryProc; |
1847 | /* Function to process a |
1848 | * 'Tcl_FSCopyDirectory()' call. If not |
1849 | * implemented, Tcl will fall back on a |
1850 | * recursive create-dir, file copy mechanism, |
1851 | * for copying actions initiated in Tcl (not |
1852 | * C). */ |
1853 | Tcl_FSLstatProc *lstatProc; /* Function to process a 'Tcl_FSLstat()' call. |
1854 | * If not implemented, Tcl will attempt to use |
1855 | * the 'statProc' defined above instead. */ |
1856 | Tcl_FSLoadFileProc *loadFileProc; |
1857 | /* Function to process a 'Tcl_FSLoadFile()' |
1858 | * call. If not implemented, Tcl will fall |
1859 | * back on a copy to native-temp followed by a |
1860 | * Tcl_FSLoadFile on that temporary copy. */ |
1861 | Tcl_FSGetCwdProc *getCwdProc; |
1862 | /* Function to process a 'Tcl_FSGetCwd()' |
1863 | * call. Most filesystems need not implement |
1864 | * this. It will usually only be called once, |
1865 | * if 'getcwd' is called before 'chdir'. May |
1866 | * be NULL. */ |
1867 | Tcl_FSChdirProc *chdirProc; /* Function to process a 'Tcl_FSChdir()' call. |
1868 | * If filesystems do not implement this, it |
1869 | * will be emulated by a series of directory |
1870 | * access checks. Otherwise, virtual |
1871 | * filesystems which do implement it need only |
1872 | * respond with a positive return result if |
1873 | * the dirName is a valid directory in their |
1874 | * filesystem. They need not remember the |
1875 | * result, since that will be automatically |
1876 | * remembered for use by GetCwd. Real |
1877 | * filesystems should carry out the correct |
1878 | * action (i.e. call the correct system |
1879 | * 'chdir' api). If not implemented, then 'cd' |
1880 | * and 'pwd' will fail inside the |
1881 | * filesystem. */ |
1882 | } Tcl_Filesystem; |
1883 | |
1884 | /* |
1885 | * The following definitions are used as values for the 'linkAction' flag to |
1886 | * Tcl_FSLink, or the linkProc of any filesystem. Any combination of flags can |
1887 | * be given. For link creation, the linkProc should create a link which |
1888 | * matches any of the types given. |
1889 | * |
1890 | * TCL_CREATE_SYMBOLIC_LINK - Create a symbolic or soft link. |
1891 | * TCL_CREATE_HARD_LINK - Create a hard link. |
1892 | */ |
1893 | |
1894 | #define TCL_CREATE_SYMBOLIC_LINK 0x01 |
1895 | #define TCL_CREATE_HARD_LINK 0x02 |
1896 | |
1897 | /* |
1898 | *---------------------------------------------------------------------------- |
1899 | * The following structure represents the Notifier functions that you can |
1900 | * override with the Tcl_SetNotifier call. |
1901 | */ |
1902 | |
1903 | typedef struct Tcl_NotifierProcs { |
1904 | Tcl_SetTimerProc *setTimerProc; |
1905 | Tcl_WaitForEventProc *waitForEventProc; |
1906 | Tcl_CreateFileHandlerProc *createFileHandlerProc; |
1907 | Tcl_DeleteFileHandlerProc *deleteFileHandlerProc; |
1908 | Tcl_InitNotifierProc *initNotifierProc; |
1909 | Tcl_FinalizeNotifierProc *finalizeNotifierProc; |
1910 | Tcl_AlertNotifierProc *alertNotifierProc; |
1911 | Tcl_ServiceModeHookProc *serviceModeHookProc; |
1912 | } Tcl_NotifierProcs; |
1913 | |
1914 | /* |
1915 | *---------------------------------------------------------------------------- |
1916 | * The following data structures and declarations are for the new Tcl parser. |
1917 | * |
1918 | * For each word of a command, and for each piece of a word such as a variable |
1919 | * reference, one of the following structures is created to describe the |
1920 | * token. |
1921 | */ |
1922 | |
1923 | typedef struct Tcl_Token { |
1924 | int type; /* Type of token, such as TCL_TOKEN_WORD; see |
1925 | * below for valid types. */ |
1926 | const char *start; /* First character in token. */ |
1927 | int size; /* Number of bytes in token. */ |
1928 | int numComponents; /* If this token is composed of other tokens, |
1929 | * this field tells how many of them there are |
1930 | * (including components of components, etc.). |
1931 | * The component tokens immediately follow |
1932 | * this one. */ |
1933 | } Tcl_Token; |
1934 | |
1935 | /* |
1936 | * Type values defined for Tcl_Token structures. These values are defined as |
1937 | * mask bits so that it's easy to check for collections of types. |
1938 | * |
1939 | * TCL_TOKEN_WORD - The token describes one word of a command, |
1940 | * from the first non-blank character of the word |
1941 | * (which may be " or {) up to but not including |
1942 | * the space, semicolon, or bracket that |
1943 | * terminates the word. NumComponents counts the |
1944 | * total number of sub-tokens that make up the |
1945 | * word. This includes, for example, sub-tokens |
1946 | * of TCL_TOKEN_VARIABLE tokens. |
1947 | * TCL_TOKEN_SIMPLE_WORD - This token is just like TCL_TOKEN_WORD except |
1948 | * that the word is guaranteed to consist of a |
1949 | * single TCL_TOKEN_TEXT sub-token. |
1950 | * TCL_TOKEN_TEXT - The token describes a range of literal text |
1951 | * that is part of a word. NumComponents is |
1952 | * always 0. |
1953 | * TCL_TOKEN_BS - The token describes a backslash sequence that |
1954 | * must be collapsed. NumComponents is always 0. |
1955 | * TCL_TOKEN_COMMAND - The token describes a command whose result |
1956 | * must be substituted into the word. The token |
1957 | * includes the enclosing brackets. NumComponents |
1958 | * is always 0. |
1959 | * TCL_TOKEN_VARIABLE - The token describes a variable substitution, |
1960 | * including the dollar sign, variable name, and |
1961 | * array index (if there is one) up through the |
1962 | * right parentheses. NumComponents tells how |
1963 | * many additional tokens follow to represent the |
1964 | * variable name. The first token will be a |
1965 | * TCL_TOKEN_TEXT token that describes the |
1966 | * variable name. If the variable is an array |
1967 | * reference then there will be one or more |
1968 | * additional tokens, of type TCL_TOKEN_TEXT, |
1969 | * TCL_TOKEN_BS, TCL_TOKEN_COMMAND, and |
1970 | * TCL_TOKEN_VARIABLE, that describe the array |
1971 | * index; numComponents counts the total number |
1972 | * of nested tokens that make up the variable |
1973 | * reference, including sub-tokens of |
1974 | * TCL_TOKEN_VARIABLE tokens. |
1975 | * TCL_TOKEN_SUB_EXPR - The token describes one subexpression of an |
1976 | * expression, from the first non-blank character |
1977 | * of the subexpression up to but not including |
1978 | * the space, brace, or bracket that terminates |
1979 | * the subexpression. NumComponents counts the |
1980 | * total number of following subtokens that make |
1981 | * up the subexpression; this includes all |
1982 | * subtokens for any nested TCL_TOKEN_SUB_EXPR |
1983 | * tokens. For example, a numeric value used as a |
1984 | * primitive operand is described by a |
1985 | * TCL_TOKEN_SUB_EXPR token followed by a |
1986 | * TCL_TOKEN_TEXT token. A binary subexpression |
1987 | * is described by a TCL_TOKEN_SUB_EXPR token |
1988 | * followed by the TCL_TOKEN_OPERATOR token for |
1989 | * the operator, then TCL_TOKEN_SUB_EXPR tokens |
1990 | * for the left then the right operands. |
1991 | * TCL_TOKEN_OPERATOR - The token describes one expression operator. |
1992 | * An operator might be the name of a math |
1993 | * function such as "abs". A TCL_TOKEN_OPERATOR |
1994 | * token is always preceeded by one |
1995 | * TCL_TOKEN_SUB_EXPR token for the operator's |
1996 | * subexpression, and is followed by zero or more |
1997 | * TCL_TOKEN_SUB_EXPR tokens for the operator's |
1998 | * operands. NumComponents is always 0. |
1999 | * TCL_TOKEN_EXPAND_WORD - This token is just like TCL_TOKEN_WORD except |
2000 | * that it marks a word that began with the |
2001 | * literal character prefix "{*}". This word is |
2002 | * marked to be expanded - that is, broken into |
2003 | * words after substitution is complete. |
2004 | */ |
2005 | |
2006 | #define TCL_TOKEN_WORD 1 |
2007 | #define TCL_TOKEN_SIMPLE_WORD 2 |
2008 | #define TCL_TOKEN_TEXT 4 |
2009 | #define TCL_TOKEN_BS 8 |
2010 | #define TCL_TOKEN_COMMAND 16 |
2011 | #define TCL_TOKEN_VARIABLE 32 |
2012 | #define TCL_TOKEN_SUB_EXPR 64 |
2013 | #define TCL_TOKEN_OPERATOR 128 |
2014 | #define TCL_TOKEN_EXPAND_WORD 256 |
2015 | |
2016 | /* |
2017 | * Parsing error types. On any parsing error, one of these values will be |
2018 | * stored in the error field of the Tcl_Parse structure defined below. |
2019 | */ |
2020 | |
2021 | #define TCL_PARSE_SUCCESS 0 |
2022 | #define TCL_PARSE_QUOTE_EXTRA 1 |
2023 | #define TCL_PARSE_BRACE_EXTRA 2 |
2024 | #define TCL_PARSE_MISSING_BRACE 3 |
2025 | #define TCL_PARSE_MISSING_BRACKET 4 |
2026 | #define TCL_PARSE_MISSING_PAREN 5 |
2027 | #define TCL_PARSE_MISSING_QUOTE 6 |
2028 | #define TCL_PARSE_MISSING_VAR_BRACE 7 |
2029 | #define TCL_PARSE_SYNTAX 8 |
2030 | #define TCL_PARSE_BAD_NUMBER 9 |
2031 | |
2032 | /* |
2033 | * A structure of the following type is filled in by Tcl_ParseCommand. It |
2034 | * describes a single command parsed from an input string. |
2035 | */ |
2036 | |
2037 | #define NUM_STATIC_TOKENS 20 |
2038 | |
2039 | typedef struct Tcl_Parse { |
2040 | const char *commentStart; /* Pointer to # that begins the first of one |
2041 | * or more comments preceding the command. */ |
2042 | int commentSize; /* Number of bytes in comments (up through |
2043 | * newline character that terminates the last |
2044 | * comment). If there were no comments, this |
2045 | * field is 0. */ |
2046 | const char *commandStart; /* First character in first word of |
2047 | * command. */ |
2048 | int commandSize; /* Number of bytes in command, including first |
2049 | * character of first word, up through the |
2050 | * terminating newline, close bracket, or |
2051 | * semicolon. */ |
2052 | int numWords; /* Total number of words in command. May be |
2053 | * 0. */ |
2054 | Tcl_Token *tokenPtr; /* Pointer to first token representing the |
2055 | * words of the command. Initially points to |
2056 | * staticTokens, but may change to point to |
2057 | * malloc-ed space if command exceeds space in |
2058 | * staticTokens. */ |
2059 | int numTokens; /* Total number of tokens in command. */ |
2060 | int tokensAvailable; /* Total number of tokens available at |
2061 | * *tokenPtr. */ |
2062 | int errorType; /* One of the parsing error types defined |
2063 | * above. */ |
2064 | |
2065 | /* |
2066 | * The fields below are intended only for the private use of the parser. |
2067 | * They should not be used by functions that invoke Tcl_ParseCommand. |
2068 | */ |
2069 | |
2070 | const char *string; /* The original command string passed to |
2071 | * Tcl_ParseCommand. */ |
2072 | const char *end; /* Points to the character just after the last |
2073 | * one in the command string. */ |
2074 | Tcl_Interp *interp; /* Interpreter to use for error reporting, or |
2075 | * NULL. */ |
2076 | const char *term; /* Points to character in string that |
2077 | * terminated most recent token. Filled in by |
2078 | * ParseTokens. If an error occurs, points to |
2079 | * beginning of region where the error |
2080 | * occurred (e.g. the open brace if the close |
2081 | * brace is missing). */ |
2082 | int incomplete; /* This field is set to 1 by Tcl_ParseCommand |
2083 | * if the command appears to be incomplete. |
2084 | * This information is used by |
2085 | * Tcl_CommandComplete. */ |
2086 | Tcl_Token staticTokens[NUM_STATIC_TOKENS]; |
2087 | /* Initial space for tokens for command. This |
2088 | * space should be large enough to accommodate |
2089 | * most commands; dynamic space is allocated |
2090 | * for very large commands that don't fit |
2091 | * here. */ |
2092 | } Tcl_Parse; |
2093 | |
2094 | /* |
2095 | *---------------------------------------------------------------------------- |
2096 | * The following structure represents a user-defined encoding. It collects |
2097 | * together all the functions that are used by the specific encoding. |
2098 | */ |
2099 | |
2100 | typedef struct Tcl_EncodingType { |
2101 | const char *encodingName; /* The name of the encoding, e.g. "euc-jp". |
2102 | * This name is the unique key for this |
2103 | * encoding type. */ |
2104 | Tcl_EncodingConvertProc *toUtfProc; |
2105 | /* Function to convert from external encoding |
2106 | * into UTF-8. */ |
2107 | Tcl_EncodingConvertProc *fromUtfProc; |
2108 | /* Function to convert from UTF-8 into |
2109 | * external encoding. */ |
2110 | Tcl_EncodingFreeProc *freeProc; |
2111 | /* If non-NULL, function to call when this |
2112 | * encoding is deleted. */ |
2113 | ClientData clientData; /* Arbitrary value associated with encoding |
2114 | * type. Passed to conversion functions. */ |
2115 | int nullSize; /* Number of zero bytes that signify |
2116 | * end-of-string in this encoding. This number |
2117 | * is used to determine the source string |
2118 | * length when the srcLen argument is |
2119 | * negative. Must be 1 or 2. */ |
2120 | } Tcl_EncodingType; |
2121 | |
2122 | /* |
2123 | * The following definitions are used as values for the conversion control |
2124 | * flags argument when converting text from one character set to another: |
2125 | * |
2126 | * TCL_ENCODING_START - Signifies that the source buffer is the first |
2127 | * block in a (potentially multi-block) input |
2128 | * stream. Tells the conversion function to reset |
2129 | * to an initial state and perform any |
2130 | * initialization that needs to occur before the |
2131 | * first byte is converted. If the source buffer |
2132 | * contains the entire input stream to be |
2133 | * converted, this flag should be set. |
2134 | * TCL_ENCODING_END - Signifies that the source buffer is the last |
2135 | * block in a (potentially multi-block) input |
2136 | * stream. Tells the conversion routine to |
2137 | * perform any finalization that needs to occur |
2138 | * after the last byte is converted and then to |
2139 | * reset to an initial state. If the source |
2140 | * buffer contains the entire input stream to be |
2141 | * converted, this flag should be set. |
2142 | * TCL_ENCODING_STOPONERROR - If set, then the converter will return |
2143 | * immediately upon encountering an invalid byte |
2144 | * sequence or a source character that has no |
2145 | * mapping in the target encoding. If clear, then |
2146 | * the converter will skip the problem, |
2147 | * substituting one or more "close" characters in |
2148 | * the destination buffer and then continue to |
2149 | * convert the source. |
2150 | */ |
2151 | |
2152 | #define TCL_ENCODING_START 0x01 |
2153 | #define TCL_ENCODING_END 0x02 |
2154 | #define TCL_ENCODING_STOPONERROR 0x04 |
2155 | |
2156 | /* |
2157 | * The following definitions are the error codes returned by the conversion |
2158 | * routines: |
2159 | * |
2160 | * TCL_OK - All characters were converted. |
2161 | * TCL_CONVERT_NOSPACE - The output buffer would not have been large |
2162 | * enough for all of the converted data; as many |
2163 | * characters as could fit were converted though. |
2164 | * TCL_CONVERT_MULTIBYTE - The last few bytes in the source string were |
2165 | * the beginning of a multibyte sequence, but |
2166 | * more bytes were needed to complete this |
2167 | * sequence. A subsequent call to the conversion |
2168 | * routine should pass the beginning of this |
2169 | * unconverted sequence plus additional bytes |
2170 | * from the source stream to properly convert the |
2171 | * formerly split-up multibyte sequence. |
2172 | * TCL_CONVERT_SYNTAX - The source stream contained an invalid |
2173 | * character sequence. This may occur if the |
2174 | * input stream has been damaged or if the input |
2175 | * encoding method was misidentified. This error |
2176 | * is reported only if TCL_ENCODING_STOPONERROR |
2177 | * was specified. |
2178 | * TCL_CONVERT_UNKNOWN - The source string contained a character that |
2179 | * could not be represented in the target |
2180 | * encoding. This error is reported only if |
2181 | * TCL_ENCODING_STOPONERROR was specified. |
2182 | */ |
2183 | |
2184 | #define TCL_CONVERT_MULTIBYTE (-1) |
2185 | #define TCL_CONVERT_SYNTAX (-2) |
2186 | #define TCL_CONVERT_UNKNOWN (-3) |
2187 | #define TCL_CONVERT_NOSPACE (-4) |
2188 | |
2189 | /* |
2190 | * The maximum number of bytes that are necessary to represent a single |
2191 | * Unicode character in UTF-8. The valid values should be 3, 4 or 6 |
2192 | * (or perhaps 1 if we want to support a non-unicode enabled core). If 3 or |
2193 | * 4, then Tcl_UniChar must be 2-bytes in size (UCS-2) (the default). If 6, |
2194 | * then Tcl_UniChar must be 4-bytes in size (UCS-4). At this time UCS-2 mode |
2195 | * is the default and recommended mode. UCS-4 is experimental and not |
2196 | * recommended. It works for the core, but most extensions expect UCS-2. |
2197 | */ |
2198 | |
2199 | #ifndef TCL_UTF_MAX |
2200 | #define TCL_UTF_MAX 3 |
2201 | #endif |
2202 | |
2203 | /* |
2204 | * This represents a Unicode character. Any changes to this should also be |
2205 | * reflected in regcustom.h. |
2206 | */ |
2207 | |
2208 | #if TCL_UTF_MAX > 4 |
2209 | /* |
2210 | * unsigned int isn't 100% accurate as it should be a strict 4-byte value |
2211 | * (perhaps wchar_t). 64-bit systems may have troubles. The size of this |
2212 | * value must be reflected correctly in regcustom.h and |
2213 | * in tclEncoding.c. |
2214 | * XXX: Tcl is currently UCS-2 and planning UTF-16 for the Unicode |
2215 | * XXX: string rep that Tcl_UniChar represents. Changing the size |
2216 | * XXX: of Tcl_UniChar is /not/ supported. |
2217 | */ |
2218 | typedef unsigned int Tcl_UniChar; |
2219 | #else |
2220 | typedef unsigned short Tcl_UniChar; |
2221 | #endif |
2222 | |
2223 | /* |
2224 | *---------------------------------------------------------------------------- |
2225 | * TIP #59: The following structure is used in calls 'Tcl_RegisterConfig' to |
2226 | * provide the system with the embedded configuration data. |
2227 | */ |
2228 | |
2229 | typedef struct Tcl_Config { |
2230 | const char *key; /* Configuration key to register. ASCII |
2231 | * encoded, thus UTF-8. */ |
2232 | const char *value; /* The value associated with the key. System |
2233 | * encoding. */ |
2234 | } Tcl_Config; |
2235 | |
2236 | /* |
2237 | *---------------------------------------------------------------------------- |
2238 | * Flags for TIP#143 limits, detailing which limits are active in an |
2239 | * interpreter. Used for Tcl_{Add,Remove}LimitHandler type argument. |
2240 | */ |
2241 | |
2242 | #define TCL_LIMIT_COMMANDS 0x01 |
2243 | #define TCL_LIMIT_TIME 0x02 |
2244 | |
2245 | /* |
2246 | * Structure containing information about a limit handler to be called when a |
2247 | * command- or time-limit is exceeded by an interpreter. |
2248 | */ |
2249 | |
2250 | typedef void (Tcl_LimitHandlerProc) (ClientData clientData, Tcl_Interp *interp); |
2251 | typedef void (Tcl_LimitHandlerDeleteProc) (ClientData clientData); |
2252 | |
2253 | /* |
2254 | *---------------------------------------------------------------------------- |
2255 | * Override definitions for libtommath. |
2256 | */ |
2257 | |
2258 | typedef struct mp_int mp_int; |
2259 | #define MP_INT_DECLARED |
2260 | typedef unsigned int mp_digit; |
2261 | #define MP_DIGIT_DECLARED |
2262 | |
2263 | /* |
2264 | *---------------------------------------------------------------------------- |
2265 | * Definitions needed for Tcl_ParseArgvObj routines. |
2266 | * Based on tkArgv.c. |
2267 | * Modifications from the original are copyright (c) Sam Bromley 2006 |
2268 | */ |
2269 | |
2270 | typedef struct { |
2271 | int type; /* Indicates the option type; see below. */ |
2272 | const char *keyStr; /* The key string that flags the option in the |
2273 | * argv array. */ |
2274 | void *srcPtr; /* Value to be used in setting dst; usage |
2275 | * depends on type.*/ |
2276 | void *dstPtr; /* Address of value to be modified; usage |
2277 | * depends on type.*/ |
2278 | const char *helpStr; /* Documentation message describing this |
2279 | * option. */ |
2280 | ClientData clientData; /* Word to pass to function callbacks. */ |
2281 | } Tcl_ArgvInfo; |
2282 | |
2283 | /* |
2284 | * Legal values for the type field of a Tcl_ArgInfo: see the user |
2285 | * documentation for details. |
2286 | */ |
2287 | |
2288 | #define TCL_ARGV_CONSTANT 15 |
2289 | #define TCL_ARGV_INT 16 |
2290 | #define TCL_ARGV_STRING 17 |
2291 | #define TCL_ARGV_REST 18 |
2292 | #define TCL_ARGV_FLOAT 19 |
2293 | #define TCL_ARGV_FUNC 20 |
2294 | #define TCL_ARGV_GENFUNC 21 |
2295 | #define TCL_ARGV_HELP 22 |
2296 | #define TCL_ARGV_END 23 |
2297 | |
2298 | /* |
2299 | * Types of callback functions for the TCL_ARGV_FUNC and TCL_ARGV_GENFUNC |
2300 | * argument types: |
2301 | */ |
2302 | |
2303 | typedef int (Tcl_ArgvFuncProc)(ClientData clientData, Tcl_Obj *objPtr, |
2304 | void *dstPtr); |
2305 | typedef int (Tcl_ArgvGenFuncProc)(ClientData clientData, Tcl_Interp *interp, |
2306 | int objc, Tcl_Obj *const *objv, void *dstPtr); |
2307 | |
2308 | /* |
2309 | * Shorthand for commonly used argTable entries. |
2310 | */ |
2311 | |
2312 | #define TCL_ARGV_AUTO_HELP \ |
2313 | {TCL_ARGV_HELP, "-help", NULL, NULL, \ |
2314 | "Print summary of command-line options and abort", NULL} |
2315 | #define TCL_ARGV_AUTO_REST \ |
2316 | {TCL_ARGV_REST, "--", NULL, NULL, \ |
2317 | "Marks the end of the options", NULL} |
2318 | #define TCL_ARGV_TABLE_END \ |
2319 | {TCL_ARGV_END, NULL, NULL, NULL, NULL, NULL} |
2320 | |
2321 | /* |
2322 | *---------------------------------------------------------------------------- |
2323 | * Definitions needed for Tcl_Zlib routines. [TIP #234] |
2324 | * |
2325 | * Constants for the format flags describing what sort of data format is |
2326 | * desired/expected for the Tcl_ZlibDeflate, Tcl_ZlibInflate and |
2327 | * Tcl_ZlibStreamInit functions. |
2328 | */ |
2329 | |
2330 | #define TCL_ZLIB_FORMAT_RAW 1 |
2331 | #define TCL_ZLIB_FORMAT_ZLIB 2 |
2332 | #define TCL_ZLIB_FORMAT_GZIP 4 |
2333 | #define TCL_ZLIB_FORMAT_AUTO 8 |
2334 | |
2335 | /* |
2336 | * Constants that describe whether the stream is to operate in compressing or |
2337 | * decompressing mode. |
2338 | */ |
2339 | |
2340 | #define TCL_ZLIB_STREAM_DEFLATE 16 |
2341 | #define TCL_ZLIB_STREAM_INFLATE 32 |
2342 | |
2343 | /* |
2344 | * Constants giving compression levels. Use of TCL_ZLIB_COMPRESS_DEFAULT is |
2345 | * recommended. |
2346 | */ |
2347 | |
2348 | #define TCL_ZLIB_COMPRESS_NONE 0 |
2349 | #define TCL_ZLIB_COMPRESS_FAST 1 |
2350 | #define TCL_ZLIB_COMPRESS_BEST 9 |
2351 | #define TCL_ZLIB_COMPRESS_DEFAULT (-1) |
2352 | |
2353 | /* |
2354 | * Constants for types of flushing, used with Tcl_ZlibFlush. |
2355 | */ |
2356 | |
2357 | #define TCL_ZLIB_NO_FLUSH 0 |
2358 | #define TCL_ZLIB_FLUSH 2 |
2359 | #define TCL_ZLIB_FULLFLUSH 3 |
2360 | #define TCL_ZLIB_FINALIZE 4 |
2361 | |
2362 | /* |
2363 | *---------------------------------------------------------------------------- |
2364 | * Definitions needed for the Tcl_LoadFile function. [TIP #416] |
2365 | */ |
2366 | |
2367 | #define TCL_LOAD_GLOBAL 1 |
2368 | #define TCL_LOAD_LAZY 2 |
2369 | |
2370 | /* |
2371 | *---------------------------------------------------------------------------- |
2372 | * Single public declaration for NRE. |
2373 | */ |
2374 | |
2375 | typedef int (Tcl_NRPostProc) (ClientData data[], Tcl_Interp *interp, |
2376 | int result); |
2377 | |
2378 | /* |
2379 | *---------------------------------------------------------------------------- |
2380 | * The following constant is used to test for older versions of Tcl in the |
2381 | * stubs tables. |
2382 | * |
2383 | * Jan Nijtman's plus patch uses 0xFCA1BACF, so we need to pick a different |
2384 | * value since the stubs tables don't match. |
2385 | */ |
2386 | |
2387 | #define TCL_STUB_MAGIC ((int) 0xFCA3BACF) |
2388 | |
2389 | /* |
2390 | * The following function is required to be defined in all stubs aware |
2391 | * extensions. The function is actually implemented in the stub library, not |
2392 | * the main Tcl library, although there is a trivial implementation in the |
2393 | * main library in case an extension is statically linked into an application. |
2394 | */ |
2395 | |
2396 | const char * Tcl_InitStubs(Tcl_Interp *interp, const char *version, |
2397 | int exact); |
2398 | const char * TclTomMathInitializeStubs(Tcl_Interp *interp, |
2399 | const char *version, int epoch, int revision); |
2400 | |
2401 | /* |
2402 | * When not using stubs, make it a macro. |
2403 | */ |
2404 | |
2405 | #ifndef USE_TCL_STUBS |
2406 | #define Tcl_InitStubs(interp, version, exact) \ |
2407 | Tcl_PkgInitStubsCheck(interp, version, exact) |
2408 | #endif |
2409 | |
2410 | /* |
2411 | * TODO - tommath stubs export goes here! |
2412 | */ |
2413 | |
2414 | /* |
2415 | * Public functions that are not accessible via the stubs table. |
2416 | * Tcl_GetMemoryInfo is needed for AOLserver. [Bug 1868171] |
2417 | */ |
2418 | |
2419 | #define Tcl_Main(argc, argv, proc) Tcl_MainEx(argc, argv, proc, \ |
2420 | ((Tcl_CreateInterp)())) |
2421 | EXTERN void Tcl_MainEx(int argc, char **argv, |
2422 | Tcl_AppInitProc *appInitProc, Tcl_Interp *interp); |
2423 | EXTERN const char * Tcl_PkgInitStubsCheck(Tcl_Interp *interp, |
2424 | const char *version, int exact); |
2425 | #if defined(TCL_THREADS) && defined(USE_THREAD_ALLOC) |
2426 | EXTERN void Tcl_GetMemoryInfo(Tcl_DString *dsPtr); |
2427 | #endif |
2428 | |
2429 | /* |
2430 | *---------------------------------------------------------------------------- |
2431 | * Include the public function declarations that are accessible via the stubs |
2432 | * table. |
2433 | */ |
2434 | |
2435 | #include "tclDecls.h" |
2436 | |
2437 | /* |
2438 | * Include platform specific public function declarations that are accessible |
2439 | * via the stubs table. |
2440 | */ |
2441 | |
2442 | #include "tclPlatDecls.h" |
2443 | |
2444 | /* |
2445 | *---------------------------------------------------------------------------- |
2446 | * The following declarations either map ckalloc and ckfree to malloc and |
2447 | * free, or they map them to functions with all sorts of debugging hooks |
2448 | * defined in tclCkalloc.c. |
2449 | */ |
2450 | |
2451 | #ifdef TCL_MEM_DEBUG |
2452 | |
2453 | # define ckalloc(x) \ |
2454 | ((void *) Tcl_DbCkalloc((unsigned)(x), __FILE__, __LINE__)) |
2455 | # define ckfree(x) \ |
2456 | Tcl_DbCkfree((char *)(x), __FILE__, __LINE__) |
2457 | # define ckrealloc(x,y) \ |
2458 | ((void *) Tcl_DbCkrealloc((char *)(x), (unsigned)(y), __FILE__, __LINE__)) |
2459 | # define attemptckalloc(x) \ |
2460 | ((void *) Tcl_AttemptDbCkalloc((unsigned)(x), __FILE__, __LINE__)) |
2461 | # define attemptckrealloc(x,y) \ |
2462 | ((void *) Tcl_AttemptDbCkrealloc((char *)(x), (unsigned)(y), __FILE__, __LINE__)) |
2463 | |
2464 | #else /* !TCL_MEM_DEBUG */ |
2465 | |
2466 | /* |
2467 | * If we are not using the debugging allocator, we should call the Tcl_Alloc, |
2468 | * et al. routines in order to guarantee that every module is using the same |
2469 | * memory allocator both inside and outside of the Tcl library. |
2470 | */ |
2471 | |
2472 | # define ckalloc(x) \ |
2473 | ((void *) Tcl_Alloc((unsigned)(x))) |
2474 | # define ckfree(x) \ |
2475 | Tcl_Free((char *)(x)) |
2476 | # define ckrealloc(x,y) \ |
2477 | ((void *) Tcl_Realloc((char *)(x), (unsigned)(y))) |
2478 | # define attemptckalloc(x) \ |
2479 | ((void *) Tcl_AttemptAlloc((unsigned)(x))) |
2480 | # define attemptckrealloc(x,y) \ |
2481 | ((void *) Tcl_AttemptRealloc((char *)(x), (unsigned)(y))) |
2482 | # undef Tcl_InitMemory |
2483 | # define Tcl_InitMemory(x) |
2484 | # undef Tcl_DumpActiveMemory |
2485 | # define Tcl_DumpActiveMemory(x) |
2486 | # undef Tcl_ValidateAllMemory |
2487 | # define Tcl_ValidateAllMemory(x,y) |
2488 | |
2489 | #endif /* !TCL_MEM_DEBUG */ |
2490 | |
2491 | #ifdef TCL_MEM_DEBUG |
2492 | # define Tcl_IncrRefCount(objPtr) \ |
2493 | Tcl_DbIncrRefCount(objPtr, __FILE__, __LINE__) |
2494 | # define Tcl_DecrRefCount(objPtr) \ |
2495 | Tcl_DbDecrRefCount(objPtr, __FILE__, __LINE__) |
2496 | # define Tcl_IsShared(objPtr) \ |
2497 | Tcl_DbIsShared(objPtr, __FILE__, __LINE__) |
2498 | #else |
2499 | # define Tcl_IncrRefCount(objPtr) \ |
2500 | ++(objPtr)->refCount |
2501 | /* |
2502 | * Use do/while0 idiom for optimum correctness without compiler warnings. |
2503 | * http://c2.com/cgi/wiki?TrivialDoWhileLoop |
2504 | */ |
2505 | # define Tcl_DecrRefCount(objPtr) \ |
2506 | do { \ |
2507 | Tcl_Obj *_objPtr = (objPtr); \ |
2508 | if (--(_objPtr)->refCount <= 0) { \ |
2509 | TclFreeObj(_objPtr); \ |
2510 | } \ |
2511 | } while(0) |
2512 | # define Tcl_IsShared(objPtr) \ |
2513 | ((objPtr)->refCount > 1) |
2514 | #endif |
2515 | |
2516 | /* |
2517 | * Macros and definitions that help to debug the use of Tcl objects. When |
2518 | * TCL_MEM_DEBUG is defined, the Tcl_New declarations are overridden to call |
2519 | * debugging versions of the object creation functions. |
2520 | */ |
2521 | |
2522 | #ifdef TCL_MEM_DEBUG |
2523 | # undef Tcl_NewBignumObj |
2524 | # define Tcl_NewBignumObj(val) \ |
2525 | Tcl_DbNewBignumObj(val, __FILE__, __LINE__) |
2526 | # undef Tcl_NewBooleanObj |
2527 | # define Tcl_NewBooleanObj(val) \ |
2528 | Tcl_DbNewBooleanObj(val, __FILE__, __LINE__) |
2529 | # undef Tcl_NewByteArrayObj |
2530 | # define Tcl_NewByteArrayObj(bytes, len) \ |
2531 | Tcl_DbNewByteArrayObj(bytes, len, __FILE__, __LINE__) |
2532 | # undef Tcl_NewDoubleObj |
2533 | # define Tcl_NewDoubleObj(val) \ |
2534 | Tcl_DbNewDoubleObj(val, __FILE__, __LINE__) |
2535 | # undef Tcl_NewIntObj |
2536 | # define Tcl_NewIntObj(val) \ |
2537 | Tcl_DbNewLongObj(val, __FILE__, __LINE__) |
2538 | # undef Tcl_NewListObj |
2539 | # define Tcl_NewListObj(objc, objv) \ |
2540 | Tcl_DbNewListObj(objc, objv, __FILE__, __LINE__) |
2541 | # undef Tcl_NewLongObj |
2542 | # define Tcl_NewLongObj(val) \ |
2543 | Tcl_DbNewLongObj(val, __FILE__, __LINE__) |
2544 | # undef Tcl_NewObj |
2545 | # define Tcl_NewObj() \ |
2546 | Tcl_DbNewObj(__FILE__, __LINE__) |
2547 | # undef Tcl_NewStringObj |
2548 | # define Tcl_NewStringObj(bytes, len) \ |
2549 | Tcl_DbNewStringObj(bytes, len, __FILE__, __LINE__) |
2550 | # undef Tcl_NewWideIntObj |
2551 | # define Tcl_NewWideIntObj(val) \ |
2552 | Tcl_DbNewWideIntObj(val, __FILE__, __LINE__) |
2553 | #endif /* TCL_MEM_DEBUG */ |
2554 | |
2555 | /* |
2556 | *---------------------------------------------------------------------------- |
2557 | * Macros for clients to use to access fields of hash entries: |
2558 | */ |
2559 | |
2560 | #define Tcl_GetHashValue(h) ((h)->clientData) |
2561 | #define Tcl_SetHashValue(h, value) ((h)->clientData = (ClientData) (value)) |
2562 | #define Tcl_GetHashKey(tablePtr, h) \ |
2563 | ((void *) (((tablePtr)->keyType == TCL_ONE_WORD_KEYS || \ |
2564 | (tablePtr)->keyType == TCL_CUSTOM_PTR_KEYS) \ |
2565 | ? (h)->key.oneWordValue \ |
2566 | : (h)->key.string)) |
2567 | |
2568 | /* |
2569 | * Macros to use for clients to use to invoke find and create functions for |
2570 | * hash tables: |
2571 | */ |
2572 | |
2573 | #undef Tcl_FindHashEntry |
2574 | #define Tcl_FindHashEntry(tablePtr, key) \ |
2575 | (*((tablePtr)->findProc))(tablePtr, (const char *)(key)) |
2576 | #undef Tcl_CreateHashEntry |
2577 | #define Tcl_CreateHashEntry(tablePtr, key, newPtr) \ |
2578 | (*((tablePtr)->createProc))(tablePtr, (const char *)(key), newPtr) |
2579 | |
2580 | /* |
2581 | *---------------------------------------------------------------------------- |
2582 | * Macros that eliminate the overhead of the thread synchronization functions |
2583 | * when compiling without thread support. |
2584 | */ |
2585 | |
2586 | #ifndef TCL_THREADS |
2587 | #undef Tcl_MutexLock |
2588 | #define Tcl_MutexLock(mutexPtr) |
2589 | #undef Tcl_MutexUnlock |
2590 | #define Tcl_MutexUnlock(mutexPtr) |
2591 | #undef Tcl_MutexFinalize |
2592 | #define Tcl_MutexFinalize(mutexPtr) |
2593 | #undef Tcl_ConditionNotify |
2594 | #define Tcl_ConditionNotify(condPtr) |
2595 | #undef Tcl_ConditionWait |
2596 | #define Tcl_ConditionWait(condPtr, mutexPtr, timePtr) |
2597 | #undef Tcl_ConditionFinalize |
2598 | #define Tcl_ConditionFinalize(condPtr) |
2599 | #endif /* TCL_THREADS */ |
2600 | |
2601 | /* |
2602 | *---------------------------------------------------------------------------- |
2603 | * Deprecated Tcl functions: |
2604 | */ |
2605 | |
2606 | #ifndef TCL_NO_DEPRECATED |
2607 | /* |
2608 | * These function have been renamed. The old names are deprecated, but we |
2609 | * define these macros for backwards compatibilty. |
2610 | */ |
2611 | |
2612 | # define Tcl_Ckalloc Tcl_Alloc |
2613 | # define Tcl_Ckfree Tcl_Free |
2614 | # define Tcl_Ckrealloc Tcl_Realloc |
2615 | # define Tcl_Return Tcl_SetResult |
2616 | # define Tcl_TildeSubst Tcl_TranslateFileName |
2617 | # define panic Tcl_Panic |
2618 | # define panicVA Tcl_PanicVA |
2619 | #endif /* !TCL_NO_DEPRECATED */ |
2620 | |
2621 | /* |
2622 | *---------------------------------------------------------------------------- |
2623 | * Convenience declaration of Tcl_AppInit for backwards compatibility. This |
2624 | * function is not *implemented* by the tcl library, so the storage class is |
2625 | * neither DLLEXPORT nor DLLIMPORT. |
2626 | */ |
2627 | |
2628 | extern Tcl_AppInitProc Tcl_AppInit; |
2629 | |
2630 | #endif /* RC_INVOKED */ |
2631 | |
2632 | /* |
2633 | * end block for C++ |
2634 | */ |
2635 | |
2636 | #ifdef __cplusplus |
2637 | } |
2638 | #endif |
2639 | |
2640 | #endif /* _TCL */ |
2641 | |
2642 | /* |
2643 | * Local Variables: |
2644 | * mode: c |
2645 | * c-basic-offset: 4 |
2646 | * fill-column: 78 |
2647 | * End: |
2648 | */ |
2649 |
Warning: That file was not part of the compilation database. It may have many parsing errors.