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