summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-10-22 22:48:25 +0100
committerLinus Groh <mail@linusgroh.de>2021-10-22 23:20:18 +0100
commit15eadcf023ac23640452b88f46c4054110ad5215 (patch)
tree1dc6112701ead16e78fb9f873abc57840d481c8e /Userland
parent68df9e4dfb3da6c7cb61e5d58a40b97913699d85 (diff)
downloadserenity-15eadcf023ac23640452b88f46c4054110ad5215.zip
LibJS: Convert Intl.DisplayNames functions to ThrowCompletionOr
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp8
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.h2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp16
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.h4
4 files changed, 15 insertions, 15 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp
index a36a2af2af..24856e7058 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp
@@ -31,7 +31,7 @@ void DisplayNamesConstructor::initialize(GlobalObject& global_object)
define_direct_property(vm.names.prototype, global_object.intl_display_names_prototype(), 0);
u8 attr = Attribute::Writable | Attribute::Configurable;
- define_old_native_function(vm.names.supportedLocalesOf, supported_locales_of, 1, attr);
+ define_native_function(vm.names.supportedLocalesOf, supported_locales_of, 1, attr);
define_direct_property(vm.names.length, Value(2), Attribute::Configurable);
}
@@ -112,7 +112,7 @@ ThrowCompletionOr<Object*> DisplayNamesConstructor::construct(FunctionObject& ne
}
// 12.3.2 Intl.DisplayNames.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-Intl.DisplayNames.supportedLocalesOf
-JS_DEFINE_OLD_NATIVE_FUNCTION(DisplayNamesConstructor::supported_locales_of)
+JS_DEFINE_NATIVE_FUNCTION(DisplayNamesConstructor::supported_locales_of)
{
auto locales = vm.argument(0);
auto options = vm.argument(1);
@@ -121,10 +121,10 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(DisplayNamesConstructor::supported_locales_of)
// No-op, availability of each requested locale is checked via Unicode::is_locale_available()
// 2. Let requestedLocales be ? CanonicalizeLocaleList(locales).
- auto requested_locales = TRY_OR_DISCARD(canonicalize_locale_list(global_object, locales));
+ auto requested_locales = TRY(canonicalize_locale_list(global_object, locales));
// 3. Return ? SupportedLocales(availableLocales, requestedLocales, options).
- return TRY_OR_DISCARD(supported_locales(global_object, requested_locales, options));
+ return TRY(supported_locales(global_object, requested_locales, options));
}
}
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.h b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.h
index 5fe7229d8f..e8968b9e87 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.h
+++ b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.h
@@ -24,7 +24,7 @@ public:
private:
virtual bool has_constructor() const override { return true; }
- JS_DECLARE_OLD_NATIVE_FUNCTION(supported_locales_of);
+ JS_DECLARE_NATIVE_FUNCTION(supported_locales_of);
};
}
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp
index cb0d0f63d8..5370b64670 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp
@@ -28,25 +28,25 @@ void DisplayNamesPrototype::initialize(GlobalObject& global_object)
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Intl.DisplayNames"), Attribute::Configurable);
u8 attr = Attribute::Writable | Attribute::Configurable;
- define_old_native_function(vm.names.of, of, 1, attr);
- define_old_native_function(vm.names.resolvedOptions, resolved_options, 0, attr);
+ define_native_function(vm.names.of, of, 1, attr);
+ define_native_function(vm.names.resolvedOptions, resolved_options, 0, attr);
}
// 12.4.3 Intl.DisplayNames.prototype.of ( code ), https://tc39.es/ecma402/#sec-Intl.DisplayNames.prototype.of
-JS_DEFINE_OLD_NATIVE_FUNCTION(DisplayNamesPrototype::of)
+JS_DEFINE_NATIVE_FUNCTION(DisplayNamesPrototype::of)
{
auto code = vm.argument(0);
// 1. Let displayNames be this value.
// 2. Perform ? RequireInternalSlot(displayNames, [[InitializedDisplayNames]]).
- auto* display_names = TRY_OR_DISCARD(typed_this_object(global_object));
+ auto* display_names = TRY(typed_this_object(global_object));
// 3. Let code be ? ToString(code).
- auto code_string = TRY_OR_DISCARD(code.to_string(global_object));
+ auto code_string = TRY(code.to_string(global_object));
code = js_string(vm, move(code_string));
// 4. Let code be ? CanonicalCodeForDisplayNames(displayNames.[[Type]], code).
- code = TRY_OR_DISCARD(canonical_code_for_display_names(global_object, display_names->type(), code.as_string().string()));
+ code = TRY(canonical_code_for_display_names(global_object, display_names->type(), code.as_string().string()));
// 5. Let fields be displayNames.[[Fields]].
// 6. If fields has a field [[<code>]], return fields.[[<code>]].
@@ -81,11 +81,11 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(DisplayNamesPrototype::of)
}
// 12.4.4 Intl.DisplayNames.prototype.resolvedOptions ( ), https://tc39.es/ecma402/#sec-Intl.DisplayNames.prototype.resolvedOptions
-JS_DEFINE_OLD_NATIVE_FUNCTION(DisplayNamesPrototype::resolved_options)
+JS_DEFINE_NATIVE_FUNCTION(DisplayNamesPrototype::resolved_options)
{
// 1. Let displayNames be this value.
// 2. Perform ? RequireInternalSlot(displayNames, [[InitializedDisplayNames]]).
- auto* display_names = TRY_OR_DISCARD(typed_this_object(global_object));
+ auto* display_names = TRY(typed_this_object(global_object));
// 3. Let options be ! OrdinaryObjectCreate(%Object.prototype%).
auto* options = Object::create(global_object, global_object.object_prototype());
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.h
index 6bc6ef975e..30e4d23f11 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.h
+++ b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.h
@@ -20,8 +20,8 @@ public:
virtual ~DisplayNamesPrototype() override = default;
private:
- JS_DECLARE_OLD_NATIVE_FUNCTION(of);
- JS_DECLARE_OLD_NATIVE_FUNCTION(resolved_options);
+ JS_DECLARE_NATIVE_FUNCTION(of);
+ JS_DECLARE_NATIVE_FUNCTION(resolved_options);
};
}