mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
LibJS: Replace PropertyKey(char[]) with PropertyKey(FlyString)
...and deal with the fallout.
This commit is contained in:
parent
d7908dbff5
commit
53da8893ac
Notes:
github-actions[bot]
2025-03-24 22:28:43 +00:00
Author: https://github.com/awesomekling Commit: https://github.com/LadybirdBrowser/ladybird/commit/53da8893acb Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4067 Reviewed-by: https://github.com/trflynn89
55 changed files with 254 additions and 251 deletions
|
@ -193,16 +193,16 @@ ALWAYS_INLINE void Interpreter::set(Operand op, Value value)
|
|||
ALWAYS_INLINE Value Interpreter::do_yield(Value value, Optional<Label> continuation)
|
||||
{
|
||||
auto object = Object::create(realm(), nullptr);
|
||||
object->define_direct_property("result", value, JS::default_attributes);
|
||||
object->define_direct_property(m_vm.names.result, value, JS::default_attributes);
|
||||
|
||||
if (continuation.has_value())
|
||||
// FIXME: If we get a pointer, which is not accurately representable as a double
|
||||
// will cause this to explode
|
||||
object->define_direct_property("continuation", Value(continuation->address()), JS::default_attributes);
|
||||
object->define_direct_property(m_vm.names.continuation, Value(continuation->address()), JS::default_attributes);
|
||||
else
|
||||
object->define_direct_property("continuation", js_null(), JS::default_attributes);
|
||||
object->define_direct_property(m_vm.names.continuation, js_null(), JS::default_attributes);
|
||||
|
||||
object->define_direct_property("isAwait", Value(false), JS::default_attributes);
|
||||
object->define_direct_property(m_vm.names.isAwait, Value(false), JS::default_attributes);
|
||||
return object;
|
||||
}
|
||||
|
||||
|
@ -2842,13 +2842,14 @@ void PrepareYield::execute_impl(Bytecode::Interpreter& interpreter) const
|
|||
|
||||
void Await::execute_impl(Bytecode::Interpreter& interpreter) const
|
||||
{
|
||||
auto& vm = interpreter.vm();
|
||||
auto yielded_value = interpreter.get(m_argument).value_or(js_undefined());
|
||||
auto object = Object::create(interpreter.realm(), nullptr);
|
||||
object->define_direct_property("result", yielded_value, JS::default_attributes);
|
||||
object->define_direct_property(vm.names.result, yielded_value, JS::default_attributes);
|
||||
// FIXME: If we get a pointer, which is not accurately representable as a double
|
||||
// will cause this to explode
|
||||
object->define_direct_property("continuation", Value(m_continuation_label.address()), JS::default_attributes);
|
||||
object->define_direct_property("isAwait", Value(true), JS::default_attributes);
|
||||
object->define_direct_property(vm.names.continuation, Value(m_continuation_label.address()), JS::default_attributes);
|
||||
object->define_direct_property(vm.names.isAwait, Value(true), JS::default_attributes);
|
||||
interpreter.do_return(object);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,15 +36,15 @@ void $262Object::initialize(Realm& realm)
|
|||
m_is_htmldda = realm.create<IsHTMLDDA>(realm);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(realm, "clearKeptObjects", clear_kept_objects, 0, attr);
|
||||
define_native_function(realm, "createRealm", create_realm, 0, attr);
|
||||
define_native_function(realm, "detachArrayBuffer", detach_array_buffer, 1, attr);
|
||||
define_native_function(realm, "evalScript", eval_script, 1, attr);
|
||||
define_native_function(realm, "clearKeptObjects"_fly_string, clear_kept_objects, 0, attr);
|
||||
define_native_function(realm, "createRealm"_fly_string, create_realm, 0, attr);
|
||||
define_native_function(realm, "detachArrayBuffer"_fly_string, detach_array_buffer, 1, attr);
|
||||
define_native_function(realm, "evalScript"_fly_string, eval_script, 1, attr);
|
||||
|
||||
define_direct_property("agent", m_agent, attr);
|
||||
define_direct_property("gc", realm.global_object().get_without_side_effects("gc"), attr);
|
||||
define_direct_property("global", &realm.global_object(), attr);
|
||||
define_direct_property("IsHTMLDDA", m_is_htmldda, attr);
|
||||
define_direct_property("agent"_fly_string, m_agent, attr);
|
||||
define_direct_property("gc"_fly_string, realm.global_object().get_without_side_effects("gc"_fly_string), attr);
|
||||
define_direct_property("global"_fly_string, &realm.global_object(), attr);
|
||||
define_direct_property("IsHTMLDDA"_fly_string, m_is_htmldda, attr);
|
||||
}
|
||||
|
||||
void $262Object::visit_edges(Cell::Visitor& visitor)
|
||||
|
|
|
@ -24,8 +24,8 @@ void AgentObject::initialize(JS::Realm& realm)
|
|||
Base::initialize(realm);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(realm, "monotonicNow", monotonic_now, 0, attr);
|
||||
define_native_function(realm, "sleep", sleep, 1, attr);
|
||||
define_native_function(realm, "monotonicNow"_fly_string, monotonic_now, 0, attr);
|
||||
define_native_function(realm, "sleep"_fly_string, sleep, 1, attr);
|
||||
// TODO: broadcast
|
||||
// TODO: getReport
|
||||
// TODO: start
|
||||
|
|
|
@ -24,8 +24,8 @@ void GlobalObject::initialize(Realm& realm)
|
|||
|
||||
// https://github.com/tc39/test262/blob/master/INTERPRETING.md#host-defined-functions
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(realm, "print", print, 1, attr);
|
||||
define_direct_property("$262", m_$262, attr);
|
||||
define_native_function(realm, "print"_fly_string, print, 1, attr);
|
||||
define_direct_property("$262"_fly_string, m_$262, attr);
|
||||
}
|
||||
|
||||
void GlobalObject::visit_edges(Cell::Visitor& visitor)
|
||||
|
|
|
@ -611,7 +611,7 @@ void CyclicModule::execute_async_module(VM& vm)
|
|||
};
|
||||
|
||||
// 5. Let onFulfilled be CreateBuiltinFunction(fulfilledClosure, 0, "", « »).
|
||||
auto on_fulfilled = NativeFunction::create(realm, move(fulfilled_closure), 0, "");
|
||||
auto on_fulfilled = NativeFunction::create(realm, move(fulfilled_closure), 0);
|
||||
|
||||
// 6. Let rejectedClosure be a new Abstract Closure with parameters (error) that captures module and performs the following steps when called:
|
||||
auto rejected_closure = [&](VM& vm) -> ThrowCompletionOr<Value> {
|
||||
|
@ -625,7 +625,7 @@ void CyclicModule::execute_async_module(VM& vm)
|
|||
};
|
||||
|
||||
// 7. Let onRejected be CreateBuiltinFunction(rejectedClosure, 0, "", « »).
|
||||
auto on_rejected = NativeFunction::create(realm, move(rejected_closure), 0, "");
|
||||
auto on_rejected = NativeFunction::create(realm, move(rejected_closure), 0);
|
||||
|
||||
// 8. Perform PerformPromiseThen(capability.[[Promise]], onFulfilled, onRejected).
|
||||
as<Promise>(capability->promise().ptr())->perform_then(on_fulfilled, on_rejected, {});
|
||||
|
@ -863,7 +863,7 @@ void continue_dynamic_import(GC::Ref<PromiseCapability> promise_capability, Thro
|
|||
};
|
||||
|
||||
// 5. Let onRejected be CreateBuiltinFunction(rejectedClosure, 1, "", « »).
|
||||
auto on_rejected = NativeFunction::create(*vm.current_realm(), move(reject_closure), 1, "");
|
||||
auto on_rejected = NativeFunction::create(*vm.current_realm(), move(reject_closure), 1);
|
||||
|
||||
// 6. Let linkAndEvaluateClosure be a new Abstract Closure with no parameters that captures module, promiseCapability,
|
||||
// and onRejected and performs the following steps when called:
|
||||
|
@ -897,7 +897,7 @@ void continue_dynamic_import(GC::Ref<PromiseCapability> promise_capability, Thro
|
|||
};
|
||||
|
||||
// e. Let onFulfilled be CreateBuiltinFunction(fulfilledClosure, 0, "", « »).
|
||||
auto on_fulfilled = NativeFunction::create(*vm.current_realm(), move(fulfilled_closure), 0, "");
|
||||
auto on_fulfilled = NativeFunction::create(*vm.current_realm(), move(fulfilled_closure), 0);
|
||||
|
||||
// f. Perform PerformPromiseThen(evaluatePromise, onFulfilled, onRejected).
|
||||
evaluate_promise.value()->perform_then(on_fulfilled, on_rejected, {});
|
||||
|
@ -907,7 +907,7 @@ void continue_dynamic_import(GC::Ref<PromiseCapability> promise_capability, Thro
|
|||
};
|
||||
|
||||
// 7. Let linkAndEvaluate be CreateBuiltinFunction(linkAndEvaluateClosure, 0, "", « »).
|
||||
auto link_and_evaluate = NativeFunction::create(*vm.current_realm(), move(link_and_evaluate_closure), 0, "");
|
||||
auto link_and_evaluate = NativeFunction::create(*vm.current_realm(), move(link_and_evaluate_closure), 0);
|
||||
|
||||
// 8. Perform PerformPromiseThen(loadPromise, linkAndEvaluate, onRejected).
|
||||
// FIXME: This is likely a spec bug, see load_requested_modules.
|
||||
|
|
|
@ -233,7 +233,7 @@ ThrowCompletionOr<void> initialize_bound_name(VM& vm, DeprecatedFlyString const&
|
|||
bool is_compatible_property_descriptor(bool extensible, PropertyDescriptor const& descriptor, Optional<PropertyDescriptor> const& current)
|
||||
{
|
||||
// 1. Return ValidateAndApplyPropertyDescriptor(undefined, "", Extensible, Desc, Current).
|
||||
return validate_and_apply_property_descriptor(nullptr, "", extensible, descriptor, current);
|
||||
return validate_and_apply_property_descriptor(nullptr, FlyString {}, extensible, descriptor, current);
|
||||
}
|
||||
|
||||
// 10.1.6.3 ValidateAndApplyPropertyDescriptor ( O, P, extensible, Desc, current ), https://tc39.es/ecma262/#sec-validateandapplypropertydescriptor
|
||||
|
@ -1544,7 +1544,7 @@ ThrowCompletionOr<GC::Ptr<FunctionObject>> get_dispose_method(VM& vm, Value valu
|
|||
// thrown synchronously.
|
||||
|
||||
// 3. Return CreateBuiltinFunction(closure, 0, "", « »).
|
||||
return NativeFunction::create(realm, move(closure), 0, "");
|
||||
return NativeFunction::create(realm, move(closure), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ JS_DEFINE_NATIVE_FUNCTION(AsyncDisposableStackPrototype::adopt)
|
|||
};
|
||||
|
||||
// 6. Let F be CreateBuiltinFunction(closure, 0, "", « »).
|
||||
auto function = NativeFunction::create(realm, move(closure), 0, "");
|
||||
auto function = NativeFunction::create(realm, move(closure), 0);
|
||||
|
||||
// 7. Perform ? AddDisposableResource(asyncDisposableStack.[[DisposeCapability]], undefined, async-dispose, F).
|
||||
TRY(add_disposable_resource(vm, async_disposable_stack->dispose_capability(), js_undefined(), Environment::InitializeBindingHint::AsyncDispose, function));
|
||||
|
|
|
@ -58,7 +58,7 @@ static Object* async_from_sync_iterator_continuation(VM& vm, Object& result, Pro
|
|||
|
||||
// 9. Let onFulfilled be CreateBuiltinFunction(unwrap, 1, "", « »).
|
||||
// 10. NOTE: onFulfilled is used when processing the "value" property of an IteratorResult object in order to wait for its value if it is a promise and re-package the result in a new "unwrapped" IteratorResult object.
|
||||
auto on_fulfilled = NativeFunction::create(realm, move(unwrap), 1, "");
|
||||
auto on_fulfilled = NativeFunction::create(realm, move(unwrap), 1);
|
||||
|
||||
// 11. Perform PerformPromiseThen(valueWrapper, onFulfilled, undefined, promiseCapability).
|
||||
as<Promise>(value_wrapper)->perform_then(move(on_fulfilled), js_undefined(), &promise_capability);
|
||||
|
|
|
@ -75,7 +75,7 @@ ThrowCompletionOr<void> AsyncFunctionDriverWrapper::await(JS::Value value)
|
|||
};
|
||||
|
||||
// 4. Let onFulfilled be CreateBuiltinFunction(fulfilledClosure, 1, "", « »).
|
||||
auto on_fulfilled = NativeFunction::create(realm, move(fulfilled_closure), 1, "");
|
||||
auto on_fulfilled = NativeFunction::create(realm, move(fulfilled_closure), 1);
|
||||
|
||||
// 5. Let rejectedClosure be a new Abstract Closure with parameters (reason) that captures asyncContext and performs the
|
||||
// following steps when called:
|
||||
|
@ -103,7 +103,7 @@ ThrowCompletionOr<void> AsyncFunctionDriverWrapper::await(JS::Value value)
|
|||
};
|
||||
|
||||
// 6. Let onRejected be CreateBuiltinFunction(rejectedClosure, 1, "", « »).
|
||||
auto on_rejected = NativeFunction::create(realm, move(rejected_closure), 1, "");
|
||||
auto on_rejected = NativeFunction::create(realm, move(rejected_closure), 1);
|
||||
|
||||
// 7. Perform PerformPromiseThen(promise, onFulfilled, onRejected).
|
||||
m_current_promise = as<Promise>(promise_object);
|
||||
|
|
|
@ -104,7 +104,7 @@ ThrowCompletionOr<void> AsyncGenerator::await(Value value)
|
|||
};
|
||||
|
||||
// 4. Let onFulfilled be CreateBuiltinFunction(fulfilledClosure, 1, "", « »).
|
||||
auto on_fulfilled = NativeFunction::create(realm, move(fulfilled_closure), 1, "");
|
||||
auto on_fulfilled = NativeFunction::create(realm, move(fulfilled_closure), 1);
|
||||
|
||||
// 5. Let rejectedClosure be a new Abstract Closure with parameters (reason) that captures asyncContext and performs the
|
||||
// following steps when called:
|
||||
|
@ -131,7 +131,7 @@ ThrowCompletionOr<void> AsyncGenerator::await(Value value)
|
|||
};
|
||||
|
||||
// 6. Let onRejected be CreateBuiltinFunction(rejectedClosure, 1, "", « »).
|
||||
auto on_rejected = NativeFunction::create(realm, move(rejected_closure), 1, "");
|
||||
auto on_rejected = NativeFunction::create(realm, move(rejected_closure), 1);
|
||||
|
||||
// 7. Perform PerformPromiseThen(promise, onFulfilled, onRejected).
|
||||
m_current_promise = as<Promise>(promise_object);
|
||||
|
@ -155,15 +155,15 @@ void AsyncGenerator::execute(VM& vm, Completion completion)
|
|||
// Loosely based on step 4 of https://tc39.es/ecma262/#sec-asyncgeneratorstart
|
||||
VERIFY(completion.value().has_value());
|
||||
|
||||
auto generated_value = [](Value value) -> Value {
|
||||
auto generated_value = [&vm](Value value) -> Value {
|
||||
if (value.is_object())
|
||||
return value.as_object().get_without_side_effects("result");
|
||||
return value.as_object().get_without_side_effects(vm.names.result);
|
||||
return value.is_empty() ? js_undefined() : value;
|
||||
};
|
||||
|
||||
auto generated_continuation = [&](Value value) -> Optional<size_t> {
|
||||
if (value.is_object()) {
|
||||
auto number_value = value.as_object().get_without_side_effects("continuation");
|
||||
auto number_value = value.as_object().get_without_side_effects(vm.names.continuation);
|
||||
if (number_value.is_null())
|
||||
return {};
|
||||
return static_cast<size_t>(number_value.as_double());
|
||||
|
@ -171,9 +171,9 @@ void AsyncGenerator::execute(VM& vm, Completion completion)
|
|||
return {};
|
||||
};
|
||||
|
||||
auto generated_is_await = [](Value value) -> bool {
|
||||
auto generated_is_await = [&vm](Value value) -> bool {
|
||||
if (value.is_object())
|
||||
return value.as_object().get_without_side_effects("isAwait").as_bool();
|
||||
return value.as_object().get_without_side_effects(vm.names.isAwait).as_bool();
|
||||
return false;
|
||||
};
|
||||
|
||||
|
@ -393,7 +393,7 @@ void AsyncGenerator::await_return()
|
|||
};
|
||||
|
||||
// 11. Let onFulfilled be CreateBuiltinFunction(fulfilledClosure, 1, "", « »).
|
||||
auto on_fulfilled = NativeFunction::create(realm, move(fulfilled_closure), 1, "");
|
||||
auto on_fulfilled = NativeFunction::create(realm, move(fulfilled_closure), 1);
|
||||
|
||||
// 12. Let rejectedClosure be a new Abstract Closure with parameters (reason) that captures generator and performs
|
||||
// the following steps when called:
|
||||
|
@ -415,7 +415,7 @@ void AsyncGenerator::await_return()
|
|||
};
|
||||
|
||||
// 13. Let onRejected be CreateBuiltinFunction(rejectedClosure, 1, "", « »).
|
||||
auto on_rejected = NativeFunction::create(realm, move(rejected_closure), 1, "");
|
||||
auto on_rejected = NativeFunction::create(realm, move(rejected_closure), 1);
|
||||
|
||||
// 14. Perform PerformPromiseThen(promise, onFulfilled, onRejected).
|
||||
// NOTE: await_return should only be called when the generator is in SuspendedStart or Completed state,
|
||||
|
|
|
@ -92,6 +92,7 @@ namespace JS {
|
|||
P(construct) \
|
||||
P(constructor) \
|
||||
P(containing) \
|
||||
P(continuation) \
|
||||
P(copyWithin) \
|
||||
P(cos) \
|
||||
P(cosh) \
|
||||
|
@ -277,6 +278,7 @@ namespace JS {
|
|||
P(Intl) \
|
||||
P(is) \
|
||||
P(isArray) \
|
||||
P(isAwait) \
|
||||
P(isDisjointFrom) \
|
||||
P(isError) \
|
||||
P(isExtensible) \
|
||||
|
@ -408,6 +410,7 @@ namespace JS {
|
|||
P(reason) \
|
||||
P(reduce) \
|
||||
P(reduceRight) \
|
||||
P(result) \
|
||||
P(Reflect) \
|
||||
P(RegExp) \
|
||||
P(region) \
|
||||
|
|
|
@ -66,7 +66,7 @@ ThrowCompletionOr<Value> await(VM& vm, Value value)
|
|||
};
|
||||
|
||||
// 4. Let onFulfilled be CreateBuiltinFunction(fulfilledClosure, 1, "", « »).
|
||||
auto on_fulfilled = NativeFunction::create(realm, move(fulfilled_closure), 1, "");
|
||||
auto on_fulfilled = NativeFunction::create(realm, move(fulfilled_closure), 1);
|
||||
|
||||
// 5. Let rejectedClosure be a new Abstract Closure with parameters (reason) that captures asyncContext and performs the following steps when called:
|
||||
auto rejected_closure = [&success, &result](VM& vm) -> ThrowCompletionOr<Value> {
|
||||
|
@ -90,7 +90,7 @@ ThrowCompletionOr<Value> await(VM& vm, Value value)
|
|||
};
|
||||
|
||||
// 6. Let onRejected be CreateBuiltinFunction(rejectedClosure, 1, "", « »).
|
||||
auto on_rejected = NativeFunction::create(realm, move(rejected_closure), 1, "");
|
||||
auto on_rejected = NativeFunction::create(realm, move(rejected_closure), 1);
|
||||
|
||||
// 7. Perform PerformPromiseThen(promise, onFulfilled, onRejected).
|
||||
auto promise = as<Promise>(promise_object);
|
||||
|
|
|
@ -67,7 +67,7 @@ JS_DEFINE_NATIVE_FUNCTION(DisposableStackPrototype::adopt)
|
|||
};
|
||||
|
||||
// 6. Let F be CreateBuiltinFunction(closure, 0, "", « »).
|
||||
auto function = NativeFunction::create(realm, move(closure), 0, "");
|
||||
auto function = NativeFunction::create(realm, move(closure), 0);
|
||||
|
||||
// 7. Perform ? AddDisposableResource(disposableStack.[[DisposeCapability]], undefined, sync-dispose, F).
|
||||
TRY(add_disposable_resource(vm, disposable_stack->dispose_capability(), js_undefined(), Environment::InitializeBindingHint::SyncDispose, function));
|
||||
|
|
|
@ -82,15 +82,15 @@ ThrowCompletionOr<Value> GeneratorObject::execute(VM& vm, Completion const& comp
|
|||
|
||||
VERIFY(completion.value().has_value());
|
||||
|
||||
auto generated_value = [](Value value) -> Value {
|
||||
auto generated_value = [&vm](Value value) -> Value {
|
||||
if (value.is_object())
|
||||
return value.as_object().get_without_side_effects("result");
|
||||
return value.as_object().get_without_side_effects(vm.names.result);
|
||||
return value.is_empty() ? js_undefined() : value;
|
||||
};
|
||||
|
||||
auto generated_continuation = [&](Value value) -> Optional<size_t> {
|
||||
if (value.is_object()) {
|
||||
auto number_value = value.as_object().get_without_side_effects("continuation");
|
||||
auto number_value = value.as_object().get_without_side_effects(vm.names.continuation);
|
||||
if (number_value.is_null())
|
||||
return {};
|
||||
return static_cast<u64>(number_value.as_double());
|
||||
|
|
|
@ -246,7 +246,7 @@ void Intrinsics::initialize_intrinsics(Realm& realm)
|
|||
realm, [](VM& vm) {
|
||||
return vm.throw_completion<TypeError>(ErrorType::RestrictedFunctionPropertiesAccess);
|
||||
},
|
||||
0, "", &realm);
|
||||
0, FlyString {}, &realm);
|
||||
m_throw_type_error_function->define_direct_property(vm.names.length, Value(0), 0);
|
||||
m_throw_type_error_function->define_direct_property(vm.names.name, PrimitiveString::create(vm, String {}), 0);
|
||||
MUST(m_throw_type_error_function->internal_prevent_extensions());
|
||||
|
|
|
@ -21,7 +21,7 @@ class NativeFunction : public FunctionObject {
|
|||
GC_DECLARE_ALLOCATOR(NativeFunction);
|
||||
|
||||
public:
|
||||
static GC::Ref<NativeFunction> create(Realm&, ESCAPING Function<ThrowCompletionOr<Value>(VM&)> behaviour, i32 length, PropertyKey const& name, Optional<Realm*> = {}, Optional<Object*> prototype = {}, Optional<StringView> const& prefix = {});
|
||||
static GC::Ref<NativeFunction> create(Realm&, ESCAPING Function<ThrowCompletionOr<Value>(VM&)> behaviour, i32 length, PropertyKey const& name = FlyString {}, Optional<Realm*> = {}, Optional<Object*> prototype = {}, Optional<StringView> const& prefix = {});
|
||||
static GC::Ref<NativeFunction> create(Realm&, DeprecatedFlyString const& name, ESCAPING Function<ThrowCompletionOr<Value>(VM&)>);
|
||||
|
||||
virtual ~NativeFunction() override = default;
|
||||
|
|
|
@ -90,7 +90,7 @@ ThrowCompletionOr<GC::Ref<PromiseCapability>> new_promise_capability(VM& vm, Val
|
|||
};
|
||||
|
||||
// 5. Let executor be CreateBuiltinFunction(executorClosure, 2, "", « »).
|
||||
auto executor = NativeFunction::create(realm, move(executor_closure), 2, "");
|
||||
auto executor = NativeFunction::create(realm, move(executor_closure), 2);
|
||||
|
||||
// 6. Let promise be ? Construct(C, « executor »).
|
||||
auto promise = TRY(construct(vm, constructor.as_function(), executor));
|
||||
|
|
|
@ -121,14 +121,14 @@ JS_DEFINE_NATIVE_FUNCTION(PromisePrototype::finally)
|
|||
};
|
||||
|
||||
// iv. Let valueThunk be CreateBuiltinFunction(returnValue, 0, "", « »).
|
||||
auto value_thunk = NativeFunction::create(realm, move(return_value), 0, "");
|
||||
auto value_thunk = NativeFunction::create(realm, move(return_value), 0);
|
||||
|
||||
// v. Return ? Invoke(promise, "then", « valueThunk »).
|
||||
return TRY(Value(promise).invoke(vm, vm.names.then, value_thunk));
|
||||
};
|
||||
|
||||
// b. Let thenFinally be CreateBuiltinFunction(thenFinallyClosure, 1, "", « »).
|
||||
then_finally = NativeFunction::create(realm, move(then_finally_closure), 1, "");
|
||||
then_finally = NativeFunction::create(realm, move(then_finally_closure), 1);
|
||||
|
||||
// c. Let catchFinallyClosure be a new Abstract Closure with parameters (reason) that captures onFinally and C and performs the following steps when called:
|
||||
auto catch_finally_closure = [constructor, on_finally](auto& vm) -> ThrowCompletionOr<Value> {
|
||||
|
@ -148,14 +148,14 @@ JS_DEFINE_NATIVE_FUNCTION(PromisePrototype::finally)
|
|||
};
|
||||
|
||||
// iv. Let thrower be CreateBuiltinFunction(throwReason, 0, "", « »).
|
||||
auto thrower = NativeFunction::create(realm, move(throw_reason), 0, "");
|
||||
auto thrower = NativeFunction::create(realm, move(throw_reason), 0);
|
||||
|
||||
// v. Return ? Invoke(promise, "then", « thrower »).
|
||||
return TRY(Value(promise).invoke(vm, vm.names.then, thrower));
|
||||
};
|
||||
|
||||
// d. Let catchFinally be CreateBuiltinFunction(catchFinallyClosure, 1, "", « »).
|
||||
catch_finally = NativeFunction::create(realm, move(catch_finally_closure), 1, "");
|
||||
catch_finally = NativeFunction::create(realm, move(catch_finally_closure), 1);
|
||||
}
|
||||
|
||||
// 7. Return ? Invoke(promise, "then", « thenFinally, catchFinally »).
|
||||
|
|
|
@ -61,9 +61,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
template<size_t N>
|
||||
PropertyKey(char const (&chars)[N])
|
||||
: PropertyKey(DeprecatedFlyString(chars))
|
||||
PropertyKey(FlyString const& string)
|
||||
: PropertyKey(string.to_deprecated_fly_string())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ JS_DEFINE_NATIVE_FUNCTION(ProxyConstructor::revocable)
|
|||
|
||||
// 3. Let revoker be CreateBuiltinFunction(revokerClosure, 0, "", « [[RevocableProxy]] »).
|
||||
// 4. Set revoker.[[RevocableProxy]] to p.
|
||||
auto revoker = NativeFunction::create(realm, move(revoker_closure), 0, "");
|
||||
auto revoker = NativeFunction::create(realm, move(revoker_closure), 0);
|
||||
|
||||
// 5. Let result be OrdinaryObjectCreate(%Object.prototype%).
|
||||
auto result = Object::create(realm, realm.intrinsics().object_prototype());
|
||||
|
|
|
@ -253,7 +253,7 @@ ThrowCompletionOr<Value> shadow_realm_import_value(VM& vm, String specifier_stri
|
|||
|
||||
// 10. Let onFulfilled be CreateBuiltinFunction(steps, 1, "", « [[ExportNameString]] », callerRealm).
|
||||
// 11. Set onFulfilled.[[ExportNameString]] to exportNameString.
|
||||
auto on_fulfilled = NativeFunction::create(realm, move(steps), 1, "", &caller_realm);
|
||||
auto on_fulfilled = NativeFunction::create(realm, move(steps), 1, FlyString {}, &caller_realm);
|
||||
|
||||
// 12. Let promiseCapability be ! NewPromiseCapability(%Promise%).
|
||||
auto promise_capability = MUST(new_promise_capability(vm, realm.intrinsics().promise_constructor()));
|
||||
|
|
|
@ -603,7 +603,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::match_all)
|
|||
// b. If isRegExp is true, then
|
||||
if (is_regexp) {
|
||||
// i. Let flags be ? Get(regexp, "flags").
|
||||
auto flags = TRY(regexp.as_object().get("flags"));
|
||||
auto flags = TRY(regexp.as_object().get(vm.names.flags));
|
||||
|
||||
// ii. Perform ? RequireObjectCoercible(flags).
|
||||
auto flags_object = TRY(require_object_coercible(vm, flags));
|
||||
|
|
|
@ -185,7 +185,7 @@ inline void TestRunnerGlobalObject::initialize(JS::Realm& realm)
|
|||
{
|
||||
Base::initialize(realm);
|
||||
|
||||
define_direct_property("global", this, JS::Attribute::Enumerable);
|
||||
define_direct_property("global"_fly_string, this, JS::Attribute::Enumerable);
|
||||
for (auto& entry : s_exposed_global_functions) {
|
||||
define_native_function(
|
||||
realm,
|
||||
|
@ -242,7 +242,7 @@ inline AK::Result<GC::Ref<JS::SourceTextModule>, ParserError> parse_module(Strin
|
|||
|
||||
inline ErrorOr<JsonValue> get_test_results(JS::Realm& realm)
|
||||
{
|
||||
auto results = MUST(realm.global_object().get("__TestResults__"));
|
||||
auto results = MUST(realm.global_object().get("__TestResults__"_fly_string));
|
||||
auto maybe_json_string = MUST(JS::JSONObject::stringify_impl(*g_vm, results, JS::js_undefined(), JS::js_undefined()));
|
||||
if (maybe_json_string.has_value())
|
||||
return JsonValue::from_string(*maybe_json_string);
|
||||
|
@ -362,7 +362,7 @@ inline JSFileResult TestRunner::run_file_test(ByteString const& test_path)
|
|||
JSFileResult file_result { test_path.substring(m_test_root.length() + 1, test_path.length() - m_test_root.length() - 1) };
|
||||
|
||||
// Collect logged messages
|
||||
auto user_output = MUST(realm->global_object().get("__UserOutput__"));
|
||||
auto user_output = MUST(realm->global_object().get("__UserOutput__"_fly_string));
|
||||
|
||||
auto& arr = user_output.as_array();
|
||||
for (auto& entry : arr.indexed_properties()) {
|
||||
|
|
|
@ -104,13 +104,13 @@ static WebIDL::ExceptionOr<KeyframeType<AL>> process_a_keyframe_like_object(JS::
|
|||
return keyframe_output;
|
||||
|
||||
auto& keyframe_object = keyframe_input.as_object();
|
||||
auto composite = TRY(keyframe_object.get("composite"));
|
||||
auto composite = TRY(keyframe_object.get("composite"_fly_string));
|
||||
if (composite.is_undefined())
|
||||
composite = JS::PrimitiveString::create(vm, "auto"_string);
|
||||
auto easing = TRY(keyframe_object.get("easing"));
|
||||
auto easing = TRY(keyframe_object.get("easing"_fly_string));
|
||||
if (easing.is_undefined())
|
||||
easing = JS::PrimitiveString::create(vm, "linear"_string);
|
||||
auto offset = TRY(keyframe_object.get("offset"));
|
||||
auto offset = TRY(keyframe_object.get("offset"_fly_string));
|
||||
|
||||
if constexpr (AL == AllowLists::Yes) {
|
||||
keyframe_output.composite = TRY(convert_value_to_maybe_list(realm, composite, to_composite_operation));
|
||||
|
|
|
@ -381,8 +381,8 @@ ErrorOr<void> initialize_main_thread_vm(HTML::EventLoop::Type type)
|
|||
|
||||
// 5. Return « Record { [[Key]]: "url", [[Value]]: urlString }, Record { [[Key]]: "resolve", [[Value]]: resolveFunction } ».
|
||||
HashMap<JS::PropertyKey, JS::Value> meta;
|
||||
meta.set("url", JS::PrimitiveString::create(vm, move(url_string)));
|
||||
meta.set("resolve", resolve_function);
|
||||
meta.set("url"_fly_string, JS::PrimitiveString::create(vm, move(url_string)));
|
||||
meta.set("resolve"_fly_string, resolve_function);
|
||||
|
||||
return meta;
|
||||
};
|
||||
|
|
|
@ -337,7 +337,7 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> AesCbcParams::from_value(J
|
|||
{
|
||||
auto& object = value.as_object();
|
||||
|
||||
auto iv_value = TRY(object.get("iv"));
|
||||
auto iv_value = TRY(object.get("iv"_fly_string));
|
||||
if (!iv_value.is_object() || !(is<JS::TypedArrayBase>(iv_value.as_object()) || is<JS::ArrayBuffer>(iv_value.as_object()) || is<JS::DataView>(iv_value.as_object())))
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "BufferSource");
|
||||
auto iv = TRY_OR_THROW_OOM(vm, WebIDL::get_buffer_source_copy(iv_value.as_object()));
|
||||
|
@ -351,12 +351,12 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> AesCtrParams::from_value(J
|
|||
{
|
||||
auto& object = value.as_object();
|
||||
|
||||
auto iv_value = TRY(object.get("counter"));
|
||||
auto iv_value = TRY(object.get("counter"_fly_string));
|
||||
if (!iv_value.is_object() || !(is<JS::TypedArrayBase>(iv_value.as_object()) || is<JS::ArrayBuffer>(iv_value.as_object()) || is<JS::DataView>(iv_value.as_object())))
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "BufferSource");
|
||||
auto iv = TRY_OR_THROW_OOM(vm, WebIDL::get_buffer_source_copy(iv_value.as_object()));
|
||||
|
||||
auto length_value = TRY(object.get("length"));
|
||||
auto length_value = TRY(object.get("length"_fly_string));
|
||||
auto length = TRY(length_value.to_u8(vm));
|
||||
|
||||
return adopt_own<AlgorithmParams>(*new AesCtrParams { iv, length });
|
||||
|
@ -368,22 +368,22 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> AesGcmParams::from_value(J
|
|||
{
|
||||
auto& object = value.as_object();
|
||||
|
||||
auto iv_value = TRY(object.get("iv"));
|
||||
auto iv_value = TRY(object.get("iv"_fly_string));
|
||||
if (!iv_value.is_object() || !(is<JS::TypedArrayBase>(iv_value.as_object()) || is<JS::ArrayBuffer>(iv_value.as_object()) || is<JS::DataView>(iv_value.as_object())))
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "BufferSource");
|
||||
auto iv = TRY_OR_THROW_OOM(vm, WebIDL::get_buffer_source_copy(iv_value.as_object()));
|
||||
|
||||
auto maybe_additional_data = Optional<ByteBuffer> {};
|
||||
if (MUST(object.has_property("additionalData"))) {
|
||||
auto additional_data_value = TRY(object.get("additionalData"));
|
||||
if (MUST(object.has_property("additionalData"_fly_string))) {
|
||||
auto additional_data_value = TRY(object.get("additionalData"_fly_string));
|
||||
if (!additional_data_value.is_object() || !(is<JS::TypedArrayBase>(additional_data_value.as_object()) || is<JS::ArrayBuffer>(additional_data_value.as_object()) || is<JS::DataView>(additional_data_value.as_object())))
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "BufferSource");
|
||||
maybe_additional_data = TRY_OR_THROW_OOM(vm, WebIDL::get_buffer_source_copy(additional_data_value.as_object()));
|
||||
}
|
||||
|
||||
auto maybe_tag_length = Optional<u8> {};
|
||||
if (MUST(object.has_property("tagLength"))) {
|
||||
auto tag_length_value = TRY(object.get("tagLength"));
|
||||
if (MUST(object.has_property("tagLength"_fly_string))) {
|
||||
auto tag_length_value = TRY(object.get("tagLength"_fly_string));
|
||||
maybe_tag_length = TRY(tag_length_value.to_u8(vm));
|
||||
}
|
||||
|
||||
|
@ -396,15 +396,15 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> HKDFParams::from_value(JS:
|
|||
{
|
||||
auto& object = value.as_object();
|
||||
|
||||
auto hash_value = TRY(object.get("hash"));
|
||||
auto hash_value = TRY(object.get("hash"_fly_string));
|
||||
auto hash = TRY(hash_algorithm_identifier_from_value(vm, hash_value));
|
||||
|
||||
auto salt_value = TRY(object.get("salt"));
|
||||
auto salt_value = TRY(object.get("salt"_fly_string));
|
||||
if (!salt_value.is_object() || !(is<JS::TypedArrayBase>(salt_value.as_object()) || is<JS::ArrayBuffer>(salt_value.as_object()) || is<JS::DataView>(salt_value.as_object())))
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "BufferSource");
|
||||
auto salt = TRY_OR_THROW_OOM(vm, WebIDL::get_buffer_source_copy(salt_value.as_object()));
|
||||
|
||||
auto info_value = TRY(object.get("info"));
|
||||
auto info_value = TRY(object.get("info"_fly_string));
|
||||
if (!info_value.is_object() || !(is<JS::TypedArrayBase>(info_value.as_object()) || is<JS::ArrayBuffer>(info_value.as_object()) || is<JS::DataView>(info_value.as_object())))
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "BufferSource");
|
||||
auto info = TRY_OR_THROW_OOM(vm, WebIDL::get_buffer_source_copy(info_value.as_object()));
|
||||
|
@ -418,17 +418,17 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> PBKDF2Params::from_value(J
|
|||
{
|
||||
auto& object = value.as_object();
|
||||
|
||||
auto salt_value = TRY(object.get("salt"));
|
||||
auto salt_value = TRY(object.get("salt"_fly_string));
|
||||
|
||||
if (!salt_value.is_object() || !(is<JS::TypedArrayBase>(salt_value.as_object()) || is<JS::ArrayBuffer>(salt_value.as_object()) || is<JS::DataView>(salt_value.as_object())))
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "BufferSource");
|
||||
|
||||
auto salt = TRY_OR_THROW_OOM(vm, WebIDL::get_buffer_source_copy(salt_value.as_object()));
|
||||
|
||||
auto iterations_value = TRY(object.get("iterations"));
|
||||
auto iterations_value = TRY(object.get("iterations"_fly_string));
|
||||
auto iterations = TRY(iterations_value.to_u32(vm));
|
||||
|
||||
auto hash_value = TRY(object.get("hash"));
|
||||
auto hash_value = TRY(object.get("hash"_fly_string));
|
||||
auto hash = TRY(hash_algorithm_identifier_from_value(vm, hash_value));
|
||||
|
||||
return adopt_own<AlgorithmParams>(*new PBKDF2Params { salt, iterations, hash });
|
||||
|
@ -440,10 +440,10 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> RsaKeyGenParams::from_valu
|
|||
{
|
||||
auto& object = value.as_object();
|
||||
|
||||
auto modulus_length_value = TRY(object.get("modulusLength"));
|
||||
auto modulus_length_value = TRY(object.get("modulusLength"_fly_string));
|
||||
auto modulus_length = TRY(modulus_length_value.to_u32(vm));
|
||||
|
||||
auto public_exponent_value = TRY(object.get("publicExponent"));
|
||||
auto public_exponent_value = TRY(object.get("publicExponent"_fly_string));
|
||||
GC::Ptr<JS::Uint8Array> public_exponent;
|
||||
|
||||
if (!public_exponent_value.is_object() || !is<JS::Uint8Array>(public_exponent_value.as_object()))
|
||||
|
@ -460,10 +460,10 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> RsaHashedKeyGenParams::fro
|
|||
{
|
||||
auto& object = value.as_object();
|
||||
|
||||
auto modulus_length_value = TRY(object.get("modulusLength"));
|
||||
auto modulus_length_value = TRY(object.get("modulusLength"_fly_string));
|
||||
auto modulus_length = TRY(modulus_length_value.to_u32(vm));
|
||||
|
||||
auto public_exponent_value = TRY(object.get("publicExponent"));
|
||||
auto public_exponent_value = TRY(object.get("publicExponent"_fly_string));
|
||||
GC::Ptr<JS::Uint8Array> public_exponent;
|
||||
|
||||
if (!public_exponent_value.is_object() || !is<JS::Uint8Array>(public_exponent_value.as_object()))
|
||||
|
@ -471,7 +471,7 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> RsaHashedKeyGenParams::fro
|
|||
|
||||
public_exponent = static_cast<JS::Uint8Array&>(public_exponent_value.as_object());
|
||||
|
||||
auto hash_value = TRY(object.get("hash"));
|
||||
auto hash_value = TRY(object.get("hash"_fly_string));
|
||||
auto hash = TRY(hash_algorithm_identifier_from_value(vm, hash_value));
|
||||
|
||||
return adopt_own<AlgorithmParams>(*new RsaHashedKeyGenParams { modulus_length, big_integer_from_api_big_integer(public_exponent), hash });
|
||||
|
@ -483,7 +483,7 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> RsaHashedImportParams::fro
|
|||
{
|
||||
auto& object = value.as_object();
|
||||
|
||||
auto hash_value = TRY(object.get("hash"));
|
||||
auto hash_value = TRY(object.get("hash"_fly_string));
|
||||
auto hash = TRY(hash_algorithm_identifier_from_value(vm, hash_value));
|
||||
|
||||
return adopt_own<AlgorithmParams>(*new RsaHashedImportParams { hash });
|
||||
|
@ -495,7 +495,7 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> RsaOaepParams::from_value(
|
|||
{
|
||||
auto& object = value.as_object();
|
||||
|
||||
auto label_value = TRY(object.get("label"));
|
||||
auto label_value = TRY(object.get("label"_fly_string));
|
||||
|
||||
ByteBuffer label;
|
||||
if (!label_value.is_nullish()) {
|
||||
|
@ -515,7 +515,7 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> RsaPssParams::from_value(J
|
|||
{
|
||||
auto& object = value.as_object();
|
||||
|
||||
auto salt_length_value = TRY(object.get("saltLength"));
|
||||
auto salt_length_value = TRY(object.get("saltLength"_fly_string));
|
||||
auto salt_length = TRY(salt_length_value.to_u32(vm));
|
||||
|
||||
return adopt_own<AlgorithmParams>(*new RsaPssParams { salt_length });
|
||||
|
@ -527,7 +527,7 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> EcdsaParams::from_value(JS
|
|||
{
|
||||
auto& object = value.as_object();
|
||||
|
||||
auto hash_value = TRY(object.get("hash"));
|
||||
auto hash_value = TRY(object.get("hash"_fly_string));
|
||||
auto hash = TRY(hash_algorithm_identifier_from_value(vm, hash_value));
|
||||
|
||||
return adopt_own<AlgorithmParams>(*new EcdsaParams { hash });
|
||||
|
@ -539,7 +539,7 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> EcKeyGenParams::from_value
|
|||
{
|
||||
auto& object = value.as_object();
|
||||
|
||||
auto curve_value = TRY(object.get("namedCurve"));
|
||||
auto curve_value = TRY(object.get("namedCurve"_fly_string));
|
||||
auto curve = TRY(curve_value.to_string(vm));
|
||||
|
||||
return adopt_own<AlgorithmParams>(*new EcKeyGenParams { curve });
|
||||
|
@ -551,7 +551,7 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> AesKeyGenParams::from_valu
|
|||
{
|
||||
auto& object = value.as_object();
|
||||
|
||||
auto length_value = TRY(object.get("length"));
|
||||
auto length_value = TRY(object.get("length"_fly_string));
|
||||
auto length = TRY(length_value.to_u16(vm));
|
||||
|
||||
return adopt_own<AlgorithmParams>(*new AesKeyGenParams { length });
|
||||
|
@ -563,7 +563,7 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> AesDerivedKeyParams::from_
|
|||
{
|
||||
auto& object = value.as_object();
|
||||
|
||||
auto length_value = TRY(object.get("length"));
|
||||
auto length_value = TRY(object.get("length"_fly_string));
|
||||
auto length = TRY(length_value.to_u16(vm));
|
||||
|
||||
return adopt_own<AlgorithmParams>(*new AesDerivedKeyParams { length });
|
||||
|
@ -575,7 +575,7 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> EcdhKeyDeriveParams::from_
|
|||
{
|
||||
auto& object = value.as_object();
|
||||
|
||||
auto key_value = TRY(object.get("public"));
|
||||
auto key_value = TRY(object.get("public"_fly_string));
|
||||
auto key_object = TRY(key_value.to_object(vm));
|
||||
|
||||
if (!is<CryptoKey>(*key_object)) {
|
||||
|
@ -593,7 +593,7 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> EcKeyImportParams::from_va
|
|||
{
|
||||
auto& object = value.as_object();
|
||||
|
||||
auto named_curve_value = TRY(object.get("namedCurve"));
|
||||
auto named_curve_value = TRY(object.get("namedCurve"_fly_string));
|
||||
auto named_curve = TRY(named_curve_value.to_string(vm));
|
||||
|
||||
return adopt_own<AlgorithmParams>(*new EcKeyImportParams { named_curve });
|
||||
|
@ -605,12 +605,12 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> HmacImportParams::from_val
|
|||
{
|
||||
auto& object = value.as_object();
|
||||
|
||||
auto hash_value = TRY(object.get("hash"));
|
||||
auto hash_value = TRY(object.get("hash"_fly_string));
|
||||
auto hash = TRY(hash_algorithm_identifier_from_value(vm, hash_value));
|
||||
|
||||
auto maybe_length = Optional<WebIDL::UnsignedLong> {};
|
||||
if (MUST(object.has_property("length"))) {
|
||||
auto length_value = TRY(object.get("length"));
|
||||
if (MUST(object.has_property("length"_fly_string))) {
|
||||
auto length_value = TRY(object.get("length"_fly_string));
|
||||
maybe_length = TRY(length_value.to_u32(vm));
|
||||
}
|
||||
|
||||
|
@ -623,12 +623,12 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> HmacKeyGenParams::from_val
|
|||
{
|
||||
auto& object = value.as_object();
|
||||
|
||||
auto hash_value = TRY(object.get("hash"));
|
||||
auto hash_value = TRY(object.get("hash"_fly_string));
|
||||
auto hash = TRY(hash_algorithm_identifier_from_value(vm, hash_value));
|
||||
|
||||
auto maybe_length = Optional<WebIDL::UnsignedLong> {};
|
||||
if (MUST(object.has_property("length"))) {
|
||||
auto length_value = TRY(object.get("length"));
|
||||
if (MUST(object.has_property("length"_fly_string))) {
|
||||
auto length_value = TRY(object.get("length"_fly_string));
|
||||
maybe_length = TRY(length_value.to_u32(vm));
|
||||
}
|
||||
|
||||
|
@ -642,8 +642,8 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> Ed448Params::from_value(JS
|
|||
auto& object = value.as_object();
|
||||
|
||||
auto maybe_context = Optional<ByteBuffer> {};
|
||||
if (MUST(object.has_property("context"))) {
|
||||
auto context_value = TRY(object.get("context"));
|
||||
if (MUST(object.has_property("context"_fly_string))) {
|
||||
auto context_value = TRY(object.get("context"_fly_string));
|
||||
if (!context_value.is_object() || !(is<JS::TypedArrayBase>(context_value.as_object()) || is<JS::ArrayBuffer>(context_value.as_object()) || is<JS::DataView>(context_value.as_object())))
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "BufferSource");
|
||||
maybe_context = TRY_OR_THROW_OOM(vm, WebIDL::get_buffer_source_copy(context_value.as_object()));
|
||||
|
|
|
@ -34,7 +34,7 @@ struct HashAlgorithmIdentifier : public AlgorithmIdentifier {
|
|||
auto value = visit(
|
||||
[](String const& name) -> JS::ThrowCompletionOr<String> { return name; },
|
||||
[&](GC::Root<JS::Object> const& obj) -> JS::ThrowCompletionOr<String> {
|
||||
auto name_property = TRY(obj->get("name"));
|
||||
auto name_property = TRY(obj->get("name"_fly_string));
|
||||
return name_property.to_string(vm);
|
||||
});
|
||||
|
||||
|
|
|
@ -91,63 +91,63 @@ JS::ThrowCompletionOr<GC::Ref<JS::Object>> JsonWebKey::to_object(JS::Realm& real
|
|||
auto object = JS::Object::create(realm, realm.intrinsics().object_prototype());
|
||||
|
||||
if (kty.has_value())
|
||||
TRY(object->create_data_property("kty", JS::PrimitiveString::create(vm, kty.value())));
|
||||
TRY(object->create_data_property("kty"_fly_string, JS::PrimitiveString::create(vm, kty.value())));
|
||||
|
||||
if (use.has_value())
|
||||
TRY(object->create_data_property("use", JS::PrimitiveString::create(vm, use.value())));
|
||||
TRY(object->create_data_property("use"_fly_string, JS::PrimitiveString::create(vm, use.value())));
|
||||
|
||||
if (key_ops.has_value()) {
|
||||
auto key_ops_array = JS::Array::create_from<String>(realm, key_ops.value().span(), [&](auto& key_usage) -> JS::Value {
|
||||
return JS::PrimitiveString::create(realm.vm(), key_usage);
|
||||
});
|
||||
TRY(object->create_data_property("key_ops", move(key_ops_array)));
|
||||
TRY(object->create_data_property("key_ops"_fly_string, move(key_ops_array)));
|
||||
}
|
||||
|
||||
if (alg.has_value())
|
||||
TRY(object->create_data_property("alg", JS::PrimitiveString::create(vm, alg.value())));
|
||||
TRY(object->create_data_property("alg"_fly_string, JS::PrimitiveString::create(vm, alg.value())));
|
||||
|
||||
if (ext.has_value())
|
||||
TRY(object->create_data_property("ext", JS::Value(ext.value())));
|
||||
TRY(object->create_data_property("ext"_fly_string, JS::Value(ext.value())));
|
||||
|
||||
if (crv.has_value())
|
||||
TRY(object->create_data_property("crv", JS::PrimitiveString::create(vm, crv.value())));
|
||||
TRY(object->create_data_property("crv"_fly_string, JS::PrimitiveString::create(vm, crv.value())));
|
||||
|
||||
if (x.has_value())
|
||||
TRY(object->create_data_property("x", JS::PrimitiveString::create(vm, x.value())));
|
||||
TRY(object->create_data_property("x"_fly_string, JS::PrimitiveString::create(vm, x.value())));
|
||||
|
||||
if (y.has_value())
|
||||
TRY(object->create_data_property("y", JS::PrimitiveString::create(vm, y.value())));
|
||||
TRY(object->create_data_property("y"_fly_string, JS::PrimitiveString::create(vm, y.value())));
|
||||
|
||||
if (d.has_value())
|
||||
TRY(object->create_data_property("d", JS::PrimitiveString::create(vm, d.value())));
|
||||
TRY(object->create_data_property("d"_fly_string, JS::PrimitiveString::create(vm, d.value())));
|
||||
|
||||
if (n.has_value())
|
||||
TRY(object->create_data_property("n", JS::PrimitiveString::create(vm, n.value())));
|
||||
TRY(object->create_data_property("n"_fly_string, JS::PrimitiveString::create(vm, n.value())));
|
||||
|
||||
if (e.has_value())
|
||||
TRY(object->create_data_property("e", JS::PrimitiveString::create(vm, e.value())));
|
||||
TRY(object->create_data_property("e"_fly_string, JS::PrimitiveString::create(vm, e.value())));
|
||||
|
||||
if (p.has_value())
|
||||
TRY(object->create_data_property("p", JS::PrimitiveString::create(vm, p.value())));
|
||||
TRY(object->create_data_property("p"_fly_string, JS::PrimitiveString::create(vm, p.value())));
|
||||
|
||||
if (q.has_value())
|
||||
TRY(object->create_data_property("q", JS::PrimitiveString::create(vm, q.value())));
|
||||
TRY(object->create_data_property("q"_fly_string, JS::PrimitiveString::create(vm, q.value())));
|
||||
|
||||
if (dp.has_value())
|
||||
TRY(object->create_data_property("dp", JS::PrimitiveString::create(vm, dp.value())));
|
||||
TRY(object->create_data_property("dp"_fly_string, JS::PrimitiveString::create(vm, dp.value())));
|
||||
|
||||
if (dq.has_value())
|
||||
TRY(object->create_data_property("dq", JS::PrimitiveString::create(vm, dq.value())));
|
||||
TRY(object->create_data_property("dq"_fly_string, JS::PrimitiveString::create(vm, dq.value())));
|
||||
|
||||
if (qi.has_value())
|
||||
TRY(object->create_data_property("qi", JS::PrimitiveString::create(vm, qi.value())));
|
||||
TRY(object->create_data_property("qi"_fly_string, JS::PrimitiveString::create(vm, qi.value())));
|
||||
|
||||
if (oth.has_value()) {
|
||||
TODO();
|
||||
}
|
||||
|
||||
if (k.has_value())
|
||||
TRY(object->create_data_property("k", JS::PrimitiveString::create(vm, k.value())));
|
||||
TRY(object->create_data_property("k"_fly_string, JS::PrimitiveString::create(vm, k.value())));
|
||||
|
||||
return object;
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ void CryptoKey::set_usages(Vector<Bindings::KeyUsage> usages)
|
|||
String CryptoKey::algorithm_name() const
|
||||
{
|
||||
if (m_algorithm_name.is_empty()) {
|
||||
auto name = MUST(m_algorithm->get("name"));
|
||||
auto name = MUST(m_algorithm->get("name"_fly_string));
|
||||
m_algorithm_name = MUST(name.to_string(vm()));
|
||||
}
|
||||
return m_algorithm_name;
|
||||
|
@ -95,8 +95,8 @@ CryptoKeyPair::CryptoKeyPair(JS::Realm& realm, GC::Ref<CryptoKey> public_key, GC
|
|||
|
||||
void CryptoKeyPair::initialize(JS::Realm& realm)
|
||||
{
|
||||
define_native_accessor(realm, "publicKey", public_key_getter, {}, JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
define_native_accessor(realm, "privateKey", private_key_getter, {}, JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
define_native_accessor(realm, "publicKey"_fly_string, public_key_getter, {}, JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
define_native_accessor(realm, "privateKey"_fly_string, private_key_getter, {}, JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
|
||||
Base::initialize(realm);
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ KeyAlgorithm::KeyAlgorithm(JS::Realm& realm)
|
|||
|
||||
void KeyAlgorithm::initialize(JS::Realm& realm)
|
||||
{
|
||||
define_native_accessor(realm, "name", name_getter, {}, JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
define_native_accessor(realm, "name"_fly_string, name_getter, {}, JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
Base::initialize(realm);
|
||||
}
|
||||
|
||||
|
@ -81,8 +81,8 @@ void RsaKeyAlgorithm::initialize(JS::Realm& realm)
|
|||
{
|
||||
Base::initialize(realm);
|
||||
|
||||
define_native_accessor(realm, "modulusLength", modulus_length_getter, {}, JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
define_native_accessor(realm, "publicExponent", public_exponent_getter, {}, JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
define_native_accessor(realm, "modulusLength"_fly_string, modulus_length_getter, {}, JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
define_native_accessor(realm, "publicExponent"_fly_string, public_exponent_getter, {}, JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
}
|
||||
|
||||
void RsaKeyAlgorithm::visit_edges(Visitor& visitor)
|
||||
|
@ -146,7 +146,7 @@ void EcKeyAlgorithm::initialize(JS::Realm& realm)
|
|||
{
|
||||
Base::initialize(realm);
|
||||
|
||||
define_native_accessor(realm, "namedCurve", named_curve_getter, {}, JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
define_native_accessor(realm, "namedCurve"_fly_string, named_curve_getter, {}, JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(EcKeyAlgorithm::named_curve_getter)
|
||||
|
@ -170,7 +170,7 @@ void RsaHashedKeyAlgorithm::initialize(JS::Realm& realm)
|
|||
{
|
||||
Base::initialize(realm);
|
||||
|
||||
define_native_accessor(realm, "hash", hash_getter, {}, JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
define_native_accessor(realm, "hash"_fly_string, hash_getter, {}, JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(RsaHashedKeyAlgorithm::hash_getter)
|
||||
|
@ -204,7 +204,7 @@ void AesKeyAlgorithm::initialize(JS::Realm& realm)
|
|||
{
|
||||
Base::initialize(realm);
|
||||
|
||||
define_native_accessor(realm, "length", length_getter, {}, JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
define_native_accessor(realm, "length"_fly_string, length_getter, {}, JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(AesKeyAlgorithm::length_getter)
|
||||
|
@ -227,8 +227,8 @@ HmacKeyAlgorithm::HmacKeyAlgorithm(JS::Realm& realm)
|
|||
void HmacKeyAlgorithm::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
define_native_accessor(realm, "hash", hash_getter, {}, JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
define_native_accessor(realm, "length", length_getter, {}, JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
define_native_accessor(realm, "hash"_fly_string, hash_getter, {}, JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
define_native_accessor(realm, "length"_fly_string, length_getter, {}, JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
}
|
||||
|
||||
void HmacKeyAlgorithm::visit_edges(JS::Cell::Visitor& visitor)
|
||||
|
|
|
@ -71,7 +71,7 @@ WebIDL::ExceptionOr<NormalizedAlgorithmAndParameter> normalize_an_algorithm(JS::
|
|||
// Return the result of running the normalize an algorithm algorithm,
|
||||
// with the alg set to a new Algorithm dictionary whose name attribute is alg, and with the op set to op.
|
||||
auto dictionary = GC::make_root(JS::Object::create(realm, realm.intrinsics().object_prototype()));
|
||||
TRY(dictionary->create_data_property("name", JS::PrimitiveString::create(vm, algorithm.get<String>())));
|
||||
TRY(dictionary->create_data_property("name"_fly_string, JS::PrimitiveString::create(vm, algorithm.get<String>())));
|
||||
|
||||
return normalize_an_algorithm(realm, dictionary, operation);
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ WebIDL::ExceptionOr<NormalizedAlgorithmAndParameter> normalize_an_algorithm(JS::
|
|||
// 3. If an error occurred, return the error and terminate this algorithm.
|
||||
// Note: We're not going to bother creating an Algorithm object, all we want is the name attribute so that we can
|
||||
// fetch the actual algorithm factory from the registeredAlgorithms map.
|
||||
auto initial_algorithm = TRY(algorithm.get<GC::Root<JS::Object>>()->get("name"));
|
||||
auto initial_algorithm = TRY(algorithm.get<GC::Root<JS::Object>>()->get("name"_fly_string));
|
||||
|
||||
if (initial_algorithm.is_undefined()) {
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "Algorithm");
|
||||
|
|
|
@ -614,7 +614,7 @@ void EventTarget::activate_event_handler(FlyString const& name, HTML::EventHandl
|
|||
TRY(event_target->process_event_handler_for_event(name, event));
|
||||
return JS::js_undefined();
|
||||
},
|
||||
0, "", &realm);
|
||||
0, FlyString {}, &realm);
|
||||
|
||||
// NOTE: As per the spec, the callback context is arbitrary.
|
||||
auto callback = realm.heap().allocate<WebIDL::CallbackType>(*callback_function, realm);
|
||||
|
|
|
@ -139,7 +139,7 @@ Optional<JS::PropertyDescriptor> cross_origin_get_own_property_helper(Variant<HT
|
|||
realm, [function = GC::make_root(*value)](auto& vm) {
|
||||
return JS::call(vm, function.value(), JS::js_undefined(), vm.running_execution_context().arguments.span());
|
||||
},
|
||||
0, "");
|
||||
0);
|
||||
}
|
||||
|
||||
// 3. Set crossOriginDesc to PropertyDescriptor{ [[Value]]: value, [[Enumerable]]: false, [[Writable]]: false, [[Configurable]]: true }.
|
||||
|
@ -156,7 +156,7 @@ Optional<JS::PropertyDescriptor> cross_origin_get_own_property_helper(Variant<HT
|
|||
realm, [object_ptr, getter = GC::make_root(*original_descriptor->get)](auto& vm) {
|
||||
return JS::call(vm, getter.cell(), object_ptr, vm.running_execution_context().arguments.span());
|
||||
},
|
||||
0, "");
|
||||
0);
|
||||
}
|
||||
|
||||
// 3. Let crossOriginSet be undefined.
|
||||
|
@ -168,7 +168,7 @@ Optional<JS::PropertyDescriptor> cross_origin_get_own_property_helper(Variant<HT
|
|||
realm, [object_ptr, setter = GC::make_root(*original_descriptor->set)](auto& vm) {
|
||||
return JS::call(vm, setter.cell(), object_ptr, vm.running_execution_context().arguments.span());
|
||||
},
|
||||
0, "");
|
||||
0);
|
||||
}
|
||||
|
||||
// 5. Set crossOriginDesc to PropertyDescriptor{ [[Get]]: crossOriginGet, [[Set]]: crossOriginSet, [[Enumerable]]: false, [[Configurable]]: true }.
|
||||
|
|
|
@ -385,7 +385,7 @@ void HTMLDialogElement::set_close_watcher()
|
|||
event.prevent_default();
|
||||
return JS::js_undefined();
|
||||
},
|
||||
0, "", &realm());
|
||||
0, ""_fly_string, &realm());
|
||||
auto cancel_callback = realm().heap().allocate<WebIDL::CallbackType>(*cancel_callback_function, realm());
|
||||
m_close_watcher->add_event_listener_without_options(HTML::EventNames::cancel, DOM::IDLEventListener::create(realm(), cancel_callback));
|
||||
// - closeAction being to close the dialog given dialog and dialog's request close return value.
|
||||
|
@ -395,7 +395,7 @@ void HTMLDialogElement::set_close_watcher()
|
|||
|
||||
return JS::js_undefined();
|
||||
},
|
||||
0, "", &realm());
|
||||
0, ""_fly_string, &realm());
|
||||
auto close_callback = realm().heap().allocate<WebIDL::CallbackType>(*close_callback_function, realm());
|
||||
m_close_watcher->add_event_listener_without_options(HTML::EventNames::close, DOM::IDLEventListener::create(realm(), close_callback));
|
||||
// - getEnabledState being to return true if dialog's enable close watcher for requestClose() is true or dialog's computed closed-by state is not None; otherwise false.
|
||||
|
|
|
@ -1332,7 +1332,7 @@ WebIDL::ExceptionOr<void> HTMLElement::show_popover(ThrowExceptions throw_except
|
|||
|
||||
return JS::js_undefined();
|
||||
},
|
||||
0, "", &realm());
|
||||
0, FlyString {}, &realm());
|
||||
auto close_callback = realm().heap().allocate<WebIDL::CallbackType>(*close_callback_function, realm());
|
||||
m_popover_close_watcher->add_event_listener_without_options(HTML::EventNames::close, DOM::IDLEventListener::create(realm(), close_callback));
|
||||
// - getEnabledState being to return true.
|
||||
|
|
|
@ -1051,7 +1051,7 @@ void HTMLInputElement::create_text_input_shadow_tree()
|
|||
commit_pending_changes();
|
||||
return JS::js_undefined();
|
||||
},
|
||||
0, "", &realm());
|
||||
0, FlyString {}, &realm());
|
||||
auto mouseup_callback = realm().heap().allocate<WebIDL::CallbackType>(*mouseup_callback_function, realm());
|
||||
DOM::AddEventListenerOptions mouseup_listener_options;
|
||||
mouseup_listener_options.once = true;
|
||||
|
@ -1064,7 +1064,7 @@ void HTMLInputElement::create_text_input_shadow_tree()
|
|||
}
|
||||
return JS::js_undefined();
|
||||
},
|
||||
0, "", &realm());
|
||||
0, FlyString {}, &realm());
|
||||
auto step_up_callback = realm().heap().allocate<WebIDL::CallbackType>(*up_callback_function, realm());
|
||||
up_button->add_event_listener_without_options(UIEvents::EventNames::mousedown, DOM::IDLEventListener::create(realm(), step_up_callback));
|
||||
up_button->add_event_listener_without_options(UIEvents::EventNames::mouseup, DOM::IDLEventListener::create(realm(), mouseup_callback));
|
||||
|
@ -1086,7 +1086,7 @@ void HTMLInputElement::create_text_input_shadow_tree()
|
|||
}
|
||||
return JS::js_undefined();
|
||||
},
|
||||
0, "", &realm());
|
||||
0, FlyString {}, &realm());
|
||||
auto step_down_callback = realm().heap().allocate<WebIDL::CallbackType>(*down_callback_function, realm());
|
||||
down_button->add_event_listener_without_options(UIEvents::EventNames::mousedown, DOM::IDLEventListener::create(realm(), step_down_callback));
|
||||
down_button->add_event_listener_without_options(UIEvents::EventNames::mouseup, DOM::IDLEventListener::create(realm(), mouseup_callback));
|
||||
|
@ -1147,7 +1147,7 @@ void HTMLInputElement::create_file_input_shadow_tree()
|
|||
return JS::js_undefined();
|
||||
};
|
||||
|
||||
auto on_button_click_function = JS::NativeFunction::create(realm, move(on_button_click), 0, "", &realm);
|
||||
auto on_button_click_function = JS::NativeFunction::create(realm, move(on_button_click), 0, FlyString {}, &realm);
|
||||
auto on_button_click_callback = realm.heap().allocate<WebIDL::CallbackType>(on_button_click_function, realm);
|
||||
m_file_button->add_event_listener_without_options(UIEvents::EventNames::click, DOM::IDLEventListener::create(realm, on_button_click_callback));
|
||||
|
||||
|
@ -1198,7 +1198,7 @@ void HTMLInputElement::create_range_input_shadow_tree()
|
|||
|
||||
auto keydown_callback_function = JS::NativeFunction::create(
|
||||
realm(), [this](JS::VM& vm) {
|
||||
auto key = MUST(vm.argument(0).get(vm, "key")).as_string().utf8_string();
|
||||
auto key = MUST(vm.argument(0).get(vm, "key"_fly_string)).as_string().utf8_string();
|
||||
|
||||
if (key == "ArrowLeft" || key == "ArrowDown")
|
||||
MUST(step_down());
|
||||
|
@ -1213,13 +1213,13 @@ void HTMLInputElement::create_range_input_shadow_tree()
|
|||
user_interaction_did_change_input_value();
|
||||
return JS::js_undefined();
|
||||
},
|
||||
0, "", &realm());
|
||||
0, ""_fly_string, &realm());
|
||||
auto keydown_callback = realm().heap().allocate<WebIDL::CallbackType>(*keydown_callback_function, realm());
|
||||
add_event_listener_without_options(UIEvents::EventNames::keydown, DOM::IDLEventListener::create(realm(), keydown_callback));
|
||||
|
||||
auto wheel_callback_function = JS::NativeFunction::create(
|
||||
realm(), [this](JS::VM& vm) {
|
||||
auto delta_y = MUST(vm.argument(0).get(vm, "deltaY")).as_i32();
|
||||
auto delta_y = MUST(vm.argument(0).get(vm, "deltaY"_fly_string)).as_i32();
|
||||
if (delta_y > 0) {
|
||||
MUST(step_down());
|
||||
} else {
|
||||
|
@ -1228,12 +1228,12 @@ void HTMLInputElement::create_range_input_shadow_tree()
|
|||
user_interaction_did_change_input_value();
|
||||
return JS::js_undefined();
|
||||
},
|
||||
0, "", &realm());
|
||||
0, ""_fly_string, &realm());
|
||||
auto wheel_callback = realm().heap().allocate<WebIDL::CallbackType>(*wheel_callback_function, realm());
|
||||
add_event_listener_without_options(UIEvents::EventNames::wheel, DOM::IDLEventListener::create(realm(), wheel_callback));
|
||||
|
||||
auto update_slider_by_mouse = [this](JS::VM& vm) {
|
||||
auto client_x = MUST(vm.argument(0).get(vm, "clientX")).as_double();
|
||||
auto client_x = MUST(vm.argument(0).get(vm, "clientX"_fly_string)).as_double();
|
||||
auto rect = get_bounding_client_rect();
|
||||
double minimum = *min();
|
||||
double maximum = *max();
|
||||
|
@ -1251,7 +1251,7 @@ void HTMLInputElement::create_range_input_shadow_tree()
|
|||
update_slider_by_mouse(vm);
|
||||
return JS::js_undefined();
|
||||
},
|
||||
0, "", &realm());
|
||||
0, ""_fly_string, &realm());
|
||||
auto mousemove_callback = realm().heap().allocate<WebIDL::CallbackType>(*mousemove_callback_function, realm());
|
||||
auto mousemove_listener = DOM::IDLEventListener::create(realm(), mousemove_callback);
|
||||
auto& window = static_cast<HTML::Window&>(relevant_global_object(*this));
|
||||
|
@ -1263,7 +1263,7 @@ void HTMLInputElement::create_range_input_shadow_tree()
|
|||
window.remove_event_listener_without_options(UIEvents::EventNames::mousemove, mousemove_listener);
|
||||
return JS::js_undefined();
|
||||
},
|
||||
0, "", &realm());
|
||||
0, ""_fly_string, &realm());
|
||||
auto mouseup_callback = realm().heap().allocate<WebIDL::CallbackType>(*mouseup_callback_function, realm());
|
||||
DOM::AddEventListenerOptions mouseup_listener_options;
|
||||
mouseup_listener_options.once = true;
|
||||
|
@ -1271,7 +1271,7 @@ void HTMLInputElement::create_range_input_shadow_tree()
|
|||
|
||||
return JS::js_undefined();
|
||||
},
|
||||
0, "", &realm());
|
||||
0, ""_fly_string, &realm());
|
||||
auto mousedown_callback = realm().heap().allocate<WebIDL::CallbackType>(*mousedown_callback_function, realm());
|
||||
add_event_listener_without_options(UIEvents::EventNames::mousedown, DOM::IDLEventListener::create(realm(), mousedown_callback));
|
||||
}
|
||||
|
|
|
@ -34,8 +34,8 @@ WebIDL::ExceptionOr<ImportMap> parse_import_map_string(JS::Realm& realm, ByteStr
|
|||
ModuleSpecifierMap sorted_and_normalised_imports;
|
||||
|
||||
// 4. If parsed["imports"] exists, then:
|
||||
if (TRY(parsed_object.has_property("imports"))) {
|
||||
auto imports = TRY(parsed_object.get("imports"));
|
||||
if (TRY(parsed_object.has_property("imports"_fly_string))) {
|
||||
auto imports = TRY(parsed_object.get("imports"_fly_string));
|
||||
|
||||
// If parsed["imports"] is not an ordered map, then throw a TypeError indicating that the value for the "imports" top-level key needs to be a JSON object.
|
||||
if (!imports.is_object())
|
||||
|
@ -49,8 +49,8 @@ WebIDL::ExceptionOr<ImportMap> parse_import_map_string(JS::Realm& realm, ByteStr
|
|||
HashMap<URL::URL, ModuleSpecifierMap> sorted_and_normalised_scopes;
|
||||
|
||||
// 6. If parsed["scopes"] exists, then:
|
||||
if (TRY(parsed_object.has_property("scopes"))) {
|
||||
auto scopes = TRY(parsed_object.get("scopes"));
|
||||
if (TRY(parsed_object.has_property("scopes"_fly_string))) {
|
||||
auto scopes = TRY(parsed_object.get("scopes"_fly_string));
|
||||
|
||||
// If parsed["scopes"] is not an ordered map, then throw a TypeError indicating that the value for the "scopes" top-level key needs to be a JSON object.
|
||||
if (!scopes.is_object())
|
||||
|
@ -64,8 +64,8 @@ WebIDL::ExceptionOr<ImportMap> parse_import_map_string(JS::Realm& realm, ByteStr
|
|||
ModuleIntegrityMap normalised_integrity;
|
||||
|
||||
// 8. If parsed["integrity"] exists, then:
|
||||
if (TRY(parsed_object.has_property("integrity"))) {
|
||||
auto integrity = TRY(parsed_object.get("integrity"));
|
||||
if (TRY(parsed_object.has_property("integrity"_fly_string))) {
|
||||
auto integrity = TRY(parsed_object.get("integrity"_fly_string));
|
||||
|
||||
// 1. If parsed["integrity"] is not an ordered map, then throw a TypeError indicating that the value for the "integrity" top-level key needs to be a JSON object.
|
||||
if (!integrity.is_object())
|
||||
|
|
|
@ -121,7 +121,7 @@ GC::Ref<WebIDL::CallbackType> UniversalGlobalScopeMixin::count_queuing_strategy_
|
|||
};
|
||||
|
||||
// 2. Let F be ! CreateBuiltinFunction(steps, 0, "size", « », globalObject’s relevant Realm).
|
||||
auto function = JS::NativeFunction::create(realm, move(steps), 0, "size", &realm);
|
||||
auto function = JS::NativeFunction::create(realm, move(steps), 0, "size"_fly_string, &realm);
|
||||
|
||||
// 3. Set globalObject’s count queuing strategy size function to a Function that represents a reference to F, with callback context equal to globalObject’s relevant settings object.
|
||||
// FIXME: Update spec comment to pass globalObject's relevant realm once Streams spec is updated for ShadowRealm spec
|
||||
|
@ -146,7 +146,7 @@ GC::Ref<WebIDL::CallbackType> UniversalGlobalScopeMixin::byte_length_queuing_str
|
|||
};
|
||||
|
||||
// 2. Let F be ! CreateBuiltinFunction(steps, 1, "size", « », globalObject’s relevant Realm).
|
||||
auto function = JS::NativeFunction::create(realm, move(steps), 1, "size", &realm);
|
||||
auto function = JS::NativeFunction::create(realm, move(steps), 1, "size"_fly_string, &realm);
|
||||
|
||||
// 3. Set globalObject’s byte length queuing strategy size function to a Function that represents a reference to F, with callback context equal to globalObject’s relevant settings object.
|
||||
// FIXME: Update spec comment to pass globalObject's relevant realm once Streams spec is updated for ShadowRealm spec
|
||||
|
|
|
@ -734,7 +734,7 @@ WebIDL::ExceptionOr<void> Window::initialize_web_interfaces(Badge<WindowEnvironm
|
|||
WindowOrWorkerGlobalScopeMixin::initialize(realm);
|
||||
|
||||
if (s_internals_object_exposed)
|
||||
define_direct_property("internals", realm.create<Internals::Internals>(realm), JS::default_attributes);
|
||||
define_direct_property("internals"_fly_string, realm.create<Internals::Internals>(realm), JS::default_attributes);
|
||||
|
||||
if (url.scheme() == "about"sv && url.paths().size() == 1) {
|
||||
auto const& path = url.paths().first();
|
||||
|
|
|
@ -633,7 +633,7 @@ void WindowOrWorkerGlobalScopeMixin::queue_the_performance_observer_task()
|
|||
// droppedEntriesCount if droppedEntriesCount is not null, otherwise unset.
|
||||
auto callback_options = JS::Object::create(realm, realm.intrinsics().object_prototype());
|
||||
if (dropped_entries_count.has_value())
|
||||
MUST(callback_options->create_data_property("droppedEntriesCount", JS::Value(dropped_entries_count.value())));
|
||||
MUST(callback_options->create_data_property("droppedEntriesCount"_fly_string, JS::Value(dropped_entries_count.value())));
|
||||
|
||||
// 9. Call po’s observer callback with observerEntryList as the first argument, with po as the second
|
||||
// argument and as callback this value, and with callbackOptions as the third argument.
|
||||
|
|
|
@ -215,8 +215,8 @@ GC::Ref<WebIDL::Promise> IDBFactory::databases()
|
|||
// 2. Set info’s name dictionary member to db’s name.
|
||||
// 3. Set info’s version dictionary member to db’s version.
|
||||
auto info = JS::Object::create(realm, realm.intrinsics().object_prototype());
|
||||
MUST(info->create_data_property("name", JS::PrimitiveString::create(realm.vm(), db->name())));
|
||||
MUST(info->create_data_property("version", JS::Value(db->version())));
|
||||
MUST(info->create_data_property("name"_fly_string, JS::PrimitiveString::create(realm.vm(), db->name())));
|
||||
MUST(info->create_data_property("version"_fly_string, JS::Value(db->version())));
|
||||
|
||||
// 4. Append info to result.
|
||||
MUST(result->create_data_property_or_throw(i, info));
|
||||
|
|
|
@ -63,8 +63,8 @@ JS::Object* Internals::hit_test(double x, double y)
|
|||
auto result = active_document.paintable_box()->hit_test({ x, y }, Painting::HitTestType::Exact);
|
||||
if (result.has_value()) {
|
||||
auto hit_tеsting_result = JS::Object::create(realm(), nullptr);
|
||||
hit_tеsting_result->define_direct_property("node", result->dom_node(), JS::default_attributes);
|
||||
hit_tеsting_result->define_direct_property("indexInNode", JS::Value(result->index_in_node), JS::default_attributes);
|
||||
hit_tеsting_result->define_direct_property("node"_fly_string, result->dom_node(), JS::default_attributes);
|
||||
hit_tеsting_result->define_direct_property("indexInNode"_fly_string, JS::Value(result->index_in_node), JS::default_attributes);
|
||||
return hit_tеsting_result;
|
||||
}
|
||||
return nullptr;
|
||||
|
|
|
@ -236,9 +236,9 @@ GC::Ref<JS::Object> MediaCapabilitiesDecodingInfo::to_object(JS::Realm& realm)
|
|||
|
||||
// FIXME: Also include configuration in this object.
|
||||
|
||||
MUST(object->create_data_property("supported", JS::BooleanObject::create(realm, supported)));
|
||||
MUST(object->create_data_property("smooth", JS::BooleanObject::create(realm, smooth)));
|
||||
MUST(object->create_data_property("powerEfficent", JS::BooleanObject::create(realm, power_efficient)));
|
||||
MUST(object->create_data_property("supported"_fly_string, JS::BooleanObject::create(realm, supported)));
|
||||
MUST(object->create_data_property("smooth"_fly_string, JS::BooleanObject::create(realm, smooth)));
|
||||
MUST(object->create_data_property("powerEfficent"_fly_string, JS::BooleanObject::create(realm, power_efficient)));
|
||||
|
||||
return object;
|
||||
}
|
||||
|
|
|
@ -19,19 +19,19 @@ JS::ThrowCompletionOr<Transformer> Transformer::from_value(JS::VM& vm, JS::Value
|
|||
auto& object = value.as_object();
|
||||
|
||||
Transformer transformer {
|
||||
.start = TRY(WebIDL::property_to_callback(vm, value, "start", WebIDL::OperationReturnsPromise::No)),
|
||||
.transform = TRY(WebIDL::property_to_callback(vm, value, "transform", WebIDL::OperationReturnsPromise::Yes)),
|
||||
.flush = TRY(WebIDL::property_to_callback(vm, value, "flush", WebIDL::OperationReturnsPromise::Yes)),
|
||||
.cancel = TRY(WebIDL::property_to_callback(vm, value, "cancel", WebIDL::OperationReturnsPromise::Yes)),
|
||||
.start = TRY(WebIDL::property_to_callback(vm, value, "start"_fly_string, WebIDL::OperationReturnsPromise::No)),
|
||||
.transform = TRY(WebIDL::property_to_callback(vm, value, "transform"_fly_string, WebIDL::OperationReturnsPromise::Yes)),
|
||||
.flush = TRY(WebIDL::property_to_callback(vm, value, "flush"_fly_string, WebIDL::OperationReturnsPromise::Yes)),
|
||||
.cancel = TRY(WebIDL::property_to_callback(vm, value, "cancel"_fly_string, WebIDL::OperationReturnsPromise::Yes)),
|
||||
.readable_type = {},
|
||||
.writable_type = {},
|
||||
};
|
||||
|
||||
if (TRY(object.has_property("readableType")))
|
||||
transformer.readable_type = TRY(object.get("readableType"));
|
||||
if (TRY(object.has_property("readableType"_fly_string)))
|
||||
transformer.readable_type = TRY(object.get("readableType"_fly_string));
|
||||
|
||||
if (TRY(object.has_property("writableType")))
|
||||
transformer.writable_type = TRY(object.get("writableType"));
|
||||
if (TRY(object.has_property("writableType"_fly_string)))
|
||||
transformer.writable_type = TRY(object.get("writableType"_fly_string));
|
||||
|
||||
return transformer;
|
||||
}
|
||||
|
|
|
@ -19,15 +19,15 @@ JS::ThrowCompletionOr<UnderlyingSink> UnderlyingSink::from_value(JS::VM& vm, JS:
|
|||
auto& object = value.as_object();
|
||||
|
||||
UnderlyingSink underlying_sink {
|
||||
.start = TRY(WebIDL::property_to_callback(vm, value, "start", WebIDL::OperationReturnsPromise::No)),
|
||||
.write = TRY(WebIDL::property_to_callback(vm, value, "write", WebIDL::OperationReturnsPromise::Yes)),
|
||||
.close = TRY(WebIDL::property_to_callback(vm, value, "close", WebIDL::OperationReturnsPromise::Yes)),
|
||||
.abort = TRY(WebIDL::property_to_callback(vm, value, "abort", WebIDL::OperationReturnsPromise::Yes)),
|
||||
.start = TRY(WebIDL::property_to_callback(vm, value, "start"_fly_string, WebIDL::OperationReturnsPromise::No)),
|
||||
.write = TRY(WebIDL::property_to_callback(vm, value, "write"_fly_string, WebIDL::OperationReturnsPromise::Yes)),
|
||||
.close = TRY(WebIDL::property_to_callback(vm, value, "close"_fly_string, WebIDL::OperationReturnsPromise::Yes)),
|
||||
.abort = TRY(WebIDL::property_to_callback(vm, value, "abort"_fly_string, WebIDL::OperationReturnsPromise::Yes)),
|
||||
.type = {},
|
||||
};
|
||||
|
||||
if (TRY(object.has_property("type")))
|
||||
underlying_sink.type = TRY(object.get("type"));
|
||||
if (TRY(object.has_property("type"_fly_string)))
|
||||
underlying_sink.type = TRY(object.get("type"_fly_string));
|
||||
|
||||
return underlying_sink;
|
||||
}
|
||||
|
|
|
@ -22,14 +22,14 @@ JS::ThrowCompletionOr<UnderlyingSource> UnderlyingSource::from_value(JS::VM& vm,
|
|||
auto& object = value.as_object();
|
||||
|
||||
UnderlyingSource underlying_source {
|
||||
.start = TRY(WebIDL::property_to_callback(vm, value, "start", WebIDL::OperationReturnsPromise::No)),
|
||||
.pull = TRY(WebIDL::property_to_callback(vm, value, "pull", WebIDL::OperationReturnsPromise::Yes)),
|
||||
.cancel = TRY(WebIDL::property_to_callback(vm, value, "cancel", WebIDL::OperationReturnsPromise::Yes)),
|
||||
.start = TRY(WebIDL::property_to_callback(vm, value, "start"_fly_string, WebIDL::OperationReturnsPromise::No)),
|
||||
.pull = TRY(WebIDL::property_to_callback(vm, value, "pull"_fly_string, WebIDL::OperationReturnsPromise::Yes)),
|
||||
.cancel = TRY(WebIDL::property_to_callback(vm, value, "cancel"_fly_string, WebIDL::OperationReturnsPromise::Yes)),
|
||||
.type = {},
|
||||
.auto_allocate_chunk_size = {},
|
||||
};
|
||||
|
||||
auto type_value = TRY(object.get("type"));
|
||||
auto type_value = TRY(object.get("type"_fly_string));
|
||||
if (!type_value.is_undefined()) {
|
||||
auto type_string = TRY(type_value.to_string(vm));
|
||||
if (type_string == "bytes"sv)
|
||||
|
@ -38,8 +38,8 @@ JS::ThrowCompletionOr<UnderlyingSource> UnderlyingSource::from_value(JS::VM& vm,
|
|||
return vm.throw_completion<JS::TypeError>(MUST(String::formatted("Unknown stream type '{}'", type_value)));
|
||||
}
|
||||
|
||||
if (TRY(object.has_property("autoAllocateChunkSize"))) {
|
||||
auto value = TRY(object.get("autoAllocateChunkSize"));
|
||||
if (TRY(object.has_property("autoAllocateChunkSize"_fly_string))) {
|
||||
auto value = TRY(object.get("autoAllocateChunkSize"_fly_string));
|
||||
underlying_source.auto_allocate_chunk_size = TRY(WebIDL::convert_to_int<WebIDL::UnsignedLongLong>(vm, value, WebIDL::EnforceRange::Yes));
|
||||
}
|
||||
|
||||
|
|
|
@ -674,8 +674,8 @@ GC::Ref<WebIDL::Promise> instantiate_promise_of_module(JS::VM& vm, GC::Ref<WebID
|
|||
|
||||
// 1. Let result be the WebAssemblyInstantiatedSource value «[ "module" → module, "instance" → instance ]».
|
||||
auto result = JS::Object::create(realm, nullptr);
|
||||
result->define_direct_property("module", module, JS::default_attributes);
|
||||
result->define_direct_property("instance", instance, JS::default_attributes);
|
||||
result->define_direct_property("module"_fly_string, module, JS::default_attributes);
|
||||
result->define_direct_property("instance"_fly_string, instance, JS::default_attributes);
|
||||
|
||||
// 2. Resolve promise with result.
|
||||
WebIDL::resolve_promise(realm, promise, result);
|
||||
|
|
|
@ -23,7 +23,7 @@ JS::ThrowCompletionOr<WebGLContextAttributes> convert_value_to_context_attribute
|
|||
if (value.is_nullish())
|
||||
alpha = JS::js_undefined();
|
||||
else
|
||||
alpha = TRY(value.as_object().get("alpha"));
|
||||
alpha = TRY(value.as_object().get("alpha"_fly_string));
|
||||
|
||||
bool alpha_value;
|
||||
if (!alpha.is_undefined())
|
||||
|
@ -37,7 +37,7 @@ JS::ThrowCompletionOr<WebGLContextAttributes> convert_value_to_context_attribute
|
|||
if (value.is_nullish())
|
||||
antialias = JS::js_undefined();
|
||||
else
|
||||
antialias = TRY(value.as_object().get("antialias"));
|
||||
antialias = TRY(value.as_object().get("antialias"_fly_string));
|
||||
|
||||
bool antialias_value;
|
||||
if (!antialias.is_undefined())
|
||||
|
@ -51,7 +51,7 @@ JS::ThrowCompletionOr<WebGLContextAttributes> convert_value_to_context_attribute
|
|||
if (value.is_nullish())
|
||||
depth = JS::js_undefined();
|
||||
else
|
||||
depth = TRY(value.as_object().get("depth"));
|
||||
depth = TRY(value.as_object().get("depth"_fly_string));
|
||||
|
||||
bool depth_value;
|
||||
if (!depth.is_undefined())
|
||||
|
@ -65,7 +65,7 @@ JS::ThrowCompletionOr<WebGLContextAttributes> convert_value_to_context_attribute
|
|||
if (value.is_nullish())
|
||||
desynchronized = JS::js_undefined();
|
||||
else
|
||||
desynchronized = TRY(value.as_object().get("desynchronized"));
|
||||
desynchronized = TRY(value.as_object().get("desynchronized"_fly_string));
|
||||
|
||||
bool desynchronized_value;
|
||||
|
||||
|
@ -80,7 +80,7 @@ JS::ThrowCompletionOr<WebGLContextAttributes> convert_value_to_context_attribute
|
|||
if (value.is_nullish())
|
||||
fail_if_major_performance_caveat = JS::js_undefined();
|
||||
else
|
||||
fail_if_major_performance_caveat = TRY(value.as_object().get("failIfMajorPerformanceCaveat"));
|
||||
fail_if_major_performance_caveat = TRY(value.as_object().get("failIfMajorPerformanceCaveat"_fly_string));
|
||||
|
||||
bool fail_if_major_performance_caveat_value;
|
||||
if (!fail_if_major_performance_caveat.is_undefined())
|
||||
|
@ -94,7 +94,7 @@ JS::ThrowCompletionOr<WebGLContextAttributes> convert_value_to_context_attribute
|
|||
if (value.is_nullish())
|
||||
power_preference = JS::js_undefined();
|
||||
else
|
||||
power_preference = TRY(value.as_object().get("powerPreference"));
|
||||
power_preference = TRY(value.as_object().get("powerPreference"_fly_string));
|
||||
|
||||
Bindings::WebGLPowerPreference power_preference_value { Bindings::WebGLPowerPreference::Default };
|
||||
|
||||
|
@ -117,7 +117,7 @@ JS::ThrowCompletionOr<WebGLContextAttributes> convert_value_to_context_attribute
|
|||
if (value.is_nullish())
|
||||
premultiplied_alpha = JS::js_undefined();
|
||||
else
|
||||
premultiplied_alpha = TRY(value.as_object().get("premultipliedAlpha"));
|
||||
premultiplied_alpha = TRY(value.as_object().get("premultipliedAlpha"_fly_string));
|
||||
|
||||
bool premultiplied_alpha_value;
|
||||
|
||||
|
@ -132,7 +132,7 @@ JS::ThrowCompletionOr<WebGLContextAttributes> convert_value_to_context_attribute
|
|||
if (value.is_nullish())
|
||||
preserve_drawing_buffer = JS::js_undefined();
|
||||
else
|
||||
preserve_drawing_buffer = TRY(value.as_object().get("preserveDrawingBuffer"));
|
||||
preserve_drawing_buffer = TRY(value.as_object().get("preserveDrawingBuffer"_fly_string));
|
||||
|
||||
bool preserve_drawing_buffer_value;
|
||||
if (!preserve_drawing_buffer.is_undefined())
|
||||
|
@ -146,7 +146,7 @@ JS::ThrowCompletionOr<WebGLContextAttributes> convert_value_to_context_attribute
|
|||
if (value.is_nullish())
|
||||
stencil = JS::js_undefined();
|
||||
else
|
||||
stencil = TRY(value.as_object().get("stencil"));
|
||||
stencil = TRY(value.as_object().get("stencil"_fly_string));
|
||||
|
||||
bool stencil_value;
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ GC::Ref<Promise> react_to_promise(Promise const& promise, GC::Ptr<ReactionSteps>
|
|||
};
|
||||
|
||||
// 2. Let onFulfilled be CreateBuiltinFunction(onFulfilledSteps, « »):
|
||||
auto on_fulfilled = JS::NativeFunction::create(realm, move(on_fulfilled_steps), 1, "");
|
||||
auto on_fulfilled = JS::NativeFunction::create(realm, move(on_fulfilled_steps), 1);
|
||||
|
||||
// 3. Let onRejectedSteps be the following steps given argument R:
|
||||
auto on_rejected_steps = [&realm, on_rejected_callback = move(on_rejected_callback)](JS::VM& vm) -> JS::ThrowCompletionOr<JS::Value> {
|
||||
|
@ -129,7 +129,7 @@ GC::Ref<Promise> react_to_promise(Promise const& promise, GC::Ptr<ReactionSteps>
|
|||
};
|
||||
|
||||
// 4. Let onRejected be CreateBuiltinFunction(onRejectedSteps, « »):
|
||||
auto on_rejected = JS::NativeFunction::create(realm, move(on_rejected_steps), 1, "");
|
||||
auto on_rejected = JS::NativeFunction::create(realm, move(on_rejected_steps), 1);
|
||||
|
||||
// 5. Let constructor be promise.[[Promise]].[[Realm]].[[Intrinsics]].[[%Promise%]].
|
||||
auto constructor = realm.intrinsics().promise_constructor();
|
||||
|
@ -232,7 +232,7 @@ void wait_for_all(JS::Realm& realm, Vector<GC::Ref<Promise>> const& promises, Fu
|
|||
};
|
||||
|
||||
// 4. Let rejectionHandler be CreateBuiltinFunction(rejectionHandlerSteps, « »):
|
||||
auto rejection_handler = JS::NativeFunction::create(realm, move(rejection_handler_steps), 1, "");
|
||||
auto rejection_handler = JS::NativeFunction::create(realm, move(rejection_handler_steps), 1);
|
||||
|
||||
// 5. Let total be promises’s size.
|
||||
auto total = promises.size();
|
||||
|
@ -280,7 +280,7 @@ void wait_for_all(JS::Realm& realm, Vector<GC::Ref<Promise>> const& promises, Fu
|
|||
};
|
||||
|
||||
// 3. Let fulfillmentHandler be CreateBuiltinFunction(fulfillmentHandler, « »):
|
||||
auto fulfillment_handler = JS::NativeFunction::create(realm, move(fulfillment_handler_steps), 1, "");
|
||||
auto fulfillment_handler = JS::NativeFunction::create(realm, move(fulfillment_handler_steps), 1);
|
||||
|
||||
// 4. Perform PerformPromiseThen(promise, fulfillmentHandler, rejectionHandler).
|
||||
static_cast<JS::Promise&>(*promise->promise()).perform_then(fulfillment_handler, rejection_handler, nullptr);
|
||||
|
|
|
@ -929,7 +929,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
|
|||
dictionary_generator.append(R"~~~(
|
||||
auto @member_property_value_name@ = JS::js_undefined();
|
||||
if (@js_name@@js_suffix@.is_object())
|
||||
@member_property_value_name@ = TRY(@js_name@@js_suffix@.as_object().get("@member_key@"));
|
||||
@member_property_value_name@ = TRY(@js_name@@js_suffix@.as_object().get("@member_key@"_fly_string));
|
||||
)~~~");
|
||||
if (member.required) {
|
||||
dictionary_generator.append(R"~~~(
|
||||
|
@ -2039,7 +2039,7 @@ static void generate_wrap_statement(SourceGenerator& generator, ByteString const
|
|||
generate_wrap_statement(dictionary_generator, ByteString::formatted("{}{}{}", value, type.is_nullable() ? "->" : ".", member.name.to_snakecase()), member.type, interface, ByteString::formatted("{} =", wrapped_value_name), WrappingReference::No, recursion_depth + 1, is_optional);
|
||||
|
||||
dictionary_generator.append(R"~~~(
|
||||
MUST(dictionary_object@recursion_depth@->create_data_property("@member_key@", @wrapped_value_name@));
|
||||
MUST(dictionary_object@recursion_depth@->create_data_property("@member_key@"_fly_string, @wrapped_value_name@));
|
||||
)~~~");
|
||||
}
|
||||
|
||||
|
@ -3112,7 +3112,7 @@ static void collect_attribute_values_of_an_inheritance_stack(SourceGenerator& fu
|
|||
generate_wrap_statement(attribute_generator, return_value_name, attribute.type, interface_in_chain, ByteString::formatted("auto {}_wrapped =", return_value_name));
|
||||
|
||||
attribute_generator.append(R"~~~(
|
||||
MUST(result->create_data_property("@attribute.name@", @attribute.return_value_name@_wrapped));
|
||||
MUST(result->create_data_property("@attribute.name@"_fly_string, @attribute.return_value_name@_wrapped));
|
||||
)~~~");
|
||||
}
|
||||
|
||||
|
@ -3123,7 +3123,7 @@ static void collect_attribute_values_of_an_inheritance_stack(SourceGenerator& fu
|
|||
generate_wrap_statement(constant_generator, constant.value, constant.type, interface_in_chain, ByteString::formatted("auto constant_{}_value =", constant.name));
|
||||
|
||||
constant_generator.append(R"~~~(
|
||||
MUST(result->create_data_property("@constant.name@", constant_@constant.name@_value));
|
||||
MUST(result->create_data_property("@constant.name@"_fly_string, constant_@constant.name@_value));
|
||||
)~~~");
|
||||
}
|
||||
}
|
||||
|
@ -3422,7 +3422,7 @@ void @class_name@::initialize(JS::Realm& realm)
|
|||
auto fixme_attribute_generator = generator.fork();
|
||||
fixme_attribute_generator.set("attribute.name", attribute.name);
|
||||
fixme_attribute_generator.append(R"~~~(
|
||||
define_direct_property("@attribute.name@", JS::js_undefined(), default_attributes | JS::Attribute::Unimplemented);
|
||||
define_direct_property("@attribute.name@"_fly_string, JS::js_undefined(), default_attributes | JS::Attribute::Unimplemented);
|
||||
)~~~");
|
||||
continue;
|
||||
}
|
||||
|
@ -3438,12 +3438,12 @@ void @class_name@::initialize(JS::Realm& realm)
|
|||
|
||||
if (attribute.extended_attributes.contains("Unscopable")) {
|
||||
attribute_generator.append(R"~~~(
|
||||
MUST(unscopable_object->create_data_property("@attribute.name@", JS::Value(true)));
|
||||
MUST(unscopable_object->create_data_property("@attribute.name@"_fly_string, JS::Value(true)));
|
||||
)~~~");
|
||||
}
|
||||
|
||||
attribute_generator.append(R"~~~(
|
||||
define_native_accessor(realm, "@attribute.name@", @attribute.getter_callback@, @attribute.setter_callback@, default_attributes);
|
||||
define_native_accessor(realm, "@attribute.name@"_fly_string, @attribute.getter_callback@, @attribute.setter_callback@, default_attributes);
|
||||
)~~~");
|
||||
}
|
||||
|
||||
|
@ -3452,7 +3452,7 @@ void @class_name@::initialize(JS::Realm& realm)
|
|||
auto fixme_function_generator = generator.fork();
|
||||
fixme_function_generator.set("function.name", function.name);
|
||||
fixme_function_generator.append(R"~~~(
|
||||
define_direct_property("@function.name@", JS::js_undefined(), default_attributes | JS::Attribute::Unimplemented);
|
||||
define_direct_property("@function.name@"_fly_string, JS::js_undefined(), default_attributes | JS::Attribute::Unimplemented);
|
||||
)~~~");
|
||||
}
|
||||
}
|
||||
|
@ -3467,7 +3467,7 @@ void @class_name@::initialize(JS::Realm& realm)
|
|||
generate_wrap_statement(constant_generator, constant.value, constant.type, interface, ByteString::formatted("auto constant_{}_value =", constant.name));
|
||||
|
||||
constant_generator.append(R"~~~(
|
||||
define_direct_property("@constant.name@", constant_@constant.name@_value, JS::Attribute::Enumerable);
|
||||
define_direct_property("@constant.name@"_fly_string, constant_@constant.name@_value, JS::Attribute::Enumerable);
|
||||
)~~~");
|
||||
}
|
||||
|
||||
|
@ -3481,12 +3481,12 @@ void @class_name@::initialize(JS::Realm& realm)
|
|||
if (any_of(overload_set.value, [](auto const& function) { return function.extended_attributes.contains("Unscopable"); })) {
|
||||
VERIFY(all_of(overload_set.value, [](auto const& function) { return function.extended_attributes.contains("Unscopable"); }));
|
||||
function_generator.append(R"~~~(
|
||||
MUST(unscopable_object->create_data_property("@function.name@", JS::Value(true)));
|
||||
MUST(unscopable_object->create_data_property("@function.name@"_fly_string, JS::Value(true)));
|
||||
)~~~");
|
||||
}
|
||||
|
||||
function_generator.append(R"~~~(
|
||||
define_native_function(realm, "@function.name@", @function.name:snakecase@, @function.length@, default_attributes);
|
||||
define_native_function(realm, "@function.name@"_fly_string, @function.name:snakecase@, @function.length@, default_attributes);
|
||||
)~~~");
|
||||
}
|
||||
|
||||
|
@ -3495,7 +3495,7 @@ void @class_name@::initialize(JS::Realm& realm)
|
|||
|
||||
auto stringifier_generator = generator.fork();
|
||||
stringifier_generator.append(R"~~~(
|
||||
define_native_function(realm, "toString", to_string, 0, default_attributes);
|
||||
define_native_function(realm, "toString"_fly_string, to_string, 0, default_attributes);
|
||||
)~~~");
|
||||
}
|
||||
|
||||
|
@ -4142,7 +4142,7 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::@attribute.setter_callback@)
|
|||
}
|
||||
|
||||
if (window) {
|
||||
TRY(window->internal_define_own_property("@attribute.name@", JS::PropertyDescriptor { .value = vm.argument(0), .writable = true }));
|
||||
TRY(window->internal_define_own_property("@attribute.name@"_fly_string, JS::PropertyDescriptor { .value = vm.argument(0), .writable = true }));
|
||||
return JS::js_undefined();
|
||||
}
|
||||
|
||||
|
@ -4160,7 +4160,7 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::@attribute.setter_callback@)
|
|||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "@namespaced_name@");
|
||||
if (vm.argument_count() < 1)
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::BadArgCountOne, "@namespaced_name@ setter");
|
||||
TRY(this_value.as_object().internal_define_own_property("@attribute.name@", JS::PropertyDescriptor { .value = vm.argument(0), .writable = true }));
|
||||
TRY(this_value.as_object().internal_define_own_property("@attribute.name@"_fly_string, JS::PropertyDescriptor { .value = vm.argument(0), .writable = true }));
|
||||
return JS::js_undefined();
|
||||
}
|
||||
)~~~");
|
||||
|
@ -4613,7 +4613,7 @@ void @namespace_class@::initialize(JS::Realm& realm)
|
|||
function_generator.set("function.length", ByteString::number(get_shortest_function_length(overload_set.value)));
|
||||
|
||||
function_generator.append(R"~~~(
|
||||
define_native_function(realm, "@function.name@", @function.name:snakecase@, @function.length@, default_attributes);
|
||||
define_native_function(realm, "@function.name@"_fly_string, @function.name:snakecase@, @function.length@, default_attributes);
|
||||
)~~~");
|
||||
}
|
||||
|
||||
|
@ -4749,7 +4749,7 @@ static void define_the_operations(SourceGenerator& generator, HashMap<ByteString
|
|||
function_generator.set("function.attributes", "JS::Attribute::Writable | JS::Attribute::Enumerable | JS::Attribute::Configurable");
|
||||
|
||||
function_generator.append(R"~~~(
|
||||
define_native_function(realm, "@function.name@", @function.name:snakecase@, @function.length@, @function.attributes@);
|
||||
define_native_function(realm, "@function.name@"_fly_string, @function.name:snakecase@, @function.length@, @function.attributes@);
|
||||
)~~~");
|
||||
}
|
||||
}
|
||||
|
@ -4865,7 +4865,7 @@ void @constructor_class@::initialize(JS::Realm& realm)
|
|||
generate_wrap_statement(constant_generator, constant.value, constant.type, interface, ByteString::formatted("auto constant_{}_value =", constant.name));
|
||||
|
||||
constant_generator.append(R"~~~(
|
||||
define_direct_property("@constant.name@", constant_@constant.name@_value, JS::Attribute::Enumerable);
|
||||
define_direct_property("@constant.name@"_fly_string, constant_@constant.name@_value, JS::Attribute::Enumerable);
|
||||
)~~~");
|
||||
}
|
||||
|
||||
|
@ -4881,7 +4881,7 @@ void @constructor_class@::initialize(JS::Realm& realm)
|
|||
attribute_generator.set("attribute.setter_callback", "nullptr");
|
||||
|
||||
attribute_generator.append(R"~~~(
|
||||
define_native_accessor(realm, "@attribute.name@", @attribute.getter_callback@, @attribute.setter_callback@, default_attributes);
|
||||
define_native_accessor(realm, "@attribute.name@"_fly_string, @attribute.getter_callback@, @attribute.setter_callback@, default_attributes);
|
||||
)~~~");
|
||||
}
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ void Intrinsics::create_web_namespace<@namespace_class@>(JS::Realm& realm)
|
|||
gen.set("owned_prototype_class", interface.prototype_class);
|
||||
|
||||
gen.append(R"~~~(
|
||||
namespace_object->define_intrinsic_accessor("@owned_interface_name@", attr, [](auto& realm) -> JS::Value { return &Bindings::ensure_web_constructor<@owned_prototype_class@>(realm, "@interface_name@.@owned_interface_name@"_fly_string); });)~~~");
|
||||
namespace_object->define_intrinsic_accessor("@owned_interface_name@"_fly_string, attr, [](auto& realm) -> JS::Value { return &Bindings::ensure_web_constructor<@owned_prototype_class@>(realm, "@interface_name@.@owned_interface_name@"_fly_string); });)~~~");
|
||||
}
|
||||
|
||||
gen.append(R"~~~(
|
||||
|
@ -267,7 +267,7 @@ void add_@global_object_snake_name@_exposed_interfaces(JS::Object& global)
|
|||
gen.set("prototype_class", prototype_class);
|
||||
|
||||
gen.append(R"~~~(
|
||||
global.define_intrinsic_accessor("@interface_name@", attr, [](auto& realm) -> JS::Value { return &ensure_web_constructor<@prototype_class@>(realm, "@interface_name@"_fly_string); });)~~~");
|
||||
global.define_intrinsic_accessor("@interface_name@"_fly_string, attr, [](auto& realm) -> JS::Value { return &ensure_web_constructor<@prototype_class@>(realm, "@interface_name@"_fly_string); });)~~~");
|
||||
|
||||
// https://webidl.spec.whatwg.org/#LegacyWindowAlias
|
||||
if (legacy_alias_name.has_value()) {
|
||||
|
@ -276,19 +276,19 @@ void add_@global_object_snake_name@_exposed_interfaces(JS::Object& global)
|
|||
for (auto legacy_alias_name : legacy_alias_names) {
|
||||
gen.set("interface_alias_name", legacy_alias_name.trim_whitespace());
|
||||
gen.append(R"~~~(
|
||||
global.define_intrinsic_accessor("@interface_alias_name@", attr, [](auto& realm) -> JS::Value { return &ensure_web_constructor<@prototype_class@>(realm, "@interface_name@"_fly_string); });)~~~");
|
||||
global.define_intrinsic_accessor("@interface_alias_name@"_fly_string, attr, [](auto& realm) -> JS::Value { return &ensure_web_constructor<@prototype_class@>(realm, "@interface_name@"_fly_string); });)~~~");
|
||||
}
|
||||
} else {
|
||||
gen.set("interface_alias_name", *legacy_alias_name);
|
||||
gen.append(R"~~~(
|
||||
global.define_intrinsic_accessor("@interface_alias_name@", attr, [](auto& realm) -> JS::Value { return &ensure_web_constructor<@prototype_class@>(realm, "@interface_name@"_fly_string); });)~~~");
|
||||
global.define_intrinsic_accessor("@interface_alias_name@"_fly_string, attr, [](auto& realm) -> JS::Value { return &ensure_web_constructor<@prototype_class@>(realm, "@interface_name@"_fly_string); });)~~~");
|
||||
}
|
||||
}
|
||||
|
||||
if (legacy_constructor.has_value()) {
|
||||
gen.set("legacy_interface_name", legacy_constructor->name);
|
||||
gen.append(R"~~~(
|
||||
global.define_intrinsic_accessor("@legacy_interface_name@", attr, [](auto& realm) -> JS::Value { return &ensure_web_constructor<@prototype_class@>(realm, "@legacy_interface_name@"_fly_string); });)~~~");
|
||||
global.define_intrinsic_accessor("@legacy_interface_name@"_fly_string, attr, [](auto& realm) -> JS::Value { return &ensure_web_constructor<@prototype_class@>(realm, "@legacy_interface_name@"_fly_string); });)~~~");
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -297,7 +297,7 @@ void add_@global_object_snake_name@_exposed_interfaces(JS::Object& global)
|
|||
gen.set("namespace_class", namespace_class);
|
||||
|
||||
gen.append(R"~~~(
|
||||
global.define_intrinsic_accessor("@interface_name@", attr, [](auto& realm) -> JS::Value { return &ensure_web_namespace<@namespace_class@>(realm, "@interface_name@"_fly_string); });)~~~");
|
||||
global.define_intrinsic_accessor("@interface_name@"_fly_string, attr, [](auto& realm) -> JS::Value { return &ensure_web_namespace<@namespace_class@>(realm, "@interface_name@"_fly_string); });)~~~");
|
||||
};
|
||||
|
||||
for (auto& interface : exposed_interfaces) {
|
||||
|
|
|
@ -27,10 +27,10 @@ void ConsoleGlobalEnvironmentExtensions::initialize(JS::Realm& realm)
|
|||
{
|
||||
Base::initialize(realm);
|
||||
|
||||
define_native_accessor(realm, "$0", $0_getter, nullptr, 0);
|
||||
define_native_accessor(realm, "$_", $__getter, nullptr, 0);
|
||||
define_native_function(realm, "$", $_function, 2, JS::default_attributes);
|
||||
define_native_function(realm, "$$", $$_function, 2, JS::default_attributes);
|
||||
define_native_accessor(realm, "$0"_fly_string, $0_getter, nullptr, 0);
|
||||
define_native_accessor(realm, "$_"_fly_string, $__getter, nullptr, 0);
|
||||
define_native_function(realm, "$"_fly_string, $_function, 2, JS::default_attributes);
|
||||
define_native_function(realm, "$$"_fly_string, $$_function, 2, JS::default_attributes);
|
||||
}
|
||||
|
||||
void ConsoleGlobalEnvironmentExtensions::visit_edges(Visitor& visitor)
|
||||
|
|
|
@ -90,19 +90,19 @@ static ErrorOr<void, TestError> run_program(InterpreterT& interpreter, ScriptOrM
|
|||
if (error_value.is_object()) {
|
||||
auto& object = error_value.as_object();
|
||||
|
||||
auto name = object.get_without_side_effects("name");
|
||||
auto name = object.get_without_side_effects("name"_fly_string);
|
||||
if (!name.is_empty() && !name.is_accessor()) {
|
||||
error.type = name.to_string_without_side_effects();
|
||||
} else {
|
||||
auto constructor = object.get_without_side_effects("constructor");
|
||||
auto constructor = object.get_without_side_effects("constructor"_fly_string);
|
||||
if (constructor.is_object()) {
|
||||
name = constructor.as_object().get_without_side_effects("name");
|
||||
name = constructor.as_object().get_without_side_effects("name"_fly_string);
|
||||
if (!name.is_undefined())
|
||||
error.type = name.to_string_without_side_effects();
|
||||
}
|
||||
}
|
||||
|
||||
auto message = object.get_without_side_effects("message");
|
||||
auto message = object.get_without_side_effects("message"_fly_string);
|
||||
if (!message.is_empty() && !message.is_accessor())
|
||||
error.details = message.to_string_without_side_effects();
|
||||
}
|
||||
|
|
|
@ -243,7 +243,7 @@ TESTJS_GLOBAL_FUNCTION(test_simd_vector, testSIMDVector)
|
|||
if (!is<JS::TypedArrayBase>(*got))
|
||||
return vm.throw_completion<JS::TypeError>("Expected a TypedArray"sv);
|
||||
auto& got_array = static_cast<JS::TypedArrayBase&>(*got);
|
||||
auto element_size = 128 / TRY(TRY(expected_array.get("length")).to_u32(vm));
|
||||
auto element_size = 128 / TRY(TRY(expected_array.get("length"_fly_string)).to_u32(vm));
|
||||
size_t i = 0;
|
||||
for (auto it = expected_array.indexed_properties().begin(false); it != expected_array.indexed_properties().end(); ++it) {
|
||||
auto got_value = TRY(got_array.get(i++));
|
||||
|
@ -277,8 +277,8 @@ TESTJS_GLOBAL_FUNCTION(test_simd_vector, testSIMDVector)
|
|||
void WebAssemblyModule::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
define_native_function(realm, "getExport", get_export, 1, JS::default_attributes);
|
||||
define_native_function(realm, "invoke", wasm_invoke, 1, JS::default_attributes);
|
||||
define_native_function(realm, "getExport"_fly_string, get_export, 1, JS::default_attributes);
|
||||
define_native_function(realm, "invoke"_fly_string, wasm_invoke, 1, JS::default_attributes);
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(WebAssemblyModule::get_export)
|
||||
|
|
|
@ -323,18 +323,18 @@ void ReplObject::initialize(JS::Realm& realm)
|
|||
{
|
||||
Base::initialize(realm);
|
||||
|
||||
define_direct_property("global", this, JS::Attribute::Enumerable);
|
||||
define_direct_property("global"_fly_string, this, JS::Attribute::Enumerable);
|
||||
u8 attr = JS::Attribute::Configurable | JS::Attribute::Writable | JS::Attribute::Enumerable;
|
||||
define_native_function(realm, "exit", exit_interpreter, 0, attr);
|
||||
define_native_function(realm, "help", repl_help, 0, attr);
|
||||
define_native_function(realm, "save", save_to_file, 1, attr);
|
||||
define_native_function(realm, "loadINI", load_ini, 1, attr);
|
||||
define_native_function(realm, "loadJSON", load_json, 1, attr);
|
||||
define_native_function(realm, "print", print, 1, attr);
|
||||
define_native_function(realm, "exit"_fly_string, exit_interpreter, 0, attr);
|
||||
define_native_function(realm, "help"_fly_string, repl_help, 0, attr);
|
||||
define_native_function(realm, "save"_fly_string, save_to_file, 1, attr);
|
||||
define_native_function(realm, "loadINI"_fly_string, load_ini, 1, attr);
|
||||
define_native_function(realm, "loadJSON"_fly_string, load_json, 1, attr);
|
||||
define_native_function(realm, "print"_fly_string, print, 1, attr);
|
||||
|
||||
define_native_accessor(
|
||||
realm,
|
||||
"_",
|
||||
"_"_fly_string,
|
||||
[](JS::VM&) {
|
||||
return g_last_value.value();
|
||||
},
|
||||
|
@ -410,11 +410,11 @@ void ScriptObject::initialize(JS::Realm& realm)
|
|||
{
|
||||
Base::initialize(realm);
|
||||
|
||||
define_direct_property("global", this, JS::Attribute::Enumerable);
|
||||
define_direct_property("global"_fly_string, this, JS::Attribute::Enumerable);
|
||||
u8 attr = JS::Attribute::Configurable | JS::Attribute::Writable | JS::Attribute::Enumerable;
|
||||
define_native_function(realm, "loadINI", load_ini, 1, attr);
|
||||
define_native_function(realm, "loadJSON", load_json, 1, attr);
|
||||
define_native_function(realm, "print", print, 1, attr);
|
||||
define_native_function(realm, "loadINI"_fly_string, load_ini, 1, attr);
|
||||
define_native_function(realm, "loadJSON"_fly_string, load_json, 1, attr);
|
||||
define_native_function(realm, "print"_fly_string, print, 1, attr);
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(ScriptObject::load_ini)
|
||||
|
|
Loading…
Add table
Reference in a new issue