mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:27:43 +00:00
LibJS: Make native function/property callbacks take VM, not Interpreter
More work on decoupling the general runtime from Interpreter. The goal is becoming clearer. Interpreter should be one possible way to execute code inside a VM. In the future we might have other ways :^)
This commit is contained in:
parent
1ff9d33131
commit
340a115dfe
64 changed files with 1160 additions and 1114 deletions
|
@ -62,14 +62,14 @@ LocationObject::~LocationObject()
|
|||
JS_DEFINE_NATIVE_GETTER(LocationObject::href_getter)
|
||||
{
|
||||
auto& window = static_cast<WindowObject&>(global_object);
|
||||
return JS::js_string(interpreter, window.impl().document().url().to_string());
|
||||
return JS::js_string(vm, window.impl().document().url().to_string());
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_SETTER(LocationObject::href_setter)
|
||||
{
|
||||
auto& window = static_cast<WindowObject&>(global_object);
|
||||
auto new_href = value.to_string(interpreter);
|
||||
if (interpreter.exception())
|
||||
auto new_href = value.to_string(global_object);
|
||||
if (vm.exception())
|
||||
return;
|
||||
window.impl().did_set_location_href({}, new_href);
|
||||
}
|
||||
|
@ -77,13 +77,13 @@ JS_DEFINE_NATIVE_SETTER(LocationObject::href_setter)
|
|||
JS_DEFINE_NATIVE_GETTER(LocationObject::pathname_getter)
|
||||
{
|
||||
auto& window = static_cast<WindowObject&>(global_object);
|
||||
return JS::js_string(interpreter, window.impl().document().url().path());
|
||||
return JS::js_string(vm, window.impl().document().url().path());
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_GETTER(LocationObject::hostname_getter)
|
||||
{
|
||||
auto& window = static_cast<WindowObject&>(global_object);
|
||||
return JS::js_string(interpreter, window.impl().document().url().host());
|
||||
return JS::js_string(vm, window.impl().document().url().host());
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_GETTER(LocationObject::host_getter)
|
||||
|
@ -94,7 +94,7 @@ JS_DEFINE_NATIVE_GETTER(LocationObject::host_getter)
|
|||
builder.append(url.host());
|
||||
builder.append(':');
|
||||
builder.appendf("%u", url.port());
|
||||
return JS::js_string(interpreter, builder.to_string());
|
||||
return JS::js_string(vm, builder.to_string());
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_GETTER(LocationObject::hash_getter)
|
||||
|
@ -102,11 +102,11 @@ JS_DEFINE_NATIVE_GETTER(LocationObject::hash_getter)
|
|||
auto& window = static_cast<WindowObject&>(global_object);
|
||||
auto fragment = window.impl().document().url().fragment();
|
||||
if (!fragment.length())
|
||||
return JS::js_string(interpreter, "");
|
||||
return JS::js_string(vm, "");
|
||||
StringBuilder builder;
|
||||
builder.append('#');
|
||||
builder.append(fragment);
|
||||
return JS::js_string(interpreter, builder.to_string());
|
||||
return JS::js_string(vm, builder.to_string());
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_GETTER(LocationObject::search_getter)
|
||||
|
@ -114,11 +114,11 @@ JS_DEFINE_NATIVE_GETTER(LocationObject::search_getter)
|
|||
auto& window = static_cast<WindowObject&>(global_object);
|
||||
auto query = window.impl().document().url().query();
|
||||
if (!query.length())
|
||||
return JS::js_string(interpreter, "");
|
||||
return JS::js_string(vm, "");
|
||||
StringBuilder builder;
|
||||
builder.append('?');
|
||||
builder.append(query);
|
||||
return JS::js_string(interpreter, builder.to_string());
|
||||
return JS::js_string(vm, builder.to_string());
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_GETTER(LocationObject::protocol_getter)
|
||||
|
@ -127,7 +127,7 @@ JS_DEFINE_NATIVE_GETTER(LocationObject::protocol_getter)
|
|||
StringBuilder builder;
|
||||
builder.append(window.impl().document().url().protocol());
|
||||
builder.append(':');
|
||||
return JS::js_string(interpreter, builder.to_string());
|
||||
return JS::js_string(vm, builder.to_string());
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(LocationObject::reload)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue