Bug 787580 - Root all jsval at the API surface; r=sfink sr=dmandelin

--HG--
rename : layout/reftests/text-decoration/underline-select-2-ref.html => layout/reftests/text-decoration/underline-button-1-ref.html
rename : layout/reftests/text-decoration/underline-select-2.html => layout/reftests/text-decoration/underline-button-1.html
extra : rebase_source : 008f2bab76a005947a4c0bd10b6d9ea8531ea6d0
This commit is contained in:
Terrence Cole 2012-09-04 16:40:12 -07:00
parent cd21ce7e8c
commit aed2094b1c
36 changed files with 258 additions and 278 deletions

View File

@ -392,7 +392,7 @@ private:
static JSBool
CheckObjectAccess(JSContext *cx, JSHandleObject obj,
JSHandleId id, JSAccessMode mode,
jsval *vp);
JSMutableHandleValue vp);
// Decides, based on CSP, whether or not eval() and stuff can be executed.
static JSBool

View File

@ -532,7 +532,7 @@ nsScriptSecurityManager::ContentSecurityPolicyPermitsJSAction(JSContext *cx)
JSBool
nsScriptSecurityManager::CheckObjectAccess(JSContext *cx, JSHandleObject obj,
JSHandleId id, JSAccessMode mode,
jsval *vp)
JSMutableHandleValue vp)
{
// Get the security manager
nsScriptSecurityManager *ssm =
@ -548,9 +548,9 @@ nsScriptSecurityManager::CheckObjectAccess(JSContext *cx, JSHandleObject obj,
// a different trust domain.
// 2. A user-defined getter or setter function accessible on another
// trust domain's window or document object.
// *vp can be a primitive, in that case, we use obj as the target
// vp can be a primitive, in that case, we use obj as the target
// object.
JSObject* target = JSVAL_IS_PRIMITIVE(*vp) ? obj : JSVAL_TO_OBJECT(*vp);
JSObject* target = JSVAL_IS_PRIMITIVE(vp) ? obj : JSVAL_TO_OBJECT(vp);
// Do the same-origin check -- this sets a JS exception if the check fails.
// Pass the parent object's class name, as we have no class-info for it.

View File

@ -128,7 +128,7 @@ nsXBLDocGlobalObject_setProperty(JSContext *cx, JSHandleObject obj,
static JSBool
nsXBLDocGlobalObject_checkAccess(JSContext *cx, JSHandleObject obj, JSHandleId id,
JSAccessMode mode, jsval *vp)
JSAccessMode mode, JSMutableHandleValue vp)
{
uint32_t translated;
if (mode & JSACC_WRITE) {

View File

@ -730,7 +730,7 @@ class CGClassConstructHook(CGAbstractStaticMethod):
class CGClassHasInstanceHook(CGAbstractStaticMethod):
def __init__(self, descriptor):
args = [Argument('JSContext*', 'cx'), Argument('JSHandleObject', 'obj'),
Argument('const jsval*', 'v'), Argument('JSBool*', 'bp')]
Argument('JSMutableHandleValue', 'vp'), Argument('JSBool*', 'bp')]
CGAbstractStaticMethod.__init__(self, descriptor, HASINSTANCE_HOOK_NAME,
'JSBool', args)
@ -743,7 +743,7 @@ class CGClassHasInstanceHook(CGAbstractStaticMethod):
return self.generate_code()
def generate_code(self):
return """ if (!v->isObject()) {
return """ if (!vp.isObject()) {
*bp = false;
return true;
}
@ -758,7 +758,7 @@ class CGClassHasInstanceHook(CGAbstractStaticMethod):
}
JSObject *objProto = &protov.toObject();
JSObject* instance = &v->toObject();
JSObject* instance = &vp.toObject();
JSObject* proto = JS_GetPrototype(instance);
while (proto) {
if (proto == objProto) {

View File

@ -673,7 +673,7 @@ ObjectWrapperParent::CPOW_Construct(JSContext* cx, unsigned argc, jsval* vp)
}
/*static*/ JSBool
ObjectWrapperParent::CPOW_HasInstance(JSContext *cx, JSHandleObject obj, const jsval *v,
ObjectWrapperParent::CPOW_HasInstance(JSContext *cx, JSHandleObject obj, JSMutableHandleValue v,
JSBool *bp)
{
CPOW_LOG(("Calling CPOW_HasInstance..."));
@ -688,7 +688,7 @@ ObjectWrapperParent::CPOW_HasInstance(JSContext *cx, JSHandleObject obj, const j
JSVariant in_v;
if (!jsval_to_JSVariant(cx, *v, &in_v))
if (!jsval_to_JSVariant(cx, v, &in_v))
return JS_FALSE;
return (self->Manager()->RequestRunToCompletion() &&
@ -698,7 +698,7 @@ ObjectWrapperParent::CPOW_HasInstance(JSContext *cx, JSHandleObject obj, const j
}
/*static*/ JSBool
ObjectWrapperParent::CPOW_Equality(JSContext *cx, JSHandleObject obj, const jsval *v,
ObjectWrapperParent::CPOW_Equality(JSContext *cx, JSHandleObject obj, JSHandleValue v,
JSBool *bp)
{
CPOW_LOG(("Calling CPOW_Equality..."));
@ -709,10 +709,10 @@ ObjectWrapperParent::CPOW_Equality(JSContext *cx, JSHandleObject obj, const jsva
if (!self)
return with_error(cx, JS_FALSE, "Unwrapping failed in CPOW_Equality");
if (JSVAL_IS_PRIMITIVE(*v))
if (JSVAL_IS_PRIMITIVE(v))
return JS_TRUE;
ObjectWrapperParent* other = Unwrap(JSVAL_TO_OBJECT(*v));
ObjectWrapperParent* other = Unwrap(JSVAL_TO_OBJECT(v));
if (!other)
return JS_TRUE;

View File

@ -95,10 +95,10 @@ private:
CPOW_Construct(JSContext *cx, unsigned argc, jsval *vp);
static JSBool
CPOW_HasInstance(JSContext *cx, JSHandleObject obj, const jsval *v, JSBool *bp);
CPOW_HasInstance(JSContext *cx, JSHandleObject obj, JSMutableHandleValue vp, JSBool *bp);
static JSBool
CPOW_Equality(JSContext *cx, JSHandleObject obj, const jsval *v, JSBool *bp);
CPOW_Equality(JSContext *cx, JSHandleObject obj, JSHandleValue v, JSBool *bp);
static bool jsval_to_JSVariant(JSContext* cx, jsval from, JSVariant* to);
static bool jsval_from_JSVariant(JSContext* cx, const JSVariant& from,

View File

@ -63,7 +63,7 @@ namespace CType {
static JSBool CreateArray(JSContext* cx, unsigned argc, jsval* vp);
static JSBool ToString(JSContext* cx, unsigned argc, jsval* vp);
static JSBool ToSource(JSContext* cx, unsigned argc, jsval* vp);
static JSBool HasInstance(JSContext* cx, JSHandleObject obj, const jsval* v, JSBool* bp);
static JSBool HasInstance(JSContext* cx, JSHandleObject obj, JSMutableHandleValue v, JSBool* bp);
/*
@ -3524,7 +3524,7 @@ CType::ToSource(JSContext* cx, unsigned argc, jsval* vp)
}
JSBool
CType::HasInstance(JSContext* cx, JSHandleObject obj, const jsval* v, JSBool* bp)
CType::HasInstance(JSContext* cx, JSHandleObject obj, JSMutableHandleValue v, JSBool* bp)
{
JS_ASSERT(CType::IsCType(obj));
@ -3534,10 +3534,10 @@ CType::HasInstance(JSContext* cx, JSHandleObject obj, const jsval* v, JSBool* bp
JS_ASSERT(CData::IsCDataProto(prototype));
*bp = JS_FALSE;
if (JSVAL_IS_PRIMITIVE(*v))
if (JSVAL_IS_PRIMITIVE(v))
return JS_TRUE;
JSObject* proto = JSVAL_TO_OBJECT(*v);
JSObject* proto = JSVAL_TO_OBJECT(v);
while ((proto = JS_GetPrototype(proto))) {
if (proto == prototype) {
*bp = JS_TRUE;

View File

@ -228,6 +228,7 @@ class MutableHandle : public MutableHandleBase<T>
typedef MutableHandle<JSObject*> MutableHandleObject;
typedef MutableHandle<Value> MutableHandleValue;
typedef MutableHandle<jsid> MutableHandleId;
/*
* Raw pointer used as documentation that a parameter does not need to be
@ -235,6 +236,7 @@ typedef MutableHandle<Value> MutableHandleValue;
*/
typedef JSObject * RawObject;
typedef JSString * RawString;
typedef Value RawValue;
extern mozilla::ThreadLocal<JSRuntime *> TlsRuntime;

View File

@ -13,7 +13,7 @@
#include "jsobj.h"
static JSBool
my_Equality(JSContext *cx, JS::HandleObject obj, const jsval *, JSBool *bp)
my_Equality(JSContext *cx, JS::HandleObject obj, JS::HandleValue, JSBool *bp)
{
*bp = JS_TRUE;
return JS_TRUE;

View File

@ -444,8 +444,9 @@ JS_RemoveArgumentFormatter(JSContext *cx, const char *format)
}
JS_PUBLIC_API(JSBool)
JS_ConvertValue(JSContext *cx, jsval v, JSType type, jsval *vp)
JS_ConvertValue(JSContext *cx, jsval valueArg, JSType type, jsval *vp)
{
RootedValue value(cx, valueArg);
JSBool ok;
RootedObject obj(cx);
JSString *str;
@ -453,35 +454,35 @@ JS_ConvertValue(JSContext *cx, jsval v, JSType type, jsval *vp)
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, v);
assertSameCompartment(cx, value);
switch (type) {
case JSTYPE_VOID:
*vp = JSVAL_VOID;
ok = JS_TRUE;
break;
case JSTYPE_OBJECT:
ok = js_ValueToObjectOrNull(cx, v, &obj);
ok = js_ValueToObjectOrNull(cx, value, &obj);
if (ok)
*vp = OBJECT_TO_JSVAL(obj);
break;
case JSTYPE_FUNCTION:
*vp = v;
*vp = value;
obj = ReportIfNotFunction(cx, *vp);
ok = (obj != NULL);
break;
case JSTYPE_STRING:
str = ToString(cx, v);
str = ToString(cx, value);
ok = (str != NULL);
if (ok)
*vp = STRING_TO_JSVAL(str);
break;
case JSTYPE_NUMBER:
ok = JS_ValueToNumber(cx, v, &d);
ok = JS_ValueToNumber(cx, value, &d);
if (ok)
*vp = DOUBLE_TO_JSVAL(d);
break;
case JSTYPE_BOOLEAN:
*vp = BooleanValue(ToBoolean(v));
*vp = BooleanValue(ToBoolean(value));
return JS_TRUE;
default: {
char numBuf[12];
@ -495,58 +496,63 @@ JS_ConvertValue(JSContext *cx, jsval v, JSType type, jsval *vp)
}
JS_PUBLIC_API(JSBool)
JS_ValueToObject(JSContext *cx, jsval v, JSObject **objpArg)
JS_ValueToObject(JSContext *cx, jsval valueArg, JSObject **objpArg)
{
RootedValue value(cx, valueArg);
RootedObject objp(cx, *objpArg);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, v);
if (!js_ValueToObjectOrNull(cx, v, &objp))
assertSameCompartment(cx, value);
if (!js_ValueToObjectOrNull(cx, value, &objp))
return false;
*objpArg = objp;
return true;
}
JS_PUBLIC_API(JSFunction *)
JS_ValueToFunction(JSContext *cx, jsval v)
JS_ValueToFunction(JSContext *cx, jsval valueArg)
{
RootedValue value(cx, valueArg);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, v);
return ReportIfNotFunction(cx, v);
assertSameCompartment(cx, value);
return ReportIfNotFunction(cx, value);
}
JS_PUBLIC_API(JSFunction *)
JS_ValueToConstructor(JSContext *cx, jsval v)
JS_ValueToConstructor(JSContext *cx, jsval valueArg)
{
RootedValue value(cx, valueArg);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, v);
return ReportIfNotFunction(cx, v);
assertSameCompartment(cx, value);
return ReportIfNotFunction(cx, value);
}
JS_PUBLIC_API(JSString *)
JS_ValueToString(JSContext *cx, jsval v)
JS_ValueToString(JSContext *cx, jsval valueArg)
{
RootedValue value(cx, valueArg);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, v);
return ToString(cx, v);
assertSameCompartment(cx, value);
return ToString(cx, value);
}
JS_PUBLIC_API(JSString *)
JS_ValueToSource(JSContext *cx, jsval v)
JS_ValueToSource(JSContext *cx, jsval valueArg)
{
RootedValue value(cx, valueArg);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, v);
return js_ValueToSource(cx, v);
assertSameCompartment(cx, value);
return js_ValueToSource(cx, value);
}
JS_PUBLIC_API(JSBool)
JS_ValueToNumber(JSContext *cx, jsval v, double *dp)
JS_ValueToNumber(JSContext *cx, jsval valueArg, double *dp)
{
RootedValue value(cx, v);
RootedValue value(cx, valueArg);
return JS::ToNumber(cx, value, dp);
}
@ -569,30 +575,30 @@ JS_DoubleToUint32(double d)
}
JS_PUBLIC_API(JSBool)
JS_ValueToECMAInt32(JSContext *cx, jsval v, int32_t *ip)
JS_ValueToECMAInt32(JSContext *cx, jsval valueArg, int32_t *ip)
{
RootedValue value(cx, v);
RootedValue value(cx, valueArg);
return JS::ToInt32(cx, value, ip);
}
JS_PUBLIC_API(JSBool)
JS_ValueToECMAUint32(JSContext *cx, jsval v, uint32_t *ip)
JS_ValueToECMAUint32(JSContext *cx, jsval valueArg, uint32_t *ip)
{
RootedValue value(cx, v);
RootedValue value(cx, valueArg);
return JS::ToUint32(cx, value, ip);
}
JS_PUBLIC_API(JSBool)
JS_ValueToInt64(JSContext *cx, jsval v, int64_t *ip)
JS_ValueToInt64(JSContext *cx, jsval valueArg, int64_t *ip)
{
RootedValue value(cx, v);
RootedValue value(cx, valueArg);
return JS::ToInt64(cx, value, ip);
}
JS_PUBLIC_API(JSBool)
JS_ValueToUint64(JSContext *cx, jsval v, uint64_t *ip)
JS_ValueToUint64(JSContext *cx, jsval valueArg, uint64_t *ip)
{
RootedValue value(cx, v);
RootedValue value(cx, valueArg);
return JS::ToUint64(cx, value, ip);
}
@ -628,28 +634,31 @@ JS_ValueToInt32(JSContext *cx, jsval vArg, int32_t *ip)
}
JS_PUBLIC_API(JSBool)
JS_ValueToUint16(JSContext *cx, jsval v, uint16_t *ip)
JS_ValueToUint16(JSContext *cx, jsval valueArg, uint16_t *ip)
{
return ToUint16(cx, v, ip);
RootedValue value(cx, valueArg);
return ToUint16(cx, value, ip);
}
JS_PUBLIC_API(JSBool)
JS_ValueToBoolean(JSContext *cx, jsval v, JSBool *bp)
JS_ValueToBoolean(JSContext *cx, jsval valueArg, JSBool *bp)
{
RootedValue value(cx, valueArg);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, v);
*bp = ToBoolean(v);
assertSameCompartment(cx, value);
*bp = ToBoolean(value);
return JS_TRUE;
}
JS_PUBLIC_API(JSType)
JS_TypeOfValue(JSContext *cx, jsval v)
JS_TypeOfValue(JSContext *cx, jsval valueArg)
{
RootedValue value(cx, valueArg);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, v);
return TypeOfValue(cx, v);
assertSameCompartment(cx, value);
return TypeOfValue(cx, value);
}
JS_PUBLIC_API(const char *)
@ -661,39 +670,45 @@ JS_GetTypeName(JSContext *cx, JSType type)
}
JS_PUBLIC_API(JSBool)
JS_StrictlyEqual(JSContext *cx, jsval v1, jsval v2, JSBool *equal)
JS_StrictlyEqual(JSContext *cx, jsval value1Arg, jsval value2Arg, JSBool *equal)
{
RootedValue value1(cx, value1Arg);
RootedValue value2(cx, value2Arg);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, v1, v2);
assertSameCompartment(cx, value1, value2);
bool eq;
if (!StrictlyEqual(cx, v1, v2, &eq))
if (!StrictlyEqual(cx, value1, value2, &eq))
return false;
*equal = eq;
return true;
}
JS_PUBLIC_API(JSBool)
JS_LooselyEqual(JSContext *cx, jsval v1, jsval v2, JSBool *equal)
JS_LooselyEqual(JSContext *cx, jsval value1Arg, jsval value2Arg, JSBool *equal)
{
RootedValue value1(cx, value1Arg);
RootedValue value2(cx, value2Arg);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, v1, v2);
assertSameCompartment(cx, value1, value2);
bool eq;
if (!LooselyEqual(cx, v1, v2, &eq))
if (!LooselyEqual(cx, value1, value2, &eq))
return false;
*equal = eq;
return true;
}
JS_PUBLIC_API(JSBool)
JS_SameValue(JSContext *cx, jsval v1, jsval v2, JSBool *same)
JS_SameValue(JSContext *cx, jsval value1Arg, jsval value2Arg, JSBool *same)
{
RootedValue value1(cx, value1Arg);
RootedValue value2(cx, value2Arg);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, v1, v2);
assertSameCompartment(cx, value1, value2);
bool s;
if (!SameValue(cx, v1, v2, &s))
if (!SameValue(cx, value1, value2, &s))
return false;
*same = s;
return true;
@ -3155,12 +3170,13 @@ JS_DestroyIdArray(JSContext *cx, JSIdArray *ida)
}
JS_PUBLIC_API(JSBool)
JS_ValueToId(JSContext *cx, jsval v, jsid *idp)
JS_ValueToId(JSContext *cx, jsval valueArg, jsid *idp)
{
RootedValue value(cx, valueArg);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, v);
return ValueToId(cx, v, idp);
assertSameCompartment(cx, value);
return ValueToId(cx, value, idp);
}
JS_PUBLIC_API(JSBool)
@ -3272,12 +3288,13 @@ JS_InstanceOf(JSContext *cx, JSObject *objArg, JSClass *clasp, jsval *argv)
}
JS_PUBLIC_API(JSBool)
JS_HasInstance(JSContext *cx, JSObject *objArg, jsval v, JSBool *bp)
JS_HasInstance(JSContext *cx, JSObject *objArg, jsval valueArg, JSBool *bp)
{
RootedObject obj(cx, objArg);
RootedValue value(cx, valueArg);
AssertHeapIsIdle(cx);
assertSameCompartment(cx, obj, v);
return HasInstance(cx, obj, &v, bp);
assertSameCompartment(cx, obj, value);
return HasInstance(cx, obj, &value, bp);
}
JS_PUBLIC_API(void *)
@ -3842,12 +3859,12 @@ DefinePropertyById(JSContext *cx, HandleObject obj, HandleId id, HandleValue val
}
JS_PUBLIC_API(JSBool)
JS_DefinePropertyById(JSContext *cx, JSObject *objArg, jsid idArg, jsval value_,
JS_DefinePropertyById(JSContext *cx, JSObject *objArg, jsid idArg, jsval valueArg,
JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs)
{
RootedObject obj(cx, objArg);
RootedId id(cx, idArg);
RootedValue value(cx, value_);
RootedValue value(cx, valueArg);
return DefinePropertyById(cx, obj, id, value, GetterWrapper(getter),
SetterWrapper(setter), attrs, 0, 0);
}
@ -3892,19 +3909,21 @@ DefineProperty(JSContext *cx, JSHandleObject obj, const char *name, const Value
}
JS_PUBLIC_API(JSBool)
JS_DefineProperty(JSContext *cx, JSObject *objArg, const char *name, jsval value,
JS_DefineProperty(JSContext *cx, JSObject *objArg, const char *name, jsval valueArg,
PropertyOp getter, JSStrictPropertyOp setter, unsigned attrs)
{
RootedObject obj(cx, objArg);
RootedValue value(cx, valueArg);
return DefineProperty(cx, obj, name, value, GetterWrapper(getter),
SetterWrapper(setter), attrs, 0, 0);
}
JS_PUBLIC_API(JSBool)
JS_DefinePropertyWithTinyId(JSContext *cx, JSObject *objArg, const char *name, int8_t tinyid,
jsval value, PropertyOp getter, JSStrictPropertyOp setter, unsigned attrs)
jsval valueArg, PropertyOp getter, JSStrictPropertyOp setter, unsigned attrs)
{
RootedObject obj(cx, objArg);
RootedValue value(cx, valueArg);
return DefineProperty(cx, obj, name, value, GetterWrapper(getter),
SetterWrapper(setter), attrs, Shape::HAS_SHORTID, tinyid);
}
@ -3926,18 +3945,20 @@ DefineUCProperty(JSContext *cx, JSHandleObject obj, const jschar *name, size_t n
JS_PUBLIC_API(JSBool)
JS_DefineUCProperty(JSContext *cx, JSObject *objArg, const jschar *name, size_t namelen,
jsval value, JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs)
jsval valueArg, JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs)
{
RootedObject obj(cx, objArg);
RootedValue value(cx, valueArg);
return DefineUCProperty(cx, obj, name, namelen, value, getter, setter, attrs, 0, 0);
}
JS_PUBLIC_API(JSBool)
JS_DefineUCPropertyWithTinyId(JSContext *cx, JSObject *objArg, const jschar *name, size_t namelen,
int8_t tinyid, jsval value,
int8_t tinyid, jsval valueArg,
JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs)
{
RootedObject obj(cx, objArg);
RootedValue value(cx, valueArg);
return DefineUCProperty(cx, obj, name, namelen, value, getter, setter, attrs,
Shape::HAS_SHORTID, tinyid);
}
@ -4716,9 +4737,9 @@ JS_GetReservedSlot(RawObject obj, uint32_t index)
}
JS_PUBLIC_API(void)
JS_SetReservedSlot(RawObject obj, uint32_t index, jsval v)
JS_SetReservedSlot(RawObject obj, uint32_t index, RawValue value)
{
obj->setReservedSlot(index, v);
obj->setReservedSlot(index, value);
}
JS_PUBLIC_API(JSObject *)
@ -4766,11 +4787,14 @@ JS_CheckAccess(JSContext *cx, JSObject *objArg, jsid idArg, JSAccessMode mode,
{
RootedObject obj(cx, objArg);
RootedId id(cx, idArg);
RootedValue value(cx, *vp);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj, id);
return CheckAccess(cx, obj, id, mode, vp, attrsp);
JSBool status = CheckAccess(cx, obj, id, mode, &value, attrsp);
*vp = value;
return status;
}
JS_PUBLIC_API(void)
@ -6421,36 +6445,38 @@ JS_ReadStructuredClone(JSContext *cx, const uint64_t *buf, size_t nbytes,
}
JS_PUBLIC_API(JSBool)
JS_WriteStructuredClone(JSContext *cx, jsval v, uint64_t **bufp, size_t *nbytesp,
JS_WriteStructuredClone(JSContext *cx, jsval valueArg, uint64_t **bufp, size_t *nbytesp,
const JSStructuredCloneCallbacks *optionalCallbacks,
void *closure)
{
RootedValue value(cx, valueArg);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, v);
assertSameCompartment(cx, value);
const JSStructuredCloneCallbacks *callbacks =
optionalCallbacks ?
optionalCallbacks :
cx->runtime->structuredCloneCallbacks;
return WriteStructuredClone(cx, v, (uint64_t **) bufp, nbytesp, callbacks, closure);
return WriteStructuredClone(cx, value, (uint64_t **) bufp, nbytesp, callbacks, closure);
}
JS_PUBLIC_API(JSBool)
JS_StructuredClone(JSContext *cx, jsval v, jsval *vp,
JS_StructuredClone(JSContext *cx, jsval valueArg, jsval *vp,
const JSStructuredCloneCallbacks *optionalCallbacks,
void *closure)
{
RootedValue value(cx, valueArg);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, v);
assertSameCompartment(cx, value);
const JSStructuredCloneCallbacks *callbacks =
optionalCallbacks ?
optionalCallbacks :
cx->runtime->structuredCloneCallbacks;
JSAutoStructuredCloneBuffer buf;
return buf.write(cx, v, callbacks, closure) &&
return buf.write(cx, value, callbacks, closure) &&
buf.read(cx, vp, callbacks, closure);
}
@ -6514,12 +6540,13 @@ JSAutoStructuredCloneBuffer::read(JSContext *cx, jsval *vp,
}
bool
JSAutoStructuredCloneBuffer::write(JSContext *cx, jsval v,
JSAutoStructuredCloneBuffer::write(JSContext *cx, jsval valueArg,
const JSStructuredCloneCallbacks *optionalCallbacks,
void *closure)
{
RootedValue value(cx, valueArg);
clear();
bool ok = !!JS_WriteStructuredClone(cx, v, &data_, &nbytes_,
bool ok = !!JS_WriteStructuredClone(cx, value, &data_, &nbytes_,
optionalCallbacks, closure);
if (!ok) {
data_ = NULL;
@ -6923,12 +6950,13 @@ JS_GetPendingException(JSContext *cx, jsval *vp)
}
JS_PUBLIC_API(void)
JS_SetPendingException(JSContext *cx, jsval v)
JS_SetPendingException(JSContext *cx, jsval valueArg)
{
RootedValue value(cx, valueArg);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, v);
cx->setPendingException(v);
assertSameCompartment(cx, value);
cx->setPendingException(value);
}
JS_PUBLIC_API(void)
@ -6997,12 +7025,13 @@ JS_DropExceptionState(JSContext *cx, JSExceptionState *state)
}
JS_PUBLIC_API(JSErrorReport *)
JS_ErrorFromException(JSContext *cx, jsval v)
JS_ErrorFromException(JSContext *cx, jsval valueArg)
{
RootedValue value(cx, valueArg);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, v);
return js_ErrorFromException(cx, v);
assertSameCompartment(cx, value);
return js_ErrorFromException(cx, value);
}
JS_PUBLIC_API(JSBool)
@ -7199,19 +7228,13 @@ AutoGCRooter::AutoGCRooter(JSContext *cx, ptrdiff_t tag)
*stackTop = this;
}
AutoEnumStateRooter::~AutoEnumStateRooter()
{
if (!stateValue.isNull())
MOZ_ALWAYS_TRUE(JSObject::enumerate(context, obj, JSENUMERATE_DESTROY, &stateValue, 0));
}
#ifdef DEBUG
JS_PUBLIC_API(void)
AssertArgumentsAreSane(JSContext *cx, const JS::Value &v)
AssertArgumentsAreSane(JSContext *cx, const JS::Value &value)
{
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, v);
assertSameCompartment(cx, value);
}
#endif /* DEBUG */

