mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1114580 - Change ESClassValue to an enum class. r=jorendorff
This commit is contained in:
parent
faac928c5a
commit
4455e57052
@ -241,12 +241,12 @@ IsNotDateOrRegExp(JSContext* cx, JS::Handle<JSObject*> obj,
|
||||
{
|
||||
MOZ_ASSERT(obj);
|
||||
|
||||
js::ESClassValue cls;
|
||||
js::ESClass cls;
|
||||
if (!js::GetBuiltinClass(cx, obj, &cls)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*notDateOrRegExp = cls != js::ESClass_Date && cls != js::ESClass_RegExp;
|
||||
*notDateOrRegExp = cls != js::ESClass::Date && cls != js::ESClass::RegExp;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -111,11 +111,11 @@ IDBKeyRange::FromJSVal(JSContext* aCx,
|
||||
JS::Rooted<JSObject*> obj(aCx, aVal.isObject() ? &aVal.toObject() : nullptr);
|
||||
bool isValidKey = aVal.isPrimitive();
|
||||
if (!isValidKey) {
|
||||
js::ESClassValue cls;
|
||||
js::ESClass cls;
|
||||
if (!js::GetBuiltinClass(aCx, obj, &cls)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
isValidKey = cls == js::ESClass_Array || cls == js::ESClass_Date;
|
||||
isValidKey = cls == js::ESClass::Array || cls == js::ESClass::Date;
|
||||
}
|
||||
if (isValidKey) {
|
||||
// A valid key returns an 'only' IDBKeyRange.
|
||||
|
@ -232,12 +232,12 @@ Key::EncodeJSValInternal(JSContext* aCx, JS::Handle<JS::Value> aVal,
|
||||
if (aVal.isObject()) {
|
||||
JS::Rooted<JSObject*> obj(aCx, &aVal.toObject());
|
||||
|
||||
js::ESClassValue cls;
|
||||
js::ESClass cls;
|
||||
if (!js::GetBuiltinClass(aCx, obj, &cls)) {
|
||||
IDB_REPORT_INTERNAL_ERR();
|
||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
}
|
||||
if (cls == js::ESClass_Array) {
|
||||
if (cls == js::ESClass::Array) {
|
||||
aTypeOffset += eMaxType;
|
||||
|
||||
if (aTypeOffset == eMaxType * kMaxArrayCollapse) {
|
||||
@ -275,7 +275,7 @@ Key::EncodeJSValInternal(JSContext* aCx, JS::Handle<JS::Value> aVal,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (cls == js::ESClass_Date) {
|
||||
if (cls == js::ESClass::Date) {
|
||||
bool valid;
|
||||
if (!js::DateIsValid(aCx, obj, &valid)) {
|
||||
IDB_REPORT_INTERNAL_ERR();
|
||||
|
@ -490,7 +490,7 @@ bool
|
||||
WrapperAnswer::RecvGetBuiltinClass(const ObjectId& objId, ReturnStatus* rs,
|
||||
uint32_t* classValue)
|
||||
{
|
||||
*classValue = js::ESClass_Other;
|
||||
*classValue = uint32_t(js::ESClass::Other);
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
if (NS_WARN_IF(!jsapi.Init(scopeForTargetObjects())))
|
||||
@ -503,11 +503,11 @@ WrapperAnswer::RecvGetBuiltinClass(const ObjectId& objId, ReturnStatus* rs,
|
||||
|
||||
LOG("%s.getBuiltinClass()", ReceiverObj(objId));
|
||||
|
||||
js::ESClassValue cls;
|
||||
js::ESClass cls;
|
||||
if (!js::GetBuiltinClass(cx, obj, &cls))
|
||||
return fail(jsapi, rs);
|
||||
|
||||
*classValue = cls;
|
||||
*classValue = uint32_t(cls);
|
||||
return ok(rs);
|
||||
}
|
||||
|
||||
|
@ -126,8 +126,7 @@ class CPOWProxyHandler : public BaseProxyHandler
|
||||
AutoIdVector& props) const override;
|
||||
virtual bool hasInstance(JSContext* cx, HandleObject proxy,
|
||||
MutableHandleValue v, bool* bp) const override;
|
||||
virtual bool getBuiltinClass(JSContext* cx, HandleObject obj,
|
||||
js::ESClassValue* classValue) const override;
|
||||
virtual bool getBuiltinClass(JSContext* cx, HandleObject obj, js::ESClass* cls) const override;
|
||||
virtual bool isArray(JSContext* cx, HandleObject obj,
|
||||
IsArrayAnswer* answer) const override;
|
||||
virtual const char* className(JSContext* cx, HandleObject proxy) const override;
|
||||
@ -729,23 +728,21 @@ WrapperOwner::hasInstance(JSContext* cx, HandleObject proxy, MutableHandleValue
|
||||
}
|
||||
|
||||
bool
|
||||
CPOWProxyHandler::getBuiltinClass(JSContext* cx, HandleObject proxy,
|
||||
js::ESClassValue* classValue) const
|
||||
CPOWProxyHandler::getBuiltinClass(JSContext* cx, HandleObject proxy, ESClass* cls) const
|
||||
{
|
||||
FORWARD(getBuiltinClass, (cx, proxy, classValue));
|
||||
FORWARD(getBuiltinClass, (cx, proxy, cls));
|
||||
}
|
||||
|
||||
bool
|
||||
WrapperOwner::getBuiltinClass(JSContext* cx, HandleObject proxy,
|
||||
js::ESClassValue* classValue)
|
||||
WrapperOwner::getBuiltinClass(JSContext* cx, HandleObject proxy, ESClass* cls)
|
||||
{
|
||||
ObjectId objId = idOf(proxy);
|
||||
|
||||
uint32_t cls = ESClass_Other;
|
||||
uint32_t classValue = uint32_t(ESClass::Other);
|
||||
ReturnStatus status;
|
||||
if (!SendGetBuiltinClass(objId, &status, &cls))
|
||||
if (!SendGetBuiltinClass(objId, &status, &classValue))
|
||||
return ipcfail(cx);
|
||||
*classValue = ESClassValue(cls);
|
||||
*cls = ESClass(classValue);
|
||||
|
||||
LOG_STACK();
|
||||
|
||||
|
@ -54,7 +54,7 @@ class WrapperOwner : public virtual JavaScriptShared
|
||||
bool getOwnEnumerablePropertyKeys(JSContext* cx, JS::HandleObject proxy,
|
||||
JS::AutoIdVector& props);
|
||||
bool hasInstance(JSContext* cx, JS::HandleObject proxy, JS::MutableHandleValue v, bool* bp);
|
||||
bool getBuiltinClass(JSContext* cx, JS::HandleObject proxy, js::ESClassValue* classValue);
|
||||
bool getBuiltinClass(JSContext* cx, JS::HandleObject proxy, js::ESClass* cls);
|
||||
bool isArray(JSContext* cx, JS::HandleObject proxy, JS::IsArrayAnswer* answer);
|
||||
const char* className(JSContext* cx, JS::HandleObject proxy);
|
||||
bool getPrototype(JSContext* cx, JS::HandleObject proxy, JS::MutableHandleObject protop);
|
||||
|
@ -958,14 +958,26 @@ Valueify(const JSClass* c)
|
||||
* Enumeration describing possible values of the [[Class]] internal property
|
||||
* value of objects.
|
||||
*/
|
||||
enum ESClassValue {
|
||||
ESClass_Object, ESClass_Array, ESClass_Number, ESClass_String,
|
||||
ESClass_Boolean, ESClass_RegExp, ESClass_ArrayBuffer, ESClass_SharedArrayBuffer,
|
||||
ESClass_Date, ESClass_Set, ESClass_Map, ESClass_Promise, ESClass_MapIterator,
|
||||
ESClass_SetIterator,
|
||||
enum class ESClass {
|
||||
Object,
|
||||
Array,
|
||||
Number,
|
||||
String,
|
||||
Boolean,
|
||||
RegExp,
|
||||
ArrayBuffer,
|
||||
SharedArrayBuffer,
|
||||
Date,
|
||||
Set,
|
||||
Map,
|
||||
Promise,
|
||||
MapIterator,
|
||||
SetIterator,
|
||||
Arguments,
|
||||
Error,
|
||||
|
||||
/** None of the above. */
|
||||
ESClass_Other
|
||||
Other
|
||||
};
|
||||
|
||||
/* Fills |vp| with the unboxed value for boxed types, or undefined otherwise. */
|
||||
|
@ -316,7 +316,7 @@ class JS_FRIEND_API(BaseProxyHandler)
|
||||
const CallArgs& args) const;
|
||||
virtual bool hasInstance(JSContext* cx, HandleObject proxy, MutableHandleValue v, bool* bp) const;
|
||||
virtual bool getBuiltinClass(JSContext* cx, HandleObject proxy,
|
||||
ESClassValue* classValue) const;
|
||||
ESClass* cls) const;
|
||||
virtual bool isArray(JSContext* cx, HandleObject proxy, JS::IsArrayAnswer* answer) const;
|
||||
virtual const char* className(JSContext* cx, HandleObject proxy) const;
|
||||
virtual JSString* fun_toString(JSContext* cx, HandleObject proxy, unsigned indent) const;
|
||||
|
@ -290,11 +290,11 @@ js::IsRegExp(JSContext* cx, HandleValue value, bool* result)
|
||||
}
|
||||
|
||||
/* Steps 5-6. */
|
||||
ESClassValue cls;
|
||||
ESClass cls;
|
||||
if (!GetClassOfValue(cx, value, &cls))
|
||||
return false;
|
||||
|
||||
*result = cls == ESClass_RegExp;
|
||||
*result = cls == ESClass::RegExp;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -308,10 +308,10 @@ regexp_compile_impl(JSContext* cx, const CallArgs& args)
|
||||
|
||||
// Step 3.
|
||||
RootedValue patternValue(cx, args.get(0));
|
||||
ESClassValue cls;
|
||||
ESClass cls;
|
||||
if (!GetClassOfValue(cx, patternValue, &cls))
|
||||
return false;
|
||||
if (cls == ESClass_RegExp) {
|
||||
if (cls == ESClass::RegExp) {
|
||||
// Step 3a.
|
||||
if (args.hasDefined(1)) {
|
||||
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NEWREGEXP_FLAGGED);
|
||||
@ -405,10 +405,10 @@ js::regexp_construct(JSContext* cx, unsigned argc, Value* vp)
|
||||
RootedValue patternValue(cx, args.get(0));
|
||||
|
||||
// Step 4.
|
||||
ESClassValue cls;
|
||||
ESClass cls;
|
||||
if (!GetClassOfValue(cx, patternValue, &cls))
|
||||
return false;
|
||||
if (cls == ESClass_RegExp) {
|
||||
if (cls == ESClass::RegExp) {
|
||||
// Beware! |patternObj| might be a proxy into another compartment, so
|
||||
// don't assume |patternObj.is<RegExpObject>()|. For the same reason,
|
||||
// don't reuse the RegExpShared below.
|
||||
|
@ -3649,11 +3649,11 @@ ImplicitConvert(JSContext* cx,
|
||||
arrObj, arrIndex);
|
||||
}
|
||||
} else {
|
||||
ESClassValue cls;
|
||||
ESClass cls;
|
||||
if (!GetClassOfValue(cx, val, &cls))
|
||||
return false;
|
||||
|
||||
if (cls == ESClass_Array) {
|
||||
if (cls == ESClass::Array) {
|
||||
// Convert each element of the array by calling ImplicitConvert.
|
||||
uint32_t sourceLength;
|
||||
if (!JS_GetArrayLength(cx, valObj, &sourceLength) ||
|
||||
@ -3684,10 +3684,10 @@ ImplicitConvert(JSContext* cx,
|
||||
}
|
||||
|
||||
memcpy(buffer, intermediate.get(), arraySize);
|
||||
} else if (cls == ESClass_ArrayBuffer || cls == ESClass_SharedArrayBuffer) {
|
||||
} else if (cls == ESClass::ArrayBuffer || cls == ESClass::SharedArrayBuffer) {
|
||||
// Check that array is consistent with type, then
|
||||
// copy the array.
|
||||
const bool bufferShared = cls == ESClass_SharedArrayBuffer;
|
||||
const bool bufferShared = cls == ESClass::SharedArrayBuffer;
|
||||
uint32_t sourceLength = bufferShared ? JS_GetSharedArrayBufferByteLength(valObj)
|
||||
: JS_GetArrayBufferByteLength(valObj);
|
||||
size_t elementSize = CType::GetSize(baseType);
|
||||
|
@ -13,17 +13,17 @@ BEGIN_TEST(testIteratorObject)
|
||||
|
||||
CHECK(result.isObject());
|
||||
JS::RootedObject obj1(cx, &result.toObject());
|
||||
ESClassValue class1 = ESClass_Other;
|
||||
ESClass class1 = ESClass::Other;
|
||||
CHECK(GetBuiltinClass(cx, obj1, &class1));
|
||||
CHECK(class1 == ESClass_MapIterator);
|
||||
CHECK(class1 == ESClass::MapIterator);
|
||||
|
||||
EVAL("new Set(['value1', 'value2']).entries()", &result);
|
||||
|
||||
CHECK(result.isObject());
|
||||
JS::RootedObject obj2(cx, &result.toObject());
|
||||
ESClassValue class2 = ESClass_Other;
|
||||
ESClass class2 = ESClass::Other;
|
||||
CHECK(GetBuiltinClass(cx, obj2, &class2));
|
||||
CHECK(class2 == ESClass_SetIterator);
|
||||
CHECK(class2 == ESClass::SetIterator);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -3222,11 +3222,11 @@ JS_IsArrayObject(JSContext* cx, JS::HandleObject obj, bool* isArray)
|
||||
{
|
||||
assertSameCompartment(cx, obj);
|
||||
|
||||
ESClassValue cls;
|
||||
ESClass cls;
|
||||
if (!GetBuiltinClass(cx, obj, &cls))
|
||||
return false;
|
||||
|
||||
*isArray = cls == ESClass_Array;
|
||||
*isArray = cls == ESClass::Array;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -5670,11 +5670,11 @@ JS_ObjectIsDate(JSContext* cx, HandleObject obj, bool* isDate)
|
||||
{
|
||||
assertSameCompartment(cx, obj);
|
||||
|
||||
ESClassValue cls;
|
||||
ESClass cls;
|
||||
if (!GetBuiltinClass(cx, obj, &cls))
|
||||
return false;
|
||||
|
||||
*isDate = cls == ESClass_Date;
|
||||
*isDate = cls == ESClass::Date;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -5774,11 +5774,11 @@ JS_ObjectIsRegExp(JSContext* cx, HandleObject obj, bool* isRegExp)
|
||||
{
|
||||
assertSameCompartment(cx, obj);
|
||||
|
||||
ESClassValue cls;
|
||||
ESClass cls;
|
||||
if (!GetBuiltinClass(cx, obj, &cls))
|
||||
return false;
|
||||
|
||||
*isRegExp = cls == ESClass_RegExp;
|
||||
*isRegExp = cls == ESClass::RegExp;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2927,12 +2927,12 @@ date_toString_impl(JSContext* cx, const CallArgs& args)
|
||||
RootedObject obj(cx, &args.thisv().toObject());
|
||||
|
||||
// Step 2.
|
||||
ESClassValue cls;
|
||||
ESClass cls;
|
||||
if (!GetBuiltinClass(cx, obj, &cls))
|
||||
return false;
|
||||
|
||||
double tv;
|
||||
if (cls != ESClass_Date) {
|
||||
if (cls != ESClass::Date) {
|
||||
// Step 2.
|
||||
tv = GenericNaN();
|
||||
} else {
|
||||
@ -3108,11 +3108,11 @@ DateOneArgument(JSContext* cx, const CallArgs& args)
|
||||
if (args[0].isObject()) {
|
||||
RootedObject obj(cx, &args[0].toObject());
|
||||
|
||||
ESClassValue cls;
|
||||
ESClass cls;
|
||||
if (!GetBuiltinClass(cx, obj, &cls))
|
||||
return false;
|
||||
|
||||
if (cls == ESClass_Date) {
|
||||
if (cls == ESClass::Date) {
|
||||
RootedValue unboxed(cx);
|
||||
if (!Unbox(cx, obj, &unboxed))
|
||||
return false;
|
||||
@ -3319,11 +3319,11 @@ js::NewDateObject(JSContext* cx, int year, int mon, int mday,
|
||||
JS_FRIEND_API(bool)
|
||||
js::DateIsValid(JSContext* cx, HandleObject obj, bool* isValid)
|
||||
{
|
||||
ESClassValue cls;
|
||||
ESClass cls;
|
||||
if (!GetBuiltinClass(cx, obj, &cls))
|
||||
return false;
|
||||
|
||||
if (cls != ESClass_Date) {
|
||||
if (cls != ESClass::Date) {
|
||||
*isValid = false;
|
||||
return true;
|
||||
}
|
||||
@ -3339,11 +3339,11 @@ js::DateIsValid(JSContext* cx, HandleObject obj, bool* isValid)
|
||||
JS_FRIEND_API(bool)
|
||||
js::DateGetMsecSinceEpoch(JSContext* cx, HandleObject obj, double* msecsSinceEpoch)
|
||||
{
|
||||
ESClassValue cls;
|
||||
ESClass cls;
|
||||
if (!GetBuiltinClass(cx, obj, &cls))
|
||||
return false;
|
||||
|
||||
if (cls != ESClass_Date) {
|
||||
if (cls != ESClass::Date) {
|
||||
*msecsSinceEpoch = 0;
|
||||
return true;
|
||||
}
|
||||
|
@ -1022,13 +1022,13 @@ js::ValueToSourceForError(JSContext* cx, HandleValue val, JSAutoByteString& byte
|
||||
StringBuffer sb(cx);
|
||||
if (val.isObject()) {
|
||||
RootedObject valObj(cx, val.toObjectOrNull());
|
||||
ESClassValue cls;
|
||||
ESClass cls;
|
||||
if (!GetBuiltinClass(cx, valObj, &cls))
|
||||
return "<<error determining class of value>>";
|
||||
const char* s;
|
||||
if (cls == ESClass_Array)
|
||||
if (cls == ESClass::Array)
|
||||
s = "the array ";
|
||||
else if (cls == ESClass_ArrayBuffer)
|
||||
else if (cls == ESClass::ArrayBuffer)
|
||||
s = "the array buffer ";
|
||||
else if (JS_IsArrayBufferViewObject(valObj))
|
||||
s = "the typed array ";
|
||||
|
@ -266,41 +266,45 @@ JS_DefineFunctionsWithHelp(JSContext* cx, HandleObject obj, const JSFunctionSpec
|
||||
}
|
||||
|
||||
JS_FRIEND_API(bool)
|
||||
js::GetBuiltinClass(JSContext* cx, HandleObject obj, ESClassValue* classValue)
|
||||
js::GetBuiltinClass(JSContext* cx, HandleObject obj, ESClass* cls)
|
||||
{
|
||||
if (MOZ_UNLIKELY(obj->is<ProxyObject>()))
|
||||
return Proxy::getBuiltinClass(cx, obj, classValue);
|
||||
return Proxy::getBuiltinClass(cx, obj, cls);
|
||||
|
||||
if (obj->is<PlainObject>() || obj->is<UnboxedPlainObject>())
|
||||
*classValue = ESClass_Object;
|
||||
*cls = ESClass::Object;
|
||||
else if (obj->is<ArrayObject>() || obj->is<UnboxedArrayObject>())
|
||||
*classValue = ESClass_Array;
|
||||
*cls = ESClass::Array;
|
||||
else if (obj->is<NumberObject>())
|
||||
*classValue = ESClass_Number;
|
||||
*cls = ESClass::Number;
|
||||
else if (obj->is<StringObject>())
|
||||
*classValue = ESClass_String;
|
||||
*cls = ESClass::String;
|
||||
else if (obj->is<BooleanObject>())
|
||||
*classValue = ESClass_Boolean;
|
||||
*cls = ESClass::Boolean;
|
||||
else if (obj->is<RegExpObject>())
|
||||
*classValue = ESClass_RegExp;
|
||||
*cls = ESClass::RegExp;
|
||||
else if (obj->is<ArrayBufferObject>())
|
||||
*classValue = ESClass_ArrayBuffer;
|
||||
*cls = ESClass::ArrayBuffer;
|
||||
else if (obj->is<SharedArrayBufferObject>())
|
||||
*classValue = ESClass_SharedArrayBuffer;
|
||||
*cls = ESClass::SharedArrayBuffer;
|
||||
else if (obj->is<DateObject>())
|
||||
*classValue = ESClass_Date;
|
||||
*cls = ESClass::Date;
|
||||
else if (obj->is<SetObject>())
|
||||
*classValue = ESClass_Set;
|
||||
*cls = ESClass::Set;
|
||||
else if (obj->is<MapObject>())
|
||||
*classValue = ESClass_Map;
|
||||
*cls = ESClass::Map;
|
||||
else if (obj->is<PromiseObject>())
|
||||
*classValue = ESClass_Promise;
|
||||
*cls = ESClass::Promise;
|
||||
else if (obj->is<MapIteratorObject>())
|
||||
*classValue = ESClass_MapIterator;
|
||||
*cls = ESClass::MapIterator;
|
||||
else if (obj->is<SetIteratorObject>())
|
||||
*classValue = ESClass_SetIterator;
|
||||
*cls = ESClass::SetIterator;
|
||||
else if (obj->is<ArgumentsObject>())
|
||||
*cls = ESClass::Arguments;
|
||||
else if (obj->is<ErrorObject>())
|
||||
*cls = ESClass::Error;
|
||||
else
|
||||
*classValue = ESClass_Other;
|
||||
*cls = ESClass::Other;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ JS_BasicObjectToString(JSContext* cx, JS::HandleObject obj);
|
||||
namespace js {
|
||||
|
||||
JS_FRIEND_API(bool)
|
||||
GetBuiltinClass(JSContext* cx, JS::HandleObject obj, ESClassValue* classValue);
|
||||
GetBuiltinClass(JSContext* cx, JS::HandleObject obj, ESClass* cls);
|
||||
|
||||
JS_FRIEND_API(const char*)
|
||||
ObjectClassName(JSContext* cx, JS::HandleObject obj);
|
||||
|
@ -810,19 +810,19 @@ GuessArrayGCKind(size_t numElements)
|
||||
return gc::AllocKind::OBJECT8;
|
||||
}
|
||||
|
||||
// Returns ESClass_Other if the value isn't an object, or if the object
|
||||
// Returns ESClass::Other if the value isn't an object, or if the object
|
||||
// isn't of one of the enumerated classes. Otherwise returns the appropriate
|
||||
// class.
|
||||
inline bool
|
||||
GetClassOfValue(JSContext* cx, HandleValue v, ESClassValue* classValue)
|
||||
GetClassOfValue(JSContext* cx, HandleValue v, ESClass* cls)
|
||||
{
|
||||
if (!v.isObject()) {
|
||||
*classValue = ESClass_Other;
|
||||
*cls = ESClass::Other;
|
||||
return true;
|
||||
}
|
||||
|
||||
RootedObject obj(cx, &v.toObject());
|
||||
return GetBuiltinClass(cx, obj, classValue);
|
||||
return GetBuiltinClass(cx, obj, cls);
|
||||
}
|
||||
|
||||
extern NativeObject*
|
||||
|
@ -261,21 +261,21 @@ PreprocessValue(JSContext* cx, HandleObject holder, KeyType key, MutableHandleVa
|
||||
if (vp.get().isObject()) {
|
||||
RootedObject obj(cx, &vp.get().toObject());
|
||||
|
||||
ESClassValue cls;
|
||||
ESClass cls;
|
||||
if (!GetBuiltinClass(cx, obj, &cls))
|
||||
return false;
|
||||
|
||||
if (cls == ESClass_Number) {
|
||||
if (cls == ESClass::Number) {
|
||||
double d;
|
||||
if (!ToNumber(cx, vp, &d))
|
||||
return false;
|
||||
vp.setNumber(d);
|
||||
} else if (cls == ESClass_String) {
|
||||
} else if (cls == ESClass::String) {
|
||||
JSString* str = ToStringSlow<CanGC>(cx, vp);
|
||||
if (!str)
|
||||
return false;
|
||||
vp.setString(str);
|
||||
} else if (cls == ESClass_Boolean) {
|
||||
} else if (cls == ESClass::Boolean) {
|
||||
if (!Unbox(cx, obj, vp))
|
||||
return false;
|
||||
}
|
||||
@ -657,11 +657,11 @@ js::Stringify(JSContext* cx, MutableHandleValue vp, JSObject* replacer_, Value s
|
||||
} else {
|
||||
bool shouldAdd = item.isString();
|
||||
if (!shouldAdd) {
|
||||
ESClassValue cls;
|
||||
ESClass cls;
|
||||
if (!GetClassOfValue(cx, item, &cls))
|
||||
return false;
|
||||
|
||||
shouldAdd = cls == ESClass_String || cls == ESClass_Number;
|
||||
shouldAdd = cls == ESClass::String || cls == ESClass::Number;
|
||||
}
|
||||
|
||||
if (shouldAdd) {
|
||||
@ -691,16 +691,16 @@ js::Stringify(JSContext* cx, MutableHandleValue vp, JSObject* replacer_, Value s
|
||||
if (space.isObject()) {
|
||||
RootedObject spaceObj(cx, &space.toObject());
|
||||
|
||||
ESClassValue cls;
|
||||
ESClass cls;
|
||||
if (!GetBuiltinClass(cx, spaceObj, &cls))
|
||||
return false;
|
||||
|
||||
if (cls == ESClass_Number) {
|
||||
if (cls == ESClass::Number) {
|
||||
double d;
|
||||
if (!ToNumber(cx, space, &d))
|
||||
return false;
|
||||
space = NumberValue(d);
|
||||
} else if (cls == ESClass_String) {
|
||||
} else if (cls == ESClass::String) {
|
||||
JSString* str = ToStringSlow<CanGC>(cx, space);
|
||||
if (!str)
|
||||
return false;
|
||||
|
@ -111,8 +111,7 @@ class JS_FRIEND_API(Wrapper) : public BaseProxyHandler
|
||||
const CallArgs& args) const override;
|
||||
virtual bool hasInstance(JSContext* cx, HandleObject proxy, MutableHandleValue v,
|
||||
bool* bp) const override;
|
||||
virtual bool getBuiltinClass(JSContext* cx, HandleObject proxy,
|
||||
ESClassValue* classValue) const override;
|
||||
virtual bool getBuiltinClass(JSContext* cx, HandleObject proxy, ESClass* cls) const override;
|
||||
virtual bool isArray(JSContext* cx, HandleObject proxy,
|
||||
JS::IsArrayAnswer* answer) const override;
|
||||
virtual const char* className(JSContext* cx, HandleObject proxy) const override;
|
||||
@ -265,8 +264,7 @@ class JS_FRIEND_API(OpaqueCrossCompartmentWrapper) : public CrossCompartmentWrap
|
||||
bool* bp) const override;
|
||||
virtual bool getOwnEnumerablePropertyKeys(JSContext* cx, HandleObject wrapper,
|
||||
AutoIdVector& props) const override;
|
||||
virtual bool getBuiltinClass(JSContext* cx, HandleObject wrapper,
|
||||
ESClassValue* classValue) const override;
|
||||
virtual bool getBuiltinClass(JSContext* cx, HandleObject wrapper, ESClass* cls) const override;
|
||||
virtual bool isArray(JSContext* cx, HandleObject obj,
|
||||
JS::IsArrayAnswer* answer) const override;
|
||||
virtual const char* className(JSContext* cx, HandleObject wrapper) const override;
|
||||
@ -307,8 +305,7 @@ class JS_FRIEND_API(SecurityWrapper) : public Base
|
||||
|
||||
virtual bool nativeCall(JSContext* cx, IsAcceptableThis test, NativeImpl impl,
|
||||
const CallArgs& args) const override;
|
||||
virtual bool getBuiltinClass(JSContext* cx, HandleObject wrapper,
|
||||
ESClassValue* classValue) const override;
|
||||
virtual bool getBuiltinClass(JSContext* cx, HandleObject wrapper, ESClass* cls) const override;
|
||||
virtual bool isArray(JSContext* cx, HandleObject wrapper, JS::IsArrayAnswer* answer) const override;
|
||||
virtual bool regexp_toShared(JSContext* cx, HandleObject proxy, RegExpGuard* g) const override;
|
||||
virtual bool boxedValue_unbox(JSContext* cx, HandleObject proxy, MutableHandleValue vp) const override;
|
||||
|
@ -359,10 +359,9 @@ BaseProxyHandler::hasInstance(JSContext* cx, HandleObject proxy, MutableHandleVa
|
||||
}
|
||||
|
||||
bool
|
||||
BaseProxyHandler::getBuiltinClass(JSContext* cx, HandleObject proxy,
|
||||
ESClassValue* classValue) const
|
||||
BaseProxyHandler::getBuiltinClass(JSContext* cx, HandleObject proxy, ESClass* cls) const
|
||||
{
|
||||
*classValue = ESClass_Other;
|
||||
*cls = ESClass::Other;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -115,8 +115,7 @@ DeadObjectProxy::hasInstance(JSContext* cx, HandleObject proxy, MutableHandleVal
|
||||
}
|
||||
|
||||
bool
|
||||
DeadObjectProxy::getBuiltinClass(JSContext* cx, HandleObject proxy,
|
||||
ESClassValue* classValue) const
|
||||
DeadObjectProxy::getBuiltinClass(JSContext* cx, HandleObject proxy, ESClass* cls) const
|
||||
{
|
||||
ReportDead(cx);
|
||||
return false;
|
||||
|
@ -45,8 +45,7 @@ class DeadObjectProxy : public BaseProxyHandler
|
||||
const CallArgs& args) const override;
|
||||
virtual bool hasInstance(JSContext* cx, HandleObject proxy, MutableHandleValue v,
|
||||
bool* bp) const override;
|
||||
virtual bool getBuiltinClass(JSContext* cx, HandleObject proxy,
|
||||
ESClassValue* classValue) const override;
|
||||
virtual bool getBuiltinClass(JSContext* cx, HandleObject proxy, ESClass* cls) const override;
|
||||
virtual bool isArray(JSContext* cx, HandleObject proxy, JS::IsArrayAnswer* answer) const override;
|
||||
virtual const char* className(JSContext* cx, HandleObject proxy) const override;
|
||||
virtual JSString* fun_toString(JSContext* cx, HandleObject proxy, unsigned indent) const override;
|
||||
|
@ -161,9 +161,9 @@ OpaqueCrossCompartmentWrapper::getOwnEnumerablePropertyKeys(JSContext* cx, Handl
|
||||
|
||||
bool
|
||||
OpaqueCrossCompartmentWrapper::getBuiltinClass(JSContext* cx, HandleObject wrapper,
|
||||
ESClassValue* classValue) const
|
||||
ESClass* cls) const
|
||||
{
|
||||
*classValue = ESClass_Other;
|
||||
*cls = ESClass::Other;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -444,10 +444,10 @@ Proxy::hasInstance(JSContext* cx, HandleObject proxy, MutableHandleValue v, bool
|
||||
}
|
||||
|
||||
bool
|
||||
Proxy::getBuiltinClass(JSContext* cx, HandleObject proxy, ESClassValue* classValue)
|
||||
Proxy::getBuiltinClass(JSContext* cx, HandleObject proxy, ESClass* cls)
|
||||
{
|
||||
JS_CHECK_RECURSION(cx, return false);
|
||||
return proxy->as<ProxyObject>().handler()->getBuiltinClass(cx, proxy, classValue);
|
||||
return proxy->as<ProxyObject>().handler()->getBuiltinClass(cx, proxy, cls);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -58,7 +58,7 @@ class Proxy
|
||||
static bool nativeCall(JSContext* cx, IsAcceptableThis test, NativeImpl impl,
|
||||
const CallArgs& args);
|
||||
static bool hasInstance(JSContext* cx, HandleObject proxy, MutableHandleValue v, bool* bp);
|
||||
static bool getBuiltinClass(JSContext* cx, HandleObject proxy, ESClassValue* classValue);
|
||||
static bool getBuiltinClass(JSContext* cx, HandleObject proxy, ESClass* cls);
|
||||
static bool isArray(JSContext* cx, HandleObject proxy, JS::IsArrayAnswer* answer);
|
||||
static const char* className(JSContext* cx, HandleObject proxy);
|
||||
static JSString* fun_toString(JSContext* cx, HandleObject proxy, unsigned indent);
|
||||
|
@ -1240,9 +1240,9 @@ ScriptedProxyHandler::hasInstance(JSContext* cx, HandleObject proxy, MutableHand
|
||||
|
||||
bool
|
||||
ScriptedProxyHandler::getBuiltinClass(JSContext* cx, HandleObject proxy,
|
||||
ESClassValue* classValue) const
|
||||
ESClass* cls) const
|
||||
{
|
||||
*classValue = ESClass_Other;
|
||||
*cls = ESClass::Other;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -63,8 +63,7 @@ class ScriptedProxyHandler : public BaseProxyHandler
|
||||
const CallArgs& args) const override;
|
||||
virtual bool hasInstance(JSContext* cx, HandleObject proxy, MutableHandleValue v,
|
||||
bool* bp) const override;
|
||||
virtual bool getBuiltinClass(JSContext* cx, HandleObject proxy,
|
||||
ESClassValue* classValue) const override;
|
||||
virtual bool getBuiltinClass(JSContext* cx, HandleObject proxy, ESClass* cls) const override;
|
||||
virtual bool isArray(JSContext* cx, HandleObject proxy,
|
||||
JS::IsArrayAnswer* answer) const override;
|
||||
virtual const char* className(JSContext* cx, HandleObject proxy) const override;
|
||||
|
@ -77,9 +77,9 @@ SecurityWrapper<Base>::isExtensible(JSContext* cx, HandleObject wrapper, bool* e
|
||||
template <class Base>
|
||||
bool
|
||||
SecurityWrapper<Base>::getBuiltinClass(JSContext* cx, HandleObject wrapper,
|
||||
ESClassValue* classValue) const
|
||||
ESClass* cls) const
|
||||
{
|
||||
*classValue = ESClass_Other;
|
||||
*cls = ESClass::Other;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -238,10 +238,10 @@ Wrapper::hasInstance(JSContext* cx, HandleObject proxy, MutableHandleValue v,
|
||||
}
|
||||
|
||||
bool
|
||||
Wrapper::getBuiltinClass(JSContext* cx, HandleObject proxy, ESClassValue* classValue) const
|
||||
Wrapper::getBuiltinClass(JSContext* cx, HandleObject proxy, ESClass* cls) const
|
||||
{
|
||||
RootedObject target(cx, proxy->as<ProxyObject>().target());
|
||||
return GetBuiltinClass(cx, target, classValue);
|
||||
return GetBuiltinClass(cx, target, cls);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -509,7 +509,7 @@ class RegExpObject : public NativeObject
|
||||
bool
|
||||
ParseRegExpFlags(JSContext* cx, JSString* flagStr, RegExpFlag* flagsOut);
|
||||
|
||||
/* Assuming GetBuiltinClass(obj) is ESClass_RegExp, return a RegExpShared for obj. */
|
||||
/* Assuming GetBuiltinClass(obj) is ESClass::RegExp, return a RegExpShared for obj. */
|
||||
inline bool
|
||||
RegExpToShared(JSContext* cx, HandleObject obj, RegExpGuard* g)
|
||||
{
|
||||
|
@ -1005,10 +1005,10 @@ JSStructuredCloneWriter::traverseObject(HandleObject obj)
|
||||
checkStack();
|
||||
|
||||
/* Write the header for obj. */
|
||||
ESClassValue cls;
|
||||
ESClass cls;
|
||||
if (!GetBuiltinClass(context(), obj, &cls))
|
||||
return false;
|
||||
return out.writePair(cls == ESClass_Array ? SCTAG_ARRAY_OBJECT : SCTAG_OBJECT_OBJECT, 0);
|
||||
return out.writePair(cls == ESClass::Array ? SCTAG_ARRAY_OBJECT : SCTAG_OBJECT_OBJECT, 0);
|
||||
}
|
||||
|
||||
bool
|
||||
@ -1194,17 +1194,17 @@ JSStructuredCloneWriter::startWrite(HandleValue v)
|
||||
if (backref)
|
||||
return true;
|
||||
|
||||
ESClassValue cls;
|
||||
ESClass cls;
|
||||
if (!GetBuiltinClass(context(), obj, &cls))
|
||||
return false;
|
||||
|
||||
if (cls == ESClass_RegExp) {
|
||||
if (cls == ESClass::RegExp) {
|
||||
RegExpGuard re(context());
|
||||
if (!RegExpToShared(context(), obj, &re))
|
||||
return false;
|
||||
return out.writePair(SCTAG_REGEXP_OBJECT, re->getFlags()) &&
|
||||
writeString(SCTAG_STRING, re->getSource());
|
||||
} else if (cls == ESClass_Date) {
|
||||
} else if (cls == ESClass::Date) {
|
||||
RootedValue unboxed(context());
|
||||
if (!Unbox(context(), obj, &unboxed))
|
||||
return false;
|
||||
@ -1217,28 +1217,28 @@ JSStructuredCloneWriter::startWrite(HandleValue v)
|
||||
return writeArrayBuffer(obj);
|
||||
} else if (JS_IsSharedArrayBufferObject(obj)) {
|
||||
return writeSharedArrayBuffer(obj);
|
||||
} else if (cls == ESClass_Object) {
|
||||
} else if (cls == ESClass::Object) {
|
||||
return traverseObject(obj);
|
||||
} else if (cls == ESClass_Array) {
|
||||
} else if (cls == ESClass::Array) {
|
||||
return traverseObject(obj);
|
||||
} else if (cls == ESClass_Boolean) {
|
||||
} else if (cls == ESClass::Boolean) {
|
||||
RootedValue unboxed(context());
|
||||
if (!Unbox(context(), obj, &unboxed))
|
||||
return false;
|
||||
return out.writePair(SCTAG_BOOLEAN_OBJECT, unboxed.toBoolean());
|
||||
} else if (cls == ESClass_Number) {
|
||||
} else if (cls == ESClass::Number) {
|
||||
RootedValue unboxed(context());
|
||||
if (!Unbox(context(), obj, &unboxed))
|
||||
return false;
|
||||
return out.writePair(SCTAG_NUMBER_OBJECT, 0) && out.writeDouble(unboxed.toNumber());
|
||||
} else if (cls == ESClass_String) {
|
||||
} else if (cls == ESClass::String) {
|
||||
RootedValue unboxed(context());
|
||||
if (!Unbox(context(), obj, &unboxed))
|
||||
return false;
|
||||
return writeString(SCTAG_STRING_OBJECT, unboxed.toString());
|
||||
} else if (cls == ESClass_Map) {
|
||||
} else if (cls == ESClass::Map) {
|
||||
return traverseMap(obj);
|
||||
} else if (cls == ESClass_Set) {
|
||||
} else if (cls == ESClass::Set) {
|
||||
return traverseSet(obj);
|
||||
} else if (SavedFrame::isSavedFrameOrWrapperAndNotProto(*obj)) {
|
||||
return traverseSavedFrame(obj);
|
||||
@ -1314,11 +1314,11 @@ JSStructuredCloneWriter::transferOwnership()
|
||||
MOZ_ASSERT(ownership == JS::SCTAG_TMO_UNFILLED);
|
||||
#endif
|
||||
|
||||
ESClassValue cls;
|
||||
ESClass cls;
|
||||
if (!GetBuiltinClass(context(), obj, &cls))
|
||||
return false;
|
||||
|
||||
if (cls == ESClass_ArrayBuffer) {
|
||||
if (cls == ESClass::ArrayBuffer) {
|
||||
// The current setup of the array buffer inheritance hierarchy doesn't
|
||||
// lend itself well to generic manipulation via proxies.
|
||||
Rooted<ArrayBufferObject*> arrayBuffer(context(), &CheckedUnwrap(obj)->as<ArrayBufferObject>());
|
||||
@ -1341,7 +1341,7 @@ JSStructuredCloneWriter::transferOwnership()
|
||||
else
|
||||
ownership = JS::SCTAG_TMO_ALLOC_DATA;
|
||||
extraData = nbytes;
|
||||
} else if (cls == ESClass_SharedArrayBuffer) {
|
||||
} else if (cls == ESClass::SharedArrayBuffer) {
|
||||
Rooted<SharedArrayBufferObject*> sharedArrayBuffer(context(), &CheckedUnwrap(obj)->as<SharedArrayBufferObject>());
|
||||
SharedArrayRawBuffer* rawbuf = sharedArrayBuffer->rawBufferObject();
|
||||
|
||||
@ -1388,11 +1388,11 @@ JSStructuredCloneWriter::write(HandleValue v)
|
||||
entries.popBack();
|
||||
checkStack();
|
||||
|
||||
ESClassValue cls;
|
||||
ESClass cls;
|
||||
if (!GetBuiltinClass(context(), obj, &cls))
|
||||
return false;
|
||||
|
||||
if (cls == ESClass_Map) {
|
||||
if (cls == ESClass::Map) {
|
||||
counts.back()--;
|
||||
RootedValue val(context(), entries.back());
|
||||
entries.popBack();
|
||||
@ -1400,7 +1400,7 @@ JSStructuredCloneWriter::write(HandleValue v)
|
||||
|
||||
if (!startWrite(key) || !startWrite(val))
|
||||
return false;
|
||||
} else if (cls == ESClass_Set || SavedFrame::isSavedFrameOrWrapperAndNotProto(*obj)) {
|
||||
} else if (cls == ESClass::Set || SavedFrame::isSavedFrameOrWrapperAndNotProto(*obj)) {
|
||||
if (!startWrite(key))
|
||||
return false;
|
||||
} else {
|
||||
|
@ -532,10 +532,10 @@ class TypedArrayObjectTemplate : public TypedArrayObject
|
||||
fromBufferWithProto(JSContext* cx, HandleObject bufobj, uint32_t byteOffset, int32_t lengthInt,
|
||||
HandleObject proto)
|
||||
{
|
||||
ESClassValue cls;
|
||||
ESClass cls;
|
||||
if (!GetBuiltinClass(cx, bufobj, &cls))
|
||||
return nullptr;
|
||||
if (cls != ESClass_ArrayBuffer && cls != ESClass_SharedArrayBuffer) {
|
||||
if (cls != ESClass::ArrayBuffer && cls != ESClass::SharedArrayBuffer) {
|
||||
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_BAD_ARGS);
|
||||
return nullptr;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user