LibJS: Add a way to attach custom data to a JS::VM instance

This will be used by LibWeb to attach web engine specific stuff that
LibJS doesn't need to know about.
This commit is contained in:
Andreas Kling 2021-09-08 22:58:36 +02:00
commit b76456f0ed
Notes: sideshowbarker 2024-07-18 04:24:48 +09:00
2 changed files with 18 additions and 5 deletions

View file

@ -61,7 +61,11 @@ struct ExecutionContext {
class VM : public RefCounted<VM> {
public:
static NonnullRefPtr<VM> create();
struct CustomData {
virtual ~CustomData();
};
static NonnullRefPtr<VM> create(OwnPtr<CustomData> = {});
~VM();
Heap& heap() { return m_heap; }
@ -272,8 +276,10 @@ public:
void initialize_instance_elements(Object& object, FunctionObject& constructor);
CustomData* custom_data() { return m_custom_data; }
private:
VM();
explicit VM(OwnPtr<CustomData>);
void ordinary_call_bind_this(FunctionObject&, ExecutionContext&, Value this_argument);
@ -310,6 +316,8 @@ private:
bool m_underscore_is_last_value { false };
u32 m_execution_generation { 0 };
OwnPtr<CustomData> m_custom_data;
};
template<>