107 ** Lua.org, PUC-Rio, Brazil (http://www.lua.org) |
110 ** Lua.org, PUC-Rio, Brazil (http://www.lua.org) |
108 ** See Copyright Notice at the end of this file |
111 ** See Copyright Notice at the end of this file |
109 *) |
112 *) |
110 |
113 |
111 const |
114 const |
112 LUA_VERSION = 'Lua 5.1'; |
115 LUA_VERSION = 'Lua 5.1'; |
113 LUA_VERSION_NUM = 501; |
116 LUA_VERSION_NUM = 501; |
114 LUA_COPYRIGHT = 'Copyright (C) 1994-2006 Tecgraf, PUC-Rio'; |
117 LUA_COPYRIGHT = 'Copyright (C) 1994-2006 Tecgraf, PUC-Rio'; |
115 LUA_AUTHORS = 'R. Ierusalimschy, L. H. de Figueiredo & W. Celes'; |
118 LUA_AUTHORS = 'R. Ierusalimschy, L. H. de Figueiredo & W. Celes'; |
116 |
119 |
117 (* mark for precompiled code (`<esc>Lua') *) |
120 (* mark for precompiled code (`<esc>Lua') *) |
118 LUA_SIGNATURE = #27 + 'Lua'; |
121 LUA_SIGNATURE = #27 + 'Lua'; |
119 |
122 |
120 (* option for multiple returns in `lua_pcall' and `lua_call' *) |
123 (* option for multiple returns in `lua_pcall' and `lua_call' *) |
121 LUA_MULTRET = -1; |
124 LUA_MULTRET = -1; |
122 |
125 |
123 (* |
126 (* |
124 ** pseudo-indices |
127 ** pseudo-indices |
125 *) |
128 *) |
126 LUA_REGISTRYINDEX = -10000; |
129 LUA_REGISTRYINDEX = -10000; |
127 LUA_ENVIRONINDEX = -10001; |
130 LUA_ENVIRONINDEX = -10001; |
128 LUA_GLOBALSINDEX = -10002; |
131 LUA_GLOBALSINDEX = -10002; |
129 |
132 |
130 function lua_upvalueindex(idx : LongInt) : LongInt; // a marco |
133 function lua_upvalueindex(idx : LongInt) : LongInt; // a marco |
131 |
134 |
132 const |
135 const |
133 (* thread status; 0 is OK *) |
136 (* thread status; 0 is OK *) |
134 LUA_YIELD_ = 1; // Note: the ending underscore is needed in Pascal |
137 LUA_YIELD_ = 1; // Note: the ending underscore is needed in Pascal |
135 LUA_ERRRUN = 2; |
138 LUA_ERRRUN = 2; |
136 LUA_ERRSYNTAX = 3; |
139 LUA_ERRSYNTAX = 3; |
137 LUA_ERRMEM = 4; |
140 LUA_ERRMEM = 4; |
138 LUA_ERRERR = 5; |
141 LUA_ERRERR = 5; |
139 |
142 |
140 type |
143 type |
141 lua_CFunction = function(L : Plua_State) : LongInt; cdecl; |
144 lua_CFunction = function(L : Plua_State) : LongInt; cdecl; |
142 |
145 |
143 (* |
146 (* |
144 ** functions that read/write blocks when loading/dumping Lua chunks |
147 ** functions that read/write blocks when loading/dumping Lua chunks |
145 *) |
148 *) |
146 lua_Reader = function (L : Plua_State; ud : Pointer; |
149 lua_Reader = function (L : Plua_State; ud : Pointer; sz : Psize_t) : PChar; cdecl; |
147 sz : Psize_t) : PChar; cdecl; |
150 lua_Writer = function (L : Plua_State; const p : Pointer; sz : size_t; ud : Pointer) : LongInt; cdecl; |
148 lua_Writer = function (L : Plua_State; const p : Pointer; sz : size_t; |
|
149 ud : Pointer) : LongInt; cdecl; |
|
150 |
151 |
151 (* |
152 (* |
152 ** prototype for memory-allocation functions |
153 ** prototype for memory-allocation functions |
153 *) |
154 *) |
154 lua_Alloc = function (ud, ptr : Pointer; |
155 lua_Alloc = function (ud, ptr : Pointer; osize, nsize : size_t) : Pointer; cdecl; |
155 osize, nsize : size_t) : Pointer; cdecl; |
156 |
156 |
157 const |
157 const |
158 (* |
158 (* |
159 ** basic types |
159 ** basic types |
160 *) |
160 *) |
161 LUA_TNONE = -1; |
161 LUA_TNONE = -1; |
162 LUA_TNIL = 0; |
162 |
163 LUA_TBOOLEAN = 1; |
163 LUA_TNIL = 0; |
164 LUA_TLIGHTUSERDATA = 2; |
164 LUA_TBOOLEAN = 1; |
165 LUA_TNUMBER = 3; |
165 LUA_TLIGHTUSERDATA = 2; |
166 LUA_TSTRING = 4; |
166 LUA_TNUMBER = 3; |
167 LUA_TTABLE = 5; |
167 LUA_TSTRING = 4; |
168 LUA_TFUNCTION = 6; |
168 LUA_TTABLE = 5; |
169 LUA_TUSERDATA = 7; |
169 LUA_TFUNCTION = 6; |
170 LUA_TTHREAD = 8; |
170 LUA_TUSERDATA = 7; |
171 |
171 LUA_TTHREAD = 8; |
172 (* minimum Lua stack available to a C function *) |
172 |
173 LUA_MINSTACK = 20; |
173 (* minimum Lua stack available to a C function *) |
|
174 LUA_MINSTACK = 20; |
|
175 |
174 |
176 type |
175 type |
177 (* type of numbers in Lua *) |
176 (* type of numbers in Lua *) |
178 lua_Number = LUA_NUMBER_; |
177 lua_Number = LUA_NUMBER_; |
179 |
178 |
180 (* type for integer functions *) |
179 (* type for integer functions *) |
181 lua_Integer = LUA_INTEGER_; |
180 lua_Integer = LUA_INTEGER_; |
182 |
181 |
183 (* |
182 (* |
184 ** state manipulation |
183 ** state manipulation |
185 *) |
184 *) |
186 function lua_newstate(f : lua_Alloc; ud : Pointer) : Plua_State; |
185 function lua_newstate(f : lua_Alloc; ud : Pointer) : Plua_State; |
187 cdecl; external LuaLibName; |
186 cdecl; external LuaLibName; |
|
187 |
188 procedure lua_close(L: Plua_State); |
188 procedure lua_close(L: Plua_State); |
189 cdecl; external LuaLibName; |
189 cdecl; external LuaLibName; |
190 function lua_newthread(L : Plua_State) : Plua_State; |
190 function lua_newthread(L : Plua_State) : Plua_State; |
191 cdecl; external LuaLibName; |
191 cdecl; external LuaLibName; |
192 |
192 |
193 function lua_atpanic(L : Plua_State; panicf : lua_CFunction) : lua_CFunction; |
193 function lua_atpanic(L : Plua_State; panicf : lua_CFunction) : lua_CFunction; |
194 cdecl; external LuaLibName; |
194 cdecl; external LuaLibName; |
195 |
195 |
196 |
196 |
197 (* |
197 (* |
198 ** basic stack manipulation |
198 ** basic stack manipulation |
199 *) |
199 *) |
200 function lua_gettop(L : Plua_State) : LongInt; |
200 function lua_gettop(L : Plua_State) : LongInt; |
201 cdecl; external LuaLibName; |
201 cdecl; external LuaLibName; |
|
202 |
202 procedure lua_settop(L : Plua_State; idx : LongInt); |
203 procedure lua_settop(L : Plua_State; idx : LongInt); |
203 cdecl; external LuaLibName; |
204 cdecl; external LuaLibName; |
|
205 |
204 procedure lua_pushvalue(L : Plua_State; idx : LongInt); |
206 procedure lua_pushvalue(L : Plua_State; idx : LongInt); |
205 cdecl; external LuaLibName; |
207 cdecl; external LuaLibName; |
|
208 |
206 procedure lua_remove(L : Plua_State; idx : LongInt); |
209 procedure lua_remove(L : Plua_State; idx : LongInt); |
207 cdecl; external LuaLibName; |
210 cdecl; external LuaLibName; |
|
211 |
208 procedure lua_insert(L : Plua_State; idx : LongInt); |
212 procedure lua_insert(L : Plua_State; idx : LongInt); |
209 cdecl; external LuaLibName; |
213 cdecl; external LuaLibName; |
|
214 |
210 procedure lua_replace(L : Plua_State; idx : LongInt); |
215 procedure lua_replace(L : Plua_State; idx : LongInt); |
211 cdecl; external LuaLibName; |
216 cdecl; external LuaLibName; |
|
217 |
212 function lua_checkstack(L : Plua_State; sz : LongInt) : LongBool; |
218 function lua_checkstack(L : Plua_State; sz : LongInt) : LongBool; |
213 cdecl; external LuaLibName; |
219 cdecl; external LuaLibName; |
214 |
220 |
215 procedure lua_xmove(src, dest : Plua_State; n : LongInt); |
221 procedure lua_xmove(src, dest : Plua_State; n : LongInt); |
216 cdecl; external LuaLibName; |
222 cdecl; external LuaLibName; |
217 |
223 |
218 |
224 |
219 (* |
225 (* |
220 ** access functions (stack -> C) |
226 ** access functions (stack -> C) |
221 *) |
227 *) |
222 function lua_isnumber(L : Plua_State; idx : LongInt) : LongBool; |
228 function lua_isnumber(L : Plua_State; idx : LongInt) : LongBool; |
223 cdecl; external LuaLibName; |
229 cdecl; external LuaLibName; |
|
230 |
224 function lua_isstring(L : Plua_State; idx : LongInt) : LongBool; |
231 function lua_isstring(L : Plua_State; idx : LongInt) : LongBool; |
225 cdecl; external LuaLibName; |
232 cdecl; external LuaLibName; |
|
233 |
226 function lua_iscfunction(L : Plua_State; idx : LongInt) : LongBool; |
234 function lua_iscfunction(L : Plua_State; idx : LongInt) : LongBool; |
227 cdecl; external LuaLibName; |
235 cdecl; external LuaLibName; |
|
236 |
228 function lua_isuserdata(L : Plua_State; idx : LongInt) : LongBool; |
237 function lua_isuserdata(L : Plua_State; idx : LongInt) : LongBool; |
229 cdecl; external LuaLibName; |
238 cdecl; external LuaLibName; |
|
239 |
230 function lua_type(L : Plua_State; idx : LongInt) : LongInt; |
240 function lua_type(L : Plua_State; idx : LongInt) : LongInt; |
231 cdecl; external LuaLibName; |
241 cdecl; external LuaLibName; |
|
242 |
232 function lua_typename(L : Plua_State; tp : LongInt) : PChar; |
243 function lua_typename(L : Plua_State; tp : LongInt) : PChar; |
233 cdecl; external LuaLibName; |
244 cdecl; external LuaLibName; |
234 |
245 |
|
246 |
235 function lua_equal(L : Plua_State; idx1, idx2 : LongInt) : LongBool; |
247 function lua_equal(L : Plua_State; idx1, idx2 : LongInt) : LongBool; |
236 cdecl; external LuaLibName; |
248 cdecl; external LuaLibName; |
|
249 |
237 function lua_rawequal(L : Plua_State; idx1, idx2 : LongInt) : LongBool; |
250 function lua_rawequal(L : Plua_State; idx1, idx2 : LongInt) : LongBool; |
238 cdecl; external LuaLibName; |
251 cdecl; external LuaLibName; |
|
252 |
239 function lua_lessthan(L : Plua_State; idx1, idx2 : LongInt) : LongBool; |
253 function lua_lessthan(L : Plua_State; idx1, idx2 : LongInt) : LongBool; |
240 cdecl; external LuaLibName; |
254 cdecl; external LuaLibName; |
241 |
255 |
242 function lua_tonumber(L : Plua_State; idx : LongInt) : lua_Number; |
256 function lua_tonumber(L : Plua_State; idx : LongInt) : lua_Number; |
243 cdecl; external LuaLibName; |
257 cdecl; external LuaLibName; |
|
258 |
244 function lua_tointeger(L : Plua_State; idx : LongInt) : lua_Integer; |
259 function lua_tointeger(L : Plua_State; idx : LongInt) : lua_Integer; |
245 cdecl; external LuaLibName; |
260 cdecl; external LuaLibName; |
|
261 |
246 function lua_toboolean(L : Plua_State; idx : LongInt) : LongBool; |
262 function lua_toboolean(L : Plua_State; idx : LongInt) : LongBool; |
247 cdecl; external LuaLibName; |
263 cdecl; external LuaLibName; |
248 function lua_tolstring(L : Plua_State; idx : LongInt; |
264 |
249 len : Psize_t) : PChar; |
265 |
250 cdecl; external LuaLibName; |
266 function lua_tolstring(L : Plua_State; idx : LongInt; len : Psize_t) : PChar; |
|
267 cdecl; external LuaLibName; |
|
268 |
251 function lua_objlen(L : Plua_State; idx : LongInt) : size_t; |
269 function lua_objlen(L : Plua_State; idx : LongInt) : size_t; |
252 cdecl; external LuaLibName; |
270 cdecl; external LuaLibName; |
|
271 |
253 function lua_tocfunction(L : Plua_State; idx : LongInt) : lua_CFunction; |
272 function lua_tocfunction(L : Plua_State; idx : LongInt) : lua_CFunction; |
254 cdecl; external LuaLibName; |
273 cdecl; external LuaLibName; |
|
274 |
255 function lua_touserdata(L : Plua_State; idx : LongInt) : Pointer; |
275 function lua_touserdata(L : Plua_State; idx : LongInt) : Pointer; |
256 cdecl; external LuaLibName; |
276 cdecl; external LuaLibName; |
|
277 |
257 function lua_tothread(L : Plua_State; idx : LongInt) : Plua_State; |
278 function lua_tothread(L : Plua_State; idx : LongInt) : Plua_State; |
258 cdecl; external LuaLibName; |
279 cdecl; external LuaLibName; |
|
280 |
259 function lua_topointer(L : Plua_State; idx : LongInt) : Pointer; |
281 function lua_topointer(L : Plua_State; idx : LongInt) : Pointer; |
260 cdecl; external LuaLibName; |
282 cdecl; external LuaLibName; |
261 |
283 |
262 |
284 |
263 (* |
285 (* |
264 ** push functions (C -> stack) |
286 ** push functions (C -> stack) |
265 *) |
287 *) |
266 procedure lua_pushnil(L : Plua_State); |
288 procedure lua_pushnil(L : Plua_State); |
267 cdecl; external LuaLibName; |
289 cdecl; external LuaLibName; |
|
290 |
268 procedure lua_pushnumber(L : Plua_State; n : lua_Number); |
291 procedure lua_pushnumber(L : Plua_State; n : lua_Number); |
269 cdecl; external LuaLibName; |
292 cdecl; external LuaLibName; |
|
293 |
270 procedure lua_pushinteger(L : Plua_State; n : lua_Integer); |
294 procedure lua_pushinteger(L : Plua_State; n : lua_Integer); |
271 cdecl; external LuaLibName; |
295 cdecl; external LuaLibName; |
|
296 |
272 procedure lua_pushlstring(L : Plua_State; const s : PChar; ls : size_t); |
297 procedure lua_pushlstring(L : Plua_State; const s : PChar; ls : size_t); |
273 cdecl; external LuaLibName; |
298 cdecl; external LuaLibName; |
|
299 |
274 procedure lua_pushstring(L : Plua_State; const s : PChar); |
300 procedure lua_pushstring(L : Plua_State; const s : PChar); |
275 cdecl; external LuaLibName; |
301 cdecl; external LuaLibName; |
|
302 |
|
303 |
276 function lua_pushvfstring(L : Plua_State; |
304 function lua_pushvfstring(L : Plua_State; |
277 const fmt : PChar; argp : Pointer) : PChar; |
305 const fmt : PChar; argp : Pointer) : PChar; |
278 cdecl; external LuaLibName; |
306 cdecl; external LuaLibName; |
|
307 |
279 function lua_pushfstring(L : Plua_State; const fmt : PChar) : PChar; varargs; |
308 function lua_pushfstring(L : Plua_State; const fmt : PChar) : PChar; varargs; |
280 cdecl; external LuaLibName; |
309 cdecl; external LuaLibName; |
|
310 |
281 procedure lua_pushcclosure(L : Plua_State; fn : lua_CFunction; n : LongInt); |
311 procedure lua_pushcclosure(L : Plua_State; fn : lua_CFunction; n : LongInt); |
282 cdecl; external LuaLibName; |
312 cdecl; external LuaLibName; |
|
313 |
283 procedure lua_pushboolean(L : Plua_State; b : LongBool); |
314 procedure lua_pushboolean(L : Plua_State; b : LongBool); |
284 cdecl; external LuaLibName; |
315 cdecl; external LuaLibName; |
|
316 |
285 procedure lua_pushlightuserdata(L : Plua_State; p : Pointer); |
317 procedure lua_pushlightuserdata(L : Plua_State; p : Pointer); |
286 cdecl; external LuaLibName; |
318 cdecl; external LuaLibName; |
|
319 |
287 function lua_pushthread(L : Plua_state) : Cardinal; |
320 function lua_pushthread(L : Plua_state) : Cardinal; |
288 cdecl; external LuaLibName; |
321 cdecl; external LuaLibName; |
289 |
322 |
290 |
323 |
291 (* |
324 (* |
292 ** get functions (Lua -> stack) |
325 ** get functions (Lua -> stack) |
293 *) |
326 *) |
294 procedure lua_gettable(L : Plua_State ; idx : LongInt); |
327 procedure lua_gettable(L : Plua_State ; idx : LongInt); |
295 cdecl; external LuaLibName; |
328 cdecl; external LuaLibName; |
|
329 |
296 procedure lua_getfield(L : Plua_State; idx : LongInt; k : PChar); |
330 procedure lua_getfield(L : Plua_State; idx : LongInt; k : PChar); |
297 cdecl; external LuaLibName; |
331 cdecl; external LuaLibName; |
|
332 |
298 procedure lua_rawget(L : Plua_State; idx : LongInt); |
333 procedure lua_rawget(L : Plua_State; idx : LongInt); |
299 cdecl; external LuaLibName; |
334 cdecl; external LuaLibName; |
|
335 |
300 procedure lua_rawgeti(L : Plua_State; idx, n : LongInt); |
336 procedure lua_rawgeti(L : Plua_State; idx, n : LongInt); |
301 cdecl; external LuaLibName; |
337 cdecl; external LuaLibName; |
|
338 |
302 procedure lua_createtable(L : Plua_State; narr, nrec : LongInt); |
339 procedure lua_createtable(L : Plua_State; narr, nrec : LongInt); |
303 cdecl; external LuaLibName; |
340 cdecl; external LuaLibName; |
|
341 |
304 function lua_newuserdata(L : Plua_State; sz : size_t) : Pointer; |
342 function lua_newuserdata(L : Plua_State; sz : size_t) : Pointer; |
305 cdecl; external LuaLibName; |
343 cdecl; external LuaLibName; |
|
344 |
306 function lua_getmetatable(L : Plua_State; objindex : LongInt) : LongBool; |
345 function lua_getmetatable(L : Plua_State; objindex : LongInt) : LongBool; |
307 cdecl; external LuaLibName; |
346 cdecl; external LuaLibName; |
|
347 |
308 procedure lua_getfenv(L : Plua_State; idx : LongInt); |
348 procedure lua_getfenv(L : Plua_State; idx : LongInt); |
309 cdecl; external LuaLibName; |
349 cdecl; external LuaLibName; |
310 |
350 |
311 |
351 |
312 (* |
352 (* |
313 ** set functions (stack -> Lua) |
353 ** set functions (stack -> Lua) |
314 *) |
354 *) |
315 procedure lua_settable(L : Plua_State; idx : LongInt); |
355 procedure lua_settable(L : Plua_State; idx : LongInt); |
316 cdecl; external LuaLibName; |
356 cdecl; external LuaLibName; |
|
357 |
317 procedure lua_setfield(L : Plua_State; idx : LongInt; const k : PChar); |
358 procedure lua_setfield(L : Plua_State; idx : LongInt; const k : PChar); |
318 cdecl; external LuaLibName; |
359 cdecl; external LuaLibName; |
|
360 |
319 procedure lua_rawset(L : Plua_State; idx : LongInt); |
361 procedure lua_rawset(L : Plua_State; idx : LongInt); |
320 cdecl; external LuaLibName; |
362 cdecl; external LuaLibName; |
|
363 |
321 procedure lua_rawseti(L : Plua_State; idx , n: LongInt); |
364 procedure lua_rawseti(L : Plua_State; idx , n: LongInt); |
322 cdecl; external LuaLibName; |
365 cdecl; external LuaLibName; |
|
366 |
323 function lua_setmetatable(L : Plua_State; objindex : LongInt): LongBool; |
367 function lua_setmetatable(L : Plua_State; objindex : LongInt): LongBool; |
324 cdecl; external LuaLibName; |
368 cdecl; external LuaLibName; |
|
369 |
325 function lua_setfenv(L : Plua_State; idx : LongInt): LongBool; |
370 function lua_setfenv(L : Plua_State; idx : LongInt): LongBool; |
326 cdecl; external LuaLibName; |
371 cdecl; external LuaLibName; |
327 |
372 |
328 (* |
373 (* |
329 ** `load' and `call' functions (load and run Lua code) |
374 ** `load' and `call' functions (load and run Lua code) |
330 *) |
375 *) |
331 procedure lua_call(L : Plua_State; nargs, nresults : LongInt); |
376 procedure lua_call(L : Plua_State; nargs, nresults : LongInt); |
332 cdecl; external LuaLibName; |
377 cdecl; external LuaLibName; |
333 function lua_pcall(L : Plua_State; |
378 |
334 nargs, nresults, errfunc : LongInt) : LongInt; |
379 function lua_pcall(L : Plua_State; nargs, nresults, errfunc : LongInt) : LongInt; |
335 cdecl; external LuaLibName; |
380 cdecl; external LuaLibName; |
336 function lua_cpcall(L : Plua_State; |
381 |
337 func : lua_CFunction; ud : Pointer) : LongInt; |
382 function lua_cpcall(L : Plua_State; func : lua_CFunction; ud : Pointer) : LongInt; |
338 cdecl; external LuaLibName; |
383 cdecl; external LuaLibName; |
339 function lua_load(L : Plua_State; reader : lua_Reader; |
384 |
340 dt : Pointer; const chunkname : PChar) : LongInt; |
385 function lua_load(L : Plua_State; reader : lua_Reader; dt : Pointer; const chunkname : PChar) : LongInt; |
341 cdecl; external LuaLibName; |
386 cdecl; external LuaLibName; |
|
387 |
342 |
388 |
343 function lua_dump(L : Plua_State; writer : lua_Writer; data: Pointer) : LongInt; |
389 function lua_dump(L : Plua_State; writer : lua_Writer; data: Pointer) : LongInt; |
344 cdecl; external LuaLibName; |
390 cdecl; external LuaLibName; |
345 |
391 |
346 |
392 |
347 (* |
393 (* |
348 ** coroutine functions |
394 ** coroutine functions |
349 *) |
395 *) |
350 function lua_yield(L : Plua_State; nresults : LongInt) : LongInt; |
396 function lua_yield(L : Plua_State; nresults : LongInt) : LongInt; |
351 cdecl; external LuaLibName; |
397 cdecl; external LuaLibName; |
|
398 |
352 function lua_resume(L : Plua_State; narg : LongInt) : LongInt; |
399 function lua_resume(L : Plua_State; narg : LongInt) : LongInt; |
353 cdecl; external LuaLibName; |
400 cdecl; external LuaLibName; |
|
401 |
354 function lua_status(L : Plua_State) : LongInt; |
402 function lua_status(L : Plua_State) : LongInt; |
355 cdecl; external LuaLibName; |
403 cdecl; external LuaLibName; |
356 |
404 |
357 (* |
405 (* |
358 ** garbage-collection functions and options |
406 ** garbage-collection functions and options |
359 *) |
407 *) |
360 const |
408 const |
361 LUA_GCSTOP = 0; |
409 LUA_GCSTOP = 0; |
362 LUA_GCRESTART = 1; |
410 LUA_GCRESTART = 1; |
363 LUA_GCCOLLECT = 2; |
411 LUA_GCCOLLECT = 2; |
364 LUA_GCCOUNT = 3; |
412 LUA_GCCOUNT = 3; |
365 LUA_GCCOUNTB = 4; |
413 LUA_GCCOUNTB = 4; |
366 LUA_GCSTEP = 5; |
414 LUA_GCSTEP = 5; |
367 LUA_GCSETPAUSE = 6; |
415 LUA_GCSETPAUSE = 6; |
368 LUA_GCSETSTEPMUL = 7; |
416 LUA_GCSETSTEPMUL = 7; |
369 |
417 |
370 function lua_gc(L : Plua_State; what, data : LongInt) : LongInt; |
418 function lua_gc(L : Plua_State; what, data : LongInt) : LongInt; |
371 cdecl; external LuaLibName; |
419 cdecl; external LuaLibName; |
372 |
420 |
373 (* |
421 (* |
374 ** miscellaneous functions |
422 ** miscellaneous functions |
375 *) |
423 *) |
376 function lua_error(L : Plua_State) : LongInt; |
424 function lua_error(L : Plua_State) : LongInt; |
377 cdecl; external LuaLibName; |
425 cdecl; external LuaLibName; |
378 |
426 |
379 function lua_next(L : Plua_State; idx : LongInt) : LongInt; |
427 function lua_next(L : Plua_State; idx : LongInt) : LongInt; |
380 cdecl; external LuaLibName; |
428 cdecl; external LuaLibName; |
381 |
429 |
382 procedure lua_concat(L : Plua_State; n : LongInt); |
430 procedure lua_concat(L : Plua_State; n : LongInt); |
383 cdecl; external LuaLibName; |
431 cdecl; external LuaLibName; |
384 |
432 |
385 function lua_getallocf(L : Plua_State; ud : PPointer) : lua_Alloc; |
433 function lua_getallocf(L : Plua_State; ud : PPointer) : lua_Alloc; |
386 cdecl; external LuaLibName; |
434 cdecl; external LuaLibName; |
|
435 |
387 procedure lua_setallocf(L : Plua_State; f : lua_Alloc; ud : Pointer); |
436 procedure lua_setallocf(L : Plua_State; f : lua_Alloc; ud : Pointer); |
388 cdecl; external LuaLibName; |
437 cdecl; external LuaLibName; |
389 |
438 |
390 (* |
439 (* |
391 ** =============================================================== |
440 ** =============================================================== |
392 ** some useful macros |
441 ** some useful macros |
393 ** =============================================================== |
442 ** =============================================================== |
576 // not compatibility with the behavior of setn/getn in Lua 5.0 |
627 // not compatibility with the behavior of setn/getn in Lua 5.0 |
577 function luaL_getn(L : Plua_State; idx : LongInt) : LongInt; |
628 function luaL_getn(L : Plua_State; idx : LongInt) : LongInt; |
578 procedure luaL_setn(L : Plua_State; i, j : LongInt); |
629 procedure luaL_setn(L : Plua_State; i, j : LongInt); |
579 |
630 |
580 const |
631 const |
581 LUA_ERRFILE = LUA_ERRERR + 1; |
632 LUA_ERRFILE = LUA_ERRERR + 1; |
582 |
633 |
583 type |
634 type |
584 luaL_Reg = packed record |
635 luaL_Reg = packed record |
585 name : PChar; |
636 name : PChar; |
586 func : lua_CFunction; |
637 func : lua_CFunction; |
587 end; |
638 end; |
588 PluaL_Reg = ^luaL_Reg; |
639 PluaL_Reg = ^luaL_Reg; |
589 |
640 |
590 |
641 |
591 procedure luaL_openlib(L : Plua_State; const libname : PChar; |
642 procedure luaL_openlib(L : Plua_State; const libname : PChar; const lr : PluaL_Reg; nup : LongInt); |
592 const lr : PluaL_Reg; nup : LongInt); |
643 cdecl; external LuaLibName; |
593 cdecl; external LuaLibName; |
644 procedure luaL_register(L : Plua_State; const libname : PChar; const lr : PluaL_Reg); |
594 procedure luaL_register(L : Plua_State; const libname : PChar; |
645 cdecl; external LuaLibName; |
595 const lr : PluaL_Reg); |
646 function luaL_getmetafield(L : Plua_State; obj : LongInt; const e : PChar) : LongInt; |
596 cdecl; external LuaLibName; |
647 cdecl; external LuaLibName; |
597 function luaL_getmetafield(L : Plua_State; obj : LongInt; |
648 function luaL_callmeta(L : Plua_State; obj : LongInt; const e : PChar) : LongInt; |
598 const e : PChar) : LongInt; |
649 cdecl; external LuaLibName; |
599 cdecl; external LuaLibName; |
650 function luaL_typerror(L : Plua_State; narg : LongInt; const tname : PChar) : LongInt; |
600 function luaL_callmeta(L : Plua_State; obj : LongInt; |
651 cdecl; external LuaLibName; |
601 const e : PChar) : LongInt; |
652 function luaL_argerror(L : Plua_State; numarg : LongInt; const extramsg : PChar) : LongInt; |
602 cdecl; external LuaLibName; |
653 cdecl; external LuaLibName; |
603 function luaL_typerror(L : Plua_State; narg : LongInt; |
654 function luaL_checklstring(L : Plua_State; numArg : LongInt; ls : Psize_t) : PChar; |
604 const tname : PChar) : LongInt; |
655 cdecl; external LuaLibName; |
605 cdecl; external LuaLibName; |
656 function luaL_optlstring(L : Plua_State; numArg : LongInt; const def: PChar; ls: Psize_t) : PChar; |
606 function luaL_argerror(L : Plua_State; numarg : LongInt; |
657 cdecl; external LuaLibName; |
607 const extramsg : PChar) : LongInt; |
|
608 cdecl; external LuaLibName; |
|
609 function luaL_checklstring(L : Plua_State; numArg : LongInt; |
|
610 ls : Psize_t) : PChar; |
|
611 cdecl; external LuaLibName; |
|
612 function luaL_optlstring(L : Plua_State; numArg : LongInt; |
|
613 const def: PChar; ls: Psize_t) : PChar; |
|
614 cdecl; external LuaLibName; |
|
615 function luaL_checknumber(L : Plua_State; numArg : LongInt) : lua_Number; |
658 function luaL_checknumber(L : Plua_State; numArg : LongInt) : lua_Number; |
616 cdecl; external LuaLibName; |
659 cdecl; external LuaLibName; |
617 function luaL_optnumber(L : Plua_State; nArg : LongInt; |
660 function luaL_optnumber(L : Plua_State; nArg : LongInt; def : lua_Number) : lua_Number; |
618 def : lua_Number) : lua_Number; |
661 cdecl; external LuaLibName; |
619 cdecl; external LuaLibName; |
|
620 |
662 |
621 function luaL_checkinteger(L : Plua_State; numArg : LongInt) : lua_Integer; |
663 function luaL_checkinteger(L : Plua_State; numArg : LongInt) : lua_Integer; |
622 cdecl; external LuaLibName; |
664 cdecl; external LuaLibName; |
623 function luaL_optinteger(L : Plua_State; nArg : LongInt; |
665 function luaL_optinteger(L : Plua_State; nArg : LongInt; def : lua_Integer) : lua_Integer; |
624 def : lua_Integer) : lua_Integer; |
666 cdecl; external LuaLibName; |
625 cdecl; external LuaLibName; |
|
626 |
667 |
627 procedure luaL_checkstack(L : Plua_State; sz : LongInt; const msg : PChar); |
668 procedure luaL_checkstack(L : Plua_State; sz : LongInt; const msg : PChar); |
628 cdecl; external LuaLibName; |
669 cdecl; external LuaLibName; |
629 procedure luaL_checktype(L : Plua_State; narg, t : LongInt); |
670 procedure luaL_checktype(L : Plua_State; narg, t : LongInt); |
630 cdecl; external LuaLibName; |
671 cdecl; external LuaLibName; |
631 procedure luaL_checkany(L : Plua_State; narg : LongInt); |
672 procedure luaL_checkany(L : Plua_State; narg : LongInt); |
632 cdecl; external LuaLibName; |
673 cdecl; external LuaLibName; |
633 |
674 |
634 function luaL_newmetatable(L : Plua_State; const tname : PChar) : LongInt; |
675 function luaL_newmetatable(L : Plua_State; const tname : PChar) : LongInt; |
635 cdecl; external LuaLibName; |
676 cdecl; external LuaLibName; |
636 function luaL_checkudata(L : Plua_State; ud : LongInt; |
677 function luaL_checkudata(L : Plua_State; ud : LongInt; const tname : PChar) : Pointer; |
637 const tname : PChar) : Pointer; |
678 cdecl; external LuaLibName; |
638 cdecl; external LuaLibName; |
|
639 |
679 |
640 procedure luaL_where(L : Plua_State; lvl : LongInt); |
680 procedure luaL_where(L : Plua_State; lvl : LongInt); |
641 cdecl; external LuaLibName; |
681 cdecl; external LuaLibName; |
642 function luaL_error(L : Plua_State; const fmt : PChar) : LongInt; varargs; |
682 function luaL_error(L : Plua_State; const fmt : PChar) : LongInt; varargs; |
643 cdecl; external LuaLibName; |
683 cdecl; external LuaLibName; |
644 |
684 |
645 function luaL_checkoption(L : Plua_State; narg : LongInt; const def : PChar; |
685 function luaL_checkoption(L : Plua_State; narg : LongInt; const def : PChar; const lst : array of PChar) : LongInt; |
646 const lst : array of PChar) : LongInt; |
686 cdecl; external LuaLibName; |
647 cdecl; external LuaLibName; |
|
648 |
687 |
649 function luaL_ref(L : Plua_State; t : LongInt) : LongInt; |
688 function luaL_ref(L : Plua_State; t : LongInt) : LongInt; |
650 cdecl; external LuaLibName; |
689 cdecl; external LuaLibName; |
651 procedure luaL_unref(L : Plua_State; t, ref : LongInt); |
690 procedure luaL_unref(L : Plua_State; t, ref : LongInt); |
652 cdecl; external LuaLibName; |
691 cdecl; external LuaLibName; |
653 |
692 |
654 function luaL_loadfile(L : Plua_State; const filename : PChar) : LongInt; |
693 function luaL_loadfile(L : Plua_State; const filename : PChar) : LongInt; |
655 cdecl; external LuaLibName; |
694 cdecl; external LuaLibName; |
656 function luaL_loadbuffer(L : Plua_State; const buff : PChar; |
695 function luaL_loadbuffer(L : Plua_State; const buff : PChar; sz : size_t; const name: PChar) : LongInt; |
657 sz : size_t; const name: PChar) : LongInt; |
696 cdecl; external LuaLibName; |
658 cdecl; external LuaLibName; |
|
659 |
697 |
660 function luaL_loadstring(L : Plua_State; const s : Pchar) : LongInt; |
698 function luaL_loadstring(L : Plua_State; const s : Pchar) : LongInt; |
661 cdecl; external LuaLibName; |
699 cdecl; external LuaLibName; |
662 |
700 |
663 function luaL_newstate : Plua_State; |
701 function luaL_newstate : Plua_State; |
664 cdecl; external LuaLibName; |
702 cdecl; external LuaLibName; |
665 |
703 |
666 function luaL_gsub(L : Plua_State; const s, p, r : PChar) : PChar; |
704 function luaL_gsub(L : Plua_State; const s, p, r : PChar) : PChar; |
667 cdecl; external LuaLibName; |
705 cdecl; external LuaLibName; |
668 |
706 |
669 function luaL_findtable(L : Plua_State; idx : LongInt; |
707 function luaL_findtable(L : Plua_State; idx : LongInt; const fname : PChar; szhint : LongInt) : PChar; |
670 const fname : PChar; szhint : LongInt) : PChar; |
708 cdecl; external LuaLibName; |
671 cdecl; external LuaLibName; |
|
672 |
709 |
673 |
710 |
674 (* |
711 (* |
675 ** =============================================================== |
712 ** =============================================================== |
676 ** some useful macros |
713 ** some useful macros |
677 ** =============================================================== |
714 ** =============================================================== |
678 *) |
715 *) |
679 |
716 |
680 function luaL_argcheck(L : Plua_State; cond : Boolean; numarg : LongInt; |
717 function luaL_argcheck(L : Plua_State; cond : Boolean; numarg : LongInt; extramsg : PChar): LongInt; |
681 extramsg : PChar): LongInt; |
|
682 function luaL_checkstring(L : Plua_State; n : LongInt) : PChar; |
718 function luaL_checkstring(L : Plua_State; n : LongInt) : PChar; |
683 function luaL_optstring(L : Plua_State; n : LongInt; d : PChar) : PChar; |
719 function luaL_optstring(L : Plua_State; n : LongInt; d : PChar) : PChar; |
684 function luaL_checkint(L : Plua_State; n : LongInt) : lua_Integer; |
720 function luaL_checkint(L : Plua_State; n : LongInt) : lua_Integer; |
685 function luaL_optint(L : Plua_State; n : LongInt; d : lua_Integer): lua_Integer; |
721 function luaL_optint(L : Plua_State; n : LongInt; d : lua_Integer): lua_Integer; |
686 function luaL_checklong(L : Plua_State; n : LongInt) : lua_Integer; |
722 function luaL_checklong(L : Plua_State; n : LongInt) : lua_Integer; |
786 (* lua.h *) |
824 (* lua.h *) |
787 (*****************************************************************************) |
825 (*****************************************************************************) |
788 |
826 |
789 function lua_upvalueindex(idx : LongInt) : LongInt; |
827 function lua_upvalueindex(idx : LongInt) : LongInt; |
790 begin |
828 begin |
791 lua_upvalueindex := LUA_GLOBALSINDEX - idx; |
829 lua_upvalueindex := LUA_GLOBALSINDEX - idx; |
792 end; |
830 end; |
793 |
831 |
794 procedure lua_pop(L : Plua_State; n : LongInt); |
832 procedure lua_pop(L : Plua_State; n : LongInt); |
795 begin |
833 begin |
796 lua_settop(L, -n - 1); |
834 lua_settop(L, -n - 1); |
797 end; |
835 end; |
798 |
836 |
799 procedure lua_newtable(L : Plua_State); |
837 procedure lua_newtable(L : Plua_State); |
800 begin |
838 begin |
801 lua_createtable(L, 0, 0); |
839 lua_createtable(L, 0, 0); |
802 end; |
840 end; |
803 |
841 |
804 procedure lua_register(L : Plua_State; n : PChar; f : lua_CFunction); |
842 procedure lua_register(L : Plua_State; n : PChar; f : lua_CFunction); |
805 begin |
843 begin |
806 lua_pushcfunction(L, f); |
844 lua_pushcfunction(L, f); |
807 lua_setglobal(L, n); |
845 lua_setglobal(L, n); |
808 end; |
846 end; |
809 |
847 |
810 procedure lua_pushcfunction(L : Plua_State; f : lua_CFunction); |
848 procedure lua_pushcfunction(L : Plua_State; f : lua_CFunction); |
811 begin |
849 begin |
812 lua_pushcclosure(L, f, 0); |
850 lua_pushcclosure(L, f, 0); |
813 end; |
851 end; |
814 |
852 |
815 function lua_strlen(L : Plua_State; idx : LongInt) : LongInt; |
853 function lua_strlen(L : Plua_State; idx : LongInt) : LongInt; |
816 begin |
854 begin |
817 lua_strlen := lua_objlen(L, idx); |
855 lua_strlen := lua_objlen(L, idx); |
818 end; |
856 end; |
819 |
857 |
820 function lua_isfunction(L : Plua_State; n : LongInt) : Boolean; |
858 function lua_isfunction(L : Plua_State; n : LongInt) : Boolean; |
821 begin |
859 begin |
822 lua_isfunction := lua_type(L, n) = LUA_TFUNCTION; |
860 lua_isfunction := lua_type(L, n) = LUA_TFUNCTION; |
823 end; |
861 end; |
824 |
862 |
825 function lua_istable(L : Plua_State; n : LongInt) : Boolean; |
863 function lua_istable(L : Plua_State; n : LongInt) : Boolean; |
826 begin |
864 begin |
827 lua_istable := lua_type(L, n) = LUA_TTABLE; |
865 lua_istable := lua_type(L, n) = LUA_TTABLE; |
828 end; |
866 end; |
829 |
867 |
830 function lua_islightuserdata(L : Plua_State; n : LongInt) : Boolean; |
868 function lua_islightuserdata(L : Plua_State; n : LongInt) : Boolean; |
831 begin |
869 begin |
832 lua_islightuserdata := lua_type(L, n) = LUA_TLIGHTUSERDATA; |
870 lua_islightuserdata := lua_type(L, n) = LUA_TLIGHTUSERDATA; |
833 end; |
871 end; |
834 |
872 |
835 function lua_isnil(L : Plua_State; n : LongInt) : Boolean; |
873 function lua_isnil(L : Plua_State; n : LongInt) : Boolean; |
836 begin |
874 begin |
837 lua_isnil := lua_type(L, n) = LUA_TNIL; |
875 lua_isnil := lua_type(L, n) = LUA_TNIL; |
838 end; |
876 end; |
839 |
877 |
840 function lua_isboolean(L : Plua_State; n : LongInt) : Boolean; |
878 function lua_isboolean(L : Plua_State; n : LongInt) : Boolean; |
841 begin |
879 begin |
842 lua_isboolean := lua_type(L, n) = LUA_TBOOLEAN; |
880 lua_isboolean := lua_type(L, n) = LUA_TBOOLEAN; |
843 end; |
881 end; |
844 |
882 |
845 function lua_isthread(L : Plua_State; n : LongInt) : Boolean; |
883 function lua_isthread(L : Plua_State; n : LongInt) : Boolean; |
846 begin |
884 begin |
847 lua_isthread := lua_type(L, n) = LUA_TTHREAD; |
885 lua_isthread := lua_type(L, n) = LUA_TTHREAD; |
848 end; |
886 end; |
849 |
887 |
850 function lua_isnone(L : Plua_State; n : LongInt) : Boolean; |
888 function lua_isnone(L : Plua_State; n : LongInt) : Boolean; |
851 begin |
889 begin |
852 lua_isnone := lua_type(L, n) = LUA_TNONE; |
890 lua_isnone := lua_type(L, n) = LUA_TNONE; |
853 end; |
891 end; |
854 |
892 |
855 function lua_isnoneornil(L : Plua_State; n : LongInt) : Boolean; |
893 function lua_isnoneornil(L : Plua_State; n : LongInt) : Boolean; |
856 begin |
894 begin |
857 lua_isnoneornil := lua_type(L, n) <= 0; |
895 lua_isnoneornil := lua_type(L, n) <= 0; |
858 end; |
896 end; |
859 |
897 |
860 procedure lua_pushliteral(L : Plua_State; s : PChar); |
898 procedure lua_pushliteral(L : Plua_State; s : PChar); |
861 begin |
899 begin |
862 lua_pushlstring(L, s, StrLen(s)); |
900 lua_pushlstring(L, s, StrLen(s)); |
863 end; |
901 end; |
864 |
902 |
865 procedure lua_setglobal(L : Plua_State; s : PChar); |
903 procedure lua_setglobal(L : Plua_State; s : PChar); |
866 begin |
904 begin |
867 lua_setfield(L, LUA_GLOBALSINDEX, s); |
905 lua_setfield(L, LUA_GLOBALSINDEX, s); |
868 end; |
906 end; |
869 |
907 |
870 procedure lua_getglobal(L: Plua_State; s: PChar); |
908 procedure lua_getglobal(L: Plua_State; s: PChar); |
871 begin |
909 begin |
872 lua_getfield(L, LUA_GLOBALSINDEX, s); |
910 lua_getfield(L, LUA_GLOBALSINDEX, s); |
873 end; |
911 end; |
874 |
912 |
875 function lua_tostring(L : Plua_State; idx : LongInt) : AnsiString; |
913 function lua_tostring(L : Plua_State; idx : LongInt) : AnsiString; |
876 begin |
914 begin |
877 lua_tostring := SysUtils.StrPas(lua_tolstring(L, idx, nil)); |
915 lua_tostring := SysUtils.StrPas(lua_tolstring(L, idx, nil)); |
878 end; |
916 end; |
879 |
917 |
880 function lua_open : Plua_State; |
918 function lua_open : Plua_State; |
881 begin |
919 begin |
882 lua_open := luaL_newstate; |
920 lua_open := luaL_newstate; |
883 end; |
921 end; |
884 |
922 |
885 procedure lua_getregistry(L : Plua_State); |
923 procedure lua_getregistry(L : Plua_State); |
886 begin |
924 begin |
887 lua_pushvalue(L, LUA_REGISTRYINDEX); |
925 lua_pushvalue(L, LUA_REGISTRYINDEX); |
888 end; |
926 end; |
889 |
927 |
890 function lua_getgccount(L : Plua_State) : LongInt; |
928 function lua_getgccount(L : Plua_State) : LongInt; |
891 begin |
929 begin |
892 lua_getgccount := lua_gc(L, LUA_GCCOUNT, 0); |
930 lua_getgccount := lua_gc(L, LUA_GCCOUNT, 0); |
893 end; |
931 end; |
894 |
932 |
895 |
933 |
896 (*****************************************************************************) |
934 (*****************************************************************************) |
897 (* lualib.h *) |
935 (* lualib.h *) |
906 (* lauxlib.h n *) |
944 (* lauxlib.h n *) |
907 (*****************************************************************************) |
945 (*****************************************************************************) |
908 |
946 |
909 function luaL_getn(L : Plua_State; idx : LongInt) : LongInt; |
947 function luaL_getn(L : Plua_State; idx : LongInt) : LongInt; |
910 begin |
948 begin |
911 luaL_getn := lua_objlen(L, idx); |
949 luaL_getn := lua_objlen(L, idx); |
912 end; |
950 end; |
913 |
951 |
914 procedure luaL_setn(L : plua_State; i, j : LongInt); |
952 procedure luaL_setn(L : plua_State; i, j : LongInt); |
915 begin |
953 begin |
916 (* no op *) |
954 (* no op *) |
917 end; |
955 end; |
918 |
956 |
919 function luaL_argcheck(L : Plua_State; cond : Boolean; numarg : LongInt; |
957 function luaL_argcheck(L : Plua_State; cond : Boolean; numarg : LongInt; extramsg : PChar): LongInt; |
920 extramsg : PChar): LongInt; |
958 begin |
921 begin |
959 if not cond then |
922 if not cond then |
960 luaL_argcheck := luaL_argerror(L, numarg, extramsg) |
923 luaL_argcheck := luaL_argerror(L, numarg, extramsg) |
961 else |
924 else |
962 luaL_argcheck := 0; |
925 luaL_argcheck := 0; |
|
926 end; |
963 end; |
927 |
964 |
928 function luaL_checkstring(L : Plua_State; n : LongInt) : PChar; |
965 function luaL_checkstring(L : Plua_State; n : LongInt) : PChar; |
929 begin |
966 begin |
930 luaL_checkstring := luaL_checklstring(L, n, nil); |
967 luaL_checkstring := luaL_checklstring(L, n, nil); |
931 end; |
968 end; |
932 |
969 |
933 function luaL_optstring(L : Plua_State; n : LongInt; d : PChar) : PChar; |
970 function luaL_optstring(L : Plua_State; n : LongInt; d : PChar) : PChar; |
934 begin |
971 begin |
935 luaL_optstring := luaL_optlstring(L, n, d, nil); |
972 luaL_optstring := luaL_optlstring(L, n, d, nil); |
936 end; |
973 end; |
937 |
974 |
938 function luaL_checkint(L : Plua_State; n : LongInt) : lua_Integer; |
975 function luaL_checkint(L : Plua_State; n : LongInt) : lua_Integer; |
939 begin |
976 begin |
940 luaL_checkint := luaL_checkinteger(L, n); |
977 luaL_checkint := luaL_checkinteger(L, n); |
941 end; |
978 end; |
942 |
979 |
943 function luaL_optint(L : Plua_State; n : LongInt; d : lua_Integer): lua_Integer; |
980 function luaL_optint(L : Plua_State; n : LongInt; d : lua_Integer): lua_Integer; |
944 begin |
981 begin |
945 luaL_optint := luaL_optinteger(L, n, d); |
982 luaL_optint := luaL_optinteger(L, n, d); |
946 end; |
983 end; |
947 |
984 |
948 function luaL_checklong(L : Plua_State; n : LongInt) : lua_Integer; |
985 function luaL_checklong(L : Plua_State; n : LongInt) : lua_Integer; |
949 begin |
986 begin |
950 luaL_checklong := luaL_checkinteger(L, n); |
987 luaL_checklong := luaL_checkinteger(L, n); |
951 end; |
988 end; |
952 |
989 |
953 function luaL_optlong(L : Plua_State; n : LongInt; d : lua_Integer) : lua_Integer; |
990 function luaL_optlong(L : Plua_State; n : LongInt; d : lua_Integer) : lua_Integer; |
954 begin |
991 begin |
955 luaL_optlong := luaL_optinteger(L, n, d); |
992 luaL_optlong := luaL_optinteger(L, n, d); |
956 end; |
993 end; |
957 |
994 |
958 function luaL_typename(L : Plua_State; idx : LongInt) : PChar; |
995 function luaL_typename(L : Plua_State; idx : LongInt) : PChar; |
959 begin |
996 begin |
960 luaL_typename := lua_typename( L, lua_type(L, idx) ); |
997 luaL_typename := lua_typename( L, lua_type(L, idx) ); |
961 end; |
998 end; |
962 |
999 |
963 function luaL_dofile(L : Plua_State; fn : PChar) : LongInt; |
1000 function luaL_dofile(L : Plua_State; fn : PChar) : LongInt; |
964 begin |
1001 begin |
965 luaL_dofile := luaL_loadfile(L, fn); |
1002 luaL_dofile := luaL_loadfile(L, fn); |
966 if luaL_dofile = 0 then |
1003 if luaL_dofile = 0 then |
967 luaL_dofile := lua_pcall(L, 0, 0, 0); |
1004 luaL_dofile := lua_pcall(L, 0, 0, 0); |
968 end; |
1005 end; |
969 |
1006 |
970 function luaL_dostring(L : Plua_State; s : PChar) : LongInt; |
1007 function luaL_dostring(L : Plua_State; s : PChar) : LongInt; |
971 begin |
1008 begin |
972 luaL_dostring := luaL_loadstring(L, s); |
1009 luaL_dostring := luaL_loadstring(L, s); |
973 if luaL_dostring = 0 then |
1010 if luaL_dostring = 0 then |
974 luaL_dostring := lua_pcall(L, 0, 0, 0); |
1011 luaL_dostring := lua_pcall(L, 0, 0, 0); |
975 end; |
1012 end; |
976 |
1013 |
977 procedure luaL_getmetatable(L : Plua_State; n : PChar); |
1014 procedure luaL_getmetatable(L : Plua_State; n : PChar); |
978 begin |
1015 begin |
979 lua_getfield(L, LUA_REGISTRYINDEX, n); |
1016 lua_getfield(L, LUA_REGISTRYINDEX, n); |
980 end; |
1017 end; |
981 |
1018 |
982 procedure luaL_addchar(B : PluaL_Buffer; c : Char); |
1019 procedure luaL_addchar(B : PluaL_Buffer; c : Char); |
983 begin |
1020 begin |
984 if not(B^.p < B^.buffer + LUAL_BUFFERSIZE) then |
1021 if not(B^.p < B^.buffer + LUAL_BUFFERSIZE) then |
985 luaL_prepbuffer(B); |
1022 luaL_prepbuffer(B); |
986 (B^.p^) := c; |
1023 (B^.p^) := c; |
987 Inc(B^.p); |
1024 Inc(B^.p); |
988 end; |
1025 end; |
989 |
1026 |
990 procedure luaL_putchar(B : PluaL_Buffer; c : Char); |
1027 procedure luaL_putchar(B : PluaL_Buffer; c : Char); |
991 begin |
1028 begin |
992 luaL_addchar(B, c); |
1029 luaL_addchar(B, c); |
993 end; |
1030 end; |
994 |
1031 |
995 procedure luaL_addsize(B : PluaL_Buffer; n : LongInt); |
1032 procedure luaL_addsize(B : PluaL_Buffer; n : LongInt); |
996 begin |
1033 begin |
997 Inc(B^.p, n); |
1034 Inc(B^.p, n); |
998 end; |
1035 end; |
999 |
1036 |
1000 function lua_ref(L : Plua_State; lock : Boolean) : LongInt; |
1037 function lua_ref(L : Plua_State; lock : Boolean) : LongInt; |
1001 begin |
1038 begin |
1002 if lock then |
1039 if lock then |
1003 lua_ref := luaL_ref(L, LUA_REGISTRYINDEX) |
1040 lua_ref := luaL_ref(L, LUA_REGISTRYINDEX) |
1004 else begin |
1041 else |
1005 lua_pushstring(L, 'unlocked references are obsolete'); |
1042 begin |
1006 lua_error(L); |
1043 lua_pushstring(L, 'unlocked references are obsolete'); |
1007 lua_ref := 0; |
1044 lua_error(L); |
1008 end; |
1045 lua_ref := 0; |
|
1046 end; |
1009 end; |
1047 end; |
1010 |
1048 |
1011 procedure lua_unref(L : Plua_State; ref : LongInt); |
1049 procedure lua_unref(L : Plua_State; ref : LongInt); |
1012 begin |
1050 begin |
1013 luaL_unref(L, LUA_REGISTRYINDEX, ref); |
1051 luaL_unref(L, LUA_REGISTRYINDEX, ref); |
1014 end; |
1052 end; |
1015 |
1053 |
1016 procedure lua_getref(L : Plua_State; ref : LongInt); |
1054 procedure lua_getref(L : Plua_State; ref : LongInt); |
1017 begin |
1055 begin |
1018 lua_rawgeti(L, LUA_REGISTRYINDEX, ref); |
1056 lua_rawgeti(L, LUA_REGISTRYINDEX, ref); |
1019 end; |
1057 end; |
1020 |
1058 |
1021 |
1059 |
1022 (****************************************************************************** |
1060 (****************************************************************************** |
1023 * Original copyright for the lua source and headers: |
1061 * Original copyright for the lua source and headers: |