summaryrefslogtreecommitdiff
path: root/core/script_language.cpp
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2020-02-27 03:30:20 +0100
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2020-03-08 12:36:39 +0100
commitb8ddaf9c33107e01928e04ed462aa08d4017247b (patch)
tree6ab71cdcbfd372e8390baa6ac30a2974fe43d119 /core/script_language.cpp
parentd0009636df6544dd26ab7c568a0244af6a20634a (diff)
Refactor ScriptDebugger.
EngineDebugger is the new interface to access the debugger. It tries to be as agnostic as possible on the data that various subsystems can expose. It allows 2 types of interactions: - Profilers: A subsystem can register a profiler, assigning it a unique name. That name can be used to activate the profiler or add data to it. The registered profiler can be composed of up to 3 functions: - Toggle: called when the profiler is activated/deactivated. - Add: called whenever data is added to the debugger (via `EngineDebugger::profiler_add_frame_data`) - Tick: called every frame (during idle), receives frame times. - Captures: (Only relevant in remote debugger for now) A subsystem can register a capture, assigning it a unique name. When receiving a message, the remote debugger will check if it starts with `[prefix]:` and call the associated capture with name `prefix`. Port MultiplayerAPI, Servers, Scripts, Visual, Performance to the new profiler system. Port SceneDebugger and RemoteDebugger to the new capture system. The LocalDebugger also uses the new profiler system for scripts profiling.
Diffstat (limited to 'core/script_language.cpp')
-rw-r--r--core/script_language.cpp89
1 files changed, 4 insertions, 85 deletions
diff --git a/core/script_language.cpp b/core/script_language.cpp
index 0b00247502..428f363b17 100644
--- a/core/script_language.cpp
+++ b/core/script_language.cpp
@@ -31,6 +31,8 @@
#include "script_language.h"
#include "core/core_string_names.h"
+#include "core/debugger/engine_debugger.h"
+#include "core/debugger/script_debugger.h"
#include "core/project_settings.h"
#include <stdint.h>
@@ -46,8 +48,8 @@ void Script::_notification(int p_what) {
if (p_what == NOTIFICATION_POSTINITIALIZE) {
- if (ScriptDebugger::get_singleton())
- ScriptDebugger::get_singleton()->set_break_language(get_language());
+ if (EngineDebugger::is_active())
+ EngineDebugger::get_script_debugger()->set_break_language(get_language());
}
}
@@ -356,89 +358,6 @@ ScriptCodeCompletionCache::ScriptCodeCompletionCache() {
void ScriptLanguage::frame() {
}
-ScriptDebugger *ScriptDebugger::singleton = NULL;
-
-void ScriptDebugger::set_lines_left(int p_left) {
-
- lines_left = p_left;
-}
-
-int ScriptDebugger::get_lines_left() const {
-
- return lines_left;
-}
-
-void ScriptDebugger::set_depth(int p_depth) {
-
- depth = p_depth;
-}
-
-int ScriptDebugger::get_depth() const {
-
- return depth;
-}
-
-void ScriptDebugger::insert_breakpoint(int p_line, const StringName &p_source) {
-
- if (!breakpoints.has(p_line))
- breakpoints[p_line] = Set<StringName>();
- breakpoints[p_line].insert(p_source);
-}
-
-void ScriptDebugger::remove_breakpoint(int p_line, const StringName &p_source) {
-
- if (!breakpoints.has(p_line))
- return;
-
- breakpoints[p_line].erase(p_source);
- if (breakpoints[p_line].size() == 0)
- breakpoints.erase(p_line);
-}
-bool ScriptDebugger::is_breakpoint(int p_line, const StringName &p_source) const {
-
- if (!breakpoints.has(p_line))
- return false;
- return breakpoints[p_line].has(p_source);
-}
-bool ScriptDebugger::is_breakpoint_line(int p_line) const {
-
- return breakpoints.has(p_line);
-}
-
-String ScriptDebugger::breakpoint_find_source(const String &p_source) const {
-
- return p_source;
-}
-
-void ScriptDebugger::clear_breakpoints() {
-
- breakpoints.clear();
-}
-
-void ScriptDebugger::idle_poll() {
-}
-
-void ScriptDebugger::line_poll() {
-}
-
-void ScriptDebugger::set_break_language(ScriptLanguage *p_lang) {
-
- break_lang = p_lang;
-}
-
-ScriptLanguage *ScriptDebugger::get_break_language() const {
-
- return break_lang;
-}
-
-ScriptDebugger::ScriptDebugger() {
-
- singleton = this;
- lines_left = -1;
- depth = -1;
- break_lang = NULL;
-}
-
bool PlaceHolderScriptInstance::set(const StringName &p_name, const Variant &p_value) {
if (script->is_placeholder_fallback_enabled())