]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - runtime/JSAPIValueWrapper.h
JavaScriptCore-1097.3.3.tar.gz
[apple/javascriptcore.git] / runtime / JSAPIValueWrapper.h
index 38cbb569e3691eadd8fe1a3289f5285e8d1b0cce..21d7b215cb493a840854c2d0ef1e3346d3575e28 100644 (file)
@@ -24,6 +24,7 @@
 #define JSAPIValueWrapper_h
 
 #include "JSCell.h"
+#include "JSValue.h"
 #include "CallFrame.h"
 #include "Structure.h"
 
@@ -32,31 +33,44 @@ namespace JSC {
     class JSAPIValueWrapper : public JSCell {
         friend JSValue jsAPIValueWrapper(ExecState*, JSValue);
     public:
-        JSValue value() const { return m_value.get(); }
+        typedef JSCell Base;
 
-        virtual bool isAPIValueWrapper() const { return true; }
+        JSValue value() const { return m_value.get(); }
 
-        static Structure* createStructure(JSGlobalData& globalData, JSValue prototype)
+        static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue prototype)
         {
-            return Structure::create(globalData, prototype, TypeInfo(CompoundType, OverridesVisitChildren | OverridesGetPropertyNames), AnonymousSlotCount, &s_info);
+            return Structure::create(globalData, globalObject, prototype, TypeInfo(APIValueWrapperType, OverridesVisitChildren | OverridesGetPropertyNames), &s_info);
         }
         
-        static const ClassInfo s_info;
+        static JS_EXPORTDATA const ClassInfo s_info;
+        
+        static JSAPIValueWrapper* create(ExecState* exec, JSValue value) 
+        {
+            JSAPIValueWrapper* wrapper = new (NotNull, allocateCell<JSAPIValueWrapper>(*exec->heap())) JSAPIValueWrapper(exec);
+            wrapper->finishCreation(exec, value);
+            return wrapper;
+        }
 
-    private:
-        JSAPIValueWrapper(ExecState* exec, JSValue value)
-            : JSCell(exec->globalData(), exec->globalData().apiWrapperStructure.get())
+    protected:
+        void finishCreation(ExecState* exec, JSValue value)
         {
+            Base::finishCreation(exec->globalData());
             m_value.set(exec->globalData(), this, value);
             ASSERT(!value.isCell());
         }
 
+    private:
+        JSAPIValueWrapper(ExecState* exec)
+            : JSCell(exec->globalData(), exec->globalData().apiWrapperStructure.get())
+        {
+        }
+
         WriteBarrier<Unknown> m_value;
     };
 
     inline JSValue jsAPIValueWrapper(ExecState* exec, JSValue value)
     {
-        return new (exec) JSAPIValueWrapper(exec, value);
+        return JSAPIValueWrapper::create(exec, value);
     }
 
 } // namespace JSC