Граф коммитов

64 Коммитов

Автор SHA1 Сообщение Дата
Greg Tatum 12c9670cc5 Bug 1713206 - Propagate ICU statuses to ICUErrors; r=platform-i18n-reviewers,dminor
Depends on D124963

Differential Revision: https://phabricator.services.mozilla.com/D124964
2021-09-08 21:36:29 +00:00
Greg Tatum 46c00b33ef Bug 1713206 - Flatten nested namespaces in mozilla::intl components; r=platform-i18n-reviewers,dminor
This is a drive-by clean-up while I'm working on errors.

Depends on D124962

Differential Revision: https://phabricator.services.mozilla.com/D124963
2021-09-08 21:36:29 +00:00
Greg Tatum e5f56207b3 Bug 1713206 - Add missing ICUError.h headers; r=platform-i18n-reviewers,dminor
Depends on D124961

Differential Revision: https://phabricator.services.mozilla.com/D124962
2021-09-08 21:36:29 +00:00
Greg Tatum 65a2bb16fc Bug 1713206 - Use ICUError in mozilla::intl::PluralRules; r=platform-i18n-reviewers,dminor
Depends on D124960

Differential Revision: https://phabricator.services.mozilla.com/D124961
2021-09-08 21:36:28 +00:00
Greg Tatum b917c44dd2 Bug 1713206 - Use ICUError in mozilla::intl::DateTimePatternGenerator; r=platform-i18n-reviewers,dminor
Depends on D124959

Differential Revision: https://phabricator.services.mozilla.com/D124960
2021-09-08 21:36:28 +00:00
Greg Tatum c5836fc86a Bug 1713206 - Use ICUError in mozilla::intl::Calendar; r=platform-i18n-reviewers,dminor
Differential Revision: https://phabricator.services.mozilla.com/D124959
2021-09-08 21:36:27 +00:00
Greg Tatum 7666a8132a Bug 1719540 - Fix unified build imports bustages for mozilla::intl; r=dminor
Depends on D120249

Differential Revision: https://phabricator.services.mozilla.com/D124116
2021-09-01 00:02:31 +00:00
Greg Tatum 443160a426 Bug 1719540 - Implement a unified Locale canonicalizer; r=platform-i18n-reviewers,dminor
I used the C api here, but verified that the behavior was the same
as using the C++ getBaseName API.

927fee5656/src/features/icu.cpp (L249-L268)

I tried to keep the implementation naming at least similar to the
work in: https://phabricator.services.mozilla.com/D118070

However, the implementation do diverge. I figure in the future, the
APIs can be made similar, but at least the gtests will ensure the
behavior remains the same.

Differential Revision: https://phabricator.services.mozilla.com/D120248
2021-09-01 00:02:30 +00:00
Alexandru Michis 7be95b70ef Backed out 2 changesets (bug 1719540) for causing bustages in RelativeTimeFormat.cpp
CLOSED TREE

Backed out changeset a6ab150a89f2 (bug 1719540)
Backed out changeset e8b05f56aa75 (bug 1719540)
2021-08-31 21:14:11 +03:00
Greg Tatum 1909173425 Bug 1719540 - Implement a unified Locale canonicalizer; r=platform-i18n-reviewers,dminor
I used the C api here, but verified that the behavior was the same
as using the C++ getBaseName API.

927fee5656/src/features/icu.cpp (L249-L268)

I tried to keep the implementation naming at least similar to the
work in: https://phabricator.services.mozilla.com/D118070

However, the implementation do diverge. I figure in the future, the
APIs can be made similar, but at least the gtests will ensure the
behavior remains the same.

Differential Revision: https://phabricator.services.mozilla.com/D120248
2021-08-31 15:39:39 +00:00
Dan Minor a7c1a01337 Bug 1719462 - Add intl::RelativeTimeFormat; r=platform-i18n-reviewers,gregtatum
Differential Revision: https://phabricator.services.mozilla.com/D121413
2021-08-30 19:50:20 +00:00
Dan Minor 76fa3fdc8c Bug 1719462 - Improve comments for NumberFormat::formatToParts; r=platform-i18n-reviewers,gregtatum
Differential Revision: https://phabricator.services.mozilla.com/D121412
2021-08-30 19:50:20 +00:00
Dan Minor 9ea8b755f2 Bug 1719462 - Move FormatResultToParts to NumberFormatFields; r=platform-i18n-reviewers,gregtatum
This code will be used by RelativeTimeFormat, so we need to move it to a place
where it will be accessible to both NumberFormat and RelativeTimeFormat.

