Change debugger init signature.
This commit is contained in:
@@ -349,7 +349,9 @@ impl Engine {
|
||||
#[inline(always)]
|
||||
pub fn register_debugger(
|
||||
&mut self,
|
||||
init: impl Fn(&Self) -> Dynamic + SendSync + 'static,
|
||||
init: impl Fn(&Self, crate::debugger::Debugger) -> crate::debugger::Debugger
|
||||
+ SendSync
|
||||
+ 'static,
|
||||
callback: impl Fn(
|
||||
EvalContext,
|
||||
crate::eval::DebuggerEvent,
|
||||
|
||||
@@ -604,7 +604,10 @@ fn main() {
|
||||
#[allow(deprecated)]
|
||||
engine.register_debugger(
|
||||
// Store the current source in the debugger state
|
||||
|_| "".into(),
|
||||
|engine, mut debugger| {
|
||||
debugger.set_state(engine.const_empty_string());
|
||||
debugger
|
||||
},
|
||||
// Main debugging interface
|
||||
move |context, event, node, source, pos| {
|
||||
debug_callback(context, event, node, source, pos, &lines)
|
||||
|
||||
@@ -10,10 +10,10 @@ use std::{fmt, iter::repeat, mem};
|
||||
|
||||
/// Callback function to initialize the debugger.
|
||||
#[cfg(not(feature = "sync"))]
|
||||
pub type OnDebuggingInit = dyn Fn(&Engine) -> Dynamic;
|
||||
pub type OnDebuggingInit = dyn Fn(&Engine, Debugger) -> Debugger;
|
||||
/// Callback function to initialize the debugger.
|
||||
#[cfg(feature = "sync")]
|
||||
pub type OnDebuggingInit = dyn Fn(&Engine) -> Dynamic + Send + Sync;
|
||||
pub type OnDebuggingInit = dyn Fn(&Engine, Debugger) -> Debugger + Send + Sync;
|
||||
|
||||
/// Callback function for debugging.
|
||||
#[cfg(not(feature = "sync"))]
|
||||
@@ -268,12 +268,12 @@ impl Debugger {
|
||||
/// Create a new [`Debugger`].
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub const fn new(status: DebuggerStatus, state: Dynamic) -> Self {
|
||||
pub const fn new(status: DebuggerStatus) -> Self {
|
||||
Self {
|
||||
status,
|
||||
break_points: Vec::new(),
|
||||
call_stack: Vec::new(),
|
||||
state,
|
||||
state: Dynamic::UNIT,
|
||||
}
|
||||
}
|
||||
/// Get the current call stack.
|
||||
|
||||
@@ -104,7 +104,8 @@ impl GlobalRuntimeState {
|
||||
|
||||
#[cfg(feature = "debugging")]
|
||||
debugger: engine.debugger.as_ref().map(|x| {
|
||||
crate::eval::Debugger::new(crate::eval::DebuggerStatus::Init, (x.0)(engine))
|
||||
let dbg = crate::eval::Debugger::new(crate::eval::DebuggerStatus::Init);
|
||||
(x.0)(engine, dbg)
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user