X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/14957cd040308e3eeec43d26bae5d76da13fcd85..81345200c95645a1b0d2635520f96ad55dfde63f:/runtime/JSAPIValueWrapper.h diff --git a/runtime/JSAPIValueWrapper.h b/runtime/JSAPIValueWrapper.h index 38cbb56..e1f2cd8 100644 --- a/runtime/JSAPIValueWrapper.h +++ b/runtime/JSAPIValueWrapper.h @@ -23,6 +23,7 @@ #ifndef JSAPIValueWrapper_h #define JSAPIValueWrapper_h +#include "JSCJSValue.h" #include "JSCell.h" #include "CallFrame.h" #include "Structure.h" @@ -32,31 +33,45 @@ 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(VM& vm, JSGlobalObject* globalObject, JSValue prototype) { - return Structure::create(globalData, prototype, TypeInfo(CompoundType, OverridesVisitChildren | OverridesGetPropertyNames), AnonymousSlotCount, &s_info); + return Structure::create(vm, globalObject, prototype, TypeInfo(APIValueWrapperType, OverridesVisitChildren | OverridesGetPropertyNames), info()); } - static const ClassInfo s_info; + DECLARE_EXPORT_INFO; + + static JSAPIValueWrapper* create(ExecState* exec, JSValue value) + { + VM& vm = exec->vm(); + JSAPIValueWrapper* wrapper = new (NotNull, allocateCell(vm.heap)) JSAPIValueWrapper(exec); + wrapper->finishCreation(vm, value); + return wrapper; + } - private: - JSAPIValueWrapper(ExecState* exec, JSValue value) - : JSCell(exec->globalData(), exec->globalData().apiWrapperStructure.get()) + protected: + void finishCreation(VM& vm, JSValue value) { - m_value.set(exec->globalData(), this, value); + Base::finishCreation(vm); + m_value.set(vm, this, value); ASSERT(!value.isCell()); } + private: + JSAPIValueWrapper(ExecState* exec) + : JSCell(exec->vm(), exec->vm().apiWrapperStructure.get()) + { + } + WriteBarrier m_value; }; inline JSValue jsAPIValueWrapper(ExecState* exec, JSValue value) { - return new (exec) JSAPIValueWrapper(exec, value); + return JSAPIValueWrapper::create(exec, value); } } // namespace JSC