2786
|
1 |
unit LuaPas;
|
|
2 |
|
|
3 |
(*
|
|
4 |
* A complete Pascal wrapper for Lua 5.1 DLL module.
|
|
5 |
*
|
|
6 |
* Created by Geo Massar, 2006
|
|
7 |
* Distributed as free/open source.
|
|
8 |
*)
|
|
9 |
|
|
10 |
interface
|
|
11 |
|
|
12 |
{.$DEFINE LUA_GETHOOK}
|
|
13 |
|
|
14 |
type
|
|
15 |
size_t = type Cardinal;
|
|
16 |
Psize_t = ^size_t;
|
|
17 |
PPointer = ^Pointer;
|
|
18 |
|
|
19 |
lua_State = record end;
|
|
20 |
Plua_State = ^lua_State;
|
|
21 |
|
|
22 |
const
|
|
23 |
{$IFDEF UNIX}
|
2799
|
24 |
LuaLibName = 'lua5.1.so';
|
|
25 |
{$IFDEF DARWIN}
|
|
26 |
LuaLibName = 'lua5.1.a';
|
|
27 |
{$ENDIF}
|
2786
|
28 |
{$ELSE}
|
2799
|
29 |
LuaLibName = 'lua5.1.dll';
|
2786
|
30 |
{$ENDIF}
|
|
31 |
|
|
32 |
|
|
33 |
(*****************************************************************************)
|
|
34 |
(* luaconfig.h *)
|
|
35 |
(*****************************************************************************)
|
|
36 |
|
|
37 |
(*
|
|
38 |
** $Id: luaconf.h,v 1.81 2006/02/10 17:44:06 roberto Exp $
|
|
39 |
** Configuration file for Lua
|
|
40 |
** See Copyright Notice in lua.h
|
|
41 |
*)
|
|
42 |
|
|
43 |
(*
|
|
44 |
** {==================================================================
|
|
45 |
@@ LUA_NUMBER is the type of numbers in Lua.
|
|
46 |
** CHANGE the following definitions only if you want to build Lua
|
|
47 |
** with a number type different from double. You may also need to
|
|
48 |
** change lua_number2int & lua_number2integer.
|
|
49 |
** ===================================================================
|
|
50 |
*)
|
|
51 |
type
|
|
52 |
LUA_NUMBER_ = type Double; // ending underscore is needed in Pascal
|
|
53 |
LUA_INTEGER_ = type LongInt;
|
|
54 |
|
|
55 |
(*
|
|
56 |
@@ LUA_IDSIZE gives the maximum size for the description of the source
|
|
57 |
@* of a function in debug information.
|
|
58 |
** CHANGE it if you want a different size.
|
|
59 |
*)
|
|
60 |
const
|
|
61 |
LUA_IDSIZE = 60;
|
|
62 |
|
|
63 |
(*
|
|
64 |
@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
|
|
65 |
*)
|
|
66 |
const
|
|
67 |
LUAL_BUFFERSIZE = 1024;
|
|
68 |
|
|
69 |
(*
|
|
70 |
@@ LUA_PROMPT is the default prompt used by stand-alone Lua.
|
|
71 |
@@ LUA_PROMPT2 is the default continuation prompt used by stand-alone Lua.
|
|
72 |
** CHANGE them if you want different prompts. (You can also change the
|
|
73 |
** prompts dynamically, assigning to globals _PROMPT/_PROMPT2.)
|
|
74 |
*)
|
|
75 |
const
|
|
76 |
LUA_PROMPT = '> ';
|
|
77 |
LUA_PROMPT2 = '>> ';
|
|
78 |
|
|
79 |
(*
|
|
80 |
@@ lua_readline defines how to show a prompt and then read a line from
|
|
81 |
@* the standard input.
|
|
82 |
@@ lua_saveline defines how to "save" a read line in a "history".
|
|
83 |
@@ lua_freeline defines how to free a line read by lua_readline.
|
|
84 |
** CHANGE them if you want to improve this functionality (e.g., by using
|
|
85 |
** GNU readline and history facilities).
|
|
86 |
*)
|
|
87 |
function lua_readline(L : Plua_State; var b : PChar; p : PChar): Boolean;
|
|
88 |
procedure lua_saveline(L : Plua_State; idx : LongInt);
|
|
89 |
procedure lua_freeline(L : Plua_State; b : PChar);
|
|
90 |
|
|
91 |
(*
|
|
92 |
@@ lua_stdin_is_tty detects whether the standard input is a 'tty' (that
|
|
93 |
@* is, whether we're running lua interactively).
|
|
94 |
** CHANGE it if you have a better definition for non-POSIX/non-Windows
|
|
95 |
** systems.
|
|
96 |
*/
|
|
97 |
#include <io.h>
|
|
98 |
#include <stdio.h>
|
|
99 |
#define lua_stdin_is_tty() _isatty(_fileno(stdin))
|
|
100 |
*)
|
|
101 |
const
|
|
102 |
lua_stdin_is_tty = TRUE;
|
|
103 |
|
|
104 |
(*****************************************************************************)
|
|
105 |
(* lua.h *)
|
|
106 |
(*****************************************************************************)
|
|
107 |
|
|
108 |
(*
|
|
109 |
** $Id: lua.h,v 1.216 2006/01/10 12:50:13 roberto Exp $
|
|
110 |
** Lua - An Extensible Extension Language
|
|
111 |
** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
|
|
112 |
** See Copyright Notice at the end of this file
|
|
113 |
*)
|
|
114 |
|
|
115 |
const
|
|
116 |
LUA_VERSION = 'Lua 5.1';
|
|
117 |
LUA_VERSION_NUM = 501;
|
|
118 |
LUA_COPYRIGHT = 'Copyright (C) 1994-2006 Tecgraf, PUC-Rio';
|
|
119 |
LUA_AUTHORS = 'R. Ierusalimschy, L. H. de Figueiredo & W. Celes';
|
|
120 |
|
|
121 |
(* mark for precompiled code (`<esc>Lua') *)
|
|
122 |
LUA_SIGNATURE = #27'Lua';
|
|
123 |
|
|
124 |
(* option for multiple returns in `lua_pcall' and `lua_call' *)
|
|
125 |
LUA_MULTRET = -1;
|
|
126 |
|
|
127 |
(*
|
|
128 |
** pseudo-indices
|
|
129 |
*)
|
|
130 |
LUA_REGISTRYINDEX = -10000;
|
|
131 |
LUA_ENVIRONINDEX = -10001;
|
|
132 |
LUA_GLOBALSINDEX = -10002;
|
|
133 |
|
|
134 |
function lua_upvalueindex(idx : LongInt) : LongInt; // a marco
|
|
135 |
|
|
136 |
const
|
|
137 |
(* thread status; 0 is OK *)
|
|
138 |
LUA_YIELD_ = 1; // Note: the ending underscore is needed in Pascal
|
|
139 |
LUA_ERRRUN = 2;
|
|
140 |
LUA_ERRSYNTAX = 3;
|
|
141 |
LUA_ERRMEM = 4;
|
|
142 |
LUA_ERRERR = 5;
|
|
143 |
|
|
144 |
type
|
|
145 |
lua_CFunction = function(L : Plua_State) : LongInt; cdecl;
|
|
146 |
|
|
147 |
(*
|
|
148 |
** functions that read/write blocks when loading/dumping Lua chunks
|
|
149 |
*)
|
|
150 |
lua_Reader = function (L : Plua_State; ud : Pointer;
|
|
151 |
sz : Psize_t) : PChar; cdecl;
|
|
152 |
lua_Writer = function (L : Plua_State; const p : Pointer; sz : size_t;
|
|
153 |
ud : Pointer) : LongInt; cdecl;
|
|
154 |
|
|
155 |
(*
|
|
156 |
** prototype for memory-allocation functions
|
|
157 |
*)
|
|
158 |
lua_Alloc = function (ud, ptr : Pointer;
|
|
159 |
osize, nsize : size_t) : Pointer; cdecl;
|
|
160 |
|
|
161 |
const
|
|
162 |
(*
|
|
163 |
** basic types
|
|
164 |
*)
|
|
165 |
LUA_TNONE = -1;
|
|
166 |
|
|
167 |
LUA_TNIL = 0;
|
|
168 |
LUA_TBOOLEAN = 1;
|
|
169 |
LUA_TLIGHTUSERDATA = 2;
|
|
170 |
LUA_TNUMBER = 3;
|
|
171 |
LUA_TSTRING = 4;
|
|
172 |
LUA_TTABLE = 5;
|
|
173 |
LUA_TFUNCTION = 6;
|
|
174 |
LUA_TUSERDATA = 7;
|
|
175 |
LUA_TTHREAD = 8;
|
|
176 |
|
|
177 |
(* minimum Lua stack available to a C function *)
|
|
178 |
LUA_MINSTACK = 20;
|
|
179 |
|
|
180 |
type
|
|
181 |
(* type of numbers in Lua *)
|
|
182 |
lua_Number = LUA_NUMBER_;
|
|
183 |
|
|
184 |
(* type for integer functions *)
|
|
185 |
lua_Integer = LUA_INTEGER_;
|
|
186 |
|
|
187 |
(*
|
|
188 |
** state manipulation
|
|
189 |
*)
|
|
190 |
function lua_newstate(f : lua_Alloc; ud : Pointer) : Plua_State;
|
2799
|
191 |
cdecl; external LuaLibName;
|
2786
|
192 |
procedure lua_close(L: Plua_State);
|
2799
|
193 |
cdecl; external LuaLibName;
|
2786
|
194 |
function lua_newthread(L : Plua_State) : Plua_State;
|
2799
|
195 |
cdecl; external LuaLibName;
|
2786
|
196 |
|
|
197 |
function lua_atpanic(L : Plua_State; panicf : lua_CFunction) : lua_CFunction;
|
2799
|
198 |
cdecl; external LuaLibName;
|
2786
|
199 |
|
|
200 |
|
|
201 |
(*
|
|
202 |
** basic stack manipulation
|
|
203 |
*)
|
|
204 |
function lua_gettop(L : Plua_State) : LongInt;
|
2799
|
205 |
cdecl; external LuaLibName;
|
2786
|
206 |
procedure lua_settop(L : Plua_State; idx : LongInt);
|
2799
|
207 |
cdecl; external LuaLibName;
|
2786
|
208 |
procedure lua_pushvalue(L : Plua_State; idx : LongInt);
|
2799
|
209 |
cdecl; external LuaLibName;
|
2786
|
210 |
procedure lua_remove(L : Plua_State; idx : LongInt);
|
2799
|
211 |
cdecl; external LuaLibName;
|
2786
|
212 |
procedure lua_insert(L : Plua_State; idx : LongInt);
|
2799
|
213 |
cdecl; external LuaLibName;
|
2786
|
214 |
procedure lua_replace(L : Plua_State; idx : LongInt);
|
2799
|
215 |
cdecl; external LuaLibName;
|
2786
|
216 |
function lua_checkstack(L : Plua_State; sz : LongInt) : LongBool;
|
2799
|
217 |
cdecl; external LuaLibName;
|
2786
|
218 |
|
|
219 |
procedure lua_xmove(src, dest : Plua_State; n : LongInt);
|
2799
|
220 |
cdecl; external LuaLibName;
|
2786
|
221 |
|
|
222 |
|
|
223 |
(*
|
|
224 |
** access functions (stack -> C)
|
|
225 |
*)
|
|
226 |
function lua_isnumber(L : Plua_State; idx : LongInt) : LongBool;
|
2799
|
227 |
cdecl; external LuaLibName;
|
2786
|
228 |
function lua_isstring(L : Plua_State; idx : LongInt) : LongBool;
|
2799
|
229 |
cdecl; external LuaLibName;
|
2786
|
230 |
function lua_iscfunction(L : Plua_State; idx : LongInt) : LongBool;
|
2799
|
231 |
cdecl; external LuaLibName;
|
2786
|
232 |
function lua_isuserdata(L : Plua_State; idx : LongInt) : LongBool;
|
2799
|
233 |
cdecl; external LuaLibName;
|
2786
|
234 |
function lua_type(L : Plua_State; idx : LongInt) : LongInt;
|
2799
|
235 |
cdecl; external LuaLibName;
|
2786
|
236 |
function lua_typename(L : Plua_State; tp : LongInt) : PChar;
|
2799
|
237 |
cdecl; external LuaLibName;
|
2786
|
238 |
|
|
239 |
function lua_equal(L : Plua_State; idx1, idx2 : LongInt) : LongBool;
|
2799
|
240 |
cdecl; external LuaLibName;
|
2786
|
241 |
function lua_rawequal(L : Plua_State; idx1, idx2 : LongInt) : LongBool;
|
2799
|
242 |
cdecl; external LuaLibName;
|
2786
|
243 |
function lua_lessthan(L : Plua_State; idx1, idx2 : LongInt) : LongBool;
|
2799
|
244 |
cdecl; external LuaLibName;
|
2786
|
245 |
|
|
246 |
function lua_tonumber(L : Plua_State; idx : LongInt) : lua_Number;
|
2799
|
247 |
cdecl; external LuaLibName;
|
2786
|
248 |
function lua_tointeger(L : Plua_State; idx : LongInt) : lua_Integer;
|
2799
|
249 |
cdecl; external LuaLibName;
|
2786
|
250 |
function lua_toboolean(L : Plua_State; idx : LongInt) : LongBool;
|
2799
|
251 |
cdecl; external LuaLibName;
|
2786
|
252 |
function lua_tolstring(L : Plua_State; idx : LongInt;
|
|
253 |
len : Psize_t) : PChar;
|
2799
|
254 |
cdecl; external LuaLibName;
|
2786
|
255 |
function lua_objlen(L : Plua_State; idx : LongInt) : size_t;
|
2799
|
256 |
cdecl; external LuaLibName;
|
2786
|
257 |
function lua_tocfunction(L : Plua_State; idx : LongInt) : lua_CFunction;
|
2799
|
258 |
cdecl; external LuaLibName;
|
2786
|
259 |
function lua_touserdata(L : Plua_State; idx : LongInt) : Pointer;
|
2799
|
260 |
cdecl; external LuaLibName;
|
2786
|
261 |
function lua_tothread(L : Plua_State; idx : LongInt) : Plua_State;
|
2799
|
262 |
cdecl; external LuaLibName;
|
2786
|
263 |
function lua_topointer(L : Plua_State; idx : LongInt) : Pointer;
|
2799
|
264 |
cdecl; external LuaLibName;
|
2786
|
265 |
|
|
266 |
|
|
267 |
(*
|
|
268 |
** push functions (C -> stack)
|
|
269 |
*)
|
|
270 |
procedure lua_pushnil(L : Plua_State);
|
2799
|
271 |
cdecl; external LuaLibName;
|
2786
|
272 |
procedure lua_pushnumber(L : Plua_State; n : lua_Number);
|
2799
|
273 |
cdecl; external LuaLibName;
|
2786
|
274 |
procedure lua_pushinteger(L : Plua_State; n : lua_Integer);
|
2799
|
275 |
cdecl; external LuaLibName;
|
2786
|
276 |
procedure lua_pushlstring(L : Plua_State; const s : PChar; ls : size_t);
|
2799
|
277 |
cdecl; external LuaLibName;
|
2786
|
278 |
procedure lua_pushstring(L : Plua_State; const s : PChar);
|
2799
|
279 |
cdecl; external LuaLibName;
|
2786
|
280 |
function lua_pushvfstring(L : Plua_State;
|
|
281 |
const fmt : PChar; argp : Pointer) : PChar;
|
2799
|
282 |
cdecl; external LuaLibName;
|
2786
|
283 |
function lua_pushfstring(L : Plua_State; const fmt : PChar) : PChar; varargs;
|
2799
|
284 |
cdecl; external LuaLibName;
|
2786
|
285 |
procedure lua_pushcclosure(L : Plua_State; fn : lua_CFunction; n : LongInt);
|
2799
|
286 |
cdecl; external LuaLibName;
|
2786
|
287 |
procedure lua_pushboolean(L : Plua_State; b : LongBool);
|
2799
|
288 |
cdecl; external LuaLibName;
|
2786
|
289 |
procedure lua_pushlightuserdata(L : Plua_State; p : Pointer);
|
2799
|
290 |
cdecl; external LuaLibName;
|
2786
|
291 |
function lua_pushthread(L : Plua_state) : Cardinal;
|
2799
|
292 |
cdecl; external LuaLibName;
|
2786
|
293 |
|
|
294 |
|
|
295 |
(*
|
|
296 |
** get functions (Lua -> stack)
|
|
297 |
*)
|
|
298 |
procedure lua_gettable(L : Plua_State ; idx : LongInt);
|
2799
|
299 |
cdecl; external LuaLibName;
|
2786
|
300 |
procedure lua_getfield(L : Plua_State; idx : LongInt; k : PChar);
|
2799
|
301 |
cdecl; external LuaLibName;
|
2786
|
302 |
procedure lua_rawget(L : Plua_State; idx : LongInt);
|
2799
|
303 |
cdecl; external LuaLibName;
|
2786
|
304 |
procedure lua_rawgeti(L : Plua_State; idx, n : LongInt);
|
2799
|
305 |
cdecl; external LuaLibName;
|
2786
|
306 |
procedure lua_createtable(L : Plua_State; narr, nrec : LongInt);
|
2799
|
307 |
cdecl; external LuaLibName;
|
2786
|
308 |
function lua_newuserdata(L : Plua_State; sz : size_t) : Pointer;
|
2799
|
309 |
cdecl; external LuaLibName;
|
2786
|
310 |
function lua_getmetatable(L : Plua_State; objindex : LongInt) : LongBool;
|
2799
|
311 |
cdecl; external LuaLibName;
|
2786
|
312 |
procedure lua_getfenv(L : Plua_State; idx : LongInt);
|
2799
|
313 |
cdecl; external LuaLibName;
|
2786
|
314 |
|
|
315 |
|
|
316 |
(*
|
|
317 |
** set functions (stack -> Lua)
|
|
318 |
*)
|
|
319 |
procedure lua_settable(L : Plua_State; idx : LongInt);
|
2799
|
320 |
cdecl; external LuaLibName;
|
2786
|
321 |
procedure lua_setfield(L : Plua_State; idx : LongInt; const k : PChar);
|
2799
|
322 |
cdecl; external LuaLibName;
|
2786
|
323 |
procedure lua_rawset(L : Plua_State; idx : LongInt);
|
2799
|
324 |
cdecl; external LuaLibName;
|
2786
|
325 |
procedure lua_rawseti(L : Plua_State; idx , n: LongInt);
|
2799
|
326 |
cdecl; external LuaLibName;
|
2786
|
327 |
function lua_setmetatable(L : Plua_State; objindex : LongInt): LongBool;
|
2799
|
328 |
cdecl; external LuaLibName;
|
2786
|
329 |
function lua_setfenv(L : Plua_State; idx : LongInt): LongBool;
|
2799
|
330 |
cdecl; external LuaLibName;
|
2786
|
331 |
|
|
332 |
(*
|
|
333 |
** `load' and `call' functions (load and run Lua code)
|
|
334 |
*)
|
|
335 |
procedure lua_call(L : Plua_State; nargs, nresults : LongInt);
|
2799
|
336 |
cdecl; external LuaLibName;
|
2786
|
337 |
function lua_pcall(L : Plua_State;
|
|
338 |
nargs, nresults, errfunc : LongInt) : LongInt;
|
2799
|
339 |
cdecl; external LuaLibName;
|
2786
|
340 |
function lua_cpcall(L : Plua_State;
|
|
341 |
func : lua_CFunction; ud : Pointer) : LongInt;
|
2799
|
342 |
cdecl; external LuaLibName;
|
2786
|
343 |
function lua_load(L : Plua_State; reader : lua_Reader;
|
|
344 |
dt : Pointer; const chunkname : PChar) : LongInt;
|
2799
|
345 |
cdecl; external LuaLibName;
|
2786
|
346 |
|
|
347 |
function lua_dump(L : Plua_State; writer : lua_Writer; data: Pointer) : LongInt;
|
2799
|
348 |
cdecl; external LuaLibName;
|
2786
|
349 |
|
|
350 |
|
|
351 |
(*
|
|
352 |
** coroutine functions
|
|
353 |
*)
|
|
354 |
function lua_yield(L : Plua_State; nresults : LongInt) : LongInt;
|
2799
|
355 |
cdecl; external LuaLibName;
|
2786
|
356 |
function lua_resume(L : Plua_State; narg : LongInt) : LongInt;
|
2799
|
357 |
cdecl; external LuaLibName;
|
2786
|
358 |
function lua_status(L : Plua_State) : LongInt;
|
2799
|
359 |
cdecl; external LuaLibName;
|
2786
|
360 |
|
|
361 |
(*
|
|
362 |
** garbage-collection functions and options
|
|
363 |
*)
|
|
364 |
const
|
|
365 |
LUA_GCSTOP = 0;
|
|
366 |
LUA_GCRESTART = 1;
|
|
367 |
LUA_GCCOLLECT = 2;
|
|
368 |
LUA_GCCOUNT = 3;
|
|
369 |
LUA_GCCOUNTB = 4;
|
|
370 |
LUA_GCSTEP = 5;
|
|
371 |
LUA_GCSETPAUSE = 6;
|
|
372 |
LUA_GCSETSTEPMUL = 7;
|
|
373 |
|
|
374 |
function lua_gc(L : Plua_State; what, data : LongInt) : LongInt;
|
2799
|
375 |
cdecl; external LuaLibName;
|
2786
|
376 |
|
|
377 |
(*
|
|
378 |
** miscellaneous functions
|
|
379 |
*)
|
|
380 |
function lua_error(L : Plua_State) : LongInt;
|
2799
|
381 |
cdecl; external LuaLibName;
|
2786
|
382 |
|
|
383 |
function lua_next(L : Plua_State; idx : LongInt) : LongInt;
|
2799
|
384 |
cdecl; external LuaLibName;
|
2786
|
385 |
|
|
386 |
procedure lua_concat(L : Plua_State; n : LongInt);
|
2799
|
387 |
cdecl; external LuaLibName;
|
2786
|
388 |
|
|
389 |
function lua_getallocf(L : Plua_State; ud : PPointer) : lua_Alloc;
|
2799
|
390 |
cdecl; external LuaLibName;
|
2786
|
391 |
procedure lua_setallocf(L : Plua_State; f : lua_Alloc; ud : Pointer);
|
2799
|
392 |
cdecl; external LuaLibName;
|
2786
|
393 |
|
|
394 |
(*
|
|
395 |
** ===============================================================
|
|
396 |
** some useful macros
|
|
397 |
** ===============================================================
|
|
398 |
*)
|
|
399 |
procedure lua_pop(L : Plua_State; n : LongInt);
|
|
400 |
|
|
401 |
procedure lua_newtable(L : Plua_State);
|
|
402 |
|
|
403 |
procedure lua_register(L : Plua_State; n : PChar; f : lua_CFunction);
|
|
404 |
|
|
405 |
procedure lua_pushcfunction(L : Plua_State; f : lua_CFunction);
|
|
406 |
|
|
407 |
function lua_strlen(L : Plua_State; idx : LongInt) : LongInt;
|
|
408 |
|
|
409 |
function lua_isfunction(L : Plua_State; n : LongInt) : Boolean;
|
|
410 |
function lua_istable(L : Plua_State; n : LongInt) : Boolean;
|
|
411 |
function lua_islightuserdata(L : Plua_State; n : LongInt) : Boolean;
|
|
412 |
function lua_isnil(L : Plua_State; n : LongInt) : Boolean;
|
|
413 |
function lua_isboolean(L : Plua_State; n : LongInt) : Boolean;
|
|
414 |
function lua_isthread(L : Plua_State; n : LongInt) : Boolean;
|
|
415 |
function lua_isnone(L : Plua_State; n : LongInt) : Boolean;
|
|
416 |
function lua_isnoneornil(L : Plua_State; n : LongInt) : Boolean;
|
|
417 |
|
|
418 |
procedure lua_pushliteral(L : Plua_State; s : PChar);
|
|
419 |
|
|
420 |
procedure lua_setglobal(L : Plua_State; s : PChar);
|
|
421 |
procedure lua_getglobal(L : Plua_State; s : PChar);
|
|
422 |
|
|
423 |
function lua_tostring(L : Plua_State; idx : LongInt) : PChar;
|
|
424 |
|
|
425 |
|
|
426 |
(*
|
|
427 |
** compatibility macros and functions
|
|
428 |
*)
|
|
429 |
function lua_open : Plua_State;
|
|
430 |
|
|
431 |
procedure lua_getregistry(L : Plua_State);
|
|
432 |
|
|
433 |
function lua_getgccount(L : Plua_State) : LongInt;
|
|
434 |
|
|
435 |
type
|
|
436 |
lua_Chuckreader = type lua_Reader;
|
|
437 |
lua_Chuckwriter = type lua_Writer;
|
|
438 |
|
|
439 |
(* ====================================================================== *)
|
|
440 |
|
|
441 |
(*
|
|
442 |
** {======================================================================
|
|
443 |
** Debug API
|
|
444 |
** =======================================================================
|
|
445 |
*)
|
|
446 |
|
|
447 |
(*
|
|
448 |
** Event codes
|
|
449 |
*)
|
|
450 |
const
|
|
451 |
LUA_HOOKCALL = 0;
|
|
452 |
LUA_HOOKRET = 1;
|
|
453 |
LUA_HOOKLINE = 2;
|
|
454 |
LUA_HOOKCOUNT = 3;
|
|
455 |
LUA_HOOKTAILRET = 4;
|
|
456 |
|
|
457 |
|
|
458 |
(*
|
|
459 |
** Event masks
|
|
460 |
*)
|
|
461 |
LUA_MASKCALL = 1 shl LUA_HOOKCALL;
|
|
462 |
LUA_MASKRET = 1 shl LUA_HOOKRET;
|
|
463 |
LUA_MASKLINE = 1 shl LUA_HOOKLINE;
|
|
464 |
LUA_MASKCOUNT = 1 shl LUA_HOOKCOUNT;
|
|
465 |
|
|
466 |
type
|
|
467 |
lua_Debug = packed record
|
|
468 |
event : LongInt;
|
|
469 |
name : PChar; (* (n) *)
|
|
470 |
namewhat : PChar; (* (n) `global', `local', `field', `method' *)
|
|
471 |
what : PChar; (* (S) `Lua', `C', `main', `tail' *)
|
|
472 |
source : PChar; (* (S) *)
|
|
473 |
currentline : LongInt; (* (l) *)
|
|
474 |
nups : LongInt; (* (u) number of upvalues *)
|
|
475 |
linedefined : LongInt; (* (S) *)
|
|
476 |
short_src : array [0..LUA_IDSIZE-1] of Char; (* (S) *)
|
|
477 |
(* private part *)
|
|
478 |
i_ci : LongInt; (* active function *)
|
|
479 |
end;
|
|
480 |
Plua_Debug = ^lua_Debug;
|
|
481 |
|
|
482 |
(* Functions to be called by the debuger in specific events *)
|
|
483 |
lua_Hook = procedure (L : Plua_State; ar : Plua_Debug); cdecl;
|
|
484 |
|
|
485 |
|
|
486 |
function lua_getstack(L : Plua_State; level : LongInt;
|
|
487 |
ar : Plua_Debug) : LongInt;
|
2799
|
488 |
cdecl; external LuaLibName;
|
2786
|
489 |
function lua_getinfo(L : Plua_State; const what : PChar;
|
|
490 |
ar: Plua_Debug): LongInt;
|
2799
|
491 |
cdecl; external LuaLibName;
|
2786
|
492 |
function lua_getlocal(L : Plua_State;
|
|
493 |
ar : Plua_Debug; n : LongInt) : PChar;
|
2799
|
494 |
cdecl; external LuaLibName;
|
2786
|
495 |
function lua_setlocal(L : Plua_State;
|
|
496 |
ar : Plua_Debug; n : LongInt) : PChar;
|
2799
|
497 |
cdecl; external LuaLibName;
|
2786
|
498 |
function lua_getupvalue(L : Plua_State; funcindex, n : LongInt) : PChar;
|
2799
|
499 |
cdecl; external LuaLibName;
|
2786
|
500 |
function lua_setupvalue(L : Plua_State; funcindex, n : LongInt) : PChar;
|
2799
|
501 |
cdecl; external LuaLibName;
|
2786
|
502 |
|
|
503 |
function lua_sethook(L : Plua_State; func : lua_Hook;
|
|
504 |
mask, count: LongInt): LongInt;
|
2799
|
505 |
cdecl; external LuaLibName;
|
2786
|
506 |
{$IFDEF LUA_GETHOOK}
|
|
507 |
function lua_gethook(L : Plua_State) : lua_Hook;
|
2799
|
508 |
cdecl; external LuaLibName;
|
2786
|
509 |
{$ENDIF}
|
|
510 |
|
|
511 |
function lua_gethookmask(L : Plua_State) : LongInt;
|
2799
|
512 |
cdecl; external LuaLibName;
|
2786
|
513 |
function lua_gethookcount(L : Plua_State) : LongInt;
|
2799
|
514 |
cdecl; external LuaLibName;
|
2786
|
515 |
|
|
516 |
|
|
517 |
(*****************************************************************************)
|
|
518 |
(* lualib.h *)
|
|
519 |
(*****************************************************************************)
|
|
520 |
|
|
521 |
(*
|
|
522 |
** $Id: lualib.h,v 1.36 2005/12/27 17:12:00 roberto Exp $
|
|
523 |
** Lua standard libraries
|
|
524 |
** See Copyright Notice at the end of this file
|
|
525 |
*)
|
|
526 |
|
|
527 |
const
|
|
528 |
(* Key to file-handle type *)
|
|
529 |
LUA_FILEHANDLE = 'FILE*';
|
|
530 |
|
|
531 |
LUA_COLIBNAME = 'coroutine';
|
|
532 |
LUA_TABLIBNAME = 'table';
|
|
533 |
LUA_IOLIBNAME = 'io';
|
|
534 |
LUA_OSLIBNAME = 'os';
|
|
535 |
LUA_STRLIBNAME = 'string';
|
|
536 |
LUA_MATHLIBNAME = 'math';
|
|
537 |
LUA_DBLIBNAME = 'debug';
|
|
538 |
LUA_LOADLIBNAME = 'package';
|
|
539 |
|
|
540 |
function luaopen_base(L : Plua_State) : LongInt;
|
2799
|
541 |
cdecl; external LuaLibName;
|
2786
|
542 |
|
|
543 |
function luaopen_table(L : Plua_State) : LongInt;
|
2799
|
544 |
cdecl; external LuaLibName;
|
2786
|
545 |
|
|
546 |
function luaopen_io(L : Plua_State) : LongInt;
|
2799
|
547 |
cdecl; external LuaLibName;
|
2786
|
548 |
|
|
549 |
function luaopen_os(L : Plua_State) : LongInt;
|
2799
|
550 |
cdecl; external LuaLibName;
|
2786
|
551 |
|
|
552 |
function luaopen_string(L : Plua_State) : LongInt;
|
2799
|
553 |
cdecl; external LuaLibName;
|
2786
|
554 |
|
|
555 |
function luaopen_math(L : Plua_State) : LongInt;
|
2799
|
556 |
cdecl; external LuaLibName;
|
2786
|
557 |
|
|
558 |
function luaopen_debug(L : Plua_State) : LongInt;
|
2799
|
559 |
cdecl; external LuaLibName;
|
2786
|
560 |
|
|
561 |
function luaopen_package(L : Plua_State) : LongInt;
|
2799
|
562 |
cdecl; external LuaLibName;
|
2786
|
563 |
|
|
564 |
procedure luaL_openlibs(L : Plua_State);
|
2799
|
565 |
cdecl; external LuaLibName;
|
2786
|
566 |
|
|
567 |
procedure lua_assert(x : Boolean); // a macro
|
|
568 |
|
|
569 |
|
|
570 |
(*****************************************************************************)
|
|
571 |
(* lauxlib.h *)
|
|
572 |
(*****************************************************************************)
|
|
573 |
|
|
574 |
(*
|
|
575 |
** $Id: lauxlib.h,v 1.87 2005/12/29 15:32:11 roberto Exp $
|
|
576 |
** Auxiliary functions for building Lua libraries
|
|
577 |
** See Copyright Notice at the end of this file.
|
|
578 |
*)
|
|
579 |
|
|
580 |
// not compatibility with the behavior of setn/getn in Lua 5.0
|
|
581 |
function luaL_getn(L : Plua_State; idx : LongInt) : LongInt;
|
|
582 |
procedure luaL_setn(L : Plua_State; i, j : LongInt);
|
|
583 |
|
|
584 |
const
|
|
585 |
LUA_ERRFILE = LUA_ERRERR + 1;
|
|
586 |
|
|
587 |
type
|
|
588 |
luaL_Reg = packed record
|
|
589 |
name : PChar;
|
|
590 |
func : lua_CFunction;
|
|
591 |
end;
|
|
592 |
PluaL_Reg = ^luaL_Reg;
|
|
593 |
|
|
594 |
|
|
595 |
procedure luaL_openlib(L : Plua_State; const libname : PChar;
|
|
596 |
const lr : PluaL_Reg; nup : LongInt);
|
2799
|
597 |
cdecl; external LuaLibName;
|
2786
|
598 |
procedure luaL_register(L : Plua_State; const libname : PChar;
|
|
599 |
const lr : PluaL_Reg);
|
2799
|
600 |
cdecl; external LuaLibName;
|
2786
|
601 |
function luaL_getmetafield(L : Plua_State; obj : LongInt;
|
|
602 |
const e : PChar) : LongInt;
|
2799
|
603 |
cdecl; external LuaLibName;
|
2786
|
604 |
function luaL_callmeta(L : Plua_State; obj : LongInt;
|
|
605 |
const e : PChar) : LongInt;
|
2799
|
606 |
cdecl; external LuaLibName;
|
2786
|
607 |
function luaL_typerror(L : Plua_State; narg : LongInt;
|
|
608 |
const tname : PChar) : LongInt;
|
2799
|
609 |
cdecl; external LuaLibName;
|
2786
|
610 |
function luaL_argerror(L : Plua_State; numarg : LongInt;
|
|
611 |
const extramsg : PChar) : LongInt;
|
2799
|
612 |
cdecl; external LuaLibName;
|
2786
|
613 |
function luaL_checklstring(L : Plua_State; numArg : LongInt;
|
|
614 |
ls : Psize_t) : PChar;
|
2799
|
615 |
cdecl; external LuaLibName;
|
2786
|
616 |
function luaL_optlstring(L : Plua_State; numArg : LongInt;
|
|
617 |
const def: PChar; ls: Psize_t) : PChar;
|
2799
|
618 |
cdecl; external LuaLibName;
|
2786
|
619 |
function luaL_checknumber(L : Plua_State; numArg : LongInt) : lua_Number;
|
2799
|
620 |
cdecl; external LuaLibName;
|
2786
|
621 |
function luaL_optnumber(L : Plua_State; nArg : LongInt;
|
|
622 |
def : lua_Number) : lua_Number;
|
2799
|
623 |
cdecl; external LuaLibName;
|
2786
|
624 |
|
|
625 |
function luaL_checkinteger(L : Plua_State; numArg : LongInt) : lua_Integer;
|
2799
|
626 |
cdecl; external LuaLibName;
|
2786
|
627 |
function luaL_optinteger(L : Plua_State; nArg : LongInt;
|
|
628 |
def : lua_Integer) : lua_Integer;
|
2799
|
629 |
cdecl; external LuaLibName;
|
2786
|
630 |
|
|
631 |
procedure luaL_checkstack(L : Plua_State; sz : LongInt; const msg : PChar);
|
2799
|
632 |
cdecl; external LuaLibName;
|
2786
|
633 |
procedure luaL_checktype(L : Plua_State; narg, t : LongInt);
|
2799
|
634 |
cdecl; external LuaLibName;
|
2786
|
635 |
procedure luaL_checkany(L : Plua_State; narg : LongInt);
|
2799
|
636 |
cdecl; external LuaLibName;
|
2786
|
637 |
|
|
638 |
function luaL_newmetatable(L : Plua_State; const tname : PChar) : LongInt;
|
2799
|
639 |
cdecl; external LuaLibName;
|
2786
|
640 |
function luaL_checkudata(L : Plua_State; ud : LongInt;
|
|
641 |
const tname : PChar) : Pointer;
|
2799
|
642 |
cdecl; external LuaLibName;
|
2786
|
643 |
|
|
644 |
procedure luaL_where(L : Plua_State; lvl : LongInt);
|
2799
|
645 |
cdecl; external LuaLibName;
|
2786
|
646 |
function luaL_error(L : Plua_State; const fmt : PChar) : LongInt; varargs;
|
2799
|
647 |
cdecl; external LuaLibName;
|
2786
|
648 |
|
|
649 |
function luaL_checkoption(L : Plua_State; narg : LongInt; const def : PChar;
|
|
650 |
const lst : array of PChar) : LongInt;
|
2799
|
651 |
cdecl; external LuaLibName;
|
2786
|
652 |
|
|
653 |
function luaL_ref(L : Plua_State; t : LongInt) : LongInt;
|
2799
|
654 |
cdecl; external LuaLibName;
|
2786
|
655 |
procedure luaL_unref(L : Plua_State; t, ref : LongInt);
|
2799
|
656 |
cdecl; external LuaLibName;
|
2786
|
657 |
|
|
658 |
function luaL_loadfile(L : Plua_State; const filename : PChar) : LongInt;
|
2799
|
659 |
cdecl; external LuaLibName;
|
2786
|
660 |
function luaL_loadbuffer(L : Plua_State; const buff : PChar;
|
|
661 |
sz : size_t; const name: PChar) : LongInt;
|
2799
|
662 |
cdecl; external LuaLibName;
|
2786
|
663 |
|
|
664 |
function luaL_loadstring(L : Plua_State; const s : Pchar) : LongInt;
|
2799
|
665 |
cdecl; external LuaLibName;
|
2786
|
666 |
|
|
667 |
function luaL_newstate : Plua_State;
|
2799
|
668 |
cdecl; external LuaLibName;
|
2786
|
669 |
|
|
670 |
function luaL_gsub(L : Plua_State; const s, p, r : PChar) : PChar;
|
2799
|
671 |
cdecl; external LuaLibName;
|
2786
|
672 |
|
|
673 |
function luaL_findtable(L : Plua_State; idx : LongInt;
|
|
674 |
const fname : PChar; szhint : LongInt) : PChar;
|
2799
|
675 |
cdecl; external LuaLibName;
|
2786
|
676 |
|
|
677 |
|
|
678 |
(*
|
|
679 |
** ===============================================================
|
|
680 |
** some useful macros
|
|
681 |
** ===============================================================
|
|
682 |
*)
|
|
683 |
|
|
684 |
function luaL_argcheck(L : Plua_State; cond : Boolean; numarg : LongInt;
|
|
685 |
extramsg : PChar): LongInt;
|
|
686 |
function luaL_checkstring(L : Plua_State; n : LongInt) : PChar;
|
|
687 |
function luaL_optstring(L : Plua_State; n : LongInt; d : PChar) : PChar;
|
|
688 |
function luaL_checkint(L : Plua_State; n : LongInt) : LongInt;
|
|
689 |
function luaL_optint(L : Plua_State; n, d : LongInt): LongInt;
|
|
690 |
function luaL_checklong(L : Plua_State; n : LongInt) : LongInt;
|
|
691 |
function luaL_optlong(L : Plua_State; n : LongInt; d : LongInt) : LongInt;
|
|
692 |
|
|
693 |
function luaL_typename(L : Plua_State; idx : LongInt) : PChar;
|
|
694 |
|
|
695 |
function luaL_dofile(L : Plua_State; fn : PChar) : LongInt;
|
|
696 |
|
|
697 |
function luaL_dostring(L : Plua_State; s : PChar) : LongInt;
|
|
698 |
|
|
699 |
procedure luaL_getmetatable(L : Plua_State; n : PChar);
|
|
700 |
|
|
701 |
(* not implemented yet
|
|
702 |
#define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n)))
|
|
703 |
*)
|
|
704 |
|
|
705 |
(*
|
|
706 |
** {======================================================
|
|
707 |
** Generic Buffer manipulation
|
|
708 |
** =======================================================
|
|
709 |
*)
|
|
710 |
|
|
711 |
type
|
|
712 |
luaL_Buffer = packed record
|
|
713 |
p : PChar; (* current position in buffer *)
|
|
714 |
lvl : LongInt; (* number of strings in the stack (level) *)
|
|
715 |
L : Plua_State;
|
|
716 |
buffer : array [0..LUAL_BUFFERSIZE-1] of Char;
|
|
717 |
end;
|
|
718 |
PluaL_Buffer = ^luaL_Buffer;
|
|
719 |
|
|
720 |
procedure luaL_addchar(B : PluaL_Buffer; c : Char);
|
|
721 |
|
|
722 |
(* compatibility only *)
|
|
723 |
procedure luaL_putchar(B : PluaL_Buffer; c : Char);
|
|
724 |
|
|
725 |
procedure luaL_addsize(B : PluaL_Buffer; n : LongInt);
|
|
726 |
|
|
727 |
procedure luaL_buffinit(L : Plua_State; B : PluaL_Buffer);
|
2799
|
728 |
cdecl; external LuaLibName;
|
2786
|
729 |
function luaL_prepbuffer(B : PluaL_Buffer) : PChar;
|
2799
|
730 |
cdecl; external LuaLibName;
|
2786
|
731 |
procedure luaL_addlstring(B : PluaL_Buffer; const s : PChar; ls : size_t);
|
2799
|
732 |
cdecl; external LuaLibName;
|
2786
|
733 |
procedure luaL_addstring(B : PluaL_Buffer; const s : PChar);
|
2799
|
734 |
cdecl; external LuaLibName;
|
2786
|
735 |
procedure luaL_addvalue(B : PluaL_Buffer);
|
2799
|
736 |
cdecl; external LuaLibName;
|
2786
|
737 |
procedure luaL_pushresult(B : PluaL_Buffer);
|
2799
|
738 |
cdecl; external LuaLibName;
|
2786
|
739 |
|
|
740 |
(* ====================================================== *)
|
|
741 |
|
|
742 |
|
|
743 |
(* compatibility with ref system *)
|
|
744 |
|
|
745 |
(* pre-defined references *)
|
|
746 |
const
|
|
747 |
LUA_NOREF = -2;
|
|
748 |
LUA_REFNIL = -1;
|
|
749 |
|
|
750 |
function lua_ref(L : Plua_State; lock : Boolean) : LongInt;
|
|
751 |
|
|
752 |
procedure lua_unref(L : Plua_State; ref : LongInt);
|
|
753 |
|
|
754 |
procedure lua_getref(L : Plua_State; ref : LongInt);
|
|
755 |
|
|
756 |
|
|
757 |
(******************************************************************************)
|
|
758 |
(******************************************************************************)
|
|
759 |
(******************************************************************************)
|
|
760 |
|
|
761 |
implementation
|
|
762 |
|
|
763 |
uses
|
|
764 |
SysUtils;
|
|
765 |
|
|
766 |
(*****************************************************************************)
|
|
767 |
(* luaconfig.h *)
|
|
768 |
(*****************************************************************************)
|
|
769 |
|
|
770 |
function lua_readline(L : Plua_State; var b : PChar; p : PChar): Boolean;
|
|
771 |
var
|
|
772 |
s : AnsiString;
|
|
773 |
begin
|
|
774 |
Write(p); // show prompt
|
|
775 |
ReadLn(s); // get line
|
|
776 |
b := PChar(s); // and return it
|
|
777 |
lua_readline := (b[0] <> #4); // test for ctrl-D
|
|
778 |
end;
|
|
779 |
|
|
780 |
procedure lua_saveline(L : Plua_State; idx : LongInt);
|
|
781 |
begin
|
|
782 |
end;
|
|
783 |
|
|
784 |
procedure lua_freeline(L : Plua_State; b : PChar);
|
|
785 |
begin
|
|
786 |
end;
|
|
787 |
|
|
788 |
|
|
789 |
(*****************************************************************************)
|
|
790 |
(* lua.h *)
|
|
791 |
(*****************************************************************************)
|
|
792 |
|
|
793 |
function lua_upvalueindex(idx : LongInt) : LongInt;
|
|
794 |
begin
|
|
795 |
lua_upvalueindex := LUA_GLOBALSINDEX - idx;
|
|
796 |
end;
|
|
797 |
|
|
798 |
procedure lua_pop(L : Plua_State; n : LongInt);
|
|
799 |
begin
|
|
800 |
lua_settop(L, -n - 1);
|
|
801 |
end;
|
|
802 |
|
|
803 |
procedure lua_newtable(L : Plua_State);
|
|
804 |
begin
|
|
805 |
lua_createtable(L, 0, 0);
|
|
806 |
end;
|
|
807 |
|
|
808 |
procedure lua_register(L : Plua_State; n : PChar; f : lua_CFunction);
|
|
809 |
begin
|
|
810 |
lua_pushcfunction(L, f);
|
|
811 |
lua_setglobal(L, n);
|
|
812 |
end;
|
|
813 |
|
|
814 |
procedure lua_pushcfunction(L : Plua_State; f : lua_CFunction);
|
|
815 |
begin
|
|
816 |
lua_pushcclosure(L, f, 0);
|
|
817 |
end;
|
|
818 |
|
|
819 |
function lua_strlen(L : Plua_State; idx : LongInt) : LongInt;
|
|
820 |
begin
|
|
821 |
lua_strlen := lua_objlen(L, idx);
|
|
822 |
end;
|
|
823 |
|
|
824 |
function lua_isfunction(L : Plua_State; n : LongInt) : Boolean;
|
|
825 |
begin
|
|
826 |
lua_isfunction := lua_type(L, n) = LUA_TFUNCTION;
|
|
827 |
end;
|
|
828 |
|
|
829 |
function lua_istable(L : Plua_State; n : LongInt) : Boolean;
|
|
830 |
begin
|
|
831 |
lua_istable := lua_type(L, n) = LUA_TTABLE;
|
|
832 |
end;
|
|
833 |
|
|
834 |
function lua_islightuserdata(L : Plua_State; n : LongInt) : Boolean;
|
|
835 |
begin
|
|
836 |
lua_islightuserdata := lua_type(L, n) = LUA_TLIGHTUSERDATA;
|
|
837 |
end;
|
|
838 |
|
|
839 |
function lua_isnil(L : Plua_State; n : LongInt) : Boolean;
|
|
840 |
begin
|
|
841 |
lua_isnil := lua_type(L, n) = LUA_TNIL;
|
|
842 |
end;
|
|
843 |
|
|
844 |
function lua_isboolean(L : Plua_State; n : LongInt) : Boolean;
|
|
845 |
begin
|
|
846 |
lua_isboolean := lua_type(L, n) = LUA_TBOOLEAN;
|
|
847 |
end;
|
|
848 |
|
|
849 |
function lua_isthread(L : Plua_State; n : LongInt) : Boolean;
|
|
850 |
begin
|
|
851 |
lua_isthread := lua_type(L, n) = LUA_TTHREAD;
|
|
852 |
end;
|
|
853 |
|
|
854 |
function lua_isnone(L : Plua_State; n : LongInt) : Boolean;
|
|
855 |
begin
|
|
856 |
lua_isnone := lua_type(L, n) = LUA_TNONE;
|
|
857 |
end;
|
|
858 |
|
|
859 |
function lua_isnoneornil(L : Plua_State; n : LongInt) : Boolean;
|
|
860 |
begin
|
|
861 |
lua_isnoneornil := lua_type(L, n) <= 0;
|
|
862 |
end;
|
|
863 |
|
|
864 |
procedure lua_pushliteral(L : Plua_State; s : PChar);
|
|
865 |
begin
|
|
866 |
lua_pushlstring(L, s, StrLen(s));
|
|
867 |
end;
|
|
868 |
|
|
869 |
procedure lua_setglobal(L : Plua_State; s : PChar);
|
|
870 |
begin
|
|
871 |
lua_setfield(L, LUA_GLOBALSINDEX, s);
|
|
872 |
end;
|
|
873 |
|
|
874 |
procedure lua_getglobal(L: Plua_State; s: PChar);
|
|
875 |
begin
|
|
876 |
lua_getfield(L, LUA_GLOBALSINDEX, s);
|
|
877 |
end;
|
|
878 |
|
|
879 |
function lua_tostring(L : Plua_State; idx : LongInt) : PChar;
|
|
880 |
begin
|
|
881 |
lua_tostring := lua_tolstring(L, idx, nil);
|
|
882 |
end;
|
|
883 |
|
|
884 |
function lua_open : Plua_State;
|
|
885 |
begin
|
|
886 |
lua_open := luaL_newstate;
|
|
887 |
end;
|
|
888 |
|
|
889 |
procedure lua_getregistry(L : Plua_State);
|
|
890 |
begin
|
|
891 |
lua_pushvalue(L, LUA_REGISTRYINDEX);
|
|
892 |
end;
|
|
893 |
|
|
894 |
function lua_getgccount(L : Plua_State) : LongInt;
|
|
895 |
begin
|
|
896 |
lua_getgccount := lua_gc(L, LUA_GCCOUNT, 0);
|
|
897 |
end;
|
|
898 |
|
|
899 |
|
|
900 |
(*****************************************************************************)
|
|
901 |
(* lualib.h *)
|
|
902 |
(*****************************************************************************)
|
|
903 |
|
|
904 |
procedure lua_assert(x : Boolean);
|
|
905 |
begin
|
|
906 |
end;
|
|
907 |
|
|
908 |
|
|
909 |
(*****************************************************************************)
|
|
910 |
(* lauxlib.h n *)
|
|
911 |
(*****************************************************************************)
|
|
912 |
|
|
913 |
function luaL_getn(L : Plua_State; idx : LongInt) : LongInt;
|
|
914 |
begin
|
|
915 |
luaL_getn := lua_objlen(L, idx);
|
|
916 |
end;
|
|
917 |
|
|
918 |
procedure luaL_setn(L : plua_State; i, j : LongInt);
|
|
919 |
begin
|
|
920 |
(* no op *)
|
|
921 |
end;
|
|
922 |
|
|
923 |
function luaL_argcheck(L : Plua_State; cond : Boolean; numarg : LongInt;
|
|
924 |
extramsg : PChar): LongInt;
|
|
925 |
begin
|
|
926 |
if not cond then
|
|
927 |
luaL_argcheck := luaL_argerror(L, numarg, extramsg)
|
|
928 |
else
|
|
929 |
luaL_argcheck := 0;
|
|
930 |
end;
|
|
931 |
|
|
932 |
function luaL_checkstring(L : Plua_State; n : LongInt) : PChar;
|
|
933 |
begin
|
|
934 |
luaL_checkstring := luaL_checklstring(L, n, nil);
|
|
935 |
end;
|
|
936 |
|
|
937 |
function luaL_optstring(L : Plua_State; n : LongInt; d : PChar) : PChar;
|
|
938 |
begin
|
|
939 |
luaL_optstring := luaL_optlstring(L, n, d, nil);
|
|
940 |
end;
|
|
941 |
|
|
942 |
function luaL_checkint(L : Plua_State; n : LongInt) : LongInt;
|
|
943 |
begin
|
|
944 |
luaL_checkint := luaL_checkinteger(L, n);
|
|
945 |
end;
|
|
946 |
|
|
947 |
function luaL_optint(L : Plua_State; n, d : LongInt): LongInt;
|
|
948 |
begin
|
|
949 |
luaL_optint := luaL_optinteger(L, n, d);
|
|
950 |
end;
|
|
951 |
|
|
952 |
function luaL_checklong(L : Plua_State; n : LongInt) : LongInt;
|
|
953 |
begin
|
|
954 |
luaL_checklong := luaL_checkinteger(L, n);
|
|
955 |
end;
|
|
956 |
|
|
957 |
function luaL_optlong(L : Plua_State; n : LongInt; d : LongInt) : LongInt;
|
|
958 |
begin
|
|
959 |
luaL_optlong := luaL_optinteger(L, n, d);
|
|
960 |
end;
|
|
961 |
|
|
962 |
function luaL_typename(L : Plua_State; idx : LongInt) : PChar;
|
|
963 |
begin
|
|
964 |
luaL_typename := lua_typename( L, lua_type(L, idx) );
|
|
965 |
end;
|
|
966 |
|
|
967 |
function luaL_dofile(L : Plua_State; fn : PChar) : LongInt;
|
|
968 |
begin
|
|
969 |
luaL_dofile := luaL_loadfile(L, fn);
|
|
970 |
if luaL_dofile = 0 then
|
|
971 |
luaL_dofile := lua_pcall(L, 0, 0, 0);
|
|
972 |
end;
|
|
973 |
|
|
974 |
function luaL_dostring(L : Plua_State; s : PChar) : LongInt;
|
|
975 |
begin
|
|
976 |
luaL_dostring := luaL_loadstring(L, s);
|
|
977 |
if luaL_dostring = 0 then
|
|
978 |
luaL_dostring := lua_pcall(L, 0, 0, 0);
|
|
979 |
end;
|
|
980 |
|
|
981 |
procedure luaL_getmetatable(L : Plua_State; n : PChar);
|
|
982 |
begin
|
|
983 |
lua_getfield(L, LUA_REGISTRYINDEX, n);
|
|
984 |
end;
|
|
985 |
|
|
986 |
procedure luaL_addchar(B : PluaL_Buffer; c : Char);
|
|
987 |
begin
|
|
988 |
if not(B^.p < B^.buffer + LUAL_BUFFERSIZE) then
|
|
989 |
luaL_prepbuffer(B);
|
|
990 |
B^.p^ := c;
|
|
991 |
Inc(B^.p);
|
|
992 |
end;
|
|
993 |
|
|
994 |
procedure luaL_putchar(B : PluaL_Buffer; c : Char);
|
|
995 |
begin
|
|
996 |
luaL_addchar(B, c);
|
|
997 |
end;
|
|
998 |
|
|
999 |
procedure luaL_addsize(B : PluaL_Buffer; n : LongInt);
|
|
1000 |
begin
|
|
1001 |
Inc(B^.p, n);
|
|
1002 |
end;
|
|
1003 |
|
|
1004 |
function lua_ref(L : Plua_State; lock : Boolean) : LongInt;
|
|
1005 |
begin
|
|
1006 |
if lock then
|
|
1007 |
lua_ref := luaL_ref(L, LUA_REGISTRYINDEX)
|
|
1008 |
else begin
|
|
1009 |
lua_pushstring(L, 'unlocked references are obsolete');
|
|
1010 |
lua_error(L);
|
|
1011 |
lua_ref := 0;
|
|
1012 |
end;
|
|
1013 |
end;
|
|
1014 |
|
|
1015 |
procedure lua_unref(L : Plua_State; ref : LongInt);
|
|
1016 |
begin
|
|
1017 |
luaL_unref(L, LUA_REGISTRYINDEX, ref);
|
|
1018 |
end;
|
|
1019 |
|
|
1020 |
procedure lua_getref(L : Plua_State; ref : LongInt);
|
|
1021 |
begin
|
|
1022 |
lua_rawgeti(L, LUA_REGISTRYINDEX, ref);
|
|
1023 |
end;
|
|
1024 |
|
|
1025 |
|
|
1026 |
(******************************************************************************
|
|
1027 |
* Original copyright for the lua source and headers:
|
|
1028 |
* 1994-2004 Tecgraf, PUC-Rio.
|
|
1029 |
* www.lua.org.
|
|
1030 |
*
|
|
1031 |
*
|
|
1032 |
* Permission is hereby granted, free of charge, to any person obtaining
|
|
1033 |
* a copy of this software and associated documentation files (the
|
|
1034 |
* "Software"), to deal in the Software without restriction, including
|
|
1035 |
* without limitation the rights to use, copy, modify, merge, publish,
|
|
1036 |
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
1037 |
* permit persons to whom the Software is furnished to do so, subject to
|
|
1038 |
* the following conditions:
|
|
1039 |
*
|
|
1040 |
* The above copyright notice and this permission notice shall be
|
|
1041 |
* included in all copies or substantial portions of the Software.
|
|
1042 |
*
|
|
1043 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
1044 |
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
1045 |
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
1046 |
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
1047 |
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
1048 |
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
1049 |
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1050 |
******************************************************************************)
|
|
1051 |
|
|
1052 |
end.
|
|
1053 |
|