lualib.pas 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. (******************************************************************************
  2. * *
  3. * File: lualib.pas *
  4. * Authors: TeCGraf (C headers + actual Lua libraries) *
  5. * Lavergne Thomas (original translation to Pascal) *
  6. * Bram Kuijvenhoven (update to Lua 5.1.1 for FreePascal) *
  7. * Description: Standard Lua libraries *
  8. * *
  9. ******************************************************************************)
  10. (*
  11. ** $Id: lualib.h,v 1.28 2003/03/18 12:24:26 roberto Exp $
  12. ** Lua standard libraries
  13. ** See Copyright Notice in lua.h
  14. *)
  15. (*
  16. ** Translated to pascal by Lavergne Thomas
  17. ** Bug reports :
  18. ** - [email protected]
  19. ** In french or in english
  20. *)
  21. {$IFDEF FPC}{$MODE OBJFPC}{$H+}{$ENDIF}
  22. unit lualib;
  23. interface
  24. uses
  25. Lua;
  26. const
  27. LUA_COLIBNAME = 'coroutine';
  28. LUA_TABLIBNAME = 'table';
  29. LUA_IOLIBNAME = 'io';
  30. LUA_OSLIBNAME = 'os';
  31. LUA_STRLINAME = 'string';
  32. LUA_MATHLIBNAME = 'math';
  33. LUA_DBLIBNAME = 'debug';
  34. LUA_LOADLIBNAME = 'package';
  35. function luaopen_base(L: Plua_State): LongBool; cdecl;
  36. function luaopen_table(L: Plua_State): LongBool; cdecl;
  37. function luaopen_io(L: Plua_State): LongBool; cdecl;
  38. function luaopen_string(L: Plua_State): LongBool; cdecl;
  39. function luaopen_math(L: Plua_State): LongBool; cdecl;
  40. function luaopen_debug(L: Plua_State): LongBool; cdecl;
  41. function luaopen_package(L: Plua_State): LongBool; cdecl;
  42. (* open all previous libraries *)
  43. procedure luaL_openlibs(L: Plua_State); cdecl;
  44. (* compatibility code *)
  45. function lua_baselibopen(L: Plua_State): LongBool;
  46. function lua_tablibopen(L: Plua_State): LongBool;
  47. function lua_iolibopen(L: Plua_State): LongBool;
  48. function lua_strlibopen(L: Plua_State): LongBool;
  49. function lua_mathlibopen(L: Plua_State): LongBool;
  50. function lua_dblibopen(L: Plua_State): LongBool;
  51. implementation
  52. function luaopen_base(L: Plua_State): LongBool; cdecl; external LUA_LIB_NAME;
  53. function luaopen_table(L: Plua_State): LongBool; cdecl; external LUA_LIB_NAME;
  54. function luaopen_io(L: Plua_State): LongBool; cdecl; external LUA_LIB_NAME;
  55. function luaopen_string(L: Plua_State): LongBool; cdecl; external LUA_LIB_NAME;
  56. function luaopen_math(L: Plua_State): LongBool; cdecl; external LUA_LIB_NAME;
  57. function luaopen_debug(L: Plua_State): LongBool; cdecl; external LUA_LIB_NAME;
  58. function luaopen_package(L: Plua_State): LongBool; cdecl; external LUA_LIB_NAME;
  59. procedure luaL_openlibs(L: Plua_State); cdecl; external LUA_LIB_NAME;
  60. function lua_baselibopen(L: Plua_State): LongBool;
  61. begin
  62. Result := luaopen_base(L);
  63. end;
  64. function lua_tablibopen(L: Plua_State): LongBool;
  65. begin
  66. Result := luaopen_table(L);
  67. end;
  68. function lua_iolibopen(L: Plua_State): LongBool;
  69. begin
  70. Result := luaopen_io(L);
  71. end;
  72. function lua_strlibopen(L: Plua_State): LongBool;
  73. begin
  74. Result := luaopen_string(L);
  75. end;
  76. function lua_mathlibopen(L: Plua_State): LongBool;
  77. begin
  78. Result := luaopen_math(L);
  79. end;
  80. function lua_dblibopen(L: Plua_State): LongBool;
  81. begin
  82. Result := luaopen_debug(L);
  83. end;
  84. end.