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