#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;
+
+ 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<JSAPIValueWrapper>(*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<Unknown> m_value;
};
inline JSValue jsAPIValueWrapper(ExecState* exec, JSValue value)
{
- return new (exec) JSAPIValueWrapper(value);
+ return JSAPIValueWrapper::create(exec, value);
}
} // namespace JSC