This commit is contained in:
Luke Wagner 2010-05-26 16:39:20 -07:00
commit 824169c8ae
12 changed files with 157 additions and 157 deletions

View File

@ -89,17 +89,17 @@ namespace CType {
static void Finalize(JSContext* cx, JSObject* obj);
static void FinalizeProtoClass(JSContext* cx, JSObject* obj);
static JSBool PrototypeGetter(JSContext* cx, JSObject* obj, jsval idval,
static JSBool PrototypeGetter(JSContext* cx, JSObject* obj, jsid idval,
jsval* vp);
static JSBool NameGetter(JSContext* cx, JSObject* obj, jsval idval,
static JSBool NameGetter(JSContext* cx, JSObject* obj, jsid idval,
jsval* vp);
static JSBool SizeGetter(JSContext* cx, JSObject* obj, jsval idval,
static JSBool SizeGetter(JSContext* cx, JSObject* obj, jsid idval,
jsval* vp);
static JSBool PtrGetter(JSContext* cx, JSObject* obj, jsval idval, jsval* vp);
static JSBool PtrGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp);
static JSBool CreateArray(JSContext* cx, uintN argc, jsval* vp);
static JSBool ToString(JSContext* cx, uintN argc, jsval* vp);
static JSBool ToSource(JSContext* cx, uintN argc, jsval* vp);
static JSBool HasInstance(JSContext* cx, JSObject* obj, jsval v, JSBool* bp);
static JSBool HasInstance(JSContext* cx, JSObject* obj, const jsval* vp, JSBool* bp);
}
namespace PointerType {
@ -107,11 +107,11 @@ namespace PointerType {
static JSBool ConstructData(JSContext* cx, JSObject* obj, uintN argc,
jsval* argv, jsval* rval);
static JSBool TargetTypeGetter(JSContext* cx, JSObject* obj, jsval idval,
static JSBool TargetTypeGetter(JSContext* cx, JSObject* obj, jsid idval,
jsval* vp);
static JSBool ContentsGetter(JSContext* cx, JSObject* obj, jsval idval,
static JSBool ContentsGetter(JSContext* cx, JSObject* obj, jsid idval,
jsval* vp);
static JSBool ContentsSetter(JSContext* cx, JSObject* obj, jsval idval,
static JSBool ContentsSetter(JSContext* cx, JSObject* obj, jsid idval,
jsval* vp);
static JSBool IsNull(JSContext* cx, uintN argc, jsval* vp);
}
@ -121,12 +121,12 @@ namespace ArrayType {
static JSBool ConstructData(JSContext* cx, JSObject* obj, uintN argc,
jsval* argv, jsval* rval);
static JSBool ElementTypeGetter(JSContext* cx, JSObject* obj, jsval idval,
static JSBool ElementTypeGetter(JSContext* cx, JSObject* obj, jsid idval,
jsval* vp);
static JSBool LengthGetter(JSContext* cx, JSObject* obj, jsval idval,
static JSBool LengthGetter(JSContext* cx, JSObject* obj, jsid idval,
jsval* vp);
static JSBool Getter(JSContext* cx, JSObject* obj, jsval idval, jsval* vp);
static JSBool Setter(JSContext* cx, JSObject* obj, jsval idval, jsval* vp);
static JSBool Getter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp);
static JSBool Setter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp);
static JSBool AddressOfElement(JSContext* cx, uintN argc, jsval* vp);
}
@ -135,11 +135,11 @@ namespace StructType {
static JSBool ConstructData(JSContext* cx, JSObject* obj, uintN argc,
jsval* argv, jsval* rval);
static JSBool FieldsArrayGetter(JSContext* cx, JSObject* obj, jsval idval,
static JSBool FieldsArrayGetter(JSContext* cx, JSObject* obj, jsid idval,
jsval* vp);
static JSBool FieldGetter(JSContext* cx, JSObject* obj, jsval idval,
static JSBool FieldGetter(JSContext* cx, JSObject* obj, jsid idval,
jsval* vp);
static JSBool FieldSetter(JSContext* cx, JSObject* obj, jsval idval,
static JSBool FieldSetter(JSContext* cx, JSObject* obj, jsid idval,
jsval* vp);
static JSBool AddressOfField(JSContext* cx, uintN argc, jsval* vp);
static JSBool Define(JSContext* cx, uintN argc, jsval* vp);
@ -153,12 +153,12 @@ namespace FunctionType {
static JSBool Call(JSContext* cx, JSObject* obj, uintN argc, jsval* argv,
jsval* rval);
static JSBool ArgTypesGetter(JSContext* cx, JSObject* obj, jsval idval,
static JSBool ArgTypesGetter(JSContext* cx, JSObject* obj, jsid idval,
jsval* vp);
static JSBool ReturnTypeGetter(JSContext* cx, JSObject* obj, jsval idval,
static JSBool ReturnTypeGetter(JSContext* cx, JSObject* obj, jsid idval,
jsval* vp);
static JSBool ABIGetter(JSContext* cx, JSObject* obj, jsval idval, jsval* vp);
static JSBool IsVariadicGetter(JSContext* cx, JSObject* obj, jsval idval,
static JSBool ABIGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp);
static JSBool IsVariadicGetter(JSContext* cx, JSObject* obj, jsid idval,
jsval* vp);
}
@ -174,9 +174,9 @@ namespace CClosure {
namespace CData {
static void Finalize(JSContext* cx, JSObject* obj);
static JSBool ValueGetter(JSContext* cx, JSObject* obj, jsval idval,
static JSBool ValueGetter(JSContext* cx, JSObject* obj, jsid idval,
jsval* vp);
static JSBool ValueSetter(JSContext* cx, JSObject* obj, jsval idval,
static JSBool ValueSetter(JSContext* cx, JSObject* obj, jsid idval,
jsval* vp);
static JSBool Address(JSContext* cx, uintN argc, jsval* vp);
static JSBool ReadString(JSContext* cx, uintN argc, jsval* vp);
@ -514,7 +514,7 @@ JSBool
TypeError(JSContext* cx, const char* expected, jsval actual)
{
JSString* str = JS_ValueToSource(cx, actual);
js::AutoValueRooter root(cx, str);
js::AutoStringRooter root(cx, str);
const char* src;
if (str) {
@ -682,7 +682,7 @@ InitTypeConstructor(JSContext* cx,
dataProto = JS_NewObject(cx, &sCDataProtoClass, CDataProto, parent);
if (!dataProto)
return false;
js::AutoValueRooter protoroot(cx, dataProto);
js::AutoObjectRooter protoroot(cx, dataProto);
// Define functions and properties on the 'dataProto' object that are common
// to all CData objects created from this type constructor. (These will
@ -816,27 +816,27 @@ InitTypeClasses(JSContext* cx, JSObject* parent)
sPointerInstanceFunctions, sPointerInstanceProps,
protos[SLOT_POINTERPROTO], protos[SLOT_POINTERDATAPROTO]))
return false;
js::AutoValueRooter proot(cx, protos[SLOT_POINTERDATAPROTO]);
js::AutoObjectRooter proot(cx, protos[SLOT_POINTERDATAPROTO]);
if (!InitTypeConstructor(cx, parent, CTypeProto, CDataProto,
sArrayFunction, NULL, sArrayProps,
sArrayInstanceFunctions, sArrayInstanceProps,
protos[SLOT_ARRAYPROTO], protos[SLOT_ARRAYDATAPROTO]))
return false;
js::AutoValueRooter aroot(cx, protos[SLOT_ARRAYDATAPROTO]);
js::AutoObjectRooter aroot(cx, protos[SLOT_ARRAYDATAPROTO]);
if (!InitTypeConstructor(cx, parent, CTypeProto, CDataProto,
sStructFunction, sStructFunctions, sStructProps,
sStructInstanceFunctions, NULL,
protos[SLOT_STRUCTPROTO], protos[SLOT_STRUCTDATAPROTO]))
return false;
js::AutoValueRooter sroot(cx, protos[SLOT_STRUCTDATAPROTO]);
js::AutoObjectRooter sroot(cx, protos[SLOT_STRUCTDATAPROTO]);
if (!InitTypeConstructor(cx, parent, CTypeProto, CDataProto,
sFunctionFunction, NULL, sFunctionProps, NULL, NULL,
protos[SLOT_FUNCTIONPROTO], protos[SLOT_FUNCTIONDATAPROTO]))
return false;
js::AutoValueRooter froot(cx, protos[SLOT_FUNCTIONDATAPROTO]);
js::AutoObjectRooter froot(cx, protos[SLOT_FUNCTIONDATAPROTO]);
protos[SLOT_CDATAPROTO] = CDataProto;
@ -1105,7 +1105,7 @@ jsvalToBool(JSContext* cx, jsval val, bool* result)
return i == 0 || i == 1;
}
if (JSVAL_IS_DOUBLE(val)) {
jsdouble d = *JSVAL_TO_DOUBLE(val);
jsdouble d = JSVAL_TO_DOUBLE(val);
*result = d != 0;
// Allow -0.
return d == 1 || d == 0;
@ -1132,7 +1132,7 @@ jsvalToInteger(JSContext* cx, jsval val, IntegerType* result)
if (JSVAL_IS_DOUBLE(val)) {
// Don't silently lose bits here -- check that val really is an
// integer value, and has the right sign.
jsdouble d = *JSVAL_TO_DOUBLE(val);
jsdouble d = JSVAL_TO_DOUBLE(val);
return ConvertExact(d, result);
}
if (!JSVAL_IS_PRIMITIVE(val)) {
@ -1213,7 +1213,7 @@ jsvalToFloat(JSContext *cx, jsval val, FloatType* result)
return true;
}
if (JSVAL_IS_DOUBLE(val)) {
*result = FloatType(*JSVAL_TO_DOUBLE(val));
*result = FloatType(JSVAL_TO_DOUBLE(val));
return true;
}
if (!JSVAL_IS_PRIMITIVE(val)) {
@ -1275,7 +1275,7 @@ jsvalToBigInteger(JSContext* cx,
if (JSVAL_IS_DOUBLE(val)) {
// Don't silently lose bits here -- check that val really is an
// integer value, and has the right sign.
jsdouble d = *JSVAL_TO_DOUBLE(val);
jsdouble d = JSVAL_TO_DOUBLE(val);
return ConvertExact(d, result);
}
if (allowString && JSVAL_IS_STRING(val)) {
@ -1338,7 +1338,7 @@ jsvalToIntegerExplicit(JSContext* cx, jsval val, IntegerType* result)
if (JSVAL_IS_DOUBLE(val)) {
// Convert -Inf, Inf, and NaN to 0; otherwise, convert by C-style cast.
jsdouble d = *JSVAL_TO_DOUBLE(val);
jsdouble d = JSVAL_TO_DOUBLE(val);
*result = FloatIsFinite(d) ? IntegerType(d) : 0;
return true;
}
@ -1371,7 +1371,7 @@ jsvalToPtrExplicit(JSContext* cx, jsval val, uintptr_t* result)
return true;
}
if (JSVAL_IS_DOUBLE(val)) {
jsdouble d = *JSVAL_TO_DOUBLE(val);
jsdouble d = JSVAL_TO_DOUBLE(val);
if (d < 0) {
// Cast through an intptr_t intermediate to sign-extend.
intptr_t i = Convert<intptr_t>(d);
@ -1858,11 +1858,11 @@ ImplicitConvert(JSContext* cx,
for (jsuint i = 0; i < sourceLength; ++i) {
js::AutoValueRooter item(cx);
if (!JS_GetElement(cx, sourceArray, i, item.addr()))
if (!JS_GetElement(cx, sourceArray, i, Jsvalify(item.addr())))
return false;
char* data = intermediate.get() + elementSize * i;
if (!ImplicitConvert(cx, item.value(), baseType, data, false, NULL))
if (!ImplicitConvert(cx, Jsvalify(item.value()), baseType, data, false, NULL))
return false;
}
@ -1883,7 +1883,7 @@ ImplicitConvert(JSContext* cx,
JSObject* iter = JS_NewPropertyIterator(cx, obj);
if (!iter)
return false;
js::AutoValueRooter iterroot(cx, iter);
js::AutoObjectRooter iterroot(cx, iter);
// Convert into an intermediate, in case of failure.
size_t structSize = CType::GetSize(cx, targetType);
@ -1902,26 +1902,25 @@ ImplicitConvert(JSContext* cx,
break;
js::AutoValueRooter fieldVal(cx);
if (!JS_IdToValue(cx, id, fieldVal.addr()))
return false;
if (!JSVAL_IS_STRING(fieldVal.value())) {
JS_IdToValue(cx, id, Jsvalify(fieldVal.addr()));
if (!fieldVal.value().isString()) {
JS_ReportError(cx, "property name is not a string");
return false;
}
const FieldInfo* field = StructType::LookupField(cx, targetType,
fieldVal.value());
Jsvalify(fieldVal.value()));
if (!field)
return false;
JSString* name = JSVAL_TO_STRING(fieldVal.value());
JSString* name = fieldVal.value().asString();
js::AutoValueRooter prop(cx);
if (!JS_GetUCProperty(cx, obj, name->chars(), name->length(), prop.addr()))
if (!JS_GetUCProperty(cx, obj, name->chars(), name->length(), Jsvalify(prop.addr())))
return false;
// Convert the field via ImplicitConvert().
char* fieldData = intermediate.get() + field->mOffset;
if (!ImplicitConvert(cx, prop.value(), field->mType, fieldData, false, NULL))
if (!ImplicitConvert(cx, Jsvalify(prop.value()), field->mType, fieldData, false, NULL))
return false;
++i;
@ -1962,7 +1961,7 @@ ExplicitConvert(JSContext* cx, jsval val, JSObject* targetType, void* buffer)
// hard failure (out of memory, or some other similarly serious condition).
// We store any pending exception in case we need to re-throw it.
js::AutoValueRooter ex(cx);
if (!JS_GetPendingException(cx, ex.addr()))
if (!JS_GetPendingException(cx, Jsvalify(ex.addr())))
return false;
// Otherwise, assume soft failure. Clear the pending exception so that we
@ -2010,7 +2009,7 @@ ExplicitConvert(JSContext* cx, jsval val, JSObject* targetType, void* buffer)
case TYPE_array:
case TYPE_struct:
// ImplicitConvert is sufficient. Re-throw the exception it generated.
JS_SetPendingException(cx, ex.value());
JS_SetPendingException(cx, Jsvalify(ex.value()));
return false;
case TYPE_void_t:
case TYPE_function:
@ -2528,7 +2527,7 @@ CType::Create(JSContext* cx,
JSObject* typeObj = JS_NewObject(cx, &sCTypeClass, typeProto, parent);
if (!typeObj)
return NULL;
js::AutoValueRooter root(cx, typeObj);
js::AutoObjectRooter root(cx, typeObj);
// Set up the reserved slots.
if (!JS_SetReservedSlot(cx, typeObj, SLOT_TYPECODE, INT_TO_JSVAL(type)) ||
@ -2543,7 +2542,7 @@ CType::Create(JSContext* cx,
JSObject* prototype = JS_NewObject(cx, &sCDataProtoClass, dataProto, parent);
if (!prototype)
return NULL;
js::AutoValueRooter protoroot(cx, prototype);
js::AutoObjectRooter protoroot(cx, prototype);
if (!JS_DefineProperty(cx, prototype, "constructor", OBJECT_TO_JSVAL(typeObj),
NULL, NULL, JSPROP_READONLY | JSPROP_PERMANENT))
@ -2581,7 +2580,7 @@ CType::DefineBuiltin(JSContext* cx,
JSString* nameStr = JS_NewStringCopyZ(cx, name);
if (!nameStr)
return NULL;
js::AutoValueRooter nameRoot(cx, nameStr);
js::AutoStringRooter nameRoot(cx, nameStr);
// Create a new CType object with the common properties and slots.
JSObject* typeObj = Create(cx, typeProto, dataProto, type, nameStr, size,
@ -2807,7 +2806,7 @@ CType::GetSafeSize(JSContext* cx, JSObject* obj, size_t* result)
return true;
}
if (JSVAL_IS_DOUBLE(size)) {
*result = Convert<size_t>(*JSVAL_TO_DOUBLE(size));
*result = Convert<size_t>(JSVAL_TO_DOUBLE(size));
return true;
}
@ -2830,7 +2829,7 @@ CType::GetSize(JSContext* cx, JSObject* obj)
// For callers who know it can never be JSVAL_VOID, return a size_t directly.
if (JSVAL_IS_INT(size))
return JSVAL_TO_INT(size);
return Convert<size_t>(*JSVAL_TO_DOUBLE(size));
return Convert<size_t>(JSVAL_TO_DOUBLE(size));
}
bool
@ -2943,7 +2942,7 @@ CType::GetProtoFromType(JSContext* cx, JSObject* obj, CTypeProtoSlot slot)
}
JSBool
CType::PrototypeGetter(JSContext* cx, JSObject* obj, jsval idval, jsval* vp)
CType::PrototypeGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
{
if (!CType::IsCType(cx, obj)) {
JS_ReportError(cx, "not a CType");
@ -2956,7 +2955,7 @@ CType::PrototypeGetter(JSContext* cx, JSObject* obj, jsval idval, jsval* vp)
}
JSBool
CType::NameGetter(JSContext* cx, JSObject* obj, jsval idval, jsval* vp)
CType::NameGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
{
if (!CType::IsCType(cx, obj)) {
JS_ReportError(cx, "not a CType");
@ -2972,7 +2971,7 @@ CType::NameGetter(JSContext* cx, JSObject* obj, jsval idval, jsval* vp)
}
JSBool
CType::SizeGetter(JSContext* cx, JSObject* obj, jsval idval, jsval* vp)
CType::SizeGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
{
if (!CType::IsCType(cx, obj)) {
JS_ReportError(cx, "not a CType");
@ -2985,7 +2984,7 @@ CType::SizeGetter(JSContext* cx, JSObject* obj, jsval idval, jsval* vp)
}
JSBool
CType::PtrGetter(JSContext* cx, JSObject* obj, jsval idval, jsval* vp)
CType::PtrGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
{
if (!CType::IsCType(cx, obj)) {
JS_ReportError(cx, "not a CType");
@ -3078,7 +3077,7 @@ CType::ToSource(JSContext* cx, uintN argc, jsval *vp)
}
JSBool
CType::HasInstance(JSContext* cx, JSObject* obj, jsval v, JSBool* bp)
CType::HasInstance(JSContext* cx, JSObject* obj, const jsval* vp, JSBool* bp)
{
JS_ASSERT(CType::IsCType(cx, obj));
@ -3089,10 +3088,10 @@ CType::HasInstance(JSContext* cx, JSObject* obj, jsval v, JSBool* bp)
JS_ASSERT(JS_GET_CLASS(cx, prototype) == &sCDataProtoClass);
*bp = JS_FALSE;
if (JSVAL_IS_PRIMITIVE(v))
if (JSVAL_IS_PRIMITIVE(*vp))
return JS_TRUE;
JSObject* proto = JSVAL_TO_OBJECT(v);
JSObject* proto = JSVAL_TO_OBJECT(*vp);
while ((proto = JS_GetPrototype(cx, proto))) {
if (proto == prototype) {
*bp = JS_TRUE;
@ -3152,7 +3151,7 @@ PointerType::CreateInternal(JSContext* cx, JSObject* baseType)
&ffi_type_pointer);
if (!typeObj)
return NULL;
js::AutoValueRooter root(cx, typeObj);
js::AutoObjectRooter root(cx, typeObj);
// Set the target type. (This will be 'null' for an opaque pointer type.)
if (!JS_SetReservedSlot(cx, typeObj, SLOT_TARGET_T, OBJECT_TO_JSVAL(baseType)))
@ -3237,7 +3236,7 @@ PointerType::GetBaseType(JSContext* cx, JSObject* obj)
JSBool
PointerType::TargetTypeGetter(JSContext* cx,
JSObject* obj,
jsval idval,
jsid idval,
jsval* vp)
{
if (!CType::IsCType(cx, obj) || CType::GetTypeCode(cx, obj) != TYPE_pointer) {
@ -3277,7 +3276,7 @@ PointerType::IsNull(JSContext* cx, uintN argc, jsval* vp)
JSBool
PointerType::ContentsGetter(JSContext* cx,
JSObject* obj,
jsval idval,
jsid idval,
jsval* vp)
{
if (!CData::IsCData(cx, obj)) {
@ -3315,7 +3314,7 @@ PointerType::ContentsGetter(JSContext* cx,
JSBool
PointerType::ContentsSetter(JSContext* cx,
JSObject* obj,
jsval idval,
jsid idval,
jsval* vp)
{
if (!CData::IsCData(cx, obj)) {
@ -3422,7 +3421,7 @@ ArrayType::CreateInternal(JSContext* cx,
sizeVal, INT_TO_JSVAL(align), NULL);
if (!typeObj)
return NULL;
js::AutoValueRooter root(cx, typeObj);
js::AutoObjectRooter root(cx, typeObj);
// Set the element type.
if (!JS_SetReservedSlot(cx, typeObj, SLOT_ELEMENT_T, OBJECT_TO_JSVAL(baseType)))
@ -3477,8 +3476,8 @@ ArrayType::ConstructData(JSContext* cx,
// This could be a JS array, or a CData array.
JSObject* arg = JSVAL_TO_OBJECT(argv[0]);
js::AutoValueRooter lengthVal(cx);
if (!JS_GetProperty(cx, arg, "length", lengthVal.addr()) ||
!jsvalToSize(cx, lengthVal.value(), false, &length)) {
if (!JS_GetProperty(cx, arg, "length", Jsvalify(lengthVal.addr())) ||
!jsvalToSize(cx, Jsvalify(lengthVal.value()), false, &length)) {
JS_ReportError(cx, "argument must be an array object or length");
return JS_FALSE;
}
@ -3521,7 +3520,7 @@ ArrayType::ConstructData(JSContext* cx,
}
// Root the CType object, in case we created one above.
js::AutoValueRooter root(cx, obj);
js::AutoObjectRooter root(cx, obj);
JSObject* result = CData::Create(cx, obj, NULL, NULL, true);
if (!result)
@ -3565,7 +3564,7 @@ ArrayType::GetSafeLength(JSContext* cx, JSObject* obj, size_t* result)
return true;
}
if (JSVAL_IS_DOUBLE(length)) {
*result = Convert<size_t>(*JSVAL_TO_DOUBLE(length));
*result = Convert<size_t>(JSVAL_TO_DOUBLE(length));
return true;
}
@ -3589,7 +3588,7 @@ ArrayType::GetLength(JSContext* cx, JSObject* obj)
// For callers who know it can never be JSVAL_VOID, return a size_t directly.
if (JSVAL_IS_INT(length))
return JSVAL_TO_INT(length);
return Convert<size_t>(*JSVAL_TO_DOUBLE(length));
return Convert<size_t>(JSVAL_TO_DOUBLE(length));
}
ffi_type*
@ -3636,7 +3635,7 @@ ArrayType::BuildFFIType(JSContext* cx, JSObject* obj)
}
JSBool
ArrayType::ElementTypeGetter(JSContext* cx, JSObject* obj, jsval idval, jsval* vp)
ArrayType::ElementTypeGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
{
if (!CType::IsCType(cx, obj) || CType::GetTypeCode(cx, obj) != TYPE_array) {
JS_ReportError(cx, "not an ArrayType");
@ -3649,7 +3648,7 @@ ArrayType::ElementTypeGetter(JSContext* cx, JSObject* obj, jsval idval, jsval* v
}
JSBool
ArrayType::LengthGetter(JSContext* cx, JSObject* obj, jsval idval, jsval* vp)
ArrayType::LengthGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
{
// This getter exists for both CTypes and CDatas of the ArrayType persuasion.
// If we're dealing with a CData, get the CType from it.
@ -3667,7 +3666,7 @@ ArrayType::LengthGetter(JSContext* cx, JSObject* obj, jsval idval, jsval* vp)
}
JSBool
ArrayType::Getter(JSContext* cx, JSObject* obj, jsval idval, jsval* vp)
ArrayType::Getter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
{
// This should never happen, but we'll check to be safe.
if (!CData::IsCData(cx, obj)) {
@ -3702,7 +3701,7 @@ ArrayType::Getter(JSContext* cx, JSObject* obj, jsval idval, jsval* vp)
}
JSBool
ArrayType::Setter(JSContext* cx, JSObject* obj, jsval idval, jsval* vp)
ArrayType::Setter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
{
// This should never happen, but we'll check to be safe.
if (!CData::IsCData(cx, obj)) {
@ -3762,7 +3761,7 @@ ArrayType::AddressOfElement(JSContext* cx, uintN argc, jsval *vp)
JSObject* pointerType = PointerType::CreateInternal(cx, baseType);
if (!pointerType)
return JS_FALSE;
js::AutoValueRooter root(cx, pointerType);
js::AutoObjectRooter root(cx, pointerType);
// Create a PointerType CData object containing null.
JSObject* result = CData::Create(cx, pointerType, NULL, NULL, true);
@ -3805,20 +3804,19 @@ ExtractStructField(JSContext* cx, jsval val, JSObject** typeObj)
JSObject* iter = JS_NewPropertyIterator(cx, obj);
if (!iter)
return NULL;
js::AutoValueRooter iterroot(cx, iter);
js::AutoObjectRooter iterroot(cx, iter);
jsid id;
if (!JS_NextProperty(cx, iter, &id))
return NULL;
js::AutoValueRooter nameVal(cx);
if (!JS_IdToValue(cx, id, nameVal.addr()))
return NULL;
if (!JSVAL_IS_STRING(nameVal.value())) {
JS_IdToValue(cx, id, Jsvalify(nameVal.addr()));
if (!nameVal.value().isString()) {
JS_ReportError(cx, "struct field descriptors require a valid name and type");
return NULL;
}
JSString* name = JSVAL_TO_STRING(nameVal.value());
JSString* name = nameVal.value().asString();
// make sure we have one, and only one, property
if (!JS_NextProperty(cx, iter, &id))
@ -3829,11 +3827,11 @@ ExtractStructField(JSContext* cx, jsval val, JSObject** typeObj)
}
js::AutoValueRooter propVal(cx);
if (!JS_GetUCProperty(cx, obj, name->chars(), name->length(), propVal.addr()))
if (!JS_GetUCProperty(cx, obj, name->chars(), name->length(), Jsvalify(propVal.addr())))
return NULL;
if (JSVAL_IS_PRIMITIVE(propVal.value()) ||
!CType::IsCType(cx, JSVAL_TO_OBJECT(propVal.value()))) {
if (propVal.value().isPrimitive() ||
!CType::IsCType(cx, &propVal.value().asObject())) {
JS_ReportError(cx, "struct field descriptors require a valid name and type");
return NULL;
}
@ -3841,7 +3839,7 @@ ExtractStructField(JSContext* cx, jsval val, JSObject** typeObj)
// Undefined size or zero size struct members are illegal.
// (Zero-size arrays are legal as struct members in C++, but libffi will
// choke on a zero-size struct, so we disallow them.)
*typeObj = JSVAL_TO_OBJECT(propVal.value());
*typeObj = &propVal.value().asObject();
size_t size;
if (!CType::GetSafeSize(cx, *typeObj, &size) || size == 0) {
JS_ReportError(cx, "struct field types must have defined and nonzero size");
@ -3902,7 +3900,7 @@ StructType::Create(JSContext* cx, uintN argc, jsval* vp)
JSVAL_TO_STRING(name), JSVAL_VOID, JSVAL_VOID, NULL);
if (!result)
return JS_FALSE;
js::AutoValueRooter root(cx, result);
js::AutoObjectRooter root(cx, result);
if (argc == 2) {
if (JSVAL_IS_PRIMITIVE(argv[1]) ||
@ -3937,7 +3935,7 @@ StructType::DefineInternal(JSContext* cx, JSObject* typeObj, JSObject* fieldsObj
JSObject* prototype = JS_NewObject(cx, &sCDataProtoClass, dataProto, NULL);
if (!prototype)
return JS_FALSE;
js::AutoValueRooter protoroot(cx, prototype);
js::AutoObjectRooter protoroot(cx, prototype);
if (!JS_DefineProperty(cx, prototype, "constructor", OBJECT_TO_JSVAL(typeObj),
NULL, NULL, JSPROP_READONLY | JSPROP_PERMANENT))
@ -3967,11 +3965,11 @@ StructType::DefineInternal(JSContext* cx, JSObject* typeObj, JSObject* fieldsObj
for (jsuint i = 0; i < len; ++i) {
js::AutoValueRooter item(cx);
if (!JS_GetElement(cx, fieldsObj, i, item.addr()))
if (!JS_GetElement(cx, fieldsObj, i, Jsvalify(item.addr())))
return JS_FALSE;
JSObject* fieldType;
JSString* name = ExtractStructField(cx, item.value(), &fieldType);
JSString* name = ExtractStructField(cx, Jsvalify(item.value()), &fieldType);
if (!name)
return JS_FALSE;
@ -4268,10 +4266,10 @@ StructType::BuildFieldsArray(JSContext* cx, JSObject* obj)
// Prepare a new array for the 'fields' property of the StructType.
jsval* fieldsVec;
JSObject* fieldsProp =
js_NewArrayObjectWithCapacity(cx, len, &fieldsVec);
js_NewArrayObjectWithCapacity(cx, len, Valueify(&fieldsVec));
if (!fieldsProp)
return NULL;
js::AutoValueRooter root(cx, fieldsProp);
js::AutoObjectRooter root(cx, fieldsProp);
JS_ASSERT(len == 0 || fieldsVec);
for (FieldInfoHash::Range r = fields->all(); !r.empty(); r.popFront()) {
@ -4290,7 +4288,7 @@ StructType::BuildFieldsArray(JSContext* cx, JSObject* obj)
}
JSBool
StructType::FieldsArrayGetter(JSContext* cx, JSObject* obj, jsval idval, jsval* vp)
StructType::FieldsArrayGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
{
if (!CType::IsCType(cx, obj) || CType::GetTypeCode(cx, obj) != TYPE_struct) {
JS_ReportError(cx, "not a StructType");
@ -4320,7 +4318,7 @@ StructType::FieldsArrayGetter(JSContext* cx, JSObject* obj, jsval idval, jsval*
}
JSBool
StructType::FieldGetter(JSContext* cx, JSObject* obj, jsval idval, jsval* vp)
StructType::FieldGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
{
if (!CData::IsCData(cx, obj)) {
JS_ReportError(cx, "not a CData");
@ -4342,7 +4340,7 @@ StructType::FieldGetter(JSContext* cx, JSObject* obj, jsval idval, jsval* vp)
}
JSBool
StructType::FieldSetter(JSContext* cx, JSObject* obj, jsval idval, jsval* vp)
StructType::FieldSetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
{
if (!CData::IsCData(cx, obj)) {
JS_ReportError(cx, "not a CData");
@ -4393,7 +4391,7 @@ StructType::AddressOfField(JSContext* cx, uintN argc, jsval *vp)
JSObject* pointerType = PointerType::CreateInternal(cx, baseType);
if (!pointerType)
return JS_FALSE;
js::AutoValueRooter root(cx, pointerType);
js::AutoObjectRooter root(cx, pointerType);
// Create a PointerType CData object containing null.
JSObject* result = CData::Create(cx, pointerType, NULL, NULL, true);
@ -4689,7 +4687,7 @@ FunctionType::Create(JSContext* cx, uintN argc, jsval* vp)
// Pull out the argument types from the array, if any.
JS_ASSERT(!argTypes.length() || arrayObj);
js::AutoArrayRooter items(cx, argTypes.length(), argTypes.begin());
js::AutoArrayRooter items(cx, argTypes.length(), Valueify(argTypes.begin()));
for (jsuint i = 0; i < argTypes.length(); ++i) {
if (!JS_GetElement(cx, arrayObj, i, &argTypes[i]))
return JS_FALSE;
@ -4728,7 +4726,7 @@ FunctionType::CreateInternal(JSContext* cx,
NULL, JSVAL_VOID, JSVAL_VOID, NULL);
if (!typeObj)
return NULL;
js::AutoValueRooter root(cx, typeObj);
js::AutoObjectRooter root(cx, typeObj);
// Stash the FunctionInfo in a reserved slot.
if (!JS_SetReservedSlot(cx, typeObj, SLOT_FNINFO,
@ -4759,7 +4757,7 @@ FunctionType::ConstructData(JSContext* cx,
JSObject* closureObj = CClosure::Create(cx, typeObj, fnObj, thisObj, data);
if (!closureObj)
return JS_FALSE;
js::AutoValueRooter root(cx, closureObj);
js::AutoObjectRooter root(cx, closureObj);
// Set the closure object as the referent of the new CData object.
if (!JS_SetReservedSlot(cx, dataObj, SLOT_REFERENT,
@ -4944,7 +4942,7 @@ CheckFunctionType(JSContext* cx, JSObject* obj)
}
JSBool
FunctionType::ArgTypesGetter(JSContext* cx, JSObject* obj, jsval idval, jsval* vp)
FunctionType::ArgTypesGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
{
if (!CheckFunctionType(cx, obj))
return JS_FALSE;
@ -4960,10 +4958,10 @@ FunctionType::ArgTypesGetter(JSContext* cx, JSObject* obj, jsval idval, jsval* v
// Prepare a new array.
jsval* vec;
JSObject* argTypes =
js_NewArrayObjectWithCapacity(cx, len, &vec);
js_NewArrayObjectWithCapacity(cx, len, Valueify(&vec));
if (!argTypes)
return JS_FALSE;
js::AutoValueRooter argsroot(cx, argTypes);
js::AutoObjectRooter argsroot(cx, argTypes);
JS_ASSERT(len == 0 || vec);
for (size_t i = 0; i < len; ++i)
@ -4979,7 +4977,7 @@ FunctionType::ArgTypesGetter(JSContext* cx, JSObject* obj, jsval idval, jsval* v
}
JSBool
FunctionType::ReturnTypeGetter(JSContext* cx, JSObject* obj, jsval idval, jsval* vp)
FunctionType::ReturnTypeGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
{
if (!CheckFunctionType(cx, obj))
return JS_FALSE;
@ -4990,7 +4988,7 @@ FunctionType::ReturnTypeGetter(JSContext* cx, JSObject* obj, jsval idval, jsval*
}
JSBool
FunctionType::ABIGetter(JSContext* cx, JSObject* obj, jsval idval, jsval* vp)
FunctionType::ABIGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
{
if (!CheckFunctionType(cx, obj))
return JS_FALSE;
@ -5001,7 +4999,7 @@ FunctionType::ABIGetter(JSContext* cx, JSObject* obj, jsval idval, jsval* vp)
}
JSBool
FunctionType::IsVariadicGetter(JSContext* cx, JSObject* obj, jsval idval, jsval* vp)
FunctionType::IsVariadicGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
{
if (!CheckFunctionType(cx, obj))
return JS_FALSE;
@ -5024,7 +5022,7 @@ CClosure::Create(JSContext* cx,
JSObject* result = JS_NewObject(cx, &sCClosureClass, NULL, NULL);
if (!result)
return NULL;
js::AutoValueRooter root(cx, result);
js::AutoObjectRooter root(cx, result);
// Get the FunctionInfo from the FunctionType.
FunctionInfo* fninfo = FunctionType::GetFunctionInfo(cx, typeObj);
@ -5176,7 +5174,7 @@ CClosure::ClosureStub(ffi_cif* cif, void* result, void** args, void* userData)
JS_ASSERT(cif == &fninfo->mCIF);
// Get a death grip on 'closureObj'.
js::AutoValueRooter root(cx, cinfo->closureObj);
js::AutoObjectRooter root(cx, cinfo->closureObj);
// Set up an array for converted arguments.
Array<jsval, 16> argv;
@ -5188,7 +5186,7 @@ CClosure::ClosureStub(ffi_cif* cif, void* result, void** args, void* userData)
for (JSUint32 i = 0; i < cif->nargs; ++i)
argv[i] = JSVAL_VOID;
js::AutoArrayRooter roots(cx, argv.length(), argv.begin());
js::AutoArrayRooter roots(cx, argv.length(), Valueify(argv.begin()));
for (JSUint32 i = 0; i < cif->nargs; ++i) {
// Convert each argument, and have any CData objects created depend on
// the existing buffers.
@ -5262,7 +5260,7 @@ CData::Create(JSContext* cx,
JSObject* dataObj = JS_NewObject(cx, &sCDataClass, proto, parent);
if (!dataObj)
return NULL;
js::AutoValueRooter root(cx, dataObj);
js::AutoObjectRooter root(cx, dataObj);
// set the CData's associated type
if (!JS_SetReservedSlot(cx, dataObj, SLOT_CTYPE, OBJECT_TO_JSVAL(typeObj)))
@ -5368,7 +5366,7 @@ CData::IsCData(JSContext* cx, JSObject* obj)
}
JSBool
CData::ValueGetter(JSContext* cx, JSObject* obj, jsval idval, jsval* vp)
CData::ValueGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
{
if (!IsCData(cx, obj)) {
JS_ReportError(cx, "not a CData");
@ -5383,7 +5381,7 @@ CData::ValueGetter(JSContext* cx, JSObject* obj, jsval idval, jsval* vp)
}
JSBool
CData::ValueSetter(JSContext* cx, JSObject* obj, jsval idval, jsval* vp)
CData::ValueSetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
{
if (!IsCData(cx, obj)) {
JS_ReportError(cx, "not a CData");
@ -5413,7 +5411,7 @@ CData::Address(JSContext* cx, uintN argc, jsval *vp)
JSObject* pointerType = PointerType::CreateInternal(cx, typeObj);
if (!pointerType)
return JS_FALSE;
js::AutoValueRooter root(cx, pointerType);
js::AutoObjectRooter root(cx, pointerType);
// Create a PointerType CData object containing null.
JSObject* result = CData::Create(cx, pointerType, NULL, NULL, true);
@ -5616,7 +5614,7 @@ Int64Base::Construct(JSContext* cx,
JSObject* result = JS_NewObject(cx, clasp, proto, JS_GetParent(cx, proto));
if (!result)
return NULL;
js::AutoValueRooter root(cx, result);
js::AutoObjectRooter root(cx, result);
// attach the Int64's data
JSUint64* buffer = new JSUint64(data);

View File

@ -85,7 +85,7 @@ Library::Create(JSContext* cx, jsval aPath)
JSObject* libraryObj = JS_NewObject(cx, &sLibraryClass, NULL, NULL);
if (!libraryObj)
return NULL;
js::AutoValueRooter root(cx, libraryObj);
js::AutoObjectRooter root(cx, libraryObj);
// initialize the library
if (!JS_SetReservedSlot(cx, libraryObj, SLOT_LIBRARY, PRIVATE_TO_JSVAL(NULL)))
@ -241,7 +241,7 @@ Library::Declare(JSContext* cx, uintN argc, jsval* vp)
return JS_FALSE;
JSObject* typeObj;
js::AutoValueRooter root(cx);
js::AutoObjectRooter root(cx);
bool isFunction = argc > 2;
if (isFunction) {
// Case 1).

View File

@ -2531,7 +2531,6 @@ JS_DestroyIdArray(JSContext *cx, JSIdArray *ida)
JS_PUBLIC_API(jsval)
JSID_TO_JSVAL(jsid id)
{
CHECK_REQUEST(cx);
return Jsvalify(IdToValue(id));
}
@ -2594,7 +2593,7 @@ JS_InitClass(JSContext *cx, JSObject *obj, JSObject *parent_proto,
JS_PUBLIC_API(JSClass *)
JS_GetClass(JSContext *cx, JSObject *obj)
{
return obj->getClass();
return Jsvalify(obj->getClass());
}
#else
JS_PUBLIC_API(JSClass *)

View File

@ -3340,14 +3340,15 @@ class Value
* As asserted above, js::Value and jsval are layout equivalent. To provide
* widespread casting, the following safe casts are provided.
*/
static inline jsval * Jsvalify(Value *v) { return (jsval *)v; }
static inline const jsval * Jsvalify(const Value *v) { return (const jsval *)v; }
static inline jsval & Jsvalify(Value &v) { return (jsval &)v; }
static inline const jsval & Jsvalify(const Value &v) { return (const jsval &)v; }
static inline Value * Valueify(jsval *v) { return (Value *)v; }
static inline const Value * Valueify(const jsval *v) { return (const Value *)v; }
static inline Value & Valueify(jsval &v) { return (Value &)v; }
static inline const Value & Valueify(const jsval &v) { return (const Value &)v; }
static inline jsval * Jsvalify(Value *v) { return (jsval *)v; }
static inline const jsval * Jsvalify(const Value *v) { return (const jsval *)v; }
static inline jsval & Jsvalify(Value &v) { return (jsval &)v; }
static inline const jsval & Jsvalify(const Value &v) { return (const jsval &)v; }
static inline Value * Valueify(jsval *v) { return (Value *)v; }
static inline const Value * Valueify(const jsval *v) { return (const Value *)v; }
static inline Value ** Valueify(jsval **v) { return (Value **)v; }
static inline Value & Valueify(jsval &v) { return (Value &)v; }
static inline const Value & Valueify(const jsval &v) { return (const Value &)v; }
/* Convenience inlines. */
static inline Value undefinedValue() { return UndefinedTag(); }

View File

@ -2040,8 +2040,10 @@ array_sort(JSContext *cx, uintN argc, Value *vp)
str = js_ValueToString(cx, v);
if (!str)
return false;
vec[2 * i].setString(str);
// Copying v must come first, because the following line overwrites v
// when i == 0.
vec[2 * i + 1] = v;
vec[2 * i].setString(str);
} while (i != 0);
JS_ASSERT(tvr.array == vec);

View File

@ -1767,9 +1767,11 @@ namespace reprmeter {
if ((vp)->isObject()) { \
obj = &(vp)->asObject(); \
} else { \
if (!js_ValueToNonNullObject(cx, *(vp), (vp))) \
Value v; \
if (!js_ValueToNonNullObject(cx, *(vp), &v)) \
goto error; \
obj = &(vp)->asObject(); \
*(vp) = v; \
obj = &v.asObject(); \
} \
JS_END_MACRO

View File

@ -493,16 +493,16 @@ FinishSharingTitle(JSContext *cx, JSTitle *title)
uint32 nslots = scope->freeslot;
JS_ASSERT(nslots >= JSSLOT_START(obj->getClass()));
for (uint32 i = JSSLOT_START(obj->getClass()); i != nslots; ++i) {
jsval v = obj->getSlot(i);
if (JSVAL_IS_STRING(v) &&
!js_MakeStringImmutable(cx, JSVAL_TO_STRING(v))) {
Value v = obj->getSlot(i);
if (v.isString() &&
!js_MakeStringImmutable(cx, v.asString())) {
/*
* FIXME bug 363059: The following error recovery changes
* runtime execution semantics, arbitrarily and silently
* ignoring errors except out-of-memory, which should have been
* reported through JS_ReportOutOfMemory at this point.
*/
obj->setSlot(i, JSVAL_VOID);
obj->setSlot(i, undefinedValue());
}
}
}
@ -710,7 +710,7 @@ js_GetSlotThreadSafe(JSContext *cx, JSObject *obj, uint32 slot)
if (CX_THREAD_IS_RUNNING_GC(cx) ||
scope->sealed() ||
(title->ownercx && ClaimTitle(title, cx))) {
return obj->getSlot(slot);
return Jsvalify(obj->getSlot(slot));
}
#ifndef NSPR_LOCK
@ -725,7 +725,7 @@ js_GetSlotThreadSafe(JSContext *cx, JSObject *obj, uint32 slot)
* lock release followed by fat lock acquisition.
*/
if (scope == obj->scope()) {
v = obj->getSlot(slot);
v = Jsvalify(obj->getSlot(slot));
if (!NativeCompareAndSwap(&tl->owner, me, 0)) {
/* Assert that scope locks never revert to flyweight. */
JS_ASSERT(title->ownercx != cx);
@ -739,12 +739,12 @@ js_GetSlotThreadSafe(JSContext *cx, JSObject *obj, uint32 slot)
js_Dequeue(tl);
}
else if (Thin_RemoveWait(ReadWord(tl->owner)) == me) {
return obj->getSlot(slot);
return Jsvalify(obj->getSlot(slot));
}
#endif
js_LockObj(cx, obj);
v = obj->getSlot(slot);
v = Jsvalify(obj->getSlot(slot));
/*
* Test whether cx took ownership of obj's scope during js_LockObj.
@ -798,7 +798,7 @@ js_SetSlotThreadSafe(JSContext *cx, JSObject *obj, uint32 slot, jsval v)
if (CX_THREAD_IS_RUNNING_GC(cx) ||
scope->sealed() ||
(title->ownercx && ClaimTitle(title, cx))) {
obj->lockedSetSlot(slot, v);
obj->lockedSetSlot(slot, Valueify(v));
return;
}
@ -808,7 +808,7 @@ js_SetSlotThreadSafe(JSContext *cx, JSObject *obj, uint32 slot, jsval v)
JS_ASSERT(CURRENT_THREAD_IS_ME(me));
if (NativeCompareAndSwap(&tl->owner, 0, me)) {
if (scope == obj->scope()) {
obj->lockedSetSlot(slot, v);
obj->lockedSetSlot(slot, Valueify(v));
if (!NativeCompareAndSwap(&tl->owner, me, 0)) {
/* Assert that scope locks never revert to flyweight. */
JS_ASSERT(title->ownercx != cx);
@ -821,13 +821,13 @@ js_SetSlotThreadSafe(JSContext *cx, JSObject *obj, uint32 slot, jsval v)
if (!NativeCompareAndSwap(&tl->owner, me, 0))
js_Dequeue(tl);
} else if (Thin_RemoveWait(ReadWord(tl->owner)) == me) {
obj->lockedSetSlot(slot, v);
obj->lockedSetSlot(slot, Valueify(v));
return;
}
#endif
js_LockObj(cx, obj);
obj->lockedSetSlot(slot, v);
obj->lockedSetSlot(slot, Valueify(v));
/*
* Same drill as above, in js_GetSlotThreadSafe.

View File

@ -65,8 +65,8 @@ JSObject::getSlotMT(JSContext *cx, uintN slot)
*/
OBJ_CHECK_SLOT(this, slot);
return (scope()->title.ownercx == cx)
? this->lockedGetSlot(slot)
: js_GetSlotThreadSafe(cx, this, slot);
? this->lockedGetSlot(slot)
: js::Valueify(js_GetSlotThreadSafe(cx, this, slot));
#else
return this->lockedGetSlot(slot);
#endif
@ -81,7 +81,7 @@ JSObject::setSlotMT(JSContext *cx, uintN slot, const js::Value &value)
if (scope()->title.ownercx == cx)
this->lockedSetSlot(slot, value);
else
js_SetSlotThreadSafe(cx, this, slot, value);
js_SetSlotThreadSafe(cx, this, slot, Jsvalify(value));
#else
this->lockedSetSlot(slot, value);
#endif

View File

@ -1737,9 +1737,7 @@ BEGIN_CASE(JSOP_CALLPROP)
if (!atom) {
ASSERT_VALID_PROPERTY_CACHE_HIT(0, aobj, obj2, entry);
if (entry->vword.isFunObj()) {
regs.sp[-1].setFunObj(entry->vword.toFunObj());
PUSH_COPY(lval);
goto end_callprop;
rval.setFunObj(entry->vword.toFunObj());
} else if (entry->vword.isSlot()) {
uint32 slot = entry->vword.toSlot();
JS_ASSERT(slot < obj2->scope()->freeslot);

View File

@ -3291,10 +3291,10 @@ Scatter(JSContext *cx, uintN argc, jsval *vp)
goto fail;
for (i = 0; i < n; i++) {
sd.results[i] = JSVAL_VOID;
ok = JS_AddRoot(cx, &sd.results[i]);
ok = JS_AddValueRoot(cx, &sd.results[i]);
if (!ok) {
while (i-- > 0)
JS_RemoveRoot(cx, &sd.results[i]);
JS_RemoveValueRoot(cx, &sd.results[i]);
free(sd.results);
sd.results = NULL;
goto fail;
@ -3311,14 +3311,14 @@ Scatter(JSContext *cx, uintN argc, jsval *vp)
sd.threads[i].cx = NULL;
sd.threads[i].fn = JSVAL_NULL;
ok = JS_AddRoot(cx, &sd.threads[i].fn);
ok = JS_AddValueRoot(cx, &sd.threads[i].fn);
if (ok && !JS_GetElement(cx, inArr, (jsint) i, &sd.threads[i].fn)) {
JS_RemoveRoot(cx, &sd.threads[i].fn);
JS_RemoveValueRoot(cx, &sd.threads[i].fn);
ok = JS_FALSE;
}
if (!ok) {
while (i-- > 0)
JS_RemoveRoot(cx, &sd.threads[i].fn);
JS_RemoveValueRoot(cx, &sd.threads[i].fn);
free(sd.threads);
sd.threads = NULL;
goto fail;
@ -3386,7 +3386,7 @@ out:
JSContext *acx;
for (i = 0; i < n; i++) {
JS_RemoveRoot(cx, &sd.threads[i].fn);
JS_RemoveValueRoot(cx, &sd.threads[i].fn);
acx = sd.threads[i].cx;
if (acx) {
JS_SetContextThread(acx);
@ -3397,7 +3397,7 @@ out:
}
if (sd.results) {
for (i = 0; i < n; i++)
JS_RemoveRoot(cx, &sd.results[i]);
JS_RemoveValueRoot(cx, &sd.results[i]);
free(sd.results);
}
if (sd.cvar)
@ -5082,7 +5082,7 @@ main(int argc, char **argv, char **envp)
JSObject *newGlobalObject(JSContext *cx) { return NewGlobalObject(cx); }
};
ShellWorkerHooks hooks;
if (!JS_AddNamedRoot(cx, &gWorkers, "Workers") ||
if (!JS_AddNamedObjectRoot(cx, &gWorkers, "Workers") ||
!js::workers::init(cx, &hooks, glob, &gWorkers)) {
return 1;
}
@ -5092,7 +5092,7 @@ main(int argc, char **argv, char **envp)
#ifdef JS_THREADSAFE
js::workers::finish(cx, gWorkers);
JS_RemoveRoot(cx, &gWorkers);
JS_RemoveObjectRoot(cx, &gWorkers);
if (result == 0)
result = gExitCode;
#endif

View File

@ -670,7 +670,7 @@ class Worker : public WorkerParent
return !w->checkTermination();
}
static JSBool jsResolveGlobal(JSContext *cx, JSObject *obj, jsval id, uintN flags,
static JSBool jsResolveGlobal(JSContext *cx, JSObject *obj, jsid id, uintN flags,
JSObject **objp)
{
if ((flags & JSRESOLVE_ASSIGNING) == 0) {
@ -869,7 +869,7 @@ class InitEvent : public Event
return fail;
AutoValueRooter rval(cx);
JSBool ok = JS_ExecuteScript(cx, child->getGlobal(), script, rval.addr());
JSBool ok = JS_ExecuteScript(cx, child->getGlobal(), script, Jsvalify(rval.addr()));
JS_DestroyScript(cx, script);
return Result(ok);
}
@ -906,7 +906,7 @@ class ErrorEvent : public Event
JSString *data = NULL;
jsval exc;
if (JS_GetPendingException(cx, &exc)) {
AutoValueRooter tvr(cx, exc);
AutoValueRooter tvr(cx, Valueify(exc));
JS_ClearPendingException(cx);
// Determine what error message to put in the error event.

View File

@ -125,10 +125,10 @@ class ResultsSink:
# key is (result, expect, random)
# value is (tinderbox label, dev test category)
LABELS = {
(TestResult.CRASH, False, False): ('TEST-UNEXPECTED-CRASH', 'REGRESSIONS'),
(TestResult.CRASH, False, True): ('TEST-UNEXPECTED-CRASH', 'REGRESSIONS'),
(TestResult.CRASH, True, False): ('TEST-UNEXPECTED-CRASH', 'REGRESSIONS'),
(TestResult.CRASH, True, True): ('TEST-UNEXPECTED-CRASH', 'REGRESSIONS'),
(TestResult.CRASH, False, False): ('TEST-UNEXPECTED-FAIL', 'REGRESSIONS'),
(TestResult.CRASH, False, True): ('TEST-UNEXPECTED-FAIL', 'REGRESSIONS'),
(TestResult.CRASH, True, False): ('TEST-UNEXPECTED-FAIL', 'REGRESSIONS'),
(TestResult.CRASH, True, True): ('TEST-UNEXPECTED-FAIL', 'REGRESSIONS'),
(TestResult.FAIL, False, False): ('TEST-KNOWN-FAIL', ''),
(TestResult.FAIL, False, True): ('TEST-KNOWN-FAIL (EXPECTED RANDOM)', ''),