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