tcl80.pp 44 KB

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