diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-01-20 17:18:19 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-01-20 17:18:19 (GMT) |
commit | f4f05b40c8c464daf1e11df6fcdb63d05766ed1f (patch) | |
tree | a513019b456be25248212ab9d722e9c7bb5fdbc2 /src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NamedNodeMap.cpp | |
parent | b5c33505b3345795811b4aba7e5fda961068f369 (diff) | |
download | uscxml-f4f05b40c8c464daf1e11df6fcdb63d05766ed1f.zip uscxml-f4f05b40c8c464daf1e11df6fcdb63d05766ed1f.tar.gz uscxml-f4f05b40c8c464daf1e11df6fcdb63d05766ed1f.tar.bz2 |
Completed V8 IDL to DOM generator
Diffstat (limited to 'src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NamedNodeMap.cpp')
-rw-r--r-- | src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NamedNodeMap.cpp | 188 |
1 files changed, 188 insertions, 0 deletions
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NamedNodeMap.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NamedNodeMap.cpp new file mode 100644 index 0000000..1037b91 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NamedNodeMap.cpp @@ -0,0 +1,188 @@ +#include "V8NamedNodeMap.h" +#include "V8Node.h" + +namespace Arabica { +namespace DOM { + + v8::Persistent<v8::FunctionTemplate> V8NamedNodeMap::Tmpl; + + + v8::Handle<v8::Value> V8NamedNodeMap::lengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr<V8NamedNodeMapPrivate >(self->GetInternalField(0)); + + return v8::Integer::New(privData->arabicaThis->getLength()); + } + v8::Handle<v8::Value> V8NamedNodeMap::getNamedItemCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in getNamedItem"); + + v8::Local<v8::Object> self = args.Holder(); + V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr<V8NamedNodeMapPrivate >(self->GetInternalField(0)); + v8::String::AsciiValue localName(args[0]); + + Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->arabicaThis->getNamedItem(*localName)); + v8::Handle<v8::Function> retCtor = V8Node::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->arabicaThis = retVal; + + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + + retObj.MakeWeak(0, V8Node::jsDestructor); + return retObj; + + } + + v8::Handle<v8::Value> V8NamedNodeMap::setNamedItemCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in setNamedItem"); + if (!(V8Node::hasInstance(args[0]))) + throw V8Exception("Parameter mismatch while calling setNamedItem"); + + v8::Local<v8::Object> self = args.Holder(); + V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr<V8NamedNodeMapPrivate >(self->GetInternalField(0)); + Arabica::DOM::Node<std::string>* localArg = V8DOM::toClassPtr<V8Node::V8NodePrivate >(args[0]->ToObject()->GetInternalField(0))->arabicaThis; + + Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->arabicaThis->setNamedItem(*localArg)); + v8::Handle<v8::Function> retCtor = V8Node::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->arabicaThis = retVal; + + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + + retObj.MakeWeak(0, V8Node::jsDestructor); + return retObj; + + } + + v8::Handle<v8::Value> V8NamedNodeMap::removeNamedItemCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in removeNamedItem"); + + v8::Local<v8::Object> self = args.Holder(); + V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr<V8NamedNodeMapPrivate >(self->GetInternalField(0)); + v8::String::AsciiValue localName(args[0]); + + Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->arabicaThis->removeNamedItem(*localName)); + v8::Handle<v8::Function> retCtor = V8Node::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->arabicaThis = retVal; + + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + + retObj.MakeWeak(0, V8Node::jsDestructor); + return retObj; + + } + + v8::Handle<v8::Value> V8NamedNodeMap::itemCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in item"); + + v8::Local<v8::Object> self = args.Holder(); + V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr<V8NamedNodeMapPrivate >(self->GetInternalField(0)); + unsigned long localIndex = args[0]->ToNumber()->Uint32Value(); + + Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->arabicaThis->item(localIndex)); + v8::Handle<v8::Function> retCtor = V8Node::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->arabicaThis = retVal; + + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + + retObj.MakeWeak(0, V8Node::jsDestructor); + return retObj; + + } + + v8::Handle<v8::Value> V8NamedNodeMap::getNamedItemNSCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in getNamedItemNS"); + + v8::Local<v8::Object> self = args.Holder(); + V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr<V8NamedNodeMapPrivate >(self->GetInternalField(0)); + v8::String::AsciiValue localNamespaceURI(args[0]); + v8::String::AsciiValue localLocalName(args[1]); + + Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->arabicaThis->getNamedItemNS(*localNamespaceURI, *localLocalName)); + v8::Handle<v8::Function> retCtor = V8Node::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->arabicaThis = retVal; + + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + + retObj.MakeWeak(0, V8Node::jsDestructor); + return retObj; + + } + + v8::Handle<v8::Value> V8NamedNodeMap::setNamedItemNSCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in setNamedItemNS"); + if (!(V8Node::hasInstance(args[0]))) + throw V8Exception("Parameter mismatch while calling setNamedItemNS"); + + v8::Local<v8::Object> self = args.Holder(); + V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr<V8NamedNodeMapPrivate >(self->GetInternalField(0)); + Arabica::DOM::Node<std::string>* localArg = V8DOM::toClassPtr<V8Node::V8NodePrivate >(args[0]->ToObject()->GetInternalField(0))->arabicaThis; + + Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->arabicaThis->setNamedItemNS(*localArg)); + v8::Handle<v8::Function> retCtor = V8Node::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->arabicaThis = retVal; + + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + + retObj.MakeWeak(0, V8Node::jsDestructor); + return retObj; + + } + + v8::Handle<v8::Value> V8NamedNodeMap::removeNamedItemNSCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in removeNamedItemNS"); + + v8::Local<v8::Object> self = args.Holder(); + V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr<V8NamedNodeMapPrivate >(self->GetInternalField(0)); + v8::String::AsciiValue localNamespaceURI(args[0]); + v8::String::AsciiValue localLocalName(args[1]); + + Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->arabicaThis->removeNamedItemNS(*localNamespaceURI, *localLocalName)); + v8::Handle<v8::Function> retCtor = V8Node::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->arabicaThis = retVal; + + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + + retObj.MakeWeak(0, V8Node::jsDestructor); + return retObj; + + } + + bool V8NamedNodeMap::hasInstance(v8::Handle<v8::Value> value) { + return getTmpl()->HasInstance(value); + } + +} +} |