Bug 900898 part 1. Give dom::TypedArray structs a no-argument constructor. r=smaug

This commit is contained in:
Boris Zbarsky 2013-08-05 13:40:01 -04:00
parent 00e61e639b
commit 967caa334c

View File

@ -24,7 +24,12 @@ template<typename T,
struct TypedArray_base {
TypedArray_base(JSObject* obj)
{
mObj = UnboxArray(obj, &mLength, &mData);
DoInit(obj);
}
TypedArray_base() :
mObj(nullptr)
{
}
private:
@ -33,6 +38,12 @@ private:
JSObject* mObj;
public:
inline void Init(JSObject* obj)
{
MOZ_ASSERT(!inited());
DoInit(obj);
}
inline bool inited() const {
return !!mObj;
}
@ -51,6 +62,12 @@ public:
MOZ_ASSERT(inited());
return mObj;
}
protected:
inline void DoInit(JSObject* obj)
{
mObj = UnboxArray(obj, &mLength, &mData);
}
};
@ -63,6 +80,10 @@ struct TypedArray : public TypedArray_base<T,UnboxArray> {
TypedArray_base<T,UnboxArray>(obj)
{}
TypedArray() :
TypedArray_base<T,UnboxArray>()
{}
static inline JSObject*
Create(JSContext* cx, nsWrapperCache* creator, uint32_t length,
const T* data = NULL) {