зеркало из https://github.com/mozilla/pjs.git
- Enable JS_HAS_NEW_OBJ_METHODS (Object.prototype.hasOwnProperty, isPrototypeOf
and propertyIsEnumerable) for JS1.5. - Optimize obj_propertyIsEnumerable to avoid extra lookup code bloat, requiring fix to js_GetAttributes (unset out param on successful early retunr) that it exposed. - Use more righteous else-if style in shaver's jsarray.c change.
This commit is contained in:
Родитель
568234107f
Коммит
ec2936ce41
|
@ -1316,16 +1316,12 @@ Array(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
if (argc > 1) {
|
||||
length = (jsuint) argc;
|
||||
vector = argv;
|
||||
}
|
||||
else {
|
||||
if (!ValueIsLength(cx, argv[0], &length)) {
|
||||
vector = argv;
|
||||
} else if (!ValueIsLength(cx, argv[0], &length)) {
|
||||
length = 1;
|
||||
vector = argv;
|
||||
} else {
|
||||
vector = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return InitArrayObject(cx, obj, length, vector);
|
||||
}
|
||||
|
|
|
@ -335,7 +335,7 @@
|
|||
#define JS_HAS_DEBUGGER_KEYWORD 1 /* has hook for debugger keyword */
|
||||
#define JS_HAS_ERROR_EXCEPTIONS 1 /* rt errors reflected as exceptions */
|
||||
#define JS_HAS_CATCH_GUARD 1 /* has exception handling catch guard */
|
||||
#define JS_HAS_NEW_OBJ_METHODS 0 /* has Object.prototype query methods */
|
||||
#define JS_HAS_NEW_OBJ_METHODS 1 /* has Object.prototype query methods */
|
||||
#define JS_HAS_SPARSE_ARRAYS 0 /* array methods preserve empty elems */
|
||||
#define JS_HAS_DFLT_MSG_STRINGS 1 /* provides English error messages */
|
||||
#define JS_HAS_NUMBER_FORMATS 1 /* numbers have formatting methods */
|
||||
|
|
|
@ -868,24 +868,16 @@ static JSBool
|
|||
obj_propertyIsEnumerable(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
jsval *rval)
|
||||
{
|
||||
JSObject *obj2;
|
||||
JSProperty *prop;
|
||||
JSAtom *atom;
|
||||
uintN attrs;
|
||||
JSBool ok;
|
||||
|
||||
atom = js_ValueToStringAtom(cx, *argv);
|
||||
if (atom == NULL || !OBJ_LOOKUP_PROPERTY(cx, obj, (jsid)atom, &obj2, &prop))
|
||||
if (atom == NULL)
|
||||
return JS_FALSE;
|
||||
if (!OBJ_GET_ATTRIBUTES(cx, obj, (jsid)atom, NULL, &attrs))
|
||||
return JS_FALSE;
|
||||
if (!prop) {
|
||||
*rval = JSVAL_FALSE;
|
||||
return JS_TRUE;
|
||||
}
|
||||
ok = OBJ_GET_ATTRIBUTES(cx, obj2, (jsid)atom, prop, &attrs);
|
||||
if (ok)
|
||||
*rval = BOOLEAN_TO_JSVAL((attrs & JSPROP_ENUMERATE) != 0);
|
||||
OBJ_DROP_PROPERTY(cx, obj2, prop);
|
||||
return ok;
|
||||
return JS_TRUE;
|
||||
}
|
||||
#endif /* JS_HAS_NEW_OBJ_METHODS */
|
||||
|
||||
|
@ -2075,8 +2067,10 @@ js_GetAttributes(JSContext *cx, JSObject *obj, jsid id, JSProperty *prop,
|
|||
if (noprop) {
|
||||
if (!js_LookupProperty(cx, obj, id, &obj, &prop))
|
||||
return JS_FALSE;
|
||||
if (!prop)
|
||||
if (!prop) {
|
||||
*attrsp = 0;
|
||||
return JS_TRUE;
|
||||
}
|
||||
if (!OBJ_IS_NATIVE(obj)) {
|
||||
ok = OBJ_GET_ATTRIBUTES(cx, obj, id, prop, attrsp);
|
||||
OBJ_DROP_PROPERTY(cx, obj, prop);
|
||||
|
|
Загрузка…
Ссылка в новой задаче