mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:07:36 +00:00
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:
parent
9661d15fe2
commit
b76456f0ed
2 changed files with 18 additions and 5 deletions
|
@ -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<>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue