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