mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 16:47:44 +00:00
AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
This commit is contained in:
parent
f74251606d
commit
6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions
|
@ -80,7 +80,7 @@ Optional<::Locale::LocaleID> is_structurally_valid_language_tag(StringView local
|
|||
}
|
||||
|
||||
// 6.2.3 CanonicalizeUnicodeLocaleId ( locale ), https://tc39.es/ecma402/#sec-canonicalizeunicodelocaleid
|
||||
String canonicalize_unicode_locale_id(::Locale::LocaleID& locale)
|
||||
DeprecatedString canonicalize_unicode_locale_id(::Locale::LocaleID& locale)
|
||||
{
|
||||
// Note: This implementation differs from the spec in how Step 3 is implemented. The spec assumes
|
||||
// the input to this method is a string, and is written such that operations are performed on parts
|
||||
|
@ -183,18 +183,18 @@ bool is_well_formed_unit_identifier(StringView unit_identifier)
|
|||
}
|
||||
|
||||
// 9.2.1 CanonicalizeLocaleList ( locales ), https://tc39.es/ecma402/#sec-canonicalizelocalelist
|
||||
ThrowCompletionOr<Vector<String>> canonicalize_locale_list(VM& vm, Value locales)
|
||||
ThrowCompletionOr<Vector<DeprecatedString>> canonicalize_locale_list(VM& vm, Value locales)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
// 1. If locales is undefined, then
|
||||
if (locales.is_undefined()) {
|
||||
// a. Return a new empty List.
|
||||
return Vector<String> {};
|
||||
return Vector<DeprecatedString> {};
|
||||
}
|
||||
|
||||
// 2. Let seen be a new empty List.
|
||||
Vector<String> seen;
|
||||
Vector<DeprecatedString> seen;
|
||||
|
||||
Object* object = nullptr;
|
||||
// 3. If Type(locales) is String or Type(locales) is Object and locales has an [[InitializedLocale]] internal slot, then
|
||||
|
@ -230,7 +230,7 @@ ThrowCompletionOr<Vector<String>> canonicalize_locale_list(VM& vm, Value locales
|
|||
if (!key_value.is_string() && !key_value.is_object())
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObjectOrString, key_value.to_string_without_side_effects());
|
||||
|
||||
String tag;
|
||||
DeprecatedString tag;
|
||||
|
||||
// iii. If Type(kValue) is Object and kValue has an [[InitializedLocale]] internal slot, then
|
||||
if (key_value.is_object() && is<Locale>(key_value.as_object())) {
|
||||
|
@ -263,7 +263,7 @@ ThrowCompletionOr<Vector<String>> canonicalize_locale_list(VM& vm, Value locales
|
|||
}
|
||||
|
||||
// 9.2.2 BestAvailableLocale ( availableLocales, locale ), https://tc39.es/ecma402/#sec-bestavailablelocale
|
||||
Optional<String> best_available_locale(StringView locale)
|
||||
Optional<DeprecatedString> best_available_locale(StringView locale)
|
||||
{
|
||||
// 1. Let candidate be locale.
|
||||
StringView candidate = locale;
|
||||
|
@ -289,12 +289,12 @@ Optional<String> best_available_locale(StringView locale)
|
|||
}
|
||||
|
||||
struct MatcherResult {
|
||||
String locale;
|
||||
DeprecatedString locale;
|
||||
Vector<::Locale::Extension> extensions {};
|
||||
};
|
||||
|
||||
// 9.2.3 LookupMatcher ( availableLocales, requestedLocales ), https://tc39.es/ecma402/#sec-lookupmatcher
|
||||
static MatcherResult lookup_matcher(Vector<String> const& requested_locales)
|
||||
static MatcherResult lookup_matcher(Vector<DeprecatedString> const& requested_locales)
|
||||
{
|
||||
// 1. Let result be a new Record.
|
||||
MatcherResult result {};
|
||||
|
@ -337,7 +337,7 @@ static MatcherResult lookup_matcher(Vector<String> const& requested_locales)
|
|||
}
|
||||
|
||||
// 9.2.4 BestFitMatcher ( availableLocales, requestedLocales ), https://tc39.es/ecma402/#sec-bestfitmatcher
|
||||
static MatcherResult best_fit_matcher(Vector<String> const& requested_locales)
|
||||
static MatcherResult best_fit_matcher(Vector<DeprecatedString> const& requested_locales)
|
||||
{
|
||||
// The algorithm is implementation dependent, but should produce results that a typical user of the requested locales would
|
||||
// perceive as at least as good as those produced by the LookupMatcher abstract operation.
|
||||
|
@ -345,7 +345,7 @@ static MatcherResult best_fit_matcher(Vector<String> const& requested_locales)
|
|||
}
|
||||
|
||||
// 9.2.6 InsertUnicodeExtensionAndCanonicalize ( locale, extension ), https://tc39.es/ecma402/#sec-insert-unicode-extension-and-canonicalize
|
||||
String insert_unicode_extension_and_canonicalize(::Locale::LocaleID locale, ::Locale::LocaleExtension extension)
|
||||
DeprecatedString insert_unicode_extension_and_canonicalize(::Locale::LocaleID locale, ::Locale::LocaleExtension extension)
|
||||
{
|
||||
// Note: This implementation differs from the spec in how the extension is inserted. The spec assumes
|
||||
// the input to this method is a string, and is written such that operations are performed on parts
|
||||
|
@ -376,7 +376,7 @@ static auto& find_key_in_value(T& value, StringView key)
|
|||
}
|
||||
|
||||
// 9.2.7 ResolveLocale ( availableLocales, requestedLocales, options, relevantExtensionKeys, localeData ), https://tc39.es/ecma402/#sec-resolvelocale
|
||||
LocaleResult resolve_locale(Vector<String> const& requested_locales, LocaleOptions const& options, Span<StringView const> relevant_extension_keys)
|
||||
LocaleResult resolve_locale(Vector<DeprecatedString> const& requested_locales, LocaleOptions const& options, Span<StringView const> relevant_extension_keys)
|
||||
{
|
||||
// 1. Let matcher be options.[[localeMatcher]].
|
||||
auto const& matcher = options.locale_matcher;
|
||||
|
@ -431,7 +431,7 @@ LocaleResult resolve_locale(Vector<String> const& requested_locales, LocaleOptio
|
|||
// f. Assert: Type(value) is either String or Null.
|
||||
// NOTE: ECMA-402 assumes keyLocaleData is sorted by locale preference. Our list is sorted
|
||||
// alphabetically, so we get the locale's preferred value from LibUnicode.
|
||||
Optional<String> value;
|
||||
Optional<DeprecatedString> value;
|
||||
if (auto preference = ::Locale::get_preferred_keyword_value_for_locale(found_locale, key); preference.has_value())
|
||||
value = *preference;
|
||||
|
||||
|
@ -526,10 +526,10 @@ LocaleResult resolve_locale(Vector<String> const& requested_locales, LocaleOptio
|
|||
}
|
||||
|
||||
// 9.2.8 LookupSupportedLocales ( availableLocales, requestedLocales ), https://tc39.es/ecma402/#sec-lookupsupportedlocales
|
||||
Vector<String> lookup_supported_locales(Vector<String> const& requested_locales)
|
||||
Vector<DeprecatedString> lookup_supported_locales(Vector<DeprecatedString> const& requested_locales)
|
||||
{
|
||||
// 1. Let subset be a new empty List.
|
||||
Vector<String> subset;
|
||||
Vector<DeprecatedString> subset;
|
||||
|
||||
// 2. For each element locale of requestedLocales, do
|
||||
for (auto const& locale : requested_locales) {
|
||||
|
@ -553,7 +553,7 @@ Vector<String> lookup_supported_locales(Vector<String> const& requested_locales)
|
|||
}
|
||||
|
||||
// 9.2.9 BestFitSupportedLocales ( availableLocales, requestedLocales ), https://tc39.es/ecma402/#sec-bestfitsupportedlocales
|
||||
Vector<String> best_fit_supported_locales(Vector<String> const& requested_locales)
|
||||
Vector<DeprecatedString> best_fit_supported_locales(Vector<DeprecatedString> const& requested_locales)
|
||||
{
|
||||
// The BestFitSupportedLocales abstract operation returns the subset of the provided BCP 47
|
||||
// language priority list requestedLocales for which availableLocales has a matching locale
|
||||
|
@ -565,7 +565,7 @@ Vector<String> best_fit_supported_locales(Vector<String> const& requested_locale
|
|||
}
|
||||
|
||||
// 9.2.10 SupportedLocales ( availableLocales, requestedLocales, options ), https://tc39.es/ecma402/#sec-supportedlocales
|
||||
ThrowCompletionOr<Array*> supported_locales(VM& vm, Vector<String> const& requested_locales, Value options)
|
||||
ThrowCompletionOr<Array*> supported_locales(VM& vm, Vector<DeprecatedString> const& requested_locales, Value options)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
|
@ -575,7 +575,7 @@ ThrowCompletionOr<Array*> supported_locales(VM& vm, Vector<String> const& reques
|
|||
// 2. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit").
|
||||
auto matcher = TRY(get_option(vm, *options_object, vm.names.localeMatcher, OptionType::String, { "lookup"sv, "best fit"sv }, "best fit"sv));
|
||||
|
||||
Vector<String> supported_locales;
|
||||
Vector<DeprecatedString> supported_locales;
|
||||
|
||||
// 3. If matcher is "best fit", then
|
||||
if (matcher.as_string().string() == "best fit"sv) {
|
||||
|
@ -589,7 +589,7 @@ ThrowCompletionOr<Array*> supported_locales(VM& vm, Vector<String> const& reques
|
|||
}
|
||||
|
||||
// 5. Return CreateArrayFromList(supportedLocales).
|
||||
return Array::create_from<String>(realm, supported_locales, [&vm](auto& locale) { return js_string(vm, locale); });
|
||||
return Array::create_from<DeprecatedString>(realm, supported_locales, [&vm](auto& locale) { return js_string(vm, locale); });
|
||||
}
|
||||
|
||||
// 9.2.12 CoerceOptionsToObject ( options ), https://tc39.es/ecma402/#sec-coerceoptionstoobject
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Span.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Variant.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibJS/Forward.h>
|
||||
|
@ -21,36 +21,36 @@ namespace JS::Intl {
|
|||
|
||||
struct LocaleOptions {
|
||||
Value locale_matcher;
|
||||
Optional<String> ca; // [[Calendar]]
|
||||
Optional<String> co; // [[Collation]]
|
||||
Optional<String> hc; // [[HourCycle]]
|
||||
Optional<String> kf; // [[CaseFirst]]
|
||||
Optional<String> kn; // [[Numeric]]
|
||||
Optional<String> nu; // [[NumberingSystem]]
|
||||
Optional<DeprecatedString> ca; // [[Calendar]]
|
||||
Optional<DeprecatedString> co; // [[Collation]]
|
||||
Optional<DeprecatedString> hc; // [[HourCycle]]
|
||||
Optional<DeprecatedString> kf; // [[CaseFirst]]
|
||||
Optional<DeprecatedString> kn; // [[Numeric]]
|
||||
Optional<DeprecatedString> nu; // [[NumberingSystem]]
|
||||
};
|
||||
|
||||
struct LocaleResult {
|
||||
String locale;
|
||||
String data_locale;
|
||||
Optional<String> ca; // [[Calendar]]
|
||||
Optional<String> co; // [[Collation]]
|
||||
Optional<String> hc; // [[HourCycle]]
|
||||
Optional<String> kf; // [[CaseFirst]]
|
||||
Optional<String> kn; // [[Numeric]]
|
||||
Optional<String> nu; // [[NumberingSystem]]
|
||||
DeprecatedString locale;
|
||||
DeprecatedString data_locale;
|
||||
Optional<DeprecatedString> ca; // [[Calendar]]
|
||||
Optional<DeprecatedString> co; // [[Collation]]
|
||||
Optional<DeprecatedString> hc; // [[HourCycle]]
|
||||
Optional<DeprecatedString> kf; // [[CaseFirst]]
|
||||
Optional<DeprecatedString> kn; // [[Numeric]]
|
||||
Optional<DeprecatedString> nu; // [[NumberingSystem]]
|
||||
};
|
||||
|
||||
struct PatternPartition {
|
||||
PatternPartition() = default;
|
||||
|
||||
PatternPartition(StringView type_string, String value_string)
|
||||
PatternPartition(StringView type_string, DeprecatedString value_string)
|
||||
: type(type_string)
|
||||
, value(move(value_string))
|
||||
{
|
||||
}
|
||||
|
||||
StringView type;
|
||||
String value;
|
||||
DeprecatedString value;
|
||||
};
|
||||
|
||||
struct PatternPartitionWithSource : public PatternPartition {
|
||||
|
@ -80,16 +80,16 @@ struct PatternPartitionWithSource : public PatternPartition {
|
|||
using StringOrBoolean = Variant<StringView, bool>;
|
||||
|
||||
Optional<::Locale::LocaleID> is_structurally_valid_language_tag(StringView locale);
|
||||
String canonicalize_unicode_locale_id(::Locale::LocaleID& locale);
|
||||
DeprecatedString canonicalize_unicode_locale_id(::Locale::LocaleID& locale);
|
||||
bool is_well_formed_currency_code(StringView currency);
|
||||
bool is_well_formed_unit_identifier(StringView unit_identifier);
|
||||
ThrowCompletionOr<Vector<String>> canonicalize_locale_list(VM&, Value locales);
|
||||
Optional<String> best_available_locale(StringView locale);
|
||||
String insert_unicode_extension_and_canonicalize(::Locale::LocaleID locale_id, ::Locale::LocaleExtension extension);
|
||||
LocaleResult resolve_locale(Vector<String> const& requested_locales, LocaleOptions const& options, Span<StringView const> relevant_extension_keys);
|
||||
Vector<String> lookup_supported_locales(Vector<String> const& requested_locales);
|
||||
Vector<String> best_fit_supported_locales(Vector<String> const& requested_locales);
|
||||
ThrowCompletionOr<Array*> supported_locales(VM&, Vector<String> const& requested_locales, Value options);
|
||||
ThrowCompletionOr<Vector<DeprecatedString>> canonicalize_locale_list(VM&, Value locales);
|
||||
Optional<DeprecatedString> best_available_locale(StringView locale);
|
||||
DeprecatedString insert_unicode_extension_and_canonicalize(::Locale::LocaleID locale_id, ::Locale::LocaleExtension extension);
|
||||
LocaleResult resolve_locale(Vector<DeprecatedString> const& requested_locales, LocaleOptions const& options, Span<StringView const> relevant_extension_keys);
|
||||
Vector<DeprecatedString> lookup_supported_locales(Vector<DeprecatedString> const& requested_locales);
|
||||
Vector<DeprecatedString> best_fit_supported_locales(Vector<DeprecatedString> const& requested_locales);
|
||||
ThrowCompletionOr<Array*> supported_locales(VM&, Vector<DeprecatedString> const& requested_locales, Value options);
|
||||
ThrowCompletionOr<Object*> coerce_options_to_object(VM&, Value options);
|
||||
ThrowCompletionOr<StringOrBoolean> get_string_or_boolean_option(VM&, Object const& options, PropertyKey const& property, Span<StringView const> values, StringOrBoolean true_value, StringOrBoolean falsy_value, StringOrBoolean fallback);
|
||||
ThrowCompletionOr<Optional<int>> default_number_option(VM&, Value value, int minimum, int maximum, Optional<int> fallback);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/Array.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <LibJS/Runtime/Intl/CollatorCompareFunction.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
|
@ -45,8 +45,8 @@ public:
|
|||
|
||||
virtual ~Collator() override = default;
|
||||
|
||||
String const& locale() const { return m_locale; }
|
||||
void set_locale(String locale) { m_locale = move(locale); }
|
||||
DeprecatedString const& locale() const { return m_locale; }
|
||||
void set_locale(DeprecatedString locale) { m_locale = move(locale); }
|
||||
|
||||
Usage usage() const { return m_usage; }
|
||||
void set_usage(StringView usage);
|
||||
|
@ -60,8 +60,8 @@ public:
|
|||
void set_case_first(StringView case_first);
|
||||
StringView case_first_string() const;
|
||||
|
||||
String const& collation() const { return m_collation; }
|
||||
void set_collation(String collation) { m_collation = move(collation); }
|
||||
DeprecatedString const& collation() const { return m_collation; }
|
||||
void set_collation(DeprecatedString collation) { m_collation = move(collation); }
|
||||
|
||||
bool ignore_punctuation() const { return m_ignore_punctuation; }
|
||||
void set_ignore_punctuation(bool ignore_punctuation) { m_ignore_punctuation = ignore_punctuation; }
|
||||
|
@ -77,11 +77,11 @@ private:
|
|||
|
||||
virtual void visit_edges(Visitor&) override;
|
||||
|
||||
String m_locale; // [[Locale]]
|
||||
DeprecatedString m_locale; // [[Locale]]
|
||||
Usage m_usage { Usage::Sort }; // [[Usage]]
|
||||
Sensitivity m_sensitivity { Sensitivity::Variant }; // [[Sensitivity]]
|
||||
CaseFirst m_case_first { CaseFirst::False }; // [[CaseFirst]]
|
||||
String m_collation; // [[Collation]]
|
||||
DeprecatedString m_collation; // [[Collation]]
|
||||
bool m_ignore_punctuation { false }; // [[IgnorePunctuation]]
|
||||
bool m_numeric { false }; // [[Numeric]]
|
||||
CollatorCompareFunction* m_bound_compare { nullptr }; // [[BoundCompare]]
|
||||
|
|
|
@ -26,7 +26,7 @@ void CollatorCompareFunction::initialize(Realm&)
|
|||
{
|
||||
auto& vm = this->vm();
|
||||
define_direct_property(vm.names.length, Value(2), Attribute::Configurable);
|
||||
define_direct_property(vm.names.name, js_string(vm, String::empty()), Attribute::Configurable);
|
||||
define_direct_property(vm.names.name, js_string(vm, DeprecatedString::empty()), Attribute::Configurable);
|
||||
}
|
||||
|
||||
// 10.3.3.2 CompareStrings ( collator, x, y ), https://tc39.es/ecma402/#sec-collator-comparestrings
|
||||
|
|
|
@ -629,7 +629,7 @@ ThrowCompletionOr<Vector<PatternPartition>> format_date_time_pattern(VM& vm, Dat
|
|||
|
||||
// d. Else if p is equal to "dayPeriod", then
|
||||
else if (part == "dayPeriod"sv) {
|
||||
String formatted_value;
|
||||
DeprecatedString formatted_value;
|
||||
|
||||
// i. Let f be the value of dateTimeFormat's internal slot whose name is the Internal Slot column of the matching row.
|
||||
auto style = date_time_format.day_period();
|
||||
|
@ -662,7 +662,7 @@ ThrowCompletionOr<Vector<PatternPartition>> format_date_time_pattern(VM& vm, Dat
|
|||
|
||||
// f. Else if p matches a Property column of the row in Table 6, then
|
||||
else if (auto style_and_value = find_calendar_field(part, date_time_format, range_format_options, local_time); style_and_value.has_value()) {
|
||||
String formatted_value;
|
||||
DeprecatedString formatted_value;
|
||||
|
||||
// i. If rangeFormatOptions is not undefined, let f be the value of rangeFormatOptions's field whose name matches p.
|
||||
// ii. Else, let f be the value of dateTimeFormat's internal slot whose name is the Internal Slot column of the matching row.
|
||||
|
@ -741,7 +741,7 @@ ThrowCompletionOr<Vector<PatternPartition>> format_date_time_pattern(VM& vm, Dat
|
|||
else if (part == "weekday"sv)
|
||||
symbol = ::Locale::get_calendar_weekday_symbol(data_locale, date_time_format.calendar(), style, static_cast<::Locale::Weekday>(value));
|
||||
|
||||
formatted_value = symbol.value_or(String::number(value));
|
||||
formatted_value = symbol.value_or(DeprecatedString::number(value));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -755,7 +755,7 @@ ThrowCompletionOr<Vector<PatternPartition>> format_date_time_pattern(VM& vm, Dat
|
|||
|
||||
// g. Else if p is equal to "ampm", then
|
||||
else if (part == "ampm"sv) {
|
||||
String formatted_value;
|
||||
DeprecatedString formatted_value;
|
||||
|
||||
// i. Let v be tm.[[Hour]].
|
||||
auto value = local_time.hour;
|
||||
|
@ -830,7 +830,7 @@ ThrowCompletionOr<Vector<PatternPartition>> partition_date_time_pattern(VM& vm,
|
|||
}
|
||||
|
||||
// 11.5.8 FormatDateTime ( dateTimeFormat, x ), https://tc39.es/ecma402/#sec-formatdatetime
|
||||
ThrowCompletionOr<String> format_date_time(VM& vm, DateTimeFormat& date_time_format, double time)
|
||||
ThrowCompletionOr<DeprecatedString> format_date_time(VM& vm, DateTimeFormat& date_time_format, double time)
|
||||
{
|
||||
// 1. Let parts be ? PartitionDateTimePattern(dateTimeFormat, x).
|
||||
auto parts = TRY(partition_date_time_pattern(vm, date_time_format, time));
|
||||
|
@ -1146,7 +1146,7 @@ ThrowCompletionOr<Vector<PatternPartitionWithSource>> partition_date_time_range_
|
|||
}
|
||||
|
||||
// 11.5.11 FormatDateTimeRange ( dateTimeFormat, x, y ), https://tc39.es/ecma402/#sec-formatdatetimerange
|
||||
ThrowCompletionOr<String> format_date_time_range(VM& vm, DateTimeFormat& date_time_format, double start, double end)
|
||||
ThrowCompletionOr<DeprecatedString> format_date_time_range(VM& vm, DateTimeFormat& date_time_format, double start, double end)
|
||||
{
|
||||
// 1. Let parts be ? PartitionDateTimeRangePattern(dateTimeFormat, x, y).
|
||||
auto parts = TRY(partition_date_time_range_pattern(vm, date_time_format, start, end));
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/Array.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/Time.h>
|
||||
#include <AK/Types.h>
|
||||
|
@ -43,17 +43,17 @@ public:
|
|||
|
||||
virtual ~DateTimeFormat() override = default;
|
||||
|
||||
String const& locale() const { return m_locale; }
|
||||
void set_locale(String locale) { m_locale = move(locale); }
|
||||
DeprecatedString const& locale() const { return m_locale; }
|
||||
void set_locale(DeprecatedString locale) { m_locale = move(locale); }
|
||||
|
||||
String const& data_locale() const { return m_data_locale; }
|
||||
void set_data_locale(String data_locale) { m_data_locale = move(data_locale); }
|
||||
DeprecatedString const& data_locale() const { return m_data_locale; }
|
||||
void set_data_locale(DeprecatedString data_locale) { m_data_locale = move(data_locale); }
|
||||
|
||||
String const& calendar() const { return m_calendar; }
|
||||
void set_calendar(String calendar) { m_calendar = move(calendar); }
|
||||
DeprecatedString const& calendar() const { return m_calendar; }
|
||||
void set_calendar(DeprecatedString calendar) { m_calendar = move(calendar); }
|
||||
|
||||
String const& numbering_system() const { return m_numbering_system; }
|
||||
void set_numbering_system(String numbering_system) { m_numbering_system = move(numbering_system); }
|
||||
DeprecatedString const& numbering_system() const { return m_numbering_system; }
|
||||
void set_numbering_system(DeprecatedString numbering_system) { m_numbering_system = move(numbering_system); }
|
||||
|
||||
bool has_hour_cycle() const { return m_hour_cycle.has_value(); }
|
||||
::Locale::HourCycle hour_cycle() const { return *m_hour_cycle; }
|
||||
|
@ -61,8 +61,8 @@ public:
|
|||
void set_hour_cycle(::Locale::HourCycle hour_cycle) { m_hour_cycle = hour_cycle; }
|
||||
void clear_hour_cycle() { m_hour_cycle.clear(); }
|
||||
|
||||
String const& time_zone() const { return m_time_zone; }
|
||||
void set_time_zone(String time_zone) { m_time_zone = move(time_zone); }
|
||||
DeprecatedString const& time_zone() const { return m_time_zone; }
|
||||
void set_time_zone(DeprecatedString time_zone) { m_time_zone = move(time_zone); }
|
||||
|
||||
bool has_date_style() const { return m_date_style.has_value(); }
|
||||
Style date_style() const { return *m_date_style; };
|
||||
|
@ -74,8 +74,8 @@ public:
|
|||
StringView time_style_string() const { return style_to_string(*m_time_style); };
|
||||
void set_time_style(StringView style) { m_time_style = style_from_string(style); };
|
||||
|
||||
String const& pattern() const { return Patterns::pattern; };
|
||||
void set_pattern(String pattern) { Patterns::pattern = move(pattern); }
|
||||
DeprecatedString const& pattern() const { return Patterns::pattern; };
|
||||
void set_pattern(DeprecatedString pattern) { Patterns::pattern = move(pattern); }
|
||||
|
||||
Span<::Locale::CalendarRangePattern const> range_patterns() const { return m_range_patterns.span(); };
|
||||
void set_range_patterns(Vector<::Locale::CalendarRangePattern> range_patterns) { m_range_patterns = move(range_patterns); }
|
||||
|
@ -134,17 +134,17 @@ private:
|
|||
|
||||
virtual void visit_edges(Visitor&) override;
|
||||
|
||||
String m_locale; // [[Locale]]
|
||||
String m_calendar; // [[Calendar]]
|
||||
String m_numbering_system; // [[NumberingSystem]]
|
||||
DeprecatedString m_locale; // [[Locale]]
|
||||
DeprecatedString m_calendar; // [[Calendar]]
|
||||
DeprecatedString m_numbering_system; // [[NumberingSystem]]
|
||||
Optional<::Locale::HourCycle> m_hour_cycle; // [[HourCycle]]
|
||||
String m_time_zone; // [[TimeZone]]
|
||||
DeprecatedString m_time_zone; // [[TimeZone]]
|
||||
Optional<Style> m_date_style; // [[DateStyle]]
|
||||
Optional<Style> m_time_style; // [[TimeStyle]]
|
||||
Vector<::Locale::CalendarRangePattern> m_range_patterns; // [[RangePatterns]]
|
||||
NativeFunction* m_bound_format { nullptr }; // [[BoundFormat]]
|
||||
|
||||
String m_data_locale;
|
||||
DeprecatedString m_data_locale;
|
||||
};
|
||||
|
||||
enum class OptionRequired {
|
||||
|
@ -186,10 +186,10 @@ Optional<::Locale::CalendarPattern> basic_format_matcher(::Locale::CalendarPatte
|
|||
Optional<::Locale::CalendarPattern> best_fit_format_matcher(::Locale::CalendarPattern const& options, Vector<::Locale::CalendarPattern> formats);
|
||||
ThrowCompletionOr<Vector<PatternPartition>> format_date_time_pattern(VM&, DateTimeFormat&, Vector<PatternPartition> pattern_parts, double time, ::Locale::CalendarPattern const* range_format_options);
|
||||
ThrowCompletionOr<Vector<PatternPartition>> partition_date_time_pattern(VM&, DateTimeFormat&, double time);
|
||||
ThrowCompletionOr<String> format_date_time(VM&, DateTimeFormat&, double time);
|
||||
ThrowCompletionOr<DeprecatedString> format_date_time(VM&, DateTimeFormat&, double time);
|
||||
ThrowCompletionOr<Array*> format_date_time_to_parts(VM&, DateTimeFormat&, double time);
|
||||
ThrowCompletionOr<Vector<PatternPartitionWithSource>> partition_date_time_range_pattern(VM&, DateTimeFormat&, double start, double end);
|
||||
ThrowCompletionOr<String> format_date_time_range(VM&, DateTimeFormat&, double start, double end);
|
||||
ThrowCompletionOr<DeprecatedString> format_date_time_range(VM&, DateTimeFormat&, double start, double end);
|
||||
ThrowCompletionOr<Array*> format_date_time_range_to_parts(VM&, DateTimeFormat&, double start, double end);
|
||||
ThrowCompletionOr<LocalTime> to_local_time(VM&, Crypto::SignedBigInteger const& epoch_ns, StringView calendar, StringView time_zone);
|
||||
|
||||
|
|
|
@ -212,7 +212,7 @@ ThrowCompletionOr<DateTimeFormat*> initialize_date_time_format(VM& vm, DateTimeF
|
|||
|
||||
// 29. Let timeZone be ? Get(options, "timeZone").
|
||||
auto time_zone_value = TRY(options->get(vm.names.timeZone));
|
||||
String time_zone;
|
||||
DeprecatedString time_zone;
|
||||
|
||||
// 30. If timeZone is undefined, then
|
||||
if (time_zone_value.is_undefined()) {
|
||||
|
@ -345,7 +345,7 @@ ThrowCompletionOr<DateTimeFormat*> initialize_date_time_format(VM& vm, DateTimeF
|
|||
}
|
||||
});
|
||||
|
||||
String pattern;
|
||||
DeprecatedString pattern;
|
||||
Vector<::Locale::CalendarRangePattern> range_patterns;
|
||||
|
||||
// 45. If dateTimeFormat.[[Hour]] is undefined, then
|
||||
|
|
|
@ -31,7 +31,7 @@ void DateTimeFormatFunction::initialize(Realm& realm)
|
|||
|
||||
Base::initialize(realm);
|
||||
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
define_direct_property(vm.names.name, js_string(vm, String::empty()), Attribute::Configurable);
|
||||
define_direct_property(vm.names.name, js_string(vm, DeprecatedString::empty()), Attribute::Configurable);
|
||||
}
|
||||
|
||||
ThrowCompletionOr<Value> DateTimeFormatFunction::call()
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
#include <LibLocale/Locale.h>
|
||||
|
@ -41,8 +41,8 @@ class DisplayNames final : public Object {
|
|||
public:
|
||||
virtual ~DisplayNames() override = default;
|
||||
|
||||
String const& locale() const { return m_locale; }
|
||||
void set_locale(String locale) { m_locale = move(locale); }
|
||||
DeprecatedString const& locale() const { return m_locale; }
|
||||
void set_locale(DeprecatedString locale) { m_locale = move(locale); }
|
||||
|
||||
::Locale::Style style() const { return m_style; }
|
||||
void set_style(StringView style) { m_style = ::Locale::style_from_string(style); }
|
||||
|
@ -64,7 +64,7 @@ public:
|
|||
private:
|
||||
DisplayNames(Object& prototype);
|
||||
|
||||
String m_locale; // [[Locale]]
|
||||
DeprecatedString m_locale; // [[Locale]]
|
||||
::Locale::Style m_style { ::Locale::Style::Long }; // [[Style]]
|
||||
Type m_type { Type::Invalid }; // [[Type]]
|
||||
Fallback m_fallback { Fallback::Invalid }; // [[Fallback]]
|
||||
|
|
|
@ -52,7 +52,7 @@ JS_DEFINE_NATIVE_FUNCTION(DisplayNamesPrototype::of)
|
|||
// 5. Let fields be displayNames.[[Fields]].
|
||||
// 6. If fields has a field [[<code>]], return fields.[[<code>]].
|
||||
Optional<StringView> result;
|
||||
Optional<String> formatted_result;
|
||||
Optional<DeprecatedString> formatted_result;
|
||||
|
||||
switch (display_names->type()) {
|
||||
case DisplayNames::Type::Language:
|
||||
|
|
|
@ -232,7 +232,7 @@ bool is_valid_duration_record(Temporal::DurationRecord const& record)
|
|||
}
|
||||
|
||||
// 1.1.6 GetDurationUnitOptions ( unit, options, baseStyle, stylesList, digitalBase, prevStyle ), https://tc39.es/proposal-intl-duration-format/#sec-getdurationunitoptions
|
||||
ThrowCompletionOr<DurationUnitOptions> get_duration_unit_options(VM& vm, String const& unit, Object const& options, StringView base_style, Span<StringView const> styles_list, StringView digital_base, StringView previous_style)
|
||||
ThrowCompletionOr<DurationUnitOptions> get_duration_unit_options(VM& vm, DeprecatedString const& unit, Object const& options, StringView base_style, Span<StringView const> styles_list, StringView digital_base, StringView previous_style)
|
||||
{
|
||||
// 1. Let style be ? GetOption(options, unit, "string", stylesList, undefined).
|
||||
auto style_value = TRY(get_option(vm, options, unit, OptionType::String, styles_list, Empty {}));
|
||||
|
@ -240,7 +240,7 @@ ThrowCompletionOr<DurationUnitOptions> get_duration_unit_options(VM& vm, String
|
|||
// 2. Let displayDefault be "always".
|
||||
auto display_default = "always"sv;
|
||||
|
||||
String style;
|
||||
DeprecatedString style;
|
||||
|
||||
// 3. If style is undefined, then
|
||||
if (style_value.is_undefined()) {
|
||||
|
@ -276,7 +276,7 @@ ThrowCompletionOr<DurationUnitOptions> get_duration_unit_options(VM& vm, String
|
|||
}
|
||||
|
||||
// 4. Let displayField be the string-concatenation of unit and "Display".
|
||||
auto display_field = String::formatted("{}Display", unit);
|
||||
auto display_field = DeprecatedString::formatted("{}Display", unit);
|
||||
|
||||
// 5. Let display be ? GetOption(options, displayField, "string", « "auto", "always" », displayDefault).
|
||||
auto display = TRY(get_option(vm, options, display_field, OptionType::String, { "auto"sv, "always"sv }, display_default));
|
||||
|
@ -510,17 +510,17 @@ Vector<PatternPartition> partition_duration_format_pattern(VM& vm, DurationForma
|
|||
|
||||
// FIXME: CreatePartsFromList expects a list of strings and creates a list of Pattern Partition records, but we already created a list of Pattern Partition records
|
||||
// so we try to hack something together from it that looks mostly right
|
||||
Vector<String> string_result;
|
||||
Vector<DeprecatedString> string_result;
|
||||
bool merge = false;
|
||||
for (size_t i = 0; i < result.size(); ++i) {
|
||||
auto const& part = result[i];
|
||||
if (part.type == "literal") {
|
||||
string_result.last() = String::formatted("{}{}", string_result.last(), part.value);
|
||||
string_result.last() = DeprecatedString::formatted("{}{}", string_result.last(), part.value);
|
||||
merge = true;
|
||||
continue;
|
||||
}
|
||||
if (merge) {
|
||||
string_result.last() = String::formatted("{}{}", string_result.last(), part.value);
|
||||
string_result.last() = DeprecatedString::formatted("{}{}", string_result.last(), part.value);
|
||||
merge = false;
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/Array.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <LibJS/Runtime/Intl/AbstractOperations.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
#include <LibJS/Runtime/Temporal/Duration.h>
|
||||
|
@ -51,18 +51,18 @@ public:
|
|||
|
||||
virtual ~DurationFormat() override = default;
|
||||
|
||||
void set_locale(String locale) { m_locale = move(locale); }
|
||||
String const& locale() const { return m_locale; }
|
||||
void set_locale(DeprecatedString locale) { m_locale = move(locale); }
|
||||
DeprecatedString const& locale() const { return m_locale; }
|
||||
|
||||
void set_data_locale(String data_locale) { m_data_locale = move(data_locale); }
|
||||
String const& data_locale() const { return m_data_locale; }
|
||||
void set_data_locale(DeprecatedString data_locale) { m_data_locale = move(data_locale); }
|
||||
DeprecatedString const& data_locale() const { return m_data_locale; }
|
||||
|
||||
void set_numbering_system(String numbering_system) { m_numbering_system = move(numbering_system); }
|
||||
String const& numbering_system() const { return m_numbering_system; }
|
||||
void set_numbering_system(DeprecatedString numbering_system) { m_numbering_system = move(numbering_system); }
|
||||
DeprecatedString const& numbering_system() const { return m_numbering_system; }
|
||||
|
||||
void set_style(StringView style) { m_style = style_from_string(style); }
|
||||
Style style() const { return m_style; }
|
||||
String style_string() const { return style_to_string(m_style); }
|
||||
DeprecatedString style_string() const { return style_to_string(m_style); }
|
||||
|
||||
void set_years_style(StringView years_style) { m_years_style = date_style_from_string(years_style); }
|
||||
ValueStyle years_style() const { return m_years_style; }
|
||||
|
@ -160,9 +160,9 @@ private:
|
|||
static Display display_from_string(StringView display);
|
||||
static StringView display_to_string(Display);
|
||||
|
||||
String m_locale; // [[Locale]]
|
||||
String m_data_locale; // [[DataLocale]]
|
||||
String m_numbering_system; // [[NumberingSystem]]
|
||||
DeprecatedString m_locale; // [[Locale]]
|
||||
DeprecatedString m_data_locale; // [[DataLocale]]
|
||||
DeprecatedString m_numbering_system; // [[NumberingSystem]]
|
||||
Style m_style; // [[Style]]
|
||||
ValueStyle m_years_style { ValueStyle::Long }; // [[YearsStyle]]
|
||||
Display m_years_display { Display::Auto }; // [[YearsDisplay]]
|
||||
|
@ -217,14 +217,14 @@ static constexpr AK::Array<DurationInstanceComponent, 10> duration_instances_com
|
|||
};
|
||||
|
||||
struct DurationUnitOptions {
|
||||
String style;
|
||||
String display;
|
||||
DeprecatedString style;
|
||||
DeprecatedString display;
|
||||
};
|
||||
|
||||
ThrowCompletionOr<Temporal::DurationRecord> to_duration_record(VM&, Value input);
|
||||
i8 duration_record_sign(Temporal::DurationRecord const&);
|
||||
bool is_valid_duration_record(Temporal::DurationRecord const&);
|
||||
ThrowCompletionOr<DurationUnitOptions> get_duration_unit_options(VM&, String const& unit, Object const& options, StringView base_style, Span<StringView const> styles_list, StringView digital_base, StringView previous_style);
|
||||
ThrowCompletionOr<DurationUnitOptions> get_duration_unit_options(VM&, DeprecatedString const& unit, Object const& options, StringView base_style, Span<StringView const> styles_list, StringView digital_base, StringView previous_style);
|
||||
Vector<PatternPartition> partition_duration_format_pattern(VM&, DurationFormat const&, Temporal::DurationRecord const& duration);
|
||||
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ ThrowCompletionOr<Object*> DurationFormatConstructor::construct(FunctionObject&
|
|||
// 8. Let opt be the Record { [[localeMatcher]]: matcher, [[nu]]: numberingSystem }.
|
||||
LocaleOptions opt {};
|
||||
opt.locale_matcher = matcher;
|
||||
opt.nu = numbering_system.is_undefined() ? Optional<String>() : numbering_system.as_string().string();
|
||||
opt.nu = numbering_system.is_undefined() ? Optional<DeprecatedString>() : numbering_system.as_string().string();
|
||||
|
||||
// 9. Let r be ResolveLocale(%DurationFormat%.[[AvailableLocales]], requestedLocales, opt, %DurationFormat%.[[RelevantExtensionKeys]], %DurationFormat%.[[LocaleData]]).
|
||||
auto result = resolve_locale(requested_locales, opt, DurationFormat::relevant_extension_keys());
|
||||
|
@ -99,7 +99,7 @@ ThrowCompletionOr<Object*> DurationFormatConstructor::construct(FunctionObject&
|
|||
duration_format->set_data_locale(move(result.data_locale));
|
||||
|
||||
// 16. Let prevStyle be the empty String.
|
||||
auto previous_style = String::empty();
|
||||
auto previous_style = DeprecatedString::empty();
|
||||
|
||||
// 17. For each row of Table 1, except the header row, in table order, do
|
||||
for (auto const& duration_instances_component : duration_instances_components) {
|
||||
|
|
|
@ -93,7 +93,7 @@ Vector<PatternPartition> deconstruct_pattern(StringView pattern, Placeables plac
|
|||
}
|
||||
|
||||
// 13.5.2 CreatePartsFromList ( listFormat, list ), https://tc39.es/ecma402/#sec-createpartsfromlist
|
||||
Vector<PatternPartition> create_parts_from_list(ListFormat const& list_format, Vector<String> const& list)
|
||||
Vector<PatternPartition> create_parts_from_list(ListFormat const& list_format, Vector<DeprecatedString> const& list)
|
||||
{
|
||||
auto list_patterns = ::Locale::get_locale_list_patterns(list_format.locale(), list_format.type_string(), list_format.style());
|
||||
if (!list_patterns.has_value())
|
||||
|
@ -182,7 +182,7 @@ Vector<PatternPartition> create_parts_from_list(ListFormat const& list_format, V
|
|||
}
|
||||
|
||||
// 13.5.3 FormatList ( listFormat, list ), https://tc39.es/ecma402/#sec-formatlist
|
||||
String format_list(ListFormat const& list_format, Vector<String> const& list)
|
||||
DeprecatedString format_list(ListFormat const& list_format, Vector<DeprecatedString> const& list)
|
||||
{
|
||||
// 1. Let parts be ! CreatePartsFromList(listFormat, list).
|
||||
auto parts = create_parts_from_list(list_format, list);
|
||||
|
@ -201,7 +201,7 @@ String format_list(ListFormat const& list_format, Vector<String> const& list)
|
|||
}
|
||||
|
||||
// 13.5.4 FormatListToParts ( listFormat, list ), https://tc39.es/ecma402/#sec-formatlisttoparts
|
||||
Array* format_list_to_parts(VM& vm, ListFormat const& list_format, Vector<String> const& list)
|
||||
Array* format_list_to_parts(VM& vm, ListFormat const& list_format, Vector<DeprecatedString> const& list)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
|
@ -237,19 +237,19 @@ Array* format_list_to_parts(VM& vm, ListFormat const& list_format, Vector<String
|
|||
}
|
||||
|
||||
// 13.5.5 StringListFromIterable ( iterable ), https://tc39.es/ecma402/#sec-createstringlistfromiterable
|
||||
ThrowCompletionOr<Vector<String>> string_list_from_iterable(VM& vm, Value iterable)
|
||||
ThrowCompletionOr<Vector<DeprecatedString>> string_list_from_iterable(VM& vm, Value iterable)
|
||||
{
|
||||
// 1. If iterable is undefined, then
|
||||
if (iterable.is_undefined()) {
|
||||
// a. Return a new empty List.
|
||||
return Vector<String> {};
|
||||
return Vector<DeprecatedString> {};
|
||||
}
|
||||
|
||||
// 2. Let iteratorRecord be ? GetIterator(iterable).
|
||||
auto iterator_record = TRY(get_iterator(vm, iterable));
|
||||
|
||||
// 3. Let list be a new empty List.
|
||||
Vector<String> list;
|
||||
Vector<DeprecatedString> list;
|
||||
|
||||
// 4. Let next be true.
|
||||
Object* next = nullptr;
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/Variant.h>
|
||||
#include <AK/Vector.h>
|
||||
|
@ -30,8 +30,8 @@ public:
|
|||
|
||||
virtual ~ListFormat() override = default;
|
||||
|
||||
String const& locale() const { return m_locale; }
|
||||
void set_locale(String locale) { m_locale = move(locale); }
|
||||
DeprecatedString const& locale() const { return m_locale; }
|
||||
void set_locale(DeprecatedString locale) { m_locale = move(locale); }
|
||||
|
||||
Type type() const { return m_type; }
|
||||
void set_type(StringView type);
|
||||
|
@ -44,7 +44,7 @@ public:
|
|||
private:
|
||||
explicit ListFormat(Object& prototype);
|
||||
|
||||
String m_locale; // [[Locale]]
|
||||
DeprecatedString m_locale; // [[Locale]]
|
||||
Type m_type { Type::Invalid }; // [[Type]]
|
||||
::Locale::Style m_style { ::Locale::Style::Long }; // [[Style]]
|
||||
};
|
||||
|
@ -52,9 +52,9 @@ private:
|
|||
using Placeables = HashMap<StringView, Variant<PatternPartition, Vector<PatternPartition>>>;
|
||||
|
||||
Vector<PatternPartition> deconstruct_pattern(StringView pattern, Placeables);
|
||||
Vector<PatternPartition> create_parts_from_list(ListFormat const&, Vector<String> const& list);
|
||||
String format_list(ListFormat const&, Vector<String> const& list);
|
||||
Array* format_list_to_parts(VM&, ListFormat const&, Vector<String> const& list);
|
||||
ThrowCompletionOr<Vector<String>> string_list_from_iterable(VM&, Value iterable);
|
||||
Vector<PatternPartition> create_parts_from_list(ListFormat const&, Vector<DeprecatedString> const& list);
|
||||
DeprecatedString format_list(ListFormat const&, Vector<DeprecatedString> const& list);
|
||||
Array* format_list_to_parts(VM&, ListFormat const&, Vector<DeprecatedString> const& list);
|
||||
ThrowCompletionOr<Vector<DeprecatedString>> string_list_from_iterable(VM&, Value iterable);
|
||||
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ Locale::Locale(::Locale::LocaleID const& locale_id, Object& prototype)
|
|||
}
|
||||
|
||||
// 1.1.1 CreateArrayFromListOrRestricted ( list , restricted )
|
||||
static Array* create_array_from_list_or_restricted(VM& vm, Vector<StringView> list, Optional<String> restricted)
|
||||
static Array* create_array_from_list_or_restricted(VM& vm, Vector<StringView> list, Optional<DeprecatedString> restricted)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
|
@ -75,7 +75,7 @@ static Array* create_array_from_list_or_restricted(VM& vm, Vector<StringView> li
|
|||
Array* calendars_of_locale(VM& vm, Locale const& locale_object)
|
||||
{
|
||||
// 1. Let restricted be loc.[[Calendar]].
|
||||
Optional<String> restricted = locale_object.has_calendar() ? locale_object.calendar() : Optional<String> {};
|
||||
Optional<DeprecatedString> restricted = locale_object.has_calendar() ? locale_object.calendar() : Optional<DeprecatedString> {};
|
||||
|
||||
// 2. Let locale be loc.[[Locale]].
|
||||
auto const& locale = locale_object.locale();
|
||||
|
@ -94,7 +94,7 @@ Array* calendars_of_locale(VM& vm, Locale const& locale_object)
|
|||
Array* collations_of_locale(VM& vm, Locale const& locale_object)
|
||||
{
|
||||
// 1. Let restricted be loc.[[Collation]].
|
||||
Optional<String> restricted = locale_object.has_collation() ? locale_object.collation() : Optional<String> {};
|
||||
Optional<DeprecatedString> restricted = locale_object.has_collation() ? locale_object.collation() : Optional<DeprecatedString> {};
|
||||
|
||||
// 2. Let locale be loc.[[Locale]].
|
||||
auto const& locale = locale_object.locale();
|
||||
|
@ -113,7 +113,7 @@ Array* collations_of_locale(VM& vm, Locale const& locale_object)
|
|||
Array* hour_cycles_of_locale(VM& vm, Locale const& locale_object)
|
||||
{
|
||||
// 1. Let restricted be loc.[[HourCycle]].
|
||||
Optional<String> restricted = locale_object.has_hour_cycle() ? locale_object.hour_cycle() : Optional<String> {};
|
||||
Optional<DeprecatedString> restricted = locale_object.has_hour_cycle() ? locale_object.hour_cycle() : Optional<DeprecatedString> {};
|
||||
|
||||
// 2. Let locale be loc.[[Locale]].
|
||||
auto const& locale = locale_object.locale();
|
||||
|
@ -132,7 +132,7 @@ Array* hour_cycles_of_locale(VM& vm, Locale const& locale_object)
|
|||
Array* numbering_systems_of_locale(VM& vm, Locale const& locale_object)
|
||||
{
|
||||
// 1. Let restricted be loc.[[NumberingSystem]].
|
||||
Optional<String> restricted = locale_object.has_numbering_system() ? locale_object.numbering_system() : Optional<String> {};
|
||||
Optional<DeprecatedString> restricted = locale_object.has_numbering_system() ? locale_object.numbering_system() : Optional<DeprecatedString> {};
|
||||
|
||||
// 2. Let locale be loc.[[Locale]].
|
||||
auto const& locale = locale_object.locale();
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/Array.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibJS/Runtime/Completion.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
|
@ -36,28 +36,28 @@ public:
|
|||
|
||||
virtual ~Locale() override = default;
|
||||
|
||||
String const& locale() const { return m_locale; }
|
||||
void set_locale(String locale) { m_locale = move(locale); }
|
||||
DeprecatedString const& locale() const { return m_locale; }
|
||||
void set_locale(DeprecatedString locale) { m_locale = move(locale); }
|
||||
|
||||
bool has_calendar() const { return m_calendar.has_value(); }
|
||||
String const& calendar() const { return m_calendar.value(); }
|
||||
void set_calendar(String calendar) { m_calendar = move(calendar); }
|
||||
DeprecatedString const& calendar() const { return m_calendar.value(); }
|
||||
void set_calendar(DeprecatedString calendar) { m_calendar = move(calendar); }
|
||||
|
||||
bool has_case_first() const { return m_case_first.has_value(); }
|
||||
String const& case_first() const { return m_case_first.value(); }
|
||||
void set_case_first(String case_first) { m_case_first = move(case_first); }
|
||||
DeprecatedString const& case_first() const { return m_case_first.value(); }
|
||||
void set_case_first(DeprecatedString case_first) { m_case_first = move(case_first); }
|
||||
|
||||
bool has_collation() const { return m_collation.has_value(); }
|
||||
String const& collation() const { return m_collation.value(); }
|
||||
void set_collation(String collation) { m_collation = move(collation); }
|
||||
DeprecatedString const& collation() const { return m_collation.value(); }
|
||||
void set_collation(DeprecatedString collation) { m_collation = move(collation); }
|
||||
|
||||
bool has_hour_cycle() const { return m_hour_cycle.has_value(); }
|
||||
String const& hour_cycle() const { return m_hour_cycle.value(); }
|
||||
void set_hour_cycle(String hour_cycle) { m_hour_cycle = move(hour_cycle); }
|
||||
DeprecatedString const& hour_cycle() const { return m_hour_cycle.value(); }
|
||||
void set_hour_cycle(DeprecatedString hour_cycle) { m_hour_cycle = move(hour_cycle); }
|
||||
|
||||
bool has_numbering_system() const { return m_numbering_system.has_value(); }
|
||||
String const& numbering_system() const { return m_numbering_system.value(); }
|
||||
void set_numbering_system(String numbering_system) { m_numbering_system = move(numbering_system); }
|
||||
DeprecatedString const& numbering_system() const { return m_numbering_system.value(); }
|
||||
void set_numbering_system(DeprecatedString numbering_system) { m_numbering_system = move(numbering_system); }
|
||||
|
||||
bool numeric() const { return m_numeric; }
|
||||
void set_numeric(bool numeric) { m_numeric = numeric; }
|
||||
|
@ -66,13 +66,13 @@ private:
|
|||
explicit Locale(Object& prototype);
|
||||
Locale(::Locale::LocaleID const&, Object& prototype);
|
||||
|
||||
String m_locale; // [[Locale]]
|
||||
Optional<String> m_calendar; // [[Calendar]]
|
||||
Optional<String> m_case_first; // [[CaseFirst]]
|
||||
Optional<String> m_collation; // [[Collation]]
|
||||
Optional<String> m_hour_cycle; // [[HourCycle]]
|
||||
Optional<String> m_numbering_system; // [[NumberingSystem]]
|
||||
bool m_numeric { false }; // [[Numeric]]
|
||||
DeprecatedString m_locale; // [[Locale]]
|
||||
Optional<DeprecatedString> m_calendar; // [[Calendar]]
|
||||
Optional<DeprecatedString> m_case_first; // [[CaseFirst]]
|
||||
Optional<DeprecatedString> m_collation; // [[Collation]]
|
||||
Optional<DeprecatedString> m_hour_cycle; // [[HourCycle]]
|
||||
Optional<DeprecatedString> m_numbering_system; // [[NumberingSystem]]
|
||||
bool m_numeric { false }; // [[Numeric]]
|
||||
};
|
||||
|
||||
// Table 1: WeekInfo Record Fields, https://tc39.es/proposal-intl-locale-info/#table-locale-weekinfo-record
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/TypeCasts.h>
|
||||
#include <LibJS/Runtime/AbstractOperations.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
|
@ -17,21 +17,21 @@
|
|||
namespace JS::Intl {
|
||||
|
||||
struct LocaleAndKeys {
|
||||
String locale;
|
||||
Optional<String> ca;
|
||||
Optional<String> co;
|
||||
Optional<String> hc;
|
||||
Optional<String> kf;
|
||||
Optional<String> kn;
|
||||
Optional<String> nu;
|
||||
DeprecatedString locale;
|
||||
Optional<DeprecatedString> ca;
|
||||
Optional<DeprecatedString> co;
|
||||
Optional<DeprecatedString> hc;
|
||||
Optional<DeprecatedString> kf;
|
||||
Optional<DeprecatedString> kn;
|
||||
Optional<DeprecatedString> nu;
|
||||
};
|
||||
|
||||
// Note: This is not an AO in the spec. This just serves to abstract very similar steps in ApplyOptionsToTag and the Intl.Locale constructor.
|
||||
static ThrowCompletionOr<Optional<String>> get_string_option(VM& vm, Object const& options, PropertyKey const& property, Function<bool(StringView)> validator, Span<StringView const> values = {})
|
||||
static ThrowCompletionOr<Optional<DeprecatedString>> get_string_option(VM& vm, Object const& options, PropertyKey const& property, Function<bool(StringView)> validator, Span<StringView const> values = {})
|
||||
{
|
||||
auto option = TRY(get_option(vm, options, property, OptionType::String, values, Empty {}));
|
||||
if (option.is_undefined())
|
||||
return Optional<String> {};
|
||||
return Optional<DeprecatedString> {};
|
||||
|
||||
if (validator && !validator(option.as_string().string()))
|
||||
return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, option, property);
|
||||
|
@ -40,7 +40,7 @@ static ThrowCompletionOr<Optional<String>> get_string_option(VM& vm, Object cons
|
|||
}
|
||||
|
||||
// 14.1.2 ApplyOptionsToTag ( tag, options ), https://tc39.es/ecma402/#sec-apply-options-to-tag
|
||||
static ThrowCompletionOr<String> apply_options_to_tag(VM& vm, StringView tag, Object const& options)
|
||||
static ThrowCompletionOr<DeprecatedString> apply_options_to_tag(VM& vm, StringView tag, Object const& options)
|
||||
{
|
||||
// 1. Assert: Type(tag) is String.
|
||||
// 2. Assert: Type(options) is Object.
|
||||
|
@ -112,7 +112,7 @@ static LocaleAndKeys apply_unicode_extension_to_tag(StringView tag, LocaleAndKey
|
|||
auto locale_id = ::Locale::parse_unicode_locale_id(tag);
|
||||
VERIFY(locale_id.has_value());
|
||||
|
||||
Vector<String> attributes;
|
||||
Vector<DeprecatedString> attributes;
|
||||
Vector<::Locale::Keyword> keywords;
|
||||
|
||||
// 3. If tag contains a substring that is a Unicode locale extension sequence, then
|
||||
|
@ -134,7 +134,7 @@ static LocaleAndKeys apply_unicode_extension_to_tag(StringView tag, LocaleAndKey
|
|||
// a. Let attributes be a new empty List.
|
||||
// b. Let keywords be a new empty List.
|
||||
|
||||
auto field_from_key = [](LocaleAndKeys& value, StringView key) -> Optional<String>& {
|
||||
auto field_from_key = [](LocaleAndKeys& value, StringView key) -> Optional<DeprecatedString>& {
|
||||
if (key == "ca"sv)
|
||||
return value.ca;
|
||||
if (key == "co"sv)
|
||||
|
@ -156,7 +156,7 @@ static LocaleAndKeys apply_unicode_extension_to_tag(StringView tag, LocaleAndKey
|
|||
// 6. For each element key of relevantExtensionKeys, do
|
||||
for (auto const& key : relevant_extension_keys) {
|
||||
// a. Let value be undefined.
|
||||
Optional<String> value {};
|
||||
Optional<DeprecatedString> value {};
|
||||
|
||||
::Locale::Keyword* entry = nullptr;
|
||||
// b. If keywords contains an element whose [[Key]] is the same as key, then
|
||||
|
@ -260,7 +260,7 @@ ThrowCompletionOr<Object*> LocaleConstructor::construct(FunctionObject& new_targ
|
|||
// 6. Let locale be ? OrdinaryCreateFromConstructor(NewTarget, "%Locale.prototype%", internalSlotsList).
|
||||
auto* locale = TRY(ordinary_create_from_constructor<Locale>(vm, new_target, &Intrinsics::intl_locale_prototype));
|
||||
|
||||
String tag;
|
||||
DeprecatedString tag;
|
||||
|
||||
// 7. If Type(tag) is not String or Object, throw a TypeError exception.
|
||||
if (!tag_value.is_string() && !tag_value.is_object())
|
||||
|
|
|
@ -293,12 +293,12 @@ bool MathematicalValue::is_zero() const
|
|||
[](auto) { return false; });
|
||||
}
|
||||
|
||||
String MathematicalValue::to_string() const
|
||||
DeprecatedString MathematicalValue::to_string() const
|
||||
{
|
||||
return m_value.visit(
|
||||
[](double value) { return number_to_string(value, NumberToStringMode::WithoutExponent); },
|
||||
[](Crypto::SignedBigInteger const& value) { return value.to_base(10); },
|
||||
[](auto) -> String { VERIFY_NOT_REACHED(); });
|
||||
[](auto) -> DeprecatedString { VERIFY_NOT_REACHED(); });
|
||||
}
|
||||
|
||||
Value MathematicalValue::to_value(VM& vm) const
|
||||
|
|
|
@ -87,7 +87,7 @@ public:
|
|||
bool is_positive() const;
|
||||
bool is_zero() const;
|
||||
|
||||
String to_string() const;
|
||||
DeprecatedString to_string() const;
|
||||
Value to_value(VM&) const;
|
||||
|
||||
private:
|
||||
|
|
|
@ -494,10 +494,10 @@ FormatResult format_numeric_to_string(NumberFormatBase const& intl_object, Mathe
|
|||
// 14. If int < minInteger, then
|
||||
if (digits < min_integer) {
|
||||
// a. Let forwardZeros be the String consisting of minInteger–int occurrences of the character "0".
|
||||
auto forward_zeros = String::repeated('0', min_integer - digits);
|
||||
auto forward_zeros = DeprecatedString::repeated('0', min_integer - digits);
|
||||
|
||||
// b. Set string to the string-concatenation of forwardZeros and string.
|
||||
string = String::formatted("{}{}", forward_zeros, string);
|
||||
string = DeprecatedString::formatted("{}{}", forward_zeros, string);
|
||||
}
|
||||
|
||||
// 15. If isNegative and x is 0, then
|
||||
|
@ -522,7 +522,7 @@ Vector<PatternPartition> partition_number_pattern(VM& vm, NumberFormat& number_f
|
|||
// 1. Let exponent be 0.
|
||||
int exponent = 0;
|
||||
|
||||
String formatted_string;
|
||||
DeprecatedString formatted_string;
|
||||
|
||||
// 2. If x is not-a-number, then
|
||||
if (number.is_nan()) {
|
||||
|
@ -714,7 +714,7 @@ static Vector<StringView> separate_integer_into_groups(::Locale::NumberGroupings
|
|||
|
||||
// 15.5.5 PartitionNotationSubPattern ( numberFormat, x, n, exponent ), https://tc39.es/ecma402/#sec-partitionnotationsubpattern
|
||||
// 1.1.7 PartitionNotationSubPattern ( numberFormat, x, n, exponent ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-partitionnotationsubpattern
|
||||
Vector<PatternPartition> partition_notation_sub_pattern(NumberFormat& number_format, MathematicalValue const& number, String formatted_string, int exponent)
|
||||
Vector<PatternPartition> partition_notation_sub_pattern(NumberFormat& number_format, MathematicalValue const& number, DeprecatedString formatted_string, int exponent)
|
||||
{
|
||||
// 1. Let result be a new empty List.
|
||||
Vector<PatternPartition> result;
|
||||
|
@ -885,7 +885,7 @@ Vector<PatternPartition> partition_notation_sub_pattern(NumberFormat& number_for
|
|||
}
|
||||
|
||||
// 15.5.6 FormatNumeric ( numberFormat, x ), https://tc39.es/ecma402/#sec-formatnumber
|
||||
String format_numeric(VM& vm, NumberFormat& number_format, MathematicalValue number)
|
||||
DeprecatedString format_numeric(VM& vm, NumberFormat& number_format, MathematicalValue number)
|
||||
{
|
||||
// 1. Let parts be ? PartitionNumberPattern(numberFormat, x).
|
||||
// Note: Our implementation of PartitionNumberPattern does not throw.
|
||||
|
@ -941,7 +941,7 @@ Array* format_numeric_to_parts(VM& vm, NumberFormat& number_format, Mathematical
|
|||
return result;
|
||||
}
|
||||
|
||||
static String cut_trailing_zeroes(StringView string, int cut)
|
||||
static DeprecatedString cut_trailing_zeroes(StringView string, int cut)
|
||||
{
|
||||
// These steps are exactly the same between ToRawPrecision and ToRawFixed.
|
||||
|
||||
|
@ -1022,7 +1022,7 @@ RawFormatResult to_raw_precision(MathematicalValue const& number, int min_precis
|
|||
// 2. If x = 0, then
|
||||
if (number.is_zero()) {
|
||||
// a. Let m be the String consisting of p occurrences of the character "0".
|
||||
result.formatted_string = String::repeated('0', precision);
|
||||
result.formatted_string = DeprecatedString::repeated('0', precision);
|
||||
|
||||
// b. Let e be 0.
|
||||
exponent = 0;
|
||||
|
@ -1073,10 +1073,10 @@ RawFormatResult to_raw_precision(MathematicalValue const& number, int min_precis
|
|||
// 4. If e ≥ p–1, then
|
||||
if (exponent >= (precision - 1)) {
|
||||
// a. Let m be the string-concatenation of m and e–p+1 occurrences of the character "0".
|
||||
result.formatted_string = String::formatted(
|
||||
result.formatted_string = DeprecatedString::formatted(
|
||||
"{}{}",
|
||||
result.formatted_string,
|
||||
String::repeated('0', exponent - precision + 1));
|
||||
DeprecatedString::repeated('0', exponent - precision + 1));
|
||||
|
||||
// b. Let int be e+1.
|
||||
result.digits = exponent + 1;
|
||||
|
@ -1084,7 +1084,7 @@ RawFormatResult to_raw_precision(MathematicalValue const& number, int min_precis
|
|||
// 5. Else if e ≥ 0, then
|
||||
else if (exponent >= 0) {
|
||||
// a. Let m be the string-concatenation of the first e+1 characters of m, the character ".", and the remaining p–(e+1) characters of m.
|
||||
result.formatted_string = String::formatted(
|
||||
result.formatted_string = DeprecatedString::formatted(
|
||||
"{}.{}",
|
||||
result.formatted_string.substring_view(0, exponent + 1),
|
||||
result.formatted_string.substring_view(exponent + 1));
|
||||
|
@ -1096,9 +1096,9 @@ RawFormatResult to_raw_precision(MathematicalValue const& number, int min_precis
|
|||
else {
|
||||
// a. Assert: e < 0.
|
||||
// b. Let m be the string-concatenation of "0.", –(e+1) occurrences of the character "0", and m.
|
||||
result.formatted_string = String::formatted(
|
||||
result.formatted_string = DeprecatedString::formatted(
|
||||
"0.{}{}",
|
||||
String::repeated('0', -1 * (exponent + 1)),
|
||||
DeprecatedString::repeated('0', -1 * (exponent + 1)),
|
||||
result.formatted_string);
|
||||
|
||||
// c. Let int be 1.
|
||||
|
@ -1206,7 +1206,7 @@ RawFormatResult to_raw_fixed(MathematicalValue const& number, int min_fraction,
|
|||
}
|
||||
|
||||
// 7. If n = 0, let m be "0". Otherwise, let m be the String consisting of the digits of the decimal representation of n (in order, with no leading zeroes).
|
||||
result.formatted_string = n.is_zero() ? String("0"sv) : n.to_string();
|
||||
result.formatted_string = n.is_zero() ? DeprecatedString("0"sv) : n.to_string();
|
||||
|
||||
// 8. If f ≠ 0, then
|
||||
if (fraction != 0) {
|
||||
|
@ -1216,10 +1216,10 @@ RawFormatResult to_raw_fixed(MathematicalValue const& number, int min_fraction,
|
|||
// b. If k ≤ f, then
|
||||
if (decimals <= static_cast<size_t>(fraction)) {
|
||||
// i. Let z be the String value consisting of f+1–k occurrences of the character "0".
|
||||
auto zeroes = String::repeated('0', fraction + 1 - decimals);
|
||||
auto zeroes = DeprecatedString::repeated('0', fraction + 1 - decimals);
|
||||
|
||||
// ii. Let m be the string-concatenation of z and m.
|
||||
result.formatted_string = String::formatted("{}{}", zeroes, result.formatted_string);
|
||||
result.formatted_string = DeprecatedString::formatted("{}{}", zeroes, result.formatted_string);
|
||||
|
||||
// iii. Let k be f+1.
|
||||
decimals = fraction + 1;
|
||||
|
@ -1230,7 +1230,7 @@ RawFormatResult to_raw_fixed(MathematicalValue const& number, int min_fraction,
|
|||
auto b = result.formatted_string.substring_view(decimals - fraction, fraction);
|
||||
|
||||
// d. Let m be the string-concatenation of a, ".", and b.
|
||||
result.formatted_string = String::formatted("{}.{}", a, b);
|
||||
result.formatted_string = DeprecatedString::formatted("{}.{}", a, b);
|
||||
|
||||
// e. Let int be the number of characters in a.
|
||||
result.digits = a.length();
|
||||
|
@ -1253,7 +1253,7 @@ RawFormatResult to_raw_fixed(MathematicalValue const& number, int min_fraction,
|
|||
|
||||
// 15.5.11 GetNumberFormatPattern ( numberFormat, x ), https://tc39.es/ecma402/#sec-getnumberformatpattern
|
||||
// 1.1.14 GetNumberFormatPattern ( numberFormat, x ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-getnumberformatpattern
|
||||
Optional<Variant<StringView, String>> get_number_format_pattern(VM& vm, NumberFormat& number_format, MathematicalValue const& number, ::Locale::NumberFormat& found_pattern)
|
||||
Optional<Variant<StringView, DeprecatedString>> get_number_format_pattern(VM& vm, NumberFormat& number_format, MathematicalValue const& number, ::Locale::NumberFormat& found_pattern)
|
||||
{
|
||||
// 1. Let localeData be %NumberFormat%.[[LocaleData]].
|
||||
// 2. Let dataLocale be numberFormat.[[DataLocale]].
|
||||
|
@ -1797,7 +1797,7 @@ Vector<PatternPartitionWithSource> collapse_number_range(Vector<PatternPartition
|
|||
}
|
||||
|
||||
// 1.1.24 FormatNumericRange( numberFormat, x, y ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-formatnumericrange
|
||||
ThrowCompletionOr<String> format_numeric_range(VM& vm, NumberFormat& number_format, MathematicalValue start, MathematicalValue end)
|
||||
ThrowCompletionOr<DeprecatedString> format_numeric_range(VM& vm, NumberFormat& number_format, MathematicalValue start, MathematicalValue end)
|
||||
{
|
||||
// 1. Let parts be ? PartitionNumberRangePattern(numberFormat, x, y).
|
||||
auto parts = TRY(partition_number_range_pattern(vm, number_format, move(start), move(end)));
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/Array.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibJS/Runtime/Intl/AbstractOperations.h>
|
||||
#include <LibJS/Runtime/Intl/MathematicalValue.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
|
@ -58,11 +58,11 @@ public:
|
|||
|
||||
virtual ~NumberFormatBase() override = default;
|
||||
|
||||
String const& locale() const { return m_locale; }
|
||||
void set_locale(String locale) { m_locale = move(locale); }
|
||||
DeprecatedString const& locale() const { return m_locale; }
|
||||
void set_locale(DeprecatedString locale) { m_locale = move(locale); }
|
||||
|
||||
String const& data_locale() const { return m_data_locale; }
|
||||
void set_data_locale(String data_locale) { m_data_locale = move(data_locale); }
|
||||
DeprecatedString const& data_locale() const { return m_data_locale; }
|
||||
void set_data_locale(DeprecatedString data_locale) { m_data_locale = move(data_locale); }
|
||||
|
||||
int min_integer_digits() const { return m_min_integer_digits; }
|
||||
void set_min_integer_digits(int min_integer_digits) { m_min_integer_digits = min_integer_digits; }
|
||||
|
@ -102,8 +102,8 @@ protected:
|
|||
explicit NumberFormatBase(Object& prototype);
|
||||
|
||||
private:
|
||||
String m_locale; // [[Locale]]
|
||||
String m_data_locale; // [[DataLocale]]
|
||||
DeprecatedString m_locale; // [[Locale]]
|
||||
DeprecatedString m_data_locale; // [[DataLocale]]
|
||||
int m_min_integer_digits { 0 }; // [[MinimumIntegerDigits]]
|
||||
Optional<int> m_min_fraction_digits {}; // [[MinimumFractionDigits]]
|
||||
Optional<int> m_max_fraction_digits {}; // [[MaximumFractionDigits]]
|
||||
|
@ -178,16 +178,16 @@ public:
|
|||
|
||||
virtual ~NumberFormat() override = default;
|
||||
|
||||
String const& numbering_system() const { return m_numbering_system; }
|
||||
void set_numbering_system(String numbering_system) { m_numbering_system = move(numbering_system); }
|
||||
DeprecatedString const& numbering_system() const { return m_numbering_system; }
|
||||
void set_numbering_system(DeprecatedString numbering_system) { m_numbering_system = move(numbering_system); }
|
||||
|
||||
Style style() const { return m_style; }
|
||||
StringView style_string() const;
|
||||
void set_style(StringView style);
|
||||
|
||||
bool has_currency() const { return m_currency.has_value(); }
|
||||
String const& currency() const { return m_currency.value(); }
|
||||
void set_currency(String currency) { m_currency = move(currency); }
|
||||
DeprecatedString const& currency() const { return m_currency.value(); }
|
||||
void set_currency(DeprecatedString currency) { m_currency = move(currency); }
|
||||
|
||||
bool has_currency_display() const { return m_currency_display.has_value(); }
|
||||
CurrencyDisplay currency_display() const { return *m_currency_display; }
|
||||
|
@ -201,8 +201,8 @@ public:
|
|||
void set_currency_sign(StringView set_currency_sign);
|
||||
|
||||
bool has_unit() const { return m_unit.has_value(); }
|
||||
String const& unit() const { return m_unit.value(); }
|
||||
void set_unit(String unit) { m_unit = move(unit); }
|
||||
DeprecatedString const& unit() const { return m_unit.value(); }
|
||||
void set_unit(DeprecatedString unit) { m_unit = move(unit); }
|
||||
|
||||
bool has_unit_display() const { return m_unit_display.has_value(); }
|
||||
::Locale::Style unit_display() const { return *m_unit_display; }
|
||||
|
@ -238,14 +238,14 @@ private:
|
|||
|
||||
virtual void visit_edges(Visitor&) override;
|
||||
|
||||
String m_locale; // [[Locale]]
|
||||
String m_data_locale; // [[DataLocale]]
|
||||
String m_numbering_system; // [[NumberingSystem]]
|
||||
DeprecatedString m_locale; // [[Locale]]
|
||||
DeprecatedString m_data_locale; // [[DataLocale]]
|
||||
DeprecatedString m_numbering_system; // [[NumberingSystem]]
|
||||
Style m_style { Style::Invalid }; // [[Style]]
|
||||
Optional<String> m_currency {}; // [[Currency]]
|
||||
Optional<DeprecatedString> m_currency {}; // [[Currency]]
|
||||
Optional<CurrencyDisplay> m_currency_display {}; // [[CurrencyDisplay]]
|
||||
Optional<CurrencySign> m_currency_sign {}; // [[CurrencySign]]
|
||||
Optional<String> m_unit {}; // [[Unit]]
|
||||
Optional<DeprecatedString> m_unit {}; // [[Unit]]
|
||||
Optional<::Locale::Style> m_unit_display {}; // [[UnitDisplay]]
|
||||
UseGrouping m_use_grouping { false }; // [[UseGrouping]]
|
||||
Notation m_notation { Notation::Invalid }; // [[Notation]]
|
||||
|
@ -261,7 +261,7 @@ private:
|
|||
};
|
||||
|
||||
struct FormatResult {
|
||||
String formatted_string; // [[FormattedString]]
|
||||
DeprecatedString formatted_string; // [[FormattedString]]
|
||||
MathematicalValue rounded_number { 0.0 }; // [[RoundedNumber]]
|
||||
};
|
||||
|
||||
|
@ -278,12 +278,12 @@ enum class RoundingDecision {
|
|||
int currency_digits(StringView currency);
|
||||
FormatResult format_numeric_to_string(NumberFormatBase const& intl_object, MathematicalValue number);
|
||||
Vector<PatternPartition> partition_number_pattern(VM&, NumberFormat&, MathematicalValue number);
|
||||
Vector<PatternPartition> partition_notation_sub_pattern(NumberFormat&, MathematicalValue const& number, String formatted_string, int exponent);
|
||||
String format_numeric(VM&, NumberFormat&, MathematicalValue number);
|
||||
Vector<PatternPartition> partition_notation_sub_pattern(NumberFormat&, MathematicalValue const& number, DeprecatedString formatted_string, int exponent);
|
||||
DeprecatedString format_numeric(VM&, NumberFormat&, MathematicalValue number);
|
||||
Array* format_numeric_to_parts(VM&, NumberFormat&, MathematicalValue number);
|
||||
RawFormatResult to_raw_precision(MathematicalValue const& number, int min_precision, int max_precision, Optional<NumberFormat::UnsignedRoundingMode> const& unsigned_rounding_mode);
|
||||
RawFormatResult to_raw_fixed(MathematicalValue const& number, int min_fraction, int max_fraction, int rounding_increment, Optional<NumberFormat::UnsignedRoundingMode> const& unsigned_rounding_mode);
|
||||
Optional<Variant<StringView, String>> get_number_format_pattern(VM&, NumberFormat&, MathematicalValue const& number, ::Locale::NumberFormat& found_pattern);
|
||||
Optional<Variant<StringView, DeprecatedString>> get_number_format_pattern(VM&, NumberFormat&, MathematicalValue const& number, ::Locale::NumberFormat& found_pattern);
|
||||
Optional<StringView> get_notation_sub_pattern(NumberFormat&, int exponent);
|
||||
int compute_exponent(NumberFormat&, MathematicalValue number);
|
||||
int compute_exponent_for_magnitude(NumberFormat&, int magnitude);
|
||||
|
@ -293,7 +293,7 @@ RoundingDecision apply_unsigned_rounding_mode(MathematicalValue const& x, Mathem
|
|||
ThrowCompletionOr<Vector<PatternPartitionWithSource>> partition_number_range_pattern(VM&, NumberFormat&, MathematicalValue start, MathematicalValue end);
|
||||
Vector<PatternPartitionWithSource> format_approximately(NumberFormat&, Vector<PatternPartitionWithSource> result);
|
||||
Vector<PatternPartitionWithSource> collapse_number_range(Vector<PatternPartitionWithSource> result);
|
||||
ThrowCompletionOr<String> format_numeric_range(VM&, NumberFormat&, MathematicalValue start, MathematicalValue end);
|
||||
ThrowCompletionOr<DeprecatedString> format_numeric_range(VM&, NumberFormat&, MathematicalValue start, MathematicalValue end);
|
||||
ThrowCompletionOr<Array*> format_numeric_range_to_parts(VM&, NumberFormat&, MathematicalValue start, MathematicalValue end);
|
||||
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ void NumberFormatFunction::initialize(Realm& realm)
|
|||
|
||||
Base::initialize(realm);
|
||||
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
define_direct_property(vm.names.name, js_string(vm, String::empty()), Attribute::Configurable);
|
||||
define_direct_property(vm.names.name, js_string(vm, DeprecatedString::empty()), Attribute::Configurable);
|
||||
}
|
||||
|
||||
ThrowCompletionOr<Value> NumberFormatFunction::call()
|
||||
|
|
|
@ -18,7 +18,7 @@ PluralRules::PluralRules(Object& prototype)
|
|||
}
|
||||
|
||||
// 16.5.1 GetOperands ( s ), https://tc39.es/ecma402/#sec-getoperands
|
||||
::Locale::PluralOperands get_operands(String const& string)
|
||||
::Locale::PluralOperands get_operands(DeprecatedString const& string)
|
||||
{
|
||||
// 1.Let n be ! ToNumber(s).
|
||||
auto number = string.to_double(AK::TrimWhitespace::Yes).release_value();
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <LibJS/Runtime/Completion.h>
|
||||
#include <LibJS/Runtime/Intl/NumberFormat.h>
|
||||
|
@ -31,7 +31,7 @@ private:
|
|||
::Locale::PluralForm m_type { ::Locale::PluralForm::Cardinal }; // [[Type]]
|
||||
};
|
||||
|
||||
::Locale::PluralOperands get_operands(String const& string);
|
||||
::Locale::PluralOperands get_operands(DeprecatedString const& string);
|
||||
::Locale::PluralCategory plural_rule_select(StringView locale, ::Locale::PluralForm type, Value number, ::Locale::PluralOperands operands);
|
||||
::Locale::PluralCategory resolve_plural(PluralRules const&, Value number);
|
||||
::Locale::PluralCategory resolve_plural(NumberFormatBase const& number_format, ::Locale::PluralForm type, Value number);
|
||||
|
|
|
@ -222,7 +222,7 @@ Vector<PatternPartitionWithUnit> make_parts_list(StringView pattern, StringView
|
|||
}
|
||||
|
||||
// 17.5.4 FormatRelativeTime ( relativeTimeFormat, value, unit ), https://tc39.es/ecma402/#sec-FormatRelativeTime
|
||||
ThrowCompletionOr<String> format_relative_time(VM& vm, RelativeTimeFormat& relative_time_format, double value, StringView unit)
|
||||
ThrowCompletionOr<DeprecatedString> format_relative_time(VM& vm, RelativeTimeFormat& relative_time_format, double value, StringView unit)
|
||||
{
|
||||
// 1. Let parts be ? PartitionRelativeTimePattern(relativeTimeFormat, value, unit).
|
||||
auto parts = TRY(partition_relative_time_pattern(vm, relative_time_format, value, unit));
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/Array.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <LibJS/Runtime/Completion.h>
|
||||
#include <LibJS/Runtime/Intl/AbstractOperations.h>
|
||||
|
@ -35,14 +35,14 @@ public:
|
|||
|
||||
virtual ~RelativeTimeFormat() override = default;
|
||||
|
||||
String const& locale() const { return m_locale; }
|
||||
void set_locale(String locale) { m_locale = move(locale); }
|
||||
DeprecatedString const& locale() const { return m_locale; }
|
||||
void set_locale(DeprecatedString locale) { m_locale = move(locale); }
|
||||
|
||||
String const& data_locale() const { return m_data_locale; }
|
||||
void set_data_locale(String data_locale) { m_data_locale = move(data_locale); }
|
||||
DeprecatedString const& data_locale() const { return m_data_locale; }
|
||||
void set_data_locale(DeprecatedString data_locale) { m_data_locale = move(data_locale); }
|
||||
|
||||
String const& numbering_system() const { return m_numbering_system; }
|
||||
void set_numbering_system(String numbering_system) { m_numbering_system = move(numbering_system); }
|
||||
DeprecatedString const& numbering_system() const { return m_numbering_system; }
|
||||
void set_numbering_system(DeprecatedString numbering_system) { m_numbering_system = move(numbering_system); }
|
||||
|
||||
::Locale::Style style() const { return m_style; }
|
||||
void set_style(StringView style) { m_style = ::Locale::style_from_string(style); }
|
||||
|
@ -63,9 +63,9 @@ private:
|
|||
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
String m_locale; // [[Locale]]
|
||||
String m_data_locale; // [[DataLocale]]
|
||||
String m_numbering_system; // [[NumberingSystem]]
|
||||
DeprecatedString m_locale; // [[Locale]]
|
||||
DeprecatedString m_data_locale; // [[DataLocale]]
|
||||
DeprecatedString m_numbering_system; // [[NumberingSystem]]
|
||||
::Locale::Style m_style { ::Locale::Style::Long }; // [[Style]]
|
||||
Numeric m_numeric { Numeric::Always }; // [[Numeric]]
|
||||
NumberFormat* m_number_format { nullptr }; // [[NumberFormat]]
|
||||
|
@ -73,7 +73,7 @@ private:
|
|||
};
|
||||
|
||||
struct PatternPartitionWithUnit : public PatternPartition {
|
||||
PatternPartitionWithUnit(StringView type, String value, StringView unit_string = {})
|
||||
PatternPartitionWithUnit(StringView type, DeprecatedString value, StringView unit_string = {})
|
||||
: PatternPartition(type, move(value))
|
||||
, unit(unit_string)
|
||||
{
|
||||
|
@ -85,7 +85,7 @@ struct PatternPartitionWithUnit : public PatternPartition {
|
|||
ThrowCompletionOr<::Locale::TimeUnit> singular_relative_time_unit(VM&, StringView unit);
|
||||
ThrowCompletionOr<Vector<PatternPartitionWithUnit>> partition_relative_time_pattern(VM&, RelativeTimeFormat&, double value, StringView unit);
|
||||
Vector<PatternPartitionWithUnit> make_parts_list(StringView pattern, StringView unit, Vector<PatternPartition> parts);
|
||||
ThrowCompletionOr<String> format_relative_time(VM&, RelativeTimeFormat&, double value, StringView unit);
|
||||
ThrowCompletionOr<DeprecatedString> format_relative_time(VM&, RelativeTimeFormat&, double value, StringView unit);
|
||||
ThrowCompletionOr<Array*> format_relative_time_to_parts(VM&, RelativeTimeFormat&, double value, StringView unit);
|
||||
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
|
||||
namespace JS::Intl {
|
||||
|
@ -23,8 +23,8 @@ public:
|
|||
|
||||
virtual ~Segmenter() override = default;
|
||||
|
||||
String const& locale() const { return m_locale; }
|
||||
void set_locale(String locale) { m_locale = move(locale); }
|
||||
DeprecatedString const& locale() const { return m_locale; }
|
||||
void set_locale(DeprecatedString locale) { m_locale = move(locale); }
|
||||
|
||||
SegmenterGranularity segmenter_granularity() const { return m_segmenter_granularity; }
|
||||
void set_segmenter_granularity(StringView);
|
||||
|
@ -33,7 +33,7 @@ public:
|
|||
private:
|
||||
explicit Segmenter(Object& prototype);
|
||||
|
||||
String m_locale; // [[Locale]]
|
||||
DeprecatedString m_locale; // [[Locale]]
|
||||
SegmenterGranularity m_segmenter_granularity { SegmenterGranularity::Grapheme }; // [[SegmenterGranularity]]
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue