Example #1
0
JSValue* JSXPathResult::getValueProperty(ExecState* exec, int token) const
{
    switch (token) {
    case ResultTypeAttrNum: {
        XPathResult* imp = static_cast<XPathResult*>(impl());

        return jsNumber(imp->resultType());
    }
    case NumberValueAttrNum: {
        ExceptionCode ec = 0;
        XPathResult* imp = static_cast<XPathResult*>(impl());

        KJS::JSValue* result = jsNumber(imp->numberValue(ec));
        setDOMException(exec, ec);
        return result;
    }
    case StringValueAttrNum: {
        ExceptionCode ec = 0;
        XPathResult* imp = static_cast<XPathResult*>(impl());

        KJS::JSValue* result = jsString(imp->stringValue(ec));
        setDOMException(exec, ec);
        return result;
    }
    case BooleanValueAttrNum: {
        ExceptionCode ec = 0;
        XPathResult* imp = static_cast<XPathResult*>(impl());

        KJS::JSValue* result = jsBoolean(imp->booleanValue(ec));
        setDOMException(exec, ec);
        return result;
    }
    case SingleNodeValueAttrNum: {
        ExceptionCode ec = 0;
        XPathResult* imp = static_cast<XPathResult*>(impl());

        KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->singleNodeValue(ec)));
        setDOMException(exec, ec);
        return result;
    }
    case InvalidIteratorStateAttrNum: {
        XPathResult* imp = static_cast<XPathResult*>(impl());

        return jsBoolean(imp->invalidIteratorState());
    }
    case SnapshotLengthAttrNum: {
        ExceptionCode ec = 0;
        XPathResult* imp = static_cast<XPathResult*>(impl());

        KJS::JSValue* result = jsNumber(imp->snapshotLength(ec));
        setDOMException(exec, ec);
        return result;
    }
    case ConstructorAttrNum:
        return getConstructor(exec);
    }
    return 0;
}
JSValue jsXPathResultSnapshotLength(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSXPathResult* castedThis = static_cast<JSXPathResult*>(asObject(slotBase));
    ExceptionCode ec = 0;
    XPathResult* imp = static_cast<XPathResult*>(castedThis->impl());
    JSC::JSValue result = jsNumber(imp->snapshotLength(ec));
    setDOMException(exec, ec);
    return result;
}
static v8::Handle<v8::Value> snapshotLengthAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
    INC_STATS("DOM.XPathResult.snapshotLength._get");
    XPathResult* imp = V8XPathResult::toNative(info.Holder());
    ExceptionCode ec = 0;
    unsigned v = imp->snapshotLength(ec);
    if (UNLIKELY(ec)) {
        V8Proxy::setDOMException(ec);
        return v8::Handle<v8::Value>();
    }
    return v8::Integer::NewFromUnsigned(v);
}