Differential Revision: https://phabricator.services.mozilla.com/D121411
2021-08-30 19:50:20 +00:00
Dan Minor d8d32990af Bug 1719462 - Use ICUError in NumberFormat; r=platform-i18n-reviewers,gregtatum
Differential Revision: https://phabricator.services.mozilla.com/D121410
2021-08-30 19:50:19 +00:00
Dan Minor 962b25b43e Bug 1719462 - Add TestBuffer::clear(); r=platform-i18n-reviewers,gregtatum
This allows reusing the same buffer multiple times in a test, which
keeps test code simpler.

Differential Revision: https://phabricator.services.mozilla.com/D121409
2021-08-30 19:50:19 +00:00
Andi-Bogdan Postelnicu 2fc4f70e9b Bug 1725145 - Preparation for the hybrid build env. r=necko-reviewers,firefox-build-system-reviewers,valentin,glandium
Automatically generated path that adds flag `REQUIRES_UNIFIED_BUILD = True` to `moz.build`
when the module governed by the build config file is not buildable outside on the unified environment.

This needs to be done in order to have a hybrid build system that adds the possibility of combing
unified build components with ones that are built outside of the unified eco system.

Differential Revision: https://phabricator.services.mozilla.com/D122345
2021-08-25 10:46:17 +00:00
André Bargull 4741c41fed Bug 1648137 - Part 18: Add decimal number and formatToParts support to NumberRangeFormat. r=platform-i18n-reviewers,nordzilla
These new functions match the similarily named functions on `intl::NumberFormat`.

Also add some assertions to `NumberFormat::formatToParts()` when called with
decimal number strings to ensure non-finite number strings aren't used here,
because we always pass `Nothing()` for the number in this method.

Differential Revision: https://phabricator.services.mozilla.com/D119758
2021-08-24 09:34:52 +00:00
André Bargull 777449a2c5 Bug 1648137 - Part 17: Add separate number range options struct. r=platform-i18n-reviewers,nordzilla
`NumberFormatterSkeleton::toRangeFormatter()` receives the two additional options
as extra parameters, because that's simpler to implement compared to storing the
`NumberRangeFormatOptions` struct in `NumberFormatterSkeleton`. We can revisit
this approach should `NumberRangeFormatOptions` ever get more additional options.

Differential Revision: https://phabricator.services.mozilla.com/D119757
2021-08-24 09:34:52 +00:00
André Bargull 982d8dbbbf Bug 1648137 - Part 15: Record the source of a number part. r=platform-i18n-reviewers,nordzilla
Add `NumberPartSource` to `NumberPart` in preparation for part 18.

Also changes the underlying type of `NumberPartType` to `int16_t` to ensure the
size of `NumberPart` doesn't change on 32-bit platforms when adding
`NumberPartSource`. (Note: `sizeof(NumberPart)` is 16 on 64-platforms with or
without this change.)

Differential Revision: https://phabricator.services.mozilla.com/D119755
2021-08-24 09:34:51 +00:00
André Bargull 52d6dde648 Bug 1648137 - Part 14: Make NumberPart a proper struct. r=platform-i18n-reviewers,dminor
In the next part of this patch stack, we want to record the "source" of a
number part. The source is used when formatting number ranges to record if the
formatted number part belongs to the start resp. end of the number range.

Differential Revision: https://phabricator.services.mozilla.com/D119754
2021-08-24 09:34:50 +00:00
André Bargull 59f5314db5 Bug 1648137 - Part 13: Move GetPartTypeForNumberField into NumberFormatFields.h. r=platform-i18n-reviewers,dminor
Change `GetPartTypeForNumberField` to a free function so a later part in this
patch stack can call it when processing number ranges.

Differential Revision: https://phabricator.services.mozilla.com/D119753
2021-08-24 09:34:50 +00:00
André Bargull e6e2c90a1e Bug 1648137 - Part 12: Add support for formatting number strings. r=tcampbell
The "Intl.NumberFormat v3 API" proposal adds support to format arbitrarily large
decimal numbers. For example it's now possible to format the decimal number
1e1000 by passing the string `"1e1000"` to the `format` function.

`ToIntlMathematicalValue()` preprocesses the number as follows:
- Non-finite values (NaN and infinities) are always stored as `double` values.
- Positive and negative zero are also stored as `double` values.
- Non-decimal strings like `"0x10"` are stored as BigInts, because ICU only
  supports decimal number strings.
- An error is thrown if the exponent is too large to workaround ICU limitations.

Normalising non-finite values and ±0 is done in preparation for part 17.

Differential Revision: https://phabricator.services.mozilla.com/D119752
2021-08-24 09:34:50 +00:00
André Bargull 93782a6021 Bug 1648137 - Part 9: Add support for roundingPriority option to intl::NumberFormat. r=platform-i18n-reviewers,dminor
The rounding priority names match the names in the Intl proposal.

Differential Revision: https://phabricator.services.mozilla.com/D119749
2021-08-24 09:34:49 +00:00
André Bargull e1b120bd3d Bug 1648137 - Part 7: Add support for new useGrouping value options to intl::NumberFormat. r=platform-i18n-reviewers,dminor
Change `mUseGrouping` to `mGrouping` and use an `enum` to represent the two
new additional modes "Always" and "Min2".

Differential Revision: https://phabricator.services.mozilla.com/D119747
2021-08-24 09:34:48 +00:00
André Bargull 83a11eb7f8 Bug 1648137 - Part 5: Add support for roundingIncrement, roundingMode, and trailingZeroDisplay options to intl::NumberFormat. r=platform-i18n-reviewers,dminor
First set of new options added in the "Intl.NumberFormat v3 API" proposal.

