]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - runtime/DateInstance.h
JavaScriptCore-1218.34.tar.gz
[apple/javascriptcore.git] / runtime / DateInstance.h
index 77d46de5df7d5e155e7e513359e38e02f149a0df..8707772407528f8dc193c9388d74ab324a121a1f 100644 (file)
 
 #include "JSWrapperObject.h"
 
-namespace WTF {
-    struct GregorianDateTime;
-}
-
 namespace JSC {
 
     class DateInstance : public JSWrapperObject {
+    protected:
+        JS_EXPORT_PRIVATE DateInstance(ExecState*, Structure*);
+        void finishCreation(VM&);
+        JS_EXPORT_PRIVATE void finishCreation(VM&, double);
+
+        static void destroy(JSCell*);
     public:
-        DateInstance(ExecState*, double);
-        DateInstance(ExecState*, NonNullPassRefPtr<Structure>, double);
-        explicit DateInstance(ExecState*, NonNullPassRefPtr<Structure>);
+        typedef JSWrapperObject Base;
 
-        double internalNumber() const { return internalValue().uncheckedGetNumber(); }
+        static DateInstance* create(ExecState* exec, Structure* structure, double date)
+        {
+            DateInstance* instance = new (NotNull, allocateCell<DateInstance>(*exec->heap())) DateInstance(exec, structure);
+            instance->finishCreation(exec->vm(), date);
+            return instance;
+        }
 
-        static JS_EXPORTDATA const ClassInfo info;
+        static DateInstance* create(ExecState* exec, Structure* structure)
+        {
+            DateInstance* instance = new (NotNull, allocateCell<DateInstance>(*exec->heap())) DateInstance(exec, structure);
+            instance->finishCreation(exec->vm());
+            return instance;
+        }
+
+        double internalNumber() const { return internalValue().asNumber(); }
+
+        static JS_EXPORTDATA const ClassInfo s_info;
 
         const GregorianDateTime* gregorianDateTime(ExecState* exec) const
         {
@@ -53,18 +68,14 @@ namespace JSC {
             return calculateGregorianDateTimeUTC(exec);
         }
 
-        static PassRefPtr<Structure> createStructure(JSValue prototype)
+        static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
         {
-            return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
+            return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), &s_info);
         }
 
-    protected:
-        static const unsigned StructureFlags = OverridesMarkChildren | JSWrapperObject::StructureFlags;
-
     private:
         const GregorianDateTime* calculateGregorianDateTime(ExecState*) const;
         const GregorianDateTime* calculateGregorianDateTimeUTC(ExecState*) const;
-        virtual const ClassInfo* classInfo() const { return &info; }
 
         mutable RefPtr<DateInstanceData> m_data;
     };
@@ -73,7 +84,7 @@ namespace JSC {
 
     inline DateInstance* asDateInstance(JSValue value)
     {
-        ASSERT(asObject(value)->inherits(&DateInstance::info));
+        ASSERT(asObject(value)->inherits(&DateInstance::s_info));
         return static_cast<DateInstance*>(asObject(value));
     }