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