tcl80.pp 44 KB

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