diff options
Diffstat (limited to 'src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentCustom.cpp')
-rw-r--r-- | src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentCustom.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentCustom.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentCustom.cpp new file mode 100644 index 0000000..23cc0f9 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentCustom.cpp @@ -0,0 +1,43 @@ +#include "JSCDocument.h" +#include "JSCXPathResult.h" + +namespace Arabica { +namespace DOM { + + +JSValueRef JSCDocument::evaluateCustomCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { +#if 0 + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in evaluate"); +// if (!((V8Node::hasInstance(args[1])) && (V8XPathResult::hasInstance(args[3])))) +// throw V8Exception("Parameter mismatch while calling evaluate"); + + v8::Local<v8::Object> self = args.Holder(); + V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0)); + + v8::String::AsciiValue localExpression(args[0]); + + XPath::XPathValue<std::string>* retVal; + if (args.Length() > 1) { + Arabica::DOM::Node<std::string>* localContextNode = V8DOM::toClassPtr<Arabica::DOM::Node<std::string> >(args[1]->ToObject()->GetInternalField(0)); + retVal = new XPath::XPathValue<std::string>(privData->dom->xpath->evaluate(*localExpression, *localContextNode)); + } else { + retVal = new XPath::XPathValue<std::string>(privData->dom->xpath->evaluate(*localExpression, *privData->nativeObj)); + } + + v8::Handle<v8::Function> retCtor = V8XPathResult::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + + V8XPathResult::V8XPathResultPrivate* retPrivData = new V8XPathResult::V8XPathResultPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; + + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + + retObj.MakeWeak(0, V8XPathResult::jsDestructor); + return retObj; +#endif +} + +} +}
\ No newline at end of file |