Merge branch 'master' of https://github.com/WilliamVenner/gmod-rs
This commit is contained in:
commit
7ed864a789
|
@ -75,6 +75,7 @@ lazy_static::lazy_static! {
|
||||||
pub(crate) struct LuaShared {
|
pub(crate) struct LuaShared {
|
||||||
pub lual_loadfile: Symbol<'static, unsafe extern "C-unwind" fn(state: LuaState, path: LuaString) -> i32>,
|
pub lual_loadfile: Symbol<'static, unsafe extern "C-unwind" fn(state: LuaState, path: LuaString) -> i32>,
|
||||||
pub lual_loadstring: Symbol<'static, unsafe extern "C-unwind" fn(state: LuaState, path: LuaString) -> i32>,
|
pub lual_loadstring: Symbol<'static, unsafe extern "C-unwind" fn(state: LuaState, path: LuaString) -> i32>,
|
||||||
|
pub lual_loadbuffer: Symbol<'static, unsafe extern "C-unwind" fn(state: LuaState, buff: LuaString, sz: LuaSize, name: LuaString) -> i32>,
|
||||||
pub lua_getfield: Symbol<'static, unsafe extern "C-unwind" fn(state: LuaState, index: i32, k: LuaString)>,
|
pub lua_getfield: Symbol<'static, unsafe extern "C-unwind" fn(state: LuaState, index: i32, k: LuaString)>,
|
||||||
pub lua_pushvalue: Symbol<'static, unsafe extern "C-unwind" fn(state: LuaState, index: i32)>,
|
pub lua_pushvalue: Symbol<'static, unsafe extern "C-unwind" fn(state: LuaState, index: i32)>,
|
||||||
pub lua_pushboolean: Symbol<'static, unsafe extern "C-unwind" fn(state: LuaState, bool: i32)>,
|
pub lua_pushboolean: Symbol<'static, unsafe extern "C-unwind" fn(state: LuaState, bool: i32)>,
|
||||||
|
@ -134,6 +135,7 @@ impl LuaShared {
|
||||||
Self {
|
Self {
|
||||||
lual_loadfile: find_symbol!("luaL_loadfile"),
|
lual_loadfile: find_symbol!("luaL_loadfile"),
|
||||||
lual_loadstring: find_symbol!("luaL_loadstring"),
|
lual_loadstring: find_symbol!("luaL_loadstring"),
|
||||||
|
lual_loadbuffer: find_symbol!("luaL_loadbuffer"),
|
||||||
lua_getfield: find_symbol!("lua_getfield"),
|
lua_getfield: find_symbol!("lua_getfield"),
|
||||||
lua_pushvalue: find_symbol!("lua_pushvalue"),
|
lua_pushvalue: find_symbol!("lua_pushvalue"),
|
||||||
lua_pushboolean: find_symbol!("lua_pushboolean"),
|
lua_pushboolean: find_symbol!("lua_pushboolean"),
|
||||||
|
|
|
@ -149,6 +149,15 @@ impl LuaState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub unsafe fn load_buffer(&self, buff: &[u8], name: LuaString) -> Result<(), LuaError> {
|
||||||
|
let lua_error_code = (LUA_SHARED.lual_loadbuffer)(*self, buff.as_ptr() as LuaString, buff.len(), name);
|
||||||
|
if lua_error_code == 0 {
|
||||||
|
Ok(())
|
||||||
|
} else {
|
||||||
|
Err(LuaError::from_lua_state(*self, lua_error_code))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub unsafe fn load_file(&self, path: LuaString) -> Result<(), LuaError> {
|
pub unsafe fn load_file(&self, path: LuaString) -> Result<(), LuaError> {
|
||||||
let lua_error_code = (LUA_SHARED.lual_loadfile)(*self, path);
|
let lua_error_code = (LUA_SHARED.lual_loadfile)(*self, path);
|
||||||
if lua_error_code == 0 {
|
if lua_error_code == 0 {
|
||||||
|
|
Loading…
Reference in New Issue