void JSXPathEvaluatorOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) { JSXPathEvaluator* jsXPathEvaluator = jsCast<JSXPathEvaluator*>(handle.get().asCell()); DOMWrapperWorld& world = *static_cast<DOMWrapperWorld*>(context); uncacheWrapper(world, &jsXPathEvaluator->impl(), jsXPathEvaluator); jsXPathEvaluator->releaseImpl(); }
EncodedJSValue JSC_HOST_CALL jsXPathEvaluatorPrototypeFunctionEvaluate(ExecState* exec) { JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSXPathEvaluator::s_info)) return throwVMTypeError(exec); JSXPathEvaluator* castedThis = static_cast<JSXPathEvaluator*>(asObject(thisValue)); XPathEvaluator* imp = static_cast<XPathEvaluator*>(castedThis->impl()); ExceptionCode ec = 0; const String& expression(ustringToString(exec->argument(0).toString(exec))); if (exec->hadException()) return JSValue::encode(jsUndefined()); Node* contextNode(toNode(exec->argument(1))); if (exec->hadException()) return JSValue::encode(jsUndefined()); RefPtr<XPathNSResolver> customResolver; XPathNSResolver* resolver = toXPathNSResolver(exec->argument(2)); if (!resolver) { customResolver = JSCustomXPathNSResolver::create(exec, exec->argument(2)); if (exec->hadException()) return JSValue::encode(jsUndefined()); resolver = customResolver.get(); } unsigned short type(exec->argument(3).toUInt32(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); XPathResult* inResult(toXPathResult(exec->argument(4))); if (exec->hadException()) return JSValue::encode(jsUndefined()); JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->evaluate(expression, contextNode, resolver, type, inResult, ec))); setDOMException(exec, ec); return JSValue::encode(result); }
EncodedJSValue JSC_HOST_CALL jsXPathEvaluatorPrototypeFunctionEvaluate(ExecState* exec) { JSValue thisValue = exec->hostThisValue(); JSXPathEvaluator* castedThis = jsDynamicCast<JSXPathEvaluator*>(thisValue); if (!castedThis) return throwVMTypeError(exec); ASSERT_GC_OBJECT_INHERITS(castedThis, JSXPathEvaluator::info()); XPathEvaluator& impl = castedThis->impl(); ExceptionCode ec = 0; const String& expression(exec->argument(0).isEmpty() ? String() : exec->argument(0).toString(exec)->value(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); Node* contextNode(toNode(exec->argument(1))); if (exec->hadException()) return JSValue::encode(jsUndefined()); RefPtr<XPathNSResolver> customResolver; XPathNSResolver* resolver = toXPathNSResolver(exec->argument(2)); if (!resolver) { customResolver = JSCustomXPathNSResolver::create(exec, exec->argument(2)); if (exec->hadException()) return JSValue::encode(jsUndefined()); resolver = customResolver.get(); } uint16_t type(toUInt16(exec, exec->argument(3), NormalConversion)); if (exec->hadException()) return JSValue::encode(jsUndefined()); XPathResult* inResult(toXPathResult(exec->argument(4))); if (exec->hadException()) return JSValue::encode(jsUndefined()); JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl.evaluate(expression, contextNode, resolver, type, inResult, ec))); setDOMException(exec, ec); return JSValue::encode(result); }
JSValue* jsXPathEvaluatorPrototypeFunctionEvaluate(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) { if (!thisValue->isObject(&JSXPathEvaluator::s_info)) return throwError(exec, TypeError); JSXPathEvaluator* castedThisObj = static_cast<JSXPathEvaluator*>(thisValue); XPathEvaluator* imp = static_cast<XPathEvaluator*>(castedThisObj->impl()); ExceptionCode ec = 0; const UString& expression = args[0]->toString(exec); Node* contextNode = toNode(args[1]); RefPtr<XPathNSResolver> customResolver; XPathNSResolver* resolver = toXPathNSResolver(args[2]); if (!resolver) { customResolver = JSCustomXPathNSResolver::create(exec, args[2]); if (exec->hadException()) return jsUndefined(); resolver = customResolver.get(); } unsigned short type = args[3]->toInt32(exec); XPathResult* inResult = toXPathResult(args[4]); KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->evaluate(expression, contextNode, resolver, type, inResult, ec))); setDOMException(exec, ec); return result; }
EncodedJSValue jsXPathEvaluatorConstructor(ExecState* exec, EncodedJSValue thisValue, EncodedJSValue, PropertyName) { JSXPathEvaluator* domObject = jsDynamicCast<JSXPathEvaluator*>(JSValue::decode(thisValue)); if (!domObject) return throwVMTypeError(exec); if (!domObject) return throwVMTypeError(exec); return JSValue::encode(JSXPathEvaluator::getConstructor(exec->vm(), domObject->globalObject())); }
JSValue* JSXPathEvaluatorPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args) { if (!thisObj->inherits(&JSXPathEvaluator::info)) return throwError(exec, TypeError); JSXPathEvaluator* castedThisObj = static_cast<JSXPathEvaluator*>(thisObj); XPathEvaluator* imp = static_cast<XPathEvaluator*>(castedThisObj->impl()); switch (id) { case JSXPathEvaluator::CreateExpressionFuncNum: { ExceptionCode ec = 0; String expression = args[0]->toString(exec); RefPtr<XPathNSResolver> customResolver; XPathNSResolver* resolver = toXPathNSResolver(args[1]); if (!resolver) { customResolver = JSCustomXPathNSResolver::create(exec, args[1]); if (exec->hadException()) return jsUndefined(); resolver = customResolver.get(); } KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createExpression(expression, resolver, ec))); setDOMException(exec, ec); return result; } case JSXPathEvaluator::CreateNSResolverFuncNum: { Node* nodeResolver = toNode(args[0]); KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createNSResolver(nodeResolver))); return result; } case JSXPathEvaluator::EvaluateFuncNum: { ExceptionCode ec = 0; String expression = args[0]->toString(exec); Node* contextNode = toNode(args[1]); RefPtr<XPathNSResolver> customResolver; XPathNSResolver* resolver = toXPathNSResolver(args[2]); if (!resolver) { customResolver = JSCustomXPathNSResolver::create(exec, args[2]); if (exec->hadException()) return jsUndefined(); resolver = customResolver.get(); } unsigned short type = args[3]->toInt32(exec); XPathResult* inResult = toXPathResult(args[4]); KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->evaluate(expression, contextNode, resolver, type, inResult, ec))); setDOMException(exec, ec); return result; } } return 0; }
JSValue* jsXPathEvaluatorPrototypeFunctionCreateNSResolver(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) { if (!thisValue->isObject(&JSXPathEvaluator::s_info)) return throwError(exec, TypeError); JSXPathEvaluator* castedThisObj = static_cast<JSXPathEvaluator*>(thisValue); XPathEvaluator* imp = static_cast<XPathEvaluator*>(castedThisObj->impl()); Node* nodeResolver = toNode(args[0]); KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createNSResolver(nodeResolver))); return result; }
EncodedJSValue JSC_HOST_CALL jsXPathEvaluatorPrototypeFunctionCreateNSResolver(ExecState* exec) { JSValue thisValue = exec->hostThisValue(); JSXPathEvaluator* castedThis = jsDynamicCast<JSXPathEvaluator*>(thisValue); if (!castedThis) return throwVMTypeError(exec); ASSERT_GC_OBJECT_INHERITS(castedThis, JSXPathEvaluator::info()); XPathEvaluator& impl = castedThis->impl(); Node* nodeResolver(toNode(exec->argument(0))); if (exec->hadException()) return JSValue::encode(jsUndefined()); JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl.createNSResolver(nodeResolver))); return JSValue::encode(result); }
EncodedJSValue JSC_HOST_CALL jsXPathEvaluatorPrototypeFunctionCreateNSResolver(ExecState* exec) { JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSXPathEvaluator::s_info)) return throwVMTypeError(exec); JSXPathEvaluator* castedThis = static_cast<JSXPathEvaluator*>(asObject(thisValue)); XPathEvaluator* imp = static_cast<XPathEvaluator*>(castedThis->impl()); Node* nodeResolver(toNode(exec->argument(0))); if (exec->hadException()) return JSValue::encode(jsUndefined()); JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->createNSResolver(nodeResolver))); return JSValue::encode(result); }
JSValue jsXPathEvaluatorConstructor(ExecState* exec, JSValue slotBase, const Identifier&) { JSXPathEvaluator* domObject = static_cast<JSXPathEvaluator*>(asObject(slotBase)); return JSXPathEvaluator::getConstructor(exec, domObject->globalObject()); }