tcl80.pp 44 KB

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