/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- * vim: set ts=8 sts=2 et sw=2 tw=80: * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef builtin_temporal_Calendar_h #define builtin_temporal_Calendar_h #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" #include "mozilla/EnumSet.h" #include #include #include "builtin/temporal/Wrapped.h" #include "js/RootingAPI.h" #include "js/TypeDecls.h" #include "js/Value.h" #include "vm/NativeObject.h" #include "vm/StringType.h" class JS_PUBLIC_API JSTracer; namespace js { struct ClassSpec; class PlainObject; } // namespace js namespace js::temporal { class CalendarObject : public NativeObject { public: static const JSClass class_; static const JSClass& protoClass_; static constexpr uint32_t IDENTIFIER_SLOT = 0; static constexpr uint32_t SLOT_COUNT = 1; JSLinearString* identifier() const { return &getFixedSlot(IDENTIFIER_SLOT).toString()->asLinear(); } private: static const ClassSpec classSpec_; }; /** * Calendar value, which is either a string containing a canonical calendar * identifier or an object. */ class MOZ_STACK_CLASS CalendarValue final { JS::Value value_{}; public: /** * Default initialize this CalendarValue. */ CalendarValue() = default; /** * Default initialize this CalendarValue. */ explicit CalendarValue(const JS::Value& value) : value_(value) { MOZ_ASSERT(value.isString() || value.isObject()); MOZ_ASSERT_IF(value.isString(), value.toString()->isLinear()); } /** * Initialize this CalendarValue with a canonical calendar identifier. */ explicit CalendarValue(JSLinearString* calendarId) : value_(JS::StringValue(calendarId)) {} /** * Initialize this CalendarValue with a calendar object. */ explicit CalendarValue(JSObject* calendar) : value_(JS::ObjectValue(*calendar)) {} /** * Return true iff this CalendarValue is initialized with either a canonical * calendar identifier or a calendar object. */ explicit operator bool() const { return !value_.isUndefined(); } /** * Return this CalendarValue as a JS::Value. */ JS::Value toValue() const { return value_; } /** * Return true if this CalendarValue is a string. */ bool isString() const { return value_.isString(); } /** * Return true if this CalendarValue is an object. */ bool isObject() const { return value_.isObject(); } /** * Return the calendar identifier. */ JSLinearString* toString() const { return &value_.toString()->asLinear(); } /** * Return the calendar object. */ JSObject* toObject() const { return &value_.toObject(); } void trace(JSTracer* trc); JS::Value* valueDoNotUse() { return &value_; } JS::Value const* valueDoNotUse() const { return &value_; } }; enum class CalendarMethod { DateAdd, DateFromFields, DateUntil, Day, Fields, MergeFields, MonthDayFromFields, YearMonthFromFields, }; class MOZ_STACK_CLASS CalendarRecord final { CalendarValue receiver_; // Null unless non-builtin calendar methods are used. JSObject* dateAdd_ = nullptr; JSObject* dateFromFields_ = nullptr; JSObject* dateUntil_ = nullptr; JSObject* day_ = nullptr; JSObject* fields_ = nullptr; JSObject* mergeFields_ = nullptr; JSObject* monthDayFromFields_ = nullptr; JSObject* yearMonthFromFields_ = nullptr; #ifdef DEBUG mozilla::EnumSet lookedUp_{}; #endif public: /** * Default initialize this CalendarRecord. */ CalendarRecord() = default; explicit CalendarRecord(const CalendarValue& receiver) : receiver_(receiver) {} const auto& receiver() const { return receiver_; } auto* dateAdd() const { return dateAdd_; } auto* dateFromFields() const { return dateFromFields_; } auto* dateUntil() const { return dateUntil_; } auto* day() const { return day_; } auto* fields() const { return fields_; } auto* mergeFields() const { return mergeFields_; } auto* monthDayFromFields() const { return monthDayFromFields_; } auto* yearMonthFromFields() const { return yearMonthFromFields_; } #ifdef DEBUG auto& lookedUp() const { return lookedUp_; } auto& lookedUp() { return lookedUp_; } #endif // Helper methods for (Mutable)WrappedPtrOperations. auto* receiverDoNotUse() const { return &receiver_; } auto* dateAddDoNotUse() const { return &dateAdd_; } auto* dateAddDoNotUse() { return &dateAdd_; } auto* dateFromFieldsDoNotUse() const { return &dateFromFields_; } auto* dateFromFieldsDoNotUse() { return &dateFromFields_; } auto* dateUntilDoNotUse() const { return &dateUntil_; } auto* dateUntilDoNotUse() { return &dateUntil_; } auto* dayDoNotUse() const { return &day_; } auto* dayDoNotUse() { return &day_; } auto* fieldsDoNotUse() const { return &fields_; } auto* fieldsDoNotUse() { return &fields_; } auto* mergeFieldsDoNotUse() const { return &mergeFields_; } auto* mergeFieldsDoNotUse() { return &mergeFields_; } auto* monthDayFromFieldsDoNotUse() const { return &monthDayFromFields_; } auto* monthDayFromFieldsDoNotUse() { return &monthDayFromFields_; } auto* yearMonthFromFieldsDoNotUse() const { return &yearMonthFromFields_; } auto* yearMonthFromFieldsDoNotUse() { return &yearMonthFromFields_; } // Trace implementation. void trace(JSTracer* trc); }; struct DateDuration; struct Duration; struct PlainDate; struct PlainDateTime; class DurationObject; class PlainDateObject; class PlainDateTimeObject; class PlainMonthDayObject; class PlainYearMonthObject; enum class CalendarOption; enum class TemporalOverflow; enum class TemporalUnit; /** * ISODaysInYear ( year ) */ int32_t ISODaysInYear(int32_t year); /** * ISODaysInMonth ( year, month ) */ int32_t ISODaysInMonth(int32_t year, int32_t month); /** * ISODaysInMonth ( year, month ) */ int32_t ISODaysInMonth(double year, int32_t month); /** * ToISODayOfYear ( year, month, day ) */ int32_t ToISODayOfYear(const PlainDate& date); /** * 21.4.1.12 MakeDay ( year, month, date ) */ int32_t MakeDay(const PlainDate& date); /** * 21.4.1.13 MakeDate ( day, time ) */ int64_t MakeDate(const PlainDateTime& dateTime); /** * 21.4.1.13 MakeDate ( day, time ) */ int64_t MakeDate(int32_t year, int32_t month, int32_t day); /** * Return the case-normalized calendar identifier if |id| is a built-in calendar * identifier. Otherwise throws a RangeError. */ bool ToBuiltinCalendar(JSContext* cx, JS::Handle id, JS::MutableHandle result); /** * ToTemporalCalendarSlotValue ( temporalCalendarLike [ , default ] ) */ bool ToTemporalCalendar(JSContext* cx, JS::Handle temporalCalendarLike, JS::MutableHandle result); /** * ToTemporalCalendarSlotValue ( temporalCalendarLike [ , default ] ) */ bool ToTemporalCalendarWithISODefault( JSContext* cx, JS::Handle temporalCalendarLike, JS::MutableHandle result); /** * GetTemporalCalendarWithISODefault ( item ) */ bool GetTemporalCalendarWithISODefault(JSContext* cx, JS::Handle item, JS::MutableHandle result); /** * ToTemporalCalendarIdentifier ( calendarSlotValue ) */ JSString* ToTemporalCalendarIdentifier(JSContext* cx, JS::Handle calendar); /** * ToTemporalCalendarObject ( calendarSlotValue ) */ JSObject* ToTemporalCalendarObject(JSContext* cx, JS::Handle calendar); enum class CalendarField { Year, Month, MonthCode, Day, }; using CalendarFieldNames = JS::StackGCVector; /** * CalendarFields ( calendarRec, fieldNames ) */ bool CalendarFields(JSContext* cx, JS::Handle calendar, std::initializer_list fieldNames, JS::MutableHandle result); /** * CalendarMergeFields ( calendarRec, fields, additionalFields ) */ JSObject* CalendarMergeFields(JSContext* cx, JS::Handle calendar, JS::Handle fields, JS::Handle additionalFields); /** * CalendarDateAdd ( calendarRec, date, duration [ , options ] ) */ Wrapped CalendarDateAdd( JSContext* cx, JS::Handle calendar, JS::Handle> date, const DateDuration& duration); /** * CalendarDateAdd ( calendarRec, date, duration [ , options ] ) */ Wrapped CalendarDateAdd( JSContext* cx, JS::Handle calendar, JS::Handle> date, const Duration& duration, JS::Handle options); /** * CalendarDateAdd ( calendarRec, date, duration [ , options ] ) */ Wrapped CalendarDateAdd( JSContext* cx, JS::Handle calendar, JS::Handle> date, JS::Handle> duration); /** * CalendarDateAdd ( calendarRec, date, duration [ , options ] ) */ Wrapped CalendarDateAdd( JSContext* cx, JS::Handle calendar, JS::Handle> date, JS::Handle> duration, JS::Handle options); /** * CalendarDateAdd ( calendarRec, date, duration [ , options ] ) */ bool CalendarDateAdd(JSContext* cx, JS::Handle calendar, const PlainDate& date, const DateDuration& duration, PlainDate* result); /** * CalendarDateAdd ( calendarRec, date, duration [ , options ] ) */ bool CalendarDateAdd(JSContext* cx, JS::Handle calendar, const PlainDate& date, const DateDuration& duration, JS::Handle options, PlainDate* result); /** * CalendarDateAdd ( calendarRec, date, duration [ , options ] ) */ bool CalendarDateAdd(JSContext* cx, JS::Handle calendar, JS::Handle> date, const DateDuration& duration, PlainDate* result); /** * CalendarDateUntil ( calendarRec, one, two, options ) */ bool CalendarDateUntil(JSContext* cx, JS::Handle calendar, const PlainDate& one, const PlainDate& two, TemporalUnit largestUnit, DateDuration* result); /** * CalendarDateUntil ( calendarRec, one, two, options ) */ bool CalendarDateUntil(JSContext* cx, JS::Handle calendar, const PlainDate& one, const PlainDate& two, TemporalUnit largestUnit, JS::Handle options, DateDuration* result); /** * CalendarDateUntil ( calendarRec, one, two, options ) */ bool CalendarDateUntil(JSContext* cx, JS::Handle calendar, JS::Handle> one, JS::Handle> two, TemporalUnit largestUnit, DateDuration* result); /** * CalendarDateUntil ( calendarRec, one, two, options ) */ bool CalendarDateUntil(JSContext* cx, JS::Handle calendar, JS::Handle> one, JS::Handle> two, TemporalUnit largestUnit, JS::Handle options, DateDuration* result); /** * CalendarYear ( calendar, dateLike ) */ bool CalendarYear(JSContext* cx, JS::Handle calendar, JS::Handle dateLike, JS::MutableHandle result); /** * CalendarYear ( calendar, dateLike ) */ bool CalendarYear(JSContext* cx, JS::Handle calendar, JS::Handle dateLike, JS::MutableHandle result); /** * CalendarYear ( calendar, dateLike ) */ bool CalendarYear(JSContext* cx, JS::Handle calendar, JS::Handle dateLike, JS::MutableHandle result); /** * CalendarYear ( calendar, dateLike ) */ bool CalendarYear(JSContext* cx, JS::Handle calendar, const PlainDateTime& dateTime, JS::MutableHandle result); /** * CalendarMonth ( calendar, dateLike ) */ bool CalendarMonth(JSContext* cx, JS::Handle calendar, JS::Handle dateLike, JS::MutableHandle result); /** * CalendarMonth ( calendar, dateLike ) */ bool CalendarMonth(JSContext* cx, JS::Handle calendar, JS::Handle dateLike, JS::MutableHandle result); /** * CalendarMonth ( calendar, dateLike ) */ bool CalendarMonth(JSContext* cx, JS::Handle calendar, JS::Handle dateLike, JS::MutableHandle result); /** * CalendarMonth ( calendar, dateLike ) */ bool CalendarMonth(JSContext* cx, JS::Handle calendar, const PlainDateTime& dateTime, JS::MutableHandle result); /** * CalendarMonthCode ( calendar, dateLike ) */ bool CalendarMonthCode(JSContext* cx, JS::Handle calendar, JS::Handle dateLike, JS::MutableHandle result); /** * CalendarMonthCode ( calendar, dateLike ) */ bool CalendarMonthCode(JSContext* cx, JS::Handle calendar, JS::Handle dateLike, JS::MutableHandle result); /** * CalendarMonthCode ( calendar, dateLike ) */ bool CalendarMonthCode(JSContext* cx, JS::Handle calendar, JS::Handle dateLike, JS::MutableHandle result); /** * CalendarMonthCode ( calendar, dateLike ) */ bool CalendarMonthCode(JSContext* cx, JS::Handle calendar, JS::Handle dateLike, JS::MutableHandle result); /** * CalendarMonthCode ( calendar, dateLike ) */ bool CalendarMonthCode(JSContext* cx, JS::Handle calendar, const PlainDateTime& dateTime, JS::MutableHandle result); /** * CalendarDay ( calendarRec, dateLike ) */ bool CalendarDay(JSContext* cx, JS::Handle calendar, JS::Handle dateLike, JS::MutableHandle result); /** * CalendarDay ( calendarRec, dateLike ) */ bool CalendarDay(JSContext* cx, JS::Handle calendar, JS::Handle dateLike, JS::MutableHandle result); /** * CalendarDay ( calendarRec, dateLike ) */ bool CalendarDay(JSContext* cx, JS::Handle calendar, JS::Handle dateLike, JS::MutableHandle result); /** * CalendarDay ( calendarRec, dateLike ) */ bool CalendarDay(JSContext* cx, JS::Handle calendar, const PlainDate& date, JS::MutableHandle result); /** * CalendarDay ( calendarRec, dateLike ) */ bool CalendarDay(JSContext* cx, JS::Handle calendar, const PlainDateTime& dateTime, JS::MutableHandle result); /** * CalendarDayOfWeek ( calendar, dateLike ) */ bool CalendarDayOfWeek(JSContext* cx, JS::Handle calendar, JS::Handle dateLike, JS::MutableHandle result); /** * CalendarDayOfWeek ( calendar, dateLike ) */ bool CalendarDayOfWeek(JSContext* cx, JS::Handle calendar, JS::Handle dateLike, JS::MutableHandle result); /** * CalendarDayOfWeek ( calendar, dateLike ) */ bool CalendarDayOfWeek(JSContext* cx, JS::Handle calendar, const PlainDateTime& dateTime, JS::MutableHandle result); /** * CalendarDayOfYear ( calendar, dateLike ) */ bool CalendarDayOfYear(JSContext* cx, JS::Handle calendar, JS::Handle dateLike, JS::MutableHandle result); /** * CalendarDayOfYear ( calendar, dateLike ) */ bool CalendarDayOfYear(JSContext* cx, JS::Handle calendar, JS::Handle dateLike, JS::MutableHandle result); /** * CalendarDayOfYear ( calendar, dateLike ) */ bool CalendarDayOfYear(JSContext* cx, JS::Handle calendar, const PlainDateTime& dateTime, JS::MutableHandle result); /** * CalendarWeekOfYear ( calendar, dateLike ) */ bool CalendarWeekOfYear(JSContext* cx, JS::Handle calendar, JS::Handle dateLike, JS::MutableHandle result); /** * CalendarWeekOfYear ( calendar, dateLike ) */ bool CalendarWeekOfYear(JSContext* cx, JS::Handle calendar, JS::Handle dateLike, JS::MutableHandle result); /** * CalendarWeekOfYear ( calendar, dateLike ) */ bool CalendarWeekOfYear(JSContext* cx, JS::Handle calendar, const PlainDateTime& dateTime, JS::MutableHandle result); /** * CalendarYearOfWeek ( calendar, dateLike ) */ bool CalendarYearOfWeek(JSContext* cx, JS::Handle calendar, JS::Handle dateLike, JS::MutableHandle result); /** * CalendarYearOfWeek ( calendar, dateLike ) */ bool CalendarYearOfWeek(JSContext* cx, JS::Handle calendar, JS::Handle dateLike, JS::MutableHandle result); /** * CalendarYearOfWeek ( calendar, dateLike ) */ bool CalendarYearOfWeek(JSContext* cx, JS::Handle calendar, const PlainDateTime& dateTime, JS::MutableHandle result); /** * CalendarDaysInWeek ( calendar, dateLike ) */ bool CalendarDaysInWeek(JSContext* cx, JS::Handle calendar, JS::Handle dateLike, JS::MutableHandle result); /** * CalendarDaysInWeek ( calendar, dateLike ) */ bool CalendarDaysInWeek(JSContext* cx, JS::Handle calendar, JS::Handle dateLike, JS::MutableHandle result); /** * CalendarDaysInWeek ( calendar, dateLike ) */ bool CalendarDaysInWeek(JSContext* cx, JS::Handle calendar, const PlainDateTime& dateTime, JS::MutableHandle result); /** * CalendarDaysInMonth ( calendar, dateLike ) */ bool CalendarDaysInMonth(JSContext* cx, JS::Handle calendar, JS::Handle dateLike, JS::MutableHandle result); /** * CalendarDaysInMonth ( calendar, dateLike ) */ bool CalendarDaysInMonth(JSContext* cx, JS::Handle calendar, JS::Handle dateLike, JS::MutableHandle result); /** * CalendarDaysInMonth ( calendar, dateLike ) */ bool CalendarDaysInMonth(JSContext* cx, JS::Handle calendar, JS::Handle dateLike, JS::MutableHandle result); /** * CalendarDaysInMonth ( calendar, dateLike ) */ bool CalendarDaysInMonth(JSContext* cx, JS::Handle calendar, const PlainDateTime& dateTime, JS::MutableHandle result); /** * CalendarDaysInYear ( calendar, dateLike ) */ bool CalendarDaysInYear(JSContext* cx, JS::Handle calendar, JS::Handle dateLike, JS::MutableHandle result); /** * CalendarDaysInYear ( calendar, dateLike ) */ bool CalendarDaysInYear(JSContext* cx, JS::Handle calendar, JS::Handle dateLike, JS::MutableHandle result); /** * CalendarDaysInYear ( calendar, dateLike ) */ bool CalendarDaysInYear(JSContext* cx, JS::Handle calendar, JS::Handle dateLike, JS::MutableHandle result); /** * CalendarDaysInYear ( calendar, dateLike ) */ bool CalendarDaysInYear(JSContext* cx, JS::Handle calendar, const PlainDateTime& dateTime, JS::MutableHandle result); /** * CalendarMonthsInYear ( calendar, dateLike ) */ bool CalendarMonthsInYear(JSContext* cx, JS::Handle calendar, JS::Handle dateLike, JS::MutableHandle result); /** * CalendarMonthsInYear ( calendar, dateLike ) */ bool CalendarMonthsInYear(JSContext* cx, JS::Handle calendar, JS::Handle dateLike, JS::MutableHandle result); /** * CalendarMonthsInYear ( calendar, dateLike ) */ bool CalendarMonthsInYear(JSContext* cx, JS::Handle calendar, JS::Handle dateLike, JS::MutableHandle result); /** * CalendarMonthsInYear ( calendar, dateLike ) */ bool CalendarMonthsInYear(JSContext* cx, JS::Handle calendar, const PlainDateTime& dateTime, JS::MutableHandle result); /** * CalendarInLeapYear ( calendar, dateLike ) */ bool CalendarInLeapYear(JSContext* cx, JS::Handle calendar, JS::Handle dateLike, JS::MutableHandle result); /** * CalendarInLeapYear ( calendar, dateLike ) */ bool CalendarInLeapYear(JSContext* cx, JS::Handle calendar, JS::Handle dateLike, JS::MutableHandle result); /** * CalendarInLeapYear ( calendar, dateLike ) */ bool CalendarInLeapYear(JSContext* cx, JS::Handle calendar, JS::Handle dateLike, JS::MutableHandle result); /** * CalendarInLeapYear ( calendar, dateLike ) */ bool CalendarInLeapYear(JSContext* cx, JS::Handle calendar, const PlainDateTime& dateTime, JS::MutableHandle result); /** * CalendarDateFromFields ( calendarRec, fields [ , options ] ) */ Wrapped CalendarDateFromFields( JSContext* cx, JS::Handle calendar, JS::Handle fields); /** * CalendarDateFromFields ( calendarRec, fields [ , options ] ) */ Wrapped CalendarDateFromFields( JSContext* cx, JS::Handle calendar, JS::Handle fields, JS::Handle options); /** * CalendarYearMonthFromFields ( calendarRec, fields [ , options ] ) */ Wrapped CalendarYearMonthFromFields( JSContext* cx, JS::Handle calendar, JS::Handle fields); /** * CalendarYearMonthFromFields ( calendarRec, fields [ , options ] ) */ Wrapped CalendarYearMonthFromFields( JSContext* cx, JS::Handle calendar, JS::Handle fields); /** * CalendarYearMonthFromFields ( calendarRec, fields [ , options ] ) */ Wrapped CalendarYearMonthFromFields( JSContext* cx, JS::Handle calendar, JS::Handle fields, JS::Handle options); /** * CalendarMonthDayFromFields ( calendarRec, fields [ , options ] ) */ Wrapped CalendarMonthDayFromFields( JSContext* cx, JS::Handle calendar, JS::Handle fields); /** * CalendarMonthDayFromFields ( calendarRec, fields [ , options ] ) */ Wrapped CalendarMonthDayFromFields( JSContext* cx, JS::Handle calendar, JS::Handle fields); /** * CalendarMonthDayFromFields ( calendarRec, fields [ , options ] ) */ Wrapped CalendarMonthDayFromFields( JSContext* cx, JS::Handle calendar, JS::Handle fields, JS::Handle options); /** * CalendarEquals ( one, two ) */ bool CalendarEquals(JSContext* cx, JS::Handle one, JS::Handle two, bool* equals); /** * CalendarEquals ( one, two ) */ bool CalendarEqualsOrThrow(JSContext* cx, JS::Handle one, JS::Handle two); /** * ConsolidateCalendars ( one, two ) */ bool ConsolidateCalendars(JSContext* cx, JS::Handle one, JS::Handle two, JS::MutableHandle result); /** * CreateCalendarMethodsRecord ( calendar, methods ) */ bool CreateCalendarMethodsRecord(JSContext* cx, JS::Handle calendar, mozilla::EnumSet methods, JS::MutableHandle result); #ifdef DEBUG /** * CalendarMethodsRecordHasLookedUp ( calendarRec, methodName ) */ inline bool CalendarMethodsRecordHasLookedUp(const CalendarRecord& calendar, CalendarMethod methodName) { // Steps 1-10. return calendar.lookedUp().contains(methodName); } #endif /** * CalendarMethodsRecordIsBuiltin ( calendarRec ) */ inline bool CalendarMethodsRecordIsBuiltin(const CalendarRecord& calendar) { // Steps 1-2. return calendar.receiver().isString(); } /** * Return true when accessing the calendar fields |fieldNames| can be optimized. * Otherwise returns false. */ bool IsBuiltinAccess(JSContext* cx, JS::Handle calendar, std::initializer_list fieldNames); // Helper for MutableWrappedPtrOperations. bool WrapCalendarValue(JSContext* cx, JS::MutableHandle calendar); } /* namespace js::temporal */ namespace js { template class WrappedPtrOperations { const auto& container() const { return static_cast(this)->get(); } public: explicit operator bool() const { return bool(container()); } JS::Handle toValue() const { return JS::Handle::fromMarkedLocation( container().valueDoNotUse()); } bool isString() const { return container().isString(); } bool isObject() const { return container().isObject(); } JSLinearString* toString() const { return container().toString(); } JSObject* toObject() const { return container().toObject(); } }; template class MutableWrappedPtrOperations : public WrappedPtrOperations { auto& container() { return static_cast(this)->get(); } JS::MutableHandle toMutableValue() { return JS::MutableHandle::fromMarkedLocation( container().valueDoNotUse()); } public: bool wrap(JSContext* cx) { return temporal::WrapCalendarValue(cx, toMutableValue()); } }; template class WrappedPtrOperations { const auto& container() const { return static_cast(this)->get(); } public: JS::Handle receiver() const { return JS::Handle::fromMarkedLocation( container().receiverDoNotUse()); } JS::Handle dateAdd() const { return JS::Handle::fromMarkedLocation( container().dateAddDoNotUse()); } JS::Handle dateFromFields() const { return JS::Handle::fromMarkedLocation( container().dateFromFieldsDoNotUse()); } JS::Handle dateUntil() const { return JS::Handle::fromMarkedLocation( container().dateUntilDoNotUse()); } JS::Handle day() const { return JS::Handle::fromMarkedLocation(container().dayDoNotUse()); } JS::Handle fields() const { return JS::Handle::fromMarkedLocation( container().fieldsDoNotUse()); } JS::Handle mergeFields() const { return JS::Handle::fromMarkedLocation( container().mergeFieldsDoNotUse()); } JS::Handle monthDayFromFields() const { return JS::Handle::fromMarkedLocation( container().monthDayFromFieldsDoNotUse()); } JS::Handle yearMonthFromFields() const { return JS::Handle::fromMarkedLocation( container().yearMonthFromFieldsDoNotUse()); } }; template class MutableWrappedPtrOperations : public WrappedPtrOperations { auto& container() { return static_cast(this)->get(); } public: JS::MutableHandle dateAdd() { return JS::MutableHandle::fromMarkedLocation( container().dateAddDoNotUse()); } JS::MutableHandle dateFromFields() { return JS::MutableHandle::fromMarkedLocation( container().dateFromFieldsDoNotUse()); } JS::MutableHandle dateUntil() { return JS::MutableHandle::fromMarkedLocation( container().dateUntilDoNotUse()); } JS::MutableHandle day() { return JS::MutableHandle::fromMarkedLocation( container().dayDoNotUse()); } JS::MutableHandle fields() { return JS::MutableHandle::fromMarkedLocation( container().fieldsDoNotUse()); } JS::MutableHandle mergeFields() { return JS::MutableHandle::fromMarkedLocation( container().mergeFieldsDoNotUse()); } JS::MutableHandle monthDayFromFields() { return JS::MutableHandle::fromMarkedLocation( container().monthDayFromFieldsDoNotUse()); } JS::MutableHandle yearMonthFromFields() { return JS::MutableHandle::fromMarkedLocation( container().yearMonthFromFieldsDoNotUse()); } }; } /* namespace js */ #endif /* builtin_temporal_Calendar_h */