Browse Source

Fix temporal builtin properties (#3930)

* Update length and builtin properties

* Split tags and names as two different statics

* Missed YearMonth and MonthDay length

* Fix length on some methods

* Missed one length

* cargo fmt
pull/3933/head
Kevin Ness 4 months ago committed by GitHub
parent
commit
99642be976
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 10
      core/engine/src/builtins/temporal/duration/mod.rs
  2. 8
      core/engine/src/builtins/temporal/instant/mod.rs
  3. 4
      core/engine/src/builtins/temporal/now.rs
  4. 20
      core/engine/src/builtins/temporal/plain_date/mod.rs
  5. 16
      core/engine/src/builtins/temporal/plain_date_time/mod.rs
  6. 6
      core/engine/src/builtins/temporal/plain_month_day/mod.rs
  7. 10
      core/engine/src/builtins/temporal/plain_time/mod.rs
  8. 6
      core/engine/src/builtins/temporal/plain_year_month/mod.rs
  9. 6
      core/engine/src/builtins/temporal/zoned_date_time/mod.rs
  10. 29
      core/string/src/common.rs

10
core/engine/src/builtins/temporal/duration/mod.rs

@ -47,7 +47,7 @@ impl Duration {
}
impl BuiltInObject for Duration {
const NAME: JsString = StaticJsStrings::DURATION;
const NAME: JsString = StaticJsStrings::DURATION_NAME;
}
impl IntrinsicObject for Duration {
@ -105,7 +105,7 @@ impl IntrinsicObject for Duration {
BuiltInBuilder::from_standard_constructor::<Self>(realm)
.property(
JsSymbol::to_string_tag(),
Self::NAME,
StaticJsStrings::DURATION_TAG,
Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE,
)
.accessor(
@ -184,8 +184,8 @@ impl IntrinsicObject for Duration {
.method(Self::with, js_string!("with"), 1)
.method(Self::negated, js_string!("negated"), 0)
.method(Self::abs, js_string!("abs"), 0)
.method(Self::add, js_string!("add"), 2)
.method(Self::subtract, js_string!("subtract"), 2)
.method(Self::add, js_string!("add"), 1)
.method(Self::subtract, js_string!("subtract"), 1)
.method(Self::round, js_string!("round"), 1)
.method(Self::total, js_string!("total"), 1)
.method(Self::to_string, js_string!("toString"), 1)
@ -199,7 +199,7 @@ impl IntrinsicObject for Duration {
}
impl BuiltInConstructor for Duration {
const LENGTH: usize = 10;
const LENGTH: usize = 0;
const STANDARD_CONSTRUCTOR: fn(&StandardConstructors) -> &StandardConstructor =
StandardConstructors::duration;

8
core/engine/src/builtins/temporal/instant/mod.rs

@ -40,7 +40,7 @@ pub struct Instant {
}
impl BuiltInObject for Instant {
const NAME: JsString = StaticJsStrings::INSTANT;
const NAME: JsString = StaticJsStrings::INSTANT_NAME;
}
impl IntrinsicObject for Instant {
@ -66,7 +66,7 @@ impl IntrinsicObject for Instant {
BuiltInBuilder::from_standard_constructor::<Self>(realm)
.property(
JsSymbol::to_string_tag(),
Self::NAME,
StaticJsStrings::INSTANT_TAG,
Attribute::CONFIGURABLE,
)
.accessor(
@ -107,8 +107,8 @@ impl IntrinsicObject for Instant {
.static_method(Self::compare, js_string!("compare"), 1)
.method(Self::add, js_string!("add"), 1)
.method(Self::subtract, js_string!("subtract"), 1)
.method(Self::until, js_string!("until"), 2)
.method(Self::since, js_string!("since"), 2)
.method(Self::until, js_string!("until"), 1)
.method(Self::since, js_string!("since"), 1)
.method(Self::round, js_string!("round"), 1)
.method(Self::equals, js_string!("equals"), 1)
.method(Self::to_zoned_date_time, js_string!("toZonedDateTime"), 1)

4
core/engine/src/builtins/temporal/now.rs

@ -32,7 +32,7 @@ impl IntrinsicObject for Now {
BuiltInBuilder::with_intrinsic::<Self>(realm)
.static_property(
JsSymbol::to_string_tag(),
Self::NAME,
StaticJsStrings::NOW_TAG,
Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE,
)
.static_method(Self::time_zone_id, js_string!("timeZoneId"), 0)
@ -52,7 +52,7 @@ impl IntrinsicObject for Now {
}
impl BuiltInObject for Now {
const NAME: JsString = StaticJsStrings::NOW;
const NAME: JsString = StaticJsStrings::NOW_NAME;
}
impl Now {

20
core/engine/src/builtins/temporal/plain_date/mod.rs

@ -60,7 +60,7 @@ impl GetTemporalCalendar for JsObject<PlainDate> {
}
impl BuiltInObject for PlainDate {
const NAME: JsString = StaticJsStrings::PLAIN_DATE;
const NAME: JsString = StaticJsStrings::PLAIN_DATE_NAME;
}
impl IntrinsicObject for PlainDate {
@ -126,7 +126,7 @@ impl IntrinsicObject for PlainDate {
BuiltInBuilder::from_standard_constructor::<Self>(realm)
.property(
JsSymbol::to_string_tag(),
Self::NAME,
StaticJsStrings::PLAIN_DATE_TAG,
Attribute::CONFIGURABLE,
)
.accessor(
@ -213,19 +213,19 @@ impl IntrinsicObject for PlainDate {
None,
Attribute::CONFIGURABLE,
)
.static_method(Self::from, js_string!("from"), 2)
.static_method(Self::from, js_string!("from"), 1)
.static_method(Self::compare, js_string!("compare"), 2)
.method(Self::to_plain_year_month, js_string!("toPlainYearMonth"), 0)
.method(Self::to_plain_month_day, js_string!("toPlainMonthDay"), 0)
.method(Self::get_iso_fields, js_string!("getISOFields"), 0)
.method(Self::add, js_string!("add"), 2)
.method(Self::subtract, js_string!("subtract"), 2)
.method(Self::with, js_string!("with"), 2)
.method(Self::add, js_string!("add"), 1)
.method(Self::subtract, js_string!("subtract"), 1)
.method(Self::with, js_string!("with"), 1)
.method(Self::with_calendar, js_string!("withCalendar"), 1)
.method(Self::until, js_string!("until"), 2)
.method(Self::since, js_string!("since"), 2)
.method(Self::until, js_string!("until"), 1)
.method(Self::since, js_string!("since"), 1)
.method(Self::equals, js_string!("equals"), 1)
.method(Self::to_plain_datetime, js_string!("toPlainDateTime"), 1)
.method(Self::to_plain_datetime, js_string!("toPlainDateTime"), 0)
.build();
}
@ -235,7 +235,7 @@ impl IntrinsicObject for PlainDate {
}
impl BuiltInConstructor for PlainDate {
const LENGTH: usize = 0;
const LENGTH: usize = 3;
const STANDARD_CONSTRUCTOR: fn(&StandardConstructors) -> &StandardConstructor =
StandardConstructors::plain_date;

16
core/engine/src/builtins/temporal/plain_date_time/mod.rs

@ -68,7 +68,7 @@ impl GetTemporalCalendar for JsObject<PlainDateTime> {
}
impl BuiltInObject for PlainDateTime {
const NAME: JsString = StaticJsStrings::PLAIN_DATETIME;
const NAME: JsString = StaticJsStrings::PLAIN_DATETIME_NAME;
}
impl IntrinsicObject for PlainDateTime {
@ -158,7 +158,7 @@ impl IntrinsicObject for PlainDateTime {
BuiltInBuilder::from_standard_constructor::<Self>(realm)
.property(
JsSymbol::to_string_tag(),
Self::NAME,
StaticJsStrings::PLAIN_DATETIME_TAG,
Attribute::CONFIGURABLE,
)
.accessor(
@ -276,14 +276,14 @@ impl IntrinsicObject for PlainDateTime {
None,
Attribute::CONFIGURABLE,
)
.static_method(Self::from, js_string!("from"), 2)
.static_method(Self::from, js_string!("from"), 1)
.static_method(Self::compare, js_string!("compare"), 2)
.method(Self::with_plain_time, js_string!("withPlainTime"), 1)
.method(Self::with_calendar, js_string!("withCalendar"), 1)
.method(Self::add, js_string!("add"), 2)
.method(Self::subtract, js_string!("subtract"), 2)
.method(Self::until, js_string!("until"), 2)
.method(Self::since, js_string!("since"), 2)
.method(Self::add, js_string!("add"), 1)
.method(Self::subtract, js_string!("subtract"), 1)
.method(Self::until, js_string!("until"), 1)
.method(Self::since, js_string!("since"), 1)
.method(Self::round, js_string!("round"), 1)
.method(Self::equals, js_string!("equals"), 1)
.build();
@ -295,7 +295,7 @@ impl IntrinsicObject for PlainDateTime {
}
impl BuiltInConstructor for PlainDateTime {
const LENGTH: usize = 0;
const LENGTH: usize = 3;
const STANDARD_CONSTRUCTOR: fn(&StandardConstructors) -> &StandardConstructor =
StandardConstructors::plain_date_time;

6
core/engine/src/builtins/temporal/plain_month_day/mod.rs

@ -46,7 +46,7 @@ impl GetTemporalCalendar for JsObject<PlainMonthDay> {
}
impl BuiltInObject for PlainMonthDay {
const NAME: JsString = StaticJsStrings::PLAIN_MD;
const NAME: JsString = StaticJsStrings::PLAIN_MD_NAME;
}
impl IntrinsicObject for PlainMonthDay {
@ -56,7 +56,7 @@ impl IntrinsicObject for PlainMonthDay {
BuiltInBuilder::from_standard_constructor::<Self>(realm)
.property(
JsSymbol::to_string_tag(),
Self::NAME,
StaticJsStrings::PLAIN_MD_TAG,
Attribute::CONFIGURABLE,
)
.build();
@ -68,7 +68,7 @@ impl IntrinsicObject for PlainMonthDay {
}
impl BuiltInConstructor for PlainMonthDay {
const LENGTH: usize = 0;
const LENGTH: usize = 2;
const STANDARD_CONSTRUCTOR: fn(&StandardConstructors) -> &StandardConstructor =
StandardConstructors::plain_month_day;

10
core/engine/src/builtins/temporal/plain_time/mod.rs

@ -36,7 +36,7 @@ pub struct PlainTime {
}
impl BuiltInObject for PlainTime {
const NAME: JsString = StaticJsStrings::PLAIN_TIME;
const NAME: JsString = StaticJsStrings::PLAIN_TIME_NAME;
}
impl IntrinsicObject for PlainTime {
@ -69,7 +69,7 @@ impl IntrinsicObject for PlainTime {
BuiltInBuilder::from_standard_constructor::<Self>(realm)
.property(
JsSymbol::to_string_tag(),
Self::NAME,
StaticJsStrings::PLAIN_TIME_TAG,
Attribute::CONFIGURABLE,
)
.accessor(
@ -108,12 +108,12 @@ impl IntrinsicObject for PlainTime {
None,
Attribute::CONFIGURABLE,
)
.static_method(Self::from, js_string!("from"), 2)
.static_method(Self::from, js_string!("from"), 1)
.static_method(Self::compare, js_string!("compare"), 2)
.method(Self::add, js_string!("add"), 1)
.method(Self::subtract, js_string!("subtract"), 1)
.method(Self::until, js_string!("until"), 2)
.method(Self::since, js_string!("since"), 2)
.method(Self::until, js_string!("until"), 1)
.method(Self::since, js_string!("since"), 1)
.method(Self::round, js_string!("round"), 1)
.method(Self::equals, js_string!("equals"), 1)
.method(Self::get_iso_fields, js_string!("getISOFields"), 0)

6
core/engine/src/builtins/temporal/plain_year_month/mod.rs

@ -52,7 +52,7 @@ impl GetTemporalCalendar for JsObject<PlainYearMonth> {
}
impl BuiltInObject for PlainYearMonth {
const NAME: JsString = StaticJsStrings::PLAIN_YM;
const NAME: JsString = StaticJsStrings::PLAIN_YM_NAME;
}
impl IntrinsicObject for PlainYearMonth {
@ -94,7 +94,7 @@ impl IntrinsicObject for PlainYearMonth {
BuiltInBuilder::from_standard_constructor::<Self>(realm)
.property(
JsSymbol::to_string_tag(),
Self::NAME,
StaticJsStrings::PLAIN_YM_TAG,
Attribute::CONFIGURABLE,
)
.accessor(
@ -160,7 +160,7 @@ impl IntrinsicObject for PlainYearMonth {
}
impl BuiltInConstructor for PlainYearMonth {
const LENGTH: usize = 0;
const LENGTH: usize = 2;
const STANDARD_CONSTRUCTOR: fn(&StandardConstructors) -> &StandardConstructor =
StandardConstructors::plain_year_month;

6
core/engine/src/builtins/temporal/zoned_date_time/mod.rs

@ -19,7 +19,7 @@ pub struct ZonedDateTime {
}
impl BuiltInObject for ZonedDateTime {
const NAME: JsString = StaticJsStrings::ZONED_DT;
const NAME: JsString = StaticJsStrings::ZONED_DT_NAME;
}
impl IntrinsicObject for ZonedDateTime {
@ -29,7 +29,7 @@ impl IntrinsicObject for ZonedDateTime {
BuiltInBuilder::from_standard_constructor::<Self>(realm)
.property(
JsSymbol::to_string_tag(),
Self::NAME,
StaticJsStrings::ZONED_DT_TAG,
Attribute::CONFIGURABLE,
)
.build();
@ -41,7 +41,7 @@ impl IntrinsicObject for ZonedDateTime {
}
impl BuiltInConstructor for ZonedDateTime {
const LENGTH: usize = 0;
const LENGTH: usize = 2;
const STANDARD_CONSTRUCTOR: fn(&StandardConstructors) -> &StandardConstructor =
StandardConstructors::zoned_date_time;

29
core/string/src/common.rs

@ -185,17 +185,24 @@ impl StaticJsStrings {
(WEAK_MAP, "WeakMap"),
(WEAK_SET, "WeakSet"),
(TEMPORAL, "Temporal"),
(NOW, "Temporal.Now"),
(INSTANT, "Temporal.Instant"),
(DURATION, "Temporal.Duration"),
(PLAIN_DATE, "Temporal.PlainDate"),
(PLAIN_DATETIME, "Temporal.PlainDateTime"),
(PLAIN_TIME, "Temporal.PlainTime"),
(PLAIN_YM, "Temporal.PlainYearMonth"),
(PLAIN_MD, "Temporal.PlainMonthDay"),
(CALENDAR, "Temporal.Calendar"),
(TIMEZONE, "Temporal.TimeZone"),
(ZONED_DT, "Temporal.ZonedDateTime"),
(NOW_TAG, "Temporal.Now"),
(INSTANT_TAG, "Temporal.Instant"),
(DURATION_TAG, "Temporal.Duration"),
(PLAIN_DATE_TAG, "Temporal.PlainDate"),
(PLAIN_DATETIME_TAG, "Temporal.PlainDateTime"),
(PLAIN_TIME_TAG, "Temporal.PlainTime"),
(PLAIN_YM_TAG, "Temporal.PlainYearMonth"),
(PLAIN_MD_TAG, "Temporal.PlainMonthDay"),
(ZONED_DT_TAG, "Temporal.ZonedDateTime"),
(NOW_NAME, "Now"),
(INSTANT_NAME, "Instant"),
(DURATION_NAME, "Duration"),
(PLAIN_DATE_NAME, "PlainDate"),
(PLAIN_DATETIME_NAME, "PlainDateTime"),
(PLAIN_TIME_NAME, "PlainTime"),
(PLAIN_YM_NAME, "PlainYearMonth"),
(PLAIN_MD_NAME, "PlainMonthDay"),
(ZONED_DT_NAME, "ZonedDateTime"),
}
}

Loading…
Cancel
Save