From ee752118ffafdcded996fea866f893d7cb018e2c Mon Sep 17 00:00:00 2001 From: Stefan Radomski Date: Wed, 12 Nov 2014 22:27:24 +0100 Subject: Hopefully fixed unfortunate document.evaluate bug in ECMAScript bindings --- .../java/src/org/uscxml/tests/datamodel/TestDataModelAccess.java | 9 +++++++-- .../ecmascript/JavaScriptCore/dom/JSCDocumentCustom.cpp | 9 ++++++++- .../plugins/datamodel/ecmascript/v8/dom/V8DocumentCustom.cpp | 3 ++- test/uscxml/dom/test-xml-access.scxml | 9 ++++++--- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/embedding/java/src/org/uscxml/tests/datamodel/TestDataModelAccess.java b/embedding/java/src/org/uscxml/tests/datamodel/TestDataModelAccess.java index fcad186..5f14946 100644 --- a/embedding/java/src/org/uscxml/tests/datamodel/TestDataModelAccess.java +++ b/embedding/java/src/org/uscxml/tests/datamodel/TestDataModelAccess.java @@ -18,18 +18,23 @@ public class TestDataModelAccess { " " + + " " + + " " + + " " + " " + " " + " " + " " + " " + " " + - " " + + "" + + " " + + " " + " " + " " + " " + ""; - + Interpreter interpreter = Interpreter.fromXML(xml); InterpreterState state; do { diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentCustom.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentCustom.cpp index c6ee022..a6d194f 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentCustom.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentCustom.cpp @@ -24,6 +24,7 @@ #include "JSCXPathResult.h" #include "JSCNode.h" #include +#include namespace Arabica { namespace DOM { @@ -93,7 +94,13 @@ JSValueRef JSCDocument::evaluateCustomCallback(JSContextRef ctx, JSObjectRef fun return JSValueMakeUndefined(ctx); } - Arabica::DOM::Node* localContextNode = (Arabica::DOM::Node*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[1], NULL)); +// Arabica::DOM::Node* localContextNode = (Arabica::DOM::Node*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[1], NULL)); + JSCNode::JSCNodePrivate* otherNodePrivate = (JSCNode::JSCNodePrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[1], NULL)); + Arabica::DOM::Node* localContextNode = otherNodePrivate->nativeObj; + +// std::cout << *localContextNode << std::endl; +// std::cout << ">>" << privData->dom->xpath->evaluate("//note/@importance", *localContextNode).asString() << "<<" << std::endl; + retVal = new XPath::XPathValue(privData->dom->xpath->evaluate(localXPath, *localContextNode)); } else { retVal = new XPath::XPathValue(privData->dom->xpath->evaluate(localXPath, *privData->nativeObj)); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentCustom.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentCustom.cpp index 8659ccd..f9882f0 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentCustom.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentCustom.cpp @@ -59,7 +59,8 @@ v8::Handle V8Document::evaluateCustomCallback(const v8::Arguments& ar XPath::XPathValue* retVal; try { if (args.Length() > 1) { - Arabica::DOM::Node* localContextNode = V8DOM::toClassPtr >(args[1]->ToObject()->GetInternalField(0)); + V8Node::V8NodePrivate* otherNodePrivate = V8DOM::toClassPtr(args[1]->ToObject()->GetInternalField(0)); + Arabica::DOM::Node* localContextNode = otherNodePrivate->nativeObj; retVal = new XPath::XPathValue(privData->dom->xpath->evaluate(*localExpression, *localContextNode)); } else { retVal = new XPath::XPathValue(privData->dom->xpath->evaluate(*localExpression, *privData->nativeObj)); diff --git a/test/uscxml/dom/test-xml-access.scxml b/test/uscxml/dom/test-xml-access.scxml index a637c00..4c7abab 100644 --- a/test/uscxml/dom/test-xml-access.scxml +++ b/test/uscxml/dom/test-xml-access.scxml @@ -2,19 +2,22 @@ + -- cgit v0.12