2017-12-02 17:04:33 -05:00
|
|
|
macro_rules! cstr {
|
|
|
|
($s:expr) => (
|
|
|
|
concat!($s, "\0") as *const str as *const [c_char] as *const c_char
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// A panic that clears the given lua stack before panicking
|
|
|
|
macro_rules! lua_panic {
|
|
|
|
($state:expr, $msg:expr) => {
|
|
|
|
{
|
|
|
|
$crate::ffi::lua_settop($state, 0);
|
2018-02-07 17:05:00 -05:00
|
|
|
panic!($msg);
|
2017-12-02 17:04:33 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-02-07 17:05:00 -05:00
|
|
|
($state:expr, $msg:expr, $($arg:tt)+) => {
|
2017-12-02 17:04:33 -05:00
|
|
|
{
|
|
|
|
$crate::ffi::lua_settop($state, 0);
|
2018-02-07 17:05:00 -05:00
|
|
|
panic!($msg, $($arg)+);
|
2017-12-02 17:04:33 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
// An assert that clears the given lua stack before panicking
|
|
|
|
macro_rules! lua_assert {
|
2018-02-07 17:05:00 -05:00
|
|
|
($state:expr, $cond:expr, $msg:expr) => {
|
2017-12-02 17:04:33 -05:00
|
|
|
if !$cond {
|
|
|
|
$crate::ffi::lua_settop($state, 0);
|
2018-02-07 17:05:00 -05:00
|
|
|
panic!($msg);
|
2017-12-02 17:04:33 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-02-07 17:05:00 -05:00
|
|
|
($state:expr, $cond:expr, $msg:expr, $($arg:tt)+) => {
|
2017-12-02 17:04:33 -05:00
|
|
|
if !$cond {
|
|
|
|
$crate::ffi::lua_settop($state, 0);
|
2018-02-07 17:05:00 -05:00
|
|
|
panic!($msg, $($arg)+);
|
2017-12-02 17:04:33 -05:00
|
|
|
}
|
|
|
|
};
|
2018-02-07 17:05:00 -05:00
|
|
|
}
|
2017-12-02 17:04:33 -05:00
|
|
|
|
2018-02-07 17:05:00 -05:00
|
|
|
macro_rules! lua_internal_panic {
|
|
|
|
($state:expr, $msg:expr) => {
|
|
|
|
lua_panic!($state, concat!("rlua internal error: ", $msg));
|
|
|
|
};
|
|
|
|
|
|
|
|
($state:expr, $msg:expr, $($arg:tt)+) => {
|
|
|
|
lua_panic!($state, concat!("rlua internal error: ", $msg), $($arg)+);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! lua_internal_assert {
|
|
|
|
($state:expr, $cond:expr, $msg:expr) => {
|
|
|
|
lua_assert!($state, $cond, concat!("rlua internal error: ", $msg));
|
|
|
|
};
|
|
|
|
|
|
|
|
($state:expr, $cond:expr, $msg:expr, $($arg:tt)+) => {
|
|
|
|
lua_assert!($state, $cond, concat!("rlua internal error: ", $msg), $($arg)+);
|
2017-12-02 17:04:33 -05:00
|
|
|
};
|
|
|
|
}
|