| 1 | /**************************************************************************/ |
| 2 | /* editor_debugger_plugin.h */ |
| 3 | /**************************************************************************/ |
| 4 | /* This file is part of: */ |
| 5 | /* GODOT ENGINE */ |
| 6 | /* https://godotengine.org */ |
| 7 | /**************************************************************************/ |
| 8 | /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ |
| 9 | /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ |
| 10 | /* */ |
| 11 | /* Permission is hereby granted, free of charge, to any person obtaining */ |
| 12 | /* a copy of this software and associated documentation files (the */ |
| 13 | /* "Software"), to deal in the Software without restriction, including */ |
| 14 | /* without limitation the rights to use, copy, modify, merge, publish, */ |
| 15 | /* distribute, sublicense, and/or sell copies of the Software, and to */ |
| 16 | /* permit persons to whom the Software is furnished to do so, subject to */ |
| 17 | /* the following conditions: */ |
| 18 | /* */ |
| 19 | /* The above copyright notice and this permission notice shall be */ |
| 20 | /* included in all copies or substantial portions of the Software. */ |
| 21 | /* */ |
| 22 | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ |
| 23 | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ |
| 24 | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ |
| 25 | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ |
| 26 | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ |
| 27 | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ |
| 28 | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ |
| 29 | /**************************************************************************/ |
| 30 | |
| 31 | #ifndef EDITOR_DEBUGGER_PLUGIN_H |
| 32 | #define EDITOR_DEBUGGER_PLUGIN_H |
| 33 | |
| 34 | #include "scene/gui/control.h" |
| 35 | |
| 36 | class ScriptEditorDebugger; |
| 37 | |
| 38 | class EditorDebuggerSession : public RefCounted { |
| 39 | GDCLASS(EditorDebuggerSession, RefCounted); |
| 40 | |
| 41 | private: |
| 42 | HashSet<Control *> tabs; |
| 43 | |
| 44 | ScriptEditorDebugger *debugger = nullptr; |
| 45 | |
| 46 | void _breaked(bool p_really_did, bool p_can_debug, String p_message, bool p_has_stackdump); |
| 47 | void _started(); |
| 48 | void _stopped(); |
| 49 | void _debugger_gone_away(); |
| 50 | |
| 51 | protected: |
| 52 | static void _bind_methods(); |
| 53 | |
| 54 | public: |
| 55 | void detach_debugger(); |
| 56 | |
| 57 | void add_session_tab(Control *p_tab); |
| 58 | void remove_session_tab(Control *p_tab); |
| 59 | void send_message(const String &p_message, const Array &p_args = Array()); |
| 60 | void toggle_profiler(const String &p_profiler, bool p_enable, const Array &p_data = Array()); |
| 61 | bool is_breaked(); |
| 62 | bool is_debuggable(); |
| 63 | bool is_active(); |
| 64 | |
| 65 | EditorDebuggerSession(ScriptEditorDebugger *p_debugger); |
| 66 | ~EditorDebuggerSession(); |
| 67 | }; |
| 68 | |
| 69 | class EditorDebuggerPlugin : public RefCounted { |
| 70 | GDCLASS(EditorDebuggerPlugin, RefCounted); |
| 71 | |
| 72 | private: |
| 73 | List<Ref<EditorDebuggerSession>> sessions; |
| 74 | |
| 75 | protected: |
| 76 | static void _bind_methods(); |
| 77 | |
| 78 | public: |
| 79 | void create_session(ScriptEditorDebugger *p_debugger); |
| 80 | void clear(); |
| 81 | |
| 82 | virtual void setup_session(int p_idx); |
| 83 | virtual bool capture(const String &p_message, const Array &p_data, int p_session); |
| 84 | virtual bool has_capture(const String &p_capture) const; |
| 85 | |
| 86 | Ref<EditorDebuggerSession> get_session(int p_session_id); |
| 87 | Array get_sessions(); |
| 88 | |
| 89 | GDVIRTUAL3R(bool, _capture, const String &, const Array &, int); |
| 90 | GDVIRTUAL1RC(bool, _has_capture, const String &); |
| 91 | GDVIRTUAL1(_setup_session, int); |
| 92 | |
| 93 | EditorDebuggerPlugin() {} |
| 94 | ~EditorDebuggerPlugin(); |
| 95 | }; |
| 96 | |
| 97 | #endif // EDITOR_DEBUGGER_PLUGIN_H |
| 98 | |