From f627a8a8b139a42568f67dc18679d92806e0ff4e Mon Sep 17 00:00:00 2001 From: Stefan Radomski Date: Tue, 2 Apr 2013 20:42:17 +0200 Subject: More bug-fixes for W3C tests --- apps/mmi-browser.cpp | 21 +-- contrib/dom/idl/SCXMLEvent.idl | 2 +- src/uscxml/Factory.cpp | 4 + src/uscxml/Factory.h | 7 +- src/uscxml/Interpreter.cpp | 51 ++++--- src/uscxml/Interpreter.h | 8 +- src/uscxml/Message.h | 2 +- src/uscxml/interpreter/InterpreterDraft6.cpp | 13 +- .../datamodel/ecmascript/v8/V8DataModel.cpp | 59 ++++++-- .../plugins/datamodel/ecmascript/v8/V8DataModel.h | 13 +- .../datamodel/ecmascript/v8/dom/V8Document.cpp.old | 59 -------- .../datamodel/ecmascript/v8/dom/V8Element.cpp.old | 24 --- .../datamodel/ecmascript/v8/dom/V8Element.h.old | 87 ----------- .../datamodel/ecmascript/v8/dom/V8Node.cpp.old | 23 --- .../datamodel/ecmascript/v8/dom/V8Node.h.old | 161 --------------------- .../datamodel/ecmascript/v8/dom/V8NodeSet.cpp.old | 60 -------- .../datamodel/ecmascript/v8/dom/V8NodeSet.h.old | 41 ------ .../datamodel/ecmascript/v8/dom/V8SCXMLEvent.cpp | 7 - .../datamodel/ecmascript/v8/dom/V8SCXMLEvent.h | 4 +- .../ecmascript/v8/dom/V8SCXMLEventCustom.cpp | 27 ++++ .../ecmascript/v8/dom/V8XPathResult.cpp.old | 30 ---- .../ecmascript/v8/dom/V8XPathResult.h.old | 75 ---------- .../plugins/datamodel/prolog/swi/SWIDataModel.cpp | 2 +- src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp | 8 +- src/uscxml/server/InterpreterServlet.cpp | 18 +++ src/uscxml/server/InterpreterServlet.h | 18 ++- test/samples/w3c/tests/test322.scxml | 2 + test/samples/w3c/tests/test330.scxml | 6 +- 28 files changed, 188 insertions(+), 644 deletions(-) delete mode 100644 src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.cpp.old delete mode 100644 src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.cpp.old delete mode 100644 src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.h.old delete mode 100644 src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.cpp.old delete mode 100644 src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.h.old delete mode 100644 src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.cpp.old delete mode 100644 src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.h.old create mode 100644 src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEventCustom.cpp delete mode 100644 src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.cpp.old delete mode 100644 src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.h.old diff --git a/apps/mmi-browser.cpp b/apps/mmi-browser.cpp index 6f997e7..b432296 100644 --- a/apps/mmi-browser.cpp +++ b/apps/mmi-browser.cpp @@ -62,7 +62,7 @@ extern "C" void __cxa_throw (void *thrown_exception, void *pvtinfo, void (*dest)(void *)) { std::cerr << __FUNCTION__ << " will throw exception from " << std::endl; if (orig_cxa_throw == 0) - load_orig_throw_code(); + load_orig_throw_code(); void *array[50]; size_t size = backtrace(array, 50); @@ -84,16 +84,17 @@ void customTerminate() { } else { tried_throw = false; }; - } - catch (const std::exception &e) { + } catch (const std::exception &e) { std::cerr << __FUNCTION__ << " caught unhandled exception. what(): " - << e.what() << std::endl; - } - catch (...) { + << e.what() << std::endl; + } catch (const uscxml::Event &e) { + std::cerr << __FUNCTION__ << " caught unhandled exception. Event: " + << e << std::endl; + } catch (...) { std::cerr << __FUNCTION__ << " caught unknown/unhandled exception." - << std::endl; + << std::endl; } - + #ifdef HAS_EXECINFO_H void * array[50]; int size = backtrace(array, 50); @@ -122,7 +123,7 @@ int main(int argc, char** argv) { using namespace uscxml; std::set_terminate(customTerminate); - + #ifdef HAS_SIGNAL_H signal(SIGPIPE, SIG_IGN); #endif @@ -134,7 +135,7 @@ int main(int argc, char** argv) { bool verbose = false; google::InitGoogleLogging(argv[0]); google::LogToStderr(); - + #ifndef _WIN32 opterr = 0; #endif diff --git a/contrib/dom/idl/SCXMLEvent.idl b/contrib/dom/idl/SCXMLEvent.idl index 4f3438e..394aa1a 100644 --- a/contrib/dom/idl/SCXMLEvent.idl +++ b/contrib/dom/idl/SCXMLEvent.idl @@ -7,7 +7,7 @@ const unsigned short EXTERNAL = 2; const unsigned short PLATFORM = 3; - readonly attribute unsigned short type; + [CustomGetter] readonly attribute DOMString type; readonly attribute DOMString name; readonly attribute DOMString origin; readonly attribute DOMString origintype; diff --git a/src/uscxml/Factory.cpp b/src/uscxml/Factory.cpp index 46974f2..41a3b5a 100644 --- a/src/uscxml/Factory.cpp +++ b/src/uscxml/Factory.cpp @@ -169,6 +169,10 @@ Factory::Factory() { registerIOProcessor(ioProcessor); } { + InterpreterServlet* ioProcessor = new InterpreterServlet(); + registerIOProcessor(ioProcessor); + } + { FetchElement* element = new FetchElement(); registerExecutableContent(element); } diff --git a/src/uscxml/Factory.h b/src/uscxml/Factory.h index e257e45..65dc5fd 100644 --- a/src/uscxml/Factory.h +++ b/src/uscxml/Factory.h @@ -183,6 +183,7 @@ public: protected: boost::shared_ptr _impl; + friend class Interpreter; }; class InvokerImpl : public IOProcessorImpl { @@ -234,8 +235,6 @@ public: virtual void setEvent(const Event& event) = 0; virtual Data getStringAsData(const std::string& content) = 0; - virtual void registerIOProcessor(const std::string& name, const IOProcessor& ioprocessor) = 0; - // foreach virtual uint32_t getLength(const std::string& expr) = 0; virtual void pushContext() = 0; @@ -296,10 +295,6 @@ public: return _impl->popContext(); } - virtual void registerIOProcessor(const std::string& name, const IOProcessor& ioprocessor) { - _impl->registerIOProcessor(name, ioprocessor); - } - virtual void eval(const std::string& expr) { return _impl->eval(expr); } diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp index 366b6d6..6caeb76 100644 --- a/src/uscxml/Interpreter.cpp +++ b/src/uscxml/Interpreter.cpp @@ -209,8 +209,8 @@ Interpreter::~Interpreter() { } if (_sendQueue) delete _sendQueue; - if (_httpServlet) - delete _httpServlet; +// if (_httpServlet) +// delete _httpServlet; } void Interpreter::start() { @@ -269,8 +269,8 @@ void Interpreter::init() { normalize(_scxml); - if (_capabilities & CAN_GENERIC_HTTP) - _httpServlet = new InterpreterServlet(this); +// if (_capabilities & CAN_GENERIC_HTTP) +// _httpServlet = new InterpreterServlet(this); _sendQueue = new DelayedEventQueue(); _sendQueue->start(); @@ -464,9 +464,11 @@ void Interpreter::processContentElement(const Arabica::DOM::Node& c LOG(ERROR) << "content element does not specify any content."; } } - + void Interpreter::send(const Arabica::DOM::Node& element) { SendRequest sendReq; + // test 331 + sendReq.Event::type = Event::EXTERNAL; try { // event if (HAS_ATTR(element, "eventexpr") && _dataModel) { @@ -516,7 +518,7 @@ void Interpreter::send(const Arabica::DOM::Node& element) { * details. The SCXML processor may generate all other ids in any format, * as long as they are unique. */ - + /** * * If 'idlocation' is present, the SCXML Processor must generate an id when @@ -666,8 +668,8 @@ void Interpreter::delayedSend(void* userdata, std::string eventName) { LOG(ERROR) << "Can not send to invoked component '" << invokeId << "', no such invokeId" << std::endl; } } else if (sendReq.target.length() == 0 && - (sendReq.type.length() == 0 || - boost::equals(sendReq.type, "http://www.w3.org/TR/scxml/#SCXMLEventProcessor"))) { + (sendReq.type.length() == 0 || + boost::equals(sendReq.type, "http://www.w3.org/TR/scxml/#SCXMLEventProcessor"))) { /** * If neither the 'target' nor the 'targetexpr' attribute is specified, the * SCXML Processor must add the event will be added to the external event @@ -675,7 +677,9 @@ void Interpreter::delayedSend(void* userdata, std::string eventName) { */ INSTANCE->_externalQueue.push(sendReq); } else { - IOProcessor ioProc = INSTANCE->getIOProcessor(sendReq.type); + IOProcessor ioProc; + if (sendReq.type.length() > 0) + IOProcessor ioProc = INSTANCE->getIOProcessor(sendReq.type); if (ioProc) { try { ioProc.send(sendReq); @@ -683,7 +687,11 @@ void Interpreter::delayedSend(void* userdata, std::string eventName) { LOG(ERROR) << "Exception caught while sending event to ioprocessor " << sendReq.type; } } else { - INSTANCE->_internalQueue.push_back(Event("error.execution")); + Event exceptionEvent; + exceptionEvent.name = "error.execution"; + exceptionEvent.type = Event::PLATFORM; + exceptionEvent.sendid = sendReq.sendid; + INSTANCE->_internalQueue.push_back(exceptionEvent); } } assert(INSTANCE->_sendIds.find(sendReq.sendid) != INSTANCE->_sendIds.end()); @@ -692,7 +700,7 @@ void Interpreter::delayedSend(void* userdata, std::string eventName) { void Interpreter::invoke(const Arabica::DOM::Node& element) { InvokeRequest invokeReq; - + invokeReq.Event::type = Event::EXTERNAL; try { // type if (HAS_ATTR(element, "typeexpr") && _dataModel) { @@ -1052,9 +1060,9 @@ void Interpreter::executeContent(const Arabica::DOM::Node& content, if (_dataModel && HAS_ATTR(content, "location") && HAS_ATTR(content, "expr")) { try { if (!_dataModel.isDeclared(ATTR(content, "location"))) { - // test 286 + // test 286, 331 LOG(ERROR) << "Assigning to undeclared location '" << ATTR(content, "location") << "' not allowed." << std::endl; - Event e("error.execution"); + Event e("error.execution", Event::PLATFORM); _internalQueue.push_back(e); throw e; return; @@ -1234,7 +1242,7 @@ bool Interpreter::hasAncestorElement(const Arabica::DOM::Node& node Arabica::DOM::Node parent = node.getParentNode(); while(parent) { if (parent.getNodeType() == Node_base::ELEMENT_NODE && - boost::iequals(TAGNAME(parent), tagName)) { + boost::iequals(TAGNAME(parent), tagName)) { return true; } parent = parent.getParentNode(); @@ -1556,14 +1564,13 @@ bool Interpreter::isPseudoState(const Arabica::DOM::Node& state) { } bool Interpreter::isTransitionTarget(const Arabica::DOM::Node& elem) { - return (isState(elem) || boost::iequals(LOCALNAME(elem), "history")); // TODO: history is a state + return (isState(elem) || boost::iequals(LOCALNAME(elem), "history")); } bool Interpreter::isAtomic(const Arabica::DOM::Node& state) { if (boost::iequals("final", LOCALNAME(state))) return true; - // I will assume that parallel states are not meant to be atomic. if (boost::iequals("parallel", LOCALNAME(state))) return false; @@ -1613,11 +1620,20 @@ void Interpreter::setupIOProcessors() { ioProcIter++; continue; } + if (boost::iequals(ioProcIter->first, "http") && !(_capabilities & CAN_GENERIC_HTTP)) { + ioProcIter++; + continue; + } _ioProcessors[ioProcIter->first] = Factory::createIOProcessor(ioProcIter->first, this); _ioProcessors[ioProcIter->first].setType(ioProcIter->first); _ioProcessors[ioProcIter->first].setInterpreter(this); + if (boost::iequals(ioProcIter->first, "http")) { + // this is somewhat ugly + _httpServlet = static_cast(_ioProcessors[ioProcIter->first]._impl.get()); + } + // register aliases std::set names = _ioProcessors[ioProcIter->first].getNames(); std::set::iterator nameIter = names.begin(); @@ -1626,7 +1642,7 @@ void Interpreter::setupIOProcessors() { _ioProcessors[*nameIter] = _ioProcessors[ioProcIter->first]; nameIter++; } - +#if 0 if (_dataModel) { try { _dataModel.registerIOProcessor(ioProcIter->first, _ioProcessors[ioProcIter->first]); @@ -1636,6 +1652,7 @@ void Interpreter::setupIOProcessors() { } else { LOG(INFO) << "Not registering " << ioProcIter->first << " at _ioprocessors in datamodel, no datamodel specified"; } +#endif ioProcIter++; } } diff --git a/src/uscxml/Interpreter.h b/src/uscxml/Interpreter.h index b48080a..0eac6fb 100644 --- a/src/uscxml/Interpreter.h +++ b/src/uscxml/Interpreter.h @@ -200,6 +200,10 @@ public: return _sessionId; } + const std::map& getIOProcessors() { + return _ioProcessors; + } + bool runOnMainThread(int fps, bool blocking = true); static bool isMember(const Arabica::DOM::Node& node, const Arabica::XPath::NodeSet& set); @@ -263,7 +267,7 @@ protected: Arabica::XPath::NodeSet _statesToInvoke; std::vector _userDefinedStartConfiguration; InvokeRequest _invokeReq; - + DataModel _dataModel; std::map > _historyValue; @@ -283,7 +287,7 @@ protected: void executeContent(const Arabica::XPath::NodeSet& content, bool rethrow = false); void processContentElement(const Arabica::DOM::Node& element, Arabica::DOM::Document& dom, std::string& text); - + void send(const Arabica::DOM::Node& element); void invoke(const Arabica::DOM::Node& element); void cancelInvoke(const Arabica::DOM::Node& element); diff --git a/src/uscxml/Message.h b/src/uscxml/Message.h index eed9836..cb7196a 100644 --- a/src/uscxml/Message.h +++ b/src/uscxml/Message.h @@ -95,7 +95,7 @@ public: }; Event() : type(INTERNAL) {} - Event(const std::string& name) : name(name), type(INTERNAL) {} + Event(const std::string& name, Type type = INTERNAL) : name(name), type(type) {} Event(const Arabica::DOM::Node& xmlString) : type(INTERNAL) {}; bool operator< (const Event& other) const { return this < &other; diff --git a/src/uscxml/interpreter/InterpreterDraft6.cpp b/src/uscxml/interpreter/InterpreterDraft6.cpp index b53ba4e..82785e8 100644 --- a/src/uscxml/interpreter/InterpreterDraft6.cpp +++ b/src/uscxml/interpreter/InterpreterDraft6.cpp @@ -33,11 +33,6 @@ void InterpreterDraft6::interpret() { if (_dataModel) { _dataModel.assign("_x.args", _cmdLineOptions); - if (_httpServlet) { - Data data; - data.compound["location"] = Data(_httpServlet->getURL(), Data::VERBATIM); - _dataModel.assign("_ioprocessors['http']", data); - } } setupIOProcessors(); @@ -127,7 +122,7 @@ void InterpreterDraft6::initializeData(const Arabica::DOM::Node& da LOG(ERROR) << "Cannot initialize data when no datamodel is given!"; return; } - + if (!HAS_ATTR(data, "id")) { LOG(ERROR) << "Data element has no id!"; return; @@ -185,7 +180,7 @@ void InterpreterDraft6::initializeData(const Arabica::DOM::Node& da } catch (Event e) { LOG(ERROR) << "Syntax error in data element:" << std::endl << e << std::endl; - } + } } void InterpreterDraft6::mainEventLoop() { @@ -337,7 +332,7 @@ void InterpreterDraft6::mainEventLoop() { if (!enabledTransitions.empty()) microstep(enabledTransitions); } - + EXIT_INTERPRETER: monIter = _monitors.begin(); while(monIter != _monitors.end()) { @@ -359,7 +354,7 @@ EXIT_INTERPRETER: sendIter++; } } - + monIter = _monitors.begin(); while(monIter != _monitors.end()) { try { diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp index affd641..c24e3ec 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp @@ -57,9 +57,19 @@ boost::shared_ptr V8DataModel::create(Interpreter* interpreter) { docObj->SetInternalField(0, Arabica::DOM::V8DOM::toExternal(privData)); context->Global()->Set(v8::String::New("document"), docObj); - context->Global()->Set(v8::String::New("_sessionid"), v8::String::New(interpreter->getSessionId().c_str()), v8::ReadOnly); - context->Global()->Set(v8::String::New("_name"), v8::String::New(interpreter->getName().c_str()), v8::ReadOnly); - context->Global()->Set(v8::String::New("_ioprocessors"), v8::Object::New(), v8::ReadOnly); + + context->Global()->SetAccessor(v8::String::New("_sessionid"), + V8DataModel::getAttribute, + V8DataModel::setWithException, + v8::String::New(interpreter->getSessionId().c_str())); + context->Global()->SetAccessor(v8::String::New("_name"), + V8DataModel::getAttribute, + V8DataModel::setWithException, + v8::String::New(interpreter->getName().c_str())); + context->Global()->SetAccessor(v8::String::New("_ioprocessors"), + V8DataModel::getIOProcessors, + V8DataModel::setWithException, + v8::External::New(reinterpret_cast(dm.get()))); dm->_contexts.push_back(context); @@ -70,13 +80,31 @@ boost::shared_ptr V8DataModel::create(Interpreter* interpreter) { return dm; } -void V8DataModel::registerIOProcessor(const std::string& name, const IOProcessor& ioprocessor) { - v8::Locker locker; - v8::HandleScope handleScope; - v8::Context::Scope contextScope(_contexts.front()); - v8::Handle global = _contexts.front()->Global(); - v8::Handle ioProcessors = global->Get(v8::String::New("_ioprocessors"))->ToObject(); - ioProcessors->Set(v8::String::New(name.c_str()),getDataAsValue(ioprocessor.getDataModelVariables())); +v8::Handle V8DataModel::getAttribute(v8::Local property, const v8::AccessorInfo& info) { + return info.Data(); +} + +void V8DataModel::setWithException(v8::Local property, v8::Local value, const v8::AccessorInfo& info) { + v8::String::AsciiValue data(property); + std::string msg = "Cannot set " + std::string(*data); + v8::ThrowException(v8::Exception::ReferenceError(v8::String::New(msg.c_str()))); +} + +v8::Handle V8DataModel::getIOProcessors(v8::Local property, const v8::AccessorInfo& info) { + V8DataModel* dataModel = Arabica::DOM::V8DOM::toClassPtr(info.Data()); + + if (dataModel->_ioProcessors.IsEmpty()) { + dataModel->_ioProcessors = v8::Persistent::New(v8::Object::New()); + //v8::Handle ioProcessorObj = v8::Object::New(); + std::map ioProcessors = dataModel->_interpreter->getIOProcessors(); + std::map::const_iterator ioProcIter = ioProcessors.begin(); + while(ioProcIter != ioProcessors.end()) { + dataModel->_ioProcessors->Set(v8::String::New(ioProcIter->first.c_str()), + dataModel->getDataAsValue(ioProcIter->second.getDataModelVariables())); + ioProcIter++; + } + } + return dataModel->_ioProcessors; } V8DataModel::~V8DataModel() { @@ -281,10 +309,10 @@ void V8DataModel::eval(const std::string& expr) { bool V8DataModel::isDeclared(const std::string& expr) { /** - * Undeclared variables can be checked by trying to access them and catching + * Undeclared variables can be checked by trying to access them and catching * a reference error. */ - + v8::Locker locker; v8::HandleScope handleScope; v8::Context::Scope contextScope(_contexts.back()); @@ -292,14 +320,14 @@ bool V8DataModel::isDeclared(const std::string& expr) { v8::TryCatch tryCatch; v8::Handle source = v8::String::New(expr.c_str()); v8::Handle script = v8::Script::Compile(source); - + v8::Handle result; if (!script.IsEmpty()) result = script->Run(); - + if (result.IsEmpty()) return false; - + return true; } @@ -374,6 +402,7 @@ void V8DataModel::throwExceptionEvent(const v8::TryCatch& tryCatch) { assert(tryCatch.HasCaught()); Event exceptionEvent; exceptionEvent.name = "error.execution"; + exceptionEvent.type = Event::PLATFORM; std::string exceptionString(*v8::String::AsciiValue(tryCatch.Exception())); exceptionEvent.data.compound["exception"] = Data(exceptionString, Data::VERBATIM);; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h index 441297d..6348cbc 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h @@ -33,10 +33,8 @@ public: virtual void initialize(); virtual void setEvent(const Event& event); - virtual void registerIOProcessor(const std::string& name, const IOProcessor& ioprocessor); - virtual bool validate(const std::string& location, const std::string& schema); - + virtual uint32_t getLength(const std::string& expr); virtual void pushContext(); virtual void popContext(); @@ -48,7 +46,7 @@ public: virtual Data getStringAsData(const std::string& content); virtual Data getValueAsData(const v8::Handle& value); virtual bool isDeclared(const std::string& expr); - + virtual std::string evalAsString(const std::string& expr); virtual bool evalAsBool(const std::string& expr); virtual double evalAsNumber(const std::string& expr); @@ -61,8 +59,13 @@ protected: Arabica::DOM::V8DOM* _dom; + v8::Persistent _ioProcessors; + static v8::Handle getIOProcessors(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle getAttribute(v8::Local property, const v8::AccessorInfo& info); + static void setWithException(v8::Local property, v8::Local value, const v8::AccessorInfo& info); + v8::Handle evalAsValue(const std::string& expr); - virtual v8::Handle getDataAsValue(const Data& data); + v8::Handle getDataAsValue(const Data& data); void throwExceptionEvent(const v8::TryCatch& tryCatch); }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.cpp.old b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.cpp.old deleted file mode 100644 index 31372ed..0000000 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.cpp.old +++ /dev/null @@ -1,59 +0,0 @@ -#include "V8Document.h" -#include "V8Element.h" -#include "V8XPathResult.h" - -namespace uscxml { - -using namespace Arabica::DOM; -using namespace Arabica::XPath; - -v8::Persistent V8Document::Tmpl; - -v8::Handle V8Document::createElementCallback(const v8::Arguments& args) { - ASSERT_ARGS1(args, IsString); - v8::String::AsciiValue tagName(args[0]); - - v8::Local self = args.Holder(); - Document* doc = V8DOM::toClassPtr >(self->GetInternalField(0)); - V8DOM* dom = V8DOM::toClassPtr(self->GetInternalField(1)); (void)dom; - - Element* element = new Element(doc->createElement(*tagName)); - - v8::Handle elemCtor = V8Element::getTmpl()->GetFunction(); - v8::Persistent elemObj = v8::Persistent::New(elemCtor->NewInstance()); - - elemObj->SetInternalField(0, V8DOM::toExternal(element)); - elemObj->SetInternalField(1, self->GetInternalField(1)); - - elemObj.MakeWeak(0, V8Element::jsDestructor); - return elemObj; -} - -v8::Handle V8Document::evaluateCallback(const v8::Arguments& args) { - ASSERT_ARGS1(args, IsString); - v8::String::AsciiValue xpathExpr(args[0]); - - v8::Local self = args.Holder(); - Document* doc = V8DOM::toClassPtr >(self->GetInternalField(0)); - V8DOM* dom = V8DOM::toClassPtr(self->GetInternalField(1)); (void)dom; - - Node* context; - if (args.Length() > 1) { - context = V8DOM::toClassPtr >(args[1]->ToObject()->GetInternalField(0)); - } else { - context = doc; - } - - XPathValue* xpathValue = new XPathValue(dom->xpath->evaluate(*xpathExpr, *context)); - - v8::Handle xpathResultCtor = V8XPathResult::getTmpl()->GetFunction(); - v8::Persistent xpathResultObj = v8::Persistent::New(xpathResultCtor->NewInstance()); - - xpathResultObj->SetInternalField(0, V8DOM::toExternal(xpathValue)); - xpathResultObj->SetInternalField(1, self->GetInternalField(1)); - - xpathResultObj.MakeWeak(0, V8XPathResult::jsDestructor); - return xpathResultObj; -} - -} \ No newline at end of file diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.cpp.old b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.cpp.old deleted file mode 100644 index 14b2eae..0000000 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.cpp.old +++ /dev/null @@ -1,24 +0,0 @@ -#include "V8Element.h" -#include - -namespace uscxml { - -using namespace Arabica::DOM; - -v8::Persistent V8Element::Tmpl; - -v8::Handle V8Element::setAttributeCallback(const v8::Arguments& args) { - ASSERT_ARGS2(args, IsString, IsString); - v8::String::AsciiValue key(args[0]); - v8::String::AsciiValue value(args[1]); - - v8::Local self = args.Holder(); - Element* elem = V8DOM::toClassPtr >(self->GetInternalField(0)); - V8DOM* dom = V8DOM::toClassPtr(self->GetInternalField(1)); (void)dom; - - elem->setAttribute(*key, *value); - - return v8::Undefined(); -} - -} \ No newline at end of file diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.h.old b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.h.old deleted file mode 100644 index f610108..0000000 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.h.old +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef V8ELEMENT_H_B55C09NB -#define V8ELEMENT_H_B55C09NB - -#include "V8DOM.h" -#include "V8Node.h" - -namespace uscxml { - - class V8Element { - public: - static v8::Handle tagNameAttrGetter(v8::Local property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - - static v8::Handle getAttributeCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle setAttributeCallback(const v8::Arguments& args); - static v8::Handle removeAttributeCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle getAttributeNodeCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle setAttributeNodeCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle removeAttributeNodeCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle getElementsByTagNameCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle getAttributeNSCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle setAttributeNSCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle removeAttributeNSCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle getElementsByTagNameNSCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle getAttributeNodeNSCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle setAttributeNodeNSCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle hasAttributeCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle hasAttributeNSCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - - V8_DESTRUCTOR(Arabica::DOM::Element); - - static v8::Persistent Tmpl; - static v8::Handle getTmpl() { - if (Tmpl.IsEmpty()) { - v8::Handle tmpl = v8::FunctionTemplate::New(); - tmpl->SetClassName(v8::String::New("Element")); - tmpl->ReadOnlyPrototype(); - - v8::Local instance = tmpl->InstanceTemplate(); - v8::Local prototype = tmpl->PrototypeTemplate(); - instance->SetInternalFieldCount(2); - - instance->SetAccessor(v8::String::NewSymbol("tagName"), V8Element::tagNameAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - - prototype->Set(v8::String::NewSymbol("getAttribute"), - v8::FunctionTemplate::New(V8Element::getAttributeCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("setAttribute"), - v8::FunctionTemplate::New(V8Element::setAttributeCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("removeAttribute"), - v8::FunctionTemplate::New(V8Element::removeAttributeCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("getAttributeNode"), - v8::FunctionTemplate::New(V8Element::getAttributeNodeCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("setAttributeNode"), - v8::FunctionTemplate::New(V8Element::setAttributeNodeCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("removeAttributeNode"), - v8::FunctionTemplate::New(V8Element::removeAttributeNodeCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("getElementsByTagName"), - v8::FunctionTemplate::New(V8Element::getElementsByTagNameCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("getAttributeNS"), - v8::FunctionTemplate::New(V8Element::getAttributeNSCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("setAttributeNS"), - v8::FunctionTemplate::New(V8Element::setAttributeNSCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("removeAttributeNS"), - v8::FunctionTemplate::New(V8Element::removeAttributeNSCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("getElementsByTagNameNS"), - v8::FunctionTemplate::New(V8Element::getElementsByTagNameNSCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("getAttributeNodeNS"), - v8::FunctionTemplate::New(V8Element::getAttributeNodeNSCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("setAttributeNodeNS"), - v8::FunctionTemplate::New(V8Element::setAttributeNodeNSCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("hasAttribute"), - v8::FunctionTemplate::New(V8Element::hasAttributeCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("hasAttributeNS"), - v8::FunctionTemplate::New(V8Element::hasAttributeNSCallback, v8::Undefined()), static_cast(v8::DontDelete)); - - tmpl->Inherit(V8Node::getTmpl()); - Tmpl = v8::Persistent::New(tmpl); - } - return Tmpl; - } - - }; - -} - - -#endif /* end of include guard: V8ELEMENT_H_B55C09NB */ diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.cpp.old b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.cpp.old deleted file mode 100644 index 97a8c1a..0000000 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.cpp.old +++ /dev/null @@ -1,23 +0,0 @@ -#include "V8Node.h" -#include - -namespace uscxml { - -using namespace Arabica::DOM; - -v8::Persistent V8Node::Tmpl; - -v8::Handle V8Node::appendChildCallback(const v8::Arguments& args) { - assert(args.Length() == 1); - assert(args[0]->IsObject()); - - v8::Local self = args.Holder(); - - Node* node = V8DOM::toClassPtr >(self->GetInternalField(0)); - Node* childToAppend = V8DOM::toClassPtr >(args[0]->ToObject()->GetInternalField(0)); - node->appendChild(*childToAppend); - - return v8::Undefined(); -} - -} \ No newline at end of file diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.h.old b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.h.old deleted file mode 100644 index 7048ab5..0000000 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.h.old +++ /dev/null @@ -1,161 +0,0 @@ -#ifndef V8NODE_H_9VGQMJNI -#define V8NODE_H_9VGQMJNI - -#include "V8DOM.h" - -namespace uscxml { - - class V8Node { - public: - static v8::Handle nodeNameAttrGetter(v8::Local property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle nodeValueAttrGetter(v8::Local property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle nodeTypeAttrGetter(v8::Local property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle parentNodeAttrGetter(v8::Local property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle childNodesAttrGetter(v8::Local property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle firstChildAttrGetter(v8::Local property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle lastChildAttrGetter(v8::Local property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle previousSiblingAttrGetter(v8::Local property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle nextSiblingAttrGetter(v8::Local property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle attributesAttrGetter(v8::Local property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle ownerDocumentAttrGetter(v8::Local property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle namespaceURIAttrGetter(v8::Local property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle prefixAttrGetter(v8::Local property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle localNameAttrGetter(v8::Local property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle baseURIAttrGetter(v8::Local property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle textContentAttrGetter(v8::Local property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle parentElementAttrGetter(v8::Local property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - - static void nodeValueAttrSetter(v8::Local property, v8::Local value, const v8::AccessorInfo& info) { } - static void prefixAttrSetter(v8::Local property, v8::Local value, const v8::AccessorInfo& info) { } - static void textContentAttrSetter(v8::Local property, v8::Local value, const v8::AccessorInfo& info) { } - - static v8::Handle insertBeforeCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle replaceChildCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle removeChildCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle appendChildCallback(const v8::Arguments& args); - static v8::Handle hasChildNodesCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle cloneNodeCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle normalizeCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle isSupportedCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle hasAttributesCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle lookupPrefixCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle isDefaultNamespaceCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle lookupNamespaceURICallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle addEventListenerCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle removeEventListenerCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - - V8_DESTRUCTOR(Arabica::DOM::Node); - - static v8::Persistent Tmpl; - static v8::Handle getTmpl() { - if (Tmpl.IsEmpty()) { - v8::Handle tmpl = v8::FunctionTemplate::New(); - tmpl->SetClassName(v8::String::New("Node")); - tmpl->ReadOnlyPrototype(); - - v8::Local instance = tmpl->InstanceTemplate(); - v8::Local prototype = tmpl->PrototypeTemplate(); - instance->SetInternalFieldCount(2); - - instance->SetAccessor(v8::String::NewSymbol("nodeName"), V8Node::nodeNameAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("nodeValue"), V8Node::nodeValueAttrGetter, V8Node::nodeValueAttrSetter, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("nodeType"), V8Node::nodeTypeAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("parentNode"), V8Node::parentNodeAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("childNodes"), V8Node::childNodesAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("firstChild"), V8Node::firstChildAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("lastChild"), V8Node::lastChildAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("previousSibling"), V8Node::previousSiblingAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("nextSibling"), V8Node::nextSiblingAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("attributes"), V8Node::attributesAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("ownerDocument"), V8Node::ownerDocumentAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("namespaceURI"), V8Node::namespaceURIAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("prefix"), V8Node::prefixAttrGetter, V8Node::prefixAttrSetter, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("localName"), V8Node::localNameAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("baseURI"), V8Node::baseURIAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("textContent"), V8Node::textContentAttrGetter, V8Node::textContentAttrSetter, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("parentElement"), V8Node::parentElementAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - - prototype->Set(v8::String::NewSymbol("insertBefore"), - v8::FunctionTemplate::New(V8Node::insertBeforeCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("replaceChild"), - v8::FunctionTemplate::New(V8Node::replaceChildCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("removeChild"), - v8::FunctionTemplate::New(V8Node::removeChildCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("appendChild"), - v8::FunctionTemplate::New(V8Node::appendChildCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("hasChildNodes"), - v8::FunctionTemplate::New(V8Node::hasChildNodesCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("cloneNode"), - v8::FunctionTemplate::New(V8Node::cloneNodeCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("normalize"), - v8::FunctionTemplate::New(V8Node::normalizeCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("isSupported"), - v8::FunctionTemplate::New(V8Node::isSupportedCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("hasAttributes"), - v8::FunctionTemplate::New(V8Node::hasAttributesCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("lookupPrefix"), - v8::FunctionTemplate::New(V8Node::lookupPrefixCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("isDefaultNamespace"), - v8::FunctionTemplate::New(V8Node::isDefaultNamespaceCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("lookupNamespaceURI"), - v8::FunctionTemplate::New(V8Node::lookupNamespaceURICallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("addEventListener"), - v8::FunctionTemplate::New(V8Node::addEventListenerCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("removeEventListener"), - v8::FunctionTemplate::New(V8Node::removeEventListenerCallback, v8::Undefined()), static_cast(v8::DontDelete)); - - tmpl->Set(v8::String::NewSymbol("ELEMENT_NODE"), v8::Integer::New(Arabica::DOM::Node_base::ELEMENT_NODE), v8::ReadOnly); - prototype->Set(v8::String::NewSymbol("ELEMENT_NODE"), v8::Integer::New(Arabica::DOM::Node_base::ELEMENT_NODE), v8::ReadOnly); - tmpl->Set(v8::String::NewSymbol("ATTRIBUTE_NODE"), v8::Integer::New(Arabica::DOM::Node_base::ATTRIBUTE_NODE), v8::ReadOnly); - prototype->Set(v8::String::NewSymbol("ATTRIBUTE_NODE"), v8::Integer::New(Arabica::DOM::Node_base::ATTRIBUTE_NODE), v8::ReadOnly); - tmpl->Set(v8::String::NewSymbol("TEXT_NODE"), v8::Integer::New(Arabica::DOM::Node_base::TEXT_NODE), v8::ReadOnly); - prototype->Set(v8::String::NewSymbol("TEXT_NODE"), v8::Integer::New(Arabica::DOM::Node_base::TEXT_NODE), v8::ReadOnly); - tmpl->Set(v8::String::NewSymbol("CDATA_SECTION_NODE"), v8::Integer::New(Arabica::DOM::Node_base::CDATA_SECTION_NODE), v8::ReadOnly); - prototype->Set(v8::String::NewSymbol("CDATA_SECTION_NODE"), v8::Integer::New(Arabica::DOM::Node_base::CDATA_SECTION_NODE), v8::ReadOnly); - tmpl->Set(v8::String::NewSymbol("ENTITY_REFERENCE_NODE"), v8::Integer::New(Arabica::DOM::Node_base::ENTITY_REFERENCE_NODE), v8::ReadOnly); - prototype->Set(v8::String::NewSymbol("ENTITY_REFERENCE_NODE"), v8::Integer::New(Arabica::DOM::Node_base::ENTITY_REFERENCE_NODE), v8::ReadOnly); - tmpl->Set(v8::String::NewSymbol("ENTITY_NODE"), v8::Integer::New(Arabica::DOM::Node_base::ENTITY_NODE), v8::ReadOnly); - prototype->Set(v8::String::NewSymbol("ENTITY_NODE"), v8::Integer::New(Arabica::DOM::Node_base::ENTITY_NODE), v8::ReadOnly); - tmpl->Set(v8::String::NewSymbol("PROCESSING_INSTRUCTION_NODE"), v8::Integer::New(Arabica::DOM::Node_base::PROCESSING_INSTRUCTION_NODE), v8::ReadOnly); - prototype->Set(v8::String::NewSymbol("PROCESSING_INSTRUCTION_NODE"), v8::Integer::New(Arabica::DOM::Node_base::PROCESSING_INSTRUCTION_NODE), v8::ReadOnly); - tmpl->Set(v8::String::NewSymbol("COMMENT_NODE"), v8::Integer::New(Arabica::DOM::Node_base::COMMENT_NODE), v8::ReadOnly); - prototype->Set(v8::String::NewSymbol("COMMENT_NODE"), v8::Integer::New(Arabica::DOM::Node_base::COMMENT_NODE), v8::ReadOnly); - tmpl->Set(v8::String::NewSymbol("DOCUMENT_NODE"), v8::Integer::New(Arabica::DOM::Node_base::DOCUMENT_NODE), v8::ReadOnly); - prototype->Set(v8::String::NewSymbol("DOCUMENT_NODE"), v8::Integer::New(Arabica::DOM::Node_base::DOCUMENT_NODE), v8::ReadOnly); - tmpl->Set(v8::String::NewSymbol("DOCUMENT_TYPE_NODE"), v8::Integer::New(Arabica::DOM::Node_base::DOCUMENT_TYPE_NODE), v8::ReadOnly); - prototype->Set(v8::String::NewSymbol("DOCUMENT_TYPE_NODE"), v8::Integer::New(Arabica::DOM::Node_base::DOCUMENT_TYPE_NODE), v8::ReadOnly); - tmpl->Set(v8::String::NewSymbol("DOCUMENT_FRAGMENT_NODE"), v8::Integer::New(Arabica::DOM::Node_base::DOCUMENT_FRAGMENT_NODE), v8::ReadOnly); - prototype->Set(v8::String::NewSymbol("DOCUMENT_FRAGMENT_NODE"), v8::Integer::New(Arabica::DOM::Node_base::DOCUMENT_FRAGMENT_NODE), v8::ReadOnly); - tmpl->Set(v8::String::NewSymbol("NOTATION_NODE"), v8::Integer::New(Arabica::DOM::Node_base::NOTATION_NODE), v8::ReadOnly); - prototype->Set(v8::String::NewSymbol("NOTATION_NODE"), v8::Integer::New(Arabica::DOM::Node_base::NOTATION_NODE), v8::ReadOnly); - tmpl->Set(v8::String::NewSymbol("MAX_TYPE"), v8::Integer::New(Arabica::DOM::Node_base::MAX_TYPE), v8::ReadOnly); - prototype->Set(v8::String::NewSymbol("MAX_TYPE"), v8::Integer::New(Arabica::DOM::Node_base::MAX_TYPE), v8::ReadOnly); - - Tmpl = v8::Persistent::New(tmpl); - } - return Tmpl; - } - - }; - -} - - -#endif /* end of include guard: V8NODE_H_9VGQMJNI */ diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.cpp.old b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.cpp.old deleted file mode 100644 index cadcf7f..0000000 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.cpp.old +++ /dev/null @@ -1,60 +0,0 @@ -#include "V8NodeSet.h" -#include "V8Element.h" -#include "V8Node.h" -#include - -namespace uscxml { - -using namespace Arabica::DOM; -using namespace Arabica::XPath; - -v8::Persistent V8NodeSet::Tmpl; - - -v8::Handle V8NodeSet::indexGetter(uint32_t index, const v8::AccessorInfo &info) { - v8::Local self = info.Holder(); - - NodeSet* nodeSet = V8DOM::toClassPtr >(self->GetInternalField(0)); - V8DOM* dom = V8DOM::toClassPtr(self->GetInternalField(1)); (void)dom; - - if (nodeSet->size() >= index) { - switch((*nodeSet)[index].getNodeType()) { - case Node_base::ELEMENT_NODE: { - v8::Handle elementCtor = V8Element::getTmpl()->GetFunction(); - v8::Persistent elementObj = v8::Persistent::New(elementCtor->NewInstance()); - - Element* element = new Element((*nodeSet)[index]); - - elementObj->SetInternalField(0, V8DOM::toExternal(element)); - elementObj->SetInternalField(1, self->GetInternalField(1)); - elementObj.MakeWeak(0, V8Element::jsDestructor); - return elementObj; - } - default: { - v8::Handle nodeCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent nodeObj = v8::Persistent::New(nodeCtor->NewInstance()); - - Node* node = new Node((*nodeSet)[index]); - - nodeObj->SetInternalField(0, V8DOM::toExternal(node)); - nodeObj->SetInternalField(1, self->GetInternalField(1)); - nodeObj.MakeWeak(0, V8Node::jsDestructor); - return nodeObj; - - } - } - } - - return v8::Undefined(); -} - -v8::Handle V8NodeSet::lengthAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - - V8DOM* dom = V8DOM::toClassPtr(self->GetInternalField(1)); (void)dom; - NodeSet* nodeSet = V8DOM::toClassPtr >(self->GetInternalField(1)); - - return v8::Integer::New(nodeSet->size()); -} - -} \ No newline at end of file diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.h.old b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.h.old deleted file mode 100644 index cb95a5d..0000000 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.h.old +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef V8NODESET_HPP_WKKXJ1RD -#define V8NODESET_HPP_WKKXJ1RD - -#include "V8DOM.h" - -namespace uscxml { - - class V8NodeSet { - public: - static v8::Handle indexGetter(uint32_t index, const v8::AccessorInfo &info); - static v8::Handle indexSetter(uint32_t index, v8::Local value, const v8::AccessorInfo &info) { assert(false); return v8::Undefined(); } - static v8::Handle lengthAttrGetter(v8::Local property, const v8::AccessorInfo& info); - - V8_DESTRUCTOR(Arabica::XPath::NodeSet); - - static v8::Persistent Tmpl; - static v8::Handle getTmpl() { - if (Tmpl.IsEmpty()) { - v8::Handle tmpl = v8::FunctionTemplate::New(); - tmpl->SetClassName(v8::String::New("NodeSet")); - tmpl->ReadOnlyPrototype(); - - v8::Local instance = tmpl->InstanceTemplate(); - // v8::Local prototype = tmpl->PrototypeTemplate(); - instance->SetInternalFieldCount(2); - - instance->SetIndexedPropertyHandler(V8NodeSet::indexGetter, V8NodeSet::indexSetter); - - instance->SetAccessor(v8::String::NewSymbol("length"), V8NodeSet::lengthAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - - Tmpl = v8::Persistent::New(tmpl); - } - return Tmpl; - } - - }; - -} - -#endif /* end of include guard: V8NODESET_HPP_WKKXJ1RD */ diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.cpp index ed6133a..fec2a94 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.cpp @@ -7,13 +7,6 @@ namespace DOM { v8::Persistent V8SCXMLEvent::Tmpl; -v8::Handle V8SCXMLEvent::typeAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - - return v8::Integer::New(privData->nativeObj->type); -} - v8::Handle V8SCXMLEvent::nameAttrGetter(v8::Local property, const v8::AccessorInfo& info) { v8::Local self = info.Holder(); struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.h index 62495cf..f17856a 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.h @@ -41,7 +41,7 @@ public: static bool hasInstance(v8::Handle); - static v8::Handle typeAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle typeCustomAttrGetter(v8::Local property, const v8::AccessorInfo& info); static v8::Handle nameAttrGetter(v8::Local property, const v8::AccessorInfo& info); static v8::Handle originAttrGetter(v8::Local property, const v8::AccessorInfo& info); static v8::Handle origintypeAttrGetter(v8::Local property, const v8::AccessorInfo& info); @@ -62,7 +62,7 @@ public: instance->SetInternalFieldCount(1); - instance->SetAccessor(v8::String::NewSymbol("type"), V8SCXMLEvent::typeAttrGetter, 0, + instance->SetAccessor(v8::String::NewSymbol("type"), V8SCXMLEvent::typeCustomAttrGetter, 0, v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); instance->SetAccessor(v8::String::NewSymbol("name"), V8SCXMLEvent::nameAttrGetter, 0, v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEventCustom.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEventCustom.cpp new file mode 100644 index 0000000..05644b0 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEventCustom.cpp @@ -0,0 +1,27 @@ +#include "V8SCXMLEvent.h" + +namespace Arabica { +namespace DOM { + +v8::Handle V8SCXMLEvent::typeCustomAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + V8SCXMLEvent::V8SCXMLEventPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + + switch (privData->nativeObj->type) { + case uscxml::Event::INTERNAL: + return v8::String::New("internal"); + break; + case uscxml::Event::EXTERNAL: + return v8::String::New("external"); + break; + case uscxml::Event::PLATFORM: + return v8::String::New("platform"); + break; + default: + break; + } + return v8::String::New("unknown"); +} + +} +} \ No newline at end of file diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.cpp.old b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.cpp.old deleted file mode 100644 index 04bfcbe..0000000 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.cpp.old +++ /dev/null @@ -1,30 +0,0 @@ -#include "V8XPathResult.h" -#include "V8NodeSet.h" - -namespace uscxml { - -using namespace Arabica::DOM; -using namespace Arabica::XPath; - -v8::Persistent V8XPathResult::Tmpl; - -v8::Handle V8XPathResult::asNodeSetCallback(const v8::Arguments& args) { - - v8::Local self = args.Holder(); - XPathValue* xpathValue = V8DOM::toClassPtr >(self->GetInternalField(0)); - V8DOM* dom = V8DOM::toClassPtr(self->GetInternalField(1)); (void)dom; - - v8::Handle nodeSetCtor = V8NodeSet::getTmpl()->GetFunction(); - v8::Persistent nodeSetObj = v8::Persistent::New(nodeSetCtor->NewInstance()); - - Arabica::XPath::NodeSet* nodeSet = new Arabica::XPath::NodeSet(xpathValue->asNodeSet()); - - nodeSetObj->SetInternalField(0, V8DOM::toExternal(nodeSet)); - nodeSetObj->SetInternalField(1, self->GetInternalField(1)); - - nodeSetObj.MakeWeak(0, V8NodeSet::jsDestructor); - return nodeSetObj; - -} - -} \ No newline at end of file diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.h.old b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.h.old deleted file mode 100644 index ce5e2d5..0000000 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.h.old +++ /dev/null @@ -1,75 +0,0 @@ -#ifndef V8XPATHRESULT_HPP_AYZD0IRH -#define V8XPATHRESULT_HPP_AYZD0IRH - -#include "V8DOM.h" - -namespace uscxml { - class V8XPathResult { - public: - static v8::Handle resultTypeAttrGetter(v8::Local property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle numberValueAttrGetter(v8::Local property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle stringValueAttrGetter(v8::Local property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle booleanValueAttrGetter(v8::Local property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle singleNodeAttrGetter(v8::Local property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle invalidIteratorStateAttrGetter(v8::Local property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle snapshotLengthAttrGetter(v8::Local property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - - static v8::Handle iterateNextCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle snapshotItemCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - - static v8::Handle asNodeSetCallback(const v8::Arguments& args); - static v8::Handle asBoolCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle asStringCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle asNumberCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - - V8_DESTRUCTOR(Arabica::XPath::XPathValue); - - static v8::Persistent Tmpl; - static v8::Handle getTmpl() { - if (Tmpl.IsEmpty()) { - v8::Handle tmpl = v8::FunctionTemplate::New(); - tmpl->SetClassName(v8::String::New("XPathResult")); - tmpl->ReadOnlyPrototype(); - - v8::Local instance = tmpl->InstanceTemplate(); - v8::Local prototype = tmpl->PrototypeTemplate(); - instance->SetInternalFieldCount(2); - - instance->SetAccessor(v8::String::NewSymbol("resultType"), V8XPathResult::resultTypeAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("numberValue"), V8XPathResult::numberValueAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("stringValue"), V8XPathResult::stringValueAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("booleanValue"), V8XPathResult::booleanValueAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("singleNode"), V8XPathResult::singleNodeAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("invalidIteratorState"), V8XPathResult::invalidIteratorStateAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("snapshotLength"), V8XPathResult::snapshotLengthAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - - prototype->Set(v8::String::NewSymbol("iterateNext"), - v8::FunctionTemplate::New(V8XPathResult::iterateNextCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("snapshotItem"), - v8::FunctionTemplate::New(V8XPathResult::snapshotItemCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("asNodeSet"), - v8::FunctionTemplate::New(V8XPathResult::asNodeSetCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("asBool"), - v8::FunctionTemplate::New(V8XPathResult::asBoolCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("asString"), - v8::FunctionTemplate::New(V8XPathResult::asStringCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("asNumber"), - v8::FunctionTemplate::New(V8XPathResult::asNumberCallback, v8::Undefined()), static_cast(v8::DontDelete)); - - Tmpl = v8::Persistent::New(tmpl); - } - return Tmpl; - } - - }; -} - - -#endif /* end of include guard: V8XPATHRESULT_HPP_AYZD0IRH */ diff --git a/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp b/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp index c9d2237..75d6da9 100644 --- a/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp +++ b/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp @@ -143,7 +143,7 @@ void SWIDataModel::assign(const std::string& location, const std::string& expr) } bool SWIDataModel::isDefined(const std::string& expr) { - return true; + return true; } } \ No newline at end of file diff --git a/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp b/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp index 292b79e..7ad528d 100644 --- a/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp +++ b/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp @@ -15,7 +15,7 @@ bool connect(pluma::Host& host) { } #endif - USCXMLInvoker::USCXMLInvoker() : _cancelled(false) { +USCXMLInvoker::USCXMLInvoker() : _cancelled(false) { } @@ -54,7 +54,7 @@ void USCXMLInvoker::invoke(const InvokeRequest& req) { if (_invokedInterpreter) { DataModel dataModel(_invokedInterpreter->getDataModel()); if (dataModel) { - + } _invokedInterpreter->setParentQueue(this); // transfer namespace prefixes @@ -68,10 +68,10 @@ void USCXMLInvoker::invoke(const InvokeRequest& req) { } _invokedInterpreter->_xmlNSPrefix = _parentInterpreter->_xmlNSPrefix; _invokedInterpreter->_sessionId = req.invokeid; - + /// test240 assumes that invoke request params will carry over to the datamodel _invokedInterpreter->setInvokeRequest(req); - + _invokedInterpreter->start(); } } diff --git a/src/uscxml/server/InterpreterServlet.cpp b/src/uscxml/server/InterpreterServlet.cpp index e537275..99b81b2 100644 --- a/src/uscxml/server/InterpreterServlet.cpp +++ b/src/uscxml/server/InterpreterServlet.cpp @@ -1,5 +1,6 @@ #include "InterpreterServlet.h" #include "uscxml/Interpreter.h" +#include namespace uscxml { @@ -17,6 +18,12 @@ InterpreterServlet::InterpreterServlet(Interpreter* interpreter) { _path = path.str(); } +boost::shared_ptr InterpreterServlet::create(Interpreter* interpreter) { + // we instantiate directly in Interpreter + boost::shared_ptr io = boost::shared_ptr(new InterpreterServlet(interpreter)); + return io; +} + void InterpreterServlet::httpRecvRequest(const HTTPServer::Request& req) { tthread::lock_guard lock(_mutex); @@ -31,4 +38,15 @@ void InterpreterServlet::httpRecvRequest(const HTTPServer::Request& req) { _interpreter->receive(event); } +Data InterpreterServlet::getDataModelVariables() { + Data data; + assert(_url.length() > 0); + data.compound["location"] = Data(_url, Data::VERBATIM); + return data; +} + +void InterpreterServlet::send(const SendRequest& req) { + LOG(ERROR) << "send not supported by http iorprocessor, use the fetch element"; +} + } \ No newline at end of file diff --git a/src/uscxml/server/InterpreterServlet.h b/src/uscxml/server/InterpreterServlet.h index 72f2f67..18e1d28 100644 --- a/src/uscxml/server/InterpreterServlet.h +++ b/src/uscxml/server/InterpreterServlet.h @@ -2,15 +2,30 @@ #define INTERPRETERSERVLET_H_XQLWNMH4 #include "HTTPServer.h" +#include "uscxml/Factory.h" namespace uscxml { class Interpreter; -class InterpreterServlet : public HTTPServlet { +class InterpreterServlet : public HTTPServlet, public IOProcessorImpl { public: + InterpreterServlet() {}; InterpreterServlet(Interpreter* interpreter); virtual ~InterpreterServlet() {} + + virtual boost::shared_ptr create(Interpreter* interpreter); + + virtual std::set getNames() { + std::set names; + names.insert("http"); + names.insert("http://www.w3.org/TR/scxml/#HTTPEventProcessor"); + return names; + } + + Data getDataModelVariables(); + virtual void send(const SendRequest& req); + virtual void httpRecvRequest(const HTTPServer::Request& req); std::string getPath() { @@ -26,6 +41,7 @@ public: return false; } + std::map& getRequests() { return _requests; } diff --git a/test/samples/w3c/tests/test322.scxml b/test/samples/w3c/tests/test322.scxml index 3e8835c..2c7f536 100644 --- a/test/samples/w3c/tests/test322.scxml +++ b/test/samples/w3c/tests/test322.scxml @@ -12,7 +12,9 @@ be assigned to --> + + diff --git a/test/samples/w3c/tests/test330.scxml b/test/samples/w3c/tests/test330.scxml index 5cbf4bc..5488f96 100644 --- a/test/samples/w3c/tests/test330.scxml +++ b/test/samples/w3c/tests/test330.scxml @@ -1,4 +1,4 @@ - + @@ -17,7 +17,7 @@ - - + + \ No newline at end of file -- cgit v0.12