- All ICU rounding modes are added. (The Intl proposal doesn't support "HalfOdd".)
- The rounding mode names match the names in the Intl proposal, which are
  different compared to the ICU names.
- Significant digits options are ignored when rounding increment is used. This is
  an ICU limitation. The Intl proposal will throw an error if both options are
  used at the same time.

Differential Revision: https://phabricator.services.mozilla.com/D119745
2021-08-24 09:34:47 +00:00
André Bargull b921491f4b Bug 1648137 - Part 2: Add PluralRules::SelectRange(). r=dminor,platform-i18n-reviewers,nordzilla
Add `intl::NumberRangeFormat` based on the existing `intl::NumberFormat` class
and use it to implement `intl::PluralRules::SelectRange()`.

Most ICU number range formatting functions are still draft APIs and therefore
are guarded by `#ifndef U_HIDE_DRAFT_API`. Instead of requiring `mozilla::intl`
users to also use `U_HIDE_DRAFT_API`, add two additional preprocessor definitions
(`MOZ_INTL_PLURAL_RULES_HAS_SELECT_RANGE` and `MOZ_INTL_HAS_NUMBER_RANGE_FORMAT`).

When `MOZ_INTL_HAS_NUMBER_RANGE_FORMAT` isn't defined, `intl::NumberRangeFormat`
is an empty class. We could also hide the complete class if the preprocessor
guard isn't defined, but the other approach results in fewer `#ifdef` guards.

Differential Revision: https://phabricator.services.mozilla.com/D119742
2021-08-24 09:34:46 +00:00
André Bargull d2bbf86876 Bug 1726123 - Part 5: Add missing "js/" includes outside of SM. r=arai
In preparation for the next part, add missing includes to "js/" public headers.

Differential Revision: https://phabricator.services.mozilla.com/D122843
2021-08-17 15:45:39 +00:00
Greg Tatum b41f145a38 Bug 1719550 - Add support for BCP 47 extensions to mozilla::intl::Collator; r=platform-i18n-reviewers,nordzilla
SpiderMonkey requires the BCP 47 locale extensions, which involves iterating
over the keywords in ICU, and mapping them to the BCP 47 version. Specifically,
this will change the "phonebook" keyword to "phonebk". This should hopefully
expose a simpler API to SpiderMonkey, the only consumer.

Differential Revision: https://phabricator.services.mozilla.com/D120903
2021-08-10 16:01:15 +00:00
Greg Tatum c2cf97af11 Bug 1719550 - Build an initial unified mozilla::intl::Collator; r=platform-i18n-reviewers,nordzilla
This collator attempts to match the options bag from the Intl.Collator API
from ECMA-402. It is built to be compatible and consistent across both Gecko
code and SpiderMonkey code. Its behavior is designed to match ECMA-402.

Differential Revision: https://phabricator.services.mozilla.com/D120494
2021-08-10 16:01:15 +00:00
Narcis Beleuzu daed5248e2 Backed out 12 changesets (bug 1719550) for bustages on TestCollator.cpp . CLOSED TREE
Backed out changeset 3b2735a29138 (bug 1719550)
Backed out changeset 5e2019335244 (bug 1719550)
Backed out changeset 105676dd2d6f (bug 1719550)
Backed out changeset b4b0d58778e9 (bug 1719550)
Backed out changeset 3ef5792020bb (bug 1719550)
Backed out changeset 389a77da6ddc (bug 1719550)
Backed out changeset 48f39b5ef77f (bug 1719550)
Backed out changeset bd125cc5b9b4 (bug 1719550)
Backed out changeset a8b778ca2375 (bug 1719550)
Backed out changeset b14702168fb9 (bug 1719550)
Backed out changeset 7b46b5cc7424 (bug 1719550)
Backed out changeset 6b04162618a1 (bug 1719550)
2021-08-10 17:46:34 +03:00
Greg Tatum 1fb2daab2a Bug 1719550 - Add support for BCP 47 extensions to mozilla::intl::Collator; r=platform-i18n-reviewers,nordzilla
SpiderMonkey requires the BCP 47 locale extensions, which involves iterating
over the keywords in ICU, and mapping them to the BCP 47 version. Specifically,
this will change the "phonebook" keyword to "phonebk". This should hopefully
expose a simpler API to SpiderMonkey, the only consumer.

Differential Revision: https://phabricator.services.mozilla.com/D120903
2021-08-10 11:46:34 +00:00
Greg Tatum 0087d035b9 Bug 1719550 - Build an initial unified mozilla::intl::Collator; r=platform-i18n-reviewers,nordzilla
This collator attempts to match the options bag from the Intl.Collator API
from ECMA-402. It is built to be compatible and consistent across both Gecko
code and SpiderMonkey code. Its behavior is designed to match ECMA-402.

Differential Revision: https://phabricator.services.mozilla.com/D120494
2021-08-10 11:46:34 +00:00
Dan Minor 26b1e33737 Bug 1715595 - Use char rather than uint8_t for utf-8 in unified components r=platform-i18n-reviewers,gregtatum
Differential Revision: https://phabricator.services.mozilla.com/D120508
2021-07-23 14:58:00 +00:00
Erik Nordin 0990d59463 Bug 1719758 - Test result values before unwrapping in TestPluralRules r=platform-i18n-reviewers,dminor
Modifies TestPluralRules.cpp to assert that all result values are okay
before unwrapping them. Previously the test suite would crash if an
error result was unwrapped. Now it will fail the test and report the
failure.

Differential Revision: https://phabricator.services.mozilla.com/D119465
2021-07-09 17:49:38 +00:00
Greg Tatum 8c72f6e6ae Bug 1715979 - Do not leak ICU objects in mozilla:intl component moves; r=nordzilla
Differential Revision: https://phabricator.services.mozilla.com/D117569
2021-06-29 15:25:44 +00:00
Erik Nordin ed5c7b4262 Bug 1718345 - Add PluralRules tests for three-letter langids r=platform-i18n-reviewers,dminor
Differential Revision: https://phabricator.services.mozilla.com/D118869
2021-06-28 16:24:03 +00:00
André Bargull 90a85eee9f Bug 1284868: Adjust field widths for hour/minute/second when the user requested 2-digit representation. r=dminor
Change `DateTimePatternGenerator::GetBestPattern()` to call `udatpg_getBestPatternWithOptions()`,
so we can adjust the computed pattern to use 2-digit representation when it was requested by the
user.

Differential Revision: https://phabricator.services.mozilla.com/D118728
2021-06-28 13:20:44 +00:00
Dan Minor eeaf61de24 Bug 1715982 - Fix initial capacity of NumberPartVector; r=anba
Differential Revision: https://phabricator.services.mozilla.com/D117540
2021-06-11 21:22:15 +00:00
Greg Tatum 07cc89dd24 Bug 1711902 - Add Calendar::GetCanonicalTimeZoneID; r=dminor
This finishes the UCalendar unification in DateTimeFormat.cpp

Differential Revision: https://phabricator.services.mozilla.com/D116158
2021-06-10 20:14:17 +00:00
Greg Tatum db78fe91b5 Bug 1711902 - Unify most of UCalendar in SpiderMonkey; r=dminor,anba
This adds a bigger unification primitive of an Enumeration iterator over the
UEnumeration ICU type.

Differential Revision: https://phabricator.services.mozilla.com/D116157
2021-06-10 20:14:17 +00:00
Greg Tatum 23873163d1 Bug 1711902 - Unify the DateTimePatternGenerator in SpiderMonkey; r=dminor,anba
Differential Revision: https://phabricator.services.mozilla.com/D115731
2021-06-10 20:14:17 +00:00
Greg Tatum cb9860735f Bug 1711902 - Remove UDateFormat from SpiderMonkey; r=dminor,anba
This patch starts the work of unifying the DateTimeFormat. It removes the uses
of UDateFormat.

Differential Revision: https://phabricator.services.mozilla.com/D115730
2021-06-10 20:14:16 +00:00
Greg Tatum efe295fd94 Bug 1711902 - Add a FormatBuffer for use in SpiderMonkey; r=anba
Differential Revision: https://phabricator.services.mozilla.com/D116911
2021-06-10 20:14:16 +00:00
Erik Nordin 875656873e Bug 1704509 - Add Unified PuralRules Impl For SpiderMonkey r=anba,dminor
- Adds mozilla::intl::PluralRules
    - Modifies SpiderMonkey code to use PluralRules.
    - Adds gtest suite for PluralRules

Differential Revision: https://phabricator.services.mozilla.com/D115783
2021-06-09 19:04:54 +00:00
Greg Tatum bf5ee6077d Bug 1705156 - Add a unified DateTimeFormat component; r=dminor,anba
This patch adds a DateTimeFormat class for use in the unified
internationalization API. Currently it's only targeting the
ICU code in the Fluent API. The plan is to use it in the Fluent DOM
code, as well as in SpiderMonkey as a centralized API for performing
datetime formatting.

Differential Revision: https://phabricator.services.mozilla.com/D114114
2021-05-27 23:03:43 +00:00
Dan Minor 0452666d00 Bug 1701695 - Add NumberFormat::TryCreate; r=tcampbell
This adds a fallible factory method to create new NumberFormat instances. This
allows us to report initialization errors at time of initialization, rather than
when format is called, and remove internal checks in the implementation for
successful initialization.

The existing fluent code assumes that creating a NumberFormat instance always
succeeds. This patch updates that code to handle failures.

Differential Revision: https://phabricator.services.mozilla.com/D114593
2021-05-12 17:22:51 +00:00
Dan Minor 3b533cd007 Bug 1701695 - Add documentation to NumberFormat.h; r=gregtatum,nordzilla
Differential Revision: https://phabricator.services.mozilla.com/D113145
2021-05-12 17:22:51 +00:00
Dan Minor 5f755ac1ab Bug 1701695 - Use intl::NumberFormatterSkeleton in PluralRules r=tcampbell
This temporarily adds intl::NumberFormatterSkeleton to the public API so that
we can use it in PluralRules. This allows us to remove the SpiderMonkey
NumberFormatterSkeleton implementation when we convert SpiderMonkey to use
intl::NumberFormat.

We can remove intl::NumberFormatterSkeleton from the public API when we
implement intl::PluralRules in Bug 1704509.

Differential Revision: https://phabricator.services.mozilla.com/D111887
2021-05-12 17:22:50 +00:00
Dan Minor d5183e8bf1 Bug 1701695 - Add support for format to parts to intl::NumberFormat r=gregtatum,tcampbell,anba
Differential Revision: https://phabricator.services.mozilla.com/D111886
2021-05-12 17:22:49 +00:00
Dan Minor 4b3bf83c4b Bug 1701695 - Restore [[nodiscard]] annotations to NumberFormatterSkeleton; r=gregtatum
I foolishly dropped these when bringing the code over from SpiderMonkey.

Differential Revision: https://phabricator.services.mozilla.com/D113558
2021-05-12 17:22:49 +00:00