annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/tcl.h @ 69:33d812a61356

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