summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-10-22 22:49:30 +0100
committerLinus Groh <mail@linusgroh.de>2021-10-22 23:20:18 +0100
commit351f0b70bdad05df5a5965488c93a921d034c98b (patch)
treee2b1061d04f6769492b5edb28fb6f3a151b3af4e /Userland
parent9fb1d7e18b974eb6ff6d457fc6997344260e666f (diff)
downloadserenity-351f0b70bdad05df5a5965488c93a921d034c98b.zip
LibJS: Convert Intl.Locale functions to ThrowCompletionOr
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp72
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.h28
2 files changed, 50 insertions, 50 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp
index fe9cf756f2..71d5068acf 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp
@@ -25,31 +25,31 @@ void LocalePrototype::initialize(GlobalObject& global_object)
auto& vm = this->vm();
u8 attr = Attribute::Writable | Attribute::Configurable;
- define_old_native_function(vm.names.maximize, maximize, 0, attr);
- define_old_native_function(vm.names.minimize, minimize, 0, attr);
- define_old_native_function(vm.names.toString, to_string, 0, attr);
+ define_native_function(vm.names.maximize, maximize, 0, attr);
+ define_native_function(vm.names.minimize, minimize, 0, attr);
+ define_native_function(vm.names.toString, to_string, 0, attr);
// 14.3.2 Intl.Locale.prototype[ @@toStringTag ], https://tc39.es/ecma402/#sec-Intl.Locale.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Intl.Locale"), Attribute::Configurable);
- define_old_native_accessor(vm.names.baseName, base_name, {}, Attribute::Configurable);
- define_old_native_accessor(vm.names.calendar, calendar, {}, Attribute::Configurable);
- define_old_native_accessor(vm.names.caseFirst, case_first, {}, Attribute::Configurable);
- define_old_native_accessor(vm.names.collation, collation, {}, Attribute::Configurable);
- define_old_native_accessor(vm.names.hourCycle, hour_cycle, {}, Attribute::Configurable);
- define_old_native_accessor(vm.names.numberingSystem, numbering_system, {}, Attribute::Configurable);
- define_old_native_accessor(vm.names.numeric, numeric, {}, Attribute::Configurable);
- define_old_native_accessor(vm.names.language, language, {}, Attribute::Configurable);
- define_old_native_accessor(vm.names.script, script, {}, Attribute::Configurable);
- define_old_native_accessor(vm.names.region, region, {}, Attribute::Configurable);
+ define_native_accessor(vm.names.baseName, base_name, {}, Attribute::Configurable);
+ define_native_accessor(vm.names.calendar, calendar, {}, Attribute::Configurable);
+ define_native_accessor(vm.names.caseFirst, case_first, {}, Attribute::Configurable);
+ define_native_accessor(vm.names.collation, collation, {}, Attribute::Configurable);
+ define_native_accessor(vm.names.hourCycle, hour_cycle, {}, Attribute::Configurable);
+ define_native_accessor(vm.names.numberingSystem, numbering_system, {}, Attribute::Configurable);
+ define_native_accessor(vm.names.numeric, numeric, {}, Attribute::Configurable);
+ define_native_accessor(vm.names.language, language, {}, Attribute::Configurable);
+ define_native_accessor(vm.names.script, script, {}, Attribute::Configurable);
+ define_native_accessor(vm.names.region, region, {}, Attribute::Configurable);
}
// 14.3.3 Intl.Locale.prototype.maximize ( ), https://tc39.es/ecma402/#sec-Intl.Locale.prototype.maximize
-JS_DEFINE_OLD_NATIVE_FUNCTION(LocalePrototype::maximize)
+JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::maximize)
{
// 1. Let loc be the this value.
// 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]).
- auto* locale_object = TRY_OR_DISCARD(typed_this_object(global_object));
+ auto* locale_object = TRY(typed_this_object(global_object));
auto locale = Unicode::parse_unicode_locale_id(locale_object->locale());
VERIFY(locale.has_value());
@@ -63,11 +63,11 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(LocalePrototype::maximize)
}
// 14.3.4 Intl.Locale.prototype.minimize ( ), https://tc39.es/ecma402/#sec-Intl.Locale.prototype.minimize
-JS_DEFINE_OLD_NATIVE_FUNCTION(LocalePrototype::minimize)
+JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::minimize)
{
// 1. Let loc be the this value.
// 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]).
- auto* locale_object = TRY_OR_DISCARD(typed_this_object(global_object));
+ auto* locale_object = TRY(typed_this_object(global_object));
auto locale = Unicode::parse_unicode_locale_id(locale_object->locale());
VERIFY(locale.has_value());
@@ -81,22 +81,22 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(LocalePrototype::minimize)
}
// 14.3.5 Intl.Locale.prototype.toString ( ), https://tc39.es/ecma402/#sec-Intl.Locale.prototype.toString
-JS_DEFINE_OLD_NATIVE_FUNCTION(LocalePrototype::to_string)
+JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::to_string)
{
// 1. Let loc be the this value.
// 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]).
- auto* locale_object = TRY_OR_DISCARD(typed_this_object(global_object));
+ auto* locale_object = TRY(typed_this_object(global_object));
// 3. Return loc.[[Locale]].
return js_string(vm, locale_object->locale());
}
// 14.3.6 get Intl.Locale.prototype.baseName, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.baseName
-JS_DEFINE_OLD_NATIVE_FUNCTION(LocalePrototype::base_name)
+JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::base_name)
{
// 1. Let loc be the this value.
// 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]).
- auto* locale_object = TRY_OR_DISCARD(typed_this_object(global_object));
+ auto* locale_object = TRY(typed_this_object(global_object));
// 3. Let locale be loc.[[Locale]].
auto locale = Unicode::parse_unicode_locale_id(locale_object->locale());
@@ -118,34 +118,34 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(LocalePrototype::base_name)
// 14.3.9 get Intl.Locale.prototype.collation, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.collation
// 14.3.10 get Intl.Locale.prototype.hourCycle, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.hourCycle
// 14.3.12 get Intl.Locale.prototype.numberingSystem, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.numberingSystem
-#define __JS_ENUMERATE(keyword) \
- JS_DEFINE_OLD_NATIVE_FUNCTION(LocalePrototype::keyword) \
- { \
- auto* locale_object = TRY_OR_DISCARD(typed_this_object(global_object)); \
- if (!locale_object->has_##keyword()) \
- return js_undefined(); \
- return js_string(vm, locale_object->keyword()); \
+#define __JS_ENUMERATE(keyword) \
+ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::keyword) \
+ { \
+ auto* locale_object = TRY(typed_this_object(global_object)); \
+ if (!locale_object->has_##keyword()) \
+ return js_undefined(); \
+ return js_string(vm, locale_object->keyword()); \
}
JS_ENUMERATE_LOCALE_KEYWORD_PROPERTIES
#undef __JS_ENUMERATE
// 14.3.11 get Intl.Locale.prototype.numeric, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.numeric
-JS_DEFINE_OLD_NATIVE_FUNCTION(LocalePrototype::numeric)
+JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::numeric)
{
// 1. Let loc be the this value.
// 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]).
- auto* locale_object = TRY_OR_DISCARD(typed_this_object(global_object));
+ auto* locale_object = TRY(typed_this_object(global_object));
// 3. Return loc.[[Numeric]].
return Value(locale_object->numeric());
}
// 14.3.13 get Intl.Locale.prototype.language, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.language
-JS_DEFINE_OLD_NATIVE_FUNCTION(LocalePrototype::language)
+JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::language)
{
// 1. Let loc be the this value.
// 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]).
- auto* locale_object = TRY_OR_DISCARD(typed_this_object(global_object));
+ auto* locale_object = TRY(typed_this_object(global_object));
// 3. Let locale be loc.[[Locale]].
auto locale = Unicode::parse_unicode_locale_id(locale_object->locale());
@@ -158,11 +158,11 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(LocalePrototype::language)
}
// 14.3.14 get Intl.Locale.prototype.script, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.script
-JS_DEFINE_OLD_NATIVE_FUNCTION(LocalePrototype::script)
+JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::script)
{
// 1. Let loc be the this value.
// 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]).
- auto* locale_object = TRY_OR_DISCARD(typed_this_object(global_object));
+ auto* locale_object = TRY(typed_this_object(global_object));
// 3. Let locale be loc.[[Locale]].
auto locale = Unicode::parse_unicode_locale_id(locale_object->locale());
@@ -179,11 +179,11 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(LocalePrototype::script)
}
// 14.3.15 get Intl.Locale.prototype.region, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.region
-JS_DEFINE_OLD_NATIVE_FUNCTION(LocalePrototype::region)
+JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::region)
{
// 1. Let loc be the this value.
// 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]).
- auto* locale_object = TRY_OR_DISCARD(typed_this_object(global_object));
+ auto* locale_object = TRY(typed_this_object(global_object));
// 3. Let locale be loc.[[Locale]].
auto locale = Unicode::parse_unicode_locale_id(locale_object->locale());
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.h
index d4e859c578..aa460a8a0a 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.h
+++ b/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.h
@@ -20,20 +20,20 @@ public:
virtual ~LocalePrototype() override = default;
private:
- JS_DECLARE_OLD_NATIVE_FUNCTION(maximize);
- JS_DECLARE_OLD_NATIVE_FUNCTION(minimize);
- JS_DECLARE_OLD_NATIVE_FUNCTION(to_string);
-
- JS_DECLARE_OLD_NATIVE_FUNCTION(base_name);
- JS_DECLARE_OLD_NATIVE_FUNCTION(calendar);
- JS_DECLARE_OLD_NATIVE_FUNCTION(case_first);
- JS_DECLARE_OLD_NATIVE_FUNCTION(collation);
- JS_DECLARE_OLD_NATIVE_FUNCTION(hour_cycle);
- JS_DECLARE_OLD_NATIVE_FUNCTION(numbering_system);
- JS_DECLARE_OLD_NATIVE_FUNCTION(numeric);
- JS_DECLARE_OLD_NATIVE_FUNCTION(language);
- JS_DECLARE_OLD_NATIVE_FUNCTION(script);
- JS_DECLARE_OLD_NATIVE_FUNCTION(region);
+ JS_DECLARE_NATIVE_FUNCTION(maximize);
+ JS_DECLARE_NATIVE_FUNCTION(minimize);
+ JS_DECLARE_NATIVE_FUNCTION(to_string);
+
+ JS_DECLARE_NATIVE_FUNCTION(base_name);
+ JS_DECLARE_NATIVE_FUNCTION(calendar);
+ JS_DECLARE_NATIVE_FUNCTION(case_first);
+ JS_DECLARE_NATIVE_FUNCTION(collation);
+ JS_DECLARE_NATIVE_FUNCTION(hour_cycle);
+ JS_DECLARE_NATIVE_FUNCTION(numbering_system);
+ JS_DECLARE_NATIVE_FUNCTION(numeric);
+ JS_DECLARE_NATIVE_FUNCTION(language);
+ JS_DECLARE_NATIVE_FUNCTION(script);
+ JS_DECLARE_NATIVE_FUNCTION(region);
};
}