mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out 7 changesets (bug 1015791) for build bustage on a CLOSED TREE
Backed out changeset a51011a46872 (bug 1015791) Backed out changeset 76a617bf6fe3 (bug 1015791) Backed out changeset b1abfb5152fd (bug 1015791) Backed out changeset d8f29a74c74a (bug 1015791) Backed out changeset 633661dee416 (bug 1015791) Backed out changeset 2870c471fe25 (bug 1015791) Backed out changeset 46dd7365c75a (bug 1015791)
This commit is contained in:
parent
5b4992f05a
commit
256c782793
@ -4205,6 +4205,8 @@ JS_DefineFunctions(JSContext *cx, HandleObject obj, const JSFunctionSpec *fs)
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
|
||||
RootedObject ctor(cx);
|
||||
|
||||
for (; fs->name; fs++) {
|
||||
RootedAtom atom(cx);
|
||||
// If the name starts with "@@", it must be a well-known symbol.
|
||||
@ -4226,12 +4228,11 @@ JS_DefineFunctions(JSContext *cx, HandleObject obj, const JSFunctionSpec *fs)
|
||||
*/
|
||||
unsigned flags = fs->flags;
|
||||
if (flags & JSFUN_GENERIC_NATIVE) {
|
||||
// We require that any consumers using JSFUN_GENERIC_NATIVE stash
|
||||
// the prototype and constructor in the global slots before invoking
|
||||
// JS_DefineFunctions on the proto.
|
||||
JSProtoKey key = JSCLASS_CACHED_PROTO_KEY(obj->getClass());
|
||||
JS_ASSERT(obj == &obj->global().getPrototype(key).toObject());
|
||||
RootedObject ctor(cx, &obj->global().getConstructor(key).toObject());
|
||||
if (!ctor) {
|
||||
ctor = JS_GetConstructor(cx, obj);
|
||||
if (!ctor)
|
||||
return false;
|
||||
}
|
||||
|
||||
flags &= ~JSFUN_GENERIC_NATIVE;
|
||||
JSFunction *fun = DefineFunction(cx, ctor, id,
|
||||
|
@ -831,6 +831,23 @@ js::ObjectMayHaveExtraIndexedProperties(JSObject *obj)
|
||||
return false;
|
||||
}
|
||||
|
||||
const Class ArrayObject::class_ = {
|
||||
"Array",
|
||||
JSCLASS_HAS_CACHED_PROTO(JSProto_Array),
|
||||
array_addProperty,
|
||||
JS_DeletePropertyStub, /* delProperty */
|
||||
JS_PropertyStub, /* getProperty */
|
||||
JS_StrictPropertyStub, /* setProperty */
|
||||
JS_EnumerateStub,
|
||||
JS_ResolveStub,
|
||||
JS_ConvertStub,
|
||||
nullptr,
|
||||
nullptr, /* call */
|
||||
nullptr, /* hasInstance */
|
||||
nullptr, /* construct */
|
||||
nullptr /* trace */
|
||||
};
|
||||
|
||||
static bool
|
||||
AddLengthProperty(ExclusiveContext *cx, HandleObject obj)
|
||||
{
|
||||
@ -3053,11 +3070,14 @@ js_Array(JSContext *cx, unsigned argc, Value *vp)
|
||||
return true;
|
||||
}
|
||||
|
||||
static JSObject *
|
||||
CreateArrayPrototype(JSContext *cx, JSProtoKey key)
|
||||
JSObject *
|
||||
js_InitArrayClass(JSContext *cx, HandleObject obj)
|
||||
{
|
||||
JS_ASSERT(key == JSProto_Array);
|
||||
RootedObject proto(cx, cx->global()->getOrCreateObjectPrototype(cx));
|
||||
JS_ASSERT(obj->isNative());
|
||||
|
||||
Rooted<GlobalObject*> global(cx, &obj->as<GlobalObject>());
|
||||
|
||||
RootedObject proto(cx, global->getOrCreateObjectPrototype(cx));
|
||||
if (!proto)
|
||||
return nullptr;
|
||||
|
||||
@ -3079,6 +3099,11 @@ CreateArrayPrototype(JSContext *cx, JSProtoKey key)
|
||||
if (!arrayProto || !JSObject::setSingletonType(cx, arrayProto) || !AddLengthProperty(cx, arrayProto))
|
||||
return nullptr;
|
||||
|
||||
RootedFunction ctor(cx);
|
||||
ctor = global->createConstructor(cx, js_Array, cx->names().Array, 1);
|
||||
if (!ctor)
|
||||
return nullptr;
|
||||
|
||||
/*
|
||||
* The default 'new' type of Array.prototype is required by type inference
|
||||
* to have unknown properties, to simplify handling of e.g. heterogenous
|
||||
@ -3088,32 +3113,21 @@ CreateArrayPrototype(JSContext *cx, JSProtoKey key)
|
||||
if (!JSObject::setNewTypeUnknown(cx, &ArrayObject::class_, arrayProto))
|
||||
return nullptr;
|
||||
|
||||
if (!LinkConstructorAndPrototype(cx, ctor, arrayProto))
|
||||
return nullptr;
|
||||
|
||||
if (!DefinePropertiesAndBrand(cx, arrayProto, nullptr, array_methods) ||
|
||||
!DefinePropertiesAndBrand(cx, ctor, nullptr, array_static_methods))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!GlobalObject::initBuiltinConstructor(cx, global, JSProto_Array, ctor, arrayProto))
|
||||
return nullptr;
|
||||
|
||||
return arrayProto;
|
||||
}
|
||||
|
||||
const Class ArrayObject::class_ = {
|
||||
"Array",
|
||||
JSCLASS_HAS_CACHED_PROTO(JSProto_Array),
|
||||
array_addProperty,
|
||||
JS_DeletePropertyStub, /* delProperty */
|
||||
JS_PropertyStub, /* getProperty */
|
||||
JS_StrictPropertyStub, /* setProperty */
|
||||
JS_EnumerateStub,
|
||||
JS_ResolveStub,
|
||||
JS_ConvertStub,
|
||||
nullptr,
|
||||
nullptr, /* call */
|
||||
nullptr, /* hasInstance */
|
||||
nullptr, /* construct */
|
||||
nullptr, /* trace */
|
||||
{
|
||||
GenericCreateConstructor<js_Array, NAME_OFFSET(Array), 1>,
|
||||
CreateArrayPrototype,
|
||||
array_static_methods,
|
||||
array_methods
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* Array allocation functions.
|
||||
*/
|
||||
|
@ -64,7 +64,7 @@
|
||||
imaginary(Null, 0, js_InitNullClass, dummy) \
|
||||
real(Object, 1, js_InitViaClassSpec, &JSObject::class_) \
|
||||
real(Function, 2, js_InitViaClassSpec, &JSFunction::class_) \
|
||||
real(Array, 3, js_InitViaClassSpec, OCLASP(Array)) \
|
||||
real(Array, 3, js_InitArrayClass, OCLASP(Array)) \
|
||||
real(Boolean, 4, js_InitBooleanClass, OCLASP(Boolean)) \
|
||||
real(JSON, 5, js_InitJSONClass, CLASP(JSON)) \
|
||||
real(Date, 6, js_InitViaClassSpec, OCLASP(Date)) \
|
||||
@ -82,21 +82,21 @@
|
||||
real(URIError, 18, js_InitExceptionClasses, OCLASP(Error)) \
|
||||
real(Iterator, 19, js_InitIteratorClasses, OCLASP(PropertyIterator)) \
|
||||
real(StopIteration, 20, js_InitIteratorClasses, OCLASP(StopIteration)) \
|
||||
real(ArrayBuffer, 21, js_InitArrayBufferClass, &js::ArrayBufferObject::protoClass) \
|
||||
real(Int8Array, 22, js_InitViaClassSpec, TYPED_ARRAY_CLASP(TYPE_INT8)) \
|
||||
real(Uint8Array, 23, js_InitViaClassSpec, TYPED_ARRAY_CLASP(TYPE_UINT8)) \
|
||||
real(Int16Array, 24, js_InitViaClassSpec, TYPED_ARRAY_CLASP(TYPE_INT16)) \
|
||||
real(Uint16Array, 25, js_InitViaClassSpec, TYPED_ARRAY_CLASP(TYPE_UINT16)) \
|
||||
real(Int32Array, 26, js_InitViaClassSpec, TYPED_ARRAY_CLASP(TYPE_INT32)) \
|
||||
real(Uint32Array, 27, js_InitViaClassSpec, TYPED_ARRAY_CLASP(TYPE_UINT32)) \
|
||||
real(Float32Array, 28, js_InitViaClassSpec, TYPED_ARRAY_CLASP(TYPE_FLOAT32)) \
|
||||
real(Float64Array, 29, js_InitViaClassSpec, TYPED_ARRAY_CLASP(TYPE_FLOAT64)) \
|
||||
real(Uint8ClampedArray, 30, js_InitViaClassSpec, TYPED_ARRAY_CLASP(TYPE_UINT8_CLAMPED)) \
|
||||
real(ArrayBuffer, 21, js_InitTypedArrayClasses, &js::ArrayBufferObject::protoClass) \
|
||||
real(Int8Array, 22, js_InitTypedArrayClasses, TYPED_ARRAY_CLASP(TYPE_INT8)) \
|
||||
real(Uint8Array, 23, js_InitTypedArrayClasses, TYPED_ARRAY_CLASP(TYPE_UINT8)) \
|
||||
real(Int16Array, 24, js_InitTypedArrayClasses, TYPED_ARRAY_CLASP(TYPE_INT16)) \
|
||||
real(Uint16Array, 25, js_InitTypedArrayClasses, TYPED_ARRAY_CLASP(TYPE_UINT16)) \
|
||||
real(Int32Array, 26, js_InitTypedArrayClasses, TYPED_ARRAY_CLASP(TYPE_INT32)) \
|
||||
real(Uint32Array, 27, js_InitTypedArrayClasses, TYPED_ARRAY_CLASP(TYPE_UINT32)) \
|
||||
real(Float32Array, 28, js_InitTypedArrayClasses, TYPED_ARRAY_CLASP(TYPE_FLOAT32)) \
|
||||
real(Float64Array, 29, js_InitTypedArrayClasses, TYPED_ARRAY_CLASP(TYPE_FLOAT64)) \
|
||||
real(Uint8ClampedArray, 30, js_InitTypedArrayClasses, TYPED_ARRAY_CLASP(TYPE_UINT8_CLAMPED)) \
|
||||
real(Proxy, 31, js_InitProxyClass, &ProxyObject::uncallableClass_) \
|
||||
real(WeakMap, 32, js_InitWeakMapClass, OCLASP(WeakMap)) \
|
||||
real(Map, 33, js_InitMapClass, OCLASP(Map)) \
|
||||
real(Set, 34, js_InitSetClass, OCLASP(Set)) \
|
||||
real(DataView, 35, js_InitDataViewClass, OCLASP(DataView)) \
|
||||
real(DataView, 35, js_InitTypedArrayClasses, OCLASP(DataView)) \
|
||||
IF_SAB(real,imaginary)(SharedArrayBuffer, 36, js_InitSharedArrayBufferClass, &js::SharedArrayBufferObject::protoClass) \
|
||||
IF_INTL(real,imaginary) (Intl, 37, js_InitIntlClass, CLASP(Intl)) \
|
||||
IF_BDATA(real,imaginary)(TypedObject, 38, js_InitTypedObjectModuleObject, OCLASP(TypedObjectModule)) \
|
||||
|
@ -3944,9 +3944,6 @@ js_InitStringClass(JSContext *cx, HandleObject obj)
|
||||
if (!ctor)
|
||||
return nullptr;
|
||||
|
||||
if (!GlobalObject::initBuiltinConstructor(cx, global, JSProto_String, ctor, proto))
|
||||
return nullptr;
|
||||
|
||||
if (!LinkConstructorAndPrototype(cx, ctor, proto))
|
||||
return nullptr;
|
||||
|
||||
@ -3956,6 +3953,9 @@ js_InitStringClass(JSContext *cx, HandleObject obj)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!GlobalObject::initBuiltinConstructor(cx, global, JSProto_String, ctor, proto))
|
||||
return nullptr;
|
||||
|
||||
/*
|
||||
* Define escape/unescape, the URI encode/decode functions, and maybe
|
||||
* uneval on the global object.
|
||||
|
@ -18,6 +18,9 @@
|
||||
#include "vm/ArrayBufferObject.h"
|
||||
#include "vm/ErrorObject.h"
|
||||
|
||||
extern JSObject *
|
||||
js_InitTypedArrayClasses(JSContext *cx, js::HandleObject obj);
|
||||
|
||||
extern JSObject *
|
||||
js_InitSharedArrayBufferClass(JSContext *cx, js::HandleObject obj);
|
||||
|
||||
@ -242,10 +245,15 @@ class GlobalObject : public JSObject
|
||||
bool dataViewClassInitialized() const {
|
||||
return classIsInitialized(JSProto_DataView);
|
||||
}
|
||||
bool typedArrayClassesInitialized() const {
|
||||
// This alias exists only for clarity: in reality all the typed array
|
||||
// classes constitute a (semi-)coherent whole.
|
||||
return classIsInitialized(JSProto_DataView);
|
||||
}
|
||||
|
||||
Value createArrayFromBufferHelper(uint32_t slot) const {
|
||||
JS_ASSERT(typedArrayClassesInitialized());
|
||||
JS_ASSERT(FROM_BUFFER_UINT8 <= slot && slot <= FROM_BUFFER_UINT8CLAMPED);
|
||||
JS_ASSERT(!getSlot(slot).isUndefined());
|
||||
return getSlot(slot);
|
||||
}
|
||||
|
||||
|
@ -206,13 +206,6 @@ class TypedArrayObjectTemplate : public TypedArrayObject
|
||||
return &TypedArrayObject::protoClasses[ArrayTypeID()];
|
||||
}
|
||||
|
||||
static JSObject *CreatePrototype(JSContext *cx, JSProtoKey key)
|
||||
{
|
||||
return cx->global()->createBlankPrototype(cx, protoClass());
|
||||
}
|
||||
|
||||
static bool FinishClassInit(JSContext *cx, HandleObject ctor, HandleObject proto);
|
||||
|
||||
static inline const Class *instanceClass()
|
||||
{
|
||||
return &TypedArrayObject::classes[ArrayTypeID()];
|
||||
@ -490,6 +483,24 @@ class TypedArrayObjectTemplate : public TypedArrayObject
|
||||
attrs);
|
||||
}
|
||||
|
||||
static
|
||||
bool defineGetters(JSContext *cx, HandleObject proto)
|
||||
{
|
||||
if (!DefineGetter(cx, proto, cx->names().length, Getter<lengthValue>))
|
||||
return false;
|
||||
|
||||
if (!DefineGetter(cx, proto, cx->names().buffer, BufferGetter))
|
||||
return false;
|
||||
|
||||
if (!DefineGetter(cx, proto, cx->names().byteLength, Getter<byteLengthValue>))
|
||||
return false;
|
||||
|
||||
if (!DefineGetter(cx, proto, cx->names().byteOffset, Getter<byteOffsetValue>))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* subarray(start[, end]) */
|
||||
static bool
|
||||
fun_subarray_impl(JSContext *cx, CallArgs args)
|
||||
@ -1138,63 +1149,54 @@ class Int8ArrayObject : public TypedArrayObjectTemplate<int8_t> {
|
||||
enum { ACTUAL_TYPE = ScalarTypeDescr::TYPE_INT8 };
|
||||
static const JSProtoKey key = JSProto_Int8Array;
|
||||
static const JSFunctionSpec jsfuncs[];
|
||||
static const JSPropertySpec jsprops[];
|
||||
};
|
||||
class Uint8ArrayObject : public TypedArrayObjectTemplate<uint8_t> {
|
||||
public:
|
||||
enum { ACTUAL_TYPE = ScalarTypeDescr::TYPE_UINT8 };
|
||||
static const JSProtoKey key = JSProto_Uint8Array;
|
||||
static const JSFunctionSpec jsfuncs[];
|
||||
static const JSPropertySpec jsprops[];
|
||||
};
|
||||
class Int16ArrayObject : public TypedArrayObjectTemplate<int16_t> {
|
||||
public:
|
||||
enum { ACTUAL_TYPE = ScalarTypeDescr::TYPE_INT16 };
|
||||
static const JSProtoKey key = JSProto_Int16Array;
|
||||
static const JSFunctionSpec jsfuncs[];
|
||||
static const JSPropertySpec jsprops[];
|
||||
};
|
||||
class Uint16ArrayObject : public TypedArrayObjectTemplate<uint16_t> {
|
||||
public:
|
||||
enum { ACTUAL_TYPE = ScalarTypeDescr::TYPE_UINT16 };
|
||||
static const JSProtoKey key = JSProto_Uint16Array;
|
||||
static const JSFunctionSpec jsfuncs[];
|
||||
static const JSPropertySpec jsprops[];
|
||||
};
|
||||
class Int32ArrayObject : public TypedArrayObjectTemplate<int32_t> {
|
||||
public:
|
||||
enum { ACTUAL_TYPE = ScalarTypeDescr::TYPE_INT32 };
|
||||
static const JSProtoKey key = JSProto_Int32Array;
|
||||
static const JSFunctionSpec jsfuncs[];
|
||||
static const JSPropertySpec jsprops[];
|
||||
};
|
||||
class Uint32ArrayObject : public TypedArrayObjectTemplate<uint32_t> {
|
||||
public:
|
||||
enum { ACTUAL_TYPE = ScalarTypeDescr::TYPE_UINT32 };
|
||||
static const JSProtoKey key = JSProto_Uint32Array;
|
||||
static const JSFunctionSpec jsfuncs[];
|
||||
static const JSPropertySpec jsprops[];
|
||||
};
|
||||
class Float32ArrayObject : public TypedArrayObjectTemplate<float> {
|
||||
public:
|
||||
enum { ACTUAL_TYPE = ScalarTypeDescr::TYPE_FLOAT32 };
|
||||
static const JSProtoKey key = JSProto_Float32Array;
|
||||
static const JSFunctionSpec jsfuncs[];
|
||||
static const JSPropertySpec jsprops[];
|
||||
};
|
||||
class Float64ArrayObject : public TypedArrayObjectTemplate<double> {
|
||||
public:
|
||||
enum { ACTUAL_TYPE = ScalarTypeDescr::TYPE_FLOAT64 };
|
||||
static const JSProtoKey key = JSProto_Float64Array;
|
||||
static const JSFunctionSpec jsfuncs[];
|
||||
static const JSPropertySpec jsprops[];
|
||||
};
|
||||
class Uint8ClampedArrayObject : public TypedArrayObjectTemplate<uint8_clamped> {
|
||||
public:
|
||||
enum { ACTUAL_TYPE = ScalarTypeDescr::TYPE_UINT8_CLAMPED };
|
||||
static const JSProtoKey key = JSProto_Uint8ClampedArray;
|
||||
static const JSFunctionSpec jsfuncs[];
|
||||
static const JSPropertySpec jsprops[];
|
||||
};
|
||||
|
||||
} /* anonymous namespace */
|
||||
@ -2039,27 +2041,24 @@ TypedArrayObject::setElement(TypedArrayObject &obj, uint32_t index, double d)
|
||||
* TypedArrayObject boilerplate
|
||||
*/
|
||||
|
||||
#ifdef RELEASE_BUILD
|
||||
# define RELEASE_ONLY_FUNCTIONS JS_FN("move", _typedArray##Object::fun_move, 3, JSFUN_GENERIC_NATIVE),
|
||||
#else
|
||||
# define RELEASE_ONLY_FUNCTIONS
|
||||
#endif
|
||||
|
||||
#define IMPL_TYPED_ARRAY_STATICS(_typedArray) \
|
||||
#ifndef RELEASE_BUILD
|
||||
# define IMPL_TYPED_ARRAY_STATICS(_typedArray) \
|
||||
const JSFunctionSpec _typedArray##Object::jsfuncs[] = { \
|
||||
JS_SELF_HOSTED_FN("@@iterator", "ArrayValues", 0, 0), \
|
||||
JS_FN("subarray", _typedArray##Object::fun_subarray, 2, JSFUN_GENERIC_NATIVE), \
|
||||
JS_FN("set", _typedArray##Object::fun_set, 2, JSFUN_GENERIC_NATIVE), \
|
||||
RELEASE_ONLY_FUNCTIONS \
|
||||
JS_FN("move", _typedArray##Object::fun_move, 3, JSFUN_GENERIC_NATIVE), \
|
||||
JS_FS_END \
|
||||
}; \
|
||||
const JSPropertySpec _typedArray##Object::jsprops[] = { \
|
||||
JS_PSG("length", _typedArray##Object::Getter<lengthValue>, JSPROP_PERMANENT), \
|
||||
JS_PSG("buffer", _typedArray##Object::BufferGetter, JSPROP_PERMANENT), \
|
||||
JS_PSG("byteLength", _typedArray##Object::Getter<byteLengthValue>, JSPROP_PERMANENT), \
|
||||
JS_PSG("byteOffset", _typedArray##Object::Getter<byteOffsetValue>, JSPROP_PERMANENT), \
|
||||
JS_PS_END \
|
||||
};
|
||||
}
|
||||
#else
|
||||
# define IMPL_TYPED_ARRAY_STATICS(_typedArray) \
|
||||
const JSFunctionSpec _typedArray##Object::jsfuncs[] = { \
|
||||
JS_SELF_HOSTED_FN("@@iterator", "ArrayValues", 0, 0), \
|
||||
JS_FN("subarray", _typedArray##Object::fun_subarray, 2, JSFUN_GENERIC_NATIVE), \
|
||||
JS_FN("set", _typedArray##Object::fun_set, 2, JSFUN_GENERIC_NATIVE), \
|
||||
JS_FS_END \
|
||||
}
|
||||
#endif
|
||||
|
||||
#define IMPL_TYPED_ARRAY_JSAPI_CONSTRUCTORS(Name,NativeType) \
|
||||
JS_FRIEND_API(JSObject *) JS_New ## Name ## Array(JSContext *cx, uint32_t nelements) \
|
||||
@ -2163,29 +2162,35 @@ IMPL_TYPED_ARRAY_COMBINED_UNWRAPPERS(Float64, double, double)
|
||||
JS_EnumerateStub, \
|
||||
JS_ResolveStub, \
|
||||
JS_ConvertStub, \
|
||||
nullptr, /* finalize */ \
|
||||
nullptr, /* finalize */ \
|
||||
nullptr, /* call */ \
|
||||
nullptr, /* hasInstance */ \
|
||||
nullptr, /* construct */ \
|
||||
ArrayBufferViewObject::trace, /* trace */ \
|
||||
{ \
|
||||
GenericCreateConstructor<_typedArray##Object::class_constructor, \
|
||||
NAME_OFFSET(_typedArray), 3>, \
|
||||
_typedArray##Object::CreatePrototype, \
|
||||
nullptr, \
|
||||
_typedArray##Object::jsfuncs, \
|
||||
_typedArray##Object::jsprops, \
|
||||
_typedArray##Object::FinishClassInit \
|
||||
} \
|
||||
}
|
||||
|
||||
template<typename NativeType>
|
||||
bool
|
||||
TypedArrayObjectTemplate<NativeType>::FinishClassInit(JSContext *cx,
|
||||
HandleObject ctor,
|
||||
HandleObject proto)
|
||||
template<class ArrayType>
|
||||
static inline bool
|
||||
InitTypedArrayClass(JSContext *cx)
|
||||
{
|
||||
RootedValue bytesValue(cx, Int32Value(BYTES_PER_ELEMENT));
|
||||
Rooted<GlobalObject*> global(cx, cx->compartment()->maybeGlobal());
|
||||
if (global->isStandardClassResolved(ArrayType::key))
|
||||
return true;
|
||||
|
||||
RootedObject proto(cx, global->createBlankPrototype(cx, ArrayType::protoClass()));
|
||||
if (!proto)
|
||||
return false;
|
||||
|
||||
RootedFunction ctor(cx);
|
||||
ctor = global->createConstructor(cx, ArrayType::class_constructor,
|
||||
ClassName(ArrayType::key, cx), 3);
|
||||
if (!ctor)
|
||||
return false;
|
||||
|
||||
if (!LinkConstructorAndPrototype(cx, ctor, proto))
|
||||
return false;
|
||||
|
||||
RootedValue bytesValue(cx, Int32Value(ArrayType::BYTES_PER_ELEMENT));
|
||||
|
||||
if (!JSObject::defineProperty(cx, ctor,
|
||||
cx->names().BYTES_PER_ELEMENT, bytesValue,
|
||||
@ -2199,28 +2204,37 @@ TypedArrayObjectTemplate<NativeType>::FinishClassInit(JSContext *cx,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ArrayType::defineGetters(cx, proto))
|
||||
return false;
|
||||
|
||||
if (!JS_DefineFunctions(cx, proto, ArrayType::jsfuncs))
|
||||
return false;
|
||||
|
||||
RootedFunction fun(cx);
|
||||
fun =
|
||||
NewFunction(cx, NullPtr(),
|
||||
ArrayBufferObject::createTypedArrayFromBuffer<ThisType>,
|
||||
0, JSFunction::NATIVE_FUN, cx->global(), NullPtr());
|
||||
ArrayBufferObject::createTypedArrayFromBuffer<typename ArrayType::ThisType>,
|
||||
0, JSFunction::NATIVE_FUN, global, NullPtr());
|
||||
if (!fun)
|
||||
return false;
|
||||
|
||||
cx->global()->setCreateArrayFromBuffer<ThisType>(fun);
|
||||
if (!GlobalObject::initBuiltinConstructor(cx, global, ArrayType::key, ctor, proto))
|
||||
return false;
|
||||
|
||||
global->setCreateArrayFromBuffer<typename ArrayType::ThisType>(fun);
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
IMPL_TYPED_ARRAY_STATICS(Int8Array)
|
||||
IMPL_TYPED_ARRAY_STATICS(Uint8Array)
|
||||
IMPL_TYPED_ARRAY_STATICS(Int16Array)
|
||||
IMPL_TYPED_ARRAY_STATICS(Uint16Array)
|
||||
IMPL_TYPED_ARRAY_STATICS(Int32Array)
|
||||
IMPL_TYPED_ARRAY_STATICS(Uint32Array)
|
||||
IMPL_TYPED_ARRAY_STATICS(Float32Array)
|
||||
IMPL_TYPED_ARRAY_STATICS(Float64Array)
|
||||
IMPL_TYPED_ARRAY_STATICS(Uint8ClampedArray)
|
||||
IMPL_TYPED_ARRAY_STATICS(Int8Array);
|
||||
IMPL_TYPED_ARRAY_STATICS(Uint8Array);
|
||||
IMPL_TYPED_ARRAY_STATICS(Int16Array);
|
||||
IMPL_TYPED_ARRAY_STATICS(Uint16Array);
|
||||
IMPL_TYPED_ARRAY_STATICS(Int32Array);
|
||||
IMPL_TYPED_ARRAY_STATICS(Uint32Array);
|
||||
IMPL_TYPED_ARRAY_STATICS(Float32Array);
|
||||
IMPL_TYPED_ARRAY_STATICS(Float64Array);
|
||||
IMPL_TYPED_ARRAY_STATICS(Uint8ClampedArray);
|
||||
|
||||
const Class TypedArrayObject::classes[ScalarTypeDescr::TYPE_MAX] = {
|
||||
IMPL_TYPED_ARRAY_FAST_CLASS(Int8Array),
|
||||
@ -2263,8 +2277,8 @@ js::IsTypedArrayThisCheck(JS::IsAcceptableThis test)
|
||||
}
|
||||
#undef CHECK
|
||||
|
||||
JSObject *
|
||||
js_InitArrayBufferClass(JSContext *cx, HandleObject obj)
|
||||
static JSObject *
|
||||
InitArrayBufferClass(JSContext *cx)
|
||||
{
|
||||
Rooted<GlobalObject*> global(cx, cx->compartment()->maybeGlobal());
|
||||
if (global->isStandardClassResolved(JSProto_ArrayBuffer))
|
||||
@ -2279,12 +2293,6 @@ js_InitArrayBufferClass(JSContext *cx, HandleObject obj)
|
||||
if (!ctor)
|
||||
return nullptr;
|
||||
|
||||
if (!GlobalObject::initBuiltinConstructor(cx, global, JSProto_ArrayBuffer,
|
||||
ctor, arrayBufferProto))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!LinkConstructorAndPrototype(cx, ctor, arrayBufferProto))
|
||||
return nullptr;
|
||||
|
||||
@ -2305,6 +2313,12 @@ js_InitArrayBufferClass(JSContext *cx, HandleObject obj)
|
||||
if (!JS_DefineFunctions(cx, arrayBufferProto, ArrayBufferObject::jsfuncs))
|
||||
return nullptr;
|
||||
|
||||
if (!GlobalObject::initBuiltinConstructor(cx, global, JSProto_ArrayBuffer,
|
||||
ctor, arrayBufferProto))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return arrayBufferProto;
|
||||
}
|
||||
|
||||
@ -2453,11 +2467,23 @@ DataViewObject::neuter(void *newData)
|
||||
}
|
||||
|
||||
JSObject *
|
||||
js_InitDataViewClass(JSContext *cx, HandleObject obj)
|
||||
js_InitTypedArrayClasses(JSContext *cx, HandleObject obj)
|
||||
{
|
||||
if (!DataViewObject::initClass(cx))
|
||||
if (!InitTypedArrayClass<Int8ArrayObject>(cx) ||
|
||||
!InitTypedArrayClass<Uint8ArrayObject>(cx) ||
|
||||
!InitTypedArrayClass<Int16ArrayObject>(cx) ||
|
||||
!InitTypedArrayClass<Uint16ArrayObject>(cx) ||
|
||||
!InitTypedArrayClass<Int32ArrayObject>(cx) ||
|
||||
!InitTypedArrayClass<Uint32ArrayObject>(cx) ||
|
||||
!InitTypedArrayClass<Float32ArrayObject>(cx) ||
|
||||
!InitTypedArrayClass<Float64ArrayObject>(cx) ||
|
||||
!InitTypedArrayClass<Uint8ClampedArrayObject>(cx) ||
|
||||
!DataViewObject::initClass(cx))
|
||||
{
|
||||
return nullptr;
|
||||
return &cx->global()->getPrototype(JSProto_DataView).toObject();
|
||||
}
|
||||
|
||||
return InitArrayBufferClass(cx);
|
||||
}
|
||||
|
||||
bool
|
||||
|
Loading…
Reference in New Issue
Block a user