diff options
Diffstat (limited to 'src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.cpp')
-rw-r--r-- | src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.cpp | 69 |
1 files changed, 23 insertions, 46 deletions
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.cpp index cadcf7f..8421d2e 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.cpp @@ -1,60 +1,37 @@ #include "V8NodeSet.h" -#include "V8Element.h" -#include "V8Node.h" -#include <DOM/Node.hpp> -namespace uscxml { +namespace Arabica { +namespace DOM { -using namespace Arabica::DOM; -using namespace Arabica::XPath; + v8::Persistent<v8::FunctionTemplate> V8NodeSet::Tmpl; -v8::Persistent<v8::FunctionTemplate> V8NodeSet::Tmpl; + v8::Handle<v8::Value> V8NodeSet::sizeAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + V8NodeSetPrivate* privData = V8DOM::toClassPtr<V8NodeSetPrivate >(self->GetInternalField(0)); -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]); + return v8::Integer::New(privData->arabicaThis->size()); + } - nodeObj->SetInternalField(0, V8DOM::toExternal(node)); - nodeObj->SetInternalField(1, self->GetInternalField(1)); - nodeObj.MakeWeak(0, V8Node::jsDestructor); - return nodeObj; + v8::Handle<v8::Value> V8NodeSet::emptyAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + V8NodeSetPrivate* privData = V8DOM::toClassPtr<V8NodeSetPrivate >(self->GetInternalField(0)); - } - } + return v8::Boolean::New(privData->arabicaThis->empty()); } + v8::Handle<v8::Value> V8NodeSet::toDocumentOrderCallback(const v8::Arguments& args) { - return v8::Undefined(); -} + v8::Local<v8::Object> self = args.Holder(); + V8NodeSetPrivate* privData = V8DOM::toClassPtr<V8NodeSetPrivate >(self->GetInternalField(0)); -v8::Handle<v8::Value> V8NodeSet::lengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); + privData->arabicaThis->to_document_order(); - V8DOM* dom = V8DOM::toClassPtr<V8DOM>(self->GetInternalField(1)); (void)dom; - NodeSet<std::string>* nodeSet = V8DOM::toClassPtr<NodeSet<std::string> >(self->GetInternalField(1)); + return v8::Undefined(); + } - return v8::Integer::New(nodeSet->size()); -} + bool V8NodeSet::hasInstance(v8::Handle<v8::Value> value) { + return getTmpl()->HasInstance(value); + } -}
\ No newline at end of file +} +} |