diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2024-06-11 10:48:34 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-06-11 10:48:34 +0200 |
commit | 430812980c0419c69526ca2c8d1301d28c10ca09 (patch) | |
tree | dda235a0a5ab0abbd8c6aea6f96be9345d33eb14 /editor | |
parent | 5241d30bfa223ed45784e32d8143d20a98a8d862 (diff) | |
parent | 857734050157ec578565f9fe02720eb10e300815 (diff) | |
download | redot-engine-430812980c0419c69526ca2c8d1301d28c10ca09.tar.gz |
Merge pull request #86721 from Naros/gde-debugger-tooling
Improve GDExtension Tools Integration with Editor Debug Tooling
Diffstat (limited to 'editor')
-rw-r--r-- | editor/plugins/editor_debugger_plugin.cpp | 27 | ||||
-rw-r--r-- | editor/plugins/editor_debugger_plugin.h | 12 |
2 files changed, 38 insertions, 1 deletions
diff --git a/editor/plugins/editor_debugger_plugin.cpp b/editor/plugins/editor_debugger_plugin.cpp index c96bec6e7f..fbb389ccb4 100644 --- a/editor/plugins/editor_debugger_plugin.cpp +++ b/editor/plugins/editor_debugger_plugin.cpp @@ -56,6 +56,7 @@ void EditorDebuggerSession::_bind_methods() { ClassDB::bind_method(D_METHOD("is_active"), &EditorDebuggerSession::is_active); ClassDB::bind_method(D_METHOD("add_session_tab", "control"), &EditorDebuggerSession::add_session_tab); ClassDB::bind_method(D_METHOD("remove_session_tab", "control"), &EditorDebuggerSession::remove_session_tab); + ClassDB::bind_method(D_METHOD("set_breakpoint", "path", "line", "enabled"), &EditorDebuggerSession::set_breakpoint); ADD_SIGNAL(MethodInfo("started")); ADD_SIGNAL(MethodInfo("stopped")); @@ -100,6 +101,11 @@ bool EditorDebuggerSession::is_active() { return debugger->is_session_active(); } +void EditorDebuggerSession::set_breakpoint(const String &p_path, int p_line, bool p_enabled) { + ERR_FAIL_NULL_MSG(debugger, "Plugin is not attached to debugger."); + debugger->set_breakpoint(p_path, p_line, p_enabled); +} + void EditorDebuggerSession::detach_debugger() { if (!debugger) { return; @@ -184,10 +190,31 @@ bool EditorDebuggerPlugin::capture(const String &p_message, const Array &p_data, return false; } +void EditorDebuggerPlugin::goto_script_line(const Ref<Script> &p_script, int p_line) { + GDVIRTUAL_CALL(_goto_script_line, p_script, p_line); +} + +void EditorDebuggerPlugin::breakpoints_cleared_in_tree() { + GDVIRTUAL_CALL(_breakpoints_cleared_in_tree); +} + +void EditorDebuggerPlugin::breakpoint_set_in_tree(const Ref<Script> &p_script, int p_line, bool p_enabled) { + GDVIRTUAL_CALL(_breakpoint_set_in_tree, p_script, p_line, p_enabled); +} + void EditorDebuggerPlugin::_bind_methods() { GDVIRTUAL_BIND(_setup_session, "session_id"); GDVIRTUAL_BIND(_has_capture, "capture"); GDVIRTUAL_BIND(_capture, "message", "data", "session_id"); + GDVIRTUAL_BIND(_goto_script_line, "script", "line"); + GDVIRTUAL_BIND(_breakpoints_cleared_in_tree); + GDVIRTUAL_BIND(_breakpoint_set_in_tree, "script", "line", "enabled"); ClassDB::bind_method(D_METHOD("get_session", "id"), &EditorDebuggerPlugin::get_session); ClassDB::bind_method(D_METHOD("get_sessions"), &EditorDebuggerPlugin::get_sessions); } + +EditorDebuggerPlugin::EditorDebuggerPlugin() { + EditorDebuggerNode::get_singleton()->connect("goto_script_line", callable_mp(this, &EditorDebuggerPlugin::goto_script_line)); + EditorDebuggerNode::get_singleton()->connect("breakpoints_cleared_in_tree", callable_mp(this, &EditorDebuggerPlugin::breakpoints_cleared_in_tree)); + EditorDebuggerNode::get_singleton()->connect("breakpoint_set_in_tree", callable_mp(this, &EditorDebuggerPlugin::breakpoint_set_in_tree)); +} diff --git a/editor/plugins/editor_debugger_plugin.h b/editor/plugins/editor_debugger_plugin.h index 41f34f67cf..4f09824d03 100644 --- a/editor/plugins/editor_debugger_plugin.h +++ b/editor/plugins/editor_debugger_plugin.h @@ -62,6 +62,8 @@ public: bool is_debuggable(); bool is_active(); + void set_breakpoint(const String &p_path, int p_line, bool p_enabled); + EditorDebuggerSession(ScriptEditorDebugger *p_debugger); ~EditorDebuggerSession(); }; @@ -90,7 +92,15 @@ public: GDVIRTUAL1RC(bool, _has_capture, const String &); GDVIRTUAL1(_setup_session, int); - EditorDebuggerPlugin() {} + virtual void goto_script_line(const Ref<Script> &p_script, int p_line); + virtual void breakpoints_cleared_in_tree(); + virtual void breakpoint_set_in_tree(const Ref<Script> &p_script, int p_line, bool p_enabled); + + GDVIRTUAL2(_goto_script_line, const Ref<Script> &, int); + GDVIRTUAL0(_breakpoints_cleared_in_tree); + GDVIRTUAL3(_breakpoint_set_in_tree, const Ref<Script> &, int, bool); + + EditorDebuggerPlugin(); ~EditorDebuggerPlugin(); }; |