Add JS_Get[UC]*PropertyAttrsGetterAndSetter for fast-back bug (274784, r/a=me).

git-svn-id: svn://10.0.0.236/trunk@172726 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
brendan%mozilla.org 2005-04-26 04:11:59 +00:00
parent dad862ec1c
commit 8bcad27cf8
2 changed files with 68 additions and 4 deletions

View File

@ -2470,7 +2470,8 @@ LookupResult(JSContext *cx, JSObject *obj, JSObject *obj2, JSProperty *prop)
static JSBool
GetPropertyAttributes(JSContext *cx, JSObject *obj, JSAtom *atom,
uintN *attrsp, JSBool *foundp)
uintN *attrsp, JSBool *foundp,
JSPropertyOp *getterp, JSPropertyOp *setterp)
{
JSObject *obj2;
JSProperty *prop;
@ -2480,8 +2481,14 @@ GetPropertyAttributes(JSContext *cx, JSObject *obj, JSAtom *atom,
return JS_FALSE;
if (!OBJ_LOOKUP_PROPERTY(cx, obj, ATOM_TO_JSID(atom), &obj2, &prop))
return JS_FALSE;
if (!prop || obj != obj2) {
*attrsp = 0;
*foundp = JS_FALSE;
if (getterp)
*getterp = NULL;
if (setterp)
*setterp = NULL;
if (prop)
OBJ_DROP_PROPERTY(cx, obj2, prop);
return JS_TRUE;
@ -2489,6 +2496,14 @@ GetPropertyAttributes(JSContext *cx, JSObject *obj, JSAtom *atom,
*foundp = JS_TRUE;
ok = OBJ_GET_ATTRIBUTES(cx, obj, ATOM_TO_JSID(atom), prop, attrsp);
if (ok && OBJ_IS_NATIVE(obj)) {
JSScopeProperty *sprop = (JSScopeProperty *) prop;
if (getterp)
*getterp = sprop->getter;
if (setterp)
*setterp = sprop->setter;
}
OBJ_DROP_PROPERTY(cx, obj, prop);
return ok;
}
@ -2518,7 +2533,6 @@ SetPropertyAttributes(JSContext *cx, JSObject *obj, JSAtom *atom,
return ok;
}
JS_PUBLIC_API(JSBool)
JS_GetPropertyAttributes(JSContext *cx, JSObject *obj, const char *name,
uintN *attrsp, JSBool *foundp)
@ -2526,7 +2540,20 @@ JS_GetPropertyAttributes(JSContext *cx, JSObject *obj, const char *name,
CHECK_REQUEST(cx);
return GetPropertyAttributes(cx, obj,
js_Atomize(cx, name, strlen(name), 0),
attrsp, foundp);
attrsp, foundp, NULL, NULL);
}
JS_PUBLIC_API(JSBool)
JS_GetPropertyAttrsGetterAndSetter(JSContext *cx, JSObject *obj,
const char *name,
uintN *attrsp, JSBool *foundp,
JSPropertyOp *getterp,
JSPropertyOp *setterp)
{
CHECK_REQUEST(cx);
return GetPropertyAttributes(cx, obj,
js_Atomize(cx, name, strlen(name), 0),
attrsp, foundp, getterp, setterp);
}
JS_PUBLIC_API(JSBool)
@ -2689,7 +2716,20 @@ JS_GetUCPropertyAttributes(JSContext *cx, JSObject *obj,
CHECK_REQUEST(cx);
return GetPropertyAttributes(cx, obj,
js_AtomizeChars(cx, name, AUTO_NAMELEN(name, namelen), 0),
attrsp, foundp);
attrsp, foundp, NULL, NULL);
}
JS_PUBLIC_API(JSBool)
JS_GetUCPropertyAttrsGetterAndSetter(JSContext *cx, JSObject *obj,
const jschar *name, size_t namelen,
uintN *attrsp, JSBool *foundp,
JSPropertyOp *getterp,
JSPropertyOp *setterp)
{
CHECK_REQUEST(cx);
return GetPropertyAttributes(cx, obj,
js_AtomizeChars(cx, name, AUTO_NAMELEN(name, namelen), 0),
attrsp, foundp, getterp, setterp);
}
JS_PUBLIC_API(JSBool)

View File

@ -1064,6 +1064,18 @@ extern JS_PUBLIC_API(JSBool)
JS_GetPropertyAttributes(JSContext *cx, JSObject *obj, const char *name,
uintN *attrsp, JSBool *foundp);
/*
* The same, but if the property is native, return its getter and setter via
* *getterp and *setterp, respectively (and only if the out parameter pointer
* is not null).
*/
extern JS_PUBLIC_API(JSBool)
JS_GetPropertyAttrsGetterAndSetter(JSContext *cx, JSObject *obj,
const char *name,
uintN *attrsp, JSBool *foundp,
JSPropertyOp *getterp,
JSPropertyOp *setterp);
/*
* Set the attributes of a property on a given object.
*
@ -1128,6 +1140,18 @@ JS_GetUCPropertyAttributes(JSContext *cx, JSObject *obj,
const jschar *name, size_t namelen,
uintN *attrsp, JSBool *foundp);
/*
* The same, but if the property is native, return its getter and setter via
* *getterp and *setterp, respectively (and only if the out parameter pointer
* is not null).
*/
extern JS_PUBLIC_API(JSBool)
JS_GetUCPropertyAttrsGetterAndSetter(JSContext *cx, JSObject *obj,
const jschar *name, size_t namelen,
uintN *attrsp, JSBool *foundp,
JSPropertyOp *getterp,
JSPropertyOp *setterp);
/*
* Set the attributes of a property on a given object.
*