diff options
Diffstat (limited to 'generic/tcl.h')
| -rw-r--r-- | generic/tcl.h | 1796 |
1 files changed, 772 insertions, 1024 deletions
diff --git a/generic/tcl.h b/generic/tcl.h index da94b47..464f205 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -38,45 +38,59 @@ extern "C" { * update the version numbers: * * library/init.tcl (1 LOC patch) - * unix/configure.ac (2 LOC Major, 2 LOC minor, 1 LOC patch) - * win/configure.ac (as above) + * unix/configure.in (2 LOC Major, 2 LOC minor, 1 LOC patch) + * win/configure.in (as above) * win/tcl.m4 (not patchlevel) - * README.md (sections 0 and 2, with and without separator) + * win/makefile.bc (not patchlevel) 2 LOC + * README (sections 0 and 2, with and without separator) + * macosx/Tcl.pbproj/project.pbxproj (not patchlevel) 1 LOC + * macosx/Tcl.pbproj/default.pbxuser (not patchlevel) 1 LOC + * macosx/Tcl.xcode/project.pbxproj (not patchlevel) 2 LOC + * macosx/Tcl.xcode/default.pbxuser (not patchlevel) 1 LOC * macosx/Tcl-Common.xcconfig (not patchlevel) 1 LOC * win/README (not patchlevel) (sections 0 and 2) * unix/tcl.spec (1 LOC patch) + * tools/tcl.hpj.in (not patchlevel, for windows installer) + * tools/tcl.wse.in (for windows installer) + * tools/tclSplash.bmp (not patchlevel) */ -#if !defined(TCL_MAJOR_VERSION) -# define TCL_MAJOR_VERSION 8 -#endif -#if TCL_MAJOR_VERSION != 8 -# error "This header-file is for Tcl 8 only" -#endif -#define TCL_MINOR_VERSION 7 -#define TCL_RELEASE_LEVEL TCL_BETA_RELEASE -#define TCL_RELEASE_SERIAL 1 +#define TCL_MAJOR_VERSION 8 +#define TCL_MINOR_VERSION 5 +#define TCL_RELEASE_LEVEL TCL_FINAL_RELEASE +#define TCL_RELEASE_SERIAL 18 + +#define TCL_VERSION "8.5" +#define TCL_PATCH_LEVEL "8.5.18" -#define TCL_VERSION "8.7" -#define TCL_PATCH_LEVEL "8.7b1" - -#if !defined(TCL_NO_DEPRECATED) || defined(RC_INVOKED) /* - *---------------------------------------------------------------------------- * The following definitions set up the proper options for Windows compilers. * We use this method because there is no autoconf equivalent. */ -#ifdef _WIN32 -# ifndef __WIN32__ +#ifndef __WIN32__ +# if defined(_WIN32) || defined(WIN32) || defined(__MSVCRT__) || defined(__BORLANDC__) || (defined(__WATCOMC__) && defined(__WINDOWS_386__)) # define __WIN32__ -# endif -# ifndef WIN32 -# define WIN32 +# ifndef WIN32 +# define WIN32 +# endif +# ifndef _WIN32 +# define _WIN32 +# endif # endif #endif /* + * STRICT: See MSDN Article Q83456 + */ + +#ifdef __WIN32__ +# ifndef STRICT +# define STRICT +# endif +#endif /* __WIN32__ */ + +/* * Utility macros: STRINGIFY takes an argument and wraps it in "" (double * quotation marks), JOIN joins two arguments. */ @@ -90,11 +104,6 @@ extern "C" { # define JOIN1(a,b) a##b #endif -#ifndef TCL_THREADS -# define TCL_THREADS 1 -#endif -#endif /* !TCL_NO_DEPRECATED */ - /* * A special definition used to allow this header file to be included from * windows resource files so that they can obtain version information. @@ -107,10 +116,15 @@ extern "C" { #ifndef RC_INVOKED /* - * Special macro to define mutexes. + * Special macro to define mutexes, that doesn't do anything if we are not + * using threads. */ +#ifdef TCL_THREADS #define TCL_DECLARE_MUTEX(name) static Tcl_Mutex name; +#else +#define TCL_DECLARE_MUTEX(name) +#endif /* * Tcl's public routine Tcl_FSSeek() uses the values SEEK_SET, SEEK_CUR, and @@ -123,10 +137,8 @@ extern "C" { */ #include <stdio.h> -#include <stddef.h> /* - *---------------------------------------------------------------------------- * Support for functions with a variable number of arguments. * * The following TCL_VARARGS* macros are to support old extensions @@ -141,51 +153,9 @@ extern "C" { # define TCL_VARARGS(type, name) (type name, ...) # define TCL_VARARGS_DEF(type, name) (type name, ...) # define TCL_VARARGS_START(type, name, list) (va_start(list, name), name) -#endif /* !TCL_NO_DEPRECATED */ -#if defined(__GNUC__) && (__GNUC__ > 2) -# if defined(_WIN32) && defined(__USE_MINGW_ANSI_STDIO) && __USE_MINGW_ANSI_STDIO -# define TCL_FORMAT_PRINTF(a,b) __attribute__ ((__format__ (__MINGW_PRINTF_FORMAT, a, b))) -# else -# define TCL_FORMAT_PRINTF(a,b) __attribute__ ((__format__ (__printf__, a, b))) -# endif -# define TCL_NORETURN __attribute__ ((noreturn)) -# define TCL_NOINLINE __attribute__ ((noinline)) -# if defined(BUILD_tcl) || defined(BUILD_tk) -# define TCL_NORETURN1 __attribute__ ((noreturn)) -# else -# define TCL_NORETURN1 /* nothing */ -# endif -#else -# define TCL_FORMAT_PRINTF(a,b) -# if defined(_MSC_VER) -# define TCL_NORETURN _declspec(noreturn) -# define TCL_NOINLINE __declspec(noinline) -# else -# define TCL_NORETURN /* nothing */ -# define TCL_NOINLINE /* nothing */ -# endif -# define TCL_NORETURN1 /* nothing */ -#endif - -/* - * Allow a part of Tcl's API to be explicitly marked as deprecated. - * - * Used to make TIP 330/336 generate moans even if people use the - * compatibility macros. Change your code, guys! We won't support you forever. - */ - -#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) -# if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) -# define TCL_DEPRECATED_API(msg) __attribute__ ((__deprecated__ (msg))) -# else -# define TCL_DEPRECATED_API(msg) __attribute__ ((__deprecated__)) -# endif -#else -# define TCL_DEPRECATED_API(msg) /* nothing portable */ #endif /* - *---------------------------------------------------------------------------- * Macros used to declare a function to be exported by a DLL. Used by Windows, * maps to no-op declarations on non-Windows systems. The default build on * windows is for a DLL, which causes the DLLIMPORT and DLLEXPORT macros to be @@ -198,7 +168,8 @@ extern "C" { * MSVCRT. */ -#ifdef _WIN32 +#if (defined(__WIN32__) && (defined(_MSC_VER) || (defined(__BORLANDC__) && (__BORLANDC__ >= 0x0550)) || defined(__LCC__) || defined(__WATCOMC__) || (defined(__GNUC__) && defined(__declspec)))) +# define HAVE_DECLSPEC 1 # ifdef STATIC_BUILD # define DLLIMPORT # define DLLEXPORT @@ -228,7 +199,7 @@ extern "C" { * to be included in a shared library, then it should have the DLLEXPORT * storage class. If is being declared for use by a module that is going to * link against the shared library, then it should have the DLLIMPORT storage - * class. If the symbol is being declared for a static build or for use from a + * class. If the symbol is beind declared for a static build or for use from a * stub library, then the storage class should be empty. * * The convention is that a macro called BUILD_xxxx, where xxxx is the name of @@ -250,33 +221,42 @@ extern "C" { #endif /* - * The following _ANSI_ARGS_ macro is to support old extensions - * written for older versions of Tcl where it permitted support - * for compilers written in the pre-prototype era of C. - * - * New code should use prototypes. - */ - -#ifndef TCL_NO_DEPRECATED -# undef _ANSI_ARGS_ -# define _ANSI_ARGS_(x) x - -/* * Definitions that allow this header file to be used either with or without - * ANSI C features. + * ANSI C features like function prototypes. */ +#undef _ANSI_ARGS_ +#undef CONST #ifndef INLINE # define INLINE #endif -#ifndef CONST + +#ifndef NO_CONST # define CONST const +#else +# define CONST #endif -#endif /* !TCL_NO_DEPRECATED */ +#ifndef NO_PROTOTYPES +# define _ANSI_ARGS_(x) x +#else +# define _ANSI_ARGS_(x) () +#endif -#ifndef CONST86 -# define CONST86 const +#ifdef USE_NON_CONST +# ifdef USE_COMPAT_CONST +# error define at most one of USE_NON_CONST and USE_COMPAT_CONST +# endif +# define CONST84 +# define CONST84_RETURN +#else +# ifdef USE_COMPAT_CONST +# define CONST84 +# define CONST84_RETURN CONST +# else +# define CONST84 CONST +# define CONST84_RETURN CONST +# endif #endif /* @@ -294,21 +274,19 @@ extern "C" { #endif /* - *---------------------------------------------------------------------------- * The following code is copied from winnt.h. If we don't replicate it here, * then <windows.h> can't be included after tcl.h, since tcl.h also defines * VOID. This block is skipped under Cygwin and Mingw. */ -#ifndef TCL_NO_DEPRECATED -#if defined(_WIN32) +#if defined(__WIN32__) && !defined(HAVE_WINNT_IGNORE_VOID) #ifndef VOID #define VOID void typedef char CHAR; typedef short SHORT; typedef long LONG; #endif -#endif /* _WIN32 */ +#endif /* __WIN32__ && !HAVE_WINNT_IGNORE_VOID */ /* * Macro to use instead of "void" for arguments that must have type "void *" @@ -316,15 +294,25 @@ typedef long LONG; */ #ifndef __VXWORKS__ -# define VOID void +# ifndef NO_VOID +# define VOID void +# else +# define VOID char +# endif #endif -#endif /* !TCL_NO_DEPRECATED */ /* * Miscellaneous declarations. */ -typedef void *ClientData; +#ifndef _CLIENTDATA +# ifndef NO_VOID + typedef void *ClientData; +# else + typedef int *ClientData; +# endif +# define _CLIENTDATA +#endif /* * Darwin specific configure overrides (to support fat compiles, where @@ -333,30 +321,25 @@ typedef void *ClientData; #ifdef __APPLE__ # ifdef __LP64__ +# undef TCL_WIDE_INT_TYPE # define TCL_WIDE_INT_IS_LONG 1 # define TCL_CFG_DO64BIT 1 # else /* !__LP64__ */ +# define TCL_WIDE_INT_TYPE long long # undef TCL_WIDE_INT_IS_LONG # undef TCL_CFG_DO64BIT # endif /* __LP64__ */ # undef HAVE_STRUCT_STAT64 #endif /* __APPLE__ */ -/* Cross-compiling 32-bit on a 64-bit platform? Then our - * configure script does the wrong thing. Correct that here. - */ -#if defined(__GNUC__) && !defined(_WIN32) && !defined(__LP64__) -# undef TCL_WIDE_INT_IS_LONG -#endif - /* * Define Tcl_WideInt to be a type that is (at least) 64-bits wide, and define * Tcl_WideUInt to be the unsigned variant of that type (assuming that where * we have one, we can have the other.) * * Also defines the following macros: - * TCL_WIDE_INT_IS_LONG - if wide ints are really longs (i.e. we're on a - * LP64 system such as modern Solaris or Linux ... not including Win64) + * TCL_WIDE_INT_IS_LONG - if wide ints are really longs (i.e. we're on a real + * 64-bit system.) * Tcl_WideAsLong - forgetful converter from wideInt to long. * Tcl_LongAsWide - sign-extending converter from long to wideInt. * Tcl_WideAsDouble - converter from wideInt to double. @@ -364,101 +347,104 @@ typedef void *ClientData; * * The following invariant should hold for any long value 'longVal': * longVal == Tcl_WideAsLong(Tcl_LongAsWide(longVal)) - */ - -#if !defined(TCL_WIDE_INT_TYPE) && !defined(TCL_WIDE_INT_IS_LONG) && !defined(_WIN32) && !defined(__GNUC__) + * + * Note on converting between Tcl_WideInt and strings. This implementation (in + * tclObj.c) depends on the function + * sprintf(...,"%" TCL_LL_MODIFIER "d",...). + */ + +#if !defined(TCL_WIDE_INT_TYPE)&&!defined(TCL_WIDE_INT_IS_LONG) +# if defined(__WIN32__) +# define TCL_WIDE_INT_TYPE __int64 +# ifdef __BORLANDC__ +# define TCL_LL_MODIFIER "L" +# else /* __BORLANDC__ */ +# define TCL_LL_MODIFIER "I64" +# endif /* __BORLANDC__ */ +# elif defined(__GNUC__) +# define TCL_WIDE_INT_TYPE long long +# define TCL_LL_MODIFIER "ll" +# else /* ! __WIN32__ && ! __GNUC__ */ /* * Don't know what platform it is and configure hasn't discovered what is * going on for us. Try to guess... */ -# include <limits.h> -# if defined(LLONG_MAX) && (LLONG_MAX == LONG_MAX) -# define TCL_WIDE_INT_IS_LONG 1 -# endif -#endif - -#ifndef TCL_WIDE_INT_TYPE -# define TCL_WIDE_INT_TYPE long long -#endif /* !TCL_WIDE_INT_TYPE */ +# ifdef NO_LIMITS_H +# error please define either TCL_WIDE_INT_TYPE or TCL_WIDE_INT_IS_LONG +# else /* !NO_LIMITS_H */ +# include <limits.h> +# if (INT_MAX < LONG_MAX) +# define TCL_WIDE_INT_IS_LONG 1 +# else +# define TCL_WIDE_INT_TYPE long long +# endif +# endif /* NO_LIMITS_H */ +# endif /* __WIN32__ */ +#endif /* !TCL_WIDE_INT_TYPE & !TCL_WIDE_INT_IS_LONG */ +#ifdef TCL_WIDE_INT_IS_LONG +# undef TCL_WIDE_INT_TYPE +# define TCL_WIDE_INT_TYPE long +#endif /* TCL_WIDE_INT_IS_LONG */ typedef TCL_WIDE_INT_TYPE Tcl_WideInt; typedef unsigned TCL_WIDE_INT_TYPE Tcl_WideUInt; -#ifndef TCL_LL_MODIFIER -# if defined(_WIN32) && (!defined(__USE_MINGW_ANSI_STDIO) || !__USE_MINGW_ANSI_STDIO) -# define TCL_LL_MODIFIER "I64" -# else -# define TCL_LL_MODIFIER "ll" -# endif -#endif /* !TCL_LL_MODIFIER */ -#ifndef TCL_Z_MODIFIER -# if defined(__GNUC__) && !defined(_WIN32) -# define TCL_Z_MODIFIER "z" +#ifdef TCL_WIDE_INT_IS_LONG +# define Tcl_WideAsLong(val) ((long)(val)) +# define Tcl_LongAsWide(val) ((long)(val)) +# define Tcl_WideAsDouble(val) ((double)((long)(val))) +# define Tcl_DoubleAsWide(val) ((long)((double)(val))) +# ifndef TCL_LL_MODIFIER +# define TCL_LL_MODIFIER "l" +# endif /* !TCL_LL_MODIFIER */ +#else /* TCL_WIDE_INT_IS_LONG */ +/* + * The next short section of defines are only done when not running on Windows + * or some other strange platform. + */ +# ifndef TCL_LL_MODIFIER +# define TCL_LL_MODIFIER "ll" +# endif /* !TCL_LL_MODIFIER */ +# define Tcl_WideAsLong(val) ((long)((Tcl_WideInt)(val))) +# define Tcl_LongAsWide(val) ((Tcl_WideInt)((long)(val))) +# define Tcl_WideAsDouble(val) ((double)((Tcl_WideInt)(val))) +# define Tcl_DoubleAsWide(val) ((Tcl_WideInt)((double)(val))) +#endif /* TCL_WIDE_INT_IS_LONG */ + +#if defined(__WIN32__) +# ifdef __BORLANDC__ + typedef struct stati64 Tcl_StatBuf; # elif defined(_WIN64) -# define TCL_Z_MODIFIER TCL_LL_MODIFIER -# else -# define TCL_Z_MODIFIER "" -# endif -#endif /* !TCL_Z_MODIFIER */ -#ifndef TCL_T_MODIFIER -# if defined(__GNUC__) && !defined(_WIN32) -# define TCL_T_MODIFIER "t" -# elif defined(_WIN64) -# define TCL_T_MODIFIER TCL_LL_MODIFIER -# else -# define TCL_T_MODIFIER TCL_Z_MODIFIER -# endif -#endif /* !TCL_T_MODIFIER */ - -#define Tcl_WideAsLong(val) ((long)((Tcl_WideInt)(val))) -#define Tcl_LongAsWide(val) ((Tcl_WideInt)((long)(val))) -#define Tcl_WideAsDouble(val) ((double)((Tcl_WideInt)(val))) -#define Tcl_DoubleAsWide(val) ((Tcl_WideInt)((double)(val))) - -#if TCL_MAJOR_VERSION < 9 - typedef int Tcl_Size; -# define TCL_SIZE_MAX ((int)(((unsigned int)-1)>>1)) -# define TCL_SIZE_MODIFIER "" -#else - typedef ptrdiff_t Tcl_Size; -# define TCL_SIZE_MAX ((ptrdiff_t)(((size_t)-1)>>1)) -# define TCL_SIZE_MODIFIER TCL_T_MODIFIER -#endif /* TCL_MAJOR_VERSION */ - -#ifdef _WIN32 -# if TCL_MAJOR_VERSION > 8 || defined(_WIN64) || defined(_USE_64BIT_TIME_T) typedef struct __stat64 Tcl_StatBuf; -# elif defined(_USE_32BIT_TIME_T) +# elif (defined(_MSC_VER) && (_MSC_VER < 1400)) || defined(_USE_32BIT_TIME_T) typedef struct _stati64 Tcl_StatBuf; # else typedef struct _stat32i64 Tcl_StatBuf; -# endif +# endif /* _MSC_VER < 1400 */ #elif defined(__CYGWIN__) typedef struct { - unsigned st_dev; + dev_t st_dev; unsigned short st_ino; unsigned short st_mode; short st_nlink; short st_uid; short st_gid; /* Here is a 2-byte gap */ - unsigned st_rdev; + dev_t st_rdev; /* Here is a 4-byte gap */ long long st_size; struct {long tv_sec;} st_atim; struct {long tv_sec;} st_mtim; struct {long tv_sec;} st_ctim; + /* Here is a 4-byte gap */ } Tcl_StatBuf; -#elif defined(HAVE_STRUCT_STAT64) && !defined(__APPLE__) \ - && (!defined(_FILE_OFFSET_BITS) || _FILE_OFFSET_BITS != 64) \ - && (!defined(_TIME_BITS) || _TIME_BITS != 64) +#elif defined(HAVE_STRUCT_STAT64) && !defined(__APPLE__) typedef struct stat64 Tcl_StatBuf; #else typedef struct stat Tcl_StatBuf; #endif /* - *---------------------------------------------------------------------------- * Data structures defined opaquely in this module. The definitions below just * provide dummy types. A few fields are made visible in Tcl_Interp * structures, namely those used for returning a string result from commands. @@ -477,17 +463,21 @@ typedef unsigned TCL_WIDE_INT_TYPE Tcl_WideUInt; * accessed with Tcl_GetObjResult() and Tcl_SetObjResult(). */ -typedef struct Tcl_Interp -#ifndef TCL_NO_DEPRECATED -{ - /* TIP #330: Strongly discourage extensions from using the string - * result. */ - char *resultDontUse; /* Don't use in extensions! */ - void (*freeProcDontUse) (char *); /* Don't use in extensions! */ - int errorLineDontUse; /* Don't use in extensions! */ -} -#endif /* !TCL_NO_DEPRECATED */ -Tcl_Interp; +typedef struct Tcl_Interp { + char *result; /* If the last command returned a string + * result, this points to it. */ + void (*freeProc) _ANSI_ARGS_((char *blockPtr)); + /* Zero means the string result is statically + * allocated. TCL_DYNAMIC means it was + * allocated with ckalloc and should be freed + * with ckfree. Other values give the address + * of function to invoke to free the result. + * Tcl_Eval must free it before executing next + * command. */ + int errorLine; /* When TCL_ERROR is returned, this gives the + * line number within the command where the + * error occurred (1 if first line). */ +} Tcl_Interp; typedef struct Tcl_AsyncHandler_ *Tcl_AsyncHandler; typedef struct Tcl_Channel_ *Tcl_Channel; @@ -508,19 +498,17 @@ typedef struct Tcl_ThreadId_ *Tcl_ThreadId; typedef struct Tcl_TimerToken_ *Tcl_TimerToken; typedef struct Tcl_Trace_ *Tcl_Trace; typedef struct Tcl_Var_ *Tcl_Var; -typedef struct Tcl_ZLibStream_ *Tcl_ZlibStream; /* - *---------------------------------------------------------------------------- * Definition of the interface to functions implementing threads. A function * following this definition is given to each call of 'Tcl_CreateThread' and * will be called as the main fuction of the new thread created by that call. */ -#if defined _WIN32 -typedef unsigned (__stdcall Tcl_ThreadCreateProc) (void *clientData); +#if defined __WIN32__ +typedef unsigned (__stdcall Tcl_ThreadCreateProc) _ANSI_ARGS_((ClientData clientData)); #else -typedef void (Tcl_ThreadCreateProc) (void *clientData); +typedef void (Tcl_ThreadCreateProc) _ANSI_ARGS_((ClientData clientData)); #endif /* @@ -529,7 +517,7 @@ typedef void (Tcl_ThreadCreateProc) (void *clientData); * in generic/tclThreadTest.c for it's usage. */ -#if defined _WIN32 +#if defined __WIN32__ # define Tcl_ThreadCreateType unsigned __stdcall # define TCL_THREAD_CREATE_RETURN return 0 #else @@ -586,28 +574,19 @@ typedef void (Tcl_ThreadCreateProc) (void *clientData); */ typedef struct Tcl_RegExpIndices { -#if TCL_MAJOR_VERSION > 8 - Tcl_Size start; /* Character offset of first character in + long start; /* Character offset of first character in * match. */ - Tcl_Size end; /* Character offset of first character after + long end; /* Character offset of first character after * the match. */ -#else - long start; - long end; -#endif } Tcl_RegExpIndices; typedef struct Tcl_RegExpInfo { - Tcl_Size nsubs; /* Number of subexpressions in the compiled + int nsubs; /* Number of subexpressions in the compiled * expression. */ Tcl_RegExpIndices *matches; /* Array of nsubs match offset pairs. */ -#if TCL_MAJOR_VERSION > 8 - Tcl_Size extendStart; /* The offset at which a subsequent match + long extendStart; /* The offset at which a subsequent match * might begin. */ -#else - long extendStart; long reserved; /* Reserved for later use. */ -#endif } Tcl_RegExpInfo; /* @@ -619,7 +598,6 @@ typedef Tcl_StatBuf *Tcl_Stat_; typedef struct stat *Tcl_OldStat_; /* - *---------------------------------------------------------------------------- * When a TCL command returns, the interpreter contains a result from the * command. Programmers are strongly encouraged to use one of the functions * Tcl_GetObjResult() or Tcl_GetStringResult() to read the interpreter's @@ -645,12 +623,9 @@ typedef struct stat *Tcl_OldStat_; #define TCL_BREAK 3 #define TCL_CONTINUE 4 -#ifndef TCL_NO_DEPRECATED #define TCL_RESULT_SIZE 200 -#endif /* - *---------------------------------------------------------------------------- * Flags to control what substitutions are performed by Tcl_SubstObj(): */ @@ -663,7 +638,6 @@ typedef struct stat *Tcl_OldStat_; * Argument descriptors for math function callbacks in expressions: */ -#ifndef TCL_NO_DEPRECATED typedef enum { TCL_INT, TCL_DOUBLE, TCL_EITHER, TCL_WIDE_INT } Tcl_ValueType; @@ -675,10 +649,6 @@ typedef struct Tcl_Value { double doubleValue; /* Double-precision floating value. */ Tcl_WideInt wideValue; /* Wide (min. 64-bit) integer value. */ } Tcl_Value; -#else -#define Tcl_ValueType void /* Just enough to prevent compilation error in Tcl */ -#define Tcl_Value void /* Just enough to prevent compilation error in Tcl */ -#endif /* * Forward declaration of Tcl_Obj to prevent an error when the forward @@ -688,85 +658,84 @@ typedef struct Tcl_Value { struct Tcl_Obj; /* - *---------------------------------------------------------------------------- * Function types defined by Tcl: */ -typedef int (Tcl_AppInitProc) (Tcl_Interp *interp); -typedef int (Tcl_AsyncProc) (void *clientData, Tcl_Interp *interp, - int code); -typedef void (Tcl_ChannelProc) (void *clientData, int mask); -typedef void (Tcl_CloseProc) (void *data); -typedef void (Tcl_CmdDeleteProc) (void *clientData); -typedef int (Tcl_CmdProc) (void *clientData, Tcl_Interp *interp, - int argc, const char *argv[]); -typedef void (Tcl_CmdTraceProc) (void *clientData, Tcl_Interp *interp, - int level, char *command, Tcl_CmdProc *proc, - void *cmdClientData, int argc, const char *argv[]); -typedef int (Tcl_CmdObjTraceProc) (void *clientData, Tcl_Interp *interp, - int level, const char *command, Tcl_Command commandInfo, int objc, - struct Tcl_Obj *const *objv); -#define Tcl_CmdObjTraceProc2 Tcl_CmdObjTraceProc -typedef void (Tcl_CmdObjTraceDeleteProc) (void *clientData); -typedef void (Tcl_DupInternalRepProc) (struct Tcl_Obj *srcPtr, - struct Tcl_Obj *dupPtr); -typedef int (Tcl_EncodingConvertProc) (void *clientData, const char *src, - int srcLen, int flags, Tcl_EncodingState *statePtr, char *dst, - int dstLen, int *srcReadPtr, int *dstWrotePtr, int *dstCharsPtr); -typedef void (Tcl_EncodingFreeProc) (void *clientData); -typedef int (Tcl_EventProc) (Tcl_Event *evPtr, int flags); -typedef void (Tcl_EventCheckProc) (void *clientData, int flags); -typedef int (Tcl_EventDeleteProc) (Tcl_Event *evPtr, void *clientData); -typedef void (Tcl_EventSetupProc) (void *clientData, int flags); -typedef void (Tcl_ExitProc) (void *clientData); -typedef void (Tcl_FileProc) (void *clientData, int mask); -typedef void (Tcl_FileFreeProc) (void *clientData); -typedef void (Tcl_FreeInternalRepProc) (struct Tcl_Obj *objPtr); -typedef void (Tcl_FreeProc) (char *blockPtr); -typedef void (Tcl_IdleProc) (void *clientData); -typedef void (Tcl_InterpDeleteProc) (void *clientData, - Tcl_Interp *interp); -typedef int (Tcl_MathProc) (void *clientData, Tcl_Interp *interp, - Tcl_Value *args, Tcl_Value *resultPtr); -typedef void (Tcl_NamespaceDeleteProc) (void *clientData); -typedef int (Tcl_ObjCmdProc) (void *clientData, Tcl_Interp *interp, - int objc, struct Tcl_Obj *const *objv); -#define Tcl_ObjCmdProc2 Tcl_ObjCmdProc -typedef int (Tcl_LibraryInitProc) (Tcl_Interp *interp); -typedef int (Tcl_LibraryUnloadProc) (Tcl_Interp *interp, int flags); -typedef void (Tcl_PanicProc) (const char *format, ...); -typedef void (Tcl_TcpAcceptProc) (void *callbackData, Tcl_Channel chan, - char *address, int port); -typedef void (Tcl_TimerProc) (void *clientData); -typedef int (Tcl_SetFromAnyProc) (Tcl_Interp *interp, struct Tcl_Obj *objPtr); -typedef void (Tcl_UpdateStringProc) (struct Tcl_Obj *objPtr); -typedef char * (Tcl_VarTraceProc) (void *clientData, Tcl_Interp *interp, - const char *part1, const char *part2, int flags); -typedef void (Tcl_CommandTraceProc) (void *clientData, Tcl_Interp *interp, - const char *oldName, const char *newName, int flags); -typedef void (Tcl_CreateFileHandlerProc) (int fd, int mask, Tcl_FileProc *proc, - void *clientData); -typedef void (Tcl_DeleteFileHandlerProc) (int fd); -typedef void (Tcl_AlertNotifierProc) (void *clientData); -typedef void (Tcl_ServiceModeHookProc) (int mode); -typedef void *(Tcl_InitNotifierProc) (void); -typedef void (Tcl_FinalizeNotifierProc) (void *clientData); -typedef void (Tcl_MainLoopProc) (void); - -#ifndef TCL_NO_DEPRECATED -# define Tcl_PackageInitProc Tcl_LibraryInitProc -# define Tcl_PackageUnloadProc Tcl_LibraryUnloadProc -#endif +typedef int (Tcl_AppInitProc) _ANSI_ARGS_((Tcl_Interp *interp)); +typedef int (Tcl_AsyncProc) _ANSI_ARGS_((ClientData clientData, + Tcl_Interp *interp, int code)); +typedef void (Tcl_ChannelProc) _ANSI_ARGS_((ClientData clientData, int mask)); +typedef void (Tcl_CloseProc) _ANSI_ARGS_((ClientData data)); +typedef void (Tcl_CmdDeleteProc) _ANSI_ARGS_((ClientData clientData)); +typedef int (Tcl_CmdProc) _ANSI_ARGS_((ClientData clientData, + Tcl_Interp *interp, int argc, CONST84 char *argv[])); +typedef void (Tcl_CmdTraceProc) _ANSI_ARGS_((ClientData clientData, + Tcl_Interp *interp, int level, char *command, Tcl_CmdProc *proc, + ClientData cmdClientData, int argc, CONST84 char *argv[])); +typedef int (Tcl_CmdObjTraceProc) _ANSI_ARGS_((ClientData clientData, + Tcl_Interp *interp, int level, CONST char *command, + Tcl_Command commandInfo, int objc, struct Tcl_Obj * CONST * objv)); +typedef void (Tcl_CmdObjTraceDeleteProc) _ANSI_ARGS_((ClientData clientData)); +typedef void (Tcl_DupInternalRepProc) _ANSI_ARGS_((struct Tcl_Obj *srcPtr, + struct Tcl_Obj *dupPtr)); +typedef int (Tcl_EncodingConvertProc)_ANSI_ARGS_((ClientData clientData, + CONST char *src, int srcLen, int flags, Tcl_EncodingState *statePtr, + char *dst, int dstLen, int *srcReadPtr, int *dstWrotePtr, + int *dstCharsPtr)); +typedef void (Tcl_EncodingFreeProc)_ANSI_ARGS_((ClientData clientData)); +typedef int (Tcl_EventProc) _ANSI_ARGS_((Tcl_Event *evPtr, int flags)); +typedef void (Tcl_EventCheckProc) _ANSI_ARGS_((ClientData clientData, + int flags)); +typedef int (Tcl_EventDeleteProc) _ANSI_ARGS_((Tcl_Event *evPtr, + ClientData clientData)); +typedef void (Tcl_EventSetupProc) _ANSI_ARGS_((ClientData clientData, + int flags)); +typedef void (Tcl_ExitProc) _ANSI_ARGS_((ClientData clientData)); +typedef void (Tcl_FileProc) _ANSI_ARGS_((ClientData clientData, int mask)); +typedef void (Tcl_FileFreeProc) _ANSI_ARGS_((ClientData clientData)); +typedef void (Tcl_FreeInternalRepProc) _ANSI_ARGS_((struct Tcl_Obj *objPtr)); +typedef void (Tcl_FreeProc) _ANSI_ARGS_((char *blockPtr)); +typedef void (Tcl_IdleProc) _ANSI_ARGS_((ClientData clientData)); +typedef void (Tcl_InterpDeleteProc) _ANSI_ARGS_((ClientData clientData, + Tcl_Interp *interp)); +typedef int (Tcl_MathProc) _ANSI_ARGS_((ClientData clientData, + Tcl_Interp *interp, Tcl_Value *args, Tcl_Value *resultPtr)); +typedef void (Tcl_NamespaceDeleteProc) _ANSI_ARGS_((ClientData clientData)); +typedef int (Tcl_ObjCmdProc) _ANSI_ARGS_((ClientData clientData, + Tcl_Interp *interp, int objc, struct Tcl_Obj * CONST * objv)); +typedef int (Tcl_PackageInitProc) _ANSI_ARGS_((Tcl_Interp *interp)); +typedef int (Tcl_PackageUnloadProc) _ANSI_ARGS_((Tcl_Interp *interp, + int flags)); +typedef void (Tcl_PanicProc) _ANSI_ARGS_((CONST char *format, ...)); +typedef void (Tcl_TcpAcceptProc) _ANSI_ARGS_((ClientData callbackData, + Tcl_Channel chan, char *address, int port)); +typedef void (Tcl_TimerProc) _ANSI_ARGS_((ClientData clientData)); +typedef int (Tcl_SetFromAnyProc) _ANSI_ARGS_((Tcl_Interp *interp, + struct Tcl_Obj *objPtr)); +typedef void (Tcl_UpdateStringProc) _ANSI_ARGS_((struct Tcl_Obj *objPtr)); +typedef char *(Tcl_VarTraceProc) _ANSI_ARGS_((ClientData clientData, + Tcl_Interp *interp, CONST84 char *part1, CONST84 char *part2, + int flags)); +typedef void (Tcl_CommandTraceProc) _ANSI_ARGS_((ClientData clientData, + Tcl_Interp *interp, CONST char *oldName, CONST char *newName, + int flags)); +typedef void (Tcl_CreateFileHandlerProc) _ANSI_ARGS_((int fd, int mask, + Tcl_FileProc *proc, ClientData clientData)); +typedef void (Tcl_DeleteFileHandlerProc) _ANSI_ARGS_((int fd)); +typedef void (Tcl_AlertNotifierProc) _ANSI_ARGS_((ClientData clientData)); +typedef void (Tcl_ServiceModeHookProc) _ANSI_ARGS_((int mode)); +typedef ClientData (Tcl_InitNotifierProc) _ANSI_ARGS_((VOID)); +typedef void (Tcl_FinalizeNotifierProc) _ANSI_ARGS_((ClientData clientData)); +typedef void (Tcl_MainLoopProc) _ANSI_ARGS_((void)); /* - *---------------------------------------------------------------------------- * The following structure represents a type of object, which is a particular * internal representation for an object plus a set of functions that provide * standard operations on objects of that type. */ typedef struct Tcl_ObjType { - const char *name; /* Name of the type, e.g. "int". */ + char *name; /* Name of the type, e.g. "int". */ Tcl_FreeInternalRepProc *freeIntRepProc; /* Called to free any storage for the type's * internal rep. NULL if the internal rep does @@ -782,30 +751,6 @@ typedef struct Tcl_ObjType { * to this type. Frees the internal rep of the * old type. Returns TCL_ERROR on failure. */ } Tcl_ObjType; -#define TCL_OBJTYPE_V0 /* just empty */ - -/* - * The following structure stores an internal representation (internalrep) for - * a Tcl value. An internalrep is associated with an Tcl_ObjType when both - * are stored in the same Tcl_Obj. The routines of the Tcl_ObjType govern - * the handling of the internalrep. - */ - -typedef union Tcl_ObjInternalRep { /* The internal representation: */ - long longValue; /* - an long integer value. */ - double doubleValue; /* - a double-precision floating value. */ - void *otherValuePtr; /* - another, type-specific value, */ - /* not used internally any more. */ - Tcl_WideInt wideValue; /* - an integer value >= 64bits */ - struct { /* - internal rep as two pointers. */ - void *ptr1; - void *ptr2; - } twoPtrValue; - struct { /* - internal rep as a pointer and a long, */ - void *ptr; /* not used internally any more. */ - unsigned long value; - } ptrAndLongRep; -} Tcl_ObjInternalRep; /* * One of the following structures exists for each object in the Tcl system. @@ -814,7 +759,7 @@ typedef union Tcl_ObjInternalRep { /* The internal representation: */ */ typedef struct Tcl_Obj { - Tcl_Size refCount; /* When 0 the object will be freed. */ + int refCount; /* When 0 the object will be freed. */ char *bytes; /* This points to the first byte of the * object's string representation. The array * must be followed by a null byte (i.e., at @@ -826,24 +771,48 @@ typedef struct Tcl_Obj { * should use Tcl_GetStringFromObj or * Tcl_GetString to get a pointer to the byte * array as a readonly value. */ - Tcl_Size length; /* The number of bytes at *bytes, not + int length; /* The number of bytes at *bytes, not * including the terminating null. */ - const Tcl_ObjType *typePtr; /* Denotes the object's type. Always + Tcl_ObjType *typePtr; /* Denotes the object's type. Always * corresponds to the type of the object's * internal rep. NULL indicates the object has * no internal rep (has no type). */ - Tcl_ObjInternalRep internalRep; /* The internal representation: */ + union { /* The internal representation: */ + long longValue; /* - an long integer value. */ + double doubleValue; /* - a double-precision floating value. */ + VOID *otherValuePtr; /* - another, type-specific value. */ + Tcl_WideInt wideValue; /* - a long long value. */ + struct { /* - internal rep as two pointers. */ + VOID *ptr1; + VOID *ptr2; + } twoPtrValue; + struct { /* - internal rep as a wide int, tightly + * packed fields. */ + VOID *ptr; /* Pointer to digits. */ + unsigned long value;/* Alloc, used, and signum packed into a + * single word. */ + } ptrAndLongRep; + } internalRep; } Tcl_Obj; - /* - *---------------------------------------------------------------------------- + * Macros to increment and decrement a Tcl_Obj's reference count, and to test + * whether an object is shared (i.e. has reference count > 1). Note: clients + * should use Tcl_DecrRefCount() when they are finished using an object, and + * should never call TclFreeObj() directly. TclFreeObj() is only defined and + * made public in tcl.h to support Tcl_DecrRefCount's macro definition. + */ + +void Tcl_IncrRefCount _ANSI_ARGS_((Tcl_Obj *objPtr)); +void Tcl_DecrRefCount _ANSI_ARGS_((Tcl_Obj *objPtr)); +int Tcl_IsShared _ANSI_ARGS_((Tcl_Obj *objPtr)); + +/* * The following structure contains the state needed by Tcl_SaveResult. No-one * outside of Tcl should access any of these fields. This structure is * typically allocated on the stack. */ -#ifndef TCL_NO_DEPRECATED typedef struct Tcl_SavedResult { char *result; Tcl_FreeProc *freeProc; @@ -851,12 +820,10 @@ typedef struct Tcl_SavedResult { char *appendResult; int appendAvl; int appendUsed; - char resultSpace[200+1]; + char resultSpace[TCL_RESULT_SIZE+1]; } Tcl_SavedResult; -#endif /* - *---------------------------------------------------------------------------- * The following definitions support Tcl's namespace facility. Note: the first * five fields must match exactly the fields in a Namespace structure (see * tclInt.h). @@ -869,7 +836,7 @@ typedef struct Tcl_Namespace { * is an synonym. */ char *fullName; /* The namespace's fully qualified name. This * starts with ::. */ - void *clientData; /* Arbitrary value associated with this + ClientData clientData; /* Arbitrary value associated with this * namespace. */ Tcl_NamespaceDeleteProc *deleteProc; /* Function invoked when deleting the @@ -881,7 +848,6 @@ typedef struct Tcl_Namespace { } Tcl_Namespace; /* - *---------------------------------------------------------------------------- * The following structure represents a call frame, or activation record. A * call frame defines a naming context for a procedure call: its local scope * (for local variables) and its namespace scope (used for non-local @@ -906,22 +872,21 @@ typedef struct Tcl_Namespace { typedef struct Tcl_CallFrame { Tcl_Namespace *nsPtr; int dummy1; - Tcl_Size dummy2; - void *dummy3; - void *dummy4; - void *dummy5; - Tcl_Size dummy6; - void *dummy7; - void *dummy8; - Tcl_Size dummy9; - void *dummy10; - void *dummy11; - void *dummy12; - void *dummy13; + int dummy2; + VOID *dummy3; + VOID *dummy4; + VOID *dummy5; + int dummy6; + VOID *dummy7; + VOID *dummy8; + int dummy9; + VOID *dummy10; + VOID *dummy11; + VOID *dummy12; + VOID *dummy13; } Tcl_CallFrame; /* - *---------------------------------------------------------------------------- * Information about commands that is returned by Tcl_GetCommandInfo and * passed to Tcl_SetCommandInfo. objProc is an objc/objv object-based command * function while proc is a traditional Tcl argc/argv string-based function. @@ -937,29 +902,26 @@ typedef struct Tcl_CallFrame { typedef struct Tcl_CmdInfo { int isNativeObjectProc; /* 1 if objProc was registered by a call to - * Tcl_CreateObjCommand; 2 if objProc was registered by - * a call to Tcl_CreateObjCommand2; 0 otherwise. - * Tcl_SetCmdInfo does not modify this field. */ + * Tcl_CreateObjCommand; 0 otherwise. + * Tcl_SetCmdInfo does not modify this + * field. */ Tcl_ObjCmdProc *objProc; /* Command's object-based function. */ - void *objClientData; /* ClientData for object proc. */ + ClientData objClientData; /* ClientData for object proc. */ Tcl_CmdProc *proc; /* Command's string-based function. */ - void *clientData; /* ClientData for string proc. */ + ClientData clientData; /* ClientData for string proc. */ Tcl_CmdDeleteProc *deleteProc; /* Function to call when command is * deleted. */ - void *deleteData; /* Value to pass to deleteProc (usually the + ClientData deleteData; /* Value to pass to deleteProc (usually the * same as clientData). */ Tcl_Namespace *namespacePtr;/* Points to the namespace that contains this * command. Note that Tcl_SetCmdInfo will not * change a command's namespace; use * TclRenameCommand or Tcl_Eval (of 'rename') * to do that. */ - Tcl_ObjCmdProc2 *objProc2; /* Not used in Tcl 8.7. */ - void *objClientData2; /* Not used in Tcl 8.7. */ } Tcl_CmdInfo; /* - *---------------------------------------------------------------------------- * The structure defined below is used to hold dynamic strings. The only * fields that clients should use are string and length, accessible via the * macros Tcl_DStringValue and Tcl_DStringLength. @@ -969,9 +931,9 @@ typedef struct Tcl_CmdInfo { typedef struct Tcl_DString { char *string; /* Points to beginning of string: either * staticSpace below or a malloced array. */ - Tcl_Size length; /* Number of non-NULL characters in the + int length; /* Number of non-NULL characters in the * string. */ - Tcl_Size spaceAvl; /* Total number of bytes available for the + int spaceAvl; /* Total number of bytes available for the * string and its terminating NULL char. */ char staticSpace[TCL_DSTRING_STATIC_SIZE]; /* Space to use in common case where string is @@ -980,14 +942,12 @@ typedef struct Tcl_DString { #define Tcl_DStringLength(dsPtr) ((dsPtr)->length) #define Tcl_DStringValue(dsPtr) ((dsPtr)->string) -#ifndef TCL_NO_DEPRECATED -# define Tcl_DStringTrunc Tcl_DStringSetLength -#endif +#define Tcl_DStringTrunc Tcl_DStringSetLength /* * Definitions for the maximum number of digits of precision that may be - * produced by Tcl_PrintDouble, and the number of bytes of buffer space - * required by Tcl_PrintDouble. + * specified in the "tcl_precision" variable, and the number of bytes of + * buffer space required by Tcl_PrintDouble. */ #define TCL_MAX_PREC 17 @@ -999,21 +959,7 @@ typedef struct Tcl_DString { * 64-bit integers). */ -#define TCL_INTEGER_SPACE (3*(int)sizeof(Tcl_WideInt)) - -/* - *---------------------------------------------------------------------------- - * Type values returned by Tcl_GetNumberFromObj - * TCL_NUMBER_INT Representation is a Tcl_WideInt - * TCL_NUMBER_BIG Representation is an mp_int - * TCL_NUMBER_DOUBLE Representation is a double - * TCL_NUMBER_NAN Value is NaN. - */ - -#define TCL_NUMBER_INT 2 -#define TCL_NUMBER_BIG 3 -#define TCL_NUMBER_DOUBLE 4 -#define TCL_NUMBER_NAN 5 +#define TCL_INTEGER_SPACE 24 /* * Flag values passed to Tcl_ConvertElement. @@ -1029,30 +975,13 @@ typedef struct Tcl_DString { #define TCL_DONT_QUOTE_HASH 8 /* - * Flags that may be passed to Tcl_GetIndexFromObj. - * TCL_EXACT disallows abbreviated strings. - * TCL_NULL_OK allows the empty string or NULL to return TCL_OK. - * The returned value will be -1; - * TCL_INDEX_TEMP_TABLE disallows caching of lookups. A possible use case is - * a table that will not live long enough to make it worthwhile. + * Flag that may be passed to Tcl_GetIndexFromObj to force it to disallow + * abbreviated strings. */ -#define TCL_EXACT 1 -#define TCL_NULL_OK 32 -#define TCL_INDEX_TEMP_TABLE 64 +#define TCL_EXACT 1 /* - * Flags that may be passed to Tcl_UniCharToUtf. - * TCL_COMBINE Combine surrogates (default in Tcl 8.x) - */ - -#if TCL_MAJOR_VERSION > 8 -# define TCL_COMBINE 0x1000000 -#else -# define TCL_COMBINE 0 -#endif -/* - *---------------------------------------------------------------------------- * Flag values passed to Tcl_RecordAndEval, Tcl_EvalObj, Tcl_EvalObjv. * WARNING: these bit choices must not conflict with the bit choices for * evalFlag bits in tclInt.h! @@ -1066,19 +995,11 @@ typedef struct Tcl_DString { * o Cut out of error traces * o Don't reset the flags controlling ensemble * error message rewriting. - * TCL_CANCEL_UNWIND: Magical Tcl_CancelEval mode that causes the - * stack for the script in progress to be - * completely unwound. - * TCL_EVAL_NOERR: Do no exception reporting at all, just return - * as the caller will report. */ - -#define TCL_NO_EVAL 0x010000 -#define TCL_EVAL_GLOBAL 0x020000 -#define TCL_EVAL_DIRECT 0x040000 -#define TCL_EVAL_INVOKE 0x080000 -#define TCL_CANCEL_UNWIND 0x100000 -#define TCL_EVAL_NOERR 0x200000 +#define TCL_NO_EVAL 0x10000 +#define TCL_EVAL_GLOBAL 0x20000 +#define TCL_EVAL_DIRECT 0x40000 +#define TCL_EVAL_INVOKE 0x80000 /* * Special freeProc values that may be passed to Tcl_SetResult (see the man @@ -1091,8 +1012,6 @@ typedef struct Tcl_DString { /* * Flag values passed to variable-related functions. - * WARNING: these bit choices must not conflict with the bit choice for - * TCL_CANCEL_UNWIND, above. */ #define TCL_GLOBAL_ONLY 1 @@ -1103,18 +1022,14 @@ typedef struct Tcl_DString { #define TCL_TRACE_WRITES 0x20 #define TCL_TRACE_UNSETS 0x40 #define TCL_TRACE_DESTROYED 0x80 - -#ifndef TCL_NO_DEPRECATED #define TCL_INTERP_DESTROYED 0x100 -#endif - #define TCL_LEAVE_ERR_MSG 0x200 #define TCL_TRACE_ARRAY 0x800 -#ifndef TCL_NO_DEPRECATED -/* Required to support old variable/vdelete/vinfo traces. */ +#ifndef TCL_REMOVE_OBSOLETE_TRACES +/* Required to support old variable/vdelete/vinfo traces */ #define TCL_TRACE_OLD_STYLE 0x1000 #endif -/* Indicate the semantics of the result of a trace. */ +/* Indicate the semantics of the result of a trace */ #define TCL_TRACE_RESULT_DYNAMIC 0x8000 #define TCL_TRACE_RESULT_OBJECT 0x10000 @@ -1130,8 +1045,8 @@ typedef struct Tcl_DString { * Flag values passed to command-related functions. */ -#define TCL_TRACE_RENAME 0x2000 -#define TCL_TRACE_DELETE 0x4000 +#define TCL_TRACE_RENAME 0x2000 +#define TCL_TRACE_DELETE 0x4000 #define TCL_ALLOW_INLINE_COMPILATION 0x20000 @@ -1160,41 +1075,39 @@ typedef struct Tcl_DString { #define TCL_LINK_SHORT 8 #define TCL_LINK_USHORT 9 #define TCL_LINK_UINT 10 -#if defined(TCL_WIDE_INT_IS_LONG) || defined(_WIN32) || defined(__CYGWIN__) -#define TCL_LINK_LONG ((sizeof(long) != sizeof(int)) ? TCL_LINK_WIDE_INT : TCL_LINK_INT) -#define TCL_LINK_ULONG ((sizeof(long) != sizeof(int)) ? TCL_LINK_WIDE_UINT : TCL_LINK_UINT) -#else #define TCL_LINK_LONG 11 #define TCL_LINK_ULONG 12 -#endif #define TCL_LINK_FLOAT 13 #define TCL_LINK_WIDE_UINT 14 -#define TCL_LINK_CHARS 15 -#define TCL_LINK_BINARY 16 #define TCL_LINK_READ_ONLY 0x80 /* - *---------------------------------------------------------------------------- * Forward declarations of Tcl_HashTable and related types. */ -#ifndef TCL_HASH_TYPE -#if TCL_MAJOR_VERSION > 8 -# define TCL_HASH_TYPE size_t -#else -# define TCL_HASH_TYPE unsigned -#endif -#endif - typedef struct Tcl_HashKeyType Tcl_HashKeyType; typedef struct Tcl_HashTable Tcl_HashTable; typedef struct Tcl_HashEntry Tcl_HashEntry; -typedef TCL_HASH_TYPE (Tcl_HashKeyProc) (Tcl_HashTable *tablePtr, void *keyPtr); -typedef int (Tcl_CompareHashKeysProc) (void *keyPtr, Tcl_HashEntry *hPtr); -typedef Tcl_HashEntry * (Tcl_AllocHashEntryProc) (Tcl_HashTable *tablePtr, - void *keyPtr); -typedef void (Tcl_FreeHashEntryProc) (Tcl_HashEntry *hPtr); +typedef unsigned int (Tcl_HashKeyProc) _ANSI_ARGS_((Tcl_HashTable *tablePtr, + VOID *keyPtr)); +typedef int (Tcl_CompareHashKeysProc) _ANSI_ARGS_((VOID *keyPtr, + Tcl_HashEntry *hPtr)); +typedef Tcl_HashEntry *(Tcl_AllocHashEntryProc) _ANSI_ARGS_(( + Tcl_HashTable *tablePtr, VOID *keyPtr)); +typedef void (Tcl_FreeHashEntryProc) _ANSI_ARGS_((Tcl_HashEntry *hPtr)); + +/* + * This flag controls whether the hash table stores the hash of a key, or + * recalculates it. There should be no reason for turning this flag off as it + * is completely binary and source compatible unless you directly access the + * bucketPtr member of the Tcl_HashTableEntry structure. This member has been + * removed and the space used to store the hash value. + */ + +#ifndef TCL_HASH_KEY_STORE_HASH +# define TCL_HASH_KEY_STORE_HASH 1 +#endif /* * Structure definition for an entry in a hash table. No-one outside Tcl @@ -1205,10 +1118,16 @@ struct Tcl_HashEntry { Tcl_HashEntry *nextPtr; /* Pointer to next entry in this hash bucket, * or NULL for end of chain. */ Tcl_HashTable *tablePtr; /* Pointer to table containing entry. */ - void *hash; /* Hash value, stored as pointer to ensure +#if TCL_HASH_KEY_STORE_HASH + VOID *hash; /* Hash value, stored as pointer to ensure * that the offsets of the fields in this * structure are not changed. */ - void *clientData; /* Application stores something here with +#else + Tcl_HashEntry **bucketPtr; /* Pointer to bucket that points to first + * entry in this entry's chain: used for + * deleting the entry. */ +#endif + ClientData clientData; /* Application stores something here with * Tcl_SetHashValue. */ union { /* Key has one of these forms: */ char *oneWordValue; /* One-word value for key. */ @@ -1216,7 +1135,7 @@ struct Tcl_HashEntry { int words[1]; /* Multiple integer words for key. The actual * size will be as large as necessary for this * table's keys. */ - char string[1]; /* String for key. The actual size will be as + char string[4]; /* String for key. The actual size will be as * large as needed to hold the key. */ } key; /* MUST BE LAST FIELD IN RECORD!! */ }; @@ -1296,31 +1215,26 @@ struct Tcl_HashTable { Tcl_HashEntry *staticBuckets[TCL_SMALL_HASH_TABLE]; /* Bucket array used for small tables (to * avoid mallocs and frees). */ - Tcl_Size numBuckets; /* Total number of buckets allocated at + int numBuckets; /* Total number of buckets allocated at * **bucketPtr. */ - Tcl_Size numEntries; /* Total number of entries present in + int numEntries; /* Total number of entries present in * table. */ - Tcl_Size rebuildSize; /* Enlarge table when numEntries gets to be + int rebuildSize; /* Enlarge table when numEntries gets to be * this large. */ -#if TCL_MAJOR_VERSION > 8 - size_t mask; /* Mask value used in hashing function. */ -#endif int downShift; /* Shift count used in hashing function. * Designed to use high-order bits of * randomized keys. */ -#if TCL_MAJOR_VERSION < 9 - int mask; /* Mask value used in hashing function. */ -#endif + int mask; /* Mask value used in hashing function. */ int keyType; /* Type of keys used in this table. It's * either TCL_CUSTOM_KEYS, TCL_STRING_KEYS, * TCL_ONE_WORD_KEYS, or an integer giving the * number of ints that is the size of the * key. */ - Tcl_HashEntry *(*findProc) (Tcl_HashTable *tablePtr, const char *key); - Tcl_HashEntry *(*createProc) (Tcl_HashTable *tablePtr, const char *key, - int *newPtr); - const Tcl_HashKeyType *typePtr; - /* Type of the keys used in the + Tcl_HashEntry *(*findProc) _ANSI_ARGS_((Tcl_HashTable *tablePtr, + CONST char *key)); + Tcl_HashEntry *(*createProc) _ANSI_ARGS_((Tcl_HashTable *tablePtr, + CONST char *key, int *newPtr)); + Tcl_HashKeyType *typePtr; /* Type of the keys used in the * Tcl_HashTable. */ }; @@ -1331,7 +1245,7 @@ struct Tcl_HashTable { typedef struct Tcl_HashSearch { Tcl_HashTable *tablePtr; /* Table being searched. */ - Tcl_Size nextIndex; /* Index of next bucket to be enumerated after + int nextIndex; /* Index of next bucket to be enumerated after * present one. */ Tcl_HashEntry *nextEntryPtr;/* Next entry to be enumerated in the current * bucket. */ @@ -1349,19 +1263,19 @@ typedef struct Tcl_HashSearch { * TCL_CUSTOM_PTR_KEYS: The keys are pointers to arbitrary types, the * pointer is stored in the entry. * - * While maintaining binary compatibility the above have to be distinct values + * While maintaining binary compatability the above have to be distinct values * as they are used to differentiate between old versions of the hash table - * which don't have a typePtr and new ones which do. Once binary compatibility + * which don't have a typePtr and new ones which do. Once binary compatability * is discarded in favour of making more wide spread changes TCL_STRING_KEYS * can be the same as TCL_CUSTOM_TYPE_KEYS, and TCL_ONE_WORD_KEYS can be the * same as TCL_CUSTOM_PTR_KEYS because they simply determine how the key is * accessed from the entry and not the behaviour. */ -#define TCL_STRING_KEYS (0) -#define TCL_ONE_WORD_KEYS (1) -#define TCL_CUSTOM_TYPE_KEYS (-2) -#define TCL_CUSTOM_PTR_KEYS (-1) +#define TCL_STRING_KEYS 0 +#define TCL_ONE_WORD_KEYS 1 +#define TCL_CUSTOM_TYPE_KEYS -2 +#define TCL_CUSTOM_PTR_KEYS -1 /* * Structure definition for information used to keep track of searches through @@ -1372,13 +1286,12 @@ typedef struct Tcl_HashSearch { typedef struct { void *next; /* Search position for underlying hash * table. */ - TCL_HASH_TYPE epoch; /* Epoch marker for dictionary being searched, - * or 0 if search has terminated. */ + int epoch; /* Epoch marker for dictionary being searched, + * or -1 if search has terminated. */ Tcl_Dict dictionaryPtr; /* Reference to dictionary being searched. */ } Tcl_DictSearch; - + /* - *---------------------------------------------------------------------------- * Flag values to pass to Tcl_DoOneEvent to disable searches for some kinds of * events: */ @@ -1405,12 +1318,11 @@ struct Tcl_Event { }; /* - * Positions to pass to Tcl_QueueEvent/Tcl_ThreadQueueEvent: + * Positions to pass to Tcl_QueueEvent: */ typedef enum { - TCL_QUEUE_TAIL, TCL_QUEUE_HEAD, TCL_QUEUE_MARK, - TCL_QUEUE_ALERT_IF_EMPTY=4 + TCL_QUEUE_TAIL, TCL_QUEUE_HEAD, TCL_QUEUE_MARK } Tcl_QueuePosition; /* @@ -1432,18 +1344,19 @@ typedef struct Tcl_Time { long usec; /* Microseconds. */ } Tcl_Time; -typedef void (Tcl_SetTimerProc) (CONST86 Tcl_Time *timePtr); -typedef int (Tcl_WaitForEventProc) (CONST86 Tcl_Time *timePtr); +typedef void (Tcl_SetTimerProc) _ANSI_ARGS_((Tcl_Time *timePtr)); +typedef int (Tcl_WaitForEventProc) _ANSI_ARGS_((Tcl_Time *timePtr)); /* * TIP #233 (Virtualized Time) */ -typedef void (Tcl_GetTimeProc) (Tcl_Time *timebuf, void *clientData); -typedef void (Tcl_ScaleTimeProc) (Tcl_Time *timebuf, void *clientData); +typedef void (Tcl_GetTimeProc) _ANSI_ARGS_((Tcl_Time *timebuf, + ClientData clientData)); +typedef void (Tcl_ScaleTimeProc) _ANSI_ARGS_((Tcl_Time *timebuf, + ClientData clientData)); /* - *---------------------------------------------------------------------------- * Bits to pass to Tcl_CreateFileHandler and Tcl_CreateChannelHandler to * indicate what sorts of events are of interest: */ @@ -1476,22 +1389,16 @@ typedef void (Tcl_ScaleTimeProc) (Tcl_Time *timebuf, void *clientData); * interface. */ -#if TCL_MAJOR_VERSION > 8 -# define TCL_CLOSE2PROC NULL -#else -# define TCL_CLOSE2PROC ((Tcl_DriverCloseProc *)(void *)(size_t)1) -#endif +#define TCL_CLOSE2PROC ((Tcl_DriverCloseProc *) 1) /* * Channel version tag. This was introduced in 8.3.2/8.4. */ -#ifndef TCL_NO_DEPRECATED #define TCL_CHANNEL_VERSION_1 ((Tcl_ChannelTypeVersion) 0x1) #define TCL_CHANNEL_VERSION_2 ((Tcl_ChannelTypeVersion) 0x2) #define TCL_CHANNEL_VERSION_3 ((Tcl_ChannelTypeVersion) 0x3) #define TCL_CHANNEL_VERSION_4 ((Tcl_ChannelTypeVersion) 0x4) -#endif #define TCL_CHANNEL_VERSION_5 ((Tcl_ChannelTypeVersion) 0x5) /* @@ -1505,41 +1412,45 @@ typedef void (Tcl_ScaleTimeProc) (Tcl_Time *timebuf, void *clientData); * Typedefs for the various operations in a channel type: */ -typedef int (Tcl_DriverBlockModeProc) (void *instanceData, int mode); -typedef int (Tcl_DriverCloseProc) (void *instanceData, - Tcl_Interp *interp); -typedef int (Tcl_DriverClose2Proc) (void *instanceData, - Tcl_Interp *interp, int flags); -typedef int (Tcl_DriverInputProc) (void *instanceData, char *buf, - int toRead, int *errorCodePtr); -typedef int (Tcl_DriverOutputProc) (void *instanceData, - const char *buf, int toWrite, int *errorCodePtr); -typedef int (Tcl_DriverSeekProc) (void *instanceData, long offset, - int mode, int *errorCodePtr); -typedef int (Tcl_DriverSetOptionProc) (void *instanceData, - Tcl_Interp *interp, const char *optionName, - const char *value); -typedef int (Tcl_DriverGetOptionProc) (void *instanceData, - Tcl_Interp *interp, const char *optionName, - Tcl_DString *dsPtr); -typedef void (Tcl_DriverWatchProc) (void *instanceData, int mask); -typedef int (Tcl_DriverGetHandleProc) (void *instanceData, - int direction, void **handlePtr); -typedef int (Tcl_DriverFlushProc) (void *instanceData); -typedef int (Tcl_DriverHandlerProc) (void *instanceData, - int interestMask); -typedef long long (Tcl_DriverWideSeekProc) (void *instanceData, - long long offset, int mode, int *errorCodePtr); +typedef int (Tcl_DriverBlockModeProc) _ANSI_ARGS_(( + ClientData instanceData, int mode)); +typedef int (Tcl_DriverCloseProc) _ANSI_ARGS_((ClientData instanceData, + Tcl_Interp *interp)); +typedef int (Tcl_DriverClose2Proc) _ANSI_ARGS_((ClientData instanceData, + Tcl_Interp *interp, int flags)); +typedef int (Tcl_DriverInputProc) _ANSI_ARGS_((ClientData instanceData, + char *buf, int toRead, int *errorCodePtr)); +typedef int (Tcl_DriverOutputProc) _ANSI_ARGS_((ClientData instanceData, + CONST84 char *buf, int toWrite, int *errorCodePtr)); +typedef int (Tcl_DriverSeekProc) _ANSI_ARGS_((ClientData instanceData, + long offset, int mode, int *errorCodePtr)); +typedef int (Tcl_DriverSetOptionProc) _ANSI_ARGS_(( + ClientData instanceData, Tcl_Interp *interp, + CONST char *optionName, CONST char *value)); +typedef int (Tcl_DriverGetOptionProc) _ANSI_ARGS_(( + ClientData instanceData, Tcl_Interp *interp, + CONST84 char *optionName, Tcl_DString *dsPtr)); +typedef void (Tcl_DriverWatchProc) _ANSI_ARGS_(( + ClientData instanceData, int mask)); +typedef int (Tcl_DriverGetHandleProc) _ANSI_ARGS_(( + ClientData instanceData, int direction, + ClientData *handlePtr)); +typedef int (Tcl_DriverFlushProc) _ANSI_ARGS_((ClientData instanceData)); +typedef int (Tcl_DriverHandlerProc) _ANSI_ARGS_(( + ClientData instanceData, int interestMask)); +typedef Tcl_WideInt (Tcl_DriverWideSeekProc) _ANSI_ARGS_(( + ClientData instanceData, Tcl_WideInt offset, + int mode, int *errorCodePtr)); /* * TIP #218, Channel Thread Actions */ -typedef void (Tcl_DriverThreadActionProc) (void *instanceData, - int action); +typedef void (Tcl_DriverThreadActionProc) _ANSI_ARGS_ (( + ClientData instanceData, int action)); /* * TIP #208, File Truncation (etc.) */ -typedef int (Tcl_DriverTruncateProc) (void *instanceData, - long long length); +typedef int (Tcl_DriverTruncateProc) _ANSI_ARGS_(( + ClientData instanceData, Tcl_WideInt length)); /* * struct Tcl_ChannelType: @@ -1553,14 +1464,14 @@ typedef int (Tcl_DriverTruncateProc) (void *instanceData, */ typedef struct Tcl_ChannelType { - const char *typeName; /* The name of the channel type in Tcl + char *typeName; /* The name of the channel type in Tcl * commands. This storage is owned by channel * type. */ Tcl_ChannelTypeVersion version; /* Version of the channel type. */ Tcl_DriverCloseProc *closeProc; /* Function to call to close the channel, or - * NULL or TCL_CLOSE2PROC if the close2Proc should be + * TCL_CLOSE2PROC if the close2Proc should be * used instead. */ Tcl_DriverInputProc *inputProc; /* Function to call for input on channel. */ @@ -1612,6 +1523,7 @@ typedef struct Tcl_ChannelType { /* Function to call to notify the driver of * thread specific activity for a channel. May * be NULL. */ + /* * Only valid in TCL_CHANNEL_VERSION_5 channels or later. * TIP #208, File Truncation. @@ -1633,7 +1545,6 @@ typedef struct Tcl_ChannelType { * mode. */ /* - *---------------------------------------------------------------------------- * Enum for different types of file paths. */ @@ -1685,67 +1596,78 @@ typedef struct Tcl_GlobTypeData { * Typedefs for the various filesystem operations: */ -typedef int (Tcl_FSStatProc) (Tcl_Obj *pathPtr, Tcl_StatBuf *buf); -typedef int (Tcl_FSAccessProc) (Tcl_Obj *pathPtr, int mode); -typedef Tcl_Channel (Tcl_FSOpenFileChannelProc) (Tcl_Interp *interp, - Tcl_Obj *pathPtr, int mode, int permissions); -typedef int (Tcl_FSMatchInDirectoryProc) (Tcl_Interp *interp, Tcl_Obj *result, - Tcl_Obj *pathPtr, const char *pattern, Tcl_GlobTypeData *types); -typedef Tcl_Obj * (Tcl_FSGetCwdProc) (Tcl_Interp *interp); -typedef int (Tcl_FSChdirProc) (Tcl_Obj *pathPtr); -typedef int (Tcl_FSLstatProc) (Tcl_Obj *pathPtr, Tcl_StatBuf *buf); -typedef int (Tcl_FSCreateDirectoryProc) (Tcl_Obj *pathPtr); -typedef int (Tcl_FSDeleteFileProc) (Tcl_Obj *pathPtr); -typedef int (Tcl_FSCopyDirectoryProc) (Tcl_Obj *srcPathPtr, - Tcl_Obj *destPathPtr, Tcl_Obj **errorPtr); -typedef int (Tcl_FSCopyFileProc) (Tcl_Obj *srcPathPtr, Tcl_Obj *destPathPtr); -typedef int (Tcl_FSRemoveDirectoryProc) (Tcl_Obj *pathPtr, int recursive, - Tcl_Obj **errorPtr); -typedef int (Tcl_FSRenameFileProc) (Tcl_Obj *srcPathPtr, Tcl_Obj *destPathPtr); -typedef void (Tcl_FSUnloadFileProc) (Tcl_LoadHandle loadHandle); -typedef Tcl_Obj * (Tcl_FSListVolumesProc) (void); +typedef int (Tcl_FSStatProc) _ANSI_ARGS_((Tcl_Obj *pathPtr, Tcl_StatBuf *buf)); +typedef int (Tcl_FSAccessProc) _ANSI_ARGS_((Tcl_Obj *pathPtr, int mode)); +typedef Tcl_Channel (Tcl_FSOpenFileChannelProc) _ANSI_ARGS_(( + Tcl_Interp *interp, Tcl_Obj *pathPtr, int mode, int permissions)); +typedef int (Tcl_FSMatchInDirectoryProc) _ANSI_ARGS_((Tcl_Interp *interp, + Tcl_Obj *result, Tcl_Obj *pathPtr, CONST char *pattern, + Tcl_GlobTypeData * types)); +typedef Tcl_Obj * (Tcl_FSGetCwdProc) _ANSI_ARGS_((Tcl_Interp *interp)); +typedef int (Tcl_FSChdirProc) _ANSI_ARGS_((Tcl_Obj *pathPtr)); +typedef int (Tcl_FSLstatProc) _ANSI_ARGS_((Tcl_Obj *pathPtr, + Tcl_StatBuf *buf)); +typedef int (Tcl_FSCreateDirectoryProc) _ANSI_ARGS_((Tcl_Obj *pathPtr)); +typedef int (Tcl_FSDeleteFileProc) _ANSI_ARGS_((Tcl_Obj *pathPtr)); +typedef int (Tcl_FSCopyDirectoryProc) _ANSI_ARGS_((Tcl_Obj *srcPathPtr, + Tcl_Obj *destPathPtr, Tcl_Obj **errorPtr)); +typedef int (Tcl_FSCopyFileProc) _ANSI_ARGS_((Tcl_Obj *srcPathPtr, + Tcl_Obj *destPathPtr)); +typedef int (Tcl_FSRemoveDirectoryProc) _ANSI_ARGS_((Tcl_Obj *pathPtr, + int recursive, Tcl_Obj **errorPtr)); +typedef int (Tcl_FSRenameFileProc) _ANSI_ARGS_((Tcl_Obj *srcPathPtr, + Tcl_Obj *destPathPtr)); +typedef void (Tcl_FSUnloadFileProc) _ANSI_ARGS_((Tcl_LoadHandle loadHandle)); +typedef Tcl_Obj * (Tcl_FSListVolumesProc) _ANSI_ARGS_((void)); /* We have to declare the utime structure here. */ struct utimbuf; -typedef int (Tcl_FSUtimeProc) (Tcl_Obj *pathPtr, struct utimbuf *tval); -typedef int (Tcl_FSNormalizePathProc) (Tcl_Interp *interp, Tcl_Obj *pathPtr, - int nextCheckpoint); -typedef int (Tcl_FSFileAttrsGetProc) (Tcl_Interp *interp, int index, - Tcl_Obj *pathPtr, Tcl_Obj **objPtrRef); -typedef const char *CONST86 * (Tcl_FSFileAttrStringsProc) (Tcl_Obj *pathPtr, - Tcl_Obj **objPtrRef); -typedef int (Tcl_FSFileAttrsSetProc) (Tcl_Interp *interp, int index, - Tcl_Obj *pathPtr, Tcl_Obj *objPtr); -typedef Tcl_Obj * (Tcl_FSLinkProc) (Tcl_Obj *pathPtr, Tcl_Obj *toPtr, - int linkType); -typedef int (Tcl_FSLoadFileProc) (Tcl_Interp *interp, Tcl_Obj *pathPtr, - Tcl_LoadHandle *handlePtr, Tcl_FSUnloadFileProc **unloadProcPtr); -typedef int (Tcl_FSPathInFilesystemProc) (Tcl_Obj *pathPtr, - void **clientDataPtr); -typedef Tcl_Obj * (Tcl_FSFilesystemPathTypeProc) (Tcl_Obj *pathPtr); -typedef Tcl_Obj * (Tcl_FSFilesystemSeparatorProc) (Tcl_Obj *pathPtr); -typedef void (Tcl_FSFreeInternalRepProc) (void *clientData); -typedef void *(Tcl_FSDupInternalRepProc) (void *clientData); -typedef Tcl_Obj * (Tcl_FSInternalToNormalizedProc) (void *clientData); -typedef void *(Tcl_FSCreateInternalRepProc) (Tcl_Obj *pathPtr); +typedef int (Tcl_FSUtimeProc) _ANSI_ARGS_((Tcl_Obj *pathPtr, + struct utimbuf *tval)); +typedef int (Tcl_FSNormalizePathProc) _ANSI_ARGS_((Tcl_Interp *interp, + Tcl_Obj *pathPtr, int nextCheckpoint)); +typedef int (Tcl_FSFileAttrsGetProc) _ANSI_ARGS_((Tcl_Interp *interp, + int index, Tcl_Obj *pathPtr, Tcl_Obj **objPtrRef)); +typedef CONST char ** (Tcl_FSFileAttrStringsProc) _ANSI_ARGS_(( + Tcl_Obj *pathPtr, Tcl_Obj **objPtrRef)); +typedef int (Tcl_FSFileAttrsSetProc) _ANSI_ARGS_((Tcl_Interp *interp, + int index, Tcl_Obj *pathPtr, Tcl_Obj *objPtr)); +typedef Tcl_Obj * (Tcl_FSLinkProc) _ANSI_ARGS_((Tcl_Obj *pathPtr, + Tcl_Obj *toPtr, int linkType)); +typedef int (Tcl_FSLoadFileProc) _ANSI_ARGS_((Tcl_Interp * interp, + Tcl_Obj *pathPtr, Tcl_LoadHandle *handlePtr, + Tcl_FSUnloadFileProc **unloadProcPtr)); +typedef int (Tcl_FSPathInFilesystemProc) _ANSI_ARGS_((Tcl_Obj *pathPtr, + ClientData *clientDataPtr)); +typedef Tcl_Obj * (Tcl_FSFilesystemPathTypeProc) _ANSI_ARGS_(( + Tcl_Obj *pathPtr)); +typedef Tcl_Obj * (Tcl_FSFilesystemSeparatorProc) _ANSI_ARGS_(( + Tcl_Obj *pathPtr)); +typedef void (Tcl_FSFreeInternalRepProc) _ANSI_ARGS_((ClientData clientData)); +typedef ClientData (Tcl_FSDupInternalRepProc) _ANSI_ARGS_(( + ClientData clientData)); +typedef Tcl_Obj * (Tcl_FSInternalToNormalizedProc) _ANSI_ARGS_(( + ClientData clientData)); +typedef ClientData (Tcl_FSCreateInternalRepProc) _ANSI_ARGS_(( + Tcl_Obj *pathPtr)); typedef struct Tcl_FSVersion_ *Tcl_FSVersion; /* - *---------------------------------------------------------------------------- + *---------------------------------------------------------------- * Data structures related to hooking into the filesystem + *---------------------------------------------------------------- */ /* * Filesystem version tag. This was introduced in 8.4. */ - #define TCL_FILESYSTEM_VERSION_1 ((Tcl_FSVersion) 0x1) /* * struct Tcl_Filesystem: * * One such structure exists for each type (kind) of filesystem. It collects - * together the functions that form the interface for a particulr the + * together in one place all the functions that are part of the specific * filesystem. Tcl always accesses the filesystem through one of these * structures. * @@ -1755,124 +1677,152 @@ typedef struct Tcl_FSVersion_ *Tcl_FSVersion; */ typedef struct Tcl_Filesystem { - const char *typeName; /* The name of the filesystem. */ - Tcl_Size structureLength; /* Length of this structure, so future binary + CONST char *typeName; /* The name of the filesystem. */ + int structureLength; /* Length of this structure, so future binary * compatibility can be assured. */ Tcl_FSVersion version; /* Version of the filesystem type. */ Tcl_FSPathInFilesystemProc *pathInFilesystemProc; - /* Determines whether the pathname is in this + /* Function to check whether a path is in this * filesystem. This is the most important * filesystem function. */ Tcl_FSDupInternalRepProc *dupInternalRepProc; - /* Duplicates the internal handle of the node. - * If it is NULL, the filesystem is less - * performant. */ + /* Function to duplicate internal fs rep. May + * be NULL (but then fs is less efficient). */ Tcl_FSFreeInternalRepProc *freeInternalRepProc; - /* Frees the internal handle of the node. NULL - * only if there is no need to free resources - * used for the internal handle. */ + /* Function to free internal fs rep. Must be + * implemented if internal representations + * need freeing, otherwise it can be NULL. */ Tcl_FSInternalToNormalizedProc *internalToNormalizedProc; - /* Converts the internal handle to a normalized - * path. NULL if the filesystem creates nodes - * having no pathname. */ + /* Function to convert internal representation + * to a normalized path. Only required if the + * fs creates pure path objects with no + * string/path representation. */ Tcl_FSCreateInternalRepProc *createInternalRepProc; - /* Creates an internal handle for a pathname. - * May be NULL if pathnames have no internal - * handle or if pathInFilesystemProc always - * immediately creates an internal - * representation for pathnames in the - * filesystem. */ + /* Function to create a filesystem-specific + * internal representation. May be NULL if + * paths have no internal representation, or + * if the Tcl_FSPathInFilesystemProc for this + * filesystem always immediately creates an + * internal representation for paths it + * accepts. */ Tcl_FSNormalizePathProc *normalizePathProc; - /* Normalizes a path. Should be implemented if - * the filesystems supports multiple paths to - * the same node. */ + /* Function to normalize a path. Should be + * implemented for all filesystems which can + * have multiple string representations for + * the same path object. */ Tcl_FSFilesystemPathTypeProc *filesystemPathTypeProc; - /* Determines the type of a path in this - * filesystem. May be NULL. */ + /* Function to determine the type of a path in + * this filesystem. May be NULL. */ Tcl_FSFilesystemSeparatorProc *filesystemSeparatorProc; - /* Produces the separator character(s) for this - * filesystem. Must not be NULL. */ - Tcl_FSStatProc *statProc; /* Called by 'Tcl_FSStat()'. Provided by any - * reasonable filesystem. */ + /* Function to return the separator + * character(s) for this filesystem. Must be + * implemented. */ + Tcl_FSStatProc *statProc; /* Function to process a 'Tcl_FSStat()' call. + * Must be implemented for any reasonable + * filesystem. */ Tcl_FSAccessProc *accessProc; - /* Called by 'Tcl_FSAccess()'. Implemented by - * any reasonable filesystem. */ + /* Function to process a 'Tcl_FSAccess()' + * call. Must be implemented for any + * reasonable filesystem. */ Tcl_FSOpenFileChannelProc *openFileChannelProc; - /* Called by 'Tcl_FSOpenFileChannel()'. - * Provided by any reasonable filesystem. */ + /* Function to process a + * 'Tcl_FSOpenFileChannel()' call. Must be + * implemented for any reasonable + * filesystem. */ Tcl_FSMatchInDirectoryProc *matchInDirectoryProc; - /* Called by 'Tcl_FSMatchInDirectory()'. NULL - * if the filesystem does not support glob or - * recursive copy. */ - Tcl_FSUtimeProc *utimeProc; /* Called by 'Tcl_FSUtime()', by 'file - * mtime' to set (not read) times, 'file - * atime', and the open-r/open-w/fcopy variant - * of 'file copy'. */ - Tcl_FSLinkProc *linkProc; /* Called by 'Tcl_FSLink()'. NULL if reading or - * creating links is not supported. */ + /* Function to process a + * 'Tcl_FSMatchInDirectory()'. If not + * implemented, then glob and recursive copy + * functionality will be lacking in the + * filesystem. */ + Tcl_FSUtimeProc *utimeProc; /* Function to process a 'Tcl_FSUtime()' call. + * Required to allow setting (not reading) of + * times with 'file mtime', 'file atime' and + * the open-r/open-w/fcopy implementation of + * 'file copy'. */ + Tcl_FSLinkProc *linkProc; /* Function to process a 'Tcl_FSLink()' call. + * Should be implemented only if the + * filesystem supports links (reading or + * creating). */ Tcl_FSListVolumesProc *listVolumesProc; - /* Lists filesystem volumes added by this - * filesystem. NULL if the filesystem does not - * use volumes. */ + /* Function to list any filesystem volumes + * added by this filesystem. Should be + * implemented only if the filesystem adds + * volumes at the head of the filesystem. */ Tcl_FSFileAttrStringsProc *fileAttrStringsProc; - /* List all valid attributes strings. NULL if - * the filesystem does not support the 'file - * attributes' command. Can be used to attach - * arbitrary additional data to files in a - * filesystem. */ + /* Function to list all attributes strings + * which are valid for this filesystem. If not + * implemented the filesystem will not support + * the 'file attributes' command. This allows + * arbitrary additional information to be + * attached to files in the filesystem. */ Tcl_FSFileAttrsGetProc *fileAttrsGetProc; - /* Called by 'Tcl_FSFileAttrsGet()' and by - * 'file attributes'. */ + /* Function to process a + * 'Tcl_FSFileAttrsGet()' call, used by 'file + * attributes'. */ Tcl_FSFileAttrsSetProc *fileAttrsSetProc; - /* Called by 'Tcl_FSFileAttrsSet()' and by - * 'file attributes'. */ + /* Function to process a + * 'Tcl_FSFileAttrsSet()' call, used by 'file + * attributes'. */ Tcl_FSCreateDirectoryProc *createDirectoryProc; - /* Called by 'Tcl_FSCreateDirectory()'. May be - * NULL if the filesystem is read-only. */ + /* Function to process a + * 'Tcl_FSCreateDirectory()' call. Should be + * implemented unless the FS is read-only. */ Tcl_FSRemoveDirectoryProc *removeDirectoryProc; - /* Called by 'Tcl_FSRemoveDirectory()'. May be - * NULL if the filesystem is read-only. */ + /* Function to process a + * 'Tcl_FSRemoveDirectory()' call. Should be + * implemented unless the FS is read-only. */ Tcl_FSDeleteFileProc *deleteFileProc; - /* Called by 'Tcl_FSDeleteFile()' May be NULL - * if the filesystem is is read-only. */ + /* Function to process a 'Tcl_FSDeleteFile()' + * call. Should be implemented unless the FS + * is read-only. */ Tcl_FSCopyFileProc *copyFileProc; - /* Called by 'Tcl_FSCopyFile()'. If NULL, for - * a copy operation at the script level (not - * C) Tcl uses open-r, open-w and fcopy. */ + /* Function to process a 'Tcl_FSCopyFile()' + * call. If not implemented Tcl will fall back + * on open-r, open-w and fcopy as a copying + * mechanism, for copying actions initiated in + * Tcl (not C). */ Tcl_FSRenameFileProc *renameFileProc; - /* Called by 'Tcl_FSRenameFile()'. If NULL, for - * a rename operation at the script level (not - * C) Tcl performs a copy operation followed - * by a delete operation. */ + /* Function to process a 'Tcl_FSRenameFile()' + * call. If not implemented, Tcl will fall + * back on a copy and delete mechanism, for + * rename actions initiated in Tcl (not C). */ Tcl_FSCopyDirectoryProc *copyDirectoryProc; - /* Called by 'Tcl_FSCopyDirectory()'. If NULL, - * for a copy operation at the script level - * (not C) Tcl recursively creates directories - * and copies files. */ - Tcl_FSLstatProc *lstatProc; /* Called by 'Tcl_FSLstat()'. If NULL, Tcl - * attempts to use 'statProc' instead. */ + /* Function to process a + * 'Tcl_FSCopyDirectory()' call. If not + * implemented, Tcl will fall back on a + * recursive create-dir, file copy mechanism, + * for copying actions initiated in Tcl (not + * C). */ + Tcl_FSLstatProc *lstatProc; /* Function to process a 'Tcl_FSLstat()' call. + * If not implemented, Tcl will attempt to use + * the 'statProc' defined above instead. */ Tcl_FSLoadFileProc *loadFileProc; - /* Called by 'Tcl_FSLoadFile()'. If NULL, Tcl - * performs a copy to a temporary file in the - * native filesystem and then calls - * Tcl_FSLoadFile() on that temporary copy. */ + /* Function to process a 'Tcl_FSLoadFile()' + * call. If not implemented, Tcl will fall + * back on a copy to native-temp followed by a + * Tcl_FSLoadFile on that temporary copy. */ Tcl_FSGetCwdProc *getCwdProc; - /* Called by 'Tcl_FSGetCwd()'. Normally NULL. - * Usually only called once: If 'getcwd' is - * called before 'chdir' is ever called. */ - Tcl_FSChdirProc *chdirProc; /* Called by 'Tcl_FSChdir()'. For a virtual - * filesystem, chdirProc just returns zero - * (success) if the pathname is a valid - * directory, and some other value otherwise. - * For A real filesystem, chdirProc performs - * the correct action, e.g. calls the system - * 'chdir' function. If not implemented, then - * 'cd' and 'pwd' fail for a pathname in this - * filesystem. On success Tcl stores the - * pathname for use by GetCwd. If NULL, Tcl - * performs records the pathname as the new - * current directory if it passes a series of - * directory access checks. */ + /* Function to process a 'Tcl_FSGetCwd()' + * call. Most filesystems need not implement + * this. It will usually only be called once, + * if 'getcwd' is called before 'chdir'. May + * be NULL. */ + Tcl_FSChdirProc *chdirProc; /* Function to process a 'Tcl_FSChdir()' call. + * If filesystems do not implement this, it + * will be emulated by a series of directory + * access checks. Otherwise, virtual + * filesystems which do implement it need only + * respond with a positive return result if + * the dirName is a valid directory in their + * filesystem. They need not remember the + * result, since that will be automatically + * remembered for use by GetCwd. Real + * filesystems should carry out the correct + * action (i.e. call the correct system + * 'chdir' api). If not implemented, then 'cd' + * and 'pwd' will fail inside the + * filesystem. */ } Tcl_Filesystem; /* @@ -1889,7 +1839,6 @@ typedef struct Tcl_Filesystem { #define TCL_CREATE_HARD_LINK 0x02 /* - *---------------------------------------------------------------------------- * The following structure represents the Notifier functions that you can * override with the Tcl_SetNotifier call. */ @@ -1904,11 +1853,73 @@ typedef struct Tcl_NotifierProcs { Tcl_AlertNotifierProc *alertNotifierProc; Tcl_ServiceModeHookProc *serviceModeHookProc; } Tcl_NotifierProcs; - + /* - *---------------------------------------------------------------------------- - * The following data structures and declarations are for the new Tcl parser. + * The following structure represents a user-defined encoding. It collects + * together all the functions that are used by the specific encoding. + */ + +typedef struct Tcl_EncodingType { + CONST char *encodingName; /* The name of the encoding, e.g. "euc-jp". + * This name is the unique key for this + * encoding type. */ + Tcl_EncodingConvertProc *toUtfProc; + /* Function to convert from external encoding + * into UTF-8. */ + Tcl_EncodingConvertProc *fromUtfProc; + /* Function to convert from UTF-8 into + * external encoding. */ + Tcl_EncodingFreeProc *freeProc; + /* If non-NULL, function to call when this + * encoding is deleted. */ + ClientData clientData; /* Arbitrary value associated with encoding + * type. Passed to conversion functions. */ + int nullSize; /* Number of zero bytes that signify + * end-of-string in this encoding. This number + * is used to determine the source string + * length when the srcLen argument is + * negative. Must be 1 or 2. */ +} Tcl_EncodingType; + +/* + * The following definitions are used as values for the conversion control + * flags argument when converting text from one character set to another: * + * TCL_ENCODING_START - Signifies that the source buffer is the first + * block in a (potentially multi-block) input + * stream. Tells the conversion function to reset + * to an initial state and perform any + * initialization that needs to occur before the + * first byte is converted. If the source buffer + * contains the entire input stream to be + * converted, this flag should be set. + * TCL_ENCODING_END - Signifies that the source buffer is the last + * block in a (potentially multi-block) input + * stream. Tells the conversion routine to + * perform any finalization that needs to occur + * after the last byte is converted and then to + * reset to an initial state. If the source + * buffer contains the entire input stream to be + * converted, this flag should be set. + * TCL_ENCODING_STOPONERROR - If set, then the converter will return + * immediately upon encountering an invalid byte + * sequence or a source character that has no + * mapping in the target encoding. If clear, then + * the converter will skip the problem, + * substituting one or more "close" characters in + * the destination buffer and then continue to + * convert the source. + */ + +#define TCL_ENCODING_START 0x01 +#define TCL_ENCODING_END 0x02 +#define TCL_ENCODING_STOPONERROR 0x04 + +/* + * The following data structures and declarations are for the new Tcl parser. + */ + +/* * For each word of a command, and for each piece of a word such as a variable * reference, one of the following structures is created to describe the * token. @@ -1917,9 +1928,9 @@ typedef struct Tcl_NotifierProcs { typedef struct Tcl_Token { int type; /* Type of token, such as TCL_TOKEN_WORD; see * below for valid types. */ - const char *start; /* First character in token. */ - Tcl_Size size; /* Number of bytes in token. */ - Tcl_Size numComponents; /* If this token is composed of other tokens, + CONST char *start; /* First character in token. */ + int size; /* Number of bytes in token. */ + int numComponents; /* If this token is composed of other tokens, * this field tells how many of them there are * (including components of components, etc.). * The component tokens immediately follow @@ -1985,7 +1996,7 @@ typedef struct Tcl_Token { * TCL_TOKEN_OPERATOR - The token describes one expression operator. * An operator might be the name of a math * function such as "abs". A TCL_TOKEN_OPERATOR - * token is always preceded by one + * token is always preceeded by one * TCL_TOKEN_SUB_EXPR token for the operator's * subexpression, and is followed by zero or more * TCL_TOKEN_SUB_EXPR tokens for the operator's @@ -2031,57 +2042,52 @@ typedef struct Tcl_Token { #define NUM_STATIC_TOKENS 20 typedef struct Tcl_Parse { - const char *commentStart; /* Pointer to # that begins the first of one + CONST char *commentStart; /* Pointer to # that begins the first of one * or more comments preceding the command. */ - Tcl_Size commentSize; /* Number of bytes in comments (up through + int commentSize; /* Number of bytes in comments (up through * newline character that terminates the last * comment). If there were no comments, this * field is 0. */ - const char *commandStart; /* First character in first word of + CONST char *commandStart; /* First character in first word of * command. */ - Tcl_Size commandSize; /* Number of bytes in command, including first + int commandSize; /* Number of bytes in command, including first * character of first word, up through the * terminating newline, close bracket, or * semicolon. */ - Tcl_Size numWords; /* Total number of words in command. May be + int numWords; /* Total number of words in command. May be * 0. */ Tcl_Token *tokenPtr; /* Pointer to first token representing the * words of the command. Initially points to * staticTokens, but may change to point to * malloc-ed space if command exceeds space in * staticTokens. */ - Tcl_Size numTokens; /* Total number of tokens in command. */ - Tcl_Size tokensAvailable; /* Total number of tokens available at + int numTokens; /* Total number of tokens in command. */ + int tokensAvailable; /* Total number of tokens available at * *tokenPtr. */ int errorType; /* One of the parsing error types defined * above. */ -#if TCL_MAJOR_VERSION > 8 - int incomplete; /* This field is set to 1 by Tcl_ParseCommand - * if the command appears to be incomplete. - * This information is used by - * Tcl_CommandComplete. */ -#endif /* * The fields below are intended only for the private use of the parser. * They should not be used by functions that invoke Tcl_ParseCommand. */ - const char *string; /* The original command string passed to + CONST char *string; /* The original command string passed to * Tcl_ParseCommand. */ - const char *end; /* Points to the character just after the last + CONST char *end; /* Points to the character just after the last * one in the command string. */ Tcl_Interp *interp; /* Interpreter to use for error reporting, or * NULL. */ - const char *term; /* Points to character in string that + CONST char *term; /* Points to character in string that * terminated most recent token. Filled in by * ParseTokens. If an error occurs, points to * beginning of region where the error * occurred (e.g. the open brace if the close * brace is missing). */ -#if TCL_MAJOR_VERSION < 9 - int incomplete; -#endif + int incomplete; /* This field is set to 1 by Tcl_ParseCommand + * if the command appears to be incomplete. + * This information is used by + * Tcl_CommandComplete. */ Tcl_Token staticTokens[NUM_STATIC_TOKENS]; /* Initial space for tokens for command. This * space should be large enough to accommodate @@ -2089,100 +2095,6 @@ typedef struct Tcl_Parse { * for very large commands that don't fit * here. */ } Tcl_Parse; - -/* - *---------------------------------------------------------------------------- - * The following structure represents a user-defined encoding. It collects - * together all the functions that are used by the specific encoding. - */ - -typedef struct Tcl_EncodingType { - const char *encodingName; /* The name of the encoding, e.g. "euc-jp". - * This name is the unique key for this - * encoding type. */ - Tcl_EncodingConvertProc *toUtfProc; - /* Function to convert from external encoding - * into UTF-8. */ - Tcl_EncodingConvertProc *fromUtfProc; - /* Function to convert from UTF-8 into - * external encoding. */ - Tcl_EncodingFreeProc *freeProc; - /* If non-NULL, function to call when this - * encoding is deleted. */ - void *clientData; /* Arbitrary value associated with encoding - * type. Passed to conversion functions. */ - Tcl_Size nullSize; /* Number of zero bytes that signify - * end-of-string in this encoding. This number - * is used to determine the source string - * length when the srcLen argument is - * negative. Must be 1, 2, or 4. */ -} Tcl_EncodingType; - -/* - * The following definitions are used as values for the conversion control - * flags argument when converting text from one character set to another: - * - * TCL_ENCODING_START - Signifies that the source buffer is the first - * block in a (potentially multi-block) input - * stream. Tells the conversion function to reset - * to an initial state and perform any - * initialization that needs to occur before the - * first byte is converted. If the source buffer - * contains the entire input stream to be - * converted, this flag should be set. - * TCL_ENCODING_END - Signifies that the source buffer is the last - * block in a (potentially multi-block) input - * stream. Tells the conversion routine to - * perform any finalization that needs to occur - * after the last byte is converted and then to - * reset to an initial state. If the source - * buffer contains the entire input stream to be - * converted, this flag should be set. - * TCL_ENCODING_STOPONERROR - If set, the converter returns immediately upon - * encountering an invalid byte sequence or a - * source character that has no mapping in the - * target encoding. If clear, the converter - * substitutes the problematic character(s) with - * one or more "close" characters in the - * destination buffer and then continues to - * convert the source. Only for Tcl 8.x. - * TCL_ENCODING_NO_TERMINATE - If set, Tcl_ExternalToUtf does not append a - * terminating NUL byte. Since it does not need - * an extra byte for a terminating NUL, it fills - * all dstLen bytes with encoded UTF-8 content if - * needed. If clear, a byte is reserved in the - * dst space for NUL termination, and a - * terminating NUL is appended. - * TCL_ENCODING_CHAR_LIMIT - If set and dstCharsPtr is not NULL, then - * Tcl_ExternalToUtf takes the initial value of - * *dstCharsPtr as a limit of the maximum number - * of chars to produce in the encoded UTF-8 - * content. Otherwise, the number of chars - * produced is controlled only by other limiting - * factors. - * TCL_ENCODING_PROFILE_* - Mutually exclusive encoding profile ids. Note - * these are bit masks. - * - * NOTE: THESE BIT DEFINITIONS SHOULD NOT OVERLAP WITH INTERNAL USE BITS - * DEFINED IN tclEncoding.c (ENCODING_INPUT et al). Be cognizant of this - * when adding bits. - */ - -#define TCL_ENCODING_START 0x01 -#define TCL_ENCODING_END 0x02 -#define TCL_ENCODING_STOPONERROR 0x04 -#define TCL_ENCODING_NO_TERMINATE 0x08 -#define TCL_ENCODING_CHAR_LIMIT 0x10 -/* Internal use bits, do not define bits in this space. See above comment */ -#define TCL_ENCODING_INTERNAL_USE_MASK 0xFF00 -/* - * Reserve top byte for profile values (disjoint, not a mask). In case of - * changes, ensure ENCODING_PROFILE_* macros in tclInt.h are modified if - * necessary. - */ -#define TCL_ENCODING_PROFILE_STRICT TCL_ENCODING_STOPONERROR -#define TCL_ENCODING_PROFILE_TCL8 0x01000000 -#define TCL_ENCODING_PROFILE_REPLACE 0x02000000 /* * The following definitions are the error codes returned by the conversion @@ -2212,24 +2124,23 @@ typedef struct Tcl_EncodingType { * TCL_ENCODING_STOPONERROR was specified. */ -#define TCL_CONVERT_MULTIBYTE (-1) -#define TCL_CONVERT_SYNTAX (-2) -#define TCL_CONVERT_UNKNOWN (-3) -#define TCL_CONVERT_NOSPACE (-4) +#define TCL_CONVERT_MULTIBYTE -1 +#define TCL_CONVERT_SYNTAX -2 +#define TCL_CONVERT_UNKNOWN -3 +#define TCL_CONVERT_NOSPACE -4 /* * The maximum number of bytes that are necessary to represent a single - * Unicode character in UTF-8. The valid values are 3 and 4. If > 3, - * then Tcl_UniChar must be 4-bytes in size (UCS-4) (the default for the - * Tcl core). If == 3, then Tcl_UniChar must be 2-bytes in size (UTF-16). + * Unicode character in UTF-8. The valid values should be 3 or 6 (or perhaps 1 + * if we want to support a non-unicode enabled core). If 3, then Tcl_UniChar + * must be 2-bytes in size (UCS-2) (the default). If 6, then Tcl_UniChar must + * be 4-bytes in size (UCS-4). At this time UCS-2 mode is the default and + * recommended mode. UCS-4 is experimental and not recommended. It works for + * the core, but most extensions expect UCS-2. */ #ifndef TCL_UTF_MAX -# ifdef BUILD_tcl -# define TCL_UTF_MAX 4 -# else -# define TCL_UTF_MAX 3 -# endif +#define TCL_UTF_MAX 3 #endif /* @@ -2237,34 +2148,34 @@ typedef struct Tcl_EncodingType { * reflected in regcustom.h. */ -#if TCL_UTF_MAX == 4 +#if TCL_UTF_MAX > 4 /* - * int isn't 100% accurate as it should be a strict 4-byte value - * (perhaps int32_t). ILP64/SILP64 systems may have troubles. The - * size of this value must be reflected correctly in regcustom.h. + * unsigned int isn't 100% accurate as it should be a strict 4-byte value + * (perhaps wchar_t). 64-bit systems may have troubles. The size of this + * value must be reflected correctly in regcustom.h and + * in tclEncoding.c. + * XXX: Tcl is currently UCS-2 and planning UTF-16 for the Unicode + * XXX: string rep that Tcl_UniChar represents. Changing the size + * XXX: of Tcl_UniChar is /not/ supported. */ -typedef int Tcl_UniChar; -#elif TCL_UTF_MAX == 3 && !defined(BUILD_tcl) -typedef unsigned short Tcl_UniChar; +typedef unsigned int Tcl_UniChar; #else -# error "This TCL_UTF_MAX value is not supported" +typedef unsigned short Tcl_UniChar; #endif - + /* - *---------------------------------------------------------------------------- * TIP #59: The following structure is used in calls 'Tcl_RegisterConfig' to * provide the system with the embedded configuration data. */ typedef struct Tcl_Config { - const char *key; /* Configuration key to register. ASCII + CONST char *key; /* Configuration key to register. ASCII * encoded, thus UTF-8. */ - const char *value; /* The value associated with the key. System + CONST char *value; /* The value associated with the key. System * encoding. */ } Tcl_Config; /* - *---------------------------------------------------------------------------- * Flags for TIP#143 limits, detailing which limits are active in an * interpreter. Used for Tcl_{Add,Remove}LimitHandler type argument. */ @@ -2277,230 +2188,68 @@ typedef struct Tcl_Config { * command- or time-limit is exceeded by an interpreter. */ -typedef void (Tcl_LimitHandlerProc) (void *clientData, Tcl_Interp *interp); -typedef void (Tcl_LimitHandlerDeleteProc) (void *clientData); - -#if 0 -/* - *---------------------------------------------------------------------------- - * We would like to provide an anonymous structure "mp_int" here, which is - * compatible with libtommath's "mp_int", but without duplicating anything - * from <tommath.h> or including <tommath.h> here. But the libtommath project - * didn't honor our request. See: <https://github.com/libtom/libtommath/pull/473> - * - * That's why this part is commented out, and we are using (void *) in - * various API's in stead of the more correct (mp_int *). - */ +typedef void (Tcl_LimitHandlerProc) _ANSI_ARGS_((ClientData clientData, + Tcl_Interp *interp)); +typedef void (Tcl_LimitHandlerDeleteProc) _ANSI_ARGS_((ClientData clientData)); -#ifndef MP_INT_DECLARED -#define MP_INT_DECLARED typedef struct mp_int mp_int; -#endif - -#endif - -/* - *---------------------------------------------------------------------------- - * Definitions needed for Tcl_ParseArgvObj routines. - * Based on tkArgv.c. - * Modifications from the original are copyright (c) Sam Bromley 2006 - */ - -typedef struct { - int type; /* Indicates the option type; see below. */ - const char *keyStr; /* The key string that flags the option in the - * argv array. */ - void *srcPtr; /* Value to be used in setting dst; usage - * depends on type.*/ - void *dstPtr; /* Address of value to be modified; usage - * depends on type.*/ - const char *helpStr; /* Documentation message describing this - * option. */ - void *clientData; /* Word to pass to function callbacks. */ -} Tcl_ArgvInfo; - -/* - * Legal values for the type field of a Tcl_ArgInfo: see the user - * documentation for details. - */ - -#define TCL_ARGV_CONSTANT 15 -#define TCL_ARGV_INT 16 -#define TCL_ARGV_STRING 17 -#define TCL_ARGV_REST 18 -#define TCL_ARGV_FLOAT 19 -#define TCL_ARGV_FUNC 20 -#define TCL_ARGV_GENFUNC 21 -#define TCL_ARGV_HELP 22 -#define TCL_ARGV_END 23 - -/* - * Types of callback functions for the TCL_ARGV_FUNC and TCL_ARGV_GENFUNC - * argument types: - */ - -typedef int (Tcl_ArgvFuncProc)(void *clientData, Tcl_Obj *objPtr, - void *dstPtr); -typedef int (Tcl_ArgvGenFuncProc)(void *clientData, Tcl_Interp *interp, - int objc, Tcl_Obj *const *objv, void *dstPtr); - -/* - * Shorthand for commonly used argTable entries. - */ - -#define TCL_ARGV_AUTO_HELP \ - {TCL_ARGV_HELP, "-help", NULL, NULL, \ - "Print summary of command-line options and abort", NULL} -#define TCL_ARGV_AUTO_REST \ - {TCL_ARGV_REST, "--", NULL, NULL, \ - "Marks the end of the options", NULL} -#define TCL_ARGV_TABLE_END \ - {TCL_ARGV_END, NULL, NULL, NULL, NULL, NULL} +#define MP_INT_DECLARED +typedef unsigned int mp_digit; +#define MP_DIGIT_DECLARED /* - *---------------------------------------------------------------------------- - * Definitions needed for Tcl_Zlib routines. [TIP #234] + * The following constant is used to test for older versions of Tcl in the + * stubs tables. * - * Constants for the format flags describing what sort of data format is - * desired/expected for the Tcl_ZlibDeflate, Tcl_ZlibInflate and - * Tcl_ZlibStreamInit functions. - */ - -#define TCL_ZLIB_FORMAT_RAW 1 -#define TCL_ZLIB_FORMAT_ZLIB 2 -#define TCL_ZLIB_FORMAT_GZIP 4 -#define TCL_ZLIB_FORMAT_AUTO 8 - -/* - * Constants that describe whether the stream is to operate in compressing or - * decompressing mode. - */ - -#define TCL_ZLIB_STREAM_DEFLATE 16 -#define TCL_ZLIB_STREAM_INFLATE 32 - -/* - * Constants giving compression levels. Use of TCL_ZLIB_COMPRESS_DEFAULT is - * recommended. - */ - -#define TCL_ZLIB_COMPRESS_NONE 0 -#define TCL_ZLIB_COMPRESS_FAST 1 -#define TCL_ZLIB_COMPRESS_BEST 9 -#define TCL_ZLIB_COMPRESS_DEFAULT (-1) - -/* - * Constants for types of flushing, used with Tcl_ZlibFlush. - */ - -#define TCL_ZLIB_NO_FLUSH 0 -#define TCL_ZLIB_FLUSH 2 -#define TCL_ZLIB_FULLFLUSH 3 -#define TCL_ZLIB_FINALIZE 4 - -/* - *---------------------------------------------------------------------------- - * Definitions needed for the Tcl_LoadFile function. [TIP #416] + * Jan Nijtman's plus patch uses 0xFCA1BACF, so we need to pick a different + * value since the stubs tables don't match. */ -#define TCL_LOAD_GLOBAL 1 -#define TCL_LOAD_LAZY 2 +#define TCL_STUB_MAGIC ((int) 0xFCA3BACF) /* - *---------------------------------------------------------------------------- - * Definitions needed for the Tcl_OpenTcpServerEx function. [TIP #456] + * The following function is required to be defined in all stubs aware + * extensions. The function is actually implemented in the stub library, not + * the main Tcl library, although there is a trivial implementation in the + * main library in case an extension is statically linked into an application. */ -#define TCL_TCPSERVER_REUSEADDR (1<<0) -#define TCL_TCPSERVER_REUSEPORT (1<<1) -/* - * Constants for special Tcl_Size-typed values, see TIP #494 - */ +EXTERN CONST char * Tcl_InitStubs _ANSI_ARGS_((Tcl_Interp *interp, + CONST char *version, int exact)); +EXTERN CONST char * TclTomMathInitializeStubs _ANSI_ARGS_(( + Tcl_Interp *interp, CONST char *version, + int epoch, int revision)); -#define TCL_IO_FAILURE ((Tcl_Size)-1) -#define TCL_AUTO_LENGTH ((Tcl_Size)-1) -#define TCL_INDEX_NONE ((Tcl_Size)-1) +#ifndef USE_TCL_STUBS /* - *---------------------------------------------------------------------------- - * Single public declaration for NRE. + * When not using stubs, make it a macro. */ -typedef int (Tcl_NRPostProc) (void *data[], Tcl_Interp *interp, - int result); +#define Tcl_InitStubs(interp, version, exact) \ + Tcl_PkgInitStubsCheck(interp, version, exact) -/* - *---------------------------------------------------------------------------- - * The following constant is used to test for older versions of Tcl in the - * stubs tables. - */ - -#if TCL_MAJOR_VERSION > 8 -# define TCL_STUB_MAGIC ((int) 0xFCA3BACB + (int) sizeof(void *)) -#else -# define TCL_STUB_MAGIC ((int) 0xFCA3BACF) #endif -/* - * The following function is required to be defined in all stubs aware - * extensions. The function is actually implemented in the stub library, not - * the main Tcl library, although there is a trivial implementation in the - * main library in case an extension is statically linked into an application. - */ - -const char * Tcl_InitStubs(Tcl_Interp *interp, const char *version, - int exact, int magic); -const char * TclTomMathInitializeStubs(Tcl_Interp *interp, - const char *version, int epoch, int revision); -#if defined(_WIN32) - TCL_NORETURN void Tcl_ConsolePanic(const char *format, ...); -#else -# define Tcl_ConsolePanic ((Tcl_PanicProc *)NULL) -#endif + /* + * TODO - tommath stubs export goes here! + */ -#ifdef USE_TCL_STUBS -# if TCL_UTF_MAX < 4 -# define Tcl_InitStubs(interp, version, exact) \ - (Tcl_InitStubs)(interp, version, \ - (exact)|(TCL_MAJOR_VERSION<<8)|(TCL_MINOR_VERSION<<16), \ - TCL_STUB_MAGIC) -# else -# define Tcl_InitStubs(interp, version, exact) \ - (Tcl_InitStubs)(interp, TCL_PATCH_LEVEL, \ - (exact)|(TCL_MAJOR_VERSION<<8)|(TCL_MINOR_VERSION<<16), \ - TCL_STUB_MAGIC) -# endif -#else -# define Tcl_InitStubs(interp, version, exact) \ - Tcl_PkgInitStubsCheck(interp, version, \ - (exact)|(TCL_MAJOR_VERSION<<8)|(TCL_MINOR_VERSION<<16)) -#endif /* * Public functions that are not accessible via the stubs table. * Tcl_GetMemoryInfo is needed for AOLserver. [Bug 1868171] */ -#define Tcl_Main(argc, argv, proc) Tcl_MainEx(argc, argv, proc, \ - ((Tcl_SetPanicProc(Tcl_ConsolePanic), Tcl_CreateInterp)())) -EXTERN void Tcl_MainEx(Tcl_Size argc, char **argv, - Tcl_AppInitProc *appInitProc, Tcl_Interp *interp); -EXTERN const char * Tcl_PkgInitStubsCheck(Tcl_Interp *interp, - const char *version, int exact); -EXTERN const char * Tcl_InitSubsystems(void); -EXTERN void Tcl_GetMemoryInfo(Tcl_DString *dsPtr); -EXTERN const char * Tcl_SetPreInitScript(const char *string); -#ifndef TCL_NO_DEPRECATED -# define Tcl_StaticPackage Tcl_StaticLibrary +EXTERN void Tcl_Main _ANSI_ARGS_((int argc, char **argv, + Tcl_AppInitProc *appInitProc)); +EXTERN CONST char * Tcl_PkgInitStubsCheck _ANSI_ARGS_((Tcl_Interp *interp, + CONST char *version, int exact)); +#if defined(TCL_THREADS) && defined(USE_THREAD_ALLOC) +EXTERN void Tcl_GetMemoryInfo _ANSI_ARGS_((Tcl_DString *dsPtr)); #endif -#ifdef _WIN32 -EXTERN const char *TclZipfs_AppHook(int *argc, wchar_t ***argv); -#else -EXTERN const char *TclZipfs_AppHook(int *argc, char ***argv); -#endif - + /* - *---------------------------------------------------------------------------- * Include the public function declarations that are accessible via the stubs * table. */ @@ -2509,19 +2258,12 @@ EXTERN const char *TclZipfs_AppHook(int *argc, char ***argv); /* * Include platform specific public function declarations that are accessible - * via the stubs table. Make all TclOO symbols MODULE_SCOPE (which only - * has effect on building it as a shared library). See ticket [3010352]. + * via the stubs table. */ -#if defined(BUILD_tcl) -# undef TCLAPI -# define TCLAPI MODULE_SCOPE -#endif - #include "tclPlatDecls.h" /* - *---------------------------------------------------------------------------- * The following declarations either map ckalloc and ckfree to malloc and * free, or they map them to functions with all sorts of debugging hooks * defined in tclCkalloc.c. @@ -2529,16 +2271,11 @@ EXTERN const char *TclZipfs_AppHook(int *argc, char ***argv); #ifdef TCL_MEM_DEBUG -# define ckalloc(x) \ - ((void *) Tcl_DbCkalloc((unsigned)(x), __FILE__, __LINE__)) -# define ckfree(x) \ - Tcl_DbCkfree((char *)(x), __FILE__, __LINE__) -# define ckrealloc(x,y) \ - ((void *) Tcl_DbCkrealloc((char *)(x), (unsigned)(y), __FILE__, __LINE__)) -# define attemptckalloc(x) \ - ((void *) Tcl_AttemptDbCkalloc((unsigned)(x), __FILE__, __LINE__)) -# define attemptckrealloc(x,y) \ - ((void *) Tcl_AttemptDbCkrealloc((char *)(x), (unsigned)(y), __FILE__, __LINE__)) +# define ckalloc(x) Tcl_DbCkalloc(x, __FILE__, __LINE__) +# define ckfree(x) Tcl_DbCkfree(x, __FILE__, __LINE__) +# define ckrealloc(x,y) Tcl_DbCkrealloc((x), (y),__FILE__, __LINE__) +# define attemptckalloc(x) Tcl_AttemptDbCkalloc(x, __FILE__, __LINE__) +# define attemptckrealloc(x,y) Tcl_AttemptDbCkrealloc((x), (y), __FILE__, __LINE__) #else /* !TCL_MEM_DEBUG */ @@ -2548,16 +2285,11 @@ EXTERN const char *TclZipfs_AppHook(int *argc, char ***argv); * memory allocator both inside and outside of the Tcl library. */ -# define ckalloc(x) \ - ((void *) Tcl_Alloc((unsigned)(x))) -# define ckfree(x) \ - Tcl_Free((char *)(x)) -# define ckrealloc(x,y) \ - ((void *) Tcl_Realloc((char *)(x), (unsigned)(y))) -# define attemptckalloc(x) \ - ((void *) Tcl_AttemptAlloc((unsigned)(x))) -# define attemptckrealloc(x,y) \ - ((void *) Tcl_AttemptRealloc((char *)(x), (unsigned)(y))) +# define ckalloc(x) Tcl_Alloc(x) +# define ckfree(x) Tcl_Free(x) +# define ckrealloc(x,y) Tcl_Realloc(x,y) +# define attemptckalloc(x) Tcl_AttemptAlloc(x) +# define attemptckrealloc(x,y) Tcl_AttemptRealloc(x,y) # undef Tcl_InitMemory # define Tcl_InitMemory(x) # undef Tcl_DumpActiveMemory @@ -2568,32 +2300,26 @@ EXTERN const char *TclZipfs_AppHook(int *argc, char ***argv); #endif /* !TCL_MEM_DEBUG */ #ifdef TCL_MEM_DEBUG -# undef Tcl_IncrRefCount # define Tcl_IncrRefCount(objPtr) \ Tcl_DbIncrRefCount(objPtr, __FILE__, __LINE__) -# undef Tcl_DecrRefCount # define Tcl_DecrRefCount(objPtr) \ Tcl_DbDecrRefCount(objPtr, __FILE__, __LINE__) -# undef Tcl_IsShared # define Tcl_IsShared(objPtr) \ Tcl_DbIsShared(objPtr, __FILE__, __LINE__) #else -# undef Tcl_IncrRefCount # define Tcl_IncrRefCount(objPtr) \ ++(objPtr)->refCount /* * Use do/while0 idiom for optimum correctness without compiler warnings. - * https://wiki.c2.com/?TrivialDoWhileLoop + * http://c2.com/cgi/wiki?TrivialDoWhileLoop */ -# undef Tcl_DecrRefCount # define Tcl_DecrRefCount(objPtr) \ do { \ Tcl_Obj *_objPtr = (objPtr); \ - if (_objPtr->refCount-- <= 1) { \ + if (--(_objPtr)->refCount <= 0) { \ TclFreeObj(_objPtr); \ } \ } while(0) -# undef Tcl_IsShared # define Tcl_IsShared(objPtr) \ ((objPtr)->refCount > 1) #endif @@ -2610,16 +2336,22 @@ EXTERN const char *TclZipfs_AppHook(int *argc, char ***argv); Tcl_DbNewBignumObj(val, __FILE__, __LINE__) # undef Tcl_NewBooleanObj # define Tcl_NewBooleanObj(val) \ - Tcl_DbNewWideIntObj((val)!=0, __FILE__, __LINE__) + Tcl_DbNewBooleanObj(val, __FILE__, __LINE__) # undef Tcl_NewByteArrayObj # define Tcl_NewByteArrayObj(bytes, len) \ Tcl_DbNewByteArrayObj(bytes, len, __FILE__, __LINE__) # undef Tcl_NewDoubleObj # define Tcl_NewDoubleObj(val) \ Tcl_DbNewDoubleObj(val, __FILE__, __LINE__) +# undef Tcl_NewIntObj +# define Tcl_NewIntObj(val) \ + Tcl_DbNewLongObj(val, __FILE__, __LINE__) # undef Tcl_NewListObj # define Tcl_NewListObj(objc, objv) \ Tcl_DbNewListObj(objc, objv, __FILE__, __LINE__) +# undef Tcl_NewLongObj +# define Tcl_NewLongObj(val) \ + Tcl_DbNewLongObj(val, __FILE__, __LINE__) # undef Tcl_NewObj # define Tcl_NewObj() \ Tcl_DbNewObj(__FILE__, __LINE__) @@ -2632,14 +2364,13 @@ EXTERN const char *TclZipfs_AppHook(int *argc, char ***argv); #endif /* TCL_MEM_DEBUG */ /* - *---------------------------------------------------------------------------- * Macros for clients to use to access fields of hash entries: */ #define Tcl_GetHashValue(h) ((h)->clientData) -#define Tcl_SetHashValue(h, value) ((h)->clientData = (void *)(value)) +#define Tcl_SetHashValue(h, value) ((h)->clientData = (ClientData) (value)) #define Tcl_GetHashKey(tablePtr, h) \ - ((void *) (((tablePtr)->keyType == TCL_ONE_WORD_KEYS || \ + ((char *) (((tablePtr)->keyType == TCL_ONE_WORD_KEYS || \ (tablePtr)->keyType == TCL_CUSTOM_PTR_KEYS) \ ? (h)->key.oneWordValue \ : (h)->key.string)) @@ -2651,42 +2382,59 @@ EXTERN const char *TclZipfs_AppHook(int *argc, char ***argv); #undef Tcl_FindHashEntry #define Tcl_FindHashEntry(tablePtr, key) \ - (*((tablePtr)->findProc))(tablePtr, (const char *)(key)) + (*((tablePtr)->findProc))(tablePtr, key) #undef Tcl_CreateHashEntry #define Tcl_CreateHashEntry(tablePtr, key, newPtr) \ - (*((tablePtr)->createProc))(tablePtr, (const char *)(key), newPtr) + (*((tablePtr)->createProc))(tablePtr, key, newPtr) /* - *---------------------------------------------------------------------------- - * Deprecated Tcl functions: + * Macros that eliminate the overhead of the thread synchronization functions + * when compiling without thread support. */ +#ifndef TCL_THREADS +#undef Tcl_MutexLock +#define Tcl_MutexLock(mutexPtr) +#undef Tcl_MutexUnlock +#define Tcl_MutexUnlock(mutexPtr) +#undef Tcl_MutexFinalize +#define Tcl_MutexFinalize(mutexPtr) +#undef Tcl_ConditionNotify +#define Tcl_ConditionNotify(condPtr) +#undef Tcl_ConditionWait +#define Tcl_ConditionWait(condPtr, mutexPtr, timePtr) +#undef Tcl_ConditionFinalize +#define Tcl_ConditionFinalize(condPtr) +#endif /* TCL_THREADS */ + #ifndef TCL_NO_DEPRECATED -/* - * These function have been renamed. The old names are deprecated, but we - * define these macros for backwards compatibility. - */ + /* + * These function have been renamed. The old names are deprecated, but we + * define these macros for backwards compatibilty. + */ # define Tcl_Ckalloc Tcl_Alloc # define Tcl_Ckfree Tcl_Free # define Tcl_Ckrealloc Tcl_Realloc # define Tcl_Return Tcl_SetResult # define Tcl_TildeSubst Tcl_TranslateFileName -#if !defined(__APPLE__) /* On OSX, there is a conflict with "mach/mach.h" */ # define panic Tcl_Panic -#endif # define panicVA Tcl_PanicVA +#endif /* - *---------------------------------------------------------------------------- * Convenience declaration of Tcl_AppInit for backwards compatibility. This * function is not *implemented* by the tcl library, so the storage class is * neither DLLEXPORT nor DLLIMPORT. */ -extern Tcl_AppInitProc Tcl_AppInit; +#undef TCL_STORAGE_CLASS +#define TCL_STORAGE_CLASS -#endif /* !TCL_NO_DEPRECATED */ +EXTERN int Tcl_AppInit _ANSI_ARGS_((Tcl_Interp *interp)); + +#undef TCL_STORAGE_CLASS +#define TCL_STORAGE_CLASS DLLIMPORT #endif /* RC_INVOKED */ |
