summaryrefslogtreecommitdiff
path: root/src/hook.rs
diff options
context:
space:
mode:
authorAlex Orlenko <zxteam@protonmail.com>2021-11-16 12:27:56 +0000
committerAlex Orlenko <zxteam@protonmail.com>2021-11-16 12:27:56 +0000
commit0e1be19cbb05cbd7bdaa27c3424f937bee97315b (patch)
treefe5ef1fd8eea176921865e2bc633d4c3472271b5 /src/hook.rs
parent0ef709672d4bcd9a5c96654424f596c658a81adb (diff)
downloadmlua-0e1be19cbb05cbd7bdaa27c3424f937bee97315b.zip
Move hook_proc under `Lua::set_hook` to use callback_error_ext
Diffstat (limited to 'src/hook.rs')
-rw-r--r--src/hook.rs19
1 files changed, 1 insertions, 18 deletions
diff --git a/src/hook.rs b/src/hook.rs
index dd9b5c6..ba2e507 100644
--- a/src/hook.rs
+++ b/src/hook.rs
@@ -3,9 +3,8 @@ use std::ffi::CStr;
use std::ops::{BitOr, BitOrAssign};
use std::os::raw::{c_char, c_int};
-use crate::ffi::{self, lua_Debug, lua_State};
+use crate::ffi::{self, lua_Debug};
use crate::lua::Lua;
-use crate::util::callback_error;
/// Contains information about currently executing Lua code.
///
@@ -283,22 +282,6 @@ impl BitOrAssign for HookTriggers {
}
}
-pub(crate) unsafe extern "C" fn hook_proc(state: *mut lua_State, ar: *mut lua_Debug) {
- callback_error(state, |_| {
- let lua = mlua_expect!(Lua::make_from_ptr(state), "cannot make Lua instance");
- let debug = Debug::new(&lua, ar);
- let hook_cb = mlua_expect!(lua.hook_callback(), "no hook callback set in hook_proc");
-
- #[allow(clippy::match_wild_err_arm)]
- match hook_cb.try_borrow_mut() {
- Ok(mut b) => (&mut *b)(&lua, debug),
- Err(_) => mlua_panic!("Lua should not allow hooks to be called within another hook"),
- }?;
-
- Ok(())
- })
-}
-
unsafe fn ptr_to_str<'a>(input: *const c_char) -> Option<&'a [u8]> {
if input.is_null() {
None