mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-21 02:22:51 +00:00
HackStudio: Implement custom JS -> C++ "proxy" objects
This patch adds a custom JS Object type that will convert written properties to their C++ equivalents, reflecting JS writes back to the debugging session. This is better than a simple proxy because printing this custom object works as expected because properties still exist on the object as existing handlers expect.
This commit is contained in:
parent
60d329a186
commit
4f2c0e9968
Notes:
sideshowbarker
2024-07-18 19:06:09 +09:00
Author: https://github.com/FalseHonesty
Commit: 4f2c0e9968
Pull-request: https://github.com/SerenityOS/serenity/pull/6285
Reviewed-by: https://github.com/itamar8910 ✅
Reviewed-by: https://github.com/linusg
5 changed files with 111 additions and 36 deletions
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Matthew Olsson <matthewcolsson@gmail.com>
|
||||
* Copyright (c) 2021, Hunter Salyer <thefalsehonesty@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "DebuggerGlobalJSObject.h"
|
||||
#include <LibDebug/DebugInfo.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
|
||||
namespace HackStudio {
|
||||
|
||||
class DebuggerVariableJSObject final : public JS::Object {
|
||||
JS_OBJECT(DebuggerVariableJSObject, JS::Object);
|
||||
|
||||
public:
|
||||
static DebuggerVariableJSObject* create(DebuggerGlobalJSObject&, const Debug::DebugInfo::VariableInfo& variable_info);
|
||||
|
||||
DebuggerVariableJSObject(const Debug::DebugInfo::VariableInfo& variable_info, JS::Object& prototype);
|
||||
virtual ~DebuggerVariableJSObject() override;
|
||||
|
||||
virtual bool put(const JS::PropertyName& name, JS::Value value, JS::Value) override;
|
||||
void finish_writing_properties() { m_is_writing_properties = false; }
|
||||
|
||||
private:
|
||||
DebuggerGlobalJSObject& debugger_object() const;
|
||||
|
||||
const Debug::DebugInfo::VariableInfo& m_variable_info;
|
||||
bool m_is_writing_properties { true };
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue