X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/9dae56ea45a0f5f8136a5c93d6f3a7f99399ca73..f9bf01c6616d5ddcf65b13b33cedf9e387ff7a63:/runtime/JSByteArray.h diff --git a/runtime/JSByteArray.h b/runtime/JSByteArray.h index 19c8f0e..5b7adcf 100644 --- a/runtime/JSByteArray.h +++ b/runtime/JSByteArray.h @@ -33,10 +33,10 @@ namespace JSC { class JSByteArray : public JSObject { - friend class Interpreter; + friend class JSGlobalData; public: bool canAccessIndex(unsigned i) { return i < m_storage->length(); } - JSValuePtr getIndex(ExecState* exec, unsigned i) + JSValue getIndex(ExecState* exec, unsigned i) { ASSERT(canAccessIndex(i)); return jsNumber(exec, m_storage->data()[i]); @@ -64,7 +64,7 @@ namespace JSC { m_storage->data()[i] = static_cast(value + 0.5); } - void setIndex(ExecState* exec, unsigned i, JSValuePtr value) + void setIndex(ExecState* exec, unsigned i, JSValue value) { double byteValue = value.toNumber(exec); if (exec->hadException()) @@ -73,21 +73,31 @@ namespace JSC { setIndex(i, byteValue); } - JSByteArray(ExecState* exec, PassRefPtr, WTF::ByteArray* storage, const JSC::ClassInfo* = &s_defaultInfo); - static PassRefPtr createStructure(JSValuePtr prototype); + JSByteArray(ExecState* exec, NonNullPassRefPtr, WTF::ByteArray* storage, const JSC::ClassInfo* = &s_defaultInfo); + static PassRefPtr createStructure(JSValue prototype); virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); virtual bool getOwnPropertySlot(JSC::ExecState*, unsigned propertyName, JSC::PropertySlot&); - virtual void put(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValuePtr, JSC::PutPropertySlot&); - virtual void put(JSC::ExecState*, unsigned propertyName, JSC::JSValuePtr); + virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&); + virtual void put(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValue, JSC::PutPropertySlot&); + virtual void put(JSC::ExecState*, unsigned propertyName, JSC::JSValue); - virtual void getPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&); + virtual void getOwnPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties); virtual const ClassInfo* classInfo() const { return m_classInfo; } static const ClassInfo s_defaultInfo; size_t length() const { return m_storage->length(); } + WTF::ByteArray* storage() const { return m_storage.get(); } + +#if !ASSERT_DISABLED + virtual ~JSByteArray(); +#endif + + protected: + static const unsigned StructureFlags = OverridesGetOwnPropertySlot | OverridesGetPropertyNames | JSObject::StructureFlags; + private: enum VPtrStealingHackType { VPtrStealingHack }; JSByteArray(VPtrStealingHackType) @@ -100,11 +110,14 @@ namespace JSC { const ClassInfo* m_classInfo; }; - JSByteArray* asByteArray(JSValuePtr value); - inline JSByteArray* asByteArray(JSValuePtr value) + JSByteArray* asByteArray(JSValue value); + inline JSByteArray* asByteArray(JSValue value) { return static_cast(asCell(value)); } -} -#endif + inline bool isJSByteArray(JSGlobalData* globalData, JSValue v) { return v.isCell() && v.asCell()->vptr() == globalData->jsByteArrayVPtr; } + +} // namespace JSC + +#endif // JSByteArray_h