123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- (*
- ** $Id: lualib.pas,v 1.5 2007-01-20 16:40:27 jfgoulet Exp $
- ** Lua standard libraries
- ** See Copyright Notice in lua.h
- *)
- unit lualib;
- {$IFNDEF lualib_h}
- {$DEFINE lualib_h}
- {$ENDIF}
- interface
- uses
- lua;
- const
- LUA_PACKLIBNAME = 'package';
- LUA_COLIBNAME = 'coroutine';
- LUA_TABLIBNAME = 'table';
- LUA_IOLIBNAME = 'io';
- LUA_OSLIBNAME = 'os';
- LUA_STRLIBNAME = 'string';
- LUA_MATHLIBNAME = 'math';
- LUA_DBLIBNAME = 'debug';
- function luaopen_base(L: Plua_State): Integer;
- cdecl external 'lua5.1.dll';
- function luaopen_package(L: Plua_State): Integer;
- cdecl external 'lua5.1.dll';
- function luaopen_table(L: Plua_State): Integer;
- cdecl external 'lua5.1.dll';
- function luaopen_io(L: Plua_State): Integer;
- cdecl external 'lua5.1.dll';
- function luaopen_string(L: Plua_State): Integer;
- cdecl external 'lua5.1.dll';
- function luaopen_math(L: Plua_State): Integer;
- cdecl external 'lua5.1.dll';
- function luaopen_debug(L: Plua_State): Integer;
- cdecl external 'lua5.1.dll';
- (* to help testing the libraries *)
- {$IFNDEF lua_assert}
- //#define lua_assert(c) (* empty *)
- {$ENDIF}
- (* compatibility code *)
- function lua_baselibopen(L: Plua_State): Integer;
- function lua_packlibopen(L: Plua_State): Integer;
- function lua_tablibopen(L: Plua_State): Integer;
- function lua_iolibopen(L: Plua_State): Integer;
- function lua_strlibopen(L: Plua_State): Integer;
- function lua_mathlibopen(L: Plua_State): Integer;
- function lua_dblibopen(L: Plua_State): Integer;
- implementation
- function lua_baselibopen(L: Plua_State): Integer;
- begin
- lua_pushcfunction(L, luaopen_base);
- lua_pushstring(L, '');
- lua_call(L, 1, 0);
- Result := 1;
- end;
- function lua_packlibopen(L: Plua_State): Integer;
- begin
- lua_pushcfunction(L, luaopen_package);
- lua_pushstring(L, 'package');
- lua_call(L, 1, 0);
- Result := 1;
- end;
- function lua_tablibopen(L: Plua_State): Integer;
- begin
- lua_pushcfunction(L, luaopen_table);
- lua_pushstring(L, 'table');
- lua_call(L, 1, 0);
- Result := 1;
- end;
- function lua_iolibopen(L: Plua_State): Integer;
- begin
- lua_pushcfunction(L, luaopen_io);
- lua_pushstring(L, 'io');
- lua_call(L, 1, 0);
- {lua_pushcfunction(L, luaopen_os);
- lua_pushstring(L, 'os');
- lua_call(L, 1, 0);
- Result := 1;}
- end;
- function lua_strlibopen(L: Plua_State): Integer;
- begin
- lua_pushcfunction(L, luaopen_string);
- lua_pushstring(L, 'string');
- lua_call(L, 1, 0);
- Result := 1;
- end;
- function lua_mathlibopen(L: Plua_State): Integer;
- begin
- lua_pushcfunction(L, luaopen_math);
- lua_pushstring(L, 'math');
- lua_call(L, 1, 0);
- Result := 1;
- end;
- function lua_dblibopen(L: Plua_State): Integer;
- begin
- lua_pushcfunction(L, luaopen_debug);
- lua_pushstring(L, 'debug');
- lua_call(L, 1, 0);
- Result := 1;
- end;
- end.
|