Give the JS engine some knowledge of wrappers so that they can compare equal and be noticed when they take part in __proto__ cycles; this was supposed to land before. bug 397855, r=brendan sr=dveditz

This commit is contained in:
mrbkap@gmail.com 2007-12-21 01:10:59 -08:00
parent c39fb98cef
commit 7c7e1261bf
3 changed files with 18 additions and 8 deletions

View File

@ -1212,7 +1212,9 @@ struct JSExtendedClass {
JSObjectOp outerObject;
JSObjectOp innerObject;
JSIteratorOp iteratorObject;
JSObjectOp wrappedObject;
JSObjectOp wrappedObject; /* NB: infallible, null
returns are treated as
the original object */
void (*reserved0)(void);
void (*reserved1)(void);
void (*reserved2)(void);

View File

@ -1522,13 +1522,19 @@ js_StrictlyEqual(JSContext *cx, jsval lval, jsval rval)
robj = JSVAL_TO_OBJECT(rval);
lclasp = OBJ_GET_CLASS(cx, lobj);
rclasp = OBJ_GET_CLASS(cx, robj);
if (lclasp->flags & rclasp->flags & JSCLASS_IS_EXTENDED) {
JSExtendedClass *lxclasp = (JSExtendedClass *) lclasp,
*rxclasp = (JSExtendedClass *) rclasp;
return (lxclasp->wrappedObject && rxclasp->wrappedObject)
? lxclasp->wrappedObject(cx, lval) ==
rxclasp->wrappedObject(cx, rval)
: lval == rval;
if (lclasp->flags & JSCLASS_IS_EXTENDED) {
JSExtendedClass *xclasp = (JSExtendedClass *) lclasp;
if (xclasp->wrappedObject &&
(lobj = xclasp->wrappedObject(cx, lobj))) {
lval = OBJECT_TO_JSVAL(lobj);
}
}
if (rclasp->flags & JSCLASS_IS_EXTENDED) {
JSExtendedClass *xclasp = (JSExtendedClass *) rclasp;
if (xclasp->wrappedObject &&
(robj = xclasp->wrappedObject(cx, robj))) {
rval = OBJECT_TO_JSVAL(robj);
}
}
}
return lval == rval;

View File

@ -201,6 +201,8 @@ JSExtendedClass sXPC_SJOW_JSClass = {
},
// JSExtendedClass initialization
XPC_SJOW_Equality,
nsnull, // outerObject
nsnull, // innerObject
nsnull, // iteratorObject
XPC_SJOW_WrappedObject,
JSCLASS_NO_RESERVED_MEMBERS