1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 03:57:44 +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:
Andreas Kling 2021-09-08 22:58:36 +02:00
parent 9661d15fe2
commit b76456f0ed
2 changed files with 18 additions and 5 deletions

View file

@ -28,13 +28,14 @@
namespace JS {
NonnullRefPtr<VM> VM::create()
NonnullRefPtr<VM> VM::create(OwnPtr<CustomData> custom_data)
{
return adopt_ref(*new VM);
return adopt_ref(*new VM(move(custom_data)));
}
VM::VM()
VM::VM(OwnPtr<CustomData> custom_data)
: m_heap(*this)
, m_custom_data(move(custom_data))
{
m_empty_string = m_heap.allocate_without_global_object<PrimitiveString>(String::empty());
for (size_t i = 0; i < 128; ++i) {
@ -773,4 +774,8 @@ void VM::dump_environment_chain() const
}
}
VM::CustomData::~CustomData()
{
}
}