mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-22 23:35:22 +00:00
further development of new wrappers
This commit is contained in:
@@ -24,89 +24,89 @@
|
||||
import
|
||||
lua
|
||||
|
||||
proc lua_pushstring*(L: Plua_State, s: string)
|
||||
proc pushstring*(L: PState, s: string)
|
||||
# compatibilty macros
|
||||
proc getn*(L: Plua_State, n: int): int
|
||||
proc getn*(L: PState, n: int): int
|
||||
# calls lua_objlen
|
||||
proc setn*(L: Plua_State, t, n: int)
|
||||
proc setn*(L: PState, t, n: int)
|
||||
# does nothing!
|
||||
type
|
||||
Treg*{.final.} = object
|
||||
name*: cstring
|
||||
func*: lua_CFunction
|
||||
func*: CFunction
|
||||
|
||||
Preg* = ptr Treg
|
||||
|
||||
proc openlib*(L: Plua_State, libname: cstring, lr: Preg, nup: int){.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc: "luaL_openlib".}
|
||||
proc register*(L: Plua_State, libname: cstring, lr: Preg){.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc: "luaL_register".}
|
||||
proc getmetafield*(L: Plua_State, obj: int, e: cstring): int{.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc: "luaL_getmetafield".}
|
||||
proc callmeta*(L: Plua_State, obj: int, e: cstring): int{.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc: "luaL_callmeta".}
|
||||
proc typerror*(L: Plua_State, narg: int, tname: cstring): int{.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc: "luaL_typerror".}
|
||||
proc argerror*(L: Plua_State, numarg: int, extramsg: cstring): int{.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc: "luaL_argerror".}
|
||||
proc checklstring*(L: Plua_State, numArg: int, l_: Psize_t): cstring{.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc: "luaL_checklstring".}
|
||||
proc optlstring*(L: Plua_State, numArg: int, def: cstring, l_: Psize_t): cstring{.
|
||||
cdecl, dynlib: LUA_LIB_NAME, importc: "luaL_optlstring".}
|
||||
proc checknumber*(L: Plua_State, numArg: int): lua_Number{.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc: "luaL_checknumber".}
|
||||
proc optnumber*(L: Plua_State, nArg: int, def: lua_Number): lua_Number{.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc: "luaL_optnumber".}
|
||||
proc checkinteger*(L: Plua_State, numArg: int): lua_Integer{.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc: "luaL_checkinteger".}
|
||||
proc optinteger*(L: Plua_State, nArg: int, def: lua_Integer): lua_Integer{.
|
||||
cdecl, dynlib: LUA_LIB_NAME, importc: "luaL_optinteger".}
|
||||
proc checkstack*(L: Plua_State, sz: int, msg: cstring){.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc: "luaL_checkstack".}
|
||||
proc checktype*(L: Plua_State, narg, t: int){.cdecl, dynlib: LUA_LIB_NAME,
|
||||
proc openlib*(L: PState, libname: cstring, lr: Preg, nup: int){.cdecl,
|
||||
dynlib: LIB_NAME, importc: "luaL_openlib".}
|
||||
proc register*(L: PState, libname: cstring, lr: Preg){.cdecl,
|
||||
dynlib: LIB_NAME, importc: "luaL_register".}
|
||||
proc getmetafield*(L: PState, obj: int, e: cstring): int{.cdecl,
|
||||
dynlib: LIB_NAME, importc: "luaL_getmetafield".}
|
||||
proc callmeta*(L: PState, obj: int, e: cstring): int{.cdecl,
|
||||
dynlib: LIB_NAME, importc: "luaL_callmeta".}
|
||||
proc typerror*(L: PState, narg: int, tname: cstring): int{.cdecl,
|
||||
dynlib: LIB_NAME, importc: "luaL_typerror".}
|
||||
proc argerror*(L: PState, numarg: int, extramsg: cstring): int{.cdecl,
|
||||
dynlib: LIB_NAME, importc: "luaL_argerror".}
|
||||
proc checklstring*(L: PState, numArg: int, l_: Psize_t): cstring{.cdecl,
|
||||
dynlib: LIB_NAME, importc: "luaL_checklstring".}
|
||||
proc optlstring*(L: PState, numArg: int, def: cstring, l_: Psize_t): cstring{.
|
||||
cdecl, dynlib: LIB_NAME, importc: "luaL_optlstring".}
|
||||
proc checknumber*(L: PState, numArg: int): lua_Number{.cdecl,
|
||||
dynlib: LIB_NAME, importc: "luaL_checknumber".}
|
||||
proc optnumber*(L: PState, nArg: int, def: lua_Number): lua_Number{.cdecl,
|
||||
dynlib: LIB_NAME, importc: "luaL_optnumber".}
|
||||
proc checkinteger*(L: PState, numArg: int): lua_Integer{.cdecl,
|
||||
dynlib: LIB_NAME, importc: "luaL_checkinteger".}
|
||||
proc optinteger*(L: PState, nArg: int, def: lua_Integer): lua_Integer{.
|
||||
cdecl, dynlib: LIB_NAME, importc: "luaL_optinteger".}
|
||||
proc checkstack*(L: PState, sz: int, msg: cstring){.cdecl,
|
||||
dynlib: LIB_NAME, importc: "luaL_checkstack".}
|
||||
proc checktype*(L: PState, narg, t: int){.cdecl, dynlib: LIB_NAME,
|
||||
importc: "luaL_checktype".}
|
||||
proc checkany*(L: Plua_State, narg: int){.cdecl, dynlib: LUA_LIB_NAME,
|
||||
proc checkany*(L: PState, narg: int){.cdecl, dynlib: LIB_NAME,
|
||||
importc: "luaL_checkany".}
|
||||
proc newmetatable*(L: Plua_State, tname: cstring): int{.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc: "luaL_newmetatable".}
|
||||
proc checkudata*(L: Plua_State, ud: int, tname: cstring): Pointer{.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc: "luaL_checkudata".}
|
||||
proc where*(L: Plua_State, lvl: int){.cdecl, dynlib: LUA_LIB_NAME,
|
||||
proc newmetatable*(L: PState, tname: cstring): int{.cdecl,
|
||||
dynlib: LIB_NAME, importc: "luaL_newmetatable".}
|
||||
proc checkudata*(L: PState, ud: int, tname: cstring): Pointer{.cdecl,
|
||||
dynlib: LIB_NAME, importc: "luaL_checkudata".}
|
||||
proc where*(L: PState, lvl: int){.cdecl, dynlib: LIB_NAME,
|
||||
importc: "luaL_where".}
|
||||
proc error*(L: Plua_State, fmt: cstring): int{.cdecl, varargs,
|
||||
dynlib: LUA_LIB_NAME, importc: "luaL_error".}
|
||||
proc checkoption*(L: Plua_State, narg: int, def: cstring, lst: cstringArray): int{.
|
||||
cdecl, dynlib: LUA_LIB_NAME, importc: "luaL_checkoption".}
|
||||
proc ref*(L: Plua_State, t: int): int{.cdecl, dynlib: LUA_LIB_NAME,
|
||||
proc error*(L: PState, fmt: cstring): int{.cdecl, varargs,
|
||||
dynlib: LIB_NAME, importc: "luaL_error".}
|
||||
proc checkoption*(L: PState, narg: int, def: cstring, lst: cstringArray): int{.
|
||||
cdecl, dynlib: LIB_NAME, importc: "luaL_checkoption".}
|
||||
proc ref*(L: PState, t: int): int{.cdecl, dynlib: LIB_NAME,
|
||||
importc: "luaL_ref".}
|
||||
proc unref*(L: Plua_State, t, theref: int){.cdecl, dynlib: LUA_LIB_NAME,
|
||||
proc unref*(L: PState, t, theref: int){.cdecl, dynlib: LIB_NAME,
|
||||
importc: "luaL_unref".}
|
||||
proc loadfile*(L: Plua_State, filename: cstring): int{.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc: "luaL_loadfile".}
|
||||
proc loadbuffer*(L: Plua_State, buff: cstring, size: size_t, name: cstring): int{.
|
||||
cdecl, dynlib: LUA_LIB_NAME, importc: "luaL_loadbuffer".}
|
||||
proc loadstring*(L: Plua_State, s: cstring): int{.cdecl, dynlib: LUA_LIB_NAME,
|
||||
proc loadfile*(L: PState, filename: cstring): int{.cdecl,
|
||||
dynlib: LIB_NAME, importc: "luaL_loadfile".}
|
||||
proc loadbuffer*(L: PState, buff: cstring, size: size_t, name: cstring): int{.
|
||||
cdecl, dynlib: LIB_NAME, importc: "luaL_loadbuffer".}
|
||||
proc loadstring*(L: PState, s: cstring): int{.cdecl, dynlib: LIB_NAME,
|
||||
importc: "luaL_loadstring".}
|
||||
proc newstate*(): Plua_State{.cdecl, dynlib: LUA_LIB_NAME,
|
||||
proc newstate*(): PState{.cdecl, dynlib: LIB_NAME,
|
||||
importc: "luaL_newstate".}
|
||||
proc lua_open*(): Plua_State
|
||||
proc lua_open*(): PState
|
||||
# compatibility; moved from unit lua to lauxlib because it needs luaL_newstate
|
||||
#
|
||||
#** ===============================================================
|
||||
#** some useful macros
|
||||
#** ===============================================================
|
||||
#
|
||||
proc argcheck*(L: Plua_State, cond: bool, numarg: int, extramsg: cstring)
|
||||
proc checkstring*(L: Plua_State, n: int): cstring
|
||||
proc optstring*(L: Plua_State, n: int, d: cstring): cstring
|
||||
proc checkint*(L: Plua_State, n: int): int
|
||||
proc checklong*(L: Plua_State, n: int): int32
|
||||
proc optint*(L: Plua_State, n: int, d: float64): int
|
||||
proc optlong*(L: Plua_State, n: int, d: float64): int32
|
||||
proc typename*(L: Plua_State, i: int): cstring
|
||||
proc lua_dofile*(L: Plua_State, filename: cstring): int
|
||||
proc lua_dostring*(L: Plua_State, str: cstring): int
|
||||
proc lua_Lgetmetatable*(L: Plua_State, tname: cstring)
|
||||
proc argcheck*(L: PState, cond: bool, numarg: int, extramsg: cstring)
|
||||
proc checkstring*(L: PState, n: int): cstring
|
||||
proc optstring*(L: PState, n: int, d: cstring): cstring
|
||||
proc checkint*(L: PState, n: int): int
|
||||
proc checklong*(L: PState, n: int): int32
|
||||
proc optint*(L: PState, n: int, d: float64): int
|
||||
proc optlong*(L: PState, n: int, d: float64): int32
|
||||
proc typename*(L: PState, i: int): cstring
|
||||
proc lua_dofile*(L: PState, filename: cstring): int
|
||||
proc lua_dostring*(L: PState, str: cstring): int
|
||||
proc lua_Lgetmetatable*(L: PState, tname: cstring)
|
||||
# not translated:
|
||||
# #define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n)))
|
||||
#
|
||||
@@ -121,7 +121,7 @@ type
|
||||
Buffer*{.final.} = object
|
||||
p*: cstring # current position in buffer
|
||||
lvl*: int # number of strings in the stack (level)
|
||||
L*: Plua_State
|
||||
L*: PState
|
||||
buffer*: array[0..BUFFERSIZE - 1, Char] # warning: see note above about LUAL_BUFFERSIZE
|
||||
|
||||
PBuffer* = ptr Buffer
|
||||
@@ -132,82 +132,82 @@ proc addchar*(B: PBuffer, c: Char)
|
||||
proc putchar*(B: PBuffer, c: Char)
|
||||
# warning: see note above about LUAL_BUFFERSIZE
|
||||
proc addsize*(B: PBuffer, n: int)
|
||||
proc buffinit*(L: Plua_State, B: PBuffer){.cdecl, dynlib: LUA_LIB_NAME,
|
||||
proc buffinit*(L: PState, B: PBuffer){.cdecl, dynlib: LIB_NAME,
|
||||
importc: "luaL_buffinit".}
|
||||
proc prepbuffer*(B: PBuffer): cstring{.cdecl, dynlib: LUA_LIB_NAME,
|
||||
proc prepbuffer*(B: PBuffer): cstring{.cdecl, dynlib: LIB_NAME,
|
||||
importc: "luaL_prepbuffer".}
|
||||
proc addlstring*(B: PBuffer, s: cstring, L: size_t){.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc: "luaL_addlstring".}
|
||||
proc addstring*(B: PBuffer, s: cstring){.cdecl, dynlib: LUA_LIB_NAME,
|
||||
dynlib: LIB_NAME, importc: "luaL_addlstring".}
|
||||
proc addstring*(B: PBuffer, s: cstring){.cdecl, dynlib: LIB_NAME,
|
||||
importc: "luaL_addstring".}
|
||||
proc addvalue*(B: PBuffer){.cdecl, dynlib: LUA_LIB_NAME,
|
||||
proc addvalue*(B: PBuffer){.cdecl, dynlib: LIB_NAME,
|
||||
importc: "luaL_addvalue".}
|
||||
proc pushresult*(B: PBuffer){.cdecl, dynlib: LUA_LIB_NAME,
|
||||
proc pushresult*(B: PBuffer){.cdecl, dynlib: LIB_NAME,
|
||||
importc: "luaL_pushresult".}
|
||||
proc gsub*(L: Plua_State, s, p, r: cstring): cstring{.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc: "luaL_gsub".}
|
||||
proc findtable*(L: Plua_State, idx: int, fname: cstring, szhint: int): cstring{.
|
||||
cdecl, dynlib: LUA_LIB_NAME, importc: "luaL_findtable".}
|
||||
proc gsub*(L: PState, s, p, r: cstring): cstring{.cdecl,
|
||||
dynlib: LIB_NAME, importc: "luaL_gsub".}
|
||||
proc findtable*(L: PState, idx: int, fname: cstring, szhint: int): cstring{.
|
||||
cdecl, dynlib: LIB_NAME, importc: "luaL_findtable".}
|
||||
# compatibility with ref system
|
||||
# pre-defined references
|
||||
const
|
||||
LUA_NOREF* = - 2
|
||||
LUA_REFNIL* = - 1
|
||||
|
||||
proc lua_unref*(L: Plua_State, theref: int)
|
||||
proc lua_getref*(L: Plua_State, theref: int)
|
||||
proc lua_unref*(L: PState, theref: int)
|
||||
proc lua_getref*(L: PState, theref: int)
|
||||
#
|
||||
#** Compatibility macros and functions
|
||||
#
|
||||
# implementation
|
||||
|
||||
proc lua_pushstring(L: Plua_State, s: string) =
|
||||
proc lua_pushstring(L: PState, s: string) =
|
||||
lua_pushlstring(L, cstring(s), len(s))
|
||||
|
||||
proc getn(L: Plua_State, n: int): int =
|
||||
proc getn(L: PState, n: int): int =
|
||||
Result = lua_objlen(L, n)
|
||||
|
||||
proc setn(L: Plua_State, t, n: int) =
|
||||
proc setn(L: PState, t, n: int) =
|
||||
# does nothing as this operation is deprecated
|
||||
nil
|
||||
|
||||
proc lua_open(): Plua_State =
|
||||
proc lua_open(): PState =
|
||||
Result = newstate()
|
||||
|
||||
proc typename(L: Plua_State, i: int): cstring =
|
||||
proc typename(L: PState, i: int): cstring =
|
||||
Result = lua_typename(L, lua_type(L, i))
|
||||
|
||||
proc lua_dofile(L: Plua_State, filename: cstring): int =
|
||||
proc lua_dofile(L: PState, filename: cstring): int =
|
||||
Result = loadfile(L, filename)
|
||||
if Result == 0: Result = lua_pcall(L, 0, LUA_MULTRET, 0)
|
||||
|
||||
proc lua_dostring(L: Plua_State, str: cstring): int =
|
||||
proc lua_dostring(L: PState, str: cstring): int =
|
||||
Result = loadstring(L, str)
|
||||
if Result == 0: Result = lua_pcall(L, 0, LUA_MULTRET, 0)
|
||||
|
||||
proc lua_Lgetmetatable(L: Plua_State, tname: cstring) =
|
||||
proc lua_Lgetmetatable(L: PState, tname: cstring) =
|
||||
lua_getfield(L, LUA_REGISTRYINDEX, tname)
|
||||
|
||||
proc argcheck(L: Plua_State, cond: bool, numarg: int, extramsg: cstring) =
|
||||
proc argcheck(L: PState, cond: bool, numarg: int, extramsg: cstring) =
|
||||
if not cond:
|
||||
discard argerror(L, numarg, extramsg)
|
||||
|
||||
proc checkstring(L: Plua_State, n: int): cstring =
|
||||
proc checkstring(L: PState, n: int): cstring =
|
||||
Result = checklstring(L, n, nil)
|
||||
|
||||
proc optstring(L: Plua_State, n: int, d: cstring): cstring =
|
||||
proc optstring(L: PState, n: int, d: cstring): cstring =
|
||||
Result = optlstring(L, n, d, nil)
|
||||
|
||||
proc checkint(L: Plua_State, n: int): int =
|
||||
proc checkint(L: PState, n: int): int =
|
||||
Result = toInt(checknumber(L, n))
|
||||
|
||||
proc checklong(L: Plua_State, n: int): int32 =
|
||||
proc checklong(L: PState, n: int): int32 =
|
||||
Result = int32(ToInt(checknumber(L, n)))
|
||||
|
||||
proc optint(L: Plua_State, n: int, d: float64): int =
|
||||
proc optint(L: PState, n: int, d: float64): int =
|
||||
Result = int(ToInt(optnumber(L, n, d)))
|
||||
|
||||
proc optlong(L: Plua_State, n: int, d: float64): int32 =
|
||||
proc optlong(L: PState, n: int, d: float64): int32 =
|
||||
Result = int32(ToInt(optnumber(L, n, d)))
|
||||
|
||||
proc addchar(B: PBuffer, c: Char) =
|
||||
@@ -222,8 +222,8 @@ proc putchar(B: PBuffer, c: Char) =
|
||||
proc addsize(B: PBuffer, n: int) =
|
||||
B.p = cast[cstring](cast[int](B.p) + n)
|
||||
|
||||
proc lua_unref(L: Plua_State, theref: int) =
|
||||
proc lua_unref(L: PState, theref: int) =
|
||||
unref(L, LUA_REGISTRYINDEX, theref)
|
||||
|
||||
proc lua_getref(L: Plua_State, theref: int) =
|
||||
proc lua_getref(L: PState, theref: int) =
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, theref)
|
||||
|
||||
@@ -47,9 +47,7 @@ else:
|
||||
const
|
||||
NAME* = "lua(|5.2|5.1|5.0).dll"
|
||||
LIB_NAME* = "lua(|5.2|5.1|5.0).dll"
|
||||
type
|
||||
size_t* = int
|
||||
Psize_t* = ptr size_t
|
||||
|
||||
|
||||
const
|
||||
VERSION* = "Lua 5.1"
|
||||
@@ -67,7 +65,7 @@ const
|
||||
|
||||
proc upvalueindex*(I: int): int
|
||||
const # thread status; 0 is OK
|
||||
YIELD_* = 1
|
||||
constYIELD* = 1
|
||||
ERRRUN* = 2
|
||||
ERRSYNTAX* = 3
|
||||
ERRMEM* = 4
|
||||
@@ -82,9 +80,9 @@ type
|
||||
#
|
||||
|
||||
type
|
||||
Reader* = proc (L: PState, ud: Pointer, sz: Psize_t): cstring{.cdecl.}
|
||||
Writer* = proc (L: PState, p: Pointer, sz: size_t, ud: Pointer): int{.cdecl.}
|
||||
Alloc* = proc (ud, theptr: Pointer, osize, nsize: size_t){.cdecl.}
|
||||
Reader* = proc (L: PState, ud: Pointer, sz: ptr int): cstring{.cdecl.}
|
||||
Writer* = proc (L: PState, p: Pointer, sz: int, ud: Pointer): int{.cdecl.}
|
||||
Alloc* = proc (ud, theptr: Pointer, osize, nsize: int){.cdecl.}
|
||||
|
||||
const
|
||||
TNONE* = - 1
|
||||
@@ -129,7 +127,7 @@ proc iscfunction*(L: PState, idx: int): cint{.cdecl, dynlib: NAME,
|
||||
importc: "lua_iscfunction".}
|
||||
proc isuserdata*(L: PState, idx: int): cint{.cdecl, dynlib: NAME,
|
||||
importc: "lua_isuserdata".}
|
||||
proc type*(L: PState, idx: int): int{.cdecl, dynlib: NAME, importc: "lua_type".}
|
||||
proc luatype*(L: PState, idx: int): int{.cdecl, dynlib: NAME, importc: "lua_type".}
|
||||
proc typename*(L: PState, tp: int): cstring{.cdecl, dynlib: NAME,
|
||||
importc: "lua_typename".}
|
||||
proc equal*(L: PState, idx1, idx2: int): cint{.cdecl, dynlib: NAME,
|
||||
@@ -144,9 +142,9 @@ proc tointeger*(L: PState, idx: int): Integer{.cdecl, dynlib: NAME,
|
||||
importc: "lua_tointeger".}
|
||||
proc toboolean*(L: PState, idx: int): cint{.cdecl, dynlib: NAME,
|
||||
importc: "lua_toboolean".}
|
||||
proc tolstring*(L: PState, idx: int, length: Psize_t): cstring{.cdecl,
|
||||
proc tolstring*(L: PState, idx: int, length: ptr int): cstring{.cdecl,
|
||||
dynlib: NAME, importc: "lua_tolstring".}
|
||||
proc objlen*(L: PState, idx: int): size_t{.cdecl, dynlib: NAME,
|
||||
proc objlen*(L: PState, idx: int): int{.cdecl, dynlib: NAME,
|
||||
importc: "lua_objlen".}
|
||||
proc tocfunction*(L: PState, idx: int): CFunction{.cdecl, dynlib: NAME,
|
||||
importc: "lua_tocfunction".}
|
||||
@@ -161,7 +159,7 @@ proc pushnumber*(L: PState, n: Number){.cdecl, dynlib: NAME,
|
||||
importc: "lua_pushnumber".}
|
||||
proc pushinteger*(L: PState, n: Integer){.cdecl, dynlib: NAME,
|
||||
importc: "lua_pushinteger".}
|
||||
proc pushlstring*(L: PState, s: cstring, l_: size_t){.cdecl, dynlib: NAME,
|
||||
proc pushlstring*(L: PState, s: cstring, l_: int){.cdecl, dynlib: NAME,
|
||||
importc: "lua_pushlstring".}
|
||||
proc pushstring*(L: PState, s: cstring){.cdecl, dynlib: NAME,
|
||||
importc: "lua_pushstring".}
|
||||
@@ -185,7 +183,7 @@ proc rawgeti*(L: PState, idx, n: int){.cdecl, dynlib: NAME,
|
||||
importc: "lua_rawgeti".}
|
||||
proc createtable*(L: PState, narr, nrec: int){.cdecl, dynlib: NAME,
|
||||
importc: "lua_createtable".}
|
||||
proc newuserdata*(L: PState, sz: size_t): Pointer{.cdecl, dynlib: NAME,
|
||||
proc newuserdata*(L: PState, sz: int): Pointer{.cdecl, dynlib: NAME,
|
||||
importc: "lua_newuserdata".}
|
||||
proc getmetatable*(L: PState, objindex: int): int{.cdecl, dynlib: NAME,
|
||||
importc: "lua_getmetatable".}
|
||||
@@ -211,7 +209,7 @@ proc load*(L: PState, reader: Reader, dt: Pointer, chunkname: cstring): int{.
|
||||
cdecl, dynlib: NAME, importc: "lua_load".}
|
||||
proc dump*(L: PState, writer: Writer, data: Pointer): int{.cdecl, dynlib: NAME,
|
||||
importc: "lua_dump".}
|
||||
proc yield*(L: PState, nresults: int): int{.cdecl, dynlib: NAME,
|
||||
proc luayield*(L: PState, nresults: int): int{.cdecl, dynlib: NAME,
|
||||
importc: "lua_yield".}
|
||||
proc resume*(L: PState, narg: int): int{.cdecl, dynlib: NAME,
|
||||
importc: "lua_resume".}
|
||||
@@ -249,7 +247,7 @@ proc pop*(L: PState, n: int)
|
||||
proc newtable*(L: Pstate)
|
||||
proc register*(L: PState, n: cstring, f: CFunction)
|
||||
proc pushcfunction*(L: PState, f: CFunction)
|
||||
proc strlen*(L: Pstate, i: int): size_t
|
||||
proc strlen*(L: Pstate, i: int): int
|
||||
proc isfunction*(L: PState, n: int): bool
|
||||
proc istable*(L: PState, n: int): bool
|
||||
proc islightuserdata*(L: PState, n: int): bool
|
||||
@@ -295,7 +293,7 @@ const
|
||||
IDSIZE* = 60
|
||||
|
||||
type
|
||||
Debug*{.final.} = object # activation record
|
||||
TDebug*{.final.} = object # activation record
|
||||
event*: int
|
||||
name*: cstring # (n)
|
||||
namewhat*: cstring # (n) `global', `local', `field', `method'
|
||||
@@ -309,7 +307,7 @@ type
|
||||
# private part
|
||||
i_ci*: int # active function
|
||||
|
||||
PDebug* = ptr Debug
|
||||
PDebug* = ptr TDebug
|
||||
Hook* = proc (L: PState, ar: PDebug){.cdecl.}
|
||||
|
||||
#
|
||||
@@ -355,32 +353,32 @@ proc register(L: PState, n: cstring, f: CFunction) =
|
||||
proc pushcfunction(L: PState, f: CFunction) =
|
||||
pushcclosure(L, f, 0)
|
||||
|
||||
proc strlen(L: PState, i: int): size_t =
|
||||
proc strlen(L: PState, i: int): int =
|
||||
Result = objlen(L, i)
|
||||
|
||||
proc isfunction(L: PState, n: int): bool =
|
||||
Result = type(L, n) == TFUNCTION
|
||||
Result = luatype(L, n) == TFUNCTION
|
||||
|
||||
proc istable(L: PState, n: int): bool =
|
||||
Result = type(L, n) == TTABLE
|
||||
Result = luatype(L, n) == TTABLE
|
||||
|
||||
proc islightuserdata(L: PState, n: int): bool =
|
||||
Result = type(L, n) == TLIGHTUSERDATA
|
||||
Result = luatype(L, n) == TLIGHTUSERDATA
|
||||
|
||||
proc isnil(L: PState, n: int): bool =
|
||||
Result = type(L, n) == TNIL
|
||||
Result = luatype(L, n) == TNIL
|
||||
|
||||
proc isboolean(L: PState, n: int): bool =
|
||||
Result = type(L, n) == TBOOLEAN
|
||||
Result = luatype(L, n) == TBOOLEAN
|
||||
|
||||
proc isthread(L: PState, n: int): bool =
|
||||
Result = type(L, n) == TTHREAD
|
||||
Result = luatype(L, n) == TTHREAD
|
||||
|
||||
proc isnone(L: PState, n: int): bool =
|
||||
Result = type(L, n) == TNONE
|
||||
Result = luatype(L, n) == TNONE
|
||||
|
||||
proc isnoneornil(L: PState, n: int): bool =
|
||||
Result = type(L, n) <= 0
|
||||
Result = luatype(L, n) <= 0
|
||||
|
||||
proc pushliteral(L: PState, s: cstring) =
|
||||
pushlstring(L, s, len(s))
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#
|
||||
|
||||
import
|
||||
|
||||
lua
|
||||
|
||||
const
|
||||
COLIBNAME* = "coroutine"
|
||||
@@ -45,30 +45,22 @@ proc open_debug*(L: PState): cint{.cdecl, dynlib: LIB_NAME,
|
||||
importc: "luaopen_debug".}
|
||||
proc open_package*(L: PState): cint{.cdecl, dynlib: LIB_NAME,
|
||||
importc: "luaopen_package".}
|
||||
proc L_openlibs*(L: PState){.cdecl, dynlib: LIB_NAME, importc: "luaL_openlibs".}
|
||||
# compatibility code
|
||||
proc baselibopen*(L: PState): Bool
|
||||
proc tablibopen*(L: PState): Bool
|
||||
proc iolibopen*(L: PState): Bool
|
||||
proc strlibopen*(L: PState): Bool
|
||||
proc mathlibopen*(L: PState): Bool
|
||||
proc dblibopen*(L: PState): Bool
|
||||
# implementation
|
||||
proc openlibs*(L: PState){.cdecl, dynlib: LIB_NAME, importc: "luaL_openlibs".}
|
||||
|
||||
proc baselibopen(L: PState): Bool =
|
||||
proc baselibopen*(L: PState): Bool =
|
||||
Result = open_base(L) != 0'i32
|
||||
|
||||
proc tablibopen(L: PState): Bool =
|
||||
proc tablibopen*(L: PState): Bool =
|
||||
Result = open_table(L) != 0'i32
|
||||
|
||||
proc iolibopen(L: PState): Bool =
|
||||
proc iolibopen*(L: PState): Bool =
|
||||
Result = open_io(L) != 0'i32
|
||||
|
||||
proc strlibopen(L: PState): Bool =
|
||||
proc strlibopen*(L: PState): Bool =
|
||||
Result = open_string(L) != 0'i32
|
||||
|
||||
proc mathlibopen(L: PState): Bool =
|
||||
proc mathlibopen*(L: PState): Bool =
|
||||
Result = open_math(L) != 0'i32
|
||||
|
||||
proc dblibopen(L: PState): Bool =
|
||||
proc dblibopen*(L: PState): Bool =
|
||||
Result = open_debug(L) != 0'i32
|
||||
|
||||
Reference in New Issue
Block a user