Procházet zdrojové kódy

LibJS: Convert Intl.ListFormat functions to ThrowCompletionOr

Linus Groh před 3 roky
rodič
revize
9fb1d7e18b

+ 4 - 4
Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp

@@ -30,7 +30,7 @@ void ListFormatConstructor::initialize(GlobalObject& global_object)
     define_direct_property(vm.names.prototype, global_object.intl_list_format_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(0), Attribute::Configurable);
 }
@@ -96,7 +96,7 @@ ThrowCompletionOr<Object*> ListFormatConstructor::construct(FunctionObject& new_
 }
 
 // 13.3.2 Intl.ListFormat.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-Intl.ListFormat.supportedLocalesOf
-JS_DEFINE_OLD_NATIVE_FUNCTION(ListFormatConstructor::supported_locales_of)
+JS_DEFINE_NATIVE_FUNCTION(ListFormatConstructor::supported_locales_of)
 {
     auto locales = vm.argument(0);
     auto options = vm.argument(1);
@@ -104,10 +104,10 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(ListFormatConstructor::supported_locales_of)
     // 1. Let availableLocales be %ListFormat%.[[AvailableLocales]].
 
     // 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));
 }
 
 }

+ 1 - 1
Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.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);
 };
 
 }

+ 11 - 11
Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp

@@ -28,22 +28,22 @@ void ListFormatPrototype::initialize(GlobalObject& global_object)
     define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Intl.ListFormat"), Attribute::Configurable);
 
     u8 attr = Attribute::Writable | Attribute::Configurable;
-    define_old_native_function(vm.names.format, format, 1, attr);
-    define_old_native_function(vm.names.formatToParts, format_to_parts, 1, attr);
-    define_old_native_function(vm.names.resolvedOptions, resolved_options, 0, attr);
+    define_native_function(vm.names.format, format, 1, attr);
+    define_native_function(vm.names.formatToParts, format_to_parts, 1, attr);
+    define_native_function(vm.names.resolvedOptions, resolved_options, 0, attr);
 }
 
 // 13.4.3 Intl.ListFormat.prototype.format ( list ), https://tc39.es/ecma402/#sec-Intl.ListFormat.prototype.format
-JS_DEFINE_OLD_NATIVE_FUNCTION(ListFormatPrototype::format)
+JS_DEFINE_NATIVE_FUNCTION(ListFormatPrototype::format)
 {
     auto list = vm.argument(0);
 
     // 1. Let lf be the this value.
     // 2. Perform ? RequireInternalSlot(lf, [[InitializedListFormat]]).
-    auto* list_format = TRY_OR_DISCARD(typed_this_object(global_object));
+    auto* list_format = TRY(typed_this_object(global_object));
 
     // 3. Let stringList be ? StringListFromIterable(list).
-    auto string_list = TRY_OR_DISCARD(string_list_from_iterable(global_object, list));
+    auto string_list = TRY(string_list_from_iterable(global_object, list));
 
     // 4. Return FormatList(lf, stringList).
     auto formatted = format_list(*list_format, string_list);
@@ -51,27 +51,27 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(ListFormatPrototype::format)
 }
 
 // 13.4.4 Intl.ListFormat.prototype.formatToParts ( list ), https://tc39.es/ecma402/#sec-Intl.ListFormat.prototype.formatToParts
-JS_DEFINE_OLD_NATIVE_FUNCTION(ListFormatPrototype::format_to_parts)
+JS_DEFINE_NATIVE_FUNCTION(ListFormatPrototype::format_to_parts)
 {
     auto list = vm.argument(0);
 
     // 1. Let lf be the this value.
     // 2. Perform ? RequireInternalSlot(lf, [[InitializedListFormat]]).
-    auto* list_format = TRY_OR_DISCARD(typed_this_object(global_object));
+    auto* list_format = TRY(typed_this_object(global_object));
 
     // 3. Let stringList be ? StringListFromIterable(list).
-    auto string_list = TRY_OR_DISCARD(string_list_from_iterable(global_object, list));
+    auto string_list = TRY(string_list_from_iterable(global_object, list));
 
     // 4. Return FormatListToParts(lf, stringList).
     return format_list_to_parts(global_object, *list_format, string_list);
 }
 
 // 13.4.5 Intl.ListFormat.prototype.resolvedOptions ( ), https://tc39.es/ecma402/#sec-Intl.ListFormat.prototype.resolvedoptions
-JS_DEFINE_OLD_NATIVE_FUNCTION(ListFormatPrototype::resolved_options)
+JS_DEFINE_NATIVE_FUNCTION(ListFormatPrototype::resolved_options)
 {
     // 1. Let lf be the this value.
     // 2. Perform ? RequireInternalSlot(lf, [[InitializedListFormat]]).
-    auto* list_format = TRY_OR_DISCARD(typed_this_object(global_object));
+    auto* list_format = TRY(typed_this_object(global_object));
 
     // 3. Let options be ! OrdinaryObjectCreate(%Object.prototype%).
     auto* options = Object::create(global_object, global_object.object_prototype());

+ 3 - 3
Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.h

@@ -20,9 +20,9 @@ public:
     virtual ~ListFormatPrototype() override = default;
 
 private:
-    JS_DECLARE_OLD_NATIVE_FUNCTION(format);
-    JS_DECLARE_OLD_NATIVE_FUNCTION(format_to_parts);
-    JS_DECLARE_OLD_NATIVE_FUNCTION(resolved_options);
+    JS_DECLARE_NATIVE_FUNCTION(format);
+    JS_DECLARE_NATIVE_FUNCTION(format_to_parts);
+    JS_DECLARE_NATIVE_FUNCTION(resolved_options);
 };
 
 }