Expand description
§LuaJIT RS
luajit_rs
is a simple wrapper around the LuaJIT project, allowing it to
be called from Rust easily and with minimal overhead. Most functions in this
crate correspond directly to underlying Lua C API calls
§Examples
#[macro_use]
extern crate luajit;
use luajit::{c_int, State};
fn return_42(state: &mut State) -> c_int {
state.push(42);
1
}
pub fn main() {
let mut state = State::new();
state.open_libs();
state.do_string(r#"print("Hello world!")"#);
state.push(lua_fn!(return_42));
state.set_global("return_42");
state.do_string(r#"print(return_42())"#);
}
Re-exports§
pub use state::State;
pub use state::ThreadStatus;
pub use types::LuaFunction;
pub use types::LuaObject;
Modules§
Macros§
- c_str
- lua_fn
- This macro is used to wrap a rust function in an
extern "C"
trampoline to automatically pass aState
struct as the first argument instead of alua_State
raw pointer - lua_
func - This macro can be used to automatically generate a
luaL_Reg
struct for the provided function, with namename
- lua_
method - This macro can be used to automatically generate a
luaL_Reg
struct for the provided method, with namename
. It automatically reads an instances of struct$st
from userdata and provides it as an argument.