@@ -6,9 +6,7 @@ pub mod globals;
66pub mod helpers;
77
88use types:: * ;
9- use globals:: {
10- LUA_GLOBALSINDEX
11- } ;
9+ use globals:: Lua ;
1210
1311use std:: path:: { Path , PathBuf } ;
1412extern crate dlopen;
@@ -24,9 +22,11 @@ pub struct LuaSharedInterface {
2422 pub luaL_loadbufferx : extern fn ( state : LuaState , code : CharBuf , size : SizeT , id : CharBuf , mode : CharBuf ) -> CInt ,
2523 pub luaL_loadbuffer : extern fn ( state : LuaState , code : CharBuf , size : SizeT , id : CharBuf ) -> CInt ,
2624 pub luaL_loadstring : extern fn ( state : LuaState , code : CharBuf ) -> CInt ,
25+
2726 pub lua_pcall : extern fn ( state : LuaState , nargs : CInt , nresults : CInt , msgh : CInt ) -> CInt ,
2827 pub lua_call : extern fn ( state : LuaState , nargs : CInt , nresults : CInt ) -> CInt ,
2928 pub lua_cpcall : extern fn ( state : LuaState , func : LuaCFunction , userdata : * mut CVoid ) -> CInt ,
29+ pub luaL_callmeta : extern fn ( state : LuaState , obj : CInt , name : CharBuf ) -> CInt ,
3030
3131 // Setters
3232 pub lua_setfield : extern fn ( state : LuaState , idx : CInt , name : CharBuf ) ,
@@ -41,11 +41,17 @@ pub struct LuaSharedInterface {
4141 pub lua_getfield : extern fn ( state : LuaState , idx : CInt , key : CharBuf ) ,
4242 pub lua_getupvalue : extern fn ( state : LuaState , fidx : CInt , idx : CInt ) -> CharBuf ,
4343 pub lua_type : extern fn ( state : LuaState , idx : CInt ) -> CInt ,
44+ pub lua_typename : extern fn ( state : LuaState , typeid : CInt ) -> CharBuf , // To be used with the return value of lua_type
4445
4546 // Getters (with "to")
4647 pub lua_tolstring : extern fn ( state : LuaState , ind : CInt , size : SizeT ) -> CharBuf ,
4748 pub lua_toboolean : extern fn ( state : LuaState , idx : CInt ) -> CInt ,
4849 pub lua_tocfunction : extern fn ( state : LuaState , idx : CInt ) -> LuaCFunction ,
50+ pub lua_tointeger : extern fn ( state : LuaState , idx : CInt ) -> LuaInteger ,
51+ pub lua_tonumber : extern fn ( state : LuaState , idx : CInt ) -> LuaNumber ,
52+ pub lua_topointer : extern fn ( state : LuaState , idx : CInt ) -> * mut CVoid ,
53+ pub lua_tothread : extern fn ( state : LuaState , idx : CInt ) -> LuaState ,
54+ pub lua_touserdata : extern fn ( state : LuaState , idx : CInt ) -> * mut CVoid ,
4955
5056 // Push functions
5157 pub lua_pushstring : extern fn ( state : LuaState , s : CharBuf ) ,
@@ -55,12 +61,35 @@ pub struct LuaSharedInterface {
5561 pub lua_pushvalue : extern fn ( state : LuaState , idx : CInt ) ,
5662 pub lua_pushcclosure : extern fn ( state : LuaState , fnc : LuaCFunction , idx : CInt ) ,
5763
64+ pub lua_checkstack : extern fn ( state : LuaState , size : CInt , msg : CharBuf ) ,
65+
66+ // Type Checks
67+ pub luaL_checkinteger : extern fn ( state : LuaState , narg : CInt ) -> LuaInteger ,
68+ pub luaL_checknumber : extern fn ( state : LuaState , narg : CInt ) -> LuaNumber ,
69+ pub luaL_checkstring : extern fn ( state : LuaState , narg : CInt ) -> CharBuf ,
70+ pub luaL_checklstring : extern fn ( state : LuaState , narg : CInt ) -> CharBuf ,
71+ pub luaL_checklong : extern fn ( state : LuaState , narg : CInt ) -> CLong ,
72+
73+ // Type Checks that return nothing
74+ pub luaL_checkany : extern fn ( state : LuaState , narg : CInt ) ,
75+ pub luaL_checktype : extern fn ( state : LuaState , narg : CInt , typeid : CInt ) ,
76+ pub luaL_checkudata : extern fn ( state : LuaState , narg : CInt , len : SizeT ) ,
77+ pub luaL_argcheck : extern fn ( state : LuaState , cond : CInt , narg : CInt , msg : CharBuf ) ,
78+
5879 // Creation
5980 pub luaL_newstate : extern fn ( ) -> LuaState ,
6081 pub lua_createtable : extern fn ( state : LuaState , narr : CInt , nrec : CInt ) ,
6182
62- // Raise Errors
63- pub luaL_typerror : extern fn ( state : LuaState , narg : CInt , typename : CharBuf ) -> CInt
83+ // JIT
84+ // Returns 1 for success, 0 for failure
85+ pub luaJIT_setmode : extern fn ( state : LuaState , idx : CInt , jit_mode : CInt ) -> CInt ,
86+
87+ // Coroutines / Yielding
88+ pub lua_yield : extern fn ( state : LuaState , nresults : CInt ) -> CInt ,
89+ pub lua_status : extern fn ( state : LuaState ) -> CInt ,
90+
91+ // Raising Errors
92+ pub luaL_typerror : extern fn ( state : LuaState , narg : CInt , typename : CharBuf ) -> CInt ,
6493}
6594
6695// C++ Macros & Custom Functions
@@ -70,20 +99,24 @@ impl LuaSharedInterface {
7099 }
71100
72101 pub fn lua_isboolean ( & self , state : LuaState , ind : CInt ) -> bool {
73- self . lua_type ( state, ind) == luatypes :: BOOL
102+ self . lua_type ( state, ind) == Lua :: Type :: Bool as i32
74103 }
75104
76105 pub fn lua_setglobal ( & self , state : LuaState , name : CharBuf ) {
77- self . lua_setfield ( state, LUA_GLOBALSINDEX , name) ;
106+ self . lua_setfield ( state, Lua :: GLOBALSINDEX , name) ;
78107 }
79108
80109 pub fn lua_getglobal ( & self , state : LuaState , name : CharBuf ) {
81- self . lua_getfield ( state, LUA_GLOBALSINDEX , name) ;
110+ self . lua_getfield ( state, Lua :: GLOBALSINDEX , name) ;
82111 }
83112
84113 pub fn lua_pushcfunction ( & self , state : LuaState , fnc : LuaCFunction ) {
85114 self . lua_pushcclosure ( state, fnc, 0 ) ;
86115 }
116+
117+ pub fn lua_tostring ( & self , state : LuaState , idx : CInt ) -> CharBuf {
118+ self . lua_tolstring ( state, idx, 0 )
119+ }
87120}
88121
89122// Global Static Stuff
0 commit comments