diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-04-02 18:42:17 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-04-02 18:42:17 (GMT) |
commit | f627a8a8b139a42568f67dc18679d92806e0ff4e (patch) | |
tree | 0ef345134ce775c6fca5ec35d2b6eecddbf3450e /src/uscxml/plugins | |
parent | f19be97dea6fd8da994392d6fa7de5b3f0d9bf3e (diff) | |
download | uscxml-f627a8a8b139a42568f67dc18679d92806e0ff4e.zip uscxml-f627a8a8b139a42568f67dc18679d92806e0ff4e.tar.gz uscxml-f627a8a8b139a42568f67dc18679d92806e0ff4e.tar.bz2 |
More bug-fixes for W3C tests
Diffstat (limited to 'src/uscxml/plugins')
16 files changed, 86 insertions, 594 deletions
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<DataModelImpl> 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<void*>(dm.get()))); dm->_contexts.push_back(context); @@ -70,13 +80,31 @@ boost::shared_ptr<DataModelImpl> 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<v8::Object> global = _contexts.front()->Global(); - v8::Handle<v8::Object> ioProcessors = global->Get(v8::String::New("_ioprocessors"))->ToObject(); - ioProcessors->Set(v8::String::New(name.c_str()),getDataAsValue(ioprocessor.getDataModelVariables())); +v8::Handle<v8::Value> V8DataModel::getAttribute(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + return info.Data(); +} + +void V8DataModel::setWithException(v8::Local<v8::String> property, v8::Local<v8::Value> 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<v8::Value> V8DataModel::getIOProcessors(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + V8DataModel* dataModel = Arabica::DOM::V8DOM::toClassPtr<V8DataModel>(info.Data()); + + if (dataModel->_ioProcessors.IsEmpty()) { + dataModel->_ioProcessors = v8::Persistent<v8::Object>::New(v8::Object::New()); + //v8::Handle<v8::Object> ioProcessorObj = v8::Object::New(); + std::map<std::string, IOProcessor> ioProcessors = dataModel->_interpreter->getIOProcessors(); + std::map<std::string, IOProcessor>::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<v8::String> source = v8::String::New(expr.c_str()); v8::Handle<v8::Script> script = v8::Script::Compile(source); - + v8::Handle<v8::Value> 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<v8::Value>& 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<v8::Object> _ioProcessors; + static v8::Handle<v8::Value> getIOProcessors(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> getAttribute(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static void setWithException(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info); + v8::Handle<v8::Value> evalAsValue(const std::string& expr); - virtual v8::Handle<v8::Value> getDataAsValue(const Data& data); + v8::Handle<v8::Value> 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<v8::FunctionTemplate> V8Document::Tmpl; - -v8::Handle<v8::Value> V8Document::createElementCallback(const v8::Arguments& args) { - ASSERT_ARGS1(args, IsString); - v8::String::AsciiValue tagName(args[0]); - - v8::Local<v8::Object> self = args.Holder(); - Document<std::string>* doc = V8DOM::toClassPtr<Document<std::string> >(self->GetInternalField(0)); - V8DOM* dom = V8DOM::toClassPtr<V8DOM>(self->GetInternalField(1)); (void)dom; - - Element<std::string>* element = new Element<std::string>(doc->createElement(*tagName)); - - v8::Handle<v8::Function> elemCtor = V8Element::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> elemObj = v8::Persistent<v8::Object>::New(elemCtor->NewInstance()); - - elemObj->SetInternalField(0, V8DOM::toExternal(element)); - elemObj->SetInternalField(1, self->GetInternalField(1)); - - elemObj.MakeWeak(0, V8Element::jsDestructor); - return elemObj; -} - -v8::Handle<v8::Value> V8Document::evaluateCallback(const v8::Arguments& args) { - ASSERT_ARGS1(args, IsString); - v8::String::AsciiValue xpathExpr(args[0]); - - v8::Local<v8::Object> self = args.Holder(); - Document<std::string>* doc = V8DOM::toClassPtr<Document<std::string> >(self->GetInternalField(0)); - V8DOM* dom = V8DOM::toClassPtr<V8DOM>(self->GetInternalField(1)); (void)dom; - - Node<std::string>* context; - if (args.Length() > 1) { - context = V8DOM::toClassPtr<Node<std::string> >(args[1]->ToObject()->GetInternalField(0)); - } else { - context = doc; - } - - XPathValue<std::string>* xpathValue = new XPathValue<std::string>(dom->xpath->evaluate(*xpathExpr, *context)); - - v8::Handle<v8::Function> xpathResultCtor = V8XPathResult::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> xpathResultObj = v8::Persistent<v8::Object>::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 <DOM/Element.hpp> - -namespace uscxml { - -using namespace Arabica::DOM; - -v8::Persistent<v8::FunctionTemplate> V8Element::Tmpl; - -v8::Handle<v8::Value> 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<v8::Object> self = args.Holder(); - Element<std::string>* elem = V8DOM::toClassPtr<Element<std::string> >(self->GetInternalField(0)); - V8DOM* dom = V8DOM::toClassPtr<V8DOM>(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<v8::Value> tagNameAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - - static v8::Handle<v8::Value> getAttributeCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> setAttributeCallback(const v8::Arguments& args); - static v8::Handle<v8::Value> removeAttributeCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> getAttributeNodeCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> setAttributeNodeCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> removeAttributeNodeCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> getElementsByTagNameCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> getAttributeNSCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> setAttributeNSCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> removeAttributeNSCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> getElementsByTagNameNSCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> getAttributeNodeNSCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> setAttributeNodeNSCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> hasAttributeCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> hasAttributeNSCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - - V8_DESTRUCTOR(Arabica::DOM::Element<std::string>); - - static v8::Persistent<v8::FunctionTemplate> Tmpl; - static v8::Handle<v8::FunctionTemplate> getTmpl() { - if (Tmpl.IsEmpty()) { - v8::Handle<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New(); - tmpl->SetClassName(v8::String::New("Element")); - tmpl->ReadOnlyPrototype(); - - v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); - v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); - instance->SetInternalFieldCount(2); - - instance->SetAccessor(v8::String::NewSymbol("tagName"), V8Element::tagNameAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - - prototype->Set(v8::String::NewSymbol("getAttribute"), - v8::FunctionTemplate::New(V8Element::getAttributeCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("setAttribute"), - v8::FunctionTemplate::New(V8Element::setAttributeCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("removeAttribute"), - v8::FunctionTemplate::New(V8Element::removeAttributeCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("getAttributeNode"), - v8::FunctionTemplate::New(V8Element::getAttributeNodeCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("setAttributeNode"), - v8::FunctionTemplate::New(V8Element::setAttributeNodeCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("removeAttributeNode"), - v8::FunctionTemplate::New(V8Element::removeAttributeNodeCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("getElementsByTagName"), - v8::FunctionTemplate::New(V8Element::getElementsByTagNameCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("getAttributeNS"), - v8::FunctionTemplate::New(V8Element::getAttributeNSCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("setAttributeNS"), - v8::FunctionTemplate::New(V8Element::setAttributeNSCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("removeAttributeNS"), - v8::FunctionTemplate::New(V8Element::removeAttributeNSCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("getElementsByTagNameNS"), - v8::FunctionTemplate::New(V8Element::getElementsByTagNameNSCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("getAttributeNodeNS"), - v8::FunctionTemplate::New(V8Element::getAttributeNodeNSCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("setAttributeNodeNS"), - v8::FunctionTemplate::New(V8Element::setAttributeNodeNSCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("hasAttribute"), - v8::FunctionTemplate::New(V8Element::hasAttributeCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("hasAttributeNS"), - v8::FunctionTemplate::New(V8Element::hasAttributeNSCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - - tmpl->Inherit(V8Node::getTmpl()); - Tmpl = v8::Persistent<v8::FunctionTemplate>::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 <DOM/Node.hpp> - -namespace uscxml { - -using namespace Arabica::DOM; - -v8::Persistent<v8::FunctionTemplate> V8Node::Tmpl; - -v8::Handle<v8::Value> V8Node::appendChildCallback(const v8::Arguments& args) { - assert(args.Length() == 1); - assert(args[0]->IsObject()); - - v8::Local<v8::Object> self = args.Holder(); - - Node<std::string>* node = V8DOM::toClassPtr<Node<std::string> >(self->GetInternalField(0)); - Node<std::string>* childToAppend = V8DOM::toClassPtr<Node<std::string> >(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<v8::Value> nodeNameAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> nodeValueAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> nodeTypeAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> parentNodeAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> childNodesAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> firstChildAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> lastChildAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> previousSiblingAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> nextSiblingAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> attributesAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> ownerDocumentAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> namespaceURIAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> prefixAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> localNameAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> baseURIAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> textContentAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> parentElementAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - - static void nodeValueAttrSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info) { } - static void prefixAttrSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info) { } - static void textContentAttrSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info) { } - - static v8::Handle<v8::Value> insertBeforeCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> replaceChildCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> removeChildCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> appendChildCallback(const v8::Arguments& args); - static v8::Handle<v8::Value> hasChildNodesCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> cloneNodeCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> normalizeCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> isSupportedCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> hasAttributesCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> lookupPrefixCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> isDefaultNamespaceCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> lookupNamespaceURICallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> addEventListenerCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> removeEventListenerCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - - V8_DESTRUCTOR(Arabica::DOM::Node<std::string>); - - static v8::Persistent<v8::FunctionTemplate> Tmpl; - static v8::Handle<v8::FunctionTemplate> getTmpl() { - if (Tmpl.IsEmpty()) { - v8::Handle<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New(); - tmpl->SetClassName(v8::String::New("Node")); - tmpl->ReadOnlyPrototype(); - - v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); - v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); - instance->SetInternalFieldCount(2); - - instance->SetAccessor(v8::String::NewSymbol("nodeName"), V8Node::nodeNameAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("nodeValue"), V8Node::nodeValueAttrGetter, V8Node::nodeValueAttrSetter, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("nodeType"), V8Node::nodeTypeAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("parentNode"), V8Node::parentNodeAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("childNodes"), V8Node::childNodesAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("firstChild"), V8Node::firstChildAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("lastChild"), V8Node::lastChildAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("previousSibling"), V8Node::previousSiblingAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("nextSibling"), V8Node::nextSiblingAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("attributes"), V8Node::attributesAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("ownerDocument"), V8Node::ownerDocumentAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("namespaceURI"), V8Node::namespaceURIAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("prefix"), V8Node::prefixAttrGetter, V8Node::prefixAttrSetter, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("localName"), V8Node::localNameAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("baseURI"), V8Node::baseURIAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("textContent"), V8Node::textContentAttrGetter, V8Node::textContentAttrSetter, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("parentElement"), V8Node::parentElementAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - - prototype->Set(v8::String::NewSymbol("insertBefore"), - v8::FunctionTemplate::New(V8Node::insertBeforeCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("replaceChild"), - v8::FunctionTemplate::New(V8Node::replaceChildCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("removeChild"), - v8::FunctionTemplate::New(V8Node::removeChildCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("appendChild"), - v8::FunctionTemplate::New(V8Node::appendChildCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("hasChildNodes"), - v8::FunctionTemplate::New(V8Node::hasChildNodesCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("cloneNode"), - v8::FunctionTemplate::New(V8Node::cloneNodeCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("normalize"), - v8::FunctionTemplate::New(V8Node::normalizeCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("isSupported"), - v8::FunctionTemplate::New(V8Node::isSupportedCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("hasAttributes"), - v8::FunctionTemplate::New(V8Node::hasAttributesCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("lookupPrefix"), - v8::FunctionTemplate::New(V8Node::lookupPrefixCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("isDefaultNamespace"), - v8::FunctionTemplate::New(V8Node::isDefaultNamespaceCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("lookupNamespaceURI"), - v8::FunctionTemplate::New(V8Node::lookupNamespaceURICallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("addEventListener"), - v8::FunctionTemplate::New(V8Node::addEventListenerCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("removeEventListener"), - v8::FunctionTemplate::New(V8Node::removeEventListenerCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(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<v8::FunctionTemplate>::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 <DOM/Node.hpp> - -namespace uscxml { - -using namespace Arabica::DOM; -using namespace Arabica::XPath; - -v8::Persistent<v8::FunctionTemplate> V8NodeSet::Tmpl; - - -v8::Handle<v8::Value> V8NodeSet::indexGetter(uint32_t index, const v8::AccessorInfo &info) { - v8::Local<v8::Object> self = info.Holder(); - - NodeSet<std::string>* nodeSet = V8DOM::toClassPtr<NodeSet<std::string> >(self->GetInternalField(0)); - V8DOM* dom = V8DOM::toClassPtr<V8DOM>(self->GetInternalField(1)); (void)dom; - - if (nodeSet->size() >= index) { - switch((*nodeSet)[index].getNodeType()) { - case Node_base::ELEMENT_NODE: { - v8::Handle<v8::Function> elementCtor = V8Element::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> elementObj = v8::Persistent<v8::Object>::New(elementCtor->NewInstance()); - - Element<std::string>* element = new Element<std::string>((*nodeSet)[index]); - - elementObj->SetInternalField(0, V8DOM::toExternal(element)); - elementObj->SetInternalField(1, self->GetInternalField(1)); - elementObj.MakeWeak(0, V8Element::jsDestructor); - return elementObj; - } - default: { - v8::Handle<v8::Function> nodeCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> nodeObj = v8::Persistent<v8::Object>::New(nodeCtor->NewInstance()); - - Node<std::string>* node = new Node<std::string>((*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<v8::Value> V8NodeSet::lengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - - V8DOM* dom = V8DOM::toClassPtr<V8DOM>(self->GetInternalField(1)); (void)dom; - NodeSet<std::string>* nodeSet = V8DOM::toClassPtr<NodeSet<std::string> >(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<v8::Value> indexGetter(uint32_t index, const v8::AccessorInfo &info); - static v8::Handle<v8::Value> indexSetter(uint32_t index, v8::Local<v8::Value> value, const v8::AccessorInfo &info) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> lengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - - V8_DESTRUCTOR(Arabica::XPath::NodeSet<std::string>); - - static v8::Persistent<v8::FunctionTemplate> Tmpl; - static v8::Handle<v8::FunctionTemplate> getTmpl() { - if (Tmpl.IsEmpty()) { - v8::Handle<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New(); - tmpl->SetClassName(v8::String::New("NodeSet")); - tmpl->ReadOnlyPrototype(); - - v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); - // v8::Local<v8::ObjectTemplate> 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::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - - Tmpl = v8::Persistent<v8::FunctionTemplate>::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<v8::FunctionTemplate> V8SCXMLEvent::Tmpl; -v8::Handle<v8::Value> V8SCXMLEvent::typeAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr<V8SCXMLEventPrivate >(self->GetInternalField(0)); - - return v8::Integer::New(privData->nativeObj->type); -} - v8::Handle<v8::Value> V8SCXMLEvent::nameAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { v8::Local<v8::Object> self = info.Holder(); struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr<V8SCXMLEventPrivate >(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<v8::Value>); - static v8::Handle<v8::Value> typeAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> typeCustomAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); static v8::Handle<v8::Value> nameAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); static v8::Handle<v8::Value> originAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); static v8::Handle<v8::Value> origintypeAttrGetter(v8::Local<v8::String> 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::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); instance->SetAccessor(v8::String::NewSymbol("name"), V8SCXMLEvent::nameAttrGetter, 0, v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(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<v8::Value> V8SCXMLEvent::typeCustomAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + V8SCXMLEvent::V8SCXMLEventPrivate* privData = V8DOM::toClassPtr<V8SCXMLEvent::V8SCXMLEventPrivate >(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<v8::FunctionTemplate> V8XPathResult::Tmpl; - -v8::Handle<v8::Value> V8XPathResult::asNodeSetCallback(const v8::Arguments& args) { - - v8::Local<v8::Object> self = args.Holder(); - XPathValue<std::string>* xpathValue = V8DOM::toClassPtr<XPathValue<std::string> >(self->GetInternalField(0)); - V8DOM* dom = V8DOM::toClassPtr<V8DOM>(self->GetInternalField(1)); (void)dom; - - v8::Handle<v8::Function> nodeSetCtor = V8NodeSet::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> nodeSetObj = v8::Persistent<v8::Object>::New(nodeSetCtor->NewInstance()); - - Arabica::XPath::NodeSet<std::string>* nodeSet = new Arabica::XPath::NodeSet<std::string>(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<v8::Value> resultTypeAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> numberValueAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> stringValueAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> booleanValueAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> singleNodeAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> invalidIteratorStateAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> snapshotLengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } - - static v8::Handle<v8::Value> iterateNextCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> snapshotItemCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - - static v8::Handle<v8::Value> asNodeSetCallback(const v8::Arguments& args); - static v8::Handle<v8::Value> asBoolCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> asStringCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - static v8::Handle<v8::Value> asNumberCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } - - V8_DESTRUCTOR(Arabica::XPath::XPathValue<std::string>); - - static v8::Persistent<v8::FunctionTemplate> Tmpl; - static v8::Handle<v8::FunctionTemplate> getTmpl() { - if (Tmpl.IsEmpty()) { - v8::Handle<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New(); - tmpl->SetClassName(v8::String::New("XPathResult")); - tmpl->ReadOnlyPrototype(); - - v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); - v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); - instance->SetInternalFieldCount(2); - - instance->SetAccessor(v8::String::NewSymbol("resultType"), V8XPathResult::resultTypeAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("numberValue"), V8XPathResult::numberValueAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("stringValue"), V8XPathResult::stringValueAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("booleanValue"), V8XPathResult::booleanValueAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("singleNode"), V8XPathResult::singleNodeAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("invalidIteratorState"), V8XPathResult::invalidIteratorStateAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("snapshotLength"), V8XPathResult::snapshotLengthAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - - prototype->Set(v8::String::NewSymbol("iterateNext"), - v8::FunctionTemplate::New(V8XPathResult::iterateNextCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("snapshotItem"), - v8::FunctionTemplate::New(V8XPathResult::snapshotItemCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("asNodeSet"), - v8::FunctionTemplate::New(V8XPathResult::asNodeSetCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("asBool"), - v8::FunctionTemplate::New(V8XPathResult::asBoolCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("asString"), - v8::FunctionTemplate::New(V8XPathResult::asStringCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("asNumber"), - v8::FunctionTemplate::New(V8XPathResult::asNumberCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - - Tmpl = v8::Persistent<v8::FunctionTemplate>::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(); } } |