#ifndef JSAPIValueWrapper_h
#define JSAPIValueWrapper_h
-#include <wtf/Platform.h>
-
+#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;
- virtual bool isAPIValueWrapper() const { return true; }
+ JSValue value() const { return m_value.get(); }
- static PassRefPtr<Structure> createStructure(JSValue prototype)
+ static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
{
- return Structure::create(prototype, TypeInfo(CompoundType, OverridesMarkChildren | OverridesGetPropertyNames), AnonymousSlotCount);
+ return Structure::create(vm, globalObject, prototype, TypeInfo(APIValueWrapperType, OverridesVisitChildren | OverridesGetPropertyNames), &s_info);
}
-
- private:
- JSAPIValueWrapper(ExecState* exec, JSValue value)
- : JSCell(exec->globalData().apiWrapperStructure.get())
- , m_value(value)
+ 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;
+ }
+
+ protected:
+ void finishCreation(ExecState* exec, JSValue value)
+ {
+ Base::finishCreation(exec->vm());
+ m_value.set(exec->vm(), this, value);
ASSERT(!value.isCell());
}
- JSValue m_value;
+ private:
+ JSAPIValueWrapper(ExecState* exec)
+ : JSCell(exec->vm(), exec->vm().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