зеркало из https://github.com/mozilla/gecko-dev.git
Backout changesets 6e78bc0145ee, 97a1463cde9c, and 9097d0b3acc6 (Bug 749535) for
erroneous bug number (r=me).
This commit is contained in:
Родитель
dbbcc2bcf0
Коммит
28008c2879
|
@ -2603,8 +2603,8 @@ GetRequestBody(ArrayBuffer* aArrayBuffer, nsIInputStream** aResult,
|
|||
aContentType.SetIsVoid(true);
|
||||
aCharset.Truncate();
|
||||
|
||||
PRInt32 length = aArrayBuffer->Length();
|
||||
char* data = reinterpret_cast<char*>(aArrayBuffer->Data());
|
||||
PRInt32 length = aArrayBuffer->mLength;
|
||||
char* data = reinterpret_cast<char*>(aArrayBuffer->mData);
|
||||
|
||||
nsCOMPtr<nsIInputStream> stream;
|
||||
nsresult rv = NS_NewByteInputStream(getter_AddRefs(stream), data, length,
|
||||
|
|
|
@ -892,7 +892,7 @@ public:
|
|||
WebGLfloat z, WebGLfloat w);
|
||||
|
||||
void Uniform1iv(WebGLUniformLocation* location, dom::Int32Array& arr) {
|
||||
Uniform1iv_base(location, arr.Length(), arr.Data());
|
||||
Uniform1iv_base(location, arr.mLength, arr.mData);
|
||||
}
|
||||
void Uniform1iv(WebGLUniformLocation* location,
|
||||
const dom::Sequence<WebGLint>& arr) {
|
||||
|
@ -902,7 +902,7 @@ public:
|
|||
const WebGLint* data);
|
||||
|
||||
void Uniform2iv(WebGLUniformLocation* location, dom::Int32Array& arr) {
|
||||
Uniform2iv_base(location, arr.Length(), arr.Data());
|
||||
Uniform2iv_base(location, arr.mLength, arr.mData);
|
||||
}
|
||||
void Uniform2iv(WebGLUniformLocation* location,
|
||||
const dom::Sequence<WebGLint>& arr) {
|
||||
|
@ -912,7 +912,7 @@ public:
|
|||
const WebGLint* data);
|
||||
|
||||
void Uniform3iv(WebGLUniformLocation* location, dom::Int32Array& arr) {
|
||||
Uniform3iv_base(location, arr.Length(), arr.Data());
|
||||
Uniform3iv_base(location, arr.mLength, arr.mData);
|
||||
}
|
||||
void Uniform3iv(WebGLUniformLocation* location,
|
||||
const dom::Sequence<WebGLint>& arr) {
|
||||
|
@ -922,7 +922,7 @@ public:
|
|||
const WebGLint* data);
|
||||
|
||||
void Uniform4iv(WebGLUniformLocation* location, dom::Int32Array& arr) {
|
||||
Uniform4iv_base(location, arr.Length(), arr.Data());
|
||||
Uniform4iv_base(location, arr.mLength, arr.mData);
|
||||
}
|
||||
void Uniform4iv(WebGLUniformLocation* location,
|
||||
const dom::Sequence<WebGLint>& arr) {
|
||||
|
@ -932,7 +932,7 @@ public:
|
|||
const WebGLint* data);
|
||||
|
||||
void Uniform1fv(WebGLUniformLocation* location, dom::Float32Array& arr) {
|
||||
Uniform1fv_base(location, arr.Length(), arr.Data());
|
||||
Uniform1fv_base(location, arr.mLength, arr.mData);
|
||||
}
|
||||
void Uniform1fv(WebGLUniformLocation* location,
|
||||
const dom::Sequence<WebGLfloat>& arr) {
|
||||
|
@ -942,7 +942,7 @@ public:
|
|||
const WebGLfloat* data);
|
||||
|
||||
void Uniform2fv(WebGLUniformLocation* location, dom::Float32Array& arr) {
|
||||
Uniform2fv_base(location, arr.Length(), arr.Data());
|
||||
Uniform2fv_base(location, arr.mLength, arr.mData);
|
||||
}
|
||||
void Uniform2fv(WebGLUniformLocation* location,
|
||||
const dom::Sequence<WebGLfloat>& arr) {
|
||||
|
@ -952,7 +952,7 @@ public:
|
|||
const WebGLfloat* data);
|
||||
|
||||
void Uniform3fv(WebGLUniformLocation* location, dom::Float32Array& arr) {
|
||||
Uniform3fv_base(location, arr.Length(), arr.Data());
|
||||
Uniform3fv_base(location, arr.mLength, arr.mData);
|
||||
}
|
||||
void Uniform3fv(WebGLUniformLocation* location,
|
||||
const dom::Sequence<WebGLfloat>& arr) {
|
||||
|
@ -962,7 +962,7 @@ public:
|
|||
const WebGLfloat* data);
|
||||
|
||||
void Uniform4fv(WebGLUniformLocation* location, dom::Float32Array& arr) {
|
||||
Uniform4fv_base(location, arr.Length(), arr.Data());
|
||||
Uniform4fv_base(location, arr.mLength, arr.mData);
|
||||
}
|
||||
void Uniform4fv(WebGLUniformLocation* location,
|
||||
const dom::Sequence<WebGLfloat>& arr) {
|
||||
|
@ -974,7 +974,7 @@ public:
|
|||
void UniformMatrix2fv(WebGLUniformLocation* location,
|
||||
WebGLboolean transpose,
|
||||
dom::Float32Array &value) {
|
||||
UniformMatrix2fv_base(location, transpose, value.Length(), value.Data());
|
||||
UniformMatrix2fv_base(location, transpose, value.mLength, value.mData);
|
||||
}
|
||||
void UniformMatrix2fv(WebGLUniformLocation* location,
|
||||
WebGLboolean transpose,
|
||||
|
@ -989,7 +989,7 @@ public:
|
|||
void UniformMatrix3fv(WebGLUniformLocation* location,
|
||||
WebGLboolean transpose,
|
||||
dom::Float32Array &value) {
|
||||
UniformMatrix3fv_base(location, transpose, value.Length(), value.Data());
|
||||
UniformMatrix3fv_base(location, transpose, value.mLength, value.mData);
|
||||
}
|
||||
void UniformMatrix3fv(WebGLUniformLocation* location,
|
||||
WebGLboolean transpose,
|
||||
|
@ -1004,7 +1004,7 @@ public:
|
|||
void UniformMatrix4fv(WebGLUniformLocation* location,
|
||||
WebGLboolean transpose,
|
||||
dom::Float32Array &value) {
|
||||
UniformMatrix4fv_base(location, transpose, value.Length(), value.Data());
|
||||
UniformMatrix4fv_base(location, transpose, value.mLength, value.mData);
|
||||
}
|
||||
void UniformMatrix4fv(WebGLUniformLocation* location,
|
||||
WebGLboolean transpose,
|
||||
|
@ -1027,7 +1027,7 @@ public:
|
|||
WebGLfloat x2, WebGLfloat x3);
|
||||
|
||||
void VertexAttrib1fv(WebGLuint idx, dom::Float32Array &arr) {
|
||||
VertexAttrib1fv_base(idx, arr.Length(), arr.Data());
|
||||
VertexAttrib1fv_base(idx, arr.mLength, arr.mData);
|
||||
}
|
||||
void VertexAttrib1fv(WebGLuint idx, const dom::Sequence<WebGLfloat>& arr) {
|
||||
VertexAttrib1fv_base(idx, arr.Length(), arr.Elements());
|
||||
|
@ -1036,7 +1036,7 @@ public:
|
|||
const WebGLfloat* ptr);
|
||||
|
||||
void VertexAttrib2fv(WebGLuint idx, dom::Float32Array &arr) {
|
||||
VertexAttrib2fv_base(idx, arr.Length(), arr.Data());
|
||||
VertexAttrib2fv_base(idx, arr.mLength, arr.mData);
|
||||
}
|
||||
void VertexAttrib2fv(WebGLuint idx, const dom::Sequence<WebGLfloat>& arr) {
|
||||
VertexAttrib2fv_base(idx, arr.Length(), arr.Elements());
|
||||
|
@ -1045,7 +1045,7 @@ public:
|
|||
const WebGLfloat* ptr);
|
||||
|
||||
void VertexAttrib3fv(WebGLuint idx, dom::Float32Array &arr) {
|
||||
VertexAttrib3fv_base(idx, arr.Length(), arr.Data());
|
||||
VertexAttrib3fv_base(idx, arr.mLength, arr.mData);
|
||||
}
|
||||
void VertexAttrib3fv(WebGLuint idx, const dom::Sequence<WebGLfloat>& arr) {
|
||||
VertexAttrib3fv_base(idx, arr.Length(), arr.Elements());
|
||||
|
@ -1054,7 +1054,7 @@ public:
|
|||
const WebGLfloat* ptr);
|
||||
|
||||
void VertexAttrib4fv(WebGLuint idx, dom::Float32Array &arr) {
|
||||
VertexAttrib4fv_base(idx, arr.Length(), arr.Data());
|
||||
VertexAttrib4fv_base(idx, arr.mLength, arr.mData);
|
||||
}
|
||||
void VertexAttrib4fv(WebGLuint idx, const dom::Sequence<WebGLfloat>& arr) {
|
||||
VertexAttrib4fv_base(idx, arr.Length(), arr.Elements());
|
||||
|
|
|
@ -546,16 +546,16 @@ WebGLContext::BufferData(WebGLenum target, ArrayBuffer *data, WebGLenum usage)
|
|||
|
||||
MakeContextCurrent();
|
||||
|
||||
GLenum error = CheckedBufferData(target, data->Length(), data->Data(), usage);
|
||||
GLenum error = CheckedBufferData(target, data->mLength, data->mData, usage);
|
||||
|
||||
if (error) {
|
||||
GenerateWarning("bufferData generated error %s", ErrorName(error));
|
||||
return;
|
||||
}
|
||||
|
||||
boundBuffer->SetByteLength(data->Length());
|
||||
boundBuffer->SetByteLength(data->mLength);
|
||||
boundBuffer->InvalidateCachedMaxElements();
|
||||
if (!boundBuffer->CopyDataIfElementArray(data->Data()))
|
||||
if (!boundBuffer->CopyDataIfElementArray(data->mData))
|
||||
return ErrorOutOfMemory("bufferData: out of memory");
|
||||
}
|
||||
|
||||
|
@ -583,15 +583,15 @@ WebGLContext::BufferData(WebGLenum target, ArrayBufferView& data, WebGLenum usag
|
|||
|
||||
MakeContextCurrent();
|
||||
|
||||
GLenum error = CheckedBufferData(target, data.Length(), data.Data(), usage);
|
||||
GLenum error = CheckedBufferData(target, data.mLength, data.mData, usage);
|
||||
if (error) {
|
||||
GenerateWarning("bufferData generated error %s", ErrorName(error));
|
||||
return;
|
||||
}
|
||||
|
||||
boundBuffer->SetByteLength(data.Length());
|
||||
boundBuffer->SetByteLength(data.mLength);
|
||||
boundBuffer->InvalidateCachedMaxElements();
|
||||
if (!boundBuffer->CopyDataIfElementArray(data.Data()))
|
||||
if (!boundBuffer->CopyDataIfElementArray(data.mData))
|
||||
return ErrorOutOfMemory("bufferData: out of memory");
|
||||
}
|
||||
|
||||
|
@ -654,7 +654,7 @@ WebGLContext::BufferSubData(GLenum target, WebGLsizeiptr byteOffset,
|
|||
if (!boundBuffer)
|
||||
return ErrorInvalidOperation("bufferData: no buffer bound!");
|
||||
|
||||
CheckedUint32 checked_neededByteLength = CheckedUint32(byteOffset) + data->Length();
|
||||
CheckedUint32 checked_neededByteLength = CheckedUint32(byteOffset) + data->mLength;
|
||||
if (!checked_neededByteLength.isValid())
|
||||
return ErrorInvalidOperation("bufferSubData: integer overflow computing the needed byte length");
|
||||
|
||||
|
@ -664,10 +664,10 @@ WebGLContext::BufferSubData(GLenum target, WebGLsizeiptr byteOffset,
|
|||
|
||||
MakeContextCurrent();
|
||||
|
||||
boundBuffer->CopySubDataIfElementArray(byteOffset, data->Length(), data->Data());
|
||||
boundBuffer->CopySubDataIfElementArray(byteOffset, data->mLength, data->mData);
|
||||
boundBuffer->InvalidateCachedMaxElements();
|
||||
|
||||
gl->fBufferSubData(target, byteOffset, data->Length(), data->Data());
|
||||
gl->fBufferSubData(target, byteOffset, data->mLength, data->mData);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -693,7 +693,7 @@ WebGLContext::BufferSubData(WebGLenum target, WebGLsizeiptr byteOffset,
|
|||
if (!boundBuffer)
|
||||
return ErrorInvalidOperation("bufferSubData: no buffer bound!");
|
||||
|
||||
CheckedUint32 checked_neededByteLength = CheckedUint32(byteOffset) + data.Length();
|
||||
CheckedUint32 checked_neededByteLength = CheckedUint32(byteOffset) + data.mLength;
|
||||
if (!checked_neededByteLength.isValid())
|
||||
return ErrorInvalidOperation("bufferSubData: integer overflow computing the needed byte length");
|
||||
|
||||
|
@ -703,10 +703,10 @@ WebGLContext::BufferSubData(WebGLenum target, WebGLsizeiptr byteOffset,
|
|||
|
||||
MakeContextCurrent();
|
||||
|
||||
boundBuffer->CopySubDataIfElementArray(byteOffset, data.Length(), data.Data());
|
||||
boundBuffer->CopySubDataIfElementArray(byteOffset, data.mLength, data.mData);
|
||||
boundBuffer->InvalidateCachedMaxElements();
|
||||
|
||||
gl->fBufferSubData(target, byteOffset, data.Length(), data.Data());
|
||||
gl->fBufferSubData(target, byteOffset, data.mLength, data.mData);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -3876,9 +3876,9 @@ WebGLContext::ReadPixels(WebGLint x, WebGLint y, WebGLsizei width,
|
|||
WebGLsizei framebufferWidth = framebufferRect ? framebufferRect->Width() : 0;
|
||||
WebGLsizei framebufferHeight = framebufferRect ? framebufferRect->Height() : 0;
|
||||
|
||||
void* data = pixels->Data();
|
||||
uint32_t dataByteLen = JS_GetTypedArrayByteLength(pixels->Obj(), NULL);
|
||||
int dataType = JS_GetTypedArrayType(pixels->Obj(), NULL);
|
||||
void* data = pixels->mData;
|
||||
uint32_t dataByteLen = JS_GetTypedArrayByteLength(pixels->mObj, NULL);
|
||||
int dataType = JS_GetTypedArrayType(pixels->mObj, NULL);
|
||||
|
||||
uint32_t channels = 0;
|
||||
|
||||
|
@ -5146,12 +5146,12 @@ WebGLContext::CompressedTexImage2D(WebGLenum target, WebGLint level, WebGLenum i
|
|||
return;
|
||||
}
|
||||
|
||||
uint32_t byteLength = view.Length();
|
||||
uint32_t byteLength = view.mLength;
|
||||
if (!ValidateCompressedTextureSize(level, internalformat, width, height, byteLength, "compressedTexImage2D")) {
|
||||
return;
|
||||
}
|
||||
|
||||
gl->fCompressedTexImage2D(target, level, internalformat, width, height, border, byteLength, view.Data());
|
||||
gl->fCompressedTexImage2D(target, level, internalformat, width, height, border, byteLength, view.mData);
|
||||
tex->SetImageInfo(target, level, width, height, internalformat, LOCAL_GL_UNSIGNED_BYTE);
|
||||
}
|
||||
|
||||
|
@ -5207,7 +5207,7 @@ WebGLContext::CompressedTexSubImage2D(WebGLenum target, WebGLint level, WebGLint
|
|||
return;
|
||||
}
|
||||
|
||||
uint32_t byteLength = view.Length();
|
||||
uint32_t byteLength = view.mLength;
|
||||
if (!ValidateCompressedTextureSize(level, format, width, height, byteLength, "compressedTexSubImage2D")) {
|
||||
return;
|
||||
}
|
||||
|
@ -5252,7 +5252,7 @@ WebGLContext::CompressedTexSubImage2D(WebGLenum target, WebGLint level, WebGLint
|
|||
}
|
||||
}
|
||||
|
||||
gl->fCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, byteLength, view.Data());
|
||||
gl->fCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, byteLength, view.mData);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -5742,9 +5742,9 @@ WebGLContext::TexImage2D(JSContext* cx, WebGLenum target, WebGLint level,
|
|||
return;
|
||||
|
||||
return TexImage2D_base(target, level, internalformat, width, height, 0, border, format, type,
|
||||
pixels ? pixels->Data() : 0,
|
||||
pixels ? pixels->Length() : 0,
|
||||
pixels ? (int)JS_GetTypedArrayType(pixels->Obj(), cx) : -1,
|
||||
pixels ? pixels->mData : 0,
|
||||
pixels ? pixels->mLength : 0,
|
||||
pixels ? (int)JS_GetTypedArrayType(pixels->mObj, cx) : -1,
|
||||
WebGLTexelConversions::Auto, false);
|
||||
}
|
||||
|
||||
|
@ -5783,7 +5783,7 @@ WebGLContext::TexImage2D(JSContext* cx, WebGLenum target, WebGLint level,
|
|||
Uint8ClampedArray arr(cx, pixels->GetDataObject());
|
||||
return TexImage2D_base(target, level, internalformat, pixels->GetWidth(),
|
||||
pixels->GetHeight(), 4*pixels->GetWidth(), 0,
|
||||
format, type, arr.Data(), arr.Length(), -1,
|
||||
format, type, arr.mData, arr.mLength, -1,
|
||||
WebGLTexelConversions::RGBA8, false);
|
||||
}
|
||||
|
||||
|
@ -5948,8 +5948,8 @@ WebGLContext::TexSubImage2D(JSContext* cx, WebGLenum target, WebGLint level,
|
|||
|
||||
return TexSubImage2D_base(target, level, xoffset, yoffset,
|
||||
width, height, 0, format, type,
|
||||
pixels->Data(), pixels->Length(),
|
||||
JS_GetTypedArrayType(pixels->Obj(), cx),
|
||||
pixels->mData, pixels->mLength,
|
||||
JS_GetTypedArrayType(pixels->mObj, cx),
|
||||
WebGLTexelConversions::Auto, false);
|
||||
}
|
||||
|
||||
|
@ -5994,7 +5994,7 @@ WebGLContext::TexSubImage2D(JSContext* cx, WebGLenum target, WebGLint level,
|
|||
return TexSubImage2D_base(target, level, xoffset, yoffset,
|
||||
pixels->GetWidth(), pixels->GetHeight(),
|
||||
4*pixels->GetWidth(), format, type,
|
||||
arr.Data(), arr.Length(),
|
||||
arr.mData, arr.mLength,
|
||||
-1,
|
||||
WebGLTexelConversions::RGBA8, false);
|
||||
}
|
||||
|
|
|
@ -4352,7 +4352,7 @@ nsCanvasRenderingContext2DAzure::PutImageData(JSContext* cx,
|
|||
|
||||
error = PutImageData_explicit(JS_DoubleToInt32(dx), JS_DoubleToInt32(dy),
|
||||
imageData->GetWidth(), imageData->GetHeight(),
|
||||
arr.Data(), arr.Length(), false, 0, 0, 0, 0);
|
||||
arr.mData, arr.mLength, false, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -4372,7 +4372,7 @@ nsCanvasRenderingContext2DAzure::PutImageData(JSContext* cx,
|
|||
|
||||
error = PutImageData_explicit(JS_DoubleToInt32(dx), JS_DoubleToInt32(dy),
|
||||
imageData->GetWidth(), imageData->GetHeight(),
|
||||
arr.Data(), arr.Length(), true,
|
||||
arr.mData, arr.mLength, true,
|
||||
JS_DoubleToInt32(dirtyX),
|
||||
JS_DoubleToInt32(dirtyY),
|
||||
JS_DoubleToInt32(dirtyWidth),
|
||||
|
|
|
@ -1972,13 +1972,19 @@ for (uint32_t i = 0; i < length; ++i) {
|
|||
"arraybuffer views because making sure all the "
|
||||
"objects are properly rooted is hard")
|
||||
name = type.name
|
||||
if type.isArrayBuffer():
|
||||
jsname = "ArrayBufferObject"
|
||||
elif type.isArrayBufferView():
|
||||
jsname = "ArrayBufferViewObject"
|
||||
else:
|
||||
jsname = type.name
|
||||
|
||||
# By default, we use a Maybe<> to hold our typed array. And in the optional
|
||||
# non-nullable case we want to pass Optional<TypedArray> to consumers, not
|
||||
# Optional<NonNull<TypedArray> >, so jump though some hoops to do that.
|
||||
holderType = "Maybe<%s>" % name
|
||||
constructLoc = "${holderName}"
|
||||
constructMethod = "construct"
|
||||
constructInternal = "ref"
|
||||
if type.nullable():
|
||||
if isOptional:
|
||||
declType = "const Optional<" + name + "*>"
|
||||
|
@ -1991,16 +1997,15 @@ for (uint32_t i = 0; i < length; ++i) {
|
|||
holderType = None
|
||||
constructLoc = "(const_cast<Optional<" + name + ">& >(${declName}))"
|
||||
constructMethod = "Construct"
|
||||
constructInternal = "Value"
|
||||
else:
|
||||
declType = "NonNull<" + name + ">"
|
||||
template = (
|
||||
"%s.%s(cx, &${val}.toObject());\n"
|
||||
"if (!%s.%s().inited()) {\n"
|
||||
"if (!JS_Is%s(&${val}.toObject(), cx)) {\n"
|
||||
"%s" # No newline here because onFailure() handles that
|
||||
"}\n" %
|
||||
(constructLoc, constructMethod, constructLoc, constructInternal,
|
||||
CGIndenter(onFailure(failureCode, descriptorProvider.workers)).define()))
|
||||
"}\n"
|
||||
"%s.%s(cx, &${val}.toObject());\n" %
|
||||
(jsname, CGIndenter(onFailure(failureCode, descriptorProvider.workers)).define(),
|
||||
constructLoc, constructMethod))
|
||||
nullableTarget = ""
|
||||
if type.nullable():
|
||||
if isOptional:
|
||||
|
|
|
@ -18,50 +18,31 @@ namespace dom {
|
|||
* a subclass of the base class that supports creation of a relevant typed array
|
||||
* or array buffer object.
|
||||
*/
|
||||
template<typename T,
|
||||
JSObject* UnboxArray(JSContext*, JSObject*, uint32_t*, T**)>
|
||||
template<typename T, typename U,
|
||||
U* GetData(JSObject*, JSContext*),
|
||||
uint32_t GetLength(JSObject*, JSContext*)>
|
||||
struct TypedArray_base {
|
||||
TypedArray_base(JSContext* cx, JSObject* obj)
|
||||
{
|
||||
mObj = UnboxArray(cx, obj, &mLength, &mData);
|
||||
}
|
||||
TypedArray_base(JSContext* cx, JSObject* obj) :
|
||||
mData(static_cast<T*>(GetData(obj, cx))),
|
||||
mLength(GetLength(obj, cx)),
|
||||
mObj(obj)
|
||||
{}
|
||||
|
||||
private:
|
||||
T* mData;
|
||||
uint32_t mLength;
|
||||
JSObject* mObj;
|
||||
|
||||
public:
|
||||
inline bool inited() const {
|
||||
return !!mObj;
|
||||
}
|
||||
|
||||
inline T *Data() const {
|
||||
MOZ_ASSERT(inited());
|
||||
return mData;
|
||||
}
|
||||
|
||||
inline uint32_t Length() const {
|
||||
MOZ_ASSERT(inited());
|
||||
return mLength;
|
||||
}
|
||||
|
||||
inline JSObject *Obj() const {
|
||||
MOZ_ASSERT(inited());
|
||||
return mObj;
|
||||
}
|
||||
T* const mData;
|
||||
const uint32_t mLength;
|
||||
JSObject* const mObj;
|
||||
};
|
||||
|
||||
|
||||
template<typename T,
|
||||
T* GetData(JSObject*, JSContext*),
|
||||
JSObject* UnboxArray(JSContext*, JSObject*, uint32_t*, T**),
|
||||
template<typename T, typename U,
|
||||
U* GetData(JSObject*, JSContext*),
|
||||
uint32_t GetLength(JSObject*, JSContext*),
|
||||
JSObject* CreateNew(JSContext*, uint32_t)>
|
||||
struct TypedArray : public TypedArray_base<T,UnboxArray> {
|
||||
struct TypedArray : public TypedArray_base<T,U,GetData,GetLength> {
|
||||
TypedArray(JSContext* cx, JSObject* obj) :
|
||||
TypedArray_base<T,UnboxArray>(cx, obj)
|
||||
TypedArray_base<T,U,GetData,GetLength>(cx, obj)
|
||||
{}
|
||||
|
||||
|
||||
static inline JSObject*
|
||||
Create(JSContext* cx, nsWrapperCache* creator, uint32_t length,
|
||||
T* data = NULL) {
|
||||
|
@ -84,37 +65,38 @@ struct TypedArray : public TypedArray_base<T,UnboxArray> {
|
|||
}
|
||||
};
|
||||
|
||||
typedef TypedArray<int8_t, JS_GetInt8ArrayData, JS_GetObjectAsInt8Array,
|
||||
typedef TypedArray<int8_t, int8_t, JS_GetInt8ArrayData, JS_GetTypedArrayLength,
|
||||
JS_NewInt8Array>
|
||||
Int8Array;
|
||||
typedef TypedArray<uint8_t, JS_GetUint8ArrayData,
|
||||
JS_GetObjectAsUint8Array, JS_NewUint8Array>
|
||||
typedef TypedArray<uint8_t, uint8_t, JS_GetUint8ArrayData,
|
||||
JS_GetTypedArrayLength, JS_NewUint8Array>
|
||||
Uint8Array;
|
||||
typedef TypedArray<uint8_t, JS_GetUint8ClampedArrayData,
|
||||
JS_GetObjectAsUint8ClampedArray, JS_NewUint8ClampedArray>
|
||||
typedef TypedArray<uint8_t, uint8_t, JS_GetUint8ClampedArrayData,
|
||||
JS_GetTypedArrayLength, JS_NewUint8ClampedArray>
|
||||
Uint8ClampedArray;
|
||||
typedef TypedArray<int16_t, JS_GetInt16ArrayData,
|
||||
JS_GetObjectAsInt16Array, JS_NewInt16Array>
|
||||
typedef TypedArray<int16_t, int16_t, JS_GetInt16ArrayData,
|
||||
JS_GetTypedArrayLength, JS_NewInt16Array>
|
||||
Int16Array;
|
||||
typedef TypedArray<uint16_t, JS_GetUint16ArrayData,
|
||||
JS_GetObjectAsUint16Array, JS_NewUint16Array>
|
||||
typedef TypedArray<uint16_t, uint16_t, JS_GetUint16ArrayData,
|
||||
JS_GetTypedArrayLength, JS_NewUint16Array>
|
||||
Uint16Array;
|
||||
typedef TypedArray<int32_t, JS_GetInt32ArrayData,
|
||||
JS_GetObjectAsInt32Array, JS_NewInt32Array>
|
||||
typedef TypedArray<int32_t, int32_t, JS_GetInt32ArrayData,
|
||||
JS_GetTypedArrayLength, JS_NewInt32Array>
|
||||
Int32Array;
|
||||
typedef TypedArray<uint32_t, JS_GetUint32ArrayData,
|
||||
JS_GetObjectAsUint32Array, JS_NewUint32Array>
|
||||
typedef TypedArray<uint32_t, uint32_t, JS_GetUint32ArrayData,
|
||||
JS_GetTypedArrayLength, JS_NewUint32Array>
|
||||
Uint32Array;
|
||||
typedef TypedArray<float, JS_GetFloat32ArrayData,
|
||||
JS_GetObjectAsFloat32Array, JS_NewFloat32Array>
|
||||
typedef TypedArray<float, float, JS_GetFloat32ArrayData, JS_GetTypedArrayLength,
|
||||
JS_NewFloat32Array>
|
||||
Float32Array;
|
||||
typedef TypedArray<double, JS_GetFloat64ArrayData,
|
||||
JS_GetObjectAsFloat64Array, JS_NewFloat64Array>
|
||||
typedef TypedArray<double, double, JS_GetFloat64ArrayData,
|
||||
JS_GetTypedArrayLength, JS_NewFloat64Array>
|
||||
Float64Array;
|
||||
typedef TypedArray_base<uint8_t, JS_GetObjectAsArrayBufferView>
|
||||
typedef TypedArray_base<uint8_t, void, JS_GetArrayBufferViewData,
|
||||
JS_GetArrayBufferViewByteLength>
|
||||
ArrayBufferView;
|
||||
typedef TypedArray<uint8_t, JS_GetArrayBufferData,
|
||||
JS_GetObjectAsArrayBuffer, JS_NewArrayBuffer>
|
||||
typedef TypedArray<uint8_t, uint8_t, JS_GetArrayBufferData,
|
||||
JS_GetArrayBufferByteLength, JS_NewArrayBuffer>
|
||||
ArrayBuffer;
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -162,7 +162,7 @@ public:
|
|||
|
||||
void
|
||||
Send(ArrayBuffer& aBody, ErrorResult& aRv) {
|
||||
return Send(aBody.Obj(), aRv);
|
||||
return Send(aBody.mObj, aRv);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -1093,35 +1093,6 @@ JS_IsFloat32Array(JSObject *obj, JSContext *cx);
|
|||
extern JS_FRIEND_API(JSBool)
|
||||
JS_IsFloat64Array(JSObject *obj, JSContext *cx);
|
||||
|
||||
|
||||
/*
|
||||
* Unwrap Typed arrays all at once. Return NULL without throwing if obj cannot
|
||||
* be viewed as the appropriate typed array, or the typed array object on
|
||||
* success, after filling the two out parameters.
|
||||
*/
|
||||
extern JS_FRIEND_API(JSObject *)
|
||||
JS_GetObjectAsInt8Array(JSContext *cx, JSObject *obj, uint32_t *length, int8_t **data);
|
||||
extern JS_FRIEND_API(JSObject *)
|
||||
JS_GetObjectAsUint8Array(JSContext *cx, JSObject *obj, uint32_t *length, uint8_t **data);
|
||||
extern JS_FRIEND_API(JSObject *)
|
||||
JS_GetObjectAsUint8ClampedArray(JSContext *cx, JSObject *obj, uint32_t *length, uint8_t **data);
|
||||
extern JS_FRIEND_API(JSObject *)
|
||||
JS_GetObjectAsInt16Array(JSContext *cx, JSObject *obj, uint32_t *length, int16_t **data);
|
||||
extern JS_FRIEND_API(JSObject *)
|
||||
JS_GetObjectAsUint16Array(JSContext *cx, JSObject *obj, uint32_t *length, uint16_t **data);
|
||||
extern JS_FRIEND_API(JSObject *)
|
||||
JS_GetObjectAsInt32Array(JSContext *cx, JSObject *obj, uint32_t *length, int32_t **data);
|
||||
extern JS_FRIEND_API(JSObject *)
|
||||
JS_GetObjectAsUint32Array(JSContext *cx, JSObject *obj, uint32_t *length, uint32_t **data);
|
||||
extern JS_FRIEND_API(JSObject *)
|
||||
JS_GetObjectAsFloat32Array(JSContext *cx, JSObject *obj, uint32_t *length, float **data);
|
||||
extern JS_FRIEND_API(JSObject *)
|
||||
JS_GetObjectAsFloat64Array(JSContext *cx, JSObject *obj, uint32_t *length, double **data);
|
||||
extern JS_FRIEND_API(JSObject *)
|
||||
JS_GetObjectAsArrayBufferView(JSContext *cx, JSObject *obj, uint32_t *length, uint8_t **data);
|
||||
extern JS_FRIEND_API(JSObject *)
|
||||
JS_GetObjectAsArrayBuffer(JSContext *cx, JSObject *obj, uint32_t *length, uint8_t **data);
|
||||
|
||||
/*
|
||||
* Get the type of elements in a typed array.
|
||||
*
|
||||
|
|
|
@ -2939,40 +2939,6 @@ IMPL_TYPED_ARRAY_JSAPI_CONSTRUCTORS(Uint32, uint32_t)
|
|||
IMPL_TYPED_ARRAY_JSAPI_CONSTRUCTORS(Float32, float)
|
||||
IMPL_TYPED_ARRAY_JSAPI_CONSTRUCTORS(Float64, double)
|
||||
|
||||
#define IMPL_TYPED_ARRAY_COMBINED_UNWRAPPERS(Name, ExternalType, InternalType) \
|
||||
JS_FRIEND_API(JSObject *) JS_GetObjectAs ## Name ## Array(JSContext *cx, \
|
||||
JSObject *obj, \
|
||||
uint32_t *length, \
|
||||
ExternalType **data) \
|
||||
{ \
|
||||
if (obj->isWrapper()) { \
|
||||
MOZ_ASSERT(!cx->isExceptionPending()); \
|
||||
if (!(obj = UnwrapObjectChecked(cx, obj))) { \
|
||||
cx->clearPendingException(); \
|
||||
return NULL; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
Class *clasp = obj->getClass(); \
|
||||
if (clasp != &TypedArray::classes[TypedArrayTemplate<InternalType>::ArrayTypeID()]) \
|
||||
return NULL; \
|
||||
\
|
||||
*length = obj->getSlot(TypedArray::FIELD_LENGTH).toInt32(); \
|
||||
*data = static_cast<ExternalType *>(TypedArray::viewData(obj)); \
|
||||
\
|
||||
return obj; \
|
||||
}
|
||||
|
||||
IMPL_TYPED_ARRAY_COMBINED_UNWRAPPERS(Int8, int8_t, int8_t)
|
||||
IMPL_TYPED_ARRAY_COMBINED_UNWRAPPERS(Uint8, uint8_t, uint8_t)
|
||||
IMPL_TYPED_ARRAY_COMBINED_UNWRAPPERS(Uint8Clamped, uint8_t, uint8_clamped)
|
||||
IMPL_TYPED_ARRAY_COMBINED_UNWRAPPERS(Int16, int16_t, int16_t)
|
||||
IMPL_TYPED_ARRAY_COMBINED_UNWRAPPERS(Uint16, uint16_t, uint16_t)
|
||||
IMPL_TYPED_ARRAY_COMBINED_UNWRAPPERS(Int32, int32_t, int32_t)
|
||||
IMPL_TYPED_ARRAY_COMBINED_UNWRAPPERS(Uint32, uint32_t, uint32_t)
|
||||
IMPL_TYPED_ARRAY_COMBINED_UNWRAPPERS(Float32, float, float)
|
||||
IMPL_TYPED_ARRAY_COMBINED_UNWRAPPERS(Float64, double, double)
|
||||
|
||||
#define IMPL_TYPED_ARRAY_PROTO_CLASS(_typedArray) \
|
||||
{ \
|
||||
#_typedArray "Prototype", \
|
||||
|
@ -3595,42 +3561,3 @@ JS_GetArrayBufferViewByteLength(JSObject *obj, JSContext *cx)
|
|||
? obj->asDataView().byteLength()
|
||||
: TypedArray::byteLengthValue(obj).toInt32();
|
||||
}
|
||||
|
||||
JS_FRIEND_API(JSObject *)
|
||||
JS_GetObjectAsArrayBufferView(JSContext *cx, JSObject *obj,
|
||||
uint32_t *length, uint8_t **data)
|
||||
{
|
||||
if (obj->isWrapper()) {
|
||||
if (!(obj = UnwrapObjectChecked(cx, obj))) {
|
||||
cx->clearPendingException();
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (!(obj->isTypedArray() || obj->isDataView()))
|
||||
return NULL;
|
||||
|
||||
*length = obj->isDataView() ? obj->asDataView().byteLength()
|
||||
: TypedArray::byteLengthValue(obj).toInt32();
|
||||
|
||||
*data = static_cast<uint8_t *>(obj->isDataView() ? obj->asDataView().dataPointer()
|
||||
: TypedArray::viewData(obj));
|
||||
return obj;
|
||||
}
|
||||
|
||||
JS_FRIEND_API(JSObject *)
|
||||
JS_GetObjectAsArrayBuffer(JSContext *cx, JSObject *obj, uint32_t *length, uint8_t **data)
|
||||
{
|
||||
if (obj->isWrapper()) {
|
||||
if (!(obj = UnwrapObjectChecked(cx, obj))) {
|
||||
cx->clearPendingException();
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (!obj->isArrayBuffer())
|
||||
return NULL;
|
||||
|
||||
*length = obj->asArrayBuffer().byteLength();
|
||||
*data = obj->asArrayBuffer().dataPointer();
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче