예제 #1
0
bool
js::InternNonIntElementId(JSContext *cx, JSObject *obj, const Value &idval,
                          typename MaybeRooted<jsid, allowGC>::MutableHandleType idp,
                          typename MaybeRooted<Value, allowGC>::MutableHandleType vp)
{
    JSAtom *atom = ToAtom<allowGC>(cx, idval);
    if (!atom)
        return false;

    idp.set(AtomToId(atom));
    vp.setString(atom);
    return true;
}
예제 #2
0
bool
js::IndexToIdSlow(JSContext *cx, uint32_t index,
                  typename MaybeRooted<jsid, allowGC>::MutableHandleType idp)
{
    JS_ASSERT(index > JSID_INT_MAX);

    jschar buf[UINT32_CHAR_BUFFER_LENGTH];
    RangedPtr<jschar> end(ArrayEnd(buf), buf, ArrayEnd(buf));
    RangedPtr<jschar> start = BackfillIndexInCharBuffer(index, end);

    JSAtom *atom = AtomizeChars<allowGC>(cx, start.get(), end - start);
    if (!atom)
        return false;

    idp.set(JSID_FROM_BITS((size_t)atom));
    return true;
}