From 9e97b8330e1b9a4e6471c9b202b76d49aa5a1bcf Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Wed, 9 Oct 2024 16:47:32 +0000 Subject: [PATCH] Bug 1920955 - Part 47: Remove ToCalendarValue and ToTemporalTimeZone from constructors. r=sfink Still not done with the "Normative: Remove calendars and time zones" spec PR. The constructors also no longer call `ToCalendarValue` or `ToTemporalTimeZone`. Differential Revision: https://phabricator.services.mozilla.com/D223553 UltraBlame original commit: d2fdb7e06acb78e3292b7e0948a5735dd66ff690 --- js/src/builtin/temporal/PlainDate.cpp | 87 +++++++++- js/src/builtin/temporal/PlainDateTime.cpp | 87 +++++++++- js/src/builtin/temporal/PlainMonthDay.cpp | 89 +++++++++- js/src/builtin/temporal/PlainYearMonth.cpp | 89 +++++++++- js/src/builtin/temporal/ZonedDateTime.cpp | 187 +++++++++++++++++++-- 5 files changed, 511 insertions(+), 28 deletions(-) diff --git a/js/src/builtin/temporal/PlainDate.cpp b/js/src/builtin/temporal/PlainDate.cpp index eab42667819e9..61de9bf367bf4 100644 --- a/js/src/builtin/temporal/PlainDate.cpp +++ b/js/src/builtin/temporal/PlainDate.cpp @@ -8683,8 +8683,10 @@ false } / / -Step +Steps 5 +- +8 . Rooted < @@ -8693,20 +8695,96 @@ CalendarValue calendar ( cx +CalendarValue +( +CalendarId +: +: +ISO8601 +) ) ; if ( +args +. +hasDefined +( +3 +) +) +{ +/ +/ +Step +6 +. +if +( ! -ToTemporalCalendarWithISODefault +args +[ +3 +] +. +isString +( +) +) +{ +ReportValueError ( cx +JSMSG_UNEXPECTED_TYPE +JSDVG_IGNORE_STACK args +[ +3 +] +nullptr +" +not +a +string +" +) +; +return +false +; +} +/ +/ +Steps +7 +- +8 . -get +Rooted +< +JSString +* +> +calendarString ( +cx +args +[ 3 +] +. +toString +( ) +) +; +if +( +! +ToBuiltinCalendar +( +cx +calendarString & calendar ) @@ -8716,10 +8794,11 @@ return false ; } +} / / Step -6 +9 . auto * diff --git a/js/src/builtin/temporal/PlainDateTime.cpp b/js/src/builtin/temporal/PlainDateTime.cpp index b5ec456cdcc2b..7c4ba21961fd0 100644 --- a/js/src/builtin/temporal/PlainDateTime.cpp +++ b/js/src/builtin/temporal/PlainDateTime.cpp @@ -6679,8 +6679,10 @@ false } / / -Step +Steps 11 +- +14 . Rooted < @@ -6689,20 +6691,96 @@ CalendarValue calendar ( cx +CalendarValue +( +CalendarId +: +: +ISO8601 +) ) ; if ( +args +. +hasDefined +( +9 +) +) +{ +/ +/ +Step +12 +. +if +( ! -ToTemporalCalendarWithISODefault +args +[ +9 +] +. +isString +( +) +) +{ +ReportValueError ( cx +JSMSG_UNEXPECTED_TYPE +JSDVG_IGNORE_STACK args +[ +9 +] +nullptr +" +not +a +string +" +) +; +return +false +; +} +/ +/ +Steps +13 +- +14 . -get +Rooted +< +JSString +* +> +calendarString ( +cx +args +[ 9 +] +. +toString +( ) +) +; +if +( +! +ToBuiltinCalendar +( +cx +calendarString & calendar ) @@ -6712,10 +6790,11 @@ return false ; } +} / / Step -12 +15 . auto * diff --git a/js/src/builtin/temporal/PlainMonthDay.cpp b/js/src/builtin/temporal/PlainMonthDay.cpp index d5e4ffb9fa873..a3e12c09300b8 100644 --- a/js/src/builtin/temporal/PlainMonthDay.cpp +++ b/js/src/builtin/temporal/PlainMonthDay.cpp @@ -2172,8 +2172,10 @@ false } / / -Step +Steps 5 +- +8 . Rooted < @@ -2182,20 +2184,96 @@ CalendarValue calendar ( cx +CalendarValue +( +CalendarId +: +: +ISO8601 +) ) ; if ( +args +. +hasDefined +( +2 +) +) +{ +/ +/ +Step +6 +. +if +( ! -ToTemporalCalendarWithISODefault +args +[ +2 +] +. +isString +( +) +) +{ +ReportValueError ( cx +JSMSG_UNEXPECTED_TYPE +JSDVG_IGNORE_STACK args +[ +2 +] +nullptr +" +not +a +string +" +) +; +return +false +; +} +/ +/ +Steps +7 +- +8 . -get +Rooted +< +JSString +* +> +calendarString ( +cx +args +[ 2 +] +. +toString +( +) ) +; +if +( +! +ToBuiltinCalendar +( +cx +calendarString & calendar ) @@ -2205,12 +2283,13 @@ return false ; } +} / / Steps 2 and -6 +9 . double isoYear @@ -2253,7 +2332,7 @@ false / / Step -7 +10 . auto * diff --git a/js/src/builtin/temporal/PlainYearMonth.cpp b/js/src/builtin/temporal/PlainYearMonth.cpp index 80d00fd6f5208..a31438e3171bb 100644 --- a/js/src/builtin/temporal/PlainYearMonth.cpp +++ b/js/src/builtin/temporal/PlainYearMonth.cpp @@ -4155,8 +4155,10 @@ false } / / -Step +Steps 5 +- +8 . Rooted < @@ -4165,20 +4167,96 @@ CalendarValue calendar ( cx +CalendarValue +( +CalendarId +: +: +ISO8601 +) ) ; if ( +args +. +hasDefined +( +2 +) +) +{ +/ +/ +Step +6 +. +if +( ! -ToTemporalCalendarWithISODefault +args +[ +2 +] +. +isString +( +) +) +{ +ReportValueError ( cx +JSMSG_UNEXPECTED_TYPE +JSDVG_IGNORE_STACK args +[ +2 +] +nullptr +" +not +a +string +" +) +; +return +false +; +} +/ +/ +Steps +7 +- +8 . -get +Rooted +< +JSString +* +> +calendarString ( +cx +args +[ 2 +] +. +toString +( +) ) +; +if +( +! +ToBuiltinCalendar +( +cx +calendarString & calendar ) @@ -4188,12 +4266,13 @@ return false ; } +} / / Steps 2 and -6 +9 . double isoDay @@ -4236,7 +4315,7 @@ false / / Step -7 +10 . auto * diff --git a/js/src/builtin/temporal/ZonedDateTime.cpp b/js/src/builtin/temporal/ZonedDateTime.cpp index 4384b745ae55e..7cd18a200e548 100644 --- a/js/src/builtin/temporal/ZonedDateTime.cpp +++ b/js/src/builtin/temporal/ZonedDateTime.cpp @@ -6742,11 +6742,72 @@ false Step 4 . +if +( +! +args +. +get +( +1 +) +. +isString +( +) +) +{ +ReportValueError +( +cx +JSMSG_UNEXPECTED_TYPE +JSDVG_IGNORE_STACK +args +. +get +( +1 +) +nullptr +" +not +a +string +" +) +; +return +false +; +} +/ +/ +Step +5 +. Rooted < -TimeZoneValue +JSString +* > -timeZone +timeZoneString +( +cx +args +[ +1 +] +. +toString +( +) +) +; +Rooted +< +ParsedTimeZone +> +timeZoneParse ( cx ) @@ -6754,15 +6815,42 @@ cx if ( ! -ToTemporalTimeZone +ParseTimeZoneIdentifier ( cx -args +timeZoneString +& +timeZoneParse +) +) +{ +return +false +; +} +/ +/ +Steps +6 +- +7 . -get +Rooted +< +TimeZoneValue +> +timeZone ( -1 +cx ) +; +if +( +! +ToTemporalTimeZone +( +cx +timeZoneParse & timeZone ) @@ -6774,8 +6862,10 @@ false } / / -Step -5 +Steps +8 +- +11 . Rooted < @@ -6784,20 +6874,96 @@ CalendarValue calendar ( cx +CalendarValue +( +CalendarId +: +: +ISO8601 +) ) ; if ( +args +. +hasDefined +( +2 +) +) +{ +/ +/ +Step +9 +. +if +( ! -ToTemporalCalendarWithISODefault +args +[ +2 +] +. +isString +( +) +) +{ +ReportValueError ( cx +JSMSG_UNEXPECTED_TYPE +JSDVG_IGNORE_STACK args +[ +2 +] +nullptr +" +not +a +string +" +) +; +return +false +; +} +/ +/ +Steps +10 +- +11 . -get +Rooted +< +JSString +* +> +calendarString ( +cx +args +[ 2 +] +. +toString +( +) ) +; +if +( +! +ToBuiltinCalendar +( +cx +calendarString & calendar ) @@ -6807,6 +6973,7 @@ return false ; } +} / / Step