summary refs log tree commit diff stats
path: root/lib/wrappers/lua/lualib.nim
blob: df5d53101b3ce8dd05c52d20341fff5ab253aea0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#*****************************************************************************
# *                                                                            *
# *  File:        lualib.pas                                                   *
# *  Authors:     TeCGraf           (C headers + actual Lua libraries)         *
# *               Lavergne Thomas   (original translation to Pascal)           *
# *               Bram Kuijvenhoven (update to Lua 5.1.1 for FreePascal)       *
# *  Description: Standard Lua libraries                                       *
# *                                                                            *
# *****************************************************************************
#
#** $Id: lualib.h,v 1.28 2003/03/18 12:24:26 roberto Exp $
#** Lua standard libraries
#** See Copyright Notice in lua.h
#
#
#** Translated to pascal by Lavergne Thomas
#** Bug reports :
#**    - thomas.lavergne@laposte.net
#**   In french or in english
#

import lua

const 
  LUA_COLIBNAME* = "coroutine"
  LUA_TABLIBNAME* = "table"
  LUA_IOLIBNAME* = "io"
  LUA_OSLIBNAME* = "os"
  LUA_STRLINAME* = "string"
  LUA_MATHLIBNAME* = "math"
  LUA_DBLIBNAME* = "debug"
  LUA_LOADLIBNAME* = "package"

proc luaopen_base*(L: Plua_State): cint{.cdecl, dynlib: LUA_LIB_NAME, 
    importc.}
proc luaopen_table*(L: Plua_State): cint{.cdecl, dynlib: LUA_LIB_NAME, 
    importc.}
proc luaopen_io*(L: Plua_State): cint{.cdecl, dynlib: LUA_LIB_NAME, importc.}
proc luaopen_string*(L: Plua_State): cint{.cdecl, dynlib: LUA_LIB_NAME, 
    importc.}
proc luaopen_math*(L: Plua_State): cint{.cdecl, dynlib: LUA_LIB_NAME, 
    importc.}
proc luaopen_debug*(L: Plua_State): cint{.cdecl, dynlib: LUA_LIB_NAME, 
    importc.}
proc luaopen_package*(L: Plua_State): cint{.cdecl, dynlib: LUA_LIB_NAME, 
    importc.}
proc luaL_openlibs*(L: Plua_State){.cdecl, dynlib: LUA_LIB_NAME, importc.}
  # compatibility code 
proc lua_baselibopen*(L: Plua_State): Bool
proc lua_tablibopen*(L: Plua_State): Bool
proc lua_iolibopen*(L: Plua_State): Bool
proc lua_strlibopen*(L: Plua_State): Bool
proc lua_mathlibopen*(L: Plua_State): Bool
proc lua_dblibopen*(L: Plua_State): Bool
# implementation

proc lua_baselibopen(L: Plua_State): Bool = 
  Result = luaopen_base(L) != 0'i32

proc lua_tablibopen(L: Plua_State): Bool = 
  Result = luaopen_table(L) != 0'i32

proc lua_iolibopen(L: Plua_State): Bool = 
  Result = luaopen_io(L) != 0'i32

proc lua_strlibopen(L: Plua_State): Bool = 
  Result = luaopen_string(L) != 0'i32

proc lua_mathlibopen(L: Plua_State): Bool = 
  Result = luaopen_math(L) != 0'i32

proc lua_dblibopen(L: Plua_State): Bool = 
  Result = luaopen_debug(L) != 0'i32