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

git-svn-id: svn://10.0.0.236/trunk@241889 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mrbkap%gmail.com 2007-12-21 09:11:02 +00:00
parent 71ba249506
commit 5a85369625
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