Bug 569471 - Rename js_GetWrappedObject to JSObject::wrappedObject. r=jorendorff

This commit is contained in:
Jeff Walden 2010-06-01 15:59:02 -07:00
Родитель fad49a60a6
Коммит 722237e63b
8 изменённых файлов: 26 добавлений и 28 удалений

Просмотреть файл

@ -3761,7 +3761,7 @@ JS_NewArrayObject(JSContext *cx, jsint length, jsval *vector)
JS_PUBLIC_API(JSBool)
JS_IsArrayObject(JSContext *cx, JSObject *obj)
{
return js_GetWrappedObject(cx, obj)->isArray();
return obj->wrappedObject(cx)->isArray();
}
JS_PUBLIC_API(JSBool)

Просмотреть файл

@ -599,7 +599,7 @@ js_HasLengthProperty(JSContext *cx, JSObject *obj, jsuint *lengthp)
JSBool
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();
if (!*answerp) {
@ -2600,7 +2600,7 @@ array_concat(JSContext *cx, uintN argc, jsval *vp)
JSObject *wobj;
aobj = JSVAL_TO_OBJECT(v);
wobj = js_GetWrappedObject(cx, aobj);
wobj = aobj->wrappedObject(cx);
if (wobj->isArray()) {
jsid id = ATOM_TO_JSID(cx->runtime->atomState.lengthAtom);
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 &&
!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;
}

Просмотреть файл

@ -795,7 +795,7 @@ JS_SetWatchPoint(JSContext *cx, JSObject *obj, jsval idval,
JSPropertyOp watcher;
origobj = obj;
obj = js_GetWrappedObject(cx, obj);
obj = obj->wrappedObject(cx);
OBJ_TO_INNER_OBJECT(cx, obj);
if (!obj)
return JS_FALSE;

Просмотреть файл

@ -3258,7 +3258,7 @@ js_SetProtoOrParentCheckingForCycles(JSContext *cx, JSObject *obj,
cycle = false;
for (JSObject *obj2 = pobj; obj2;) {
obj2 = js_GetWrappedObject(cx, obj2);
obj2 = obj2->wrappedObject(cx);
if (obj2 == obj) {
cycle = true;
break;

Просмотреть файл

@ -986,8 +986,8 @@ js_StrictlyEqual(JSContext *cx, jsval lval, jsval rval)
!JSVAL_IS_NULL(rval)) {
JSObject *lobj, *robj;
lobj = js_GetWrappedObject(cx, JSVAL_TO_OBJECT(lval));
robj = js_GetWrappedObject(cx, JSVAL_TO_OBJECT(rval));
lobj = JSVAL_TO_OBJECT(lval)->wrappedObject(cx);
robj = JSVAL_TO_OBJECT(rval)->wrappedObject(cx);
lval = OBJECT_TO_JSVAL(lobj);
rval = OBJECT_TO_JSVAL(robj);
}

Просмотреть файл

@ -879,7 +879,7 @@ obj_toString(JSContext *cx, uintN argc, jsval *vp)
if (!GetProxyObjectClass(cx, obj, &clazz))
return false;
} else {
obj = js_GetWrappedObject(cx, obj);
obj = obj->wrappedObject(cx);
clazz = obj->getClass()->name;
}
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);
/*
* This call to js_GetWrappedObject is safe because of the security checks
* we do below. However, the control flow below is confusing, so we double
* check. There are two cases:
* This call to JSObject::wrappedObject is safe because of the security
* checks we do below. However, the control flow below is confusing, so we
* double check. There are two cases:
* - Direct call: This object is never used. So unwrapping can't hurt.
* - 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
@ -1095,7 +1095,7 @@ obj_eval(JSContext *cx, uintN argc, jsval *vp)
JSObject *obj = JS_THIS_OBJECT(cx, vp);
if (!obj)
return JS_FALSE;
obj = js_GetWrappedObject(cx, obj);
obj = obj->wrappedObject(cx);
/*
* 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
} else {
scopeobj = js_GetWrappedObject(cx, scopeobj);
scopeobj = scopeobj->wrappedObject(cx);
OBJ_TO_INNER_OBJECT(cx, scopeobj);
if (!scopeobj)
return JS_FALSE;
@ -5556,7 +5556,7 @@ js_TypeOf(JSContext *cx, JSObject *obj)
* overwrite js_TypeOf (i.e. XPCCrossOriginWrapper), so we have to
* unwrap here.
*/
obj = js_GetWrappedObject(cx, obj);
obj = obj->wrappedObject(cx);
/*
* 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;
if (JSVAL_IS_PRIMITIVE(v))
return JS_TRUE;
obj2 = js_GetWrappedObject(cx, JSVAL_TO_OBJECT(v));
obj2 = JSVAL_TO_OBJECT(v)->wrappedObject(cx);
while ((obj2 = obj2->getProto()) != NULL) {
if (obj2 == obj) {
*bp = JS_TRUE;
@ -6298,20 +6298,16 @@ js_SetReservedSlot(JSContext *cx, JSObject *obj, uint32 index, jsval v)
}
JSObject *
js_GetWrappedObject(JSContext *cx, JSObject *obj)
JSObject::wrappedObject(JSContext *cx) const
{
JSClass *clasp;
clasp = obj->getClass();
JSClass *clasp = getClass();
if (clasp->flags & JSCLASS_IS_EXTENDED) {
JSExtendedClass *xclasp;
JSObject *obj2;
xclasp = (JSExtendedClass *)clasp;
if (xclasp->wrappedObject && (obj2 = xclasp->wrappedObject(cx, obj)))
return obj2;
if (JSObjectOp wrappedObject = reinterpret_cast<JSExtendedClass *>(clasp)->wrappedObject) {
if (JSObject *obj = wrappedObject(cx, const_cast<JSObject *>(this)))
return obj;
}
}
return obj;
return const_cast<JSObject *>(this);
}
JSObject *

Просмотреть файл

@ -676,6 +676,8 @@ struct JSObject {
return map->ops->typeOf(cx, this);
}
JSObject *wrappedObject(JSContext *cx) const;
/* These four are time-optimized to avoid stub calls. */
JSObject *thisObject(JSContext *cx) {
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.
// See also js_GetWrappedObject in jsobj.h.
// See also JSObject::wrappedObject in jsobj.cpp.
// TODO Move to XPCWrapper?
static inline JSObject *
GetWrappedJSObject(JSContext *cx, JSObject *obj)