tcl80.pp 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032
  1. {*
  2. * tcl.h --
  3. *
  4. * This header file describes the externally-visible facilities of the Tcl
  5. * interpreter.
  6. *
  7. * Translated to Pascal Copyright (c) 2002 by Max Artemev
  8. * aka Bert Raccoon ([email protected], [email protected])
  9. *
  10. *
  11. * Copyright (c) 1998-2000 by Scriptics Corporation.
  12. * Copyright (c) 1994-1998 Sun Microsystems, Inc.
  13. * Copyright (c) 1993-1996 Lucent Technologies.
  14. * Copyright (c) 1987-1994 John Ousterhout, The Regents of the
  15. * University of California, Berkeley.
  16. *
  17. * ***********************************************************************
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  21. * ***********************************************************************
  22. *}
  23. unit Tcl80;
  24. {$MODE OBJFPC}
  25. {$ASMMODE INTEL}
  26. {$IFNDEF WIN32}
  27. {$LINKLIB c}
  28. {$LINKLIB m}
  29. {$ENDIF}
  30. {$PACKRECORDS C}
  31. { $DEFINE USE_C}
  32. {*
  33. * I recommend you to compile and link "argv.o" file to this unit.
  34. * If you don't have the GCC and you working on the Intel platform
  35. * undefine/comment the `USE_C` macro
  36. *}
  37. {$IFDEF USE_C}
  38. {$LINK argv.o}
  39. {$ENDIF}
  40. interface
  41. // M$ Win32?
  42. {$IFDEF WIN32}
  43. uses windows;
  44. {$ENDIF}
  45. const
  46. {$IFDEF WIN32}
  47. TCL_LIBRARY = 'tcl80.dll';
  48. {$ELSE}
  49. TCL_LIBRARY = 'tcl80';
  50. {$ENDIF}
  51. TCL_DESTROYED = integer($DEADDEAD); // yeah it dead ;)
  52. TCL_OK = 0;
  53. TCL_ERROR = 1;
  54. TCL_RETURN = 2;
  55. TCL_BREAK = 3;
  56. TCL_CONTINUE = 4;
  57. TCL_RESULT_SIZE = 200;
  58. MAX_ARGV = $7FFF;
  59. TCL_VERSION_MAJOR: integer = 0;
  60. TCL_VERSION_MINOR: integer = 0;
  61. TCL_NO_EVAL = $10000;
  62. TCL_EVAL_GLOBAL = $20000;
  63. {* Flag values passed to variable-related procedures. *}
  64. TCL_GLOBAL_ONLY = 1;
  65. TCL_NAMESPACE_ONLY = 2;
  66. TCL_APPEND_VALUE = 4;
  67. TCL_LIST_ELEMENT = 8;
  68. TCL_TRACE_READS = $10;
  69. TCL_TRACE_WRITES = $20;
  70. TCL_TRACE_UNSETS = $40;
  71. TCL_TRACE_DESTROYED = $80;
  72. TCL_INTERP_DESTROYED = $100;
  73. TCL_LEAVE_ERR_MSG = $200;
  74. TCL_PARSE_PART1 = $400;
  75. {* Types for linked variables: *}
  76. TCL_LINK_INT = 1;
  77. TCL_LINK_DOUBLE = 2;
  78. TCL_LINK_BOOLEAN = 3;
  79. TCL_LINK_STRING = 4;
  80. TCL_LINK_READ_ONLY = $80;
  81. TCL_SMALL_HASH_TABLE = 4;
  82. {* Hash Table *}
  83. TCL_STRING_KEYS = 0;
  84. TCL_ONE_WORD_KEYS = 1;
  85. {* Const/enums Tcl_QueuePosition *}
  86. // typedef enum {
  87. TCL_QUEUE_TAIL = 0;
  88. TCL_QUEUE_HEAD = 1;
  89. TCL_QUEUE_MARK = 2;
  90. //} Tcl_QueuePosition;
  91. // Event Flags
  92. TCL_DONT_WAIT = 1 shl 1;
  93. TCL_WINDOW_EVENTS = 1 shl 2;
  94. TCL_FILE_EVENTS = 1 shl 3;
  95. TCL_TIMER_EVENTS = 1 shl 4;
  96. TCL_IDLE_EVENTS = 1 shl 5; {* WAS 0x10 ???? *}
  97. TCL_ALL_EVENTS = ($FFFFFFFF xor TCL_DONT_WAIT); // (~TCL_DONT_WAIT)
  98. // Result type
  99. TCL_VOLATILE = 1;
  100. TCL_STATIC = 0;
  101. TCL_DYNAMIC = 3;
  102. // Channel
  103. TCL_STDIN = 1 shl 1;
  104. TCL_STDOUT = 1 shl 2;
  105. TCL_STDERR = 1 shl 3;
  106. TCL_ENFORCE_MODE = 1 shl 4;
  107. TCL_READABLE = 1 shl 1;
  108. TCL_WRITABLE = 1 shl 2;
  109. TCL_EXCEPTION = 1 shl 3;
  110. {* POSIX *}
  111. EPERM = 1;
  112. {* Operation not permitted; only the owner of the file (or other
  113. * resource) or processes with special privileges can perform the
  114. * operation.
  115. *}
  116. ENOENT = 2;
  117. {* No such file or directory. This is a "file doesn't exist" error
  118. * for ordinary files that are referenced in contexts where they are
  119. * expected to already exist.
  120. *}
  121. ESRCH = 3;
  122. {* No process matches the specified process ID. *}
  123. EINTR = 4;
  124. {* Interrupted function call; an asynchronous signal occurred and
  125. * prevented completion of the call. When this happens, you should
  126. * try the call again.
  127. *}
  128. EIO = 5;
  129. {* Input/output error; usually used for physical read or write errors. *}
  130. ENXIO = 6;
  131. {* No such device or address. The system tried to use the device
  132. * represented by a file you specified, and it couldn't find the
  133. * device. This can mean that the device file was installed
  134. * incorrectly, or that the physical device is missing or not
  135. * correctly attached to the computer.
  136. *}
  137. E2BIG = 7;
  138. {* Argument list too long; used when the arguments passed to a new
  139. * program being executed with one of the `exec' functions (*note
  140. * Executing a File::.) occupy too much memory space. This condition
  141. * never arises in the GNU system.
  142. *}
  143. ENOEXEC = 8;
  144. {* Invalid executable file format. This condition is detected by the
  145. * `exec' functions; see *Note Executing a File::.
  146. *}
  147. EBADF = 9;
  148. {* Bad file descriptor; for example, I/O on a descriptor that has been
  149. * closed or reading from a descriptor open only for writing (or vice
  150. * versa).
  151. *}
  152. ECHILD = 10;
  153. {* There are no child processes. This error happens on operations
  154. * that are supposed to manipulate child processes, when there aren't
  155. * any processes to manipulate.
  156. *}
  157. EDEADLK = 11;
  158. {* Deadlock avoided; allocating a system resource would have resulted
  159. * in a deadlock situation. The system does not guarantee that it
  160. * will notice all such situations. This error means you got lucky
  161. * and the system noticed; it might just hang. *Note File Locks::,
  162. * for an example.
  163. *}
  164. ENOMEM = 12;
  165. {* No memory available. The system cannot allocate more virtual
  166. * memory because its capacity is full.
  167. *}
  168. EACCES = 13;
  169. {* Permission denied; the file permissions do not allow the attempted
  170. * operation.
  171. *}
  172. EFAULT = 14;
  173. {* Bad address; an invalid pointer was detected. In the GNU system,
  174. * this error never happens; you get a signal instead.
  175. *}
  176. ENOTBLK = 15;
  177. {* A file that isn't a block special file was given in a situation
  178. * that requires one. For example, trying to mount an ordinary file
  179. * as a file system in Unix gives this error.
  180. *}
  181. EBUSY = 16;
  182. {* Resource busy; a system resource that can't be shared is already
  183. * in use. For example, if you try to delete a file that is the root
  184. * of a currently mounted filesystem, you get this error.
  185. *}
  186. EEXIST = 17;
  187. {* File exists; an existing file was specified in a context where it
  188. * only makes sense to specify a new file.
  189. *}
  190. EXDEV = 18;
  191. {* An attempt to make an improper link across file systems was
  192. * detected. This happens not only when you use `link' (*note Hard
  193. * Links::.) but also when you rename a file with `rename' (*note
  194. * Renaming Files::.).
  195. *}
  196. ENODEV = 19;
  197. {* The wrong type of device was given to a function that expects a
  198. * particular sort of device.
  199. *}
  200. ENOTDIR = 20;
  201. {* A file that isn't a directory was specified when a directory is
  202. * required.
  203. *}
  204. EISDIR = 21;
  205. {* File is a directory; you cannot open a directory for writing, or
  206. * create or remove hard links to it.
  207. *}
  208. EINVAL = 22;
  209. {* Invalid argument. This is used to indicate various kinds of
  210. * problems with passing the wrong argument to a library function.
  211. *}
  212. EMFILE = 24;
  213. {* The current process has too many files open and can't open any
  214. * more. Duplicate descriptors do count toward this limit.
  215. *
  216. * In BSD and GNU, the number of open files is controlled by a
  217. * resource limit that can usually be increased. If you get this
  218. * error, you might want to increase the `RLIMIT_NOFILE' limit or
  219. * make it unlimited; *note Limits on Resources::..
  220. *}
  221. ENFILE = 23;
  222. {* There are too many distinct file openings in the entire system.
  223. * Note that any number of linked channels count as just one file
  224. * opening; see *Note Linked Channels::. This error never occurs in
  225. * the GNU system.
  226. *}
  227. ENOTTY = 25;
  228. {* Inappropriate I/O control operation, such as trying to set terminal
  229. * modes on an ordinary file.
  230. *}
  231. ETXTBSY = 26;
  232. {* An attempt to execute a file that is currently open for writing, or
  233. * write to a file that is currently being executed. Often using a
  234. * debugger to run a program is considered having it open for writing
  235. * and will cause this error. (The name stands for "text file
  236. * busy".) This is not an error in the GNU system; the text is
  237. * copied as necessary.
  238. *}
  239. EFBIG = 27;
  240. {* File too big; the size of a file would be larger than allowed by
  241. * the system.
  242. *}
  243. ENOSPC = 28;
  244. {* No space left on device; write operation on a file failed because
  245. * the disk is full.
  246. *}
  247. ESPIPE = 29;
  248. {* Invalid seek operation (such as on a pipe). *}
  249. EROFS = 30;
  250. {* An attempt was made to modify something on a read-only file system. *}
  251. EMLINK = 31;
  252. {* Too many links; the link count of a single file would become too
  253. * large. `rename' can cause this error if the file being renamed
  254. * already has as many links as it can take (*note Renaming Files::.).
  255. *}
  256. EPIPE = 32;
  257. {* Broken pipe; there is no process reading from the other end of a
  258. * pipe. Every library function that returns this error code also
  259. * generates a `SIGPIPE' signal; this signal terminates the program
  260. * if not handled or blocked. Thus, your program will never actually
  261. * see `EPIPE' unless it has handled or blocked `SIGPIPE'.
  262. *}
  263. EDOM = 33;
  264. {* Domain error; used by mathematical functions when an argument
  265. * value does not fall into the domain over which the function is
  266. * defined.
  267. *}
  268. ERANGE = 34;
  269. {* Range error; used by mathematical functions when the result value
  270. * is not representable because of overflow or underflow.
  271. *}
  272. EAGAIN = 35;
  273. {* Resource temporarily unavailable; the call might work if you try
  274. * again later. The macro `EWOULDBLOCK' is another name for `EAGAIN';
  275. * they are always the same in the GNU C library.
  276. *}
  277. EWOULDBLOCK = EAGAIN;
  278. {* In the GNU C library, this is another name for `EAGAIN' (above).
  279. * The values are always the same, on every operating system.
  280. * C libraries in many older Unix systems have `EWOULDBLOCK' as a
  281. * separate error code.
  282. *}
  283. EINPROGRESS = 36;
  284. {* An operation that cannot complete immediately was initiated on an
  285. * object that has non-blocking mode selected. Some functions that
  286. * must always block (such as `connect'; *note Connecting::.) never
  287. * return `EAGAIN'. Instead, they return `EINPROGRESS' to indicate
  288. * that the operation has begun and will take some time. Attempts to
  289. * manipulate the object before the call completes return `EALREADY'.
  290. * You can use the `select' function to find out when the pending
  291. * operation has completed; *note Waiting for I/O::..
  292. *}
  293. EALREADY = 37;
  294. {* An operation is already in progress on an object that has
  295. * non-blocking mode selected.
  296. *}
  297. ENOTSOCK = 38;
  298. {* A file that isn't a socket was specified when a socket is required. *}
  299. EDESTADDRREQ = 39;
  300. {* No default destination address was set for the socket. You get
  301. * this error when you try to transmit data over a connectionless
  302. * socket, without first specifying a destination for the data with
  303. * `connect'.
  304. *}
  305. EMSGSIZE = 40;
  306. {* The size of a message sent on a socket was larger than the
  307. * supported maximum size.
  308. *}
  309. EPROTOTYPE = 41;
  310. {* The socket type does not support the requested communications
  311. * protocol.
  312. *}
  313. ENOPROTOOPT = 42;
  314. {* You specified a socket option that doesn't make sense for the
  315. * particular protocol being used by the socket. *Note Socket
  316. * Options::.
  317. *}
  318. EPROTONOSUPPORT = 43;
  319. {* The socket domain does not support the requested communications
  320. * protocol (perhaps because the requested protocol is completely
  321. * invalid.) *Note Creating a Socket::.
  322. *}
  323. ESOCKTNOSUPPORT = 44;
  324. {* The socket type is not supported. *}
  325. EOPNOTSUPP = 45;
  326. {* The operation you requested is not supported. Some socket
  327. * functions don't make sense for all types of sockets, and others
  328. * may not be implemented for all communications protocols. In the
  329. * GNU system, this error can happen for many calls when the object
  330. * does not support the particular operation; it is a generic
  331. * indication that the server knows nothing to do for that call.
  332. *}
  333. EPFNOSUPPORT = 46;
  334. {* The socket communications protocol family you requested is not
  335. * supported.
  336. *}
  337. EAFNOSUPPORT = 47;
  338. {* The address family specified for a socket is not supported; it is
  339. * inconsistent with the protocol being used on the socket. *Note
  340. * Sockets::.
  341. *}
  342. EADDRINUSE = 48;
  343. {* The requested socket address is already in use. *Note Socket
  344. * Addresses::.
  345. *}
  346. EADDRNOTAVAIL = 49;
  347. {* The requested socket address is not available; for example, you
  348. * tried to give a socket a name that doesn't match the local host
  349. * name. *Note Socket Addresses::.
  350. *}
  351. ENETDOWN = 50;
  352. {* A socket operation failed because the network was down. *}
  353. ENETUNREACH = 51;
  354. {* A socket operation failed because the subnet containing the remote
  355. * host was unreachable.
  356. *}
  357. ENETRESET = 52;
  358. {* A network connection was reset because the remote host crashed. *}
  359. ECONNABORTED = 53;
  360. {* A network connection was aborted locally. *}
  361. ECONNRESET = 54;
  362. {* A network connection was closed for reasons outside the control of
  363. * the local host, such as by the remote machine rebooting or an
  364. * unrecoverable protocol violation.
  365. *}
  366. ENOBUFS = 55;
  367. {* The kernel's buffers for I/O operations are all in use. In GNU,
  368. * this error is always synonymous with `ENOMEM'; you may get one or
  369. * the other from network operations.
  370. *}
  371. EISCONN = 56;
  372. {* You tried to connect a socket that is already connected. *Note
  373. * Connecting::.
  374. *}
  375. ENOTCONN = 57;
  376. {* The socket is not connected to anything. You get this error when
  377. * you try to transmit data over a socket, without first specifying a
  378. * destination for the data. For a connectionless socket (for
  379. * datagram protocols, such as UDP), you get `EDESTADDRREQ' instead.
  380. *}
  381. ESHUTDOWN = 58;
  382. {* The socket has already been shut down. *}
  383. ETOOMANYREFS = 59;
  384. {* ??? *}
  385. ETIMEDOUT = 60;
  386. {* A socket operation with a specified timeout received no response
  387. * during the timeout period.
  388. *}
  389. ECONNREFUSED = 61;
  390. {* A remote host refused to allow the network connection (typically
  391. * because it is not running the requested service).
  392. *}
  393. ELOOP = 62;
  394. {* Too many levels of symbolic links were encountered in looking up a
  395. * file name. This often indicates a cycle of symbolic links.
  396. *}
  397. ENAMETOOLONG = 63;
  398. {* Filename too long (longer than `PATH_MAX'; *note Limits for
  399. * Files::.) or host name too long (in `gethostname' or
  400. * `sethostname'; *note Host Identification::.).
  401. *}
  402. EHOSTDOWN = 64;
  403. {* The remote host for a requested network connection is down. *}
  404. EHOSTUNREACH = 65;
  405. {* The remote host for a requested network connection is not
  406. * reachable.
  407. *}
  408. ENOTEMPTY = 66;
  409. {* Directory not empty, where an empty directory was expected.
  410. * Typically, this error occurs when you are trying to delete a
  411. * directory.
  412. *}
  413. EPROCLIM = 67;
  414. {* This means that the per-user limit on new process would be
  415. * exceeded by an attempted `fork'. *Note Limits on Resources::, for
  416. * details on the `RLIMIT_NPROC' limit.
  417. *}
  418. EUSERS = 68;
  419. {* The file quota system is confused because there are too many users. *}
  420. EDQUOT = 69;
  421. {* The user's disk quota was exceeded. *}
  422. ESTALE = 70;
  423. {* Stale NFS file handle. This indicates an internal confusion in
  424. * the NFS system which is due to file system rearrangements on the
  425. * server host. Repairing this condition usually requires unmounting
  426. * and remounting the NFS file system on the local host.
  427. *}
  428. EREMOTE = 71;
  429. {* An attempt was made to NFS-mount a remote file system with a file
  430. * name that already specifies an NFS-mounted file. (This is an
  431. * error on some operating systems, but we expect it to work properly
  432. * on the GNU system, making this error code impossible.)
  433. *}
  434. EBADRPC = 72;
  435. {* ??? *}
  436. ERPCMISMATCH = 73;
  437. {* ??? *}
  438. EPROGUNAVAIL = 74;
  439. {* ??? *}
  440. EPROGMISMATCH = 75;
  441. {* ??? *}
  442. EPROCUNAVAIL = 76;
  443. {* ??? *}
  444. ENOLCK = 77;
  445. {* No locks available. This is used by the file locking facilities;
  446. * see *Note File Locks::. This error is never generated by the GNU
  447. * system, but it can result from an operation to an NFS server
  448. * running another operating system.
  449. *}
  450. ENOSYS = 78;
  451. {* Function not implemented. Some functions have commands or options
  452. * defined that might not be supported in all implementations, and
  453. * this is the kind of error you get if you request them and they are
  454. * not supported.
  455. *}
  456. EFTYPE = 79;
  457. {* Inappropriate file type or format. The file was the wrong type
  458. * for the operation, or a data file had the wrong format.
  459. * On some systems `chmod' returns this error if you try to set the
  460. * sticky bit on a non-directory file; *note Setting Permissions::..
  461. *}
  462. type
  463. PPChar = ^PChar;
  464. Tcl_Argv = PPChar;
  465. Tcl_ClientData = pointer;
  466. Tcl_FreeProc = procedure(block : pointer); cdecl;
  467. PTcl_Interp = ^Tcl_Interp;
  468. Tcl_Interp = packed record
  469. result : PChar; {* Do not access this directly. Use
  470. * Tcl_GetStringResult since result
  471. * may be pointing to an object
  472. *}
  473. freeProc : Tcl_FreeProc;
  474. errorLine: integer;
  475. end;
  476. {* Event Definitions *}
  477. TTcl_EventSetupProc = procedure(clientData: Tcl_ClientData; flags: integer); cdecl;
  478. TTcl_EventCheckProc = TTcl_EventSetupProc;
  479. PTcl_Event = ^Tcl_Event;
  480. TTcl_EventProc = function(evPtr: PTcl_Event; flags: integer): integer; cdecl;
  481. Tcl_Event = packed record
  482. proc : TTcl_EventProc;
  483. nextPtr : PTcl_Event;
  484. ClientData: TObject; {* ClientData is just pointer.*}
  485. end;
  486. PTcl_Time = ^Tcl_Time;
  487. Tcl_Time = packed record
  488. sec: longInt; { * Seconds. * }
  489. usec: longInt; { * Microseconds. * }
  490. end;
  491. Tcl_TimerToken = pointer;
  492. PInteger = ^integer;
  493. PTcl_HashTable = pointer;
  494. PTcl_HashEntry = ^Tcl_HashEntry;
  495. PPTcl_HashEntry = ^PTcl_HashEntry;
  496. Tcl_HashEntry = packed record
  497. nextPtr : PTcl_HashEntry;
  498. tablePtr : PTcl_HashTable;
  499. bucketPtr : PPTcl_HashEntry;
  500. clientData : Tcl_ClientData;
  501. key : array[0..3] of Char;
  502. end;
  503. { case key: integer of
  504. 0: (oneWordValue: pChar);
  505. 1: (words : pInteger);
  506. 2: (str : pChar);
  507. }
  508. Tcl_HashFindProc = function(tablePtr: PTcl_HashTable; key: PChar): PTcl_HashEntry; cdecl;
  509. Tcl_HashCreateProc = function(tablePtr: PTcl_HashTable; key: PChar; newPtr: PInteger): PTcl_HashEntry; cdecl;
  510. PHashTable = ^Tcl_HashTable;
  511. Tcl_HashTable = packed record
  512. buckets : ppTcl_HashEntry;
  513. staticBuckets : array[0..TCL_SMALL_HASH_TABLE - 1] of PTcl_HashEntry;
  514. numBuckets : integer;
  515. numEntries : integer;
  516. rebuildSize : integer;
  517. downShift : integer;
  518. mask : integer;
  519. keyType : integer;
  520. findProc : Tcl_HashFindProc;
  521. createProc : Tcl_HashCreateProc;
  522. end;
  523. PTcl_HashSearch = ^Tcl_HashSearch;
  524. Tcl_HashSearch = packed record
  525. tablePtr : PTcl_HashTable;
  526. nextIndex : integer;
  527. nextEntryPtr: PTcl_HashEntry;
  528. end;
  529. TTclAppInitProc = function(interp: pTcl_Interp): integer; cdecl;
  530. TTclPackageInitProc = function(interp: pTcl_Interp): integer; cdecl;
  531. TTclCmdProc = function(clientData : Tcl_ClientData; interp : pTcl_Interp; argc: integer; argv : Tcl_Argv): integer; cdecl;
  532. TTclVarTraceProc = function (clientData: Tcl_ClientData; interp: pTcl_Interp;
  533. varName: PChar; elemName: PChar; flags: integer): PChar; cdecl;
  534. TTclFreeProc = procedure(block: pointer); cdecl;
  535. TTclInterpDeleteProc = procedure(clientData: Tcl_ClientData; interp: pTcl_Interp); cdecl;
  536. TTclCmdDeleteProc = procedure(clientData: Tcl_ClientData); cdecl;
  537. TTclNamespaceDeleteProc = procedure(clientData: Tcl_ClientData); cdecl;
  538. const
  539. TCL_DSTRING_STATIC_SIZE = 200;
  540. type
  541. PTcl_DString = ^Tcl_DString;
  542. Tcl_DString = packed record
  543. str : PChar;
  544. length : integer;
  545. spaceAvl : integer;
  546. staticSpace: array[0..TCL_DSTRING_STATIC_SIZE - 1] of char;
  547. end;
  548. PTcl_Channel = ^Tcl_Channel;
  549. Tcl_Channel = packed record
  550. end;
  551. TTclDriverBlockModeProc = function(instanceData: Tcl_ClientData; mode: integer): integer; cdecl;
  552. TTclDriverCloseProc = function(instanceData: Tcl_ClientData; interp: PTcl_Interp): integer; cdecl;
  553. TTclDriverInputProc = function(instanceData: Tcl_ClientData; buf: PChar; toRead: integer;
  554. errorCodePtr: PInteger): integer; cdecl;
  555. TTclDriverOutputProc = function(instanceData: Tcl_ClientData; buf: PChar; toWrite: integer;
  556. errorCodePtr: PInteger): integer; cdecl;
  557. TTclDriverSeekProc = function(instanceData: Tcl_ClientData; offset: longint; mode: integer;
  558. errorCodePtr: PInteger): integer; cdecl;
  559. TTclDriverSetOptionProc = function(instanceData: Tcl_ClientData; interp: PTcl_Interp; optionName: PChar;
  560. value: PChar): integer; cdecl;
  561. TTclDriverGetOptionProc = function(instanceData: Tcl_ClientData; interp: pTcl_Interp; optionName: PChar;
  562. dsPtr: PTcl_DString): integer; cdecl;
  563. TTclDriverWatchProc = procedure(instanceData: Tcl_ClientData; mask: integer); cdecl;
  564. TTclDriverGetHandleProc = function(instanceData: Tcl_ClientData; direction: integer;
  565. var handlePtr: Tcl_ClientData): integer; cdecl;
  566. PTcl_ChannelType = ^Tcl_ChannelType;
  567. Tcl_ChannelType = packed record
  568. typeName : PChar;
  569. blockModeProc: TTclDriverBlockModeProc;
  570. closeProc : TTclDriverCloseProc;
  571. inputProc : TTclDriverInputProc;
  572. ouputProc : TTclDriverOutputProc;
  573. seekProc : TTclDriverSeekProc;
  574. setOptionProc: TTclDriverSetOptionProc;
  575. getOptionProc: TTclDriverGetOptionProc;
  576. watchProc : TTclDriverWatchProc;
  577. getHandleProc: TTclDriverGetHandleProc;
  578. end;
  579. TTclChannelProc = procedure(clientData: Tcl_ClientData; mask: integer); cdecl;
  580. PTcl_Obj = ^Tcl_Obj;
  581. PPTcl_Obj = ^PTcl_Obj;
  582. Tcl_Obj = packed record
  583. refCount: integer;
  584. // ...
  585. end;
  586. TTclObjCmdProc = function(clientData: Tcl_ClientData; interp: PTcl_Interp; objc: integer; PPObj: PPTcl_Obj): integer; cdecl;
  587. PTcl_Namespace = ^Tcl_Namespace;
  588. Tcl_Namespace = packed record
  589. name : pchar;
  590. fullName : PChar;
  591. clientData: Tcl_ClientData;
  592. deleteProc: TTclNamespaceDeleteProc;
  593. parentPtr : PTcl_Namespace;
  594. end;
  595. PTcl_CallFrame = ^Tcl_CallFrame;
  596. Tcl_CallFrame = packed record
  597. nsPtr : PTcl_Namespace;
  598. dummy1 : integer;
  599. dummy2 : integer;
  600. dummy3 : PChar;
  601. dummy4 : PChar;
  602. dummy5 : PChar;
  603. dummy6 : integer;
  604. dummy7 : PChar;
  605. dummy8 : PChar;
  606. dummy9 : integer;
  607. dummy10: PChar;
  608. end;
  609. PTcl_CmdInfo = ^Tcl_CmdInfo;
  610. Tcl_CmdInfo = packed record
  611. isNativeObjectProc: integer;
  612. objProc : TTclObjCmdProc;
  613. objClientData : Tcl_ClientData;
  614. proc : TTclCmdProc;
  615. clientData : Tcl_ClientData;
  616. deleteProc : TTclCmdDeleteProc;
  617. deleteData : Tcl_ClientData;
  618. namespacePtr : pTcl_Namespace;
  619. end;
  620. pTcl_Command = ^Tcl_Command;
  621. Tcl_Command = packed record
  622. end;
  623. { hPtr : pTcl_HashEntry;
  624. nsPtr : pTcl_Namespace;
  625. refCount : integer;
  626. isCmdEpoch : integer;
  627. compileProc : pointer;
  628. objProc : pointer;
  629. objClientData : Tcl_ClientData;
  630. proc : pointer;
  631. clientData : Tcl_ClientData;
  632. deleteProc : TTclCmdDeleteProc;
  633. deleteData : Tcl_ClientData;
  634. deleted : integer;
  635. importRefPtr : pointer;
  636. }
  637. type
  638. ulong = longint;
  639. uint = integer;
  640. bool = longbool;
  641. TTclPanicProc = procedure(fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8: PChar); cdecl; // 1/15/97 orig. Tcl style
  642. TTclClientDataProc = procedure (clientData: Tcl_ClientData); cdecl;
  643. TTclIdleProc = procedure (clientData: Tcl_ClientData); cdecl;
  644. TTclTimerProc = TTclIdleProc;
  645. TTclCreateCloseHandler = procedure (channel: pTcl_Channel; proc: TTclClientDataProc; clientData: Tcl_ClientData); cdecl;
  646. TTclDeleteCloseHandler = TTclCreateCloseHandler;
  647. TTclEventDeleteProc = function(evPtr: pTcl_Event; clientData: Tcl_ClientData): integer; cdecl;
  648. function Tcl_Alloc(size: Cardinal): PChar; cdecl; external TCL_LIBRARY;
  649. function Tcl_CreateInterp : pTcl_Interp; cdecl; external TCL_LIBRARY;
  650. procedure Tcl_DeleteInterp(interp: pTcl_Interp); cdecl; external TCL_LIBRARY;
  651. procedure Tcl_ResetResult(interp: pTcl_Interp); cdecl; external TCL_LIBRARY;
  652. function Tcl_Eval(interp: pTcl_Interp; script : PChar):integer; cdecl; external TCL_LIBRARY;
  653. function Tcl_EvalFile(interp: pTcl_Interp; filename: PChar):integer; cdecl; external TCL_LIBRARY;
  654. procedure Tcl_AddErrorInfo(interp: pTcl_Interp; message: PChar); cdecl; external TCL_LIBRARY;
  655. procedure Tcl_BackgroundError(interp: pTcl_Interp); cdecl; external TCL_LIBRARY;
  656. function Tcl_CreateCommand(interp: pTcl_Interp; name: PChar; cmdProc: TTclCmdProc;
  657. clientData: Tcl_ClientData; deleteProc: TTclCmdDeleteProc): pTcl_Command; cdecl; external TCL_LIBRARY;
  658. function Tcl_DeleteCommand(interp: pTcl_Interp; name: PChar): integer; cdecl; external TCL_LIBRARY;
  659. procedure Tcl_CallWhenDeleted(interp: pTcl_Interp; proc: TTclInterpDeleteProc; clientData: Tcl_ClientData); cdecl; external TCL_LIBRARY;
  660. procedure Tcl_DontCallWhenDeleted(interp: pTcl_Interp; proc: TTclInterpDeleteProc; clientData: Tcl_ClientData); cdecl; external TCL_LIBRARY;
  661. function Tcl_CommandComplete(cmd: PChar): integer; cdecl; external TCL_LIBRARY;
  662. function Tcl_LinkVar(interp: pTcl_Interp; varName: PChar; var addr; typ: integer): integer; cdecl; external TCL_LIBRARY;
  663. procedure Tcl_UnlinkVar(interp: pTcl_Interp; varName: PChar); cdecl; external TCL_LIBRARY;
  664. function Tcl_TraceVar(interp: pTcl_Interp; varName: PChar; flags: integer; proc: TTclVarTraceProc;
  665. clientData: Tcl_ClientData): integer; cdecl; external TCL_LIBRARY;
  666. function Tcl_TraceVar2(interp: pTcl_Interp; varName: PChar; elemName: PChar; flags : integer; proc: TTclVarTraceProc;
  667. clientData: Tcl_ClientData): integer; cdecl; external TCL_LIBRARY;
  668. procedure Tcl_UntraceVar(interp: pTcl_Interp; varName: PChar; flags: integer;
  669. proc: TTclVarTraceProc; clientData: Tcl_ClientData); cdecl; external TCL_LIBRARY;
  670. procedure Tcl_UntraceVar2(interp: pTcl_Interp; varName: PChar; elemName: PChar; flags: integer;
  671. proc: TTclVarTraceProc; clientData: Tcl_ClientData); cdecl; external TCL_LIBRARY;
  672. function Tcl_GetVar(interp: pTcl_Interp; varName: PChar; flags: integer): PChar; cdecl; external TCL_LIBRARY;
  673. function Tcl_GetVar2(interp: pTcl_Interp; varName: PChar; elemName: PChar; flags: integer): PChar; cdecl; external TCL_LIBRARY;
  674. function Tcl_SetVar(interp: pTcl_Interp; varName: PChar; newValue: PChar; flags: integer): PChar; cdecl; external TCL_LIBRARY;
  675. function Tcl_SetVar2(interp: pTcl_Interp; varName: PChar; elemName: PChar; newValue: PChar; flags: integer): PChar; cdecl; external TCL_LIBRARY;
  676. function Tcl_UnsetVar(interp: pTcl_Interp; varName: PChar; flags: integer): integer; cdecl; external TCL_LIBRARY;
  677. function Tcl_UnsetVar2(interp: pTcl_Interp; varName: PChar; elemName: PChar; flags: integer): integer; cdecl; external TCL_LIBRARY;
  678. procedure Tcl_SetResult(interp: pTcl_Interp; newValue: PChar; freeProc: TTclFreeProc); cdecl; external TCL_LIBRARY;
  679. function Tcl_FirstHashEntry(hashTbl: pTcl_HashTable; var searchInfo: Tcl_HashSearch): pTcl_HashEntry; cdecl; external TCL_LIBRARY;
  680. function Tcl_NextHashEntry(var searchInfo: Tcl_HashSearch): pTcl_HashEntry; cdecl; external TCL_LIBRARY;
  681. procedure Tcl_InitHashTable(hashTbl: pTcl_HashTable; keyType: integer); cdecl; external TCL_LIBRARY;
  682. function Tcl_StringMatch(str: PChar; pattern: PChar): integer; cdecl; external TCL_LIBRARY;
  683. function _Tcl_GetHashKey(hashTbl: pTcl_HashTable; hashEntry: pTcl_HashEntry): PChar; cdecl;
  684. function Tcl_GetErrno:integer; cdecl; external TCL_LIBRARY;
  685. procedure Tcl_SetErrno(val: integer); cdecl; external TCL_LIBRARY;
  686. procedure Tcl_SetPanicProc(proc: TTclPanicProc); cdecl; external TCL_LIBRARY;
  687. function Tcl_PkgProvide(interp: pTcl_Interp; name: PChar; version: PChar): integer; cdecl; external TCL_LIBRARY;
  688. procedure Tcl_StaticPackage(interp: pTcl_Interp; pkgName: PChar; initProc: TTclPackageInitProc;
  689. safeInitProc: TTclPackageInitProc); cdecl; external TCL_LIBRARY;
  690. procedure Tcl_CreateEventSource(setupProc: TTcl_EventSetupProc;
  691. checkProc: TTcl_EventCheckProc; clientData: Tcl_ClientData); cdecl; external TCL_LIBRARY;
  692. procedure Tcl_DeleteEventSource(setupProc: TTcl_EventSetupProc;
  693. checkProc: TTcl_EventCheckProc; clientData: Tcl_ClientData); cdecl; external TCL_LIBRARY;
  694. procedure Tcl_QueueEvent(evPtr: pTcl_Event; pos: integer); cdecl; external TCL_LIBRARY;
  695. procedure Tcl_SetMaxBlockTime(timePtr: pTcl_Time); cdecl; external TCL_LIBRARY;
  696. procedure Tcl_DeleteEvents(proc: TTclEventDeleteProc; clientData: Tcl_ClientData); cdecl; external TCL_LIBRARY;
  697. function Tcl_DoOneEvent(flags: integer): integer; cdecl; external TCL_LIBRARY;
  698. procedure Tcl_DoWhenIdle(proc: TTclIdleProc; clientData: Tcl_ClientData); cdecl; external TCL_LIBRARY;
  699. procedure Tcl_CancelIdleCall(proc: TTclIdleProc; clientData: Tcl_ClientData); cdecl; external TCL_LIBRARY;
  700. function Tcl_CreateTimerHandler(milliseconds: integer; proc: TTclTimerProc;
  701. clientData: Tcl_ClientData): Tcl_TimerToken; cdecl; external TCL_LIBRARY;
  702. procedure Tcl_DeleteTimerHandler(token: Tcl_TimerToken); cdecl; external TCL_LIBRARY;
  703. // procedure Tcl_CreateModalTimeout(milliseconds: integer; proc: TTclTimerProc; clientData: Tcl_ClientData); cdecl; external TCL_LIBRARY;
  704. // procedure Tcl_DeleteModalTimeout(proc: TTclTimerProc; clientData: Tcl_ClientData); cdecl; external TCL_LIBRARY;
  705. function Tcl_SplitList(interp: pTcl_Interp; list: PChar; var argcPtr: integer; var argvPtr: Tcl_Argv): integer; cdecl; external TCL_LIBRARY;
  706. function Tcl_Merge(argc: integer; argv: Tcl_Argv):PChar; cdecl; external TCL_LIBRARY;
  707. procedure Tcl_Free( ptr: PChar ); cdecl; external TCL_LIBRARY;
  708. function Tcl_Init(interp: pTcl_Interp): integer; cdecl; external TCL_LIBRARY;
  709. // procedure Tcl_InterpDeleteProc(clientData: Tcl_ClientData; interp: pTcl_Interp); cdecl; external TCL_LIBRARY;
  710. function Tcl_GetAssocData(interp:pTcl_Interp; key: PChar; var proc: TTclInterpDeleteProc): Tcl_ClientData; cdecl; external TCL_LIBRARY;
  711. procedure Tcl_DeleteAssocData(interp: pTcl_Interp; key: PChar); cdecl; external TCL_LIBRARY;
  712. procedure Tcl_SetAssocData(interp: pTcl_Interp; key: PChar; proc: TTclInterpDeleteProc;
  713. clientData: Tcl_ClientData); cdecl; external TCL_LIBRARY;
  714. function Tcl_IsSafe(interp: pTcl_Interp): integer; cdecl; external TCL_LIBRARY;
  715. function Tcl_MakeSafe(interp: pTcl_Interp): integer; cdecl; external TCL_LIBRARY;
  716. function Tcl_CreateSlave(interp: pTcl_Interp; slaveName: PChar; isSafe: integer): pTcl_Interp; cdecl; external TCL_LIBRARY;
  717. function Tcl_GetSlave(interp: pTcl_Interp; slaveName: PChar): pTcl_Interp; cdecl; external TCL_LIBRARY;
  718. function Tcl_GetMaster(interp: pTcl_Interp): pTcl_Interp; cdecl; external TCL_LIBRARY;
  719. function Tcl_GetInterpPath(askingInterp: pTcl_Interp; slaveInterp: pTcl_Interp): integer; cdecl; external TCL_LIBRARY;
  720. function Tcl_CreateAlias(slaveInterp: pTcl_Interp; srcCmd: PChar; targetInterp: pTcl_Interp; targetCmd: PChar;
  721. argc: integer; argv: Tcl_Argv): integer; cdecl; external TCL_LIBRARY;
  722. function Tcl_GetAlias(interp: pTcl_Interp; srcCmd: PChar; var targetInterp: pTcl_Interp; var targetCmd: PChar;
  723. var argc: integer; var argv: Tcl_Argv): integer; cdecl; external TCL_LIBRARY;
  724. function Tcl_ExposeCommand(interp: pTcl_Interp; hiddenCmdName: PChar; cmdName: PChar): integer; cdecl; external TCL_LIBRARY;
  725. function Tcl_HideCommand(interp: pTcl_Interp; cmdName: PChar; hiddenCmdName: PChar): integer; cdecl; external TCL_LIBRARY;
  726. procedure Tcl_EventuallyFree(clientData: Tcl_ClientData; freeProc: TTclFreeProc); cdecl; external TCL_LIBRARY;
  727. procedure Tcl_Preserve(clientData: Tcl_ClientData); cdecl; external TCL_LIBRARY;
  728. procedure Tcl_Release(clientData: Tcl_ClientData); cdecl; external TCL_LIBRARY;
  729. function Tcl_InterpDeleted(interp: pTcl_Interp): integer; cdecl; external TCL_LIBRARY;
  730. function Tcl_GetCommandInfo(interp: pTcl_Interp; cmdName: PChar; var info: Tcl_CmdInfo): integer; cdecl; external TCL_LIBRARY;
  731. function Tcl_SetCommandInfo(interp: pTcl_Interp; cmdName: PChar; var info: Tcl_CmdInfo): integer; cdecl; external TCL_LIBRARY;
  732. procedure Tcl_FindExecutable(path: PChar); cdecl; external TCL_LIBRARY;
  733. function Tcl_GetStringResult(interp: pTcl_Interp): PChar; cdecl; external TCL_LIBRARY; //v1.0
  734. function Tcl_FindCommand(interp: pTcl_Interp; cmdName: PChar;
  735. contextNsPtr: pTcl_Namespace; flags: integer): Tcl_Command; cdecl; external TCL_LIBRARY; //v1.0
  736. function Tcl_DeleteCommandFromToken(interp: pTcl_Interp; cmd: pTcl_Command): integer; cdecl; external TCL_LIBRARY;
  737. function Tcl_CreateNamespace(interp: pTcl_Interp; name: PChar; clientData: Tcl_ClientData;
  738. deleteProc: TTclNamespaceDeleteProc): pTcl_Namespace; cdecl; external TCL_LIBRARY; //v1.0
  739. procedure Tcl_DeleteNamespace(namespacePtr: pTcl_Namespace); cdecl; external TCL_LIBRARY;
  740. function Tcl_FindNamespace(interp: pTcl_Interp; name: PChar; contextNsPtr: pTcl_Namespace; flags: integer): pTcl_Namespace; cdecl; external TCL_LIBRARY;
  741. function Tcl_Export(interp: pTcl_Interp; namespacePtr: pTcl_Namespace; pattern: PChar;
  742. resetListFirst: integer): integer; cdecl; external TCL_LIBRARY;
  743. function Tcl_Import(interp: pTcl_Interp; namespacePtr: pTcl_Namespace; pattern: PChar;
  744. allowOverwrite: integer): integer; cdecl; external TCL_LIBRARY;
  745. function Tcl_GetCurrentNamespace(interp: pTcl_Interp): pTcl_Namespace; cdecl; external TCL_LIBRARY;
  746. function Tcl_GetGlobalNamespace(interp: pTcl_Interp): pTcl_Namespace; cdecl; external TCL_LIBRARY;
  747. function Tcl_PushCallFrame(interp: pTcl_Interp; var callFramePtr: Tcl_CallFrame;
  748. namespacePtr: pTcl_Namespace; isProcCallFrame: integer): integer; cdecl; external TCL_LIBRARY;
  749. procedure Tcl_PopCallFrame(interp: pTcl_Interp); cdecl; external TCL_LIBRARY;
  750. function Tcl_VarEval(interp: pTcl_Interp; args: array of const):integer; cdecl; external TCL_LIBRARY;
  751. {* For TkConsole.c *}
  752. function Tcl_RecordAndEval(interp: pTcl_Interp; cmd: PChar; flags: integer): integer; cdecl; external TCL_LIBRARY;
  753. function Tcl_GlobalEval(interp: pTcl_Interp; command: PChar): integer; cdecl; external TCL_LIBRARY;
  754. procedure Tcl_DStringFree(dsPtr: pTcl_DString); cdecl; external TCL_LIBRARY;
  755. function Tcl_DStringAppend(dsPtr: pTcl_DString; str: PChar; len: integer): PChar; cdecl; external TCL_LIBRARY;
  756. function Tcl_DStringAppendElement(dsPtr: pTcl_DString; str: PChar): PChar; cdecl; external TCL_LIBRARY;
  757. procedure Tcl_DStringInit(dsPtr: pTcl_DString); cdecl; external TCL_LIBRARY;
  758. procedure Tcl_AppendResult(interp: pTcl_Interp; args: array of const); cdecl; external TCL_LIBRARY; // actually a "C" var array
  759. procedure Tcl_SetStdChannel(channel: pTcl_Channel; typ: integer); cdecl; external TCL_LIBRARY;
  760. function Tcl_SetChannelOption(interp: pTcl_Interp; chan: pTcl_Channel; optionName: PChar; newValue: PChar): integer; cdecl; external TCL_LIBRARY;
  761. function Tcl_GetChannelOption(interp: pTcl_Interp; chan: pTcl_Channel; optionName: PChar; dsPtr: pTcl_DString): integer; cdecl; external TCL_LIBRARY;
  762. function Tcl_CreateChannel(typePtr: pTcl_ChannelType; chanName: PChar;
  763. instanceData: Tcl_ClientData; mask: integer):pTcl_Channel; cdecl; external TCL_LIBRARY;
  764. procedure Tcl_RegisterChannel(interp: pTcl_Interp; channel: pTcl_Channel); cdecl; external TCL_LIBRARY;
  765. function Tcl_UnregisterChannel(interp: pTcl_Interp; channel: pTcl_Channel): integer; cdecl; external TCL_LIBRARY;
  766. procedure Tcl_CreateChannelHandler(chan: pTcl_Channel; mask: integer; proc: TTclChannelProc; clientData: Tcl_ClientData); cdecl; external TCL_LIBRARY;
  767. function Tcl_GetChannel(interp: pTcl_Interp; chanName: PChar; modePtr: pInteger): pTcl_Channel; cdecl; external TCL_LIBRARY;
  768. function Tcl_GetStdChannel(typ: integer): pTcl_Channel; cdecl; external TCL_LIBRARY;
  769. function Tcl_Gets(chan: pTcl_Channel; dsPtr: pTcl_DString): integer; cdecl; external TCL_LIBRARY;
  770. function Tcl_Write(chan: pTcl_Channel; s: PChar; slen: integer): integer; cdecl; external TCL_LIBRARY;
  771. function Tcl_Flush(chan: pTcl_Channel): integer; cdecl; external TCL_LIBRARY;
  772. // TclWinLoadLibrary = function(name: PChar): HMODULE; cdecl; external TCL_LIBRARY;
  773. procedure Tcl_CreateExitHandler(proc: TTclClientDataProc; clientData: Tcl_ClientData); cdecl; external TCL_LIBRARY;
  774. procedure Tcl_DeleteExitHandler(proc: TTclClientDataProc; clientData: Tcl_ClientData); cdecl; external TCL_LIBRARY;
  775. function Tcl_GetStringFromObj(pObj: pTcl_Obj; pLen: pInteger): PChar; cdecl; external TCL_LIBRARY;
  776. function Tcl_CreateObjCommand(interp: pTcl_Interp; name: PChar; cmdProc: TTclObjCmdProc;
  777. clientData: Tcl_ClientData; deleteProc: TTclCmdDeleteProc): pTcl_Command; cdecl; external TCL_LIBRARY;
  778. function Tcl_NewStringObj(bytes: PChar; len: integer): pTcl_Obj; cdecl; external TCL_LIBRARY;
  779. // procedure TclFreeObj(pObj: pTcl_Obj); cdecl; external TCL_LIBRARY;
  780. function Tcl_EvalObj(interp: pTcl_Interp; pObj: pTcl_Obj): integer; cdecl; external TCL_LIBRARY;
  781. function Tcl_GlobalEvalObj(interp: pTcl_Interp; pObj: pTcl_Obj): integer; cdecl; external TCL_LIBRARY;
  782. function TclRegComp(exp: PChar): pointer; cdecl; external TCL_LIBRARY;
  783. function TclRegExec(prog: pointer; str: PChar; start: PChar): integer; cdecl; external TCL_LIBRARY;
  784. procedure TclRegError(msg: PChar); cdecl; external TCL_LIBRARY;
  785. function TclGetRegError: PChar; cdecl; external TCL_LIBRARY;
  786. procedure Tcl_RegExpRange(prog: pointer; index: integer; var head: PChar; var tail: PChar); cdecl; external TCL_LIBRARY;
  787. // C Macro Emulation
  788. function Tcl_GetCommandTable(interp: pTcl_Interp): pHashTable;
  789. function Tcl_CreateHashEntry(tablePtr: pTcl_HashTable; key: PChar; newPtr: pInteger): pTcl_HashEntry;
  790. function Tcl_FindHashEntry(tablePtr: pTcl_HashTable; key: PChar): pTcl_HashEntry;
  791. procedure Tcl_SetHashValue(h: pTcl_HashEntry; clientData: Tcl_ClientData);
  792. function Tcl_GetHashValue(h: pTcl_HashEntry): Tcl_ClientData;
  793. procedure Tcl_IncrRefCount(pObj: pTcl_Obj); cdecl;
  794. procedure Tcl_DecrRefCount(pObj: pTcl_Obj); cdecl;
  795. function Tcl_IsShared(pObj: pTcl_Obj): integer; cdecl;
  796. {$IFDEF USE_C}
  797. function ArgvItem(argv: PPChar; idx: integer): PChar; cdecl; external; // argv.c must be compiled by GCC
  798. {$ELSE}
  799. function ArgvItem(argv: PPChar; idx: integer): PChar; cdecl;
  800. {$ENDIF}
  801. implementation
  802. uses SysUtils {, Classes};
  803. // Macro emulation
  804. function Tcl_CreateHashEntry(tablePtr: pTcl_HashTable; key: PChar; newPtr: pInteger): pTcl_HashEntry;
  805. begin
  806. result := pHashTable(tablePtr)^.createProc(tablePtr, key, newPtr);
  807. end;
  808. function Tcl_FindHashEntry(tablePtr: pTcl_HashTable; key: PChar): pTcl_HashEntry;
  809. begin
  810. result := pHashTable(tablePtr)^.findProc(tablePtr, key);
  811. end;
  812. procedure Tcl_SetHashValue(h: pTcl_HashEntry; clientData: Tcl_ClientData);
  813. begin
  814. h^.clientData := clientData;
  815. end;
  816. function Tcl_GetHashValue(h: pTcl_HashEntry): Tcl_ClientData;
  817. begin
  818. result := h^.clientData;
  819. end;
  820. function _Tcl_GetHashKey(hashTbl: pTcl_HashTable; hashEntry: pTcl_HashEntry): PChar; cdecl;
  821. begin
  822. if (hashTbl = nil) or (hashEntry = nil) then
  823. result := nil
  824. else if pHashTable(hashTbl)^.keyType = 1 then
  825. result := PChar(pLongInt(@(hashEntry^.key[0]))^)
  826. else
  827. result := hashEntry^.key;
  828. end;
  829. procedure Tcl_IncrRefCount(pObj: pTcl_Obj); cdecl;
  830. begin
  831. inc(pObj^.refCount);
  832. end;
  833. procedure Tcl_DecrRefCount(pObj: pTcl_Obj); cdecl;
  834. begin
  835. dec(pObj^.refCount);
  836. if pObj^.refCount <= 0 then
  837. FreeMem(pObj);
  838. end;
  839. function Tcl_IsShared(pObj: pTcl_Obj): integer; cdecl;
  840. begin
  841. if pObj^.refCount > 0 then
  842. result := 1
  843. else
  844. result := 0;
  845. end;
  846. function Tcl_GetCommandTable(interp: pTcl_Interp): pHashTable;
  847. begin
  848. if interp = nil then
  849. result := nil
  850. else if TCL_VERSION_MAJOR >= 8 then // pretty sure it happened in this version
  851. result := pHashTable(longint(interp) + sizeof(Tcl_Interp) + sizeof(pointer))
  852. else
  853. result := pHashTable(longint(interp) + sizeof(Tcl_Interp));
  854. end;
  855. {$IFNDEF USE_C}
  856. {*
  857. * Use this if you don't have the C compiler and you're on
  858. * the Intel platform.
  859. * Otherwise define `USE_C` macro.
  860. *}
  861. function ArgvItem(argv: PPChar; idx: integer): PChar; cdecl;
  862. var
  863. Buf: LongWord;
  864. begin
  865. asm
  866. MOV EAX,idx //* index please
  867. MOV EDX,[argv] //* gotcha argv^
  868. MOV EAX,[EDX + EAX*4] //* PChar is 32bit pointer, so EAX*4 its offset for
  869. //* one item in array.
  870. //* gotcha something like this: (argv^)^[idx]
  871. //*
  872. MOV Buf,EAX
  873. end;
  874. ArgvItem:=PChar(Buf);
  875. end;
  876. {$ENDIF}
  877. end.