macro_rules! lua_library {
{$(
$field:ident $(: $fn:expr)?
),*} => { ... };
(@field $field:ident $fn:expr) => { ... };
(@field $field:ident) => { ... };
}Expand description
Create a Library with a more understandable syntax.
The macro accepts a struct construction-like syntax, to construct an
instance from a static array of pairs of CStr and
Option<CFunction>, where a field with a value creates a pair
("name", Some(func_name)), and a field with no value specified creates a
pair ("name", None).
ยงExamples
use lunka::prelude::*;
unsafe extern "C-unwind" fn l_get_pi(l: *mut LuaState) -> core::ffi::c_int {
let lua = LuaThread::from_ptr(l);
lua.push_number(3.14);
1
}
// This will create a `LuaLibrary` that, when used with `Thread::set_funcs`,
// will set a table's field `get_pi` to the `l_get_pi` function, and `set_pi`
// to `false`.
let library = lua_library! {
get_pi: l_get_pi,
set_pi
};