mirror of
https://github.com/mlua-rs/mlua
synced 2026-06-08 16:05:43 +00:00
Can.. can I do this? Is this a thing that actually works?
Drastic times and all that.
This commit is contained in:
+1
-1
@@ -122,7 +122,7 @@ impl<'lua> Function<'lua> {
|
||||
/// # }
|
||||
/// ```
|
||||
pub fn bind<A: ToLuaMulti<'lua>>(&self, args: A) -> Result<Function<'lua>> {
|
||||
#[cfg_attr(feature = "unwind", unwind)]
|
||||
#[cfg_attr(unwind, unwind)]
|
||||
unsafe extern "C" fn bind_call_impl(state: *mut ffi::lua_State) -> c_int {
|
||||
let nargs = ffi::lua_gettop(state);
|
||||
let nbinds = ffi::lua_tointeger(state, ffi::lua_upvalueindex(2)) as c_int;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
#![cfg_attr(feature = "unwind", feature(unwind_attributes))]
|
||||
#![cfg_attr(unwind, feature(unwind_attributes))]
|
||||
|
||||
//! # High-level bindings to Lua
|
||||
//!
|
||||
|
||||
+2
-2
@@ -759,7 +759,7 @@ impl Lua {
|
||||
pub(crate) unsafe fn userdata_metatable<T: UserData>(&self) -> Result<c_int> {
|
||||
// Used if both an __index metamethod is set and regular methods, checks methods table
|
||||
// first, then __index metamethod.
|
||||
#[cfg_attr(feature = "unwind", unwind)]
|
||||
#[cfg_attr(unwind, unwind)]
|
||||
unsafe extern "C" fn meta_index_impl(state: *mut ffi::lua_State) -> c_int {
|
||||
ffi::luaL_checkstack(state, 2, ptr::null());
|
||||
|
||||
@@ -995,7 +995,7 @@ impl Lua {
|
||||
&'lua self,
|
||||
func: Callback<'callback, 'static>,
|
||||
) -> Result<Function<'lua>> {
|
||||
#[cfg_attr(feature = "unwind", unwind)]
|
||||
#[cfg_attr(unwind, unwind)]
|
||||
unsafe extern "C" fn callback_call_impl(state: *mut ffi::lua_State) -> c_int {
|
||||
callback_error(state, || {
|
||||
let lua = Lua {
|
||||
|
||||
+8
-8
@@ -121,7 +121,7 @@ where
|
||||
nresults: c_int,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "unwind", unwind)]
|
||||
#[cfg_attr(unwind, unwind)]
|
||||
unsafe extern "C" fn do_call<F, R>(state: *mut ffi::lua_State) -> c_int
|
||||
where
|
||||
F: FnOnce(*mut ffi::lua_State) -> R,
|
||||
@@ -272,7 +272,7 @@ pub unsafe fn take_userdata<T>(state: *mut ffi::lua_State) -> T {
|
||||
ptr::read(ud)
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "unwind", unwind)]
|
||||
#[cfg_attr(unwind, unwind)]
|
||||
pub unsafe extern "C" fn userdata_destructor<T>(state: *mut ffi::lua_State) -> c_int {
|
||||
callback_error(state, || {
|
||||
take_userdata::<T>(state);
|
||||
@@ -306,7 +306,7 @@ where
|
||||
// Takes an error at the top of the stack, and if it is a WrappedError, converts it to an
|
||||
// Error::CallbackError with a traceback, if it is some lua type, prints the error along with a
|
||||
// traceback, and if it is a WrappedPanic, does not modify it.
|
||||
#[cfg_attr(feature = "unwind", unwind)]
|
||||
#[cfg_attr(unwind, unwind)]
|
||||
pub unsafe extern "C" fn error_traceback(state: *mut ffi::lua_State) -> c_int {
|
||||
ffi::luaL_checkstack(state, 2, ptr::null());
|
||||
|
||||
@@ -337,7 +337,7 @@ pub unsafe extern "C" fn error_traceback(state: *mut ffi::lua_State) -> c_int {
|
||||
}
|
||||
|
||||
// A variant of pcall that does not allow lua to catch panic errors from callback_error
|
||||
#[cfg_attr(feature = "unwind", unwind)]
|
||||
#[cfg_attr(unwind, unwind)]
|
||||
pub unsafe extern "C" fn safe_pcall(state: *mut ffi::lua_State) -> c_int {
|
||||
ffi::luaL_checkstack(state, 2, ptr::null());
|
||||
|
||||
@@ -360,9 +360,9 @@ pub unsafe extern "C" fn safe_pcall(state: *mut ffi::lua_State) -> c_int {
|
||||
}
|
||||
|
||||
// A variant of xpcall that does not allow lua to catch panic errors from callback_error
|
||||
#[cfg_attr(feature = "unwind", unwind)]
|
||||
#[cfg_attr(unwind, unwind)]
|
||||
pub unsafe extern "C" fn safe_xpcall(state: *mut ffi::lua_State) -> c_int {
|
||||
#[cfg_attr(feature = "unwind", unwind)]
|
||||
#[cfg_attr(unwind, unwind)]
|
||||
unsafe extern "C" fn xpcall_msgh(state: *mut ffi::lua_State) -> c_int {
|
||||
ffi::luaL_checkstack(state, 2, ptr::null());
|
||||
|
||||
@@ -510,7 +510,7 @@ unsafe fn is_wrapped_panic(state: *mut ffi::lua_State, index: c_int) -> bool {
|
||||
unsafe fn get_error_metatable(state: *mut ffi::lua_State) -> c_int {
|
||||
static ERROR_METATABLE_REGISTRY_KEY: u8 = 0;
|
||||
|
||||
#[cfg_attr(feature = "unwind", unwind)]
|
||||
#[cfg_attr(unwind, unwind)]
|
||||
unsafe extern "C" fn error_tostring(state: *mut ffi::lua_State) -> c_int {
|
||||
ffi::luaL_checkstack(state, 2, ptr::null());
|
||||
|
||||
@@ -612,7 +612,7 @@ unsafe fn get_panic_metatable(state: *mut ffi::lua_State) -> c_int {
|
||||
unsafe fn get_destructed_userdata_metatable(state: *mut ffi::lua_State) -> c_int {
|
||||
static DESTRUCTED_USERDATA_METATABLE: u8 = 0;
|
||||
|
||||
#[cfg_attr(feature = "unwind", unwind)]
|
||||
#[cfg_attr(unwind, unwind)]
|
||||
unsafe extern "C" fn destructed_error(state: *mut ffi::lua_State) -> c_int {
|
||||
ffi::luaL_checkstack(state, 2, ptr::null());
|
||||
push_wrapped_error(state, Error::CallbackDestructed);
|
||||
|
||||
Reference in New Issue
Block a user