diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-01-10 22:42:42 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-01-10 22:42:42 (GMT) |
commit | 7aa7095d17a180d663cd9647c31d99d97c1dca4f (patch) | |
tree | 460bc3a67f0adc3199bec9f22ee15a102263eb4c /src/uscxml/plugins | |
parent | da1032ffbff229ce2ca9a83d47522ff45c90ba23 (diff) | |
download | uscxml-7aa7095d17a180d663cd9647c31d99d97c1dca4f.zip uscxml-7aa7095d17a180d663cd9647c31d99d97c1dca4f.tar.gz uscxml-7aa7095d17a180d663cd9647c31d99d97c1dca4f.tar.bz2 |
Major changes - see details
- Dynamic SceneGraph ML
- V8 DOM for ecmascript datamodel
- New heartbeat invoker
- Fixed various bugs
Diffstat (limited to 'src/uscxml/plugins')
23 files changed, 1039 insertions, 338 deletions
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp index 6073e26..3bdf28c 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp @@ -1,6 +1,7 @@ #include "uscxml/Common.h" #include "V8DataModel.h" -#include "dom/V8SCXMLDOM.h" +#include "dom/V8DOM.h" +#include "dom/V8Document.h" #include "uscxml/Message.h" #include <glog/logging.h> @@ -28,16 +29,32 @@ DataModel* V8DataModel::create(Interpreter* interpreter) { v8::Locker locker; v8::HandleScope scope; + V8DOM* dom = new V8DOM(); + dom->interpreter = interpreter; + dom->xpath = new Arabica::XPath::XPath<std::string>(); + dom->xpath->setNamespaceContext(interpreter->getNSContext()); + // see http://stackoverflow.com/questions/3171418/v8-functiontemplate-class-instance -// dm->_globalTemplate = v8::Persistent<v8::ObjectTemplate>(v8::ObjectTemplate::New()); -// dm->_globalTemplate->Set(v8::String::New("In"), v8::FunctionTemplate::New(jsIn, v8::External::New(reinterpret_cast<void*>(this)))); + // some free functions v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(); - global->Set(v8::String::New("In"), v8::FunctionTemplate::New(jsIn, v8::External::New(reinterpret_cast<void*>(dm)))); - global->Set(v8::String::New("print"), v8::FunctionTemplate::New(jsPrint, v8::External::New(reinterpret_cast<void*>(dm)))); - global->Set(v8::String::New("document"), V8SCXMLDOM::getDocument(interpreter->getDocument())); - - dm->_contexts.push_back(v8::Context::New(NULL, global)); + global->Set(v8::String::New("In"), v8::FunctionTemplate::New(jsIn, v8::External::New(reinterpret_cast<void*>(dm))), v8::ReadOnly); + global->Set(v8::String::New("print"), v8::FunctionTemplate::New(jsPrint, v8::External::New(reinterpret_cast<void*>(dm))), v8::ReadOnly); + + v8::Persistent<v8::Context> context = v8::Context::New(0, global); + v8::Context::Scope contextScope(context); + + // instantiate the document function + v8::Handle<v8::Function> docCtor = V8Document::getTmpl()->GetFunction(); + v8::Handle<v8::Object> docObj = docCtor->NewInstance(); + docObj->SetInternalField(0, V8DOM::toExternal(&(interpreter->getDocument()))); + docObj->SetInternalField(1, V8DOM::toExternal(dom)); + context->Global()->Set(v8::String::New("document"), docObj); + + dm->_contexts.push_back(context); + + // instantiate objects - we have to have a context for that! + dm->setName(interpreter->getName()); dm->setSessionId(interpreter->getSessionId()); dm->eval("_ioprocessors = {};"); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.cpp new file mode 100644 index 0000000..d1aa301 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.cpp @@ -0,0 +1,9 @@ +#include "V8DOM.h" + +namespace uscxml { + +V8DOM::V8DOM() { + +} + +}
\ No newline at end of file diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h new file mode 100644 index 0000000..9fbe0e4 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h @@ -0,0 +1,53 @@ +#ifndef V8DOM_H_LKE1HKJK +#define V8DOM_H_LKE1HKJK + +#include "uscxml/Interpreter.h" +#include <v8.h> + +#define V8_DESTRUCTOR(type) \ +static void jsDestructor(v8::Persistent<v8::Value> object, void* data) { \ +v8::HandleScope handleScope; \ +type* thing = static_cast<type*>(v8::Local<v8::External>::Cast(object->ToObject()->GetInternalField(0))->Value()); \ +delete thing; \ +object.Dispose(); \ +object.Clear(); \ +} + +#define ASSERT_ARGS1(args, type1) \ +assert(args.Length() == 1); \ +assert(args[0]->type1()); + +#define ASSERT_ARGS2(args, type1, type2) \ +assert(args.Length() == 2); \ +assert(args[0]->type1()); \ +assert(args[1]->type2()); + +namespace uscxml { + +class V8DOM { +public: + V8DOM(); + virtual ~V8DOM() { }; + + template <typename T> + static T* toClassPtr(v8::Local<v8::Value> data) { + if(data.IsEmpty()) + return NULL; + else if(!data->IsExternal()) + return NULL; + else + return static_cast<T *>(v8::External::Unwrap(data)); + return NULL; + } + static v8::Local<v8::External> toExternal(void* pointer) { + v8::HandleScope scope; + return scope.Close(v8::External::New(pointer)); + } + + Interpreter* interpreter; + Arabica::XPath::XPath<std::string>* xpath; +}; + +} + +#endif /* end of include guard: V8DOM_H_LKE1HKJK */ diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.cpp new file mode 100644 index 0000000..31372ed --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.cpp @@ -0,0 +1,59 @@ +#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/V8Document.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.h new file mode 100644 index 0000000..680c433 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.h @@ -0,0 +1,104 @@ +#ifndef V8DOCUMENT_H_COKK9O3L +#define V8DOCUMENT_H_COKK9O3L + +#include "V8DOM.h" +#include "V8Node.h" + +namespace uscxml { + + class V8Document { + public: + static v8::Handle<v8::Value> doctypeAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } + static v8::Handle<v8::Value> implementationAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } + static v8::Handle<v8::Value> documentElementAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { assert(false); return v8::Undefined(); } + + static v8::Handle<v8::Value> createElementCallback(const v8::Arguments& args); + static v8::Handle<v8::Value> createDocumentFragmentCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } + static v8::Handle<v8::Value> createTextNodeCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } + static v8::Handle<v8::Value> createCommentCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } + static v8::Handle<v8::Value> createCDATASectionCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } + static v8::Handle<v8::Value> createProcessingInstructionCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } + static v8::Handle<v8::Value> createAttributeCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } + static v8::Handle<v8::Value> createEntityReferenceCallback(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> importNodeCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } + static v8::Handle<v8::Value> createElementNSCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } + static v8::Handle<v8::Value> createAttributeNSCallback(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> getElementByIdCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } + + static v8::Handle<v8::Value> createEventCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } + + static v8::Handle<v8::Value> createExpressionCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } + static v8::Handle<v8::Value> createNSResolverCallback(const v8::Arguments& args) { assert(false); return v8::Undefined(); } + static v8::Handle<v8::Value> evaluateCallback(const v8::Arguments& args); + + V8_DESTRUCTOR(Arabica::DOM::Document<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("Document")); + tmpl->ReadOnlyPrototype(); + + v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); + v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); + instance->SetInternalFieldCount(2); + + instance->SetAccessor(v8::String::NewSymbol("doctype"), V8Document::doctypeAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("implementation"), V8Document::implementationAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("documentElement"), V8Document::documentElementAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + + prototype->Set(v8::String::NewSymbol("createElement"), + v8::FunctionTemplate::New(V8Document::createElementCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("createDocumentFragment"), + v8::FunctionTemplate::New(V8Document::createDocumentFragmentCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("createTextNode"), + v8::FunctionTemplate::New(V8Document::createTextNodeCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("createComment"), + v8::FunctionTemplate::New(V8Document::createCommentCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("createCDATASection"), + v8::FunctionTemplate::New(V8Document::createCDATASectionCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("createProcessingInstruction"), + v8::FunctionTemplate::New(V8Document::createProcessingInstructionCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("createAttribute"), + v8::FunctionTemplate::New(V8Document::createAttributeCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("createEntityReference"), + v8::FunctionTemplate::New(V8Document::createEntityReferenceCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("getElementsByTagName"), + v8::FunctionTemplate::New(V8Document::getElementsByTagNameCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("importNode"), + v8::FunctionTemplate::New(V8Document::importNodeCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("createElementNS"), + v8::FunctionTemplate::New(V8Document::createElementNSCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("createAttributeNS"), + v8::FunctionTemplate::New(V8Document::createAttributeNSCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("getElementsByTagNameNS"), + v8::FunctionTemplate::New(V8Document::getElementsByTagNameNSCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("getElementById"), + v8::FunctionTemplate::New(V8Document::getElementByIdCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("createEvent"), + v8::FunctionTemplate::New(V8Document::createEventCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("createExpression"), + v8::FunctionTemplate::New(V8Document::createExpressionCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("createNSResolver"), + v8::FunctionTemplate::New(V8Document::createNSResolverCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("evaluate"), + v8::FunctionTemplate::New(V8Document::evaluateCallback, 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: V8DOCUMENT_H_COKK9O3L */ diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.cpp new file mode 100644 index 0000000..14b2eae --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.cpp @@ -0,0 +1,24 @@ +#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 b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.h new file mode 100644 index 0000000..f610108 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.h @@ -0,0 +1,87 @@ +#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 b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.cpp new file mode 100644 index 0000000..97a8c1a --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.cpp @@ -0,0 +1,23 @@ +#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 b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.h new file mode 100644 index 0000000..7048ab5 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.h @@ -0,0 +1,161 @@ +#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 b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.cpp new file mode 100644 index 0000000..cadcf7f --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.cpp @@ -0,0 +1,60 @@ +#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 b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.h new file mode 100644 index 0000000..cb95a5d --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.h @@ -0,0 +1,41 @@ +#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/V8SCXMLDOM.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLDOM.cpp deleted file mode 100644 index 585bdd7..0000000 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLDOM.cpp +++ /dev/null @@ -1,219 +0,0 @@ -#ifdef _WIN32 -#include <winsock2.h> -#include <windows.h> -#endif -#include "V8SCXMLDOM.h" - -#define ASSERT_ARGS1(args, type1) \ -assert(args.Length() == 1); \ -assert(args[0]->type1()); - -#define ASSERT_ARGS2(args, type1, type2) \ -assert(args.Length() == 2); \ -assert(args[0]->type1()); \ -assert(args[1]->type2()); - -namespace uscxml { - -using namespace Arabica::DOM; -using namespace Arabica::XPath; - -V8SCXMLDOM::V8SCXMLDOM() { -} - -v8::Handle<v8::ObjectTemplate> V8SCXMLDOM::getDocument(Arabica::DOM::Document<std::string>& document) { - v8::Handle<v8::ObjectTemplate> documentTmpl = v8::ObjectTemplate::New(); - documentTmpl->Set(v8::String::New("createElement"), v8::FunctionTemplate::New(jsDocumentCreateElement, v8::External::New(reinterpret_cast<void*>(&document)))); - documentTmpl->Set(v8::String::New("evaluate"), v8::FunctionTemplate::New(jsDocumentEvaluate, v8::External::New(reinterpret_cast<void*>(&document)))); - return documentTmpl; -} - -v8::Handle<v8::Value> V8SCXMLDOM::jsDocumentCreateElement(const v8::Arguments& args) { - assert(!args.Data().IsEmpty()); - assert(args.Data()->IsExternal()); - - ASSERT_ARGS1(args, IsString) - - Document<std::string>* document = static_cast<Document<std::string>*>(v8::External::Unwrap(args.Data())); - v8::Persistent<v8::Object> elementJS = v8::Persistent<v8::Object>::New(getElementTmpl()->NewInstance()); - - v8::String::AsciiValue tagName(args[0]); - Element<std::string>* element = new Element<std::string>(document->createElement(*tagName)); - - elementJS->SetInternalField(0, v8::External::New(element)); - elementJS.MakeWeak(NULL, jsElementDestructor); - return elementJS; -} - -v8::Handle<v8::Value> V8SCXMLDOM::jsDocumentEvaluate(const v8::Arguments& args) { - assert(!args.Data().IsEmpty()); - assert(args.Data()->IsExternal()); - - assert(args.Length() > 0); - assert(args[0]->IsString()); - - - Document<std::string>* document = static_cast<Document<std::string>*>(v8::External::Unwrap(args.Data())); - Node<std::string> context; - if (args.Length() > 1) { - assert(args[1]->ToObject()->InternalFieldCount() == 1); - context = *static_cast<Node<std::string>*>(v8::Local<v8::External>::Cast(args[1]->ToObject()->GetInternalField(0))->Value()); - } else { - context = *document; - } - v8::String::AsciiValue xpathExpr(args[0]); - XPath<std::string> xpath; - XPathValue<std::string>* xpathValue = new XPathValue<std::string>(xpath.evaluate(*xpathExpr, context)); - - v8::Persistent<v8::Object> xpathValueJS = v8::Persistent<v8::Object>::New(getXPathValueTmpl()->NewInstance()); - xpathValueJS->SetInternalField(0, v8::External::New(xpathValue)); - xpathValueJS.MakeWeak(NULL, jsXPathValueDestructor); - return xpathValueJS; -} - -v8::Handle<v8::Value> V8SCXMLDOM::jsElementTagName(v8::Local<v8::String> property, const v8::AccessorInfo &info) { - Element<std::string>* element = static_cast<Element<std::string>*>(v8::Local<v8::External>::Cast(info.Holder()->GetInternalField(0))->Value()); - return v8::String::New(element->getTagName().c_str()); -} - -v8::Handle<v8::Value> V8SCXMLDOM::jsElementGetAttribute(const v8::Arguments& args) { - assert(!args.Data().IsEmpty()); - assert(args.Data()->IsExternal()); - - ASSERT_ARGS1(args, IsString); - - Element<std::string>* element = static_cast<Element<std::string>*>(v8::External::Unwrap(args.Data())); - - v8::String::AsciiValue attribute(args[0]); - if (element->hasAttribute(*attribute)) { - return v8::String::New(element->getAttribute(*attribute).c_str()); - } - return v8::String::New(""); -} - -v8::Handle<v8::Value> V8SCXMLDOM::jsElementSetAttribute(const v8::Arguments& args) { - v8::Local<v8::Object> self = args.Holder(); - assert(self->InternalFieldCount() == 1); - - ASSERT_ARGS2(args, IsString, IsString); - - v8::String::AsciiValue attribute(args[0]); - v8::String::AsciiValue value(args[1]); - - Element<std::string>* element = static_cast<Element<std::string>*>(v8::External::Unwrap(self->GetInternalField(0))); - element->setAttribute(*attribute, *value); - return v8::Undefined(); -} - -v8::Handle<v8::Value> V8SCXMLDOM::jsXPathValueAsNodeSet(const v8::Arguments& args) { - v8::Local<v8::Object> self = args.Holder(); - assert(self->InternalFieldCount() == 1); - XPathValue<std::string>* xPathValue = static_cast<XPathValue<std::string>*>(v8::External::Unwrap(self->GetInternalField(0))); - - v8::Persistent<v8::Object> nodeSetJS = v8::Persistent<v8::Object>::New(getNodeSetTmpl()->NewInstance()); - nodeSetJS->SetInternalField(0, v8::External::New(new NodeSet<std::string>(xPathValue->asNodeSet()))); - nodeSetJS.MakeWeak(NULL, jsNodeSetDestructor); - return nodeSetJS; - -} - -void V8SCXMLDOM::jsNodeSetDestructor(v8::Persistent<v8::Value> object, void* data) { - NodeSet<std::string>* nodeSet = static_cast<NodeSet<std::string>*>(v8::Local<v8::External>::Cast(object->ToObject()->GetInternalField(0))->Value()); - delete nodeSet; -} - -void V8SCXMLDOM::jsNodeDestructor(v8::Persistent<v8::Value> object, void* data) { - Node<std::string>* node = static_cast<Node<std::string>*>(v8::Local<v8::External>::Cast(object->ToObject()->GetInternalField(0))->Value()); - delete node; -} - -void V8SCXMLDOM::jsXPathValueDestructor(v8::Persistent<v8::Value> object, void* data) { - XPathValue<std::string>* xPathValue = static_cast<XPathValue<std::string>*>(v8::Local<v8::External>::Cast(object->ToObject()->GetInternalField(0))->Value()); - delete xPathValue; -} - -void V8SCXMLDOM::jsElementDestructor(v8::Persistent<v8::Value> object, void* data) { - Element<std::string>* element = static_cast<Element<std::string>*>(v8::Local<v8::External>::Cast(object->ToObject()->GetInternalField(0))->Value()); - delete element; -} - -v8::Handle<v8::Value> V8SCXMLDOM::jsNodeSetGetIndex(uint32_t index, const v8::AccessorInfo &info) { - v8::Local<v8::Object> self = info.Holder(); - assert(self->InternalFieldCount() == 1); - NodeSet<std::string>* nodeSet = static_cast<NodeSet<std::string>*>(v8::Local<v8::External>::Cast(info.Holder()->GetInternalField(0))->Value()); - - if (nodeSet->size() >= index) { - Node<std::string>* node = new Node<std::string>((*nodeSet)[index]); - v8::Persistent<v8::Object> nodeJS = v8::Persistent<v8::Object>::New(getNodeTmpl()->NewInstance()); - nodeJS->SetInternalField(0, v8::External::New(node)); - nodeJS.MakeWeak(NULL, jsNodeDestructor); - return nodeJS; - } - return v8::Undefined(); -} - -v8::Handle<v8::Value> V8SCXMLDOM::jsNodeSetLength(const v8::Arguments& args) { - v8::Local<v8::Object> self = args.Holder(); - assert(self->InternalFieldCount() == 1); - NodeSet<std::string>* nodeSet = static_cast<NodeSet<std::string>*>(v8::External::Unwrap(self->GetInternalField(0))); - return v8::Integer::New(nodeSet->size()); -} - -v8::Handle<v8::Value> V8SCXMLDOM::jsNodeAppendChild(const v8::Arguments& args) { - v8::Local<v8::Object> self = args.Holder(); - assert(self->InternalFieldCount() == 1); - Node<std::string>* node = static_cast<Node<std::string>*>(v8::External::Unwrap(self->GetInternalField(0))); - - assert(args.Length() == 1); - assert(args[0]->IsObject()); - - Node<std::string>* childToAppend = static_cast<Node<std::string>*>(v8::External::Unwrap(args[0]->ToObject()->GetInternalField(0))); - node->appendChild(*childToAppend); - - return v8::Undefined(); -} - -v8::Handle<v8::ObjectTemplate> V8SCXMLDOM::xPathValueTmpl; -v8::Handle<v8::ObjectTemplate> V8SCXMLDOM::getXPathValueTmpl() { - if (xPathValueTmpl.IsEmpty()) { - xPathValueTmpl = v8::ObjectTemplate::New(); - xPathValueTmpl->SetInternalFieldCount(1); - xPathValueTmpl->Set(v8::String::New("asNodeSet"), v8::FunctionTemplate::New(jsXPathValueAsNodeSet)); - } - return xPathValueTmpl; -} - -v8::Handle<v8::ObjectTemplate> V8SCXMLDOM::nodeSetTmpl; -v8::Handle<v8::ObjectTemplate> V8SCXMLDOM::getNodeSetTmpl() { - if (nodeSetTmpl.IsEmpty()) { - nodeSetTmpl = v8::ObjectTemplate::New(); - nodeSetTmpl->SetInternalFieldCount(1); - nodeSetTmpl->SetIndexedPropertyHandler(jsNodeSetGetIndex); - nodeSetTmpl->Set(v8::String::New("length"), v8::FunctionTemplate::New(jsNodeSetLength)); - } - return nodeSetTmpl; -} - -v8::Handle<v8::ObjectTemplate> V8SCXMLDOM::nodeTmpl; -v8::Handle<v8::ObjectTemplate> V8SCXMLDOM::getNodeTmpl() { - if (nodeTmpl.IsEmpty()) { - nodeTmpl = v8::ObjectTemplate::New(); - nodeTmpl->SetInternalFieldCount(1); - nodeTmpl->Set(v8::String::New("appendChild"), v8::FunctionTemplate::New(jsNodeAppendChild)); - } - return nodeTmpl; -} - -v8::Handle<v8::ObjectTemplate> V8SCXMLDOM::elementTmpl; -v8::Handle<v8::ObjectTemplate> V8SCXMLDOM::getElementTmpl() { - if (elementTmpl.IsEmpty()) { - elementTmpl = v8::ObjectTemplate::New(); - elementTmpl->SetAccessor(v8::String::New("tagName"), V8SCXMLDOM::jsElementTagName); - elementTmpl->Set(v8::String::New("getAttribute"), v8::FunctionTemplate::New(jsElementGetAttribute)); - elementTmpl->Set(v8::String::New("setAttribute"), v8::FunctionTemplate::New(jsElementSetAttribute)); - elementTmpl->SetInternalFieldCount(1); - } - return elementTmpl; -} - -}
\ No newline at end of file diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLDOM.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLDOM.h deleted file mode 100644 index 36c6b15..0000000 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLDOM.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef V8SCXMLDOM_H_AREM0ZC4 -#define V8SCXMLDOM_H_AREM0ZC4 - -#include "uscxml/Interpreter.h" - -#include <DOM/Document.hpp> -#include <v8.h> - -#include <list> - -namespace uscxml { - -class V8SCXMLDOM { -public: - V8SCXMLDOM(); - virtual ~V8SCXMLDOM() {}; - - static v8::Handle<v8::ObjectTemplate> getDocument(Arabica::DOM::Document<std::string>& document); - static v8::Handle<v8::Value> jsDocumentCreateElement(const v8::Arguments& args); - static v8::Handle<v8::Value> jsDocumentEvaluate(const v8::Arguments& args); - - static v8::Handle<v8::Value> jsElementTagName(v8::Local<v8::String> property, const v8::AccessorInfo &info); - static v8::Handle<v8::Value> jsElementGetAttribute(const v8::Arguments& args); - static v8::Handle<v8::Value> jsElementSetAttribute(const v8::Arguments& args); - static void jsElementDestructor(v8::Persistent<v8::Value> object, void* data); - - static v8::Handle<v8::Value> jsXPathValueAsNodeSet(const v8::Arguments& args); - static void jsXPathValueDestructor(v8::Persistent<v8::Value> object, void* data); - - static v8::Handle<v8::Value> jsNodeSetGetIndex(uint32_t index, const v8::AccessorInfo &info); - static v8::Handle<v8::Value> jsNodeSetLength(const v8::Arguments& args); - static void jsNodeSetDestructor(v8::Persistent<v8::Value> object, void* data); - - static v8::Handle<v8::Value> jsNodeAppendChild(const v8::Arguments& args); - static void jsNodeDestructor(v8::Persistent<v8::Value> object, void* data); - - static v8::Handle<v8::ObjectTemplate> getXPathValueTmpl(); - static v8::Handle<v8::ObjectTemplate> getNodeSetTmpl(); - static v8::Handle<v8::ObjectTemplate> getNodeTmpl(); - static v8::Handle<v8::ObjectTemplate> getElementTmpl(); - - static v8::Handle<v8::ObjectTemplate> xPathValueTmpl; - static v8::Handle<v8::ObjectTemplate> nodeSetTmpl; - static v8::Handle<v8::ObjectTemplate> nodeTmpl; - static v8::Handle<v8::ObjectTemplate> elementTmpl; - -}; - -class V8Node { -}; - -class V8DOMDocument { - V8DOMDocument(); - virtual ~V8DOMDocument(); - - v8::Handle<v8::Array> jsChildNodes(); -}; - -} - -#endif /* end of include guard: V8SCXMLDOM_H_AREM0ZC4 */ diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.cpp new file mode 100644 index 0000000..04bfcbe --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.cpp @@ -0,0 +1,30 @@ +#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 b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.h new file mode 100644 index 0000000..ce5e2d5 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.h @@ -0,0 +1,75 @@ +#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/invoker/graphics/openscenegraph/OSGInvoker.cpp b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp index 2712be3..7a0e63a 100644 --- a/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp +++ b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp @@ -45,6 +45,13 @@ void OSGInvoker::sendToParent(SendRequest& req) { void OSGInvoker::invoke(InvokeRequest& req) { tthread::lock_guard<tthread::recursive_mutex> lock(_mutex); + // register default event handlers + Arabica::DOM::Events::EventTarget<std::string> evTarget = Arabica::DOM::Events::EventTarget<std::string>(req.dom); + evTarget.addEventListener("DOMSubtreeModified", *this, false); + evTarget.addEventListener("DOMNodeInserted", *this, false); + evTarget.addEventListener("DOMNodeRemoved", *this, false); + evTarget.addEventListener("DOMAttrModified", *this, false); + Arabica::XPath::NodeSet<std::string> content = Interpreter::filterChildElements("content", req.dom); std::set<std::string> validChilds; @@ -62,7 +69,19 @@ void OSGInvoker::runOnMainThread() { _mutex.unlock(); } } - + +void OSGInvoker::handleEvent(Arabica::DOM::Events::Event<std::string>& event) { +// std::cout << "Handling Event!" << std::endl; + Arabica::DOM::Node<std::string> node(event.getTarget()); + if (_nodes.find(node) != _nodes.end()) { + osg::Node* osgNode = _nodes[node]; + if (false) { + } else if (boost::iequals(LOCALNAME(node), "rotation")) { + updateRotation(osgNode, event); + } + } +} + void OSGInvoker::processDisplay(const Arabica::DOM::Node<std::string>& element) { // std::cout << element << std::endl; @@ -108,13 +127,17 @@ void OSGInvoker::processViewport(const Arabica::DOM::Node<std::string>& element) compDisp->addView(name, viewPort, sceneView); std::set<std::string> validChilds; + validChilds.insert("camera"); validChilds.insert("translation"); validChilds.insert("rotation"); validChilds.insert("scale"); validChilds.insert("node"); - processChildren(validChilds, element); + processChildren(validChilds, element); } +void OSGInvoker::processCamera(const Arabica::DOM::Node<std::string>& element) {} +void OSGInvoker::updateCamera(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event) {} + void OSGInvoker::processTranslation(const Arabica::DOM::Node<std::string>& element) { assert(_nodes.find(element.getParentNode()) != _nodes.end()); osg::Node* node = _nodes[element.getParentNode()]; @@ -146,7 +169,31 @@ void OSGInvoker::processTranslation(const Arabica::DOM::Node<std::string>& eleme void OSGInvoker::processRotation(const Arabica::DOM::Node<std::string>& element) { assert(_nodes.find(element.getParentNode()) != _nodes.end()); osg::Node* node = _nodes[element.getParentNode()]; - + + osg::Matrix rotation = rotationFromElement(element); + osg::MatrixTransform* transform = new osg::MatrixTransform(); + transform->setMatrix(rotation); + node->asGroup()->addChild(transform); + _nodes[element] = transform; + + std::set<std::string> validChilds; + validChilds.insert("translation"); + validChilds.insert("rotation"); + validChilds.insert("scale"); + validChilds.insert("node"); + processChildren(validChilds, element); +} + +void OSGInvoker::updateRotation(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event) { + osg::MatrixTransform* transform = static_cast<osg::MatrixTransform*>(node); + if (false) { + } else if (boost::iequals(event.getType(), "DOMAttrModified")) { + osg::Matrix rotation = rotationFromElement(Arabica::DOM::Node<std::string>(event.getTarget())); + transform->setMatrix(rotation); + } +} + +osg::Matrix OSGInvoker::rotationFromElement(const Arabica::DOM::Node<std::string>& element) { double pitch = 0, roll = 0, yaw = 0; if (HAS_ATTR(element, "pitch")) { NumAttr pitchAttr = NumAttr(ATTR(element, "pitch")); @@ -178,24 +225,13 @@ void OSGInvoker::processRotation(const Arabica::DOM::Node<std::string>& element) yaw = strTo<float>(yawAttr.value); } } - + osg::Matrix rotation; rotation.makeRotate(roll, osg::Vec3(0,1,0), // roll pitch, osg::Vec3(1,0,0) , // pitch yaw, osg::Vec3(0,0,1) ); // heading - - osg::MatrixTransform* transform = new osg::MatrixTransform(); - transform->setMatrix(rotation); - node->asGroup()->addChild(transform); - _nodes[element] = transform; - - std::set<std::string> validChilds; - validChilds.insert("translation"); - validChilds.insert("rotation"); - validChilds.insert("scale"); - validChilds.insert("node"); - processChildren(validChilds, element); + return rotation; } void OSGInvoker::processScale(const Arabica::DOM::Node<std::string>& element) { @@ -227,6 +263,9 @@ void OSGInvoker::processScale(const Arabica::DOM::Node<std::string>& element) { } void OSGInvoker::processNode(const Arabica::DOM::Node<std::string>& element) { + _nodes_t::iterator nodeIter = _nodes.find(element.getParentNode()); + assert(nodeIter != _nodes.end()); + assert(_nodes.find(element.getParentNode()) != _nodes.end()); osg::Node* parent = _nodes[element.getParentNode()]; @@ -276,6 +315,9 @@ void OSGInvoker::processChildren(const std::set<std::string>& validChildren, con } else if (boost::iequals(LOCALNAME(childs.item(i)), "viewport") && validChildren.find("viewport") != validChildren.end()) { processViewport(childs.item(i)); + } else if (boost::iequals(LOCALNAME(childs.item(i)), "camera") && + validChildren.find("camera") != validChildren.end()) { + processCamera(childs.item(i)); } else if (boost::iequals(LOCALNAME(childs.item(i)), "display") && validChildren.find("display") != validChildren.end()) { processDisplay(childs.item(i)); diff --git a/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.h b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.h index cf1556e..90dda31 100644 --- a/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.h +++ b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.h @@ -2,6 +2,9 @@ #define OSGINVOKER_H_H6T4R8HU #include <uscxml/Interpreter.h> +#include <DOM/Events/MutationEvent.hpp> +#include <DOM/Events/EventListener.hpp> +#include <DOM/Events/Event.hpp> #include "CompositeDisplay.h" #include <osg/MatrixTransform> #include <osgDB/ReadFile> @@ -13,7 +16,7 @@ namespace uscxml { -class OSGInvoker : public Invoker { +class OSGInvoker : public Invoker, public Arabica::DOM::Events::EventListener<std::string> { public: OSGInvoker(); virtual ~OSGInvoker(); @@ -32,16 +35,30 @@ public: virtual void cancel(const std::string sendId); virtual void invoke(InvokeRequest& req); virtual void sendToParent(SendRequest& req); + virtual void handleEvent(Arabica::DOM::Events::Event<std::string>& event); virtual void runOnMainThread(); protected: void processDisplay(const Arabica::DOM::Node<std::string>& element); + void updateDisplay(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event); void processViewport(const Arabica::DOM::Node<std::string>& element); + void updateViewport(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event); + void processCamera(const Arabica::DOM::Node<std::string>& element); + void updateCamera(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event); + void processTranslation(const Arabica::DOM::Node<std::string>& element); + void updateTranslation(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event); + void processRotation(const Arabica::DOM::Node<std::string>& element); + void updateRotation(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event); + static osg::Matrix rotationFromElement(const Arabica::DOM::Node<std::string>& element); + void processScale(const Arabica::DOM::Node<std::string>& element); + void updateScale(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event); void processNode(const Arabica::DOM::Node<std::string>& element); + void updateNode(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event); + void processChildren(const std::set<std::string>& validChildren, const Arabica::DOM::Node<std::string>& element); void getViewport(const Arabica::DOM::Node<std::string>& element, diff --git a/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp b/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp new file mode 100644 index 0000000..6bc06d9 --- /dev/null +++ b/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp @@ -0,0 +1,95 @@ +#include "HeartbeatInvoker.h" +#include <glog/logging.h> + +#ifdef BUILD_AS_PLUGINS +#include <Pluma/Connector.hpp> +#endif + +namespace uscxml { + +#ifdef BUILD_AS_PLUGINS +PLUMA_CONNECTOR +bool connect(pluma::Host& host) { + host.add( new HeartbeatInvokerProvider() ); + return true; +} +#endif + +HeartbeatInvoker::HeartbeatInvoker() { +} + +HeartbeatInvoker::~HeartbeatInvoker() { +}; + +Invoker* HeartbeatInvoker::create(Interpreter* interpreter) { + HeartbeatInvoker* invoker = new HeartbeatInvoker(); + invoker->_interpreter = interpreter; + return invoker; +} + +Data HeartbeatInvoker::getDataModelVariables() { + Data data; + return data; +} + +void HeartbeatInvoker::send(SendRequest& req) { +} + +void HeartbeatInvoker::cancel(const std::string sendId) { + HeartbeatDispatcher::getInstance()->cancelEvent(toStr(this)); +} + +void HeartbeatInvoker::sendToParent(SendRequest& req) { +} + +void HeartbeatInvoker::invoke(InvokeRequest& req) { + _invokeId = req.invokeid; + _event.invokeid = _invokeId; + std::string intervalStr; + double interval = 0; + unsigned long intervalMs = 0; + InvokeRequest::params_t::iterator paramIter = req.params.begin(); + while(paramIter != req.params.end()) { + if (boost::iequals(paramIter->first, "interval")) { + intervalStr = paramIter->second; + NumAttr intervalAttr(paramIter->second); + interval = strTo<double>(intervalAttr.value); + if (false) { + } else if (boost::iequals(intervalAttr.unit, "s")) { + intervalMs = interval * 1000; + } else if (boost::iequals(intervalAttr.unit, "ms")) { + intervalMs = interval; + } else { + intervalMs = interval; + } + } + if (boost::iequals(paramIter->first, "eventname")) { + _event.name = paramIter->second; + } + paramIter++; + } + if (_event.name.length() == 0) + _event.name = std::string("heartbeat." + intervalStr); + + if (intervalMs > 0) { + HeartbeatDispatcher::getInstance()->addEvent(toStr(this), HeartbeatInvoker::dispatch, intervalMs, this, true); + } +} + +void HeartbeatInvoker::dispatch(void* instance, std::string name) { + HeartbeatInvoker* invoker = (HeartbeatInvoker*)instance; + invoker->_interpreter->receive(invoker->_event); +} + +HeartbeatDispatcher* HeartbeatDispatcher::_instance = NULL; +HeartbeatDispatcher* HeartbeatDispatcher::getInstance() { + if (_instance == NULL) { + _instance = new HeartbeatDispatcher(); + _instance->start(); + } + return _instance; +} + +HeartbeatDispatcher::HeartbeatDispatcher() {} + +}
\ No newline at end of file diff --git a/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.h b/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.h new file mode 100644 index 0000000..9a6cb47 --- /dev/null +++ b/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.h @@ -0,0 +1,54 @@ +#ifndef HEARTBEATINVOKER_H_W09J90F0 +#define HEARTBEATINVOKER_H_W09J90F0 + +#include <uscxml/Interpreter.h> + +#ifdef BUILD_AS_PLUGINS +#include "uscxml/plugins/Plugins.h" +#endif + +namespace uscxml { + +class HeartbeatInvoker : public Invoker { +public: + HeartbeatInvoker(); + virtual ~HeartbeatInvoker(); + virtual Invoker* create(Interpreter* interpreter); + + virtual std::set<std::string> getNames() { + std::set<std::string> names; + names.insert("heartbeat"); + names.insert("http://uscxml.tk.informatik.tu-darmstadt.de/#heartbaet"); + return names; + } + + virtual Data getDataModelVariables(); + virtual void send(SendRequest& req); + virtual void cancel(const std::string sendId); + virtual void invoke(InvokeRequest& req); + virtual void sendToParent(SendRequest& req); + + static void dispatch(void* instance, std::string name); + +protected: + std::string _invokeId; + Event _event; + +}; + +class HeartbeatDispatcher : public DelayedEventQueue { +public: + static HeartbeatDispatcher* getInstance(); +protected: + static HeartbeatDispatcher* _instance; + HeartbeatDispatcher(); +}; + +#ifdef BUILD_AS_PLUGINS +PLUMA_INHERIT_PROVIDER(HeartbeatInvoker, Invoker); +#endif + +} + + +#endif /* end of include guard: HEARTBEATINVOKER_H_W09J90F0 */ diff --git a/src/uscxml/plugins/invoker/sample/SampleInvoker.cpp b/src/uscxml/plugins/invoker/sample/SampleInvoker.cpp index b5c351c..f115c25 100644 --- a/src/uscxml/plugins/invoker/sample/SampleInvoker.cpp +++ b/src/uscxml/plugins/invoker/sample/SampleInvoker.cpp @@ -42,6 +42,7 @@ void SampleInvoker::sendToParent(SendRequest& req) { } void SampleInvoker::invoke(InvokeRequest& req) { + _invokeId = req.invokeid; } }
\ No newline at end of file diff --git a/src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp b/src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp index ee6c903..9957bfa 100644 --- a/src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp +++ b/src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp @@ -1,5 +1,6 @@ #include "UmundoInvoker.h" #include <glog/logging.h> +#include "uscxml/URL.h" #ifdef BUILD_AS_PLUGINS #include <Pluma/Connector.hpp> @@ -15,12 +16,16 @@ bool connect(pluma::Host& host) { } #endif -UmundoInvoker::UmundoInvoker() { +UmundoInvoker::UmundoInvoker() : _node(NULL), _pub(NULL), _sub(NULL) { } UmundoInvoker::~UmundoInvoker() { - _node.removeSubscriber(_sub); - _node.removePublisher(_pub); + if (_node) { + if (_sub) + _node->removeSubscriber(*_sub); + if (_pub) + _node->removePublisher(*_pub); + } }; Invoker* UmundoInvoker::create(Interpreter* interpreter) { @@ -63,8 +68,8 @@ void UmundoInvoker::send(SendRequest& req) { } else { // add all s11n properties if (!_isService) { - _pub.prepareMsg(msg, type, pbMsg); - _pub.send(msg); + _pub->prepareMsg(msg, type, pbMsg); + _pub->send(msg); } else { std::map<umundo::ServiceDescription, umundo::ServiceStub*>::iterator svcIter = _svcs.begin(); while(svcIter != _svcs.end()) { @@ -107,11 +112,12 @@ void UmundoInvoker::sendToParent(SendRequest& req) { void UmundoInvoker::invoke(InvokeRequest& req) { _invokeId = req.invokeid; + std::string domain; std::string channelName; std::string serviceName; if (req.params.find("channel") != req.params.end()) { - channelName = req.params.find("type")->second; + channelName = req.params.find("channel")->second; _isService = false; } else if (req.params.find("service") != req.params.end()) { serviceName = req.params.find("service")->second; @@ -120,34 +126,50 @@ void UmundoInvoker::invoke(InvokeRequest& req) { LOG(ERROR) << "Invoking umundo needs a service or a channel param"; return; } + if (req.params.find("domain") != req.params.end()) { + domain = req.params.find("domain")->second; + } + _node = getNode(_interpreter, domain); - _node = getNode(_interpreter); - - // add types from .proto or .desc files - if (req.params.find("types") != req.params.end()) { + // add type from .proto or .desc files + if (req.params.find("type") != req.params.end()) { std::pair<InvokeRequest::params_t::iterator, InvokeRequest::params_t::iterator> typeRange = req.params.equal_range("types"); for (InvokeRequest::params_t::iterator it = typeRange.first; it != typeRange.second; it++) { - Arabica::io::URI srcURI(it->first); - // if (!_interpreter->makeAbsolute(srcURI)) { - // LOG(ERROR) << "Relative URI for types in umundo invoker " << *typeIter << " with no base URI set for interpreter"; - // return; - // } - umundo::PBSerializer::addProto(srcURI.path()); + URL typeURI(it->second); + if (typeURI.toAbsolute(_interpreter->getBaseURI())) { + std::string filename = typeURI.asLocalFile(".proto"); + umundo::PBSerializer::addProto(filename); + } else { + LOG(ERROR) << "umundo invoker has relative type src but nor baseURI set with interpreter."; + } } } + // add directory with .proto or .desc files + if (req.params.find("types") != req.params.end()) { + std::pair<InvokeRequest::params_t::iterator, InvokeRequest::params_t::iterator> typeRange = req.params.equal_range("types"); + for (InvokeRequest::params_t::iterator it = typeRange.first; it != typeRange.second; it++) { + URL typeURI(it->second); + if (typeURI.toAbsolute(_interpreter->getBaseURI()) && typeURI.scheme().compare("file") == 0) { + umundo::PBSerializer::addProto(typeURI.path()); + } else { + LOG(ERROR) << "invoke element has relative src URI with no baseURI set."; + } + } + } + if (!_isService) { // use umundo to publish objects on a channel - _pub = umundo::TypedPublisher(channelName); - _sub = umundo::TypedSubscriber(channelName, this); + _pub = new umundo::TypedPublisher(channelName); + _sub = new umundo::TypedSubscriber(channelName, this); - _node.addPublisher(_pub); - _node.addSubscriber(_sub); + _node->addPublisher(*_pub); + _node->addSubscriber(*_sub); } else if (serviceName.length() > 0) { // use umundo to access services _svcFilter = umundo::ServiceFilter(serviceName); - _node.connect(&_svcMgr); + _node->connect(&_svcMgr); _svcMgr.startQuery(_svcFilter, this); } } @@ -233,12 +255,17 @@ void UmundoInvoker::removed(umundo::ServiceDescription desc) { void UmundoInvoker::changed(umundo::ServiceDescription desc) { } -std::map<std::string, umundo::Node> UmundoInvoker::_nodes; -umundo::Node UmundoInvoker::getNode(Interpreter* interpreter) { - if ((_nodes.find(interpreter->getName()) == _nodes.end())) { - _nodes[interpreter->getName()] = umundo::Node(); - } - return _nodes[interpreter->getName()]; +std::multimap<std::string, std::pair<std::string, umundo::Node*> > UmundoInvoker::_nodes; +umundo::Node* UmundoInvoker::getNode(Interpreter* interpreter, const std::string& domain) { + std::pair<_nodes_t::iterator, _nodes_t::iterator> range = _nodes.equal_range(interpreter->getName()); + for (_nodes_t::iterator it = range.first; it != range.second; it++) { + if (it->second.first.compare(domain) == 0) + return it->second.second; + } + umundo::Node* node = new umundo::Node(domain); + std::pair<std::string, std::pair<std::string, umundo::Node*> > pair = std::make_pair(interpreter->getName(), std::make_pair(domain, node)); + _nodes.insert(pair); + return node; } bool UmundoInvoker::protobufToData(Data& data, const google::protobuf::Message& msg) { diff --git a/src/uscxml/plugins/invoker/umundo/UmundoInvoker.h b/src/uscxml/plugins/invoker/umundo/UmundoInvoker.h index 72fcc9b..09d07bf 100644 --- a/src/uscxml/plugins/invoker/umundo/UmundoInvoker.h +++ b/src/uscxml/plugins/invoker/umundo/UmundoInvoker.h @@ -49,16 +49,17 @@ protected: bool dataToProtobuf(google::protobuf::Message* msg, Data& data); bool protobufToData(Data& data, const google::protobuf::Message& msg); - umundo::TypedPublisher _pub; - umundo::TypedSubscriber _sub; - umundo::Node _node; + umundo::Node* _node; + umundo::TypedPublisher* _pub; + umundo::TypedSubscriber* _sub; umundo::ServiceFilter _svcFilter; umundo::ServiceManager _svcMgr; std::map<umundo::ServiceDescription, umundo::ServiceStub*> _svcs; - static std::map<std::string, umundo::Node> _nodes; - static umundo::Node getNode(Interpreter* interpreter); + static std::multimap<std::string, std::pair<std::string, umundo::Node*> > _nodes; + typedef std::multimap<std::string, std::pair<std::string, umundo::Node*> > _nodes_t; + static umundo::Node* getNode(Interpreter* interpreter, const std::string& domain); }; #ifdef BUILD_AS_PLUGINS diff --git a/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.cpp b/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.cpp index 78ecbe3..a50dcaf 100644 --- a/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.cpp +++ b/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.cpp @@ -313,6 +313,8 @@ void EventIOServer::registerProcessor(EventIOProcessor* processor) { INSTANCE->_processors[actualPath.str()] = processor; processor->setURL(processorURL.str()); + LOG(INFO) << "SCXML listening at: " << processorURL.str() << std::endl; + evhttp_set_cb(INSTANCE->_http, ("/" + actualPath.str()).c_str(), EventIOProcessor::httpRecvReq, processor); // evhttp_set_cb(THIS->_http, "/", EventIOProcessor::httpRecvReq, processor); // evhttp_set_gencb(THIS->_http, EventIOProcessor::httpRecvReq, NULL); @@ -332,7 +334,6 @@ void EventIOServer::start() { void EventIOServer::run(void* instance) { EventIOServer* INSTANCE = (EventIOServer*)instance; while(INSTANCE->_isRunning) { - LOG(INFO) << "Dispatching HTTP Server" << std::endl; event_base_dispatch(INSTANCE->_base); } LOG(INFO) << "HTTP Server stopped" << std::endl; |