зеркало из https://github.com/mozilla/pjs.git
bug 486106 - restoring JS*Lookup API compatibility with fast arrays. r=shaver
This commit is contained in:
Родитель
12d9908e2c
Коммит
ba3f4f2620
|
@ -3237,6 +3237,8 @@ LookupResult(JSContext *cx, JSObject *obj, JSObject *obj2, JSProperty *prop)
|
|||
rval = SPROP_HAS_VALID_SLOT(sprop, OBJ_SCOPE(obj2))
|
||||
? LOCKED_OBJ_GET_SLOT(obj2, sprop->slot)
|
||||
: JSVAL_TRUE;
|
||||
} else if (OBJ_IS_DENSE_ARRAY(cx, obj2)) {
|
||||
rval = js_GetDenseArrayElementValue(obj2, prop);
|
||||
} else {
|
||||
/* XXX bad API: no way to return "defined but value unknown" */
|
||||
rval = JSVAL_TRUE;
|
||||
|
|
|
@ -739,6 +739,23 @@ array_dropProperty(JSContext *cx, JSObject *obj, JSProperty *prop)
|
|||
#endif
|
||||
}
|
||||
|
||||
jsval
|
||||
js_GetDenseArrayElementValue(JSObject *obj, JSProperty *prop)
|
||||
{
|
||||
/* OBJ_IS_DENSE_ARRAY does not use the cx argument. */
|
||||
JS_ASSERT(OBJ_IS_DENSE_ARRAY(cx, obj));
|
||||
JS_ASSERT((void *) prop ==
|
||||
(void *) &(obj->fslots[JSSLOT_ARRAY_LOOKUP_HOLDER]));
|
||||
JS_ASSERT((jsval) prop->id == obj->fslots[JSSLOT_ARRAY_LOOKUP_HOLDER]);
|
||||
JS_ASSERT(JSVAL_IS_INT(prop->id));
|
||||
|
||||
jsint i = JSID_TO_INT(prop->id);
|
||||
JS_ASSERT(i >= 0);
|
||||
jsval v = obj->dslots[i];
|
||||
JS_ASSERT(v != JSVAL_HOLE);
|
||||
return v;
|
||||
}
|
||||
|
||||
static JSBool
|
||||
array_getProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
|
|
|
@ -223,6 +223,12 @@ js_ArrayToJSDoubleBuffer(JSContext *cx, JSObject *obj, jsuint offset, jsuint cou
|
|||
JSBool
|
||||
js_PrototypeHasIndexedProperties(JSContext *cx, JSObject *obj);
|
||||
|
||||
/*
|
||||
* Utility to access the value from the id returned by array_lookupProperty.
|
||||
*/
|
||||
jsval
|
||||
js_GetDenseArrayElementValue(JSObject *obj, JSProperty *prop);
|
||||
|
||||
JS_END_EXTERN_C
|
||||
|
||||
#endif /* jsarray_h___ */
|
||||
|
|
Загрузка…
Ссылка в новой задаче