зеркало из https://github.com/mozilla/pjs.git
Bug 569471 - Rename js_GetWrappedObject to JSObject::wrappedObject. r=jorendorff
This commit is contained in:
Родитель
fad49a60a6
Коммит
722237e63b
|
@ -3761,7 +3761,7 @@ JS_NewArrayObject(JSContext *cx, jsint length, jsval *vector)
|
||||||
JS_PUBLIC_API(JSBool)
|
JS_PUBLIC_API(JSBool)
|
||||||
JS_IsArrayObject(JSContext *cx, JSObject *obj)
|
JS_IsArrayObject(JSContext *cx, JSObject *obj)
|
||||||
{
|
{
|
||||||
return js_GetWrappedObject(cx, obj)->isArray();
|
return obj->wrappedObject(cx)->isArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API(JSBool)
|
JS_PUBLIC_API(JSBool)
|
||||||
|
|
|
@ -599,7 +599,7 @@ js_HasLengthProperty(JSContext *cx, JSObject *obj, jsuint *lengthp)
|
||||||
JSBool
|
JSBool
|
||||||
js_IsArrayLike(JSContext *cx, JSObject *obj, JSBool *answerp, jsuint *lengthp)
|
js_IsArrayLike(JSContext *cx, JSObject *obj, JSBool *answerp, jsuint *lengthp)
|
||||||
{
|
{
|
||||||
JSObject *wrappedObj = js_GetWrappedObject(cx, obj);
|
JSObject *wrappedObj = obj->wrappedObject(cx);
|
||||||
|
|
||||||
*answerp = wrappedObj->isArguments() || wrappedObj->isArray();
|
*answerp = wrappedObj->isArguments() || wrappedObj->isArray();
|
||||||
if (!*answerp) {
|
if (!*answerp) {
|
||||||
|
@ -2600,7 +2600,7 @@ array_concat(JSContext *cx, uintN argc, jsval *vp)
|
||||||
JSObject *wobj;
|
JSObject *wobj;
|
||||||
|
|
||||||
aobj = JSVAL_TO_OBJECT(v);
|
aobj = JSVAL_TO_OBJECT(v);
|
||||||
wobj = js_GetWrappedObject(cx, aobj);
|
wobj = aobj->wrappedObject(cx);
|
||||||
if (wobj->isArray()) {
|
if (wobj->isArray()) {
|
||||||
jsid id = ATOM_TO_JSID(cx->runtime->atomState.lengthAtom);
|
jsid id = ATOM_TO_JSID(cx->runtime->atomState.lengthAtom);
|
||||||
if (!aobj->getProperty(cx, id, tvr.addr()))
|
if (!aobj->getProperty(cx, id, tvr.addr()))
|
||||||
|
@ -3041,7 +3041,7 @@ array_isArray(JSContext *cx, uintN argc, jsval *vp)
|
||||||
{
|
{
|
||||||
*vp = BOOLEAN_TO_JSVAL(argc > 0 &&
|
*vp = BOOLEAN_TO_JSVAL(argc > 0 &&
|
||||||
!JSVAL_IS_PRIMITIVE(vp[2]) &&
|
!JSVAL_IS_PRIMITIVE(vp[2]) &&
|
||||||
js_GetWrappedObject(cx, JSVAL_TO_OBJECT(vp[2]))->isArray());
|
JSVAL_TO_OBJECT(vp[2])->wrappedObject(cx)->isArray());
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -795,7 +795,7 @@ JS_SetWatchPoint(JSContext *cx, JSObject *obj, jsval idval,
|
||||||
JSPropertyOp watcher;
|
JSPropertyOp watcher;
|
||||||
|
|
||||||
origobj = obj;
|
origobj = obj;
|
||||||
obj = js_GetWrappedObject(cx, obj);
|
obj = obj->wrappedObject(cx);
|
||||||
OBJ_TO_INNER_OBJECT(cx, obj);
|
OBJ_TO_INNER_OBJECT(cx, obj);
|
||||||
if (!obj)
|
if (!obj)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
|
|
|
@ -3258,7 +3258,7 @@ js_SetProtoOrParentCheckingForCycles(JSContext *cx, JSObject *obj,
|
||||||
|
|
||||||
cycle = false;
|
cycle = false;
|
||||||
for (JSObject *obj2 = pobj; obj2;) {
|
for (JSObject *obj2 = pobj; obj2;) {
|
||||||
obj2 = js_GetWrappedObject(cx, obj2);
|
obj2 = obj2->wrappedObject(cx);
|
||||||
if (obj2 == obj) {
|
if (obj2 == obj) {
|
||||||
cycle = true;
|
cycle = true;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -986,8 +986,8 @@ js_StrictlyEqual(JSContext *cx, jsval lval, jsval rval)
|
||||||
!JSVAL_IS_NULL(rval)) {
|
!JSVAL_IS_NULL(rval)) {
|
||||||
JSObject *lobj, *robj;
|
JSObject *lobj, *robj;
|
||||||
|
|
||||||
lobj = js_GetWrappedObject(cx, JSVAL_TO_OBJECT(lval));
|
lobj = JSVAL_TO_OBJECT(lval)->wrappedObject(cx);
|
||||||
robj = js_GetWrappedObject(cx, JSVAL_TO_OBJECT(rval));
|
robj = JSVAL_TO_OBJECT(rval)->wrappedObject(cx);
|
||||||
lval = OBJECT_TO_JSVAL(lobj);
|
lval = OBJECT_TO_JSVAL(lobj);
|
||||||
rval = OBJECT_TO_JSVAL(robj);
|
rval = OBJECT_TO_JSVAL(robj);
|
||||||
}
|
}
|
||||||
|
|
|
@ -879,7 +879,7 @@ obj_toString(JSContext *cx, uintN argc, jsval *vp)
|
||||||
if (!GetProxyObjectClass(cx, obj, &clazz))
|
if (!GetProxyObjectClass(cx, obj, &clazz))
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
obj = js_GetWrappedObject(cx, obj);
|
obj = obj->wrappedObject(cx);
|
||||||
clazz = obj->getClass()->name;
|
clazz = obj->getClass()->name;
|
||||||
}
|
}
|
||||||
nchars = 9 + strlen(clazz); /* 9 for "[object ]" */
|
nchars = 9 + strlen(clazz); /* 9 for "[object ]" */
|
||||||
|
@ -1083,9 +1083,9 @@ obj_eval(JSContext *cx, uintN argc, jsval *vp)
|
||||||
bool indirectCall = (callerPC && *callerPC != JSOP_EVAL);
|
bool indirectCall = (callerPC && *callerPC != JSOP_EVAL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This call to js_GetWrappedObject is safe because of the security checks
|
* This call to JSObject::wrappedObject is safe because of the security
|
||||||
* we do below. However, the control flow below is confusing, so we double
|
* checks we do below. However, the control flow below is confusing, so we
|
||||||
* check. There are two cases:
|
* double check. There are two cases:
|
||||||
* - Direct call: This object is never used. So unwrapping can't hurt.
|
* - Direct call: This object is never used. So unwrapping can't hurt.
|
||||||
* - Indirect call: If this object isn't already the scope chain (which
|
* - Indirect call: If this object isn't already the scope chain (which
|
||||||
* we're guaranteed to be allowed to access) then we do a security
|
* we're guaranteed to be allowed to access) then we do a security
|
||||||
|
@ -1095,7 +1095,7 @@ obj_eval(JSContext *cx, uintN argc, jsval *vp)
|
||||||
JSObject *obj = JS_THIS_OBJECT(cx, vp);
|
JSObject *obj = JS_THIS_OBJECT(cx, vp);
|
||||||
if (!obj)
|
if (!obj)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
obj = js_GetWrappedObject(cx, obj);
|
obj = obj->wrappedObject(cx);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ban all indirect uses of eval (global.foo = eval; global.foo(...)) and
|
* Ban all indirect uses of eval (global.foo = eval; global.foo(...)) and
|
||||||
|
@ -1196,7 +1196,7 @@ obj_eval(JSContext *cx, uintN argc, jsval *vp)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
scopeobj = js_GetWrappedObject(cx, scopeobj);
|
scopeobj = scopeobj->wrappedObject(cx);
|
||||||
OBJ_TO_INNER_OBJECT(cx, scopeobj);
|
OBJ_TO_INNER_OBJECT(cx, scopeobj);
|
||||||
if (!scopeobj)
|
if (!scopeobj)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
|
@ -5556,7 +5556,7 @@ js_TypeOf(JSContext *cx, JSObject *obj)
|
||||||
* overwrite js_TypeOf (i.e. XPCCrossOriginWrapper), so we have to
|
* overwrite js_TypeOf (i.e. XPCCrossOriginWrapper), so we have to
|
||||||
* unwrap here.
|
* unwrap here.
|
||||||
*/
|
*/
|
||||||
obj = js_GetWrappedObject(cx, obj);
|
obj = obj->wrappedObject(cx);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ECMA 262, 11.4.3 says that any native object that implements
|
* ECMA 262, 11.4.3 says that any native object that implements
|
||||||
|
@ -5728,7 +5728,7 @@ js_IsDelegate(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
|
||||||
*bp = JS_FALSE;
|
*bp = JS_FALSE;
|
||||||
if (JSVAL_IS_PRIMITIVE(v))
|
if (JSVAL_IS_PRIMITIVE(v))
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
obj2 = js_GetWrappedObject(cx, JSVAL_TO_OBJECT(v));
|
obj2 = JSVAL_TO_OBJECT(v)->wrappedObject(cx);
|
||||||
while ((obj2 = obj2->getProto()) != NULL) {
|
while ((obj2 = obj2->getProto()) != NULL) {
|
||||||
if (obj2 == obj) {
|
if (obj2 == obj) {
|
||||||
*bp = JS_TRUE;
|
*bp = JS_TRUE;
|
||||||
|
@ -6298,20 +6298,16 @@ js_SetReservedSlot(JSContext *cx, JSObject *obj, uint32 index, jsval v)
|
||||||
}
|
}
|
||||||
|
|
||||||
JSObject *
|
JSObject *
|
||||||
js_GetWrappedObject(JSContext *cx, JSObject *obj)
|
JSObject::wrappedObject(JSContext *cx) const
|
||||||
{
|
{
|
||||||
JSClass *clasp;
|
JSClass *clasp = getClass();
|
||||||
|
|
||||||
clasp = obj->getClass();
|
|
||||||
if (clasp->flags & JSCLASS_IS_EXTENDED) {
|
if (clasp->flags & JSCLASS_IS_EXTENDED) {
|
||||||
JSExtendedClass *xclasp;
|
if (JSObjectOp wrappedObject = reinterpret_cast<JSExtendedClass *>(clasp)->wrappedObject) {
|
||||||
JSObject *obj2;
|
if (JSObject *obj = wrappedObject(cx, const_cast<JSObject *>(this)))
|
||||||
|
return obj;
|
||||||
xclasp = (JSExtendedClass *)clasp;
|
}
|
||||||
if (xclasp->wrappedObject && (obj2 = xclasp->wrappedObject(cx, obj)))
|
|
||||||
return obj2;
|
|
||||||
}
|
}
|
||||||
return obj;
|
return const_cast<JSObject *>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
JSObject *
|
JSObject *
|
||||||
|
|
|
@ -676,6 +676,8 @@ struct JSObject {
|
||||||
return map->ops->typeOf(cx, this);
|
return map->ops->typeOf(cx, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JSObject *wrappedObject(JSContext *cx) const;
|
||||||
|
|
||||||
/* These four are time-optimized to avoid stub calls. */
|
/* These four are time-optimized to avoid stub calls. */
|
||||||
JSObject *thisObject(JSContext *cx) {
|
JSObject *thisObject(JSContext *cx) {
|
||||||
return map->ops->thisObject ? map->ops->thisObject(cx, this) : this;
|
return map->ops->thisObject ? map->ops->thisObject(cx, this) : this;
|
||||||
|
|
|
@ -318,7 +318,7 @@ ThrowException(nsresult rv, JSContext *cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Like GetWrappedObject, but works on other types of wrappers, too.
|
// Like GetWrappedObject, but works on other types of wrappers, too.
|
||||||
// See also js_GetWrappedObject in jsobj.h.
|
// See also JSObject::wrappedObject in jsobj.cpp.
|
||||||
// TODO Move to XPCWrapper?
|
// TODO Move to XPCWrapper?
|
||||||
static inline JSObject *
|
static inline JSObject *
|
||||||
GetWrappedJSObject(JSContext *cx, JSObject *obj)
|
GetWrappedJSObject(JSContext *cx, JSObject *obj)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче