tcl.h 92 KB

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