X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/ba379fdc102753d6be2c4d937058fe40257329fe..217a6308cd6a1dc049a0bb69263bd4c91f91c4d0:/runtime/JSAPIValueWrapper.h diff --git a/runtime/JSAPIValueWrapper.h b/runtime/JSAPIValueWrapper.h index e16fbba..f091095 100644 --- a/runtime/JSAPIValueWrapper.h +++ b/runtime/JSAPIValueWrapper.h @@ -23,39 +23,54 @@ #ifndef JSAPIValueWrapper_h #define JSAPIValueWrapper_h -#include - +#include "JSCJSValue.h" #include "JSCell.h" +#include "CallFrame.h" +#include "Structure.h" namespace JSC { class JSAPIValueWrapper : public JSCell { friend JSValue jsAPIValueWrapper(ExecState*, JSValue); public: - JSValue value() const { return m_value; } + typedef JSCell Base; + + JSValue value() const { return m_value.get(); } - virtual bool isAPIValueWrapper() const { return true; } + static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype) + { + return Structure::create(vm, globalObject, prototype, TypeInfo(APIValueWrapperType, OverridesVisitChildren | OverridesGetPropertyNames), &s_info); + } + + static JS_EXPORTDATA const ClassInfo s_info; + + static JSAPIValueWrapper* create(ExecState* exec, JSValue value) + { + JSAPIValueWrapper* wrapper = new (NotNull, allocateCell(*exec->heap())) JSAPIValueWrapper(exec); + wrapper->finishCreation(exec, value); + return wrapper; + } - virtual JSValue toPrimitive(ExecState*, PreferredPrimitiveType) const; - virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue&); - virtual bool toBoolean(ExecState*) const; - virtual double toNumber(ExecState*) const; - virtual UString toString(ExecState*) const; - virtual JSObject* toObject(ExecState*) const; + protected: + void finishCreation(ExecState* exec, JSValue value) + { + Base::finishCreation(exec->vm()); + m_value.set(exec->vm(), this, value); + ASSERT(!value.isCell()); + } private: - JSAPIValueWrapper(JSValue value) - : JSCell(0) - , m_value(value) + JSAPIValueWrapper(ExecState* exec) + : JSCell(exec->vm(), exec->vm().apiWrapperStructure.get()) { } - JSValue m_value; + WriteBarrier m_value; }; inline JSValue jsAPIValueWrapper(ExecState* exec, JSValue value) { - return new (exec) JSAPIValueWrapper(value); + return JSAPIValueWrapper::create(exec, value); } } // namespace JSC