X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/9dae56ea45a0f5f8136a5c93d6f3a7f99399ca73..1df5f87f1309a8daa30dabdee855f48ae40d14ab:/runtime/DateInstance.h diff --git a/runtime/DateInstance.h b/runtime/DateInstance.h index 398f299..6195c85 100644 --- a/runtime/DateInstance.h +++ b/runtime/DateInstance.h @@ -23,40 +23,52 @@ #include "JSWrapperObject.h" -namespace JSC { - +namespace WTF { struct GregorianDateTime; +} + +namespace JSC { class DateInstance : public JSWrapperObject { public: - explicit DateInstance(PassRefPtr); - virtual ~DateInstance(); + DateInstance(ExecState*, Structure*, double); + explicit DateInstance(ExecState*, Structure*); double internalNumber() const { return internalValue().uncheckedGetNumber(); } - bool getTime(GregorianDateTime&, int& offset) const; - bool getUTCTime(GregorianDateTime&) const; - bool getTime(double& milliseconds, int& offset) const; - bool getUTCTime(double& milliseconds) const; - - static const ClassInfo info; - - void msToGregorianDateTime(double, bool outputIsUTC, GregorianDateTime&) const; + static JS_EXPORTDATA const ClassInfo s_info; + + const GregorianDateTime* gregorianDateTime(ExecState* exec) const + { + if (m_data && m_data->m_gregorianDateTimeCachedForMS == internalNumber()) + return &m_data->m_cachedGregorianDateTime; + return calculateGregorianDateTime(exec); + } + + const GregorianDateTime* gregorianDateTimeUTC(ExecState* exec) const + { + if (m_data && m_data->m_gregorianDateTimeUTCCachedForMS == internalNumber()) + return &m_data->m_cachedGregorianDateTimeUTC; + return calculateGregorianDateTimeUTC(exec); + } + + static Structure* createStructure(JSGlobalData& globalData, JSValue prototype) + { + return Structure::create(globalData, prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info); + } private: - virtual const ClassInfo* classInfo() const { return &info; } - - using JSWrapperObject::internalValue; + const GregorianDateTime* calculateGregorianDateTime(ExecState*) const; + const GregorianDateTime* calculateGregorianDateTimeUTC(ExecState*) const; - struct Cache; - mutable Cache* m_cache; + mutable RefPtr m_data; }; - DateInstance* asDateInstance(JSValuePtr); + DateInstance* asDateInstance(JSValue); - inline DateInstance* asDateInstance(JSValuePtr value) + inline DateInstance* asDateInstance(JSValue value) { - ASSERT(asObject(value)->inherits(&DateInstance::info)); + ASSERT(asObject(value)->inherits(&DateInstance::s_info)); return static_cast(asObject(value)); }