View File

@ -1044,7 +1044,6 @@ class JS_PUBLIC_API(AutoGCRooter) {
VALARRAY = -2, /* js::AutoValueArrayRooter */
PARSER = -3, /* js::frontend::Parser */
SHAPEVECTOR = -4, /* js::AutoShapeVector */
ENUMERATOR = -5, /* js::AutoEnumStateRooter */
IDARRAY = -6, /* js::AutoIdArray */
DESCRIPTORS = -7, /* js::AutoPropDescArrayRooter */
NAMESPACES = -8, /* js::AutoNamespaceArray */
@ -1218,36 +1217,6 @@ class AutoArrayRooter : private AutoGCRooter {
SkipRoot skip;
};
/* The auto-root for enumeration object and its state. */
class AutoEnumStateRooter : private AutoGCRooter
{
public:
AutoEnumStateRooter(JSContext *cx, JSObject *obj
JS_GUARD_OBJECT_NOTIFIER_PARAM)
: AutoGCRooter(cx, ENUMERATOR), obj(cx, obj), stateValue(), context(cx)
{
JS_GUARD_OBJECT_NOTIFIER_INIT;
JS_ASSERT(obj);
}
~AutoEnumStateRooter();
friend void AutoGCRooter::trace(JSTracer *trc);
const Value &state() const { return stateValue; }
Value *addr() { return &stateValue; }
protected:
void trace(JSTracer *trc);
RootedObject obj;
private:
Value stateValue;
JSContext *context;
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
};
template<class T>
class AutoVectorRooter : protected AutoGCRooter
{
@ -1642,10 +1611,11 @@ JS_STATIC_ASSERT(sizeof(jsval_layout) == sizeof(jsval));
typedef JS::Handle<JSObject*> JSHandleObject;
typedef JS::Handle<JSString*> JSHandleString;
typedef JS::Handle<jsid> JSHandleId;
typedef JS::Handle<JS::Value> JSHandleValue;
typedef JS::Handle<jsid> JSHandleId;
typedef JS::MutableHandle<JSObject*> JSMutableHandleObject;
typedef JS::MutableHandle<JS::Value> JSMutableHandleValue;
typedef JS::MutableHandle<jsid> JSMutableHandleId;
typedef JS::RawObject JSRawObject;
#else
@ -1656,11 +1626,12 @@ typedef JS::RawObject JSRawObject;
*/
typedef struct { JSObject **_; } JSHandleObject;
typedef struct { jsval _; } JSHandleValue;
typedef struct { JSString **_; } JSHandleString;
typedef struct { JSObject **_; } JSMutableHandleObject;
typedef struct { jsval *_; } JSHandleValue;
typedef struct { jsid *_; } JSHandleId;
typedef struct { JSObject **_; } JSMutableHandleObject;
typedef struct { jsval *_; } JSMutableHandleValue;
typedef struct { jsid *_; } JSMutableHandleId;
typedef JSObject *JSRawObject;
JSBool JS_CreateHandleObject(JSContext *cx, JSObject *obj, JSHandleObject *phandle);
@ -1730,7 +1701,7 @@ typedef JSBool
*/
typedef JSBool
(* JSNewEnumerateOp)(JSContext *cx, JSHandleObject obj, JSIterateOp enum_op,
jsval *statep, jsid *idp);
JSMutableHandleValue statep, JSMutableHandleId idp);
/*
* The old-style JSClass.enumerate op should define all lazy properties not
@ -1830,7 +1801,7 @@ struct JSStringFinalizer {
*/
typedef JSBool
(* JSCheckAccessOp)(JSContext *cx, JSHandleObject obj, JSHandleId id, JSAccessMode mode,
jsval *vp);
JSMutableHandleValue vp);
/*
* Check whether v is an instance of obj. Return false on error or exception,
@ -1838,7 +1809,7 @@ typedef JSBool
* *bp otherwise.
*/
typedef JSBool
(* JSHasInstanceOp)(JSContext *cx, JSHandleObject obj, const jsval *v, JSBool *bp);
(* JSHasInstanceOp)(JSContext *cx, JSHandleObject obj, JSMutableHandleValue vp, JSBool *bp);
/*
* Function type for trace operation of the class called to enumerate all
@ -1868,7 +1839,7 @@ typedef void
(* JSTraceNamePrinter)(JSTracer *trc, char *buf, size_t bufsize);
typedef JSBool
(* JSEqualityOp)(JSContext *cx, JSHandleObject obj, const jsval *v, JSBool *bp);
(* JSEqualityOp)(JSContext *cx, JSHandleObject obj, JSHandleValue v, JSBool *bp);
/*
* Typedef for native functions called by the JS VM.
@ -2499,14 +2470,6 @@ class AutoIdRooter : private AutoGCRooter
/************************************************************************/
/* Lock and unlock the GC thing held by a jsval. */
#define JSVAL_LOCK(cx,v) (JSVAL_IS_GCTHING(v) \
? JS_LockGCThing(cx, JSVAL_TO_GCTHING(v)) \
: JS_TRUE)
#define JSVAL_UNLOCK(cx,v) (JSVAL_IS_GCTHING(v) \
? JS_UnlockGCThing(cx, JSVAL_TO_GCTHING(v)) \
: JS_TRUE)
/* Property attributes, set in JSPropertySpec and passed to API functions. */
#define JSPROP_ENUMERATE 0x01 /* property is visible to for/in loop */
#define JSPROP_READONLY 0x02 /* not settable: assignment is no-op.

View File

@ -255,7 +255,7 @@ JS_SetWatchPoint(JSContext *cx, JSObject *obj_, jsid id,
if (!obj)
return false;
Value v;
RootedValue v(cx);
unsigned attrs;
RootedId propid(cx);

View File

@ -271,9 +271,9 @@ InitExnPrivate(JSContext *cx, HandleObject exnObject, HandleString message,
* NB: this means 'fp' may point to cross-compartment frames.
*/
if (checkAccess && i.isNonEvalFunctionFrame()) {
Value v = NullValue();
RootedValue v(cx);
RootedId callerid(cx, NameToId(cx->runtime->atomState.callerAtom));
Rooted<JSObject*> obj(cx, i.callee());
RootedObject obj(cx, i.callee());
if (!checkAccess(cx, obj, callerid, JSACC_READ, &v))
break;
}

View File

@ -151,7 +151,8 @@ extern JS_FRIEND_API(JSBool)
JS_WrapAutoIdVector(JSContext *cx, JS::AutoIdVector &props);
extern JS_FRIEND_API(JSBool)
JS_EnumerateState(JSContext *cx, JSHandleObject obj, JSIterateOp enum_op, js::Value *statep, jsid *idp);
JS_EnumerateState(JSContext *cx, JSHandleObject obj, JSIterateOp enum_op,
js::MutableHandleValue statep, js::MutableHandleId idp);
struct JSFunctionSpecWithHelp {
const char *name;

View File

@ -450,9 +450,9 @@ js::CloneInterpretedFunction(JSContext *cx, HandleObject enclosingScope, HandleF
* if v is an object) returning true if .prototype is found.
*/
static JSBool
fun_hasInstance(JSContext *cx, HandleObject obj_, const Value *v, JSBool *bp)
fun_hasInstance(JSContext *cx, HandleObject objArg, MutableHandleValue v, JSBool *bp)
{
RootedObject obj(cx, obj_);
RootedObject obj(cx, objArg);
while (obj->isFunction()) {
if (!obj->isBoundFunction())
@ -474,7 +474,7 @@ fun_hasInstance(JSContext *cx, HandleObject obj_, const Value *v, JSBool *bp)
return JS_FALSE;
}
*bp = js_IsDelegate(cx, &pval.toObject(), *v);
*bp = js_IsDelegate(cx, &pval.toObject(), v);
return JS_TRUE;
}

View File

@ -2236,11 +2236,6 @@ AutoIdArray::trace(JSTracer *trc)
gc::MarkIdRange(trc, idArray->length, idArray->vector, "JSAutoIdArray.idArray");
}
void
AutoEnumStateRooter::trace(JSTracer *trc)
{
}
inline void
AutoGCRooter::trace(JSTracer *trc)
{
@ -2253,10 +2248,6 @@ AutoGCRooter::trace(JSTracer *trc)
static_cast<frontend::Parser *>(this)->trace(trc);
return;
case ENUMERATOR:
static_cast<AutoEnumStateRooter *>(this)->trace(trc);
return;
case IDARRAY: {
JSIdArray *ida = static_cast<AutoIdArray *>(this)->idArray;
MarkIdRange(trc, ida->length, ida->vector, "JS::AutoIdArray.idArray");

View File

@ -525,7 +525,7 @@ js::Execute(JSContext *cx, HandleScript script, JSObject &scopeChainArg, Value *
}
JSBool
js::HasInstance(JSContext *cx, HandleObject obj, const Value *v, JSBool *bp)
js::HasInstance(JSContext *cx, HandleObject obj, MutableHandleValue v, JSBool *bp)
{
Class *clasp = obj->getClass();
if (clasp->hasInstance)
@ -570,8 +570,9 @@ js::LooselyEqual(JSContext *cx, const Value &lval, const Value &rval, bool *resu
if (JSEqualityOp eq = l->getClass()->ext.equality) {
JSBool res;
Rooted<JSObject*> lobj(cx, l);
if (!eq(cx, lobj, &rval, &res))
RootedObject lobj(cx, l);
RootedValue r(cx, rval);
if (!eq(cx, lobj, r, &res))
return false;
*result = !!res;
return true;
@ -2992,9 +2993,9 @@ BEGIN_CASE(JSOP_SETTER)
* Getters and setters are just like watchpoints from an access control
* point of view.
*/
Value rtmp;
scratch.setUndefined();
unsigned attrs;
if (!CheckAccess(cx, obj, id, JSACC_WATCH, &rtmp, &attrs))
if (!CheckAccess(cx, obj, id, JSACC_WATCH, &scratch, &attrs))
goto error;
PropertyOp getter;
@ -3260,9 +3261,8 @@ BEGIN_CASE(JSOP_INSTANCEOF)
}
RootedObject &obj = rootObject0;
obj = &rref.toObject();
const Value &lref = regs.sp[-2];
JSBool cond = JS_FALSE;
if (!HasInstance(cx, obj, &lref, &cond))
if (!HasInstance(cx, obj, MutableHandleValue::fromMarkedLocation(&regs.sp[-2]), &cond))
goto error;
regs.sp--;
regs.sp[-1].setBoolean(cond);

View File

@ -205,7 +205,7 @@ extern JSType
TypeOfValue(JSContext *cx, const Value &v);
extern JSBool
HasInstance(JSContext *cx, HandleObject obj, const js::Value *v, JSBool *bp);
HasInstance(JSContext *cx, HandleObject obj, MutableHandleValue v, JSBool *bp);
/*
* A linked list of the |FrameRegs regs;| variables belonging to all

View File

@ -259,16 +259,17 @@ Snapshot(JSContext *cx, RawObject obj_, unsigned flags, AutoIdVector *props)
/* Proxy objects enumerate the prototype on their own, so we are done here. */
break;
}
Value state;
RootedValue state(cx);
RootedId id(cx);
JSIterateOp op = (flags & JSITER_HIDDEN) ? JSENUMERATE_INIT_ALL : JSENUMERATE_INIT;
if (!JSObject::enumerate(cx, pobj, op, &state, NULL))
if (!JSObject::enumerate(cx, pobj, op, &state, &id))
return false;
if (state.isMagic(JS_NATIVE_ENUMERATE)) {
if (!EnumerateNativeProperties(cx, obj, pobj, flags, ht, props))
return false;
} else {
while (true) {
jsid id;
RootedId id(cx);
if (!JSObject::enumerate(cx, pobj, JSENUMERATE_NEXT, &state, &id))
return false;
if (state.isNull())
@ -1280,9 +1281,9 @@ js_IteratorNext(JSContext *cx, JSObject *iterobj, MutableHandleValue rval)
}
static JSBool
stopiter_hasInstance(JSContext *cx, HandleObject obj, const Value *v, JSBool *bp)
stopiter_hasInstance(JSContext *cx, HandleObject obj, MutableHandleValue v, JSBool *bp)
{
*bp = IsStopIteration(*v);
*bp = IsStopIteration(v);
return JS_TRUE;
}

View File

@ -433,7 +433,7 @@ obj_watch(JSContext *cx, unsigned argc, Value *vp)
if (!obj)
return false;
Value tmp;
RootedValue tmp(cx);
unsigned attrs;
if (!CheckAccess(cx, obj, propid, JSACC_WATCH, &tmp, &attrs))
return false;
@ -1289,7 +1289,7 @@ DefinePropertyOnObject(JSContext *cx, HandleObject obj, HandleId id, const PropD
* Getters and setters are just like watchpoints from an access
* control point of view.
*/
Value dummy;
RootedValue dummy(cx);
unsigned dummyAttrs;
if (!CheckAccess(cx, obj, id, JSACC_WATCH, &dummy, &dummyAttrs))
return JS_FALSE;
@ -1496,7 +1496,7 @@ DefinePropertyOnObject(JSContext *cx, HandleObject obj, HandleId id, const PropD
* Getters and setters are just like watchpoints from an access
* control point of view.
*/
Value dummy;
RootedValue dummy(cx);
if (!CheckAccess(cx, obj2, id, JSACC_WATCH, &dummy, &attrs))
return JS_FALSE;
@ -4956,7 +4956,8 @@ DefaultValue(JSContext *cx, HandleObject obj, JSType hint, MutableHandleValue vp
} /* namespace js */
JS_FRIEND_API(JSBool)
JS_EnumerateState(JSContext *cx, JSHandleObject obj, JSIterateOp enum_op, Value *statep, jsid *idp)
JS_EnumerateState(JSContext *cx, JSHandleObject obj, JSIterateOp enum_op,
JSMutableHandleValue statep, JSMutableHandleId idp)
{
/* If the class has a custom JSCLASS_NEW_ENUMERATE hook, call it. */
Class *clasp = obj->getClass();
@ -4971,7 +4972,7 @@ JS_EnumerateState(JSContext *cx, JSHandleObject obj, JSIterateOp enum_op, Value
/* Tell InitNativeIterator to treat us like a native object. */
JS_ASSERT(enum_op == JSENUMERATE_INIT || enum_op == JSENUMERATE_INIT_ALL);
statep->setMagic(JS_NATIVE_ENUMERATE);
statep.setMagic(JS_NATIVE_ENUMERATE);
return true;
}
@ -4979,7 +4980,7 @@ namespace js {
JSBool
CheckAccess(JSContext *cx, JSObject *obj_, HandleId id, JSAccessMode mode,
Value *vp, unsigned *attrsp)
MutableHandleValue vp, unsigned *attrsp)
{
JSBool writing;
RootedObject obj(cx, obj_), pobj(cx);
@ -4992,7 +4993,7 @@ CheckAccess(JSContext *cx, JSObject *obj_, HandleId id, JSAccessMode mode,
case JSACC_PROTO:
pobj = obj;
if (!writing)
vp->setObjectOrNull(obj->getProto());
vp.setObjectOrNull(obj->getProto());
*attrsp = JSPROP_PERMANENT;
break;
@ -5002,7 +5003,7 @@ CheckAccess(JSContext *cx, JSObject *obj_, HandleId id, JSAccessMode mode,
return JS_FALSE;
if (!shape) {
if (!writing)
vp->setUndefined();
vp.setUndefined();
*attrsp = 0;
pobj = obj;
break;
@ -5010,7 +5011,7 @@ CheckAccess(JSContext *cx, JSObject *obj_, HandleId id, JSAccessMode mode,
if (!pobj->isNative()) {
if (!writing) {
vp->setUndefined();
vp.setUndefined();
*attrsp = 0;
}
break;
@ -5019,9 +5020,9 @@ CheckAccess(JSContext *cx, JSObject *obj_, HandleId id, JSAccessMode mode,
*attrsp = shape->attributes();
if (!writing) {
if (shape->hasSlot())
*vp = pobj->nativeGetSlot(shape->slot());
vp.set(pobj->nativeGetSlot(shape->slot()));
else
vp->setUndefined();
vp.setUndefined();
}
}

View File

@ -883,8 +883,8 @@ struct JSObject : public js::ObjectImpl
static bool deleteByValue(JSContext *cx, js::HandleObject obj,
const js::Value &property, js::MutableHandleValue rval, bool strict);
static inline bool enumerate(JSContext *cx, js::HandleObject obj,
JSIterateOp iterop, js::Value *statep, jsid *idp);
static inline bool enumerate(JSContext *cx, JS::HandleObject obj, JSIterateOp iterop,
JS::MutableHandleValue statep, JS::MutableHandleId idp);
static inline bool defaultValue(JSContext *cx, js::HandleObject obj,
JSType hint, js::MutableHandleValue vp);
static inline JSType typeOf(JSContext *cx, js::HandleObject obj);
@ -1314,7 +1314,7 @@ HasDataProperty(JSContext *cx, HandleObject obj, PropertyName *name, Value *vp)
extern JSBool
CheckAccess(JSContext *cx, JSObject *obj, HandleId id, JSAccessMode mode,
js::Value *vp, unsigned *attrsp);
MutableHandleValue v, unsigned *attrsp);
} /* namespace js */

View File

@ -53,8 +53,8 @@
#include "vm/String-inl.h"
/* static */ inline bool
JSObject::enumerate(JSContext *cx, js::HandleObject obj,
JSIterateOp iterop, js::Value *statep, jsid *idp)
JSObject::enumerate(JSContext *cx, JS::HandleObject obj, JSIterateOp iterop,
JS::MutableHandleValue statep, JS::MutableHandleId idp)
{
JSNewEnumerateOp op = obj->getOps()->enumerate;
return (op ? op : JS_EnumerateState)(cx, obj, iterop, statep, idp);

View File

@ -328,9 +328,9 @@ BaseProxyHandler::nativeCall(JSContext *cx, IsAcceptableThis test, NativeImpl im
}
bool
BaseProxyHandler::hasInstance(JSContext *cx, JSObject *proxy, const Value *vp, bool *bp)
BaseProxyHandler::hasInstance(JSContext *cx, HandleObject proxy, MutableHandleValue v, bool *bp)
{
RootedValue val(cx, ObjectValue(*proxy));
RootedValue val(cx, ObjectValue(*proxy.get()));
js_ReportValueError(cx, JSMSG_BAD_INSTANCEOF_RHS,
JSDVG_SEARCH_STACK, val, NullPtr());
return false;
@ -478,12 +478,12 @@ IndirectProxyHandler::nativeCall(JSContext *cx, IsAcceptableThis test, NativeImp
}
bool
IndirectProxyHandler::hasInstance(JSContext *cx, JSObject *proxy, const Value *vp,
IndirectProxyHandler::hasInstance(JSContext *cx, HandleObject proxy, MutableHandleValue v,
bool *bp)
{
JSBool b;
RootedObject target(cx, GetProxyTargetObject(proxy));
if (!JS_HasInstance(cx, target, *vp, &b))
if (!JS_HasInstance(cx, target, v, &b))
return false;
*bp = !!b;
return true;
@ -2474,11 +2474,10 @@ Proxy::nativeCall(JSContext *cx, IsAcceptableThis test, NativeImpl impl, CallArg
}
bool
Proxy::hasInstance(JSContext *cx, JSObject *proxy_, const js::Value *vp, bool *bp)
Proxy::hasInstance(JSContext *cx, HandleObject proxy, MutableHandleValue v, bool *bp)
{
JS_CHECK_RECURSION(cx, return false);
RootedObject proxy(cx, proxy_);
return GetProxyHandler(proxy)->hasInstance(cx, proxy, vp, bp);
return GetProxyHandler(proxy)->hasInstance(cx, proxy, v, bp);
}
JSType
@ -2857,7 +2856,7 @@ proxy_Finalize(FreeOp *fop, JSObject *obj)
}
static JSBool
proxy_HasInstance(JSContext *cx, HandleObject proxy, const Value *v, JSBool *bp)
proxy_HasInstance(JSContext *cx, HandleObject proxy, MutableHandleValue v, JSBool *bp)
{
bool b;
if (!Proxy::hasInstance(cx, proxy, v, &b))

View File

@ -112,7 +112,7 @@ class JS_FRIEND_API(BaseProxyHandler) {
virtual bool call(JSContext *cx, JSObject *proxy, unsigned argc, Value *vp);
virtual bool construct(JSContext *cx, JSObject *proxy, unsigned argc, Value *argv, Value *rval);
virtual bool nativeCall(JSContext *cx, IsAcceptableThis test, NativeImpl impl, CallArgs args);
virtual bool hasInstance(JSContext *cx, JSObject *proxy, const Value *vp, bool *bp);
virtual bool hasInstance(JSContext *cx, HandleObject proxy, MutableHandleValue v, bool *bp);
virtual JSType typeOf(JSContext *cx, JSObject *proxy);
virtual bool objectClassIs(JSObject *obj, ESClassValue classValue, JSContext *cx);
virtual JSString *obj_toString(JSContext *cx, JSObject *proxy);
@ -162,7 +162,7 @@ class JS_PUBLIC_API(IndirectProxyHandler) : public BaseProxyHandler {
Value *argv, Value *rval) MOZ_OVERRIDE;
virtual bool nativeCall(JSContext *cx, IsAcceptableThis test, NativeImpl impl,
CallArgs args) MOZ_OVERRIDE;
virtual bool hasInstance(JSContext *cx, JSObject *proxy, const Value *vp,
virtual bool hasInstance(JSContext *cx, HandleObject proxy, MutableHandleValue v,
bool *bp) MOZ_OVERRIDE;
virtual JSType typeOf(JSContext *cx, JSObject *proxy) MOZ_OVERRIDE;
virtual bool objectClassIs(JSObject *obj, ESClassValue classValue,
@ -237,7 +237,7 @@ class Proxy {
static bool call(JSContext *cx, JSObject *proxy, unsigned argc, Value *vp);
static bool construct(JSContext *cx, JSObject *proxy, unsigned argc, Value *argv, Value *rval);
static bool nativeCall(JSContext *cx, IsAcceptableThis test, NativeImpl impl, CallArgs args);
static bool hasInstance(JSContext *cx, JSObject *proxy, const Value *vp, bool *bp);
static bool hasInstance(JSContext *cx, HandleObject proxy, MutableHandleValue v, bool *bp);
static JSType typeOf(JSContext *cx, JSObject *proxy);
static bool objectClassIs(JSObject *obj, ESClassValue classValue, JSContext *cx);
static JSString *obj_toString(JSContext *cx, JSObject *proxy);

View File

@ -813,10 +813,10 @@ ArrayBufferObject::obj_deleteSpecial(JSContext *cx, HandleObject obj,
}
JSBool
ArrayBufferObject::obj_enumerate(JSContext *cx, HandleObject obj,
JSIterateOp enum_op, Value *statep, jsid *idp)
ArrayBufferObject::obj_enumerate(JSContext *cx, HandleObject obj, JSIterateOp enum_op,
MutableHandleValue statep, MutableHandleId idp)
{
statep->setNull();
statep.setNull();
return true;
}
@ -1371,7 +1371,7 @@ class TypedArrayTemplate
static JSBool
obj_enumerate(JSContext *cx, HandleObject tarray, JSIterateOp enum_op,
Value *statep, jsid *idp)
MutableHandleValue statep, MutableHandleId idp)
{
JS_ASSERT(tarray->isTypedArray());
@ -1379,24 +1379,23 @@ class TypedArrayTemplate
switch (enum_op) {
case JSENUMERATE_INIT_ALL:
case JSENUMERATE_INIT:
statep->setInt32(0);
if (idp)
*idp = ::INT_TO_JSID(length(tarray));
statep.setInt32(0);
idp.set(::INT_TO_JSID(length(tarray)));
break;
case JSENUMERATE_NEXT:
index = static_cast<uint32_t>(statep->toInt32());
index = static_cast<uint32_t>(statep.toInt32());
if (index < length(tarray)) {
*idp = ::INT_TO_JSID(index);
statep->setInt32(index + 1);
idp.set(::INT_TO_JSID(index));
statep.setInt32(index + 1);
} else {
JS_ASSERT(index == length(tarray));
statep->setNull();
statep.setNull();
}
break;
case JSENUMERATE_DESTROY:
statep->setNull();
statep.setNull();
break;
}

View File

@ -137,7 +137,7 @@ class ArrayBufferObject : public JSObject
static JSBool
obj_enumerate(JSContext *cx, HandleObject obj, JSIterateOp enum_op,
Value *statep, jsid *idp);
MutableHandleValue statep, MutableHandleId idp);
static JSType
obj_typeOf(JSContext *cx, HandleObject obj);

View File

@ -333,11 +333,11 @@ DirectWrapper::nativeCall(JSContext *cx, IsAcceptableThis test, NativeImpl impl,
}
bool
DirectWrapper::hasInstance(JSContext *cx, JSObject *wrapper, const Value *vp, bool *bp)
DirectWrapper::hasInstance(JSContext *cx, HandleObject wrapper, MutableHandleValue v, bool *bp)
{
*bp = false; // default result if we refuse to perform this action
const jsid id = JSID_VOID;
GET(IndirectProxyHandler::hasInstance(cx, wrapper, vp, bp));
GET(IndirectProxyHandler::hasInstance(cx, wrapper, v, bp));
}
JSString *
@ -704,13 +704,12 @@ CrossCompartmentWrapper::nativeCall(JSContext *cx, IsAcceptableThis test, Native
}
bool
CrossCompartmentWrapper::hasInstance(JSContext *cx, JSObject *wrapper, const Value *vp, bool *bp)
CrossCompartmentWrapper::hasInstance(JSContext *cx, HandleObject wrapper, MutableHandleValue v, bool *bp)
{
AutoCompartment call(cx, wrappedObject(wrapper));
Value v = *vp;
if (!cx->compartment->wrap(cx, &v))
if (!cx->compartment->wrap(cx, v.address()))
return false;
return DirectWrapper::hasInstance(cx, wrapper, &v, bp);
return DirectWrapper::hasInstance(cx, wrapper, v, bp);
}
JSString *
@ -892,7 +891,7 @@ DeadObjectProxy::nativeCall(JSContext *cx, IsAcceptableThis test, NativeImpl imp
}
bool
DeadObjectProxy::hasInstance(JSContext *cx, JSObject *proxy, const Value *vp,
DeadObjectProxy::hasInstance(JSContext *cx, HandleObject proxy, MutableHandleValue v,
bool *bp)
{
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_DEAD_OBJECT);

View File

@ -204,7 +204,7 @@ class JS_FRIEND_API(DirectWrapper) : public Wrapper, public DirectProxyHandler
virtual bool construct(JSContext *cx, JSObject *wrapper, unsigned argc, Value *argv, Value *rval) MOZ_OVERRIDE;
virtual bool nativeCall(JSContext *cx, IsAcceptableThis test, NativeImpl impl,
CallArgs args) MOZ_OVERRIDE;
virtual bool hasInstance(JSContext *cx, JSObject *wrapper, const Value *vp, bool *bp) MOZ_OVERRIDE;
virtual bool hasInstance(JSContext *cx, HandleObject wrapper, MutableHandleValue v, bool *bp) MOZ_OVERRIDE;
virtual JSString *obj_toString(JSContext *cx, JSObject *wrapper) MOZ_OVERRIDE;
virtual JSString *fun_toString(JSContext *cx, JSObject *wrapper, unsigned indent) MOZ_OVERRIDE;
@ -247,7 +247,7 @@ class JS_FRIEND_API(CrossCompartmentWrapper) : public DirectWrapper
virtual bool construct(JSContext *cx, JSObject *wrapper, unsigned argc, Value *argv, Value *rval) MOZ_OVERRIDE;
virtual bool nativeCall(JSContext *cx, IsAcceptableThis test, NativeImpl impl,
CallArgs args) MOZ_OVERRIDE;
virtual bool hasInstance(JSContext *cx, JSObject *wrapper, const Value *vp, bool *bp) MOZ_OVERRIDE;
virtual bool hasInstance(JSContext *cx, HandleObject wrapper, MutableHandleValue v, bool *bp) MOZ_OVERRIDE;
virtual JSString *obj_toString(JSContext *cx, JSObject *wrapper) MOZ_OVERRIDE;
virtual JSString *fun_toString(JSContext *cx, JSObject *wrapper, unsigned indent) MOZ_OVERRIDE;
virtual bool regexp_toShared(JSContext *cx, JSObject *proxy, RegExpGuard *g) MOZ_OVERRIDE;
@ -305,7 +305,7 @@ class JS_FRIEND_API(DeadObjectProxy) : public BaseProxyHandler
virtual bool construct(JSContext *cx, JSObject *proxy, unsigned argc, Value *argv, Value *rval);
virtual bool nativeCall(JSContext *cx, IsAcceptableThis test, NativeImpl impl,
CallArgs args) MOZ_OVERRIDE;
virtual bool hasInstance(JSContext *cx, JSObject *proxy, const Value *vp, bool *bp);
virtual bool hasInstance(JSContext *cx, HandleObject proxy, MutableHandleValue v, bool *bp);
virtual bool objectClassIs(JSObject *obj, ESClassValue classValue, JSContext *cx);
virtual JSString *obj_toString(JSContext *cx, JSObject *proxy);
virtual JSString *fun_toString(JSContext *cx, JSObject *proxy, unsigned indent);

View File

@ -155,12 +155,12 @@ DEFINE_GETTER(NameURI_getter,
if (obj->getClass() == &NamespaceClass) vp.set(obj->getNameURIVal()))
static JSBool
namespace_equality(JSContext *cx, HandleObject obj, const Value *v, JSBool *bp)
namespace_equality(JSContext *cx, HandleObject obj, HandleValue v, JSBool *bp)
{
JSObject *obj2;
JS_ASSERT(v->isObjectOrNull());
obj2 = v->toObjectOrNull();
JS_ASSERT(v.isObjectOrNull());
obj2 = v.toObjectOrNull();
*bp = (!obj2 || obj2->getClass() != &NamespaceClass)
? JS_FALSE
: EqualStrings(obj->getNameURI(), obj2->getNameURI());
@ -269,11 +269,11 @@ qname_identity(JSObject *qna, const JSObject *qnb)
}
static JSBool
qname_equality(JSContext *cx, HandleObject qn, const Value *v, JSBool *bp)
qname_equality(JSContext *cx, HandleObject qn, HandleValue v, JSBool *bp)
{
JSObject *obj2;
obj2 = v->toObjectOrNull();
obj2 = v.toObjectOrNull();
*bp = (!obj2 || obj2->getClass() != &QNameClass)
? JS_FALSE
: qname_identity(qn, obj2);
@ -5059,7 +5059,8 @@ xml_convert(JSContext *cx, HandleObject obj, JSType hint, MutableHandleValue rva
}
static JSBool
xml_enumerate(JSContext *cx, HandleObject obj, JSIterateOp enum_op, Value *statep, jsid *idp)
xml_enumerate(JSContext *cx, HandleObject obj, JSIterateOp enum_op,
MutableHandleValue statep, MutableHandleId idp)
{
JSXML *xml;
uint32_t length, index;
@ -5072,37 +5073,36 @@ xml_enumerate(JSContext *cx, HandleObject obj, JSIterateOp enum_op, Value *state
case JSENUMERATE_INIT:
case JSENUMERATE_INIT_ALL:
if (length == 0) {
statep->setInt32(0);
statep.setInt32(0);
} else {
cursor = cx->new_< JSXMLArrayCursor<JSXML> >(&xml->xml_kids);
if (!cursor)
return JS_FALSE;
statep->setPrivate(cursor);
statep.address()->setPrivate(cursor);
}
if (idp)
*idp = INT_TO_JSID(length);
idp.set(INT_TO_JSID(length));
break;
case JSENUMERATE_NEXT:
if (statep->isInt32(0)) {
statep->setNull();
if (statep.address()->isInt32(0)) {
statep.setNull();
break;
}
cursor = (JSXMLArrayCursor<JSXML> *) statep->toPrivate();
cursor = (JSXMLArrayCursor<JSXML> *) statep.address()->toPrivate();
if (cursor && cursor->array && (index = cursor->index) < length) {
*idp = INT_TO_JSID(index);
idp.set(INT_TO_JSID(index));
cursor->index = index + 1;
break;
}
/* FALL THROUGH */
case JSENUMERATE_DESTROY:
if (!statep->isInt32(0)) {
cursor = (JSXMLArrayCursor<JSXML> *) statep->toPrivate();
if (!statep.address()->isInt32(0)) {
cursor = (JSXMLArrayCursor<JSXML> *) statep.address()->toPrivate();
if (cursor)
js_delete(cursor);
}
statep->setNull();
statep.setNull();
break;
}
return JS_TRUE;
@ -5115,7 +5115,7 @@ xml_typeOf(JSContext *cx, HandleObject obj)
}
static JSBool
xml_hasInstance(JSContext *cx, HandleObject obj, const Value *, JSBool *bp)
xml_hasInstance(JSContext *cx, HandleObject obj, MutableHandleValue v, JSBool *bp)
{
return JS_TRUE;
}

View File

@ -493,8 +493,9 @@ StubEqualityOp(VMFrame &f)
JSObject *l = &lval.toObject(), *r = &rval.toObject();
if (JSEqualityOp eq = l->getClass()->ext.equality) {
JSBool equal;
Rooted<JSObject*> lobj(cx, l);
if (!eq(cx, lobj, &rval, &equal))
RootedObject lobj(cx, l);
RootedValue r(cx, rval);
if (!eq(cx, lobj, r, &equal))
return false;
cond = !!equal == EQ;
} else {
@ -1149,9 +1150,9 @@ stubs::InstanceOf(VMFrame &f)
THROWV(JS_FALSE);
}
RootedObject obj(cx, &rref.toObject());
const Value &lref = regs.sp[-2];
MutableHandleValue lref = MutableHandleValue::fromMarkedLocation(&regs.sp[-2]);
JSBool cond = JS_FALSE;
if (!HasInstance(cx, obj, &lref, &cond))
if (!HasInstance(cx, obj, lref, &cond))
THROWV(JS_FALSE);
f.regs.sp[-2].setBoolean(cond);
return cond;

View File

@ -4796,7 +4796,8 @@ MaybeOverrideOutFileFromEnv(const char* const envVar,
JSPrincipals shellTrustedPrincipals = { 1 };
JSBool
CheckObjectAccess(JSContext *cx, HandleObject obj, HandleId id, JSAccessMode mode, jsval *vp)
CheckObjectAccess(JSContext *cx, HandleObject obj, HandleId id, JSAccessMode mode,
MutableHandleValue vp)
{
return true;
}

View File

@ -74,10 +74,10 @@ ProtoGetterImpl(JSContext *cx, CallArgs args)
return false;
unsigned dummy;
Rooted<JSObject*> obj(cx, &args.thisv().toObject());
Rooted<jsid> nid(cx, NameToId(cx->runtime->atomState.protoAtom));
Rooted<Value> v(cx);
if (!CheckAccess(cx, obj, nid, JSACC_PROTO, v.address(), &dummy))
RootedObject obj(cx, &args.thisv().toObject());
RootedId nid(cx, NameToId(cx->runtime->atomState.protoAtom));
RootedValue v(cx);
if (!CheckAccess(cx, obj, nid, JSACC_PROTO, &v, &dummy))
return false;
args.rval().set(v);
@ -154,9 +154,9 @@ ProtoSetterImpl(JSContext *cx, CallArgs args)
Rooted<JSObject*> newProto(cx, args[0].toObjectOrNull());
unsigned dummy;
Rooted<jsid> nid(cx, NameToId(cx->runtime->atomState.protoAtom));
Rooted<Value> v(cx);
if (!CheckAccess(cx, obj, nid, JSAccessMode(JSACC_PROTO | JSACC_WRITE), v.address(), &dummy))
RootedId nid(cx, NameToId(cx->runtime->atomState.protoAtom));
RootedValue v(cx);
if (!CheckAccess(cx, obj, nid, JSAccessMode(JSACC_PROTO | JSACC_WRITE), &v, &dummy))
return false;
if (!SetProto(cx, obj, newProto, true))

View File

@ -482,7 +482,7 @@ with_DeleteSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid,
static JSBool
with_Enumerate(JSContext *cx, HandleObject obj, JSIterateOp enum_op,
Value *statep, jsid *idp)
MutableHandleValue statep, MutableHandleId idp)
{
RootedObject actual(cx, &obj->asWith().object());
return JSObject::enumerate(cx, actual, enum_op, statep, idp);

View File

@ -700,9 +700,8 @@ XPC_GetIdentityObject(JSContext *cx, JSObject *obj)
}
JSBool
XPC_WN_Equality(JSContext *cx, JSHandleObject obj, const jsval *valp, JSBool *bp)
XPC_WN_Equality(JSContext *cx, JSHandleObject obj, JSHandleValue v, JSBool *bp)
{
jsval v = *valp;
*bp = false;
JSObject *obj2;
@ -942,10 +941,10 @@ XPC_WN_Helper_Convert(JSContext *cx, JSHandleObject obj, JSType type, JSMutableH
static JSBool
XPC_WN_Helper_CheckAccess(JSContext *cx, JSHandleObject obj, JSHandleId id,
JSAccessMode mode, jsval *vp)
JSAccessMode mode, JSMutableHandleValue vp)
{
PRE_HELPER_STUB
CheckAccess(wrapper, cx, obj, id, mode, vp, &retval);
CheckAccess(wrapper, cx, obj, id, mode, vp.address(), &retval);
POST_HELPER_STUB
}
@ -989,12 +988,12 @@ XPC_WN_Helper_Construct(JSContext *cx, unsigned argc, jsval *vp)
}
static JSBool
XPC_WN_Helper_HasInstance(JSContext *cx, JSHandleObject obj, const jsval *valp, JSBool *bp)
XPC_WN_Helper_HasInstance(JSContext *cx, JSHandleObject obj, JSMutableHandleValue valp, JSBool *bp)
{
SLIM_LOG_WILL_MORPH(cx, obj);
bool retval2;
PRE_HELPER_STUB_NO_SLIM
HasInstance(wrapper, cx, obj, *valp, &retval2, &retval);
HasInstance(wrapper, cx, obj, valp, &retval2, &retval);
*bp = retval2;
POST_HELPER_STUB
}
@ -1145,7 +1144,7 @@ XPC_WN_Helper_NewResolve(JSContext *cx, JSHandleObject obj, JSHandleId id, unsig
JSBool
XPC_WN_JSOp_Enumerate(JSContext *cx, JSHandleObject obj, JSIterateOp enum_op,
jsval *statep, jsid *idp)
JSMutableHandleValue statep, JSMutableHandleId idp)
{
js::Class *clazz = js::GetObjectClass(obj);
if (!IS_WRAPPER_CLASS(clazz) || clazz == &XPC_WN_NoHelper_JSClass.base) {
@ -1175,7 +1174,7 @@ XPC_WN_JSOp_Enumerate(JSContext *cx, JSHandleObject obj, JSIterateOp enum_op,
enum_op == JSENUMERATE_INIT_ALL) &&
wrapper->HasMutatedSet() &&
!XPC_WN_Shared_Enumerate(cx, obj)) {
*statep = JSVAL_NULL;
statep.set(JSVAL_NULL);
return false;
}
@ -1183,11 +1182,11 @@ XPC_WN_JSOp_Enumerate(JSContext *cx, JSHandleObject obj, JSIterateOp enum_op,
// js_ObjectOps.enumerate ???
rv = si->GetCallback()->
NewEnumerate(wrapper, cx, obj, enum_op, statep, idp, &retval);
NewEnumerate(wrapper, cx, obj, enum_op, statep.address(), idp.address(), &retval);
if ((enum_op == JSENUMERATE_INIT || enum_op == JSENUMERATE_INIT_ALL) &&
(NS_FAILED(rv) || !retval)) {
*statep = JSVAL_NULL;
statep.set(JSVAL_NULL);
}
if (NS_FAILED(rv))
@ -1201,14 +1200,14 @@ XPC_WN_JSOp_Enumerate(JSContext *cx, JSHandleObject obj, JSIterateOp enum_op,
!si->GetFlags().DontEnumStaticProps()) &&
wrapper->HasMutatedSet() &&
!XPC_WN_Shared_Enumerate(cx, obj)) {
*statep = JSVAL_NULL;
statep.set(JSVAL_NULL);
return false;
}
rv = si->GetCallback()->
Enumerate(wrapper, cx, obj, &retval);
if (NS_FAILED(rv) || !retval)
*statep = JSVAL_NULL;
statep.set(JSVAL_NULL);
if (NS_FAILED(rv))
return Throw(rv, cx);

View File

@ -270,9 +270,9 @@ ListBase<LC>::namedItem(JSContext *cx, JSObject *obj, jsval *name, NameGetterTyp
}
JSBool
interface_hasInstance(JSContext *cx, JSHandleObject obj, const JS::Value *vp, JSBool *bp)
interface_hasInstance(JSContext *cx, JSHandleObject obj, JSMutableHandleValue vp, JSBool *bp)
{
if (vp->isObject()) {
if (vp.isObject()) {
jsval prototype;
if (!JS_GetPropertyById(cx, obj, s_prototype_id, &prototype) ||
JSVAL_IS_PRIMITIVE(prototype)) {
@ -281,7 +281,7 @@ interface_hasInstance(JSContext *cx, JSHandleObject obj, const JS::Value *vp, JS
return false;
}
JSObject *other = &vp->toObject();
JSObject *other = &vp.toObject();
if (instanceIsProxy(other)) {
ProxyHandler *handler = static_cast<ProxyHandler*>(js::GetProxyHandler(other));
if (handler->isInstanceOf(JSVAL_TO_OBJECT(prototype))) {

View File

@ -1451,7 +1451,7 @@ XPC_WN_GetterSetter(JSContext *cx, unsigned argc, jsval *vp);
extern JSBool
XPC_WN_JSOp_Enumerate(JSContext *cx, JSHandleObject obj, JSIterateOp enum_op,
jsval *statep, jsid *idp);
JSMutableHandleValue statep, JSMutableHandleId idp);
extern JSType
XPC_WN_JSOp_TypeOf_Object(JSContext *cx, JSHandleObject obj);