Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
[JSC] Implement Intl.DurationFormat
https://bugs.webkit.org/show_bug.cgi?id=214794 <rdar://66436701> Reviewed by Ross Kirsling. This patch implements Intl.DurationFormat[1], which is now stage-3 feature. It is decoupled from Temporal now: it can take an object with `hours` etc. properties, and generate formatted string for duration. In the future, it will accept Temporal.Duration too. 1. We add new microsecond and nanosecond units because they are necessary to DurationFormat[2]. 2. Implement Intl.DurationFormat with UNumberFormatter and UListFormatter. [1]: https://github.com/tc39/proposal-intl-duration-format [2]: tc39/ecma402#708 * JSTests/stress/intl-durationformat-basic.js: Added. (shouldBe): (shouldBeOneOf): (shouldBeForICUVersion): (shouldNotThrow): (shouldThrow): * JSTests/stress/intl-durationformat-digital.js: Added. (shouldBe): (throw.new.Error): * JSTests/stress/intl-durationformat-format-to-parts.js: Added. (shouldBe): (shouldBeOneOf): (shouldBeForICUVersion): (shouldNotThrow): (shouldThrow): (throw.new.Error): * JSTests/stress/intl-durationformat.js: Added. (shouldBe): (shouldNotThrow): (shouldThrow): (test.DerivedDurationFormat): (test.get shouldThrow): (test): * JSTests/stress/intl-enumeration.js: * JSTests/test262/config.yaml: * JSTests/test262/expectations.yaml: * Source/JavaScriptCore/CMakeLists.txt: * Source/JavaScriptCore/DerivedSources-input.xcfilelist: * Source/JavaScriptCore/DerivedSources-output.xcfilelist: * Source/JavaScriptCore/DerivedSources.make: * Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj: * Source/JavaScriptCore/Sources.txt: * Source/JavaScriptCore/heap/Heap.cpp: (JSC::Heap::Heap): * Source/JavaScriptCore/heap/Heap.h: * Source/JavaScriptCore/heap/HeapSubspaceTypes.h: * Source/JavaScriptCore/runtime/CommonIdentifiers.h: * Source/JavaScriptCore/runtime/IntlDurationFormat.cpp: Added. (JSC::IntlDurationFormat::create): (JSC::IntlDurationFormat::createStructure): (JSC::IntlDurationFormat::IntlDurationFormat): (JSC::IntlDurationFormat::finishCreation): (JSC::intlDurationUnitOptions): (JSC::displayName): (JSC::IntlDurationFormat::initializeDurationFormat): (JSC::ListFormatInput::ListFormatInput): (JSC::ListFormatInput::size const): (JSC::ListFormatInput::stringPointers const): (JSC::ListFormatInput::stringLengths const): (JSC::retrieveSeparator): (JSC::collectElements): (JSC::IntlDurationFormat::format const): (JSC::IntlDurationFormat::formatToParts const): (JSC::IntlDurationFormat::resolvedOptions const): (JSC::IntlDurationFormat::styleString): (JSC::IntlDurationFormat::unitStyleString): (JSC::IntlDurationFormat::displayString): * Source/JavaScriptCore/runtime/IntlDurationFormat.h: Added. * Source/JavaScriptCore/runtime/IntlDurationFormatConstructor.cpp: Added. (JSC::IntlDurationFormatConstructor::create): (JSC::IntlDurationFormatConstructor::createStructure): (JSC::IntlDurationFormatConstructor::IntlDurationFormatConstructor): (JSC::IntlDurationFormatConstructor::finishCreation): (JSC::JSC_DEFINE_HOST_FUNCTION): * Source/JavaScriptCore/runtime/IntlDurationFormatConstructor.h: Added. * Source/JavaScriptCore/runtime/IntlDurationFormatPrototype.cpp: Added. (JSC::IntlDurationFormatPrototype::create): (JSC::IntlDurationFormatPrototype::createStructure): (JSC::IntlDurationFormatPrototype::IntlDurationFormatPrototype): (JSC::IntlDurationFormatPrototype::finishCreation): (JSC::JSC_DEFINE_HOST_FUNCTION): * Source/JavaScriptCore/runtime/IntlDurationFormatPrototype.h: Added. * Source/JavaScriptCore/runtime/IntlObject.cpp: (JSC::createDurationFormatConstructor): (JSC::IntlObject::finishCreation): * Source/JavaScriptCore/runtime/IntlObject.h: (JSC::intlDurationFormatAvailableLocales): * Source/JavaScriptCore/runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * Source/JavaScriptCore/runtime/JSGlobalObject.h: (JSC::JSGlobalObject::durationFormatStructure): Canonical link: https://commits.webkit.org/254791@main
- Loading branch information