Commit graph

63 commits

Author SHA1 Message Date
Linus Groh
08dd1c3e2d LibJS: Convert get_options_object() to ThrowCompletionOr 2021-09-16 22:34:24 +01:00
Idan Horowitz
5a4c90fcb1 LibJS: Convert ordinary_create_from_constructor<T> to ThrowCompletionOr 2021-09-16 13:53:37 +01:00
Linus Groh
8253e14818 LibJS: Convert Intl.NumberFormat.prototype to be a PrototypeObject 2021-09-13 19:07:26 +01:00
Linus Groh
b0c1179ff8 LibJS: Convert Intl.Locale.prototype to be a PrototypeObject 2021-09-13 19:07:26 +01:00
Linus Groh
c277658ca6 LibJS: Convert Intl.ListFormat.prototype to be a PrototypeObject 2021-09-13 19:07:26 +01:00
Linus Groh
b256b50476 LibJS: Convert Intl.DisplayNames.prototype to be a PrototypeObject 2021-09-13 19:07:26 +01:00
Timothy Flynn
673fc02ac5 LibJS: Move locale_relevant_extension_keys to Intl.Locale 2021-09-12 12:57:17 +01:00
Timothy Flynn
7769cd2cab LibJS: Move number_format_relevant_extension_keys to Intl.NumberFormat
This method represents the Intl.NumberFormat's [[RelevantExtensionKeys]]
internal slot, so it makes more sense for this to be directly in the
class itself.
2021-09-12 12:57:17 +01:00
Timothy Flynn
94a5a0437c LibJS: Move Intl.NumberFormat's AOs to its object file 2021-09-12 12:57:17 +01:00
Timothy Flynn
0b08201fec LibJS: Move Intl.ListFormat's AOs to its object file
To be consistent with the style in Temporal, let's move all AOs in Intl
to their object file, rather than splitting the AOs between prototype
and constructor files.
2021-09-12 12:57:17 +01:00
Timothy Flynn
ae7b5280c2 LibJS: Make "options" objects const references in NumberFormat's AOs 2021-09-12 12:57:17 +01:00
Timothy Flynn
7f700bd84e LibJS: Make GetNumberOption's "options" object a const reference 2021-09-12 12:57:17 +01:00
Timothy Flynn
aa2af06c84 LibJS: Store Intl.Locale's "tag" argument as a plain string 2021-09-12 12:57:17 +01:00
Timothy Flynn
4411e16798 LibJS: Change GetOption AO to accept the options as a concrete Object
This was being verified at runtime anyways, so let the compiler ensure
it. This also matches the GetOption AO in Temporal now.
2021-09-12 12:57:17 +01:00
Timothy Flynn
ada56981dc LibJS: Sort Intl AbstractOperation declarations by spec ID
The definitions in the .cpp file are already sorted this way.
2021-09-12 12:57:17 +01:00
Timothy Flynn
094c390fb1 LibJS: Move CanonicalCodeForDisplayNames to Intl.DisplayNames
Intl.DisplayNames was the first Intl object implemented, and at that
point all AOs were just put into the main Intl AO header. But AOs that
belong to specific objects belong in that object's header. So this moves
CanonicalCodeForDisplayNames to the Intl.DisplayNames header.
2021-09-12 12:57:17 +01:00
Timothy Flynn
470262c8ab LibJS: Use ErrorType::NotAnObjectOfType instead of NotA 2021-09-12 00:16:39 +02:00
Timothy Flynn
9b5696fee7 LibJS: Implement Intl.NumberFormat.prototype.resolvedOptions 2021-09-11 11:05:50 +01:00
Timothy Flynn
071e193d92 LibJS: Implement Intl.NumberFormat.supportedLocalesOf 2021-09-11 11:05:50 +01:00
Timothy Flynn
e42ba7f748 LibJS: Implement the Intl.NumberFormat constructor 2021-09-11 11:05:50 +01:00
Timothy Flynn
07f12b108b LibJS: Implement a nearly empty Intl.NumberFormat object
This adds plumbing for the Intl.NumberFormat object, constructor, and
prototype.
2021-09-11 11:05:50 +01:00
Timothy Flynn
a1954262f8 LibJS: Handle Unicode locale extensions in the ResolveLocale operation
Currently, all callers of ResolveLocale invoke the operation with an
empty [[RelevantExtensionKeys]] slot, so the block of the method that
deals with those keys was unimplemented. This implements that block now
to prepare for Intl.NumberFormat which has a [[RelevantExtensionKeys]].

Note that the find_key_in_value() method is a simple VERIFY_NOT_REACHED
in just this commit until the Intl.NumberFormat's keys are handled in
its implementation.
2021-09-11 11:05:50 +01:00
Timothy Flynn
4f2bcebe74 LibUnicode+LibJS: Store locale keyword values as a single string
Previously, LibUnicode would store the values of a keyword as a Vector.
For example, the locale "en-u-ca-abc-def" would have its keyword "ca"
stored as {"abc, "def"}. Then, canonicalization would occur on each of
the elements in that Vector.

This is incorrect because, for example, the keyword value "true" should
only be dropped if that is the entire value. That is, the canonical form
of "en-u-kb-true" is "en-u-kb", but "en-u-kb-abc-true" does not change
for canonicalization. However, we would canonicalize that locale as
"en-u-kb-abc".
2021-09-08 21:08:48 +01:00
Timothy Flynn
2ebafe000a LibJS: Fix typos in Intl.ListFormat comments 2021-09-08 21:08:48 +01:00
Timothy Flynn
ef94c73a01 LibJS: Implement Intl.ListFormat.prototype.resolvedOptions 2021-09-06 23:49:56 +01:00
Timothy Flynn
5c06a91dfa LibJS: Implement Intl.ListFormat.prototype.formatToParts 2021-09-06 23:49:56 +01:00
Timothy Flynn
cdba40f7ea LibJS: Implement Intl.ListFormat.prototype.format 2021-09-06 23:49:56 +01:00
Timothy Flynn
3b410742ab LibJS: Implement Intl.ListFormat.supportedLocalesOf 2021-09-06 23:49:56 +01:00
Timothy Flynn
eacc8bef47 LibJS: Implement the Intl.ListFormat constructor 2021-09-06 23:49:56 +01:00
Timothy Flynn
8e75e5fabb LibJS: Implement a nearly empty Intl.ListFormat object
This adds plumbing for the Intl.ListFormat object, constructor, and
prototype.
2021-09-06 23:49:56 +01:00
Timothy Flynn
207319ecf1 LibJS: Implement ECMA-402 String.prototype.toLocale{Lower,Upper}Case 2021-09-06 15:24:27 +01:00
Timothy Flynn
14086c69e7 LibJS: Only remove Unicode locale extensions during the LookupMatcher AO
This was one of the first AOs used for Intl, and I misinterpreted the
spec. Rather than removing all extensions, we must only remove Unicode
locale extensions.

Also use LocaleID::to_string() here instead of the heavier canonical
string method, because the locale is already canonical.
2021-09-06 15:24:27 +01:00
Linus Groh
0094259d72 LibJS: Implement Intl.DisplayNames.supportedLocalesOf() 2021-09-04 19:08:18 +01:00
Timothy Flynn
90971673c7 LibJS: Implement Intl.Locale.prototype.minimize 2021-09-04 13:51:40 +01:00
Timothy Flynn
0b1f5118d5 LibJS: Implement Intl.Locale.prototype.maximize 2021-09-04 13:51:40 +01:00
Timothy Flynn
03d7f01e0c LibJS: Add a constructor to create an Intl.Locale object from a LocaleID 2021-09-04 13:51:40 +01:00
Timothy Flynn
3abfe7f7db LibJS: Add missing Intl.Locale initializer for plain boolean type 2021-09-04 13:51:40 +01:00
Timothy Flynn
32825107de LibJS: Implement Intl.Locale.prototype.region 2021-09-02 17:56:42 +01:00
Timothy Flynn
349fd06b86 LibJS: Implement Intl.Locale.prototype.script 2021-09-02 17:56:42 +01:00
Timothy Flynn
c3b6f43641 LibJS: Implement Intl.Locale.prototype.language 2021-09-02 17:56:42 +01:00
Timothy Flynn
bdf36575c8 LibJS: Implement Intl.Locale.prototype.numeric 2021-09-02 17:56:42 +01:00
Timothy Flynn
d7825f3680 LibJS: Implement most Intl.Locale.Prototype.<<keyword>> properties
The keyword accessors all have the same function body in the spec,
except for the Intl.Locale method they invoke. This generates those
properties in the same manner as RegExp.prototype.

    Intl.Locale.prototype.calendar
    Intl.Locale.prototype.caseFirst
    Intl.Locale.prototype.collation
    Intl.Locale.prototype.hourCycle
    Intl.Locale.prototype.numberingSystem

The exception is Intl.Locale.prototype.numeric, which will be defined
separately because it is a boolean value.
2021-09-02 17:56:42 +01:00
Timothy Flynn
21b3c5edba LibJS: Implement Intl.Locale.prototype.baseName 2021-09-02 17:56:42 +01:00
Timothy Flynn
27fc3cfe75 LibJS: Handle existing Intl.Locale objects in CanonicalizeLocaleList 2021-09-02 17:56:42 +01:00
Timothy Flynn
17639a42ae LibJS: Implement the Intl.Locale constructor 2021-09-02 17:56:42 +01:00
Timothy Flynn
990dd037d2 LibJS: Implement Intl.Locale.prototype.toString()
This isn't particularly testable yet without the Intl.Locale constructor
but having this defined will make testing the constructor possible. So
more specific tests for this prototype will come later.
2021-09-02 17:56:42 +01:00
Timothy Flynn
940c023e09 LibJS: Compare Unicode locale variants using case-insensitive matching
In the IsStructurallyValidLanguageTag AO, we of course cannot assume the
variants are canonicalized to lower-case yet, because canonicalization
hasn't happened yet.
2021-09-02 17:56:42 +01:00
Timothy Flynn
fdedb3ab33 LibJS: Remove duplicated error message from ErrorTypes.h
ErrorType::IntlInvalidCode has almost exactly the same message as
ErrorType::OptionIsNotValidValue. Remove it, as all uses of the former
are semantically interchangeable with the latter.
2021-09-02 17:56:42 +01:00
Timothy Flynn
2c10e9fdd3 LibJS: Implement a nearly empty Intl.Locale object
This adds plumbing for the Intl.Locale object, constructor, and
prototype.
2021-09-02 17:56:42 +01:00
Timothy Flynn
d13142f015 LibJS+LibUnicode: Store parsed Unicode locale data as full strings
Originally, it was convenient to store the parsed Unicode locale data as
views into the original string being parsed. But to implement locale
aliases will require mutating the data that was parsed. To prepare for
that, store the parsed data as proper strings.
2021-09-01 14:14:47 +01:00