summaryrefslogtreecommitdiffstats
path: root/src/uscxml/plugins/datamodel
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-01-10 22:42:42 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-01-10 22:42:42 (GMT)
commit7aa7095d17a180d663cd9647c31d99d97c1dca4f (patch)
tree460bc3a67f0adc3199bec9f22ee15a102263eb4c /src/uscxml/plugins/datamodel
parentda1032ffbff229ce2ca9a83d47522ff45c90ba23 (diff)
downloaduscxml-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/datamodel')
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp33
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.cpp9
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h53
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.cpp59
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.h104
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.cpp24
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.h87
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.cpp23
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.h161
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.cpp60
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.h41
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLDOM.cpp219
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLDOM.h61
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.cpp30
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.h75
15 files changed, 751 insertions, 288 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 */