зеркало из https://github.com/mozilla/gecko-dev.git
Fix array_concat to be more generic. bug 420966, r=brendan a=beltzner
This commit is contained in:
Родитель
556a3969cb
Коммит
9a51eefa28
|
@ -2390,8 +2390,11 @@ array_concat(JSContext *cx, uintN argc, jsval *vp)
|
|||
goto out;
|
||||
v = argv[i];
|
||||
if (JSVAL_IS_OBJECT(v)) {
|
||||
JSObject *wobj;
|
||||
|
||||
aobj = JSVAL_TO_OBJECT(v);
|
||||
if (aobj && OBJ_IS_ARRAY(cx, aobj)) {
|
||||
wobj = js_GetWrappedObject(cx, aobj);
|
||||
if (aobj && OBJ_IS_ARRAY(cx, wobj)) {
|
||||
ok = OBJ_GET_PROPERTY(cx, aobj,
|
||||
ATOM_TO_JSID(cx->runtime->atomState
|
||||
.lengthAtom),
|
||||
|
|
|
@ -2874,17 +2874,7 @@ ProcessSetSlotRequest(JSContext *cx, JSSetSlotRequest *ssr)
|
|||
slot = ssr->slot;
|
||||
|
||||
while (pobj) {
|
||||
JSClass *clasp = STOBJ_GET_CLASS(pobj);
|
||||
if (clasp->flags & JSCLASS_IS_EXTENDED) {
|
||||
JSExtendedClass *xclasp = (JSExtendedClass *) clasp;
|
||||
if (xclasp->wrappedObject) {
|
||||
/* If there is no wrapped object, use the wrapper. */
|
||||
JSObject *wrapped = xclasp->wrappedObject(cx, pobj);
|
||||
if (wrapped)
|
||||
pobj = wrapped;
|
||||
}
|
||||
}
|
||||
|
||||
pobj = js_GetWrappedObject(cx, pobj);
|
||||
if (pobj == obj) {
|
||||
ssr->errnum = JSMSG_CYCLIC_VALUE;
|
||||
return;
|
||||
|
|
|
@ -1769,26 +1769,11 @@ js_StrictlyEqual(JSContext *cx, jsval lval, jsval rval)
|
|||
!JSVAL_IS_NULL(lval) &&
|
||||
!JSVAL_IS_NULL(rval)) {
|
||||
JSObject *lobj, *robj;
|
||||
JSClass *lclasp, *rclasp;
|
||||
|
||||
lobj = JSVAL_TO_OBJECT(lval);
|
||||
robj = JSVAL_TO_OBJECT(rval);
|
||||
lclasp = OBJ_GET_CLASS(cx, lobj);
|
||||
rclasp = OBJ_GET_CLASS(cx, robj);
|
||||
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);
|
||||
}
|
||||
}
|
||||
lobj = js_GetWrappedObject(cx, JSVAL_TO_OBJECT(lval));
|
||||
robj = js_GetWrappedObject(cx, JSVAL_TO_OBJECT(rval));
|
||||
lval = OBJECT_TO_JSVAL(lobj);
|
||||
rval = OBJECT_TO_JSVAL(robj);
|
||||
}
|
||||
return lval == rval;
|
||||
}
|
||||
|
|
|
@ -1010,25 +1010,14 @@ obj_toString(JSContext *cx, uintN argc, jsval *vp)
|
|||
JSObject *obj;
|
||||
jschar *chars;
|
||||
size_t nchars;
|
||||
JSClass *clasp;
|
||||
const char *clazz, *prefix;
|
||||
JSString *str;
|
||||
|
||||
obj = JS_THIS_OBJECT(cx, vp);
|
||||
if (!obj)
|
||||
return JS_FALSE;
|
||||
clasp = OBJ_GET_CLASS(cx, obj);
|
||||
if (clasp->flags & JSCLASS_IS_EXTENDED) {
|
||||
JSExtendedClass *xclasp;
|
||||
JSObject *obj2;
|
||||
|
||||
if ((xclasp = (JSExtendedClass *)clasp)->wrappedObject &&
|
||||
(obj2 = xclasp->wrappedObject(cx, obj))) {
|
||||
obj = obj2;
|
||||
clasp = OBJ_GET_CLASS(cx, obj);
|
||||
}
|
||||
}
|
||||
clazz = clasp->name;
|
||||
obj = js_GetWrappedObject(cx, obj);
|
||||
clazz = OBJ_GET_CLASS(cx, obj)->name;
|
||||
nchars = 9 + strlen(clazz); /* 9 for "[object ]" */
|
||||
chars = (jschar *) JS_malloc(cx, (nchars + 1) * sizeof(jschar));
|
||||
if (!chars)
|
||||
|
@ -1174,16 +1163,10 @@ obj_eval(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
* the former indirect case.
|
||||
*/
|
||||
scopeobj = OBJ_GET_PARENT(cx, obj);
|
||||
if (scopeobj &&
|
||||
((clasp = OBJ_GET_CLASS(cx, obj))->flags & JSCLASS_IS_EXTENDED)) {
|
||||
JSExtendedClass *xclasp = (JSExtendedClass *) clasp;
|
||||
if (xclasp->wrappedObject) {
|
||||
JSObject *wrapped = xclasp->wrappedObject(cx, obj);
|
||||
if (wrapped)
|
||||
scopeobj = OBJ_GET_PARENT(cx, wrapped);
|
||||
}
|
||||
if (scopeobj) {
|
||||
scopeobj = js_GetWrappedObject(cx, obj);
|
||||
scopeobj = OBJ_GET_PARENT(cx, scopeobj);
|
||||
}
|
||||
|
||||
if (indirectCall || scopeobj) {
|
||||
uintN flags = scopeobj
|
||||
? JSREPORT_ERROR
|
||||
|
@ -5120,6 +5103,23 @@ js_SetRequiredSlot(JSContext *cx, JSObject *obj, uint32 slot, jsval v)
|
|||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSObject *
|
||||
js_GetWrappedObject(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
JSClass *clasp;
|
||||
|
||||
clasp = OBJ_GET_CLASS(cx, obj);
|
||||
if (clasp->flags & JSCLASS_IS_EXTENDED) {
|
||||
JSExtendedClass *xclasp;
|
||||
JSObject *obj2;
|
||||
|
||||
xclasp = (JSExtendedClass *)clasp;
|
||||
if (xclasp->wrappedObject && (obj2 = xclasp->wrappedObject(cx, obj)))
|
||||
return obj2;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
/* Routines to print out values during debugging. */
|
||||
|
|
|
@ -695,6 +695,10 @@ extern JSBool
|
|||
js_CheckPrincipalsAccess(JSContext *cx, JSObject *scopeobj,
|
||||
JSPrincipals *principals, JSAtom *caller);
|
||||
|
||||
/* Infallible -- returns its argument if there is no wrapped object. */
|
||||
extern JSObject *
|
||||
js_GetWrappedObject(JSContext *cx, JSObject *obj);
|
||||
|
||||
JS_END_EXTERN_C
|
||||
|
||||
#endif /* jsobj_h___ */
|
||||
|
|
Загрузка…
Ссылка в новой задаче