mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 09:37:34 +00:00
LibJS: Add ThrowCompletionOr versions of the JS native function macros
The old versions were renamed to JS_DECLARE_OLD_NATIVE_FUNCTION and JS_DEFINE_OLD_NATIVE_FUNCTION, and will be eventually removed once all native functions were converted to the new format.
This commit is contained in:
parent
3355b52cca
commit
20163c0584
180 changed files with 1478 additions and 1472 deletions
|
@ -117,7 +117,7 @@ Value DisplayNamesConstructor::construct(FunctionObject& new_target)
|
|||
}
|
||||
|
||||
// 12.3.2 Intl.DisplayNames.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-Intl.DisplayNames.supportedLocalesOf
|
||||
JS_DEFINE_NATIVE_FUNCTION(DisplayNamesConstructor::supported_locales_of)
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(DisplayNamesConstructor::supported_locales_of)
|
||||
{
|
||||
auto locales = vm.argument(0);
|
||||
auto options = vm.argument(1);
|
||||
|
|
|
@ -24,7 +24,7 @@ public:
|
|||
private:
|
||||
virtual bool has_constructor() const override { return true; }
|
||||
|
||||
JS_DECLARE_NATIVE_FUNCTION(supported_locales_of);
|
||||
JS_DECLARE_OLD_NATIVE_FUNCTION(supported_locales_of);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ void DisplayNamesPrototype::initialize(GlobalObject& global_object)
|
|||
}
|
||||
|
||||
// 12.4.3 Intl.DisplayNames.prototype.of ( code ), https://tc39.es/ecma402/#sec-Intl.DisplayNames.prototype.of
|
||||
JS_DEFINE_NATIVE_FUNCTION(DisplayNamesPrototype::of)
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(DisplayNamesPrototype::of)
|
||||
{
|
||||
auto code = vm.argument(0);
|
||||
|
||||
|
@ -81,7 +81,7 @@ JS_DEFINE_NATIVE_FUNCTION(DisplayNamesPrototype::of)
|
|||
}
|
||||
|
||||
// 12.4.4 Intl.DisplayNames.prototype.resolvedOptions ( ), https://tc39.es/ecma402/#sec-Intl.DisplayNames.prototype.resolvedOptions
|
||||
JS_DEFINE_NATIVE_FUNCTION(DisplayNamesPrototype::resolved_options)
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(DisplayNamesPrototype::resolved_options)
|
||||
{
|
||||
// 1. Let displayNames be this value.
|
||||
// 2. Perform ? RequireInternalSlot(displayNames, [[InitializedDisplayNames]]).
|
||||
|
|
|
@ -20,8 +20,8 @@ public:
|
|||
virtual ~DisplayNamesPrototype() override = default;
|
||||
|
||||
private:
|
||||
JS_DECLARE_NATIVE_FUNCTION(of);
|
||||
JS_DECLARE_NATIVE_FUNCTION(resolved_options);
|
||||
JS_DECLARE_OLD_NATIVE_FUNCTION(of);
|
||||
JS_DECLARE_OLD_NATIVE_FUNCTION(resolved_options);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ void Intl::initialize(GlobalObject& global_object)
|
|||
}
|
||||
|
||||
// 8.3.1 Intl.getCanonicalLocales ( locales ), https://tc39.es/ecma402/#sec-intl.getcanonicallocales
|
||||
JS_DEFINE_NATIVE_FUNCTION(Intl::get_canonical_locales)
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(Intl::get_canonical_locales)
|
||||
{
|
||||
auto locales = vm.argument(0);
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ public:
|
|||
virtual ~Intl() override = default;
|
||||
|
||||
private:
|
||||
JS_DECLARE_NATIVE_FUNCTION(get_canonical_locales);
|
||||
JS_DECLARE_OLD_NATIVE_FUNCTION(get_canonical_locales);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ Value ListFormatConstructor::construct(FunctionObject& new_target)
|
|||
}
|
||||
|
||||
// 13.3.2 Intl.ListFormat.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-Intl.ListFormat.supportedLocalesOf
|
||||
JS_DEFINE_NATIVE_FUNCTION(ListFormatConstructor::supported_locales_of)
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(ListFormatConstructor::supported_locales_of)
|
||||
{
|
||||
auto locales = vm.argument(0);
|
||||
auto options = vm.argument(1);
|
||||
|
|
|
@ -24,7 +24,7 @@ public:
|
|||
private:
|
||||
virtual bool has_constructor() const override { return true; }
|
||||
|
||||
JS_DECLARE_NATIVE_FUNCTION(supported_locales_of);
|
||||
JS_DECLARE_OLD_NATIVE_FUNCTION(supported_locales_of);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ void ListFormatPrototype::initialize(GlobalObject& global_object)
|
|||
}
|
||||
|
||||
// 13.4.3 Intl.ListFormat.prototype.format ( list ), https://tc39.es/ecma402/#sec-Intl.ListFormat.prototype.format
|
||||
JS_DEFINE_NATIVE_FUNCTION(ListFormatPrototype::format)
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(ListFormatPrototype::format)
|
||||
{
|
||||
auto list = vm.argument(0);
|
||||
|
||||
|
@ -51,7 +51,7 @@ JS_DEFINE_NATIVE_FUNCTION(ListFormatPrototype::format)
|
|||
}
|
||||
|
||||
// 13.4.4 Intl.ListFormat.prototype.formatToParts ( list ), https://tc39.es/ecma402/#sec-Intl.ListFormat.prototype.formatToParts
|
||||
JS_DEFINE_NATIVE_FUNCTION(ListFormatPrototype::format_to_parts)
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(ListFormatPrototype::format_to_parts)
|
||||
{
|
||||
auto list = vm.argument(0);
|
||||
|
||||
|
@ -67,7 +67,7 @@ JS_DEFINE_NATIVE_FUNCTION(ListFormatPrototype::format_to_parts)
|
|||
}
|
||||
|
||||
// 13.4.5 Intl.ListFormat.prototype.resolvedOptions ( ), https://tc39.es/ecma402/#sec-Intl.ListFormat.prototype.resolvedoptions
|
||||
JS_DEFINE_NATIVE_FUNCTION(ListFormatPrototype::resolved_options)
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(ListFormatPrototype::resolved_options)
|
||||
{
|
||||
// 1. Let lf be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(lf, [[InitializedListFormat]]).
|
||||
|
|
|
@ -20,9 +20,9 @@ public:
|
|||
virtual ~ListFormatPrototype() override = default;
|
||||
|
||||
private:
|
||||
JS_DECLARE_NATIVE_FUNCTION(format);
|
||||
JS_DECLARE_NATIVE_FUNCTION(format_to_parts);
|
||||
JS_DECLARE_NATIVE_FUNCTION(resolved_options);
|
||||
JS_DECLARE_OLD_NATIVE_FUNCTION(format);
|
||||
JS_DECLARE_OLD_NATIVE_FUNCTION(format_to_parts);
|
||||
JS_DECLARE_OLD_NATIVE_FUNCTION(resolved_options);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ void LocalePrototype::initialize(GlobalObject& global_object)
|
|||
}
|
||||
|
||||
// 14.3.3 Intl.Locale.prototype.maximize ( ), https://tc39.es/ecma402/#sec-Intl.Locale.prototype.maximize
|
||||
JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::maximize)
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(LocalePrototype::maximize)
|
||||
{
|
||||
// 1. Let loc be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]).
|
||||
|
@ -63,7 +63,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::maximize)
|
|||
}
|
||||
|
||||
// 14.3.4 Intl.Locale.prototype.minimize ( ), https://tc39.es/ecma402/#sec-Intl.Locale.prototype.minimize
|
||||
JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::minimize)
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(LocalePrototype::minimize)
|
||||
{
|
||||
// 1. Let loc be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]).
|
||||
|
@ -81,7 +81,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::minimize)
|
|||
}
|
||||
|
||||
// 14.3.5 Intl.Locale.prototype.toString ( ), https://tc39.es/ecma402/#sec-Intl.Locale.prototype.toString
|
||||
JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::to_string)
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(LocalePrototype::to_string)
|
||||
{
|
||||
// 1. Let loc be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]).
|
||||
|
@ -92,7 +92,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::to_string)
|
|||
}
|
||||
|
||||
// 14.3.6 get Intl.Locale.prototype.baseName, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.baseName
|
||||
JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::base_name)
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(LocalePrototype::base_name)
|
||||
{
|
||||
// 1. Let loc be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]).
|
||||
|
@ -119,7 +119,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::base_name)
|
|||
// 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_NATIVE_FUNCTION(LocalePrototype::keyword) \
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(LocalePrototype::keyword) \
|
||||
{ \
|
||||
auto* locale_object = TRY_OR_DISCARD(typed_this_object(global_object)); \
|
||||
if (!locale_object->has_##keyword()) \
|
||||
|
@ -130,7 +130,7 @@ 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_NATIVE_FUNCTION(LocalePrototype::numeric)
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(LocalePrototype::numeric)
|
||||
{
|
||||
// 1. Let loc be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]).
|
||||
|
@ -141,7 +141,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::numeric)
|
|||
}
|
||||
|
||||
// 14.3.13 get Intl.Locale.prototype.language, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.language
|
||||
JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::language)
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(LocalePrototype::language)
|
||||
{
|
||||
// 1. Let loc be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]).
|
||||
|
@ -158,7 +158,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::language)
|
|||
}
|
||||
|
||||
// 14.3.14 get Intl.Locale.prototype.script, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.script
|
||||
JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::script)
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(LocalePrototype::script)
|
||||
{
|
||||
// 1. Let loc be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]).
|
||||
|
@ -179,7 +179,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::script)
|
|||
}
|
||||
|
||||
// 14.3.15 get Intl.Locale.prototype.region, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.region
|
||||
JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::region)
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(LocalePrototype::region)
|
||||
{
|
||||
// 1. Let loc be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]).
|
||||
|
|
|
@ -20,20 +20,20 @@ public:
|
|||
virtual ~LocalePrototype() override = default;
|
||||
|
||||
private:
|
||||
JS_DECLARE_NATIVE_FUNCTION(maximize);
|
||||
JS_DECLARE_NATIVE_FUNCTION(minimize);
|
||||
JS_DECLARE_NATIVE_FUNCTION(to_string);
|
||||
JS_DECLARE_OLD_NATIVE_FUNCTION(maximize);
|
||||
JS_DECLARE_OLD_NATIVE_FUNCTION(minimize);
|
||||
JS_DECLARE_OLD_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);
|
||||
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);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ Value NumberFormatConstructor::construct(FunctionObject& new_target)
|
|||
}
|
||||
|
||||
// 15.3.2 Intl.NumberFormat.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-intl.numberformat.supportedlocalesof
|
||||
JS_DEFINE_NATIVE_FUNCTION(NumberFormatConstructor::supported_locales_of)
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(NumberFormatConstructor::supported_locales_of)
|
||||
{
|
||||
auto locales = vm.argument(0);
|
||||
auto options = vm.argument(1);
|
||||
|
|
|
@ -24,7 +24,7 @@ public:
|
|||
private:
|
||||
virtual bool has_constructor() const override { return true; }
|
||||
|
||||
JS_DECLARE_NATIVE_FUNCTION(supported_locales_of);
|
||||
JS_DECLARE_OLD_NATIVE_FUNCTION(supported_locales_of);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ void NumberFormatPrototype::initialize(GlobalObject& global_object)
|
|||
}
|
||||
|
||||
// 15.4.5 Intl.NumberFormat.prototype.resolvedOptions ( ), https://tc39.es/ecma402/#sec-intl.numberformat.prototype.resolvedoptions
|
||||
JS_DEFINE_NATIVE_FUNCTION(NumberFormatPrototype::resolved_options)
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(NumberFormatPrototype::resolved_options)
|
||||
{
|
||||
// 1. Let nf be the this value.
|
||||
// 2. If the implementation supports the normative optional constructor mode of 4.3 Note 1, then
|
||||
|
|
|
@ -20,7 +20,7 @@ public:
|
|||
virtual ~NumberFormatPrototype() override = default;
|
||||
|
||||
private:
|
||||
JS_DECLARE_NATIVE_FUNCTION(resolved_options);
|
||||
JS_DECLARE_OLD_NATIVE_FUNCTION(resolved_options);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue