8#include <condition_variable>
114 std::size_t max_result_bytes = 1024 * 1024);
131 enum class RequestState { queued, running, finished };
135 std::size_t max_result_bytes = 0;
136 std::condition_variable cv;
137 RequestState
state = RequestState::queued;
138 bool timeout_requested =
false;
139 bool detach_requested =
false;
140 bool interrupt_requested =
false;
141 bool interrupt_consumed =
false;
142 bool evaluation_finished =
false;
144 ScriptEngine* engine =
nullptr;
145 bool can_interrupt =
false;
150 bool interrupt_window_open =
false;
157 EvalResult serialize_eval(ScriptEngine* engine,
const std::string& code,
158 std::size_t max_result_bytes)
const;
161 EvalResult run_claimed_request(
const std::shared_ptr<Request>& request,
162 ScriptEngine* engine);
167 void finish_locked(
const std::shared_ptr<Request>& request, EvalResult result);
171 static bool interrupt_if_active_locked(
const std::shared_ptr<Request>& request);
177 void apply_realm_gate_locked();
179 mutable std::mutex mutex_;
180 std::condition_variable state_cv_;
186 std::thread::id engine_thread_{};
187 bool have_engine_thread_ =
false;
188 bool in_flight_ =
false;
193 bool reset_pending_ =
false;
194 bool reset_in_progress_ =
false;
195 std::thread::id reset_thread_{};
196 std::shared_ptr<Request> pending_;
197 std::shared_ptr<Request> running_;
A granted-capability set.
Definition reload_capabilities.hpp:74
Definition script_engine.hpp:22
Definition script_inspector_bridge.hpp:37
ScriptInspectorBridge(const ScriptInspectorBridge &)=delete
bool pump() override
Run at most one queued request. True when it changed realm state.
bool post_evaluation_reset_pending() const
void set_post_evaluation_reset(std::function< std::string(EvaluationDeadline)> reset) override
Install the realm reset a completed evaluation owes.
ScriptInspectorBridge & operator=(const ScriptInspectorBridge &)=delete
friend struct ScriptInspectorBridgeTestAccess
Definition script_inspector_bridge.hpp:173
~ScriptInspectorBridge() override
static constexpr std::chrono::milliseconds kDefaultTimeout
Definition script_inspector_bridge.hpp:68
void set_realm_capabilities(const CapabilitySet &granted) override
Tell the port which native capabilities the realm it is about to be attached to holds.
ScriptInspectorBridge()=default
std::string run_pending_post_evaluation_reset() override
Run the owed reset if one is pending.
void detach() override
Release the engine; a blocked off-thread request wakes as detached.
EvalResult evaluate(const std::string &code, std::chrono::milliseconds timeout=kDefaultTimeout, std::size_t max_result_bytes=1024 *1024)
void attach(ScriptEngine *engine) override
Point the port at engine, or at none with nullptr.
Capabilities capabilities() const
The engine-thread half of a runtime inspector, as ScriptedUiSession drives it.
Definition script_inspector_port.hpp:22
std::chrono::steady_clock::time_point EvaluationDeadline
Definition script_inspector_port.hpp:24
Definition scripted_ui.hpp:125
SequencerStateChannel is the audio-safe transport for a plugin's structured NON-parameter state: the ...
Definition audio_device_manager.hpp:48
Hover-cursor tracking for platform window hosts.
Definition fwd.hpp:27
void install_script_inspector_bridge() noexcept
Make every ScriptedUiSession constructed afterwards carry a ScriptInspectorBridge as its inspector po...
ScriptInspectorBridge * script_inspector(ScriptedUiSession &session) noexcept
The session's ScriptInspectorBridge, or nullptr when the session was built without one (install_scrip...
Definition script_inspector_bridge.hpp:52
bool can_break
source-line breakpoints (never on mainline QuickJS)
Definition script_inspector_bridge.hpp:56
bool can_inspect_locals
paused local-scope inspection
Definition script_inspector_bridge.hpp:58
bool can_interrupt
a runaway eval can be aborted
Definition script_inspector_bridge.hpp:55
std::string refused_capability
Wire name of the first effectful capability the realm's EXPLICIT grant holds, empty when evaluation i...
Definition script_inspector_bridge.hpp:65
std::string engine
"QuickJS" / "JavaScriptCore" / "V8" / ""
Definition script_inspector_bridge.hpp:53
bool can_evaluate
bounded Runtime.evaluate is available
Definition script_inspector_bridge.hpp:54
bool can_step
step in/over/out
Definition script_inspector_bridge.hpp:57
Definition script_inspector_bridge.hpp:39
bool timed_out
the request exceeded its deadline
Definition script_inspector_bridge.hpp:41
bool detached
no engine is attached
Definition script_inspector_bridge.hpp:43
bool refused
the realm's explicit grant holds an effectful capability
Definition script_inspector_bridge.hpp:44
bool busy
another evaluation was already in flight
Definition script_inspector_bridge.hpp:42
bool ok
evaluation completed without throwing
Definition script_inspector_bridge.hpp:40
std::string error
message when !ok (exception text / reason)
Definition script_inspector_bridge.hpp:46
std::string json
result serialized as JSON when ok
Definition script_inspector_bridge.hpp:45