diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-06-10 22:47:14 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-06-10 22:47:14 (GMT) |
commit | 6f56474450b7c54f2c95b5dea6a7a42623141649 (patch) | |
tree | 420c52085d8cf778360c09baf9722b21d01259da /src | |
parent | a154682fc1b25581742d38dd5fe9aa06ede167b7 (diff) | |
download | uscxml-6f56474450b7c54f2c95b5dea6a7a42623141649.zip uscxml-6f56474450b7c54f2c95b5dea6a7a42623141649.tar.gz uscxml-6f56474450b7c54f2c95b5dea6a7a42623141649.tar.bz2 |
W3C MMI Architecture framework
Diffstat (limited to 'src')
88 files changed, 3473 insertions, 2657 deletions
diff --git a/src/uscxml/Factory.cpp b/src/uscxml/Factory.cpp index 9c59259..5ad5e9a 100644 --- a/src/uscxml/Factory.cpp +++ b/src/uscxml/Factory.cpp @@ -11,6 +11,7 @@ #else # include "uscxml/plugins/ioprocessor/basichttp/BasicHTTPIOProcessor.h" +# include "uscxml/plugins/ioprocessor/modality/MMIHTTPIOProcessor.h" # include "uscxml/plugins/ioprocessor/scxml/SCXMLIOProcessor.h" # include "uscxml/plugins/invoker/scxml/USCXMLInvoker.h" # include "uscxml/plugins/invoker/http/HTTPServletInvoker.h" @@ -56,12 +57,24 @@ # include "uscxml/plugins/element/respond/RespondElement.h" # include "uscxml/plugins/element/postpone/PostponeElement.h" +# if 0 +# include "uscxml/plugins/element/mmi/MMIEvents.h" +# endif #endif +#define ELEMENT_MMI_REGISTER(class)\ +class##Element* class = new class##Element(); \ +registerExecutableContent(class); + + namespace uscxml { +Factory::Factory(Factory* parentFactory) : _parentFactory(parentFactory) { +} + Factory::Factory() { + _parentFactory = NULL; #ifdef BUILD_AS_PLUGINS if (pluginPath.length() == 0) { // try to read USCXML_PLUGIN_PATH environment variable @@ -187,6 +200,10 @@ Factory::Factory() { registerIOProcessor(ioProcessor); } { + MMIHTTPIOProcessor* ioProcessor = new MMIHTTPIOProcessor(); + registerIOProcessor(ioProcessor); + } + { SCXMLIOProcessor* ioProcessor = new SCXMLIOProcessor(); registerIOProcessor(ioProcessor); } @@ -207,6 +224,29 @@ Factory::Factory() { registerExecutableContent(element); } +#if 0 + { + ELEMENT_MMI_REGISTER(PrepareRequest); + ELEMENT_MMI_REGISTER(StartRequest); + ELEMENT_MMI_REGISTER(PauseRequest); + ELEMENT_MMI_REGISTER(ResumeRequest); + ELEMENT_MMI_REGISTER(CancelRequest); + ELEMENT_MMI_REGISTER(ClearContextRequest); + ELEMENT_MMI_REGISTER(StatusRequest); + ELEMENT_MMI_REGISTER(NewContextResponse); + ELEMENT_MMI_REGISTER(PrepareResponse); + ELEMENT_MMI_REGISTER(StartResponse); + ELEMENT_MMI_REGISTER(PauseResponse); + ELEMENT_MMI_REGISTER(ResumeResponse); + ELEMENT_MMI_REGISTER(CancelResponse); + ELEMENT_MMI_REGISTER(ClearContextResponse); + ELEMENT_MMI_REGISTER(StatusResponse); + ELEMENT_MMI_REGISTER(DoneNotification); + ELEMENT_MMI_REGISTER(NewContextRequest); + ELEMENT_MMI_REGISTER(ExtensionNotification); + } +#endif + #endif } @@ -261,63 +301,96 @@ void Factory::registerExecutableContent(ExecutableContentImpl* executableContent _executableContent[std::make_pair(localName, nameSpace)] = executableContent; } +std::map<std::string, IOProcessorImpl*> Factory::getIOProcessors() { + std::map<std::string, IOProcessorImpl*> ioProcs; + if (_parentFactory) { + ioProcs = _parentFactory->getIOProcessors(); + } + + std::map<std::string, IOProcessorImpl*>::iterator ioProcIter = _ioProcessors.begin(); + while(ioProcIter != _ioProcessors.end()) { + ioProcs.insert(std::make_pair(ioProcIter->first, ioProcIter->second)); + ioProcIter++; + } + + return ioProcs; +} boost::shared_ptr<InvokerImpl> Factory::createInvoker(const std::string& type, InterpreterImpl* interpreter) { - Factory* factory = getInstance(); - if (factory->_invokerAliases.find(type) == factory->_invokerAliases.end()) { - LOG(ERROR) << "No " << type << " Invoker known"; - return boost::shared_ptr<InvokerImpl>(); + + // do we have this type ourself? + if (_invokerAliases.find(type) != _invokerAliases.end()) { + std::string canonicalName = _invokerAliases[type]; + if (_invokers.find(canonicalName) != _invokers.end()) { + return _invokers[canonicalName]->create(interpreter); + } } - std::string canonicalName = factory->_invokerAliases[type]; - if (factory->_invokers.find(canonicalName) == factory->_invokers.end()) { - LOG(ERROR) << "Invoker " << type << " known as " << canonicalName << " but no prototype is available in factory"; - return boost::shared_ptr<InvokerImpl>(); + // lookup in parent factory + if (_parentFactory) { + return _parentFactory->createInvoker(type, interpreter); + } else { + LOG(ERROR) << "No " << type << " Invoker known"; } - - return boost::static_pointer_cast<InvokerImpl>(factory->_invokers[canonicalName]->create(interpreter)); + + return boost::shared_ptr<InvokerImpl>(); } boost::shared_ptr<DataModelImpl> Factory::createDataModel(const std::string& type, InterpreterImpl* interpreter) { - Factory* factory = getInstance(); - if (factory->_dataModelAliases.find(type) == factory->_dataModelAliases.end()) { - LOG(ERROR) << "No " << type << " DataModel known"; - return boost::shared_ptr<DataModelImpl>(); + + // do we have this type ourself? + if (_dataModelAliases.find(type) != _dataModelAliases.end()) { + std::string canonicalName = _dataModelAliases[type]; + if (_dataModels.find(canonicalName) != _dataModels.end()) { + return _dataModels[canonicalName]->create(interpreter); + } } - - std::string canonicalName = factory->_dataModelAliases[type]; - if (factory->_dataModels.find(canonicalName) == factory->_dataModels.end()) { - LOG(ERROR) << "DataModel " << type << " known as " << canonicalName << " but no prototype is available in factory"; - return boost::shared_ptr<DataModelImpl>(); + + // lookup in parent factory + if (_parentFactory) { + return _parentFactory->createDataModel(type, interpreter); + } else { + LOG(ERROR) << "No " << type << " Datamodel known"; } - - return factory->_dataModels[canonicalName]->create(interpreter); + + return boost::shared_ptr<DataModelImpl>(); } boost::shared_ptr<IOProcessorImpl> Factory::createIOProcessor(const std::string& type, InterpreterImpl* interpreter) { - Factory* factory = getInstance(); - if (factory->_ioProcessorAliases.find(type) == factory->_ioProcessorAliases.end()) { - LOG(ERROR) << "No " << type << " IOProcessor known"; - return boost::shared_ptr<IOProcessorImpl>(); + // do we have this type ourself? + if (_ioProcessorAliases.find(type) != _ioProcessorAliases.end()) { + std::string canonicalName = _ioProcessorAliases[type]; + if (_ioProcessors.find(canonicalName) != _ioProcessors.end()) { + return _ioProcessors[canonicalName]->create(interpreter); + } } - - std::string canonicalName = factory->_ioProcessorAliases[type]; - if (factory->_ioProcessors.find(canonicalName) == factory->_ioProcessors.end()) { - LOG(ERROR) << "IOProcessor " << type << " known as " << canonicalName << " but no prototype is available in factory"; - return boost::shared_ptr<IOProcessorImpl>(); + + // lookup in parent factory + if (_parentFactory) { + return _parentFactory->createIOProcessor(type, interpreter); + } else { + LOG(ERROR) << "No " << type << " Datamodel known"; } - - return factory->_ioProcessors[canonicalName]->create(interpreter); + + return boost::shared_ptr<IOProcessorImpl>(); } boost::shared_ptr<ExecutableContentImpl> Factory::createExecutableContent(const std::string& localName, const std::string& nameSpace, InterpreterImpl* interpreter) { - Factory* factory = getInstance(); + // do we have this type in this factory? std::string actualNameSpace = (nameSpace.length() == 0 ? "http://www.w3.org/2005/07/scxml" : nameSpace); - if (factory->_executableContent.find(std::make_pair(localName, actualNameSpace)) == factory->_executableContent.end()) { + if (_executableContent.find(std::make_pair(localName, actualNameSpace)) != _executableContent.end()) { + return _executableContent[std::make_pair(localName, actualNameSpace)]->create(interpreter); + } + + // lookup in parent factory + if (_parentFactory) { + return _parentFactory->createExecutableContent(localName, nameSpace, interpreter); + } else { LOG(ERROR) << "Executable content " << localName << " in " << actualNameSpace << " not available in factory"; - return boost::shared_ptr<ExecutableContentImpl>(); } - return factory->_executableContent[std::make_pair(localName, actualNameSpace)]->create(interpreter); + + return boost::shared_ptr<ExecutableContentImpl>(); + } @@ -328,7 +401,7 @@ Factory* Factory::getInstance() { return _instance; } -void IOProcessorImpl::returnEvent(Event& event) { +void EventHandlerImpl::returnEvent(Event& event) { if (event.invokeid.length() == 0) event.invokeid = _invokeId; if (event.type == 0) diff --git a/src/uscxml/Factory.h b/src/uscxml/Factory.h index 59835b3..d92d105 100644 --- a/src/uscxml/Factory.h +++ b/src/uscxml/Factory.h @@ -103,11 +103,8 @@ protected: }; -class IOProcessorImpl { +class EventHandlerImpl { public: - IOProcessorImpl() {}; - virtual ~IOProcessorImpl() {}; - virtual boost::shared_ptr<IOProcessorImpl> create(InterpreterImpl* interpreter) = 0; virtual std::set<std::string> getNames() = 0; virtual void setInterpreter(InterpreterImpl* interpreter) { @@ -119,48 +116,31 @@ public: void setType(const std::string& type) { _type = type; } - + virtual Data getDataModelVariables() = 0; virtual void send(const SendRequest& req) = 0; - + virtual void runOnMainThread() {}; - void returnEvent(Event& event); - + protected: InterpreterImpl* _interpreter; std::string _invokeId; std::string _type; + }; -class IOProcessor { +class EventHandler { public: - IOProcessor() : _impl() {} - IOProcessor(boost::shared_ptr<IOProcessorImpl> const impl) : _impl(impl) { } - IOProcessor(const IOProcessor& other) : _impl(other._impl) { } - virtual ~IOProcessor() {}; - - operator bool() const { - return _impl; - } - bool operator< (const IOProcessor& other) const { - return _impl < other._impl; - } - bool operator==(const IOProcessor& other) const { - return _impl == other._impl; - } - bool operator!=(const IOProcessor& other) const { - return _impl != other._impl; - } - IOProcessor& operator= (const IOProcessor& other) { - _impl = other._impl; - return *this; - } - + EventHandler() : _impl() {} + EventHandler(boost::shared_ptr<EventHandlerImpl> const impl) : _impl(impl) { } + EventHandler(const EventHandler& other) : _impl(other._impl) { } + virtual ~EventHandler() {}; + virtual std::set<std::string> getNames() { return _impl->getNames(); } - + virtual Data getDataModelVariables() const { return _impl->getDataModelVariables(); }; @@ -170,7 +150,7 @@ public: virtual void runOnMainThread() { return _impl->runOnMainThread(); } - + void setInterpreter(InterpreterImpl* interpreter) { _impl->setInterpreter(interpreter); } @@ -182,21 +162,58 @@ public: } protected: + boost::shared_ptr<EventHandlerImpl> _impl; + friend class InterpreterImpl; +}; + +class IOProcessorImpl : public EventHandlerImpl { +public: + IOProcessorImpl() {}; + virtual ~IOProcessorImpl() {}; + virtual boost::shared_ptr<IOProcessorImpl> create(InterpreterImpl* interpreter) = 0; +}; + +class IOProcessor : public EventHandler { +public: + IOProcessor() : _impl() {} + IOProcessor(boost::shared_ptr<IOProcessorImpl> const impl) : EventHandler(impl), _impl(impl) { } + IOProcessor(const IOProcessor& other) : EventHandler(other._impl), _impl(other._impl) { } + virtual ~IOProcessor() {}; + + operator bool() const { + return _impl; + } + bool operator< (const IOProcessor& other) const { + return _impl < other._impl; + } + bool operator==(const IOProcessor& other) const { + return _impl == other._impl; + } + bool operator!=(const IOProcessor& other) const { + return _impl != other._impl; + } + IOProcessor& operator= (const IOProcessor& other) { + _impl = other._impl; + EventHandler::_impl = _impl; + return *this; + } + +protected: boost::shared_ptr<IOProcessorImpl> _impl; friend class InterpreterImpl; }; -class InvokerImpl : public IOProcessorImpl { +class InvokerImpl : public EventHandlerImpl { public: virtual void invoke(const InvokeRequest& req) = 0; - virtual boost::shared_ptr<IOProcessorImpl> create(InterpreterImpl* interpreter) = 0; + virtual boost::shared_ptr<InvokerImpl> create(InterpreterImpl* interpreter) = 0; }; -class Invoker : public IOProcessor { +class Invoker : public EventHandler { public: Invoker() : _impl() {} - Invoker(boost::shared_ptr<InvokerImpl> const impl) : IOProcessor(impl), _impl(impl) { } - Invoker(const Invoker& other) : IOProcessor(other._impl), _impl(other._impl) { } + Invoker(boost::shared_ptr<InvokerImpl> const impl) : EventHandler(impl), _impl(impl) { } + Invoker(const Invoker& other) : EventHandler(other._impl), _impl(other._impl) { } virtual ~Invoker() {}; operator bool() const { @@ -213,7 +230,7 @@ public: } Invoker& operator= (const Invoker& other) { _impl = other._impl; - IOProcessor::_impl = _impl; + EventHandler::_impl = _impl; return *this; } @@ -352,16 +369,20 @@ protected: class Factory { public: + Factory(Factory* parentFactory); + void registerIOProcessor(IOProcessorImpl* ioProcessor); void registerDataModel(DataModelImpl* dataModel); void registerInvoker(InvokerImpl* invoker); void registerExecutableContent(ExecutableContentImpl* executableContent); - static boost::shared_ptr<DataModelImpl> createDataModel(const std::string& type, InterpreterImpl* interpreter); - static boost::shared_ptr<IOProcessorImpl> createIOProcessor(const std::string& type, InterpreterImpl* interpreter); - static boost::shared_ptr<InvokerImpl> createInvoker(const std::string& type, InterpreterImpl* interpreter); - static boost::shared_ptr<ExecutableContentImpl> createExecutableContent(const std::string& localName, const std::string& nameSpace, InterpreterImpl* interpreter); + boost::shared_ptr<DataModelImpl> createDataModel(const std::string& type, InterpreterImpl* interpreter); + boost::shared_ptr<IOProcessorImpl> createIOProcessor(const std::string& type, InterpreterImpl* interpreter); + boost::shared_ptr<InvokerImpl> createInvoker(const std::string& type, InterpreterImpl* interpreter); + boost::shared_ptr<ExecutableContentImpl> createExecutableContent(const std::string& localName, const std::string& nameSpace, InterpreterImpl* interpreter); + std::map<std::string, IOProcessorImpl*> getIOProcessors(); + static Factory* getInstance(); std::map<std::string, DataModelImpl*> _dataModels; @@ -381,6 +402,7 @@ protected: Factory(); ~Factory(); + Factory* _parentFactory; static Factory* _instance; }; diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp index dea7299..8bb6499 100644 --- a/src/uscxml/Interpreter.cpp +++ b/src/uscxml/Interpreter.cpp @@ -1,6 +1,7 @@ #include "uscxml/Common.h" #include "uscxml/Interpreter.h" #include "uscxml/URL.h" +#include "uscxml/NameSpacingParser.h" #include "uscxml/debug/SCXMLDotWriter.h" #include "uscxml/plugins/invoker/http/HTTPServletInvoker.h" @@ -59,6 +60,7 @@ InterpreterImpl::InterpreterImpl() { _done = true; _isInitialized = false; _httpServlet = NULL; + _factory = NULL; _capabilities = CAN_BASIC_HTTP | CAN_GENERIC_HTTP; #ifdef _WIN32 @@ -131,18 +133,9 @@ Interpreter Interpreter::fromInputSource(Arabica::SAX::InputSource<std::string>& tthread::lock_guard<tthread::recursive_mutex> lock(_instanceMutex); boost::shared_ptr<InterpreterDraft6> interpreterImpl = boost::shared_ptr<InterpreterDraft6>(new InterpreterDraft6); Interpreter interpreter; - SCXMLParser* parser = new SCXMLParser(interpreterImpl.get()); - if(!parser->parse(source) || !parser->getDocument().hasChildNodes()) { - if(parser->_errorHandler.errorsReported()) { - LOG(ERROR) << "could not parse input:"; - LOG(ERROR) << parser->_errorHandler.errors() << std::endl; - } else { - Arabica::SAX::InputSourceResolver resolver(source, Arabica::default_string_adaptor<std::string>()); - if (!resolver.resolve()) { - LOG(ERROR) << source.getSystemId() << ": no such file"; - } - } - } else { + NameSpacingParser* parser = new NameSpacingParser(); + if (parser->parse(source) && parser->getDocument() && parser->getDocument().hasChildNodes()) { + interpreterImpl->setNameSpaceInfo(parser->nameSpace); interpreterImpl->_document = parser->getDocument(); interpreterImpl->init(); interpreter = Interpreter(interpreterImpl); @@ -153,32 +146,32 @@ Interpreter Interpreter::fromInputSource(Arabica::SAX::InputSource<std::string>& return interpreter; } -SCXMLParser::SCXMLParser(InterpreterImpl* interpreter) : _interpreter(interpreter) { - Arabica::SAX::CatchErrorHandler<std::string> errorHandler; - setErrorHandler(errorHandler); -} - -void SCXMLParser::startPrefixMapping(const std::string& prefix, const std::string& uri) { -#if 0 - std::cout << "starting prefix mapping " << prefix << ": " << uri << std::endl; -#endif - if (boost::iequals(uri, "http://www.w3.org/2005/07/scxml")) { - _interpreter->_nsURL = uri; - if (prefix.size() == 0) { - LOG(INFO) << "Mapped default namespace to 'scxml:'"; - _interpreter->_xpathPrefix = "scxml:"; - _interpreter->_nsContext.addNamespaceDeclaration(uri, "scxml"); - _interpreter->_nsToPrefix[uri] = "scxml"; +void InterpreterImpl::setNameSpaceInfo(const std::map<std::string, std::string> namespaceInfo) { + _nameSpaceInfo = namespaceInfo; + std::map<std::string, std::string>::const_iterator nsIter = namespaceInfo.begin(); + while(nsIter != namespaceInfo.end()) { + std::string uri = nsIter->first; + std::string prefix = nsIter->second; + if (boost::iequals(uri, "http://www.w3.org/2005/07/scxml")) { + _nsURL = uri; + if (prefix.size() == 0) { + LOG(INFO) << "Mapped default namespace to 'scxml:'"; + _xpathPrefix = "scxml:"; + _nsContext.addNamespaceDeclaration(uri, "scxml"); + _nsToPrefix[uri] = "scxml"; + } else { + _xpathPrefix = prefix + ":"; + _xmlNSPrefix = _xpathPrefix; + _nsContext.addNamespaceDeclaration(uri, prefix); + _nsToPrefix[uri] = prefix; + } } else { - _interpreter->_xpathPrefix = prefix + ":"; - _interpreter->_xmlNSPrefix = _interpreter->_xpathPrefix; - _interpreter->_nsContext.addNamespaceDeclaration(uri, prefix); - _interpreter->_nsToPrefix[uri] = prefix; + _nsContext.addNamespaceDeclaration(uri, prefix); + _nsToPrefix[uri] = prefix; } - } else { - _interpreter->_nsContext.addNamespaceDeclaration(uri, prefix); - _interpreter->_nsToPrefix[uri] = prefix; + nsIter++; } + } void InterpreterImpl::setName(const std::string& name) { @@ -261,9 +254,13 @@ void InterpreterImpl::init() { normalize(_scxml); + // setup event queue for delayed send _sendQueue = new DelayedEventQueue(); _sendQueue->start(); + if (_factory == NULL) + _factory = Factory::getInstance(); + } else { LOG(ERROR) << "Cannot find SCXML element" << std::endl; _done = true; @@ -480,7 +477,7 @@ void InterpreterImpl::processDOMorText(const Arabica::DOM::Node<std::string>& no Node<std::string> container = dom.createElement("container"); dom.replaceChild(container, content); container.appendChild(content); - std::cout << dom << std::endl; +// std::cout << dom << std::endl; return; } else { text = srcContent.str(); @@ -830,7 +827,7 @@ void InterpreterImpl::invoke(const Arabica::DOM::Node<std::string>& element) { if (invokeReq.type.size() == 0) invokeReq.type = "http://www.w3.org/TR/scxml/"; - Invoker invoker(Factory::createInvoker(invokeReq.type, this)); + Invoker invoker(_factory->createInvoker(invokeReq.type, this)); if (invoker) { tthread::lock_guard<tthread::recursive_mutex> lock(_pluginMutex); try { @@ -1159,7 +1156,7 @@ void InterpreterImpl::executeContent(const Arabica::DOM::Node<std::string>& cont // --- Custom Executable Content ExecutableContent execContent; if (_executableContent.find(content) == _executableContent.end()) { - execContent = Factory::createExecutableContent(content.getLocalName(), content.getNamespaceURI(), this); + execContent = _factory->createExecutableContent(content.getLocalName(), content.getNamespaceURI(), this); if (!execContent) { LOG(ERROR) << "No custom executable content known for element '" << content.getLocalName() << "' in namespace '" << content.getNamespaceURI() << "'"; @@ -1620,8 +1617,9 @@ bool InterpreterImpl::isCompound(const Arabica::DOM::Node<std::string>& state) { void InterpreterImpl::setupIOProcessors() { tthread::lock_guard<tthread::recursive_mutex> lock(_pluginMutex); - std::map<std::string, IOProcessorImpl*>::iterator ioProcIter = Factory::getInstance()->_ioProcessors.begin(); - while(ioProcIter != Factory::getInstance()->_ioProcessors.end()) { + std::map<std::string, IOProcessorImpl*> ioProcs = _factory->getIOProcessors(); + std::map<std::string, IOProcessorImpl*>::iterator ioProcIter = ioProcs.begin(); + while(ioProcIter != ioProcs.end()) { if (boost::iequals(ioProcIter->first, "basichttp") && !(_capabilities & CAN_BASIC_HTTP)) { ioProcIter++; continue; @@ -1631,7 +1629,7 @@ void InterpreterImpl::setupIOProcessors() { continue; } - _ioProcessors[ioProcIter->first] = Factory::createIOProcessor(ioProcIter->first, this); + _ioProcessors[ioProcIter->first] = _factory->createIOProcessor(ioProcIter->first, this); _ioProcessors[ioProcIter->first].setType(ioProcIter->first); _ioProcessors[ioProcIter->first].setInterpreter(this); diff --git a/src/uscxml/Interpreter.h b/src/uscxml/Interpreter.h index d88fe10..7c95426 100644 --- a/src/uscxml/Interpreter.h +++ b/src/uscxml/Interpreter.h @@ -56,15 +56,6 @@ public: std::string unit; }; -class SCXMLParser : public Arabica::SAX2DOM::Parser<std::string> { -public: - SCXMLParser(InterpreterImpl* interpreter); - void startPrefixMapping(const std::string& /* prefix */, const std::string& /* uri */); - - Arabica::SAX::CatchErrorHandler<std::string> _errorHandler; - InterpreterImpl* _interpreter; -}; - enum Capabilities { CAN_NOTHING = 0, CAN_BASIC_HTTP = 1, @@ -123,6 +114,12 @@ public: void setParentQueue(uscxml::concurrency::BlockingQueue<SendRequest>* parentQueue) { _parentQueue = parentQueue; } + void setFactory(Factory* factory) { + _factory = factory; + } + Factory* getFactory() { + return _factory; + } std::string getXPathPrefix() { return _xpathPrefix; } @@ -137,7 +134,9 @@ public: return _nsToPrefix[ns] + ":"; return ""; } - + void setNameSpaceInfo(const std::map<std::string, std::string> nameSpaceInfo); + std::map<std::string, std::string> getNameSpaceInfo() { return _nameSpaceInfo; } + void receiveInternal(const Event& event); void receive(const Event& event, bool toFront = false); @@ -252,6 +251,7 @@ protected: std::string _xpathPrefix; // prefix mapped for xpath, "scxml" is _xmlNSPrefix is empty but _nsURL set std::string _nsURL; // ough to be "http://www.w3.org/2005/07/scxml" std::map<std::string, std::string> _nsToPrefix; + std::map<std::string, std::string> _nameSpaceInfo; bool _running; bool _done; @@ -271,6 +271,7 @@ protected: DelayedEventQueue* _sendQueue; Event _currEvent; + Factory* _factory; InterpreterServlet* _httpServlet; std::set<InterpreterMonitor*> _monitors; @@ -321,7 +322,6 @@ protected: std::map<std::string, Arabica::DOM::Node<std::string> > _cachedStates; std::map<std::string, URL> _cachedURLs; - friend class SCXMLParser; friend class USCXMLInvoker; friend class SCXMLIOProcessor; friend class Interpreter; @@ -385,6 +385,13 @@ public: return _impl->getBaseURI(); } + void setNameSpaceInfo(const std::map<std::string, std::string> namespaceInfo) { + _impl->setNameSpaceInfo(namespaceInfo); + } + std::map<std::string, std::string> getNameSpaceInfo() { + return _impl->getNameSpaceInfo(); + } + void setCmdLineOptions(int argc, char** argv) { return _impl->setCmdLineOptions(argc, argv); } @@ -402,6 +409,12 @@ public: void setParentQueue(uscxml::concurrency::BlockingQueue<SendRequest>* parentQueue) { return _impl->setParentQueue(parentQueue); } + void setFactory(Factory* factory) { + return _impl->setFactory(factory); + } + Factory* getFactory() { + return _impl->getFactory(); + } std::string getXPathPrefix() { return _impl->getXPathPrefix(); } @@ -566,7 +579,6 @@ public: return InterpreterImpl::getUUID(); } -#ifndef SWIG boost::shared_ptr<InterpreterImpl> getImpl() { return _impl; } @@ -584,8 +596,6 @@ public: return _instances; } -#endif - protected: boost::shared_ptr<InterpreterImpl> _impl; static std::map<std::string, boost::weak_ptr<InterpreterImpl> > _instances; diff --git a/src/uscxml/Message.h b/src/uscxml/Message.h index 1d8cb53..0f82947 100644 --- a/src/uscxml/Message.h +++ b/src/uscxml/Message.h @@ -35,6 +35,33 @@ public: return (atom.length() > 0 || !compound.empty() || !array.empty()); } + bool hasKey(const std::string& key) const { + return (!compound.empty() && compound.find(key) != compound.end()); + } + + const Data operator[](const std::string& key) const { + return operator[](key.c_str()); + } + + const Data operator[](const char* key) const { + if (hasKey(key)) + return compound.at(key); + Data data; + return data; + } + + operator std::string() { + return atom; + } + + operator std::map<std::string, Data>() { + return compound; + } + + operator std::list<Data>() { + return array; + } + static Data fromJSON(const std::string& jsonString); static Data fromXML(const std::string& xmlString); Arabica::DOM::Document<std::string> toDocument(); diff --git a/src/uscxml/NameSpacingParser.cpp b/src/uscxml/NameSpacingParser.cpp new file mode 100644 index 0000000..21d9704 --- /dev/null +++ b/src/uscxml/NameSpacingParser.cpp @@ -0,0 +1,44 @@ +#include "NameSpacingParser.h" +#include <glog/logging.h> + +namespace uscxml { + + NameSpacingParser* NameSpacingParser::fromXML(const std::string& xml) { + if (xml.length() == 0) + return NULL; + std::stringstream* ss = new std::stringstream(); + (*ss) << xml; + // we need an auto_ptr for arabica to assume ownership + std::auto_ptr<std::istream> ssPtr(ss); + Arabica::SAX::InputSource<std::string> inputSource; + inputSource.setByteStream(ssPtr); + return fromInputSource(inputSource); + } + + NameSpacingParser* NameSpacingParser::fromInputSource(Arabica::SAX::InputSource<std::string>& source) { + NameSpacingParser* parser = new NameSpacingParser(); + if(!parser->parse(source) || !parser->getDocument().hasChildNodes()) { + if(parser->_errorHandler.errorsReported()) { + LOG(ERROR) << "could not parse input:"; + LOG(ERROR) << parser->_errorHandler.errors() << std::endl; + } else { + Arabica::SAX::InputSourceResolver resolver(source, Arabica::default_string_adaptor<std::string>()); + if (!resolver.resolve()) { + LOG(ERROR) << source.getSystemId() << ": no such file"; + } + } + delete parser; + } + return parser; + } + + NameSpacingParser::NameSpacingParser() { + Arabica::SAX::CatchErrorHandler<std::string> errorHandler; + setErrorHandler(errorHandler); + } + + void NameSpacingParser::startPrefixMapping(const std::string& prefix, const std::string& uri) { + nameSpace.insert(std::make_pair(uri, prefix)); + } + +}
\ No newline at end of file diff --git a/src/uscxml/NameSpacingParser.h b/src/uscxml/NameSpacingParser.h new file mode 100644 index 0000000..7dcefcf --- /dev/null +++ b/src/uscxml/NameSpacingParser.h @@ -0,0 +1,26 @@ +#ifndef NAMESPACINGPARSER_H_1S91TNPM +#define NAMESPACINGPARSER_H_1S91TNPM + +#include <DOM/SAX2DOM/SAX2DOM.hpp> +#include <SAX/helpers/CatchErrorHandler.hpp> + +namespace uscxml { + + class NameSpacingParser : public Arabica::SAX2DOM::Parser<std::string> { + public: + NameSpacingParser(); + static NameSpacingParser* fromXML(const std::string& xml); + static NameSpacingParser* fromInputSource(Arabica::SAX::InputSource<std::string>& source); + + void startPrefixMapping(const std::string& prefix, const std::string& uri); + + Arabica::SAX::CatchErrorHandler<std::string> _errorHandler; + std::map<std::string, std::string> nameSpace; + + private: + NameSpacingParser(const NameSpacingParser& other) {} + }; + +} + +#endif /* end of include guard: NAMESPACINGPARSER_H_1S91TNPM */ diff --git a/src/uscxml/interpreter/InterpreterDraft6.cpp b/src/uscxml/interpreter/InterpreterDraft6.cpp index 97223f8..fb6a637 100644 --- a/src/uscxml/interpreter/InterpreterDraft6.cpp +++ b/src/uscxml/interpreter/InterpreterDraft6.cpp @@ -14,6 +14,8 @@ void InterpreterDraft6::interpret() { if (!_isInitialized) init(); +// std::cout << _scxml << std::endl; + if (!_scxml) { // _mutex.unlock(); return; @@ -30,8 +32,11 @@ void InterpreterDraft6::interpret() { datamodelName = ATTR(_scxml, "datamodel"); if (datamodelName.length() == 0 && HAS_ATTR(_scxml, "profile")) // SCION SCXML uses profile to specify datamodel datamodelName = ATTR(_scxml, "profile"); - if(datamodelName.length() > 0) - _dataModel = Factory::createDataModel(datamodelName, this); + if(datamodelName.length() > 0) { + _dataModel = _factory->createDataModel(datamodelName, this); + } else { + _dataModel = _factory->createDataModel("null", this); + } if(datamodelName.length() > 0 && !_dataModel) { LOG(ERROR) << "No datamodel for " << datamodelName << " registered"; } diff --git a/src/uscxml/interpreter/InterpreterDraft7.cpp b/src/uscxml/interpreter/InterpreterDraft7.cpp index 2f8c7b2..7f16b1f 100644 --- a/src/uscxml/interpreter/InterpreterDraft7.cpp +++ b/src/uscxml/interpreter/InterpreterDraft7.cpp @@ -38,8 +38,11 @@ void InterpreterDraft7::interpret() { datamodelName = ATTR(_scxml, "datamodel"); if (datamodelName.length() == 0 && HAS_ATTR(_scxml, "profile")) // SCION SCXML uses profile to specify datamodel datamodelName = ATTR(_scxml, "profile"); - if(datamodelName.length() > 0) - _dataModel = Factory::createDataModel(datamodelName, this); + if(datamodelName.length() > 0) { + _dataModel = _factory->createDataModel(datamodelName, this); + } else { + _dataModel = _factory->createDataModel("null", this); + } if(datamodelName.length() > 0 && !_dataModel) { LOG(ERROR) << "No datamodel for " << datamodelName << " registered"; } diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Attr.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Attr.cpp index bee6042..d16f81b 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Attr.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Attr.cpp @@ -5,59 +5,59 @@ namespace Arabica { namespace DOM { -v8::Persistent<v8::FunctionTemplate> V8Attr::Tmpl; + v8::Persistent<v8::FunctionTemplate> V8Attr::Tmpl; -v8::Handle<v8::Value> V8Attr::nameAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8AttrPrivate* privData = V8DOM::toClassPtr<V8AttrPrivate >(self->GetInternalField(0)); + v8::Handle<v8::Value> V8Attr::nameAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8AttrPrivate* privData = V8DOM::toClassPtr<V8AttrPrivate >(self->GetInternalField(0)); - return v8::String::New(privData->nativeObj->getName().c_str()); -} + return v8::String::New(privData->nativeObj->getName().c_str()); + } -v8::Handle<v8::Value> V8Attr::specifiedAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8AttrPrivate* privData = V8DOM::toClassPtr<V8AttrPrivate >(self->GetInternalField(0)); + v8::Handle<v8::Value> V8Attr::specifiedAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8AttrPrivate* privData = V8DOM::toClassPtr<V8AttrPrivate >(self->GetInternalField(0)); - return v8::Boolean::New(privData->nativeObj->getSpecified()); -} + return v8::Boolean::New(privData->nativeObj->getSpecified()); + } -v8::Handle<v8::Value> V8Attr::valueAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8AttrPrivate* privData = V8DOM::toClassPtr<V8AttrPrivate >(self->GetInternalField(0)); + v8::Handle<v8::Value> V8Attr::valueAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8AttrPrivate* privData = V8DOM::toClassPtr<V8AttrPrivate >(self->GetInternalField(0)); - return v8::String::New(privData->nativeObj->getValue().c_str()); -} + return v8::String::New(privData->nativeObj->getValue().c_str()); + } -void V8Attr::valueAttrSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8AttrPrivate* privData = V8DOM::toClassPtr<V8AttrPrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localValue(value); - privData->nativeObj->setValue(*localValue); -} + void V8Attr::valueAttrSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8AttrPrivate* privData = V8DOM::toClassPtr<V8AttrPrivate >(self->GetInternalField(0)); + v8::String::AsciiValue localValue(value); + privData->nativeObj->setValue(*localValue); + } -v8::Handle<v8::Value> V8Attr::ownerElementAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8AttrPrivate* privData = V8DOM::toClassPtr<V8AttrPrivate >(self->GetInternalField(0)); + v8::Handle<v8::Value> V8Attr::ownerElementAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8AttrPrivate* privData = V8DOM::toClassPtr<V8AttrPrivate >(self->GetInternalField(0)); - if (!privData->nativeObj->getOwnerElement()) return v8::Undefined(); - Arabica::DOM::Element<std::string>* arbaicaRet = new Arabica::DOM::Element<std::string>(privData->nativeObj->getOwnerElement()); + if (!privData->nativeObj->getOwnerElement()) return v8::Undefined(); + Arabica::DOM::Element<std::string>* arbaicaRet = new Arabica::DOM::Element<std::string>(privData->nativeObj->getOwnerElement()); - v8::Handle<v8::Function> arbaicaRetCtor = V8Element::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance()); + v8::Handle<v8::Function> arbaicaRetCtor = V8Element::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance()); - struct V8Element::V8ElementPrivate* retPrivData = new V8Element::V8ElementPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = arbaicaRet; + struct V8Element::V8ElementPrivate* retPrivData = new V8Element::V8ElementPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = arbaicaRet; + + arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + arbaicaRetObj.MakeWeak(0, V8Element::jsDestructor); + return arbaicaRetObj; - arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - arbaicaRetObj.MakeWeak(0, V8Element::jsDestructor); - return arbaicaRetObj; + } + bool V8Attr::hasInstance(v8::Handle<v8::Value> value) { + return getTmpl()->HasInstance(value); + } -} -bool V8Attr::hasInstance(v8::Handle<v8::Value> value) { - return getTmpl()->HasInstance(value); -} - -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Attr.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Attr.h index 9829023..e317698 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Attr.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Attr.h @@ -33,50 +33,50 @@ namespace DOM { class V8Attr { public: - struct V8AttrPrivate { - V8DOM* dom; - Arabica::DOM::Attr<std::string>* nativeObj; - }; - - V8_DESTRUCTOR(V8AttrPrivate); - static bool hasInstance(v8::Handle<v8::Value>); - - - static v8::Handle<v8::Value> nameAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> specifiedAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> valueAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static void valueAttrSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> ownerElementAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - - 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("Attr")); - tmpl->ReadOnlyPrototype(); - - v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); - v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); - (void)prototype; // surpress unused warnings - - instance->SetInternalFieldCount(1); - - instance->SetAccessor(v8::String::NewSymbol("name"), V8Attr::nameAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("specified"), V8Attr::specifiedAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("value"), V8Attr::valueAttrGetter, V8Attr::valueAttrSetter, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("ownerElement"), V8Attr::ownerElementAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - - - - tmpl->Inherit(V8Node::getTmpl()); - Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); - } - return Tmpl; - } + struct V8AttrPrivate { + V8DOM* dom; + Arabica::DOM::Attr<std::string>* nativeObj; + }; + + V8_DESTRUCTOR(V8AttrPrivate); + static bool hasInstance(v8::Handle<v8::Value>); + + + static v8::Handle<v8::Value> nameAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> specifiedAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> valueAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static void valueAttrSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> ownerElementAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + + 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("Attr")); + tmpl->ReadOnlyPrototype(); + + v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); + v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); + + instance->SetAccessor(v8::String::NewSymbol("name"), V8Attr::nameAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("specified"), V8Attr::specifiedAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("value"), V8Attr::valueAttrGetter, V8Attr::valueAttrSetter, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("ownerElement"), V8Attr::ownerElementAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + + + + tmpl->Inherit(V8Node::getTmpl()); + Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); + } + return Tmpl; + } }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CDATASection.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CDATASection.cpp index a9e5ac9..90495f4 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CDATASection.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CDATASection.cpp @@ -4,11 +4,11 @@ namespace Arabica { namespace DOM { -v8::Persistent<v8::FunctionTemplate> V8CDATASection::Tmpl; + v8::Persistent<v8::FunctionTemplate> V8CDATASection::Tmpl; -bool V8CDATASection::hasInstance(v8::Handle<v8::Value> value) { - return getTmpl()->HasInstance(value); -} + bool V8CDATASection::hasInstance(v8::Handle<v8::Value> value) { + return getTmpl()->HasInstance(value); + } -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CDATASection.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CDATASection.h index 3b95b84..f9767a0 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CDATASection.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CDATASection.h @@ -33,37 +33,37 @@ namespace DOM { class V8CDATASection { public: - struct V8CDATASectionPrivate { - V8DOM* dom; - Arabica::DOM::CDATASection<std::string>* nativeObj; - }; + struct V8CDATASectionPrivate { + V8DOM* dom; + Arabica::DOM::CDATASection<std::string>* nativeObj; + }; - V8_DESTRUCTOR(V8CDATASectionPrivate); - static bool hasInstance(v8::Handle<v8::Value>); + V8_DESTRUCTOR(V8CDATASectionPrivate); + static bool hasInstance(v8::Handle<v8::Value>); - 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("CDATASection")); - tmpl->ReadOnlyPrototype(); + 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("CDATASection")); + tmpl->ReadOnlyPrototype(); - v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); - v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); - (void)prototype; // surpress unused warnings + v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); + v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); - instance->SetInternalFieldCount(1); - - tmpl->Inherit(V8Text::getTmpl()); - Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); - } - return Tmpl; - } + tmpl->Inherit(V8Text::getTmpl()); + Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); + } + return Tmpl; + } }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CharacterData.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CharacterData.cpp index 459cf96..74c80ea 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CharacterData.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CharacterData.cpp @@ -4,102 +4,102 @@ namespace Arabica { namespace DOM { -v8::Persistent<v8::FunctionTemplate> V8CharacterData::Tmpl; + v8::Persistent<v8::FunctionTemplate> V8CharacterData::Tmpl; -v8::Handle<v8::Value> V8CharacterData::dataAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8CharacterDataPrivate* privData = V8DOM::toClassPtr<V8CharacterDataPrivate >(self->GetInternalField(0)); + v8::Handle<v8::Value> V8CharacterData::dataAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8CharacterDataPrivate* privData = V8DOM::toClassPtr<V8CharacterDataPrivate >(self->GetInternalField(0)); - return v8::String::New(privData->nativeObj->getData().c_str()); -} + return v8::String::New(privData->nativeObj->getData().c_str()); + } -void V8CharacterData::dataAttrSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8CharacterDataPrivate* privData = V8DOM::toClassPtr<V8CharacterDataPrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localData(value); - privData->nativeObj->setData(*localData); -} + void V8CharacterData::dataAttrSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8CharacterDataPrivate* privData = V8DOM::toClassPtr<V8CharacterDataPrivate >(self->GetInternalField(0)); + v8::String::AsciiValue localData(value); + privData->nativeObj->setData(*localData); + } -v8::Handle<v8::Value> V8CharacterData::lengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8CharacterDataPrivate* privData = V8DOM::toClassPtr<V8CharacterDataPrivate >(self->GetInternalField(0)); + v8::Handle<v8::Value> V8CharacterData::lengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8CharacterDataPrivate* privData = V8DOM::toClassPtr<V8CharacterDataPrivate >(self->GetInternalField(0)); - return v8::Integer::New(privData->nativeObj->getLength()); -} -v8::Handle<v8::Value> V8CharacterData::substringDataCallback(const v8::Arguments& args) { - if (args.Length() < 2) - throw V8Exception("Wrong number of arguments in substringData"); + return v8::Integer::New(privData->nativeObj->getLength()); + } + v8::Handle<v8::Value> V8CharacterData::substringDataCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in substringData"); - v8::Local<v8::Object> self = args.Holder(); - struct V8CharacterDataPrivate* privData = V8DOM::toClassPtr<V8CharacterDataPrivate >(self->GetInternalField(0)); - unsigned long localOffset = args[0]->ToNumber()->Uint32Value(); - unsigned long localCount = args[1]->ToNumber()->Uint32Value(); + v8::Local<v8::Object> self = args.Holder(); + struct V8CharacterDataPrivate* privData = V8DOM::toClassPtr<V8CharacterDataPrivate >(self->GetInternalField(0)); + unsigned long localOffset = args[0]->ToNumber()->Uint32Value(); + unsigned long localCount = args[1]->ToNumber()->Uint32Value(); - std::string retVal = privData->nativeObj->substringData(localOffset, localCount); + std::string retVal = privData->nativeObj->substringData(localOffset, localCount); - return v8::String::New(retVal.c_str()); -} + return v8::String::New(retVal.c_str()); + } -v8::Handle<v8::Value> V8CharacterData::appendDataCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in appendData"); + v8::Handle<v8::Value> V8CharacterData::appendDataCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in appendData"); - v8::Local<v8::Object> self = args.Holder(); - struct V8CharacterDataPrivate* privData = V8DOM::toClassPtr<V8CharacterDataPrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localArg(args[0]); + v8::Local<v8::Object> self = args.Holder(); + struct V8CharacterDataPrivate* privData = V8DOM::toClassPtr<V8CharacterDataPrivate >(self->GetInternalField(0)); + v8::String::AsciiValue localArg(args[0]); - privData->nativeObj->appendData(*localArg); + privData->nativeObj->appendData(*localArg); - return v8::Undefined(); -} + return v8::Undefined(); + } -v8::Handle<v8::Value> V8CharacterData::insertDataCallback(const v8::Arguments& args) { - if (args.Length() < 2) - throw V8Exception("Wrong number of arguments in insertData"); + v8::Handle<v8::Value> V8CharacterData::insertDataCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in insertData"); - v8::Local<v8::Object> self = args.Holder(); - struct V8CharacterDataPrivate* privData = V8DOM::toClassPtr<V8CharacterDataPrivate >(self->GetInternalField(0)); - unsigned long localOffset = args[0]->ToNumber()->Uint32Value(); - v8::String::AsciiValue localArg(args[1]); + v8::Local<v8::Object> self = args.Holder(); + struct V8CharacterDataPrivate* privData = V8DOM::toClassPtr<V8CharacterDataPrivate >(self->GetInternalField(0)); + unsigned long localOffset = args[0]->ToNumber()->Uint32Value(); + v8::String::AsciiValue localArg(args[1]); - privData->nativeObj->insertData(localOffset, *localArg); + privData->nativeObj->insertData(localOffset, *localArg); - return v8::Undefined(); -} + return v8::Undefined(); + } -v8::Handle<v8::Value> V8CharacterData::deleteDataCallback(const v8::Arguments& args) { - if (args.Length() < 2) - throw V8Exception("Wrong number of arguments in deleteData"); + v8::Handle<v8::Value> V8CharacterData::deleteDataCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in deleteData"); - v8::Local<v8::Object> self = args.Holder(); - struct V8CharacterDataPrivate* privData = V8DOM::toClassPtr<V8CharacterDataPrivate >(self->GetInternalField(0)); - unsigned long localOffset = args[0]->ToNumber()->Uint32Value(); - unsigned long localCount = args[1]->ToNumber()->Uint32Value(); + v8::Local<v8::Object> self = args.Holder(); + struct V8CharacterDataPrivate* privData = V8DOM::toClassPtr<V8CharacterDataPrivate >(self->GetInternalField(0)); + unsigned long localOffset = args[0]->ToNumber()->Uint32Value(); + unsigned long localCount = args[1]->ToNumber()->Uint32Value(); - privData->nativeObj->deleteData(localOffset, localCount); + privData->nativeObj->deleteData(localOffset, localCount); - return v8::Undefined(); -} + return v8::Undefined(); + } -v8::Handle<v8::Value> V8CharacterData::replaceDataCallback(const v8::Arguments& args) { - if (args.Length() < 3) - throw V8Exception("Wrong number of arguments in replaceData"); + v8::Handle<v8::Value> V8CharacterData::replaceDataCallback(const v8::Arguments& args) { + if (args.Length() < 3) + throw V8Exception("Wrong number of arguments in replaceData"); - v8::Local<v8::Object> self = args.Holder(); - struct V8CharacterDataPrivate* privData = V8DOM::toClassPtr<V8CharacterDataPrivate >(self->GetInternalField(0)); - unsigned long localOffset = args[0]->ToNumber()->Uint32Value(); - unsigned long localCount = args[1]->ToNumber()->Uint32Value(); - v8::String::AsciiValue localArg(args[2]); + v8::Local<v8::Object> self = args.Holder(); + struct V8CharacterDataPrivate* privData = V8DOM::toClassPtr<V8CharacterDataPrivate >(self->GetInternalField(0)); + unsigned long localOffset = args[0]->ToNumber()->Uint32Value(); + unsigned long localCount = args[1]->ToNumber()->Uint32Value(); + v8::String::AsciiValue localArg(args[2]); - privData->nativeObj->replaceData(localOffset, localCount, *localArg); + privData->nativeObj->replaceData(localOffset, localCount, *localArg); - return v8::Undefined(); -} + return v8::Undefined(); + } -bool V8CharacterData::hasInstance(v8::Handle<v8::Value> value) { - return getTmpl()->HasInstance(value); -} + bool V8CharacterData::hasInstance(v8::Handle<v8::Value> value) { + return getTmpl()->HasInstance(value); + } -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CharacterData.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CharacterData.h index 6c51ca7..fe93896 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CharacterData.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CharacterData.h @@ -33,59 +33,59 @@ namespace DOM { class V8CharacterData { public: - struct V8CharacterDataPrivate { - V8DOM* dom; - Arabica::DOM::CharacterData<std::string>* nativeObj; - }; - - V8_DESTRUCTOR(V8CharacterDataPrivate); - static bool hasInstance(v8::Handle<v8::Value>); - - static v8::Handle<v8::Value> substringDataCallback(const v8::Arguments&); - static v8::Handle<v8::Value> appendDataCallback(const v8::Arguments&); - static v8::Handle<v8::Value> insertDataCallback(const v8::Arguments&); - static v8::Handle<v8::Value> deleteDataCallback(const v8::Arguments&); - static v8::Handle<v8::Value> replaceDataCallback(const v8::Arguments&); - - static v8::Handle<v8::Value> dataAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static void dataAttrSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> lengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - - 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("CharacterData")); - tmpl->ReadOnlyPrototype(); - - v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); - v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); - (void)prototype; // surpress unused warnings - - instance->SetInternalFieldCount(1); - - instance->SetAccessor(v8::String::NewSymbol("data"), V8CharacterData::dataAttrGetter, V8CharacterData::dataAttrSetter, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("length"), V8CharacterData::lengthAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - - prototype->Set(v8::String::NewSymbol("substringData"), - v8::FunctionTemplate::New(V8CharacterData::substringDataCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("appendData"), - v8::FunctionTemplate::New(V8CharacterData::appendDataCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("insertData"), - v8::FunctionTemplate::New(V8CharacterData::insertDataCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("deleteData"), - v8::FunctionTemplate::New(V8CharacterData::deleteDataCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("replaceData"), - v8::FunctionTemplate::New(V8CharacterData::replaceDataCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - - - tmpl->Inherit(V8Node::getTmpl()); - Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); - } - return Tmpl; - } + struct V8CharacterDataPrivate { + V8DOM* dom; + Arabica::DOM::CharacterData<std::string>* nativeObj; + }; + + V8_DESTRUCTOR(V8CharacterDataPrivate); + static bool hasInstance(v8::Handle<v8::Value>); + + static v8::Handle<v8::Value> substringDataCallback(const v8::Arguments&); + static v8::Handle<v8::Value> appendDataCallback(const v8::Arguments&); + static v8::Handle<v8::Value> insertDataCallback(const v8::Arguments&); + static v8::Handle<v8::Value> deleteDataCallback(const v8::Arguments&); + static v8::Handle<v8::Value> replaceDataCallback(const v8::Arguments&); + + static v8::Handle<v8::Value> dataAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static void dataAttrSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> lengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + + 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("CharacterData")); + tmpl->ReadOnlyPrototype(); + + v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); + v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); + + instance->SetAccessor(v8::String::NewSymbol("data"), V8CharacterData::dataAttrGetter, V8CharacterData::dataAttrSetter, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("length"), V8CharacterData::lengthAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + + prototype->Set(v8::String::NewSymbol("substringData"), + v8::FunctionTemplate::New(V8CharacterData::substringDataCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("appendData"), + v8::FunctionTemplate::New(V8CharacterData::appendDataCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("insertData"), + v8::FunctionTemplate::New(V8CharacterData::insertDataCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("deleteData"), + v8::FunctionTemplate::New(V8CharacterData::deleteDataCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("replaceData"), + v8::FunctionTemplate::New(V8CharacterData::replaceDataCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + + + tmpl->Inherit(V8Node::getTmpl()); + Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); + } + return Tmpl; + } }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Comment.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Comment.cpp index f754ea7..e470a70 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Comment.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Comment.cpp @@ -4,11 +4,11 @@ namespace Arabica { namespace DOM { -v8::Persistent<v8::FunctionTemplate> V8Comment::Tmpl; + v8::Persistent<v8::FunctionTemplate> V8Comment::Tmpl; -bool V8Comment::hasInstance(v8::Handle<v8::Value> value) { - return getTmpl()->HasInstance(value); -} + bool V8Comment::hasInstance(v8::Handle<v8::Value> value) { + return getTmpl()->HasInstance(value); + } -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Comment.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Comment.h index 074da74..c659150 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Comment.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Comment.h @@ -33,37 +33,37 @@ namespace DOM { class V8Comment { public: - struct V8CommentPrivate { - V8DOM* dom; - Arabica::DOM::Comment<std::string>* nativeObj; - }; + struct V8CommentPrivate { + V8DOM* dom; + Arabica::DOM::Comment<std::string>* nativeObj; + }; - V8_DESTRUCTOR(V8CommentPrivate); - static bool hasInstance(v8::Handle<v8::Value>); + V8_DESTRUCTOR(V8CommentPrivate); + static bool hasInstance(v8::Handle<v8::Value>); - 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("Comment")); - tmpl->ReadOnlyPrototype(); + 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("Comment")); + tmpl->ReadOnlyPrototype(); - v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); - v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); - (void)prototype; // surpress unused warnings + v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); + v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); - instance->SetInternalFieldCount(1); - - tmpl->Inherit(V8CharacterData::getTmpl()); - Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); - } - return Tmpl; - } + tmpl->Inherit(V8CharacterData::getTmpl()); + Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); + } + return Tmpl; + } }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOMImplementation.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOMImplementation.cpp index f7a7575..0f81958 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOMImplementation.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOMImplementation.cpp @@ -5,77 +5,77 @@ namespace Arabica { namespace DOM { -v8::Persistent<v8::FunctionTemplate> V8DOMImplementation::Tmpl; + v8::Persistent<v8::FunctionTemplate> V8DOMImplementation::Tmpl; -v8::Handle<v8::Value> V8DOMImplementation::hasFeatureCallback(const v8::Arguments& args) { - if (args.Length() < 2) - throw V8Exception("Wrong number of arguments in hasFeature"); + v8::Handle<v8::Value> V8DOMImplementation::hasFeatureCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in hasFeature"); - v8::Local<v8::Object> self = args.Holder(); - struct V8DOMImplementationPrivate* privData = V8DOM::toClassPtr<V8DOMImplementationPrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localFeature(args[0]); - v8::String::AsciiValue localVersion(args[1]); + v8::Local<v8::Object> self = args.Holder(); + struct V8DOMImplementationPrivate* privData = V8DOM::toClassPtr<V8DOMImplementationPrivate >(self->GetInternalField(0)); + v8::String::AsciiValue localFeature(args[0]); + v8::String::AsciiValue localVersion(args[1]); - bool retVal = privData->nativeObj->hasFeature(*localFeature, *localVersion); + bool retVal = privData->nativeObj->hasFeature(*localFeature, *localVersion); - return v8::Boolean::New(retVal); -} + return v8::Boolean::New(retVal); + } -v8::Handle<v8::Value> V8DOMImplementation::createDocumentTypeCallback(const v8::Arguments& args) { - if (args.Length() < 3) - throw V8Exception("Wrong number of arguments in createDocumentType"); + v8::Handle<v8::Value> V8DOMImplementation::createDocumentTypeCallback(const v8::Arguments& args) { + if (args.Length() < 3) + throw V8Exception("Wrong number of arguments in createDocumentType"); - v8::Local<v8::Object> self = args.Holder(); - struct V8DOMImplementationPrivate* privData = V8DOM::toClassPtr<V8DOMImplementationPrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localQualifiedName(args[0]); - v8::String::AsciiValue localPublicId(args[1]); - v8::String::AsciiValue localSystemId(args[2]); + v8::Local<v8::Object> self = args.Holder(); + struct V8DOMImplementationPrivate* privData = V8DOM::toClassPtr<V8DOMImplementationPrivate >(self->GetInternalField(0)); + v8::String::AsciiValue localQualifiedName(args[0]); + v8::String::AsciiValue localPublicId(args[1]); + v8::String::AsciiValue localSystemId(args[2]); - Arabica::DOM::DocumentType<std::string>* retVal = new Arabica::DOM::DocumentType<std::string>(privData->nativeObj->createDocumentType(*localQualifiedName, *localPublicId, *localSystemId)); - v8::Handle<v8::Function> retCtor = V8DocumentType::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + Arabica::DOM::DocumentType<std::string>* retVal = new Arabica::DOM::DocumentType<std::string>(privData->nativeObj->createDocumentType(*localQualifiedName, *localPublicId, *localSystemId)); + v8::Handle<v8::Function> retCtor = V8DocumentType::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); - struct V8DocumentType::V8DocumentTypePrivate* retPrivData = new V8DocumentType::V8DocumentTypePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct V8DocumentType::V8DocumentTypePrivate* retPrivData = new V8DocumentType::V8DocumentTypePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, V8DocumentType::jsDestructor); - return retObj; + retObj.MakeWeak(0, V8DocumentType::jsDestructor); + return retObj; -} + } -v8::Handle<v8::Value> V8DOMImplementation::createDocumentCallback(const v8::Arguments& args) { - if (args.Length() < 3) - throw V8Exception("Wrong number of arguments in createDocument"); - if (!(V8DocumentType::hasInstance(args[2]))) - throw V8Exception("Parameter mismatch while calling createDocument"); + v8::Handle<v8::Value> V8DOMImplementation::createDocumentCallback(const v8::Arguments& args) { + if (args.Length() < 3) + throw V8Exception("Wrong number of arguments in createDocument"); + if (!(V8DocumentType::hasInstance(args[2]))) + throw V8Exception("Parameter mismatch while calling createDocument"); - v8::Local<v8::Object> self = args.Holder(); - struct V8DOMImplementationPrivate* privData = V8DOM::toClassPtr<V8DOMImplementationPrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localNamespaceURI(args[0]); - v8::String::AsciiValue localQualifiedName(args[1]); - Arabica::DOM::DocumentType<std::string>* localDoctype = V8DOM::toClassPtr<V8DocumentType::V8DocumentTypePrivate >(args[2]->ToObject()->GetInternalField(0))->nativeObj; + v8::Local<v8::Object> self = args.Holder(); + struct V8DOMImplementationPrivate* privData = V8DOM::toClassPtr<V8DOMImplementationPrivate >(self->GetInternalField(0)); + v8::String::AsciiValue localNamespaceURI(args[0]); + v8::String::AsciiValue localQualifiedName(args[1]); + Arabica::DOM::DocumentType<std::string>* localDoctype = V8DOM::toClassPtr<V8DocumentType::V8DocumentTypePrivate >(args[2]->ToObject()->GetInternalField(0))->nativeObj; - Arabica::DOM::Document<std::string>* retVal = new Arabica::DOM::Document<std::string>(privData->nativeObj->createDocument(*localNamespaceURI, *localQualifiedName, *localDoctype)); - v8::Handle<v8::Function> retCtor = V8Document::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + Arabica::DOM::Document<std::string>* retVal = new Arabica::DOM::Document<std::string>(privData->nativeObj->createDocument(*localNamespaceURI, *localQualifiedName, *localDoctype)); + v8::Handle<v8::Function> retCtor = V8Document::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); - struct V8Document::V8DocumentPrivate* retPrivData = new V8Document::V8DocumentPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct V8Document::V8DocumentPrivate* retPrivData = new V8Document::V8DocumentPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, V8Document::jsDestructor); - return retObj; + retObj.MakeWeak(0, V8Document::jsDestructor); + return retObj; -} + } -bool V8DOMImplementation::hasInstance(v8::Handle<v8::Value> value) { - return getTmpl()->HasInstance(value); -} + bool V8DOMImplementation::hasInstance(v8::Handle<v8::Value> value) { + return getTmpl()->HasInstance(value); + } -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOMImplementation.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOMImplementation.h index 5c58e22..6fb8c7e 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOMImplementation.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOMImplementation.h @@ -32,45 +32,45 @@ namespace DOM { class V8DOMImplementation { public: - struct V8DOMImplementationPrivate { - V8DOM* dom; - Arabica::DOM::DOMImplementation<std::string>* nativeObj; - }; + struct V8DOMImplementationPrivate { + V8DOM* dom; + Arabica::DOM::DOMImplementation<std::string>* nativeObj; + }; - V8_DESTRUCTOR(V8DOMImplementationPrivate); - static bool hasInstance(v8::Handle<v8::Value>); + V8_DESTRUCTOR(V8DOMImplementationPrivate); + static bool hasInstance(v8::Handle<v8::Value>); - static v8::Handle<v8::Value> hasFeatureCallback(const v8::Arguments&); - static v8::Handle<v8::Value> createDocumentTypeCallback(const v8::Arguments&); - static v8::Handle<v8::Value> createDocumentCallback(const v8::Arguments&); + static v8::Handle<v8::Value> hasFeatureCallback(const v8::Arguments&); + static v8::Handle<v8::Value> createDocumentTypeCallback(const v8::Arguments&); + static v8::Handle<v8::Value> createDocumentCallback(const v8::Arguments&); - 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("DOMImplementation")); - tmpl->ReadOnlyPrototype(); + 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("DOMImplementation")); + tmpl->ReadOnlyPrototype(); - v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); - v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); - (void)prototype; // surpress unused warnings + v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); + v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); - instance->SetInternalFieldCount(1); + prototype->Set(v8::String::NewSymbol("hasFeature"), + v8::FunctionTemplate::New(V8DOMImplementation::hasFeatureCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("createDocumentType"), + v8::FunctionTemplate::New(V8DOMImplementation::createDocumentTypeCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("createDocument"), + v8::FunctionTemplate::New(V8DOMImplementation::createDocumentCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("hasFeature"), - v8::FunctionTemplate::New(V8DOMImplementation::hasFeatureCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("createDocumentType"), - v8::FunctionTemplate::New(V8DOMImplementation::createDocumentTypeCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("createDocument"), - v8::FunctionTemplate::New(V8DOMImplementation::createDocumentCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - - Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); - } - return Tmpl; - } + Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); + } + return Tmpl; + } }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.cpp index 06191ea..d9d123a 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.cpp @@ -15,397 +15,397 @@ namespace Arabica { namespace DOM { -v8::Persistent<v8::FunctionTemplate> V8Document::Tmpl; + v8::Persistent<v8::FunctionTemplate> V8Document::Tmpl; -v8::Handle<v8::Value> V8Document::doctypeAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0)); + v8::Handle<v8::Value> V8Document::doctypeAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0)); - if (!privData->nativeObj->getDoctype()) return v8::Undefined(); - Arabica::DOM::DocumentType<std::string>* arbaicaRet = new Arabica::DOM::DocumentType<std::string>(privData->nativeObj->getDoctype()); + if (!privData->nativeObj->getDoctype()) return v8::Undefined(); + Arabica::DOM::DocumentType<std::string>* arbaicaRet = new Arabica::DOM::DocumentType<std::string>(privData->nativeObj->getDoctype()); - v8::Handle<v8::Function> arbaicaRetCtor = V8DocumentType::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance()); + v8::Handle<v8::Function> arbaicaRetCtor = V8DocumentType::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance()); - struct V8DocumentType::V8DocumentTypePrivate* retPrivData = new V8DocumentType::V8DocumentTypePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = arbaicaRet; + struct V8DocumentType::V8DocumentTypePrivate* retPrivData = new V8DocumentType::V8DocumentTypePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = arbaicaRet; + + arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + arbaicaRetObj.MakeWeak(0, V8DocumentType::jsDestructor); + return arbaicaRetObj; - arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - arbaicaRetObj.MakeWeak(0, V8DocumentType::jsDestructor); - return arbaicaRetObj; + } -} + v8::Handle<v8::Value> V8Document::implementationAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0)); -v8::Handle<v8::Value> V8Document::implementationAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0)); + if (!privData->nativeObj->getImplementation()) return v8::Undefined(); + Arabica::DOM::DOMImplementation<std::string>* arbaicaRet = new Arabica::DOM::DOMImplementation<std::string>(privData->nativeObj->getImplementation()); - if (!privData->nativeObj->getImplementation()) return v8::Undefined(); - Arabica::DOM::DOMImplementation<std::string>* arbaicaRet = new Arabica::DOM::DOMImplementation<std::string>(privData->nativeObj->getImplementation()); + v8::Handle<v8::Function> arbaicaRetCtor = V8DOMImplementation::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance()); - v8::Handle<v8::Function> arbaicaRetCtor = V8DOMImplementation::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance()); + struct V8DOMImplementation::V8DOMImplementationPrivate* retPrivData = new V8DOMImplementation::V8DOMImplementationPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = arbaicaRet; + + arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + arbaicaRetObj.MakeWeak(0, V8DOMImplementation::jsDestructor); + return arbaicaRetObj; - struct V8DOMImplementation::V8DOMImplementationPrivate* retPrivData = new V8DOMImplementation::V8DOMImplementationPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = arbaicaRet; + } - arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - arbaicaRetObj.MakeWeak(0, V8DOMImplementation::jsDestructor); - return arbaicaRetObj; + v8::Handle<v8::Value> V8Document::documentElementAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0)); -} + if (!privData->nativeObj->getDocumentElement()) return v8::Undefined(); + Arabica::DOM::Element<std::string>* arbaicaRet = new Arabica::DOM::Element<std::string>(privData->nativeObj->getDocumentElement()); -v8::Handle<v8::Value> V8Document::documentElementAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0)); + v8::Handle<v8::Function> arbaicaRetCtor = V8Element::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance()); - if (!privData->nativeObj->getDocumentElement()) return v8::Undefined(); - Arabica::DOM::Element<std::string>* arbaicaRet = new Arabica::DOM::Element<std::string>(privData->nativeObj->getDocumentElement()); + struct V8Element::V8ElementPrivate* retPrivData = new V8Element::V8ElementPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = arbaicaRet; + + arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + arbaicaRetObj.MakeWeak(0, V8Element::jsDestructor); + return arbaicaRetObj; - v8::Handle<v8::Function> arbaicaRetCtor = V8Element::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance()); + } + v8::Handle<v8::Value> V8Document::createElementCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in createElement"); - struct V8Element::V8ElementPrivate* retPrivData = new V8Element::V8ElementPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = arbaicaRet; + v8::Local<v8::Object> self = args.Holder(); + struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0)); + v8::String::AsciiValue localTagName(args[0]); - arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - arbaicaRetObj.MakeWeak(0, V8Element::jsDestructor); - return arbaicaRetObj; + Arabica::DOM::Element<std::string>* retVal = new Arabica::DOM::Element<std::string>(privData->nativeObj->createElement(*localTagName)); + v8::Handle<v8::Function> retCtor = V8Element::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); -} -v8::Handle<v8::Value> V8Document::createElementCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in createElement"); + struct V8Element::V8ElementPrivate* retPrivData = new V8Element::V8ElementPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - v8::Local<v8::Object> self = args.Holder(); - struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localTagName(args[0]); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - Arabica::DOM::Element<std::string>* retVal = new Arabica::DOM::Element<std::string>(privData->nativeObj->createElement(*localTagName)); - v8::Handle<v8::Function> retCtor = V8Element::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + retObj.MakeWeak(0, V8Element::jsDestructor); + return retObj; - struct V8Element::V8ElementPrivate* retPrivData = new V8Element::V8ElementPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + } - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + v8::Handle<v8::Value> V8Document::createDocumentFragmentCallback(const v8::Arguments& args) { - retObj.MakeWeak(0, V8Element::jsDestructor); - return retObj; + v8::Local<v8::Object> self = args.Holder(); + struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0)); -} + Arabica::DOM::DocumentFragment<std::string>* retVal = new Arabica::DOM::DocumentFragment<std::string>(privData->nativeObj->createDocumentFragment()); + v8::Handle<v8::Function> retCtor = V8DocumentFragment::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); -v8::Handle<v8::Value> V8Document::createDocumentFragmentCallback(const v8::Arguments& args) { + struct V8DocumentFragment::V8DocumentFragmentPrivate* retPrivData = new V8DocumentFragment::V8DocumentFragmentPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - v8::Local<v8::Object> self = args.Holder(); - struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - Arabica::DOM::DocumentFragment<std::string>* retVal = new Arabica::DOM::DocumentFragment<std::string>(privData->nativeObj->createDocumentFragment()); - v8::Handle<v8::Function> retCtor = V8DocumentFragment::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + retObj.MakeWeak(0, V8DocumentFragment::jsDestructor); + return retObj; - struct V8DocumentFragment::V8DocumentFragmentPrivate* retPrivData = new V8DocumentFragment::V8DocumentFragmentPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + } - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + v8::Handle<v8::Value> V8Document::createTextNodeCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in createTextNode"); - retObj.MakeWeak(0, V8DocumentFragment::jsDestructor); - return retObj; + v8::Local<v8::Object> self = args.Holder(); + struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0)); + v8::String::AsciiValue localData(args[0]); -} + Arabica::DOM::Text<std::string>* retVal = new Arabica::DOM::Text<std::string>(privData->nativeObj->createTextNode(*localData)); + v8::Handle<v8::Function> retCtor = V8Text::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); -v8::Handle<v8::Value> V8Document::createTextNodeCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in createTextNode"); + struct V8Text::V8TextPrivate* retPrivData = new V8Text::V8TextPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - v8::Local<v8::Object> self = args.Holder(); - struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localData(args[0]); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - Arabica::DOM::Text<std::string>* retVal = new Arabica::DOM::Text<std::string>(privData->nativeObj->createTextNode(*localData)); - v8::Handle<v8::Function> retCtor = V8Text::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + retObj.MakeWeak(0, V8Text::jsDestructor); + return retObj; - struct V8Text::V8TextPrivate* retPrivData = new V8Text::V8TextPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + } - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + v8::Handle<v8::Value> V8Document::createCommentCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in createComment"); - retObj.MakeWeak(0, V8Text::jsDestructor); - return retObj; + v8::Local<v8::Object> self = args.Holder(); + struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0)); + v8::String::AsciiValue localData(args[0]); -} + Arabica::DOM::Comment<std::string>* retVal = new Arabica::DOM::Comment<std::string>(privData->nativeObj->createComment(*localData)); + v8::Handle<v8::Function> retCtor = V8Comment::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); -v8::Handle<v8::Value> V8Document::createCommentCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in createComment"); + struct V8Comment::V8CommentPrivate* retPrivData = new V8Comment::V8CommentPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - v8::Local<v8::Object> self = args.Holder(); - struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localData(args[0]); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - Arabica::DOM::Comment<std::string>* retVal = new Arabica::DOM::Comment<std::string>(privData->nativeObj->createComment(*localData)); - v8::Handle<v8::Function> retCtor = V8Comment::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + retObj.MakeWeak(0, V8Comment::jsDestructor); + return retObj; - struct V8Comment::V8CommentPrivate* retPrivData = new V8Comment::V8CommentPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + } - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + v8::Handle<v8::Value> V8Document::createCDATASectionCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in createCDATASection"); - retObj.MakeWeak(0, V8Comment::jsDestructor); - return retObj; + v8::Local<v8::Object> self = args.Holder(); + struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0)); + v8::String::AsciiValue localData(args[0]); -} + Arabica::DOM::CDATASection<std::string>* retVal = new Arabica::DOM::CDATASection<std::string>(privData->nativeObj->createCDATASection(*localData)); + v8::Handle<v8::Function> retCtor = V8CDATASection::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); -v8::Handle<v8::Value> V8Document::createCDATASectionCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in createCDATASection"); + struct V8CDATASection::V8CDATASectionPrivate* retPrivData = new V8CDATASection::V8CDATASectionPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - v8::Local<v8::Object> self = args.Holder(); - struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localData(args[0]); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - Arabica::DOM::CDATASection<std::string>* retVal = new Arabica::DOM::CDATASection<std::string>(privData->nativeObj->createCDATASection(*localData)); - v8::Handle<v8::Function> retCtor = V8CDATASection::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + retObj.MakeWeak(0, V8CDATASection::jsDestructor); + return retObj; - struct V8CDATASection::V8CDATASectionPrivate* retPrivData = new V8CDATASection::V8CDATASectionPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + } - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + v8::Handle<v8::Value> V8Document::createProcessingInstructionCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in createProcessingInstruction"); - retObj.MakeWeak(0, V8CDATASection::jsDestructor); - return retObj; + v8::Local<v8::Object> self = args.Holder(); + struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0)); + v8::String::AsciiValue localTarget(args[0]); + v8::String::AsciiValue localData(args[1]); -} + Arabica::DOM::ProcessingInstruction<std::string>* retVal = new Arabica::DOM::ProcessingInstruction<std::string>(privData->nativeObj->createProcessingInstruction(*localTarget, *localData)); + v8::Handle<v8::Function> retCtor = V8ProcessingInstruction::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); -v8::Handle<v8::Value> V8Document::createProcessingInstructionCallback(const v8::Arguments& args) { - if (args.Length() < 2) - throw V8Exception("Wrong number of arguments in createProcessingInstruction"); + struct V8ProcessingInstruction::V8ProcessingInstructionPrivate* retPrivData = new V8ProcessingInstruction::V8ProcessingInstructionPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - v8::Local<v8::Object> self = args.Holder(); - struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localTarget(args[0]); - v8::String::AsciiValue localData(args[1]); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - Arabica::DOM::ProcessingInstruction<std::string>* retVal = new Arabica::DOM::ProcessingInstruction<std::string>(privData->nativeObj->createProcessingInstruction(*localTarget, *localData)); - v8::Handle<v8::Function> retCtor = V8ProcessingInstruction::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + retObj.MakeWeak(0, V8ProcessingInstruction::jsDestructor); + return retObj; - struct V8ProcessingInstruction::V8ProcessingInstructionPrivate* retPrivData = new V8ProcessingInstruction::V8ProcessingInstructionPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + } - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + v8::Handle<v8::Value> V8Document::createAttributeCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in createAttribute"); - retObj.MakeWeak(0, V8ProcessingInstruction::jsDestructor); - return retObj; + v8::Local<v8::Object> self = args.Holder(); + struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0)); + v8::String::AsciiValue localName(args[0]); -} + Arabica::DOM::Attr<std::string>* retVal = new Arabica::DOM::Attr<std::string>(privData->nativeObj->createAttribute(*localName)); + v8::Handle<v8::Function> retCtor = V8Attr::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); -v8::Handle<v8::Value> V8Document::createAttributeCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in createAttribute"); + struct V8Attr::V8AttrPrivate* retPrivData = new V8Attr::V8AttrPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - v8::Local<v8::Object> self = args.Holder(); - struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localName(args[0]); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - Arabica::DOM::Attr<std::string>* retVal = new Arabica::DOM::Attr<std::string>(privData->nativeObj->createAttribute(*localName)); - v8::Handle<v8::Function> retCtor = V8Attr::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + retObj.MakeWeak(0, V8Attr::jsDestructor); + return retObj; - struct V8Attr::V8AttrPrivate* retPrivData = new V8Attr::V8AttrPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + } - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + v8::Handle<v8::Value> V8Document::createEntityReferenceCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in createEntityReference"); - retObj.MakeWeak(0, V8Attr::jsDestructor); - return retObj; + v8::Local<v8::Object> self = args.Holder(); + struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0)); + v8::String::AsciiValue localName(args[0]); -} + Arabica::DOM::EntityReference<std::string>* retVal = new Arabica::DOM::EntityReference<std::string>(privData->nativeObj->createEntityReference(*localName)); + v8::Handle<v8::Function> retCtor = V8EntityReference::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); -v8::Handle<v8::Value> V8Document::createEntityReferenceCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in createEntityReference"); + struct V8EntityReference::V8EntityReferencePrivate* retPrivData = new V8EntityReference::V8EntityReferencePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - v8::Local<v8::Object> self = args.Holder(); - struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localName(args[0]); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - Arabica::DOM::EntityReference<std::string>* retVal = new Arabica::DOM::EntityReference<std::string>(privData->nativeObj->createEntityReference(*localName)); - v8::Handle<v8::Function> retCtor = V8EntityReference::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + retObj.MakeWeak(0, V8EntityReference::jsDestructor); + return retObj; - struct V8EntityReference::V8EntityReferencePrivate* retPrivData = new V8EntityReference::V8EntityReferencePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + } - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + v8::Handle<v8::Value> V8Document::getElementsByTagNameCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in getElementsByTagName"); - retObj.MakeWeak(0, V8EntityReference::jsDestructor); - return retObj; + v8::Local<v8::Object> self = args.Holder(); + struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0)); + v8::String::AsciiValue localTagname(args[0]); -} + Arabica::DOM::NodeList<std::string>* retVal = new Arabica::DOM::NodeList<std::string>(privData->nativeObj->getElementsByTagName(*localTagname)); + v8::Handle<v8::Function> retCtor = V8NodeList::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); -v8::Handle<v8::Value> V8Document::getElementsByTagNameCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in getElementsByTagName"); + struct V8NodeList::V8NodeListPrivate* retPrivData = new V8NodeList::V8NodeListPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - v8::Local<v8::Object> self = args.Holder(); - struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localTagname(args[0]); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - Arabica::DOM::NodeList<std::string>* retVal = new Arabica::DOM::NodeList<std::string>(privData->nativeObj->getElementsByTagName(*localTagname)); - v8::Handle<v8::Function> retCtor = V8NodeList::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + retObj.MakeWeak(0, V8NodeList::jsDestructor); + return retObj; - struct V8NodeList::V8NodeListPrivate* retPrivData = new V8NodeList::V8NodeListPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + } - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + v8::Handle<v8::Value> V8Document::importNodeCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in importNode"); + if (!(V8Node::hasInstance(args[0]))) + throw V8Exception("Parameter mismatch while calling importNode"); - retObj.MakeWeak(0, V8NodeList::jsDestructor); - return retObj; + v8::Local<v8::Object> self = args.Holder(); + struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0)); + Arabica::DOM::Node<std::string>* localImportedNode = V8DOM::toClassPtr<V8Node::V8NodePrivate >(args[0]->ToObject()->GetInternalField(0))->nativeObj; + bool localDeep = args[1]->ToBoolean()->BooleanValue(); -} + Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->importNode(*localImportedNode, localDeep)); + v8::Handle<v8::Function> retCtor = V8Node::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); -v8::Handle<v8::Value> V8Document::importNodeCallback(const v8::Arguments& args) { - if (args.Length() < 2) - throw V8Exception("Wrong number of arguments in importNode"); - if (!(V8Node::hasInstance(args[0]))) - throw V8Exception("Parameter mismatch while calling importNode"); + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - v8::Local<v8::Object> self = args.Holder(); - struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0)); - Arabica::DOM::Node<std::string>* localImportedNode = V8DOM::toClassPtr<V8Node::V8NodePrivate >(args[0]->ToObject()->GetInternalField(0))->nativeObj; - bool localDeep = args[1]->ToBoolean()->BooleanValue(); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->importNode(*localImportedNode, localDeep)); - v8::Handle<v8::Function> retCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + retObj.MakeWeak(0, V8Node::jsDestructor); + return retObj; - struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + } - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + v8::Handle<v8::Value> V8Document::createElementNSCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in createElementNS"); - retObj.MakeWeak(0, V8Node::jsDestructor); - return retObj; + v8::Local<v8::Object> self = args.Holder(); + struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0)); + v8::String::AsciiValue localNamespaceURI(args[0]); + v8::String::AsciiValue localQualifiedName(args[1]); -} + Arabica::DOM::Element<std::string>* retVal = new Arabica::DOM::Element<std::string>(privData->nativeObj->createElementNS(*localNamespaceURI, *localQualifiedName)); + v8::Handle<v8::Function> retCtor = V8Element::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); -v8::Handle<v8::Value> V8Document::createElementNSCallback(const v8::Arguments& args) { - if (args.Length() < 2) - throw V8Exception("Wrong number of arguments in createElementNS"); + struct V8Element::V8ElementPrivate* retPrivData = new V8Element::V8ElementPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - v8::Local<v8::Object> self = args.Holder(); - struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localNamespaceURI(args[0]); - v8::String::AsciiValue localQualifiedName(args[1]); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - Arabica::DOM::Element<std::string>* retVal = new Arabica::DOM::Element<std::string>(privData->nativeObj->createElementNS(*localNamespaceURI, *localQualifiedName)); - v8::Handle<v8::Function> retCtor = V8Element::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + retObj.MakeWeak(0, V8Element::jsDestructor); + return retObj; - struct V8Element::V8ElementPrivate* retPrivData = new V8Element::V8ElementPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + } - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + v8::Handle<v8::Value> V8Document::createAttributeNSCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in createAttributeNS"); - retObj.MakeWeak(0, V8Element::jsDestructor); - return retObj; + v8::Local<v8::Object> self = args.Holder(); + struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0)); + v8::String::AsciiValue localNamespaceURI(args[0]); + v8::String::AsciiValue localQualifiedName(args[1]); -} + Arabica::DOM::Attr<std::string>* retVal = new Arabica::DOM::Attr<std::string>(privData->nativeObj->createAttributeNS(*localNamespaceURI, *localQualifiedName)); + v8::Handle<v8::Function> retCtor = V8Attr::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); -v8::Handle<v8::Value> V8Document::createAttributeNSCallback(const v8::Arguments& args) { - if (args.Length() < 2) - throw V8Exception("Wrong number of arguments in createAttributeNS"); + struct V8Attr::V8AttrPrivate* retPrivData = new V8Attr::V8AttrPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - v8::Local<v8::Object> self = args.Holder(); - struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localNamespaceURI(args[0]); - v8::String::AsciiValue localQualifiedName(args[1]); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - Arabica::DOM::Attr<std::string>* retVal = new Arabica::DOM::Attr<std::string>(privData->nativeObj->createAttributeNS(*localNamespaceURI, *localQualifiedName)); - v8::Handle<v8::Function> retCtor = V8Attr::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + retObj.MakeWeak(0, V8Attr::jsDestructor); + return retObj; - struct V8Attr::V8AttrPrivate* retPrivData = new V8Attr::V8AttrPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + } - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + v8::Handle<v8::Value> V8Document::getElementsByTagNameNSCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in getElementsByTagNameNS"); - retObj.MakeWeak(0, V8Attr::jsDestructor); - return retObj; + v8::Local<v8::Object> self = args.Holder(); + struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0)); + v8::String::AsciiValue localNamespaceURI(args[0]); + v8::String::AsciiValue localLocalName(args[1]); -} + Arabica::DOM::NodeList<std::string>* retVal = new Arabica::DOM::NodeList<std::string>(privData->nativeObj->getElementsByTagNameNS(*localNamespaceURI, *localLocalName)); + v8::Handle<v8::Function> retCtor = V8NodeList::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); -v8::Handle<v8::Value> V8Document::getElementsByTagNameNSCallback(const v8::Arguments& args) { - if (args.Length() < 2) - throw V8Exception("Wrong number of arguments in getElementsByTagNameNS"); + struct V8NodeList::V8NodeListPrivate* retPrivData = new V8NodeList::V8NodeListPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - v8::Local<v8::Object> self = args.Holder(); - struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localNamespaceURI(args[0]); - v8::String::AsciiValue localLocalName(args[1]); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - Arabica::DOM::NodeList<std::string>* retVal = new Arabica::DOM::NodeList<std::string>(privData->nativeObj->getElementsByTagNameNS(*localNamespaceURI, *localLocalName)); - v8::Handle<v8::Function> retCtor = V8NodeList::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + retObj.MakeWeak(0, V8NodeList::jsDestructor); + return retObj; - struct V8NodeList::V8NodeListPrivate* retPrivData = new V8NodeList::V8NodeListPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + } - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + v8::Handle<v8::Value> V8Document::getElementByIdCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in getElementById"); - retObj.MakeWeak(0, V8NodeList::jsDestructor); - return retObj; + v8::Local<v8::Object> self = args.Holder(); + struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0)); + v8::String::AsciiValue localElementId(args[0]); -} + Arabica::DOM::Element<std::string>* retVal = new Arabica::DOM::Element<std::string>(privData->nativeObj->getElementById(*localElementId)); + v8::Handle<v8::Function> retCtor = V8Element::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); -v8::Handle<v8::Value> V8Document::getElementByIdCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in getElementById"); + struct V8Element::V8ElementPrivate* retPrivData = new V8Element::V8ElementPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - v8::Local<v8::Object> self = args.Holder(); - struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localElementId(args[0]); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - Arabica::DOM::Element<std::string>* retVal = new Arabica::DOM::Element<std::string>(privData->nativeObj->getElementById(*localElementId)); - v8::Handle<v8::Function> retCtor = V8Element::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + retObj.MakeWeak(0, V8Element::jsDestructor); + return retObj; - struct V8Element::V8ElementPrivate* retPrivData = new V8Element::V8ElementPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + } - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + bool V8Document::hasInstance(v8::Handle<v8::Value> value) { + return getTmpl()->HasInstance(value); + } - retObj.MakeWeak(0, V8Element::jsDestructor); - return retObj; - -} - -bool V8Document::hasInstance(v8::Handle<v8::Value> value) { - return getTmpl()->HasInstance(value); -} - -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.h index 2db4b54..c12e0dc 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.h @@ -33,91 +33,91 @@ namespace DOM { class V8Document { public: - struct V8DocumentPrivate { - V8DOM* dom; - Arabica::DOM::Document<std::string>* nativeObj; - }; - - V8_DESTRUCTOR(V8DocumentPrivate); - static bool hasInstance(v8::Handle<v8::Value>); - - static v8::Handle<v8::Value> createElementCallback(const v8::Arguments&); - static v8::Handle<v8::Value> createDocumentFragmentCallback(const v8::Arguments&); - static v8::Handle<v8::Value> createTextNodeCallback(const v8::Arguments&); - static v8::Handle<v8::Value> createCommentCallback(const v8::Arguments&); - static v8::Handle<v8::Value> createCDATASectionCallback(const v8::Arguments&); - static v8::Handle<v8::Value> createProcessingInstructionCallback(const v8::Arguments&); - static v8::Handle<v8::Value> createAttributeCallback(const v8::Arguments&); - static v8::Handle<v8::Value> createEntityReferenceCallback(const v8::Arguments&); - static v8::Handle<v8::Value> getElementsByTagNameCallback(const v8::Arguments&); - static v8::Handle<v8::Value> importNodeCallback(const v8::Arguments&); - static v8::Handle<v8::Value> createElementNSCallback(const v8::Arguments&); - static v8::Handle<v8::Value> createAttributeNSCallback(const v8::Arguments&); - static v8::Handle<v8::Value> getElementsByTagNameNSCallback(const v8::Arguments&); - static v8::Handle<v8::Value> getElementByIdCallback(const v8::Arguments&); - static v8::Handle<v8::Value> evaluateCustomCallback(const v8::Arguments&); - - static v8::Handle<v8::Value> doctypeAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> implementationAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> documentElementAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - - 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(); - (void)prototype; // surpress unused warnings - - instance->SetInternalFieldCount(1); - - 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("evaluate"), - v8::FunctionTemplate::New(V8Document::evaluateCustomCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - - - tmpl->Inherit(V8Node::getTmpl()); - Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); - } - return Tmpl; - } + struct V8DocumentPrivate { + V8DOM* dom; + Arabica::DOM::Document<std::string>* nativeObj; + }; + + V8_DESTRUCTOR(V8DocumentPrivate); + static bool hasInstance(v8::Handle<v8::Value>); + + static v8::Handle<v8::Value> createElementCallback(const v8::Arguments&); + static v8::Handle<v8::Value> createDocumentFragmentCallback(const v8::Arguments&); + static v8::Handle<v8::Value> createTextNodeCallback(const v8::Arguments&); + static v8::Handle<v8::Value> createCommentCallback(const v8::Arguments&); + static v8::Handle<v8::Value> createCDATASectionCallback(const v8::Arguments&); + static v8::Handle<v8::Value> createProcessingInstructionCallback(const v8::Arguments&); + static v8::Handle<v8::Value> createAttributeCallback(const v8::Arguments&); + static v8::Handle<v8::Value> createEntityReferenceCallback(const v8::Arguments&); + static v8::Handle<v8::Value> getElementsByTagNameCallback(const v8::Arguments&); + static v8::Handle<v8::Value> importNodeCallback(const v8::Arguments&); + static v8::Handle<v8::Value> createElementNSCallback(const v8::Arguments&); + static v8::Handle<v8::Value> createAttributeNSCallback(const v8::Arguments&); + static v8::Handle<v8::Value> getElementsByTagNameNSCallback(const v8::Arguments&); + static v8::Handle<v8::Value> getElementByIdCallback(const v8::Arguments&); + static v8::Handle<v8::Value> evaluateCustomCallback(const v8::Arguments&); + + static v8::Handle<v8::Value> doctypeAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> implementationAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> documentElementAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + + 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(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); + + 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("evaluate"), + v8::FunctionTemplate::New(V8Document::evaluateCustomCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + + + tmpl->Inherit(V8Node::getTmpl()); + Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); + } + return Tmpl; + } }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentFragment.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentFragment.cpp index 1403574..e6bec84 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentFragment.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentFragment.cpp @@ -4,11 +4,11 @@ namespace Arabica { namespace DOM { -v8::Persistent<v8::FunctionTemplate> V8DocumentFragment::Tmpl; + v8::Persistent<v8::FunctionTemplate> V8DocumentFragment::Tmpl; -bool V8DocumentFragment::hasInstance(v8::Handle<v8::Value> value) { - return getTmpl()->HasInstance(value); -} + bool V8DocumentFragment::hasInstance(v8::Handle<v8::Value> value) { + return getTmpl()->HasInstance(value); + } -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentFragment.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentFragment.h index c669b05..cf7f6ba 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentFragment.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentFragment.h @@ -33,37 +33,37 @@ namespace DOM { class V8DocumentFragment { public: - struct V8DocumentFragmentPrivate { - V8DOM* dom; - Arabica::DOM::DocumentFragment<std::string>* nativeObj; - }; + struct V8DocumentFragmentPrivate { + V8DOM* dom; + Arabica::DOM::DocumentFragment<std::string>* nativeObj; + }; - V8_DESTRUCTOR(V8DocumentFragmentPrivate); - static bool hasInstance(v8::Handle<v8::Value>); + V8_DESTRUCTOR(V8DocumentFragmentPrivate); + static bool hasInstance(v8::Handle<v8::Value>); - 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("DocumentFragment")); - tmpl->ReadOnlyPrototype(); + 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("DocumentFragment")); + tmpl->ReadOnlyPrototype(); - v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); - v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); - (void)prototype; // surpress unused warnings + v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); + v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); - instance->SetInternalFieldCount(1); - - tmpl->Inherit(V8Node::getTmpl()); - Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); - } - return Tmpl; - } + tmpl->Inherit(V8Node::getTmpl()); + Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); + } + return Tmpl; + } }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentType.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentType.cpp index 6b9a7b0..a2098f2 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentType.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentType.cpp @@ -5,79 +5,79 @@ namespace Arabica { namespace DOM { -v8::Persistent<v8::FunctionTemplate> V8DocumentType::Tmpl; + v8::Persistent<v8::FunctionTemplate> V8DocumentType::Tmpl; -v8::Handle<v8::Value> V8DocumentType::nameAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8DocumentTypePrivate* privData = V8DOM::toClassPtr<V8DocumentTypePrivate >(self->GetInternalField(0)); + v8::Handle<v8::Value> V8DocumentType::nameAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8DocumentTypePrivate* privData = V8DOM::toClassPtr<V8DocumentTypePrivate >(self->GetInternalField(0)); - return v8::String::New(privData->nativeObj->getName().c_str()); -} + return v8::String::New(privData->nativeObj->getName().c_str()); + } -v8::Handle<v8::Value> V8DocumentType::entitiesAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8DocumentTypePrivate* privData = V8DOM::toClassPtr<V8DocumentTypePrivate >(self->GetInternalField(0)); + v8::Handle<v8::Value> V8DocumentType::entitiesAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8DocumentTypePrivate* privData = V8DOM::toClassPtr<V8DocumentTypePrivate >(self->GetInternalField(0)); + + Arabica::DOM::NamedNodeMap<std::string>* arbaicaRet = new Arabica::DOM::NamedNodeMap<std::string>(privData->nativeObj->getEntities()); - Arabica::DOM::NamedNodeMap<std::string>* arbaicaRet = new Arabica::DOM::NamedNodeMap<std::string>(privData->nativeObj->getEntities()); + v8::Handle<v8::Function> arbaicaRetCtor = V8NamedNodeMap::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance()); - v8::Handle<v8::Function> arbaicaRetCtor = V8NamedNodeMap::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance()); + struct V8NamedNodeMap::V8NamedNodeMapPrivate* retPrivData = new V8NamedNodeMap::V8NamedNodeMapPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = arbaicaRet; + + arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + arbaicaRetObj.MakeWeak(0, V8NamedNodeMap::jsDestructor); + return arbaicaRetObj; - struct V8NamedNodeMap::V8NamedNodeMapPrivate* retPrivData = new V8NamedNodeMap::V8NamedNodeMapPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = arbaicaRet; + } - arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - arbaicaRetObj.MakeWeak(0, V8NamedNodeMap::jsDestructor); - return arbaicaRetObj; + v8::Handle<v8::Value> V8DocumentType::notationsAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8DocumentTypePrivate* privData = V8DOM::toClassPtr<V8DocumentTypePrivate >(self->GetInternalField(0)); -} + + Arabica::DOM::NamedNodeMap<std::string>* arbaicaRet = new Arabica::DOM::NamedNodeMap<std::string>(privData->nativeObj->getNotations()); -v8::Handle<v8::Value> V8DocumentType::notationsAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8DocumentTypePrivate* privData = V8DOM::toClassPtr<V8DocumentTypePrivate >(self->GetInternalField(0)); + v8::Handle<v8::Function> arbaicaRetCtor = V8NamedNodeMap::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance()); + struct V8NamedNodeMap::V8NamedNodeMapPrivate* retPrivData = new V8NamedNodeMap::V8NamedNodeMapPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = arbaicaRet; + + arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + arbaicaRetObj.MakeWeak(0, V8NamedNodeMap::jsDestructor); + return arbaicaRetObj; - Arabica::DOM::NamedNodeMap<std::string>* arbaicaRet = new Arabica::DOM::NamedNodeMap<std::string>(privData->nativeObj->getNotations()); + } - v8::Handle<v8::Function> arbaicaRetCtor = V8NamedNodeMap::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance()); + v8::Handle<v8::Value> V8DocumentType::publicIdAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8DocumentTypePrivate* privData = V8DOM::toClassPtr<V8DocumentTypePrivate >(self->GetInternalField(0)); - struct V8NamedNodeMap::V8NamedNodeMapPrivate* retPrivData = new V8NamedNodeMap::V8NamedNodeMapPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = arbaicaRet; + return v8::String::New(privData->nativeObj->getPublicId().c_str()); + } - arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - arbaicaRetObj.MakeWeak(0, V8NamedNodeMap::jsDestructor); - return arbaicaRetObj; + v8::Handle<v8::Value> V8DocumentType::systemIdAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8DocumentTypePrivate* privData = V8DOM::toClassPtr<V8DocumentTypePrivate >(self->GetInternalField(0)); -} + return v8::String::New(privData->nativeObj->getSystemId().c_str()); + } -v8::Handle<v8::Value> V8DocumentType::publicIdAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8DocumentTypePrivate* privData = V8DOM::toClassPtr<V8DocumentTypePrivate >(self->GetInternalField(0)); + v8::Handle<v8::Value> V8DocumentType::internalSubsetAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8DocumentTypePrivate* privData = V8DOM::toClassPtr<V8DocumentTypePrivate >(self->GetInternalField(0)); - return v8::String::New(privData->nativeObj->getPublicId().c_str()); -} + return v8::String::New(privData->nativeObj->getInternalSubset().c_str()); + } + bool V8DocumentType::hasInstance(v8::Handle<v8::Value> value) { + return getTmpl()->HasInstance(value); + } -v8::Handle<v8::Value> V8DocumentType::systemIdAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8DocumentTypePrivate* privData = V8DOM::toClassPtr<V8DocumentTypePrivate >(self->GetInternalField(0)); - - return v8::String::New(privData->nativeObj->getSystemId().c_str()); -} - -v8::Handle<v8::Value> V8DocumentType::internalSubsetAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8DocumentTypePrivate* privData = V8DOM::toClassPtr<V8DocumentTypePrivate >(self->GetInternalField(0)); - - return v8::String::New(privData->nativeObj->getInternalSubset().c_str()); -} -bool V8DocumentType::hasInstance(v8::Handle<v8::Value> value) { - return getTmpl()->HasInstance(value); -} - -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentType.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentType.h index 59c2607..65ce30c 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentType.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentType.h @@ -33,55 +33,55 @@ namespace DOM { class V8DocumentType { public: - struct V8DocumentTypePrivate { - V8DOM* dom; - Arabica::DOM::DocumentType<std::string>* nativeObj; - }; - - V8_DESTRUCTOR(V8DocumentTypePrivate); - static bool hasInstance(v8::Handle<v8::Value>); - - - static v8::Handle<v8::Value> nameAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> entitiesAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> notationsAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> publicIdAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> systemIdAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> internalSubsetAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - - 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("DocumentType")); - tmpl->ReadOnlyPrototype(); - - v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); - v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); - (void)prototype; // surpress unused warnings - - instance->SetInternalFieldCount(1); - - instance->SetAccessor(v8::String::NewSymbol("name"), V8DocumentType::nameAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("entities"), V8DocumentType::entitiesAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("notations"), V8DocumentType::notationsAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("publicId"), V8DocumentType::publicIdAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("systemId"), V8DocumentType::systemIdAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("internalSubset"), V8DocumentType::internalSubsetAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - - - - tmpl->Inherit(V8Node::getTmpl()); - Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); - } - return Tmpl; - } + struct V8DocumentTypePrivate { + V8DOM* dom; + Arabica::DOM::DocumentType<std::string>* nativeObj; + }; + + V8_DESTRUCTOR(V8DocumentTypePrivate); + static bool hasInstance(v8::Handle<v8::Value>); + + + static v8::Handle<v8::Value> nameAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> entitiesAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> notationsAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> publicIdAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> systemIdAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> internalSubsetAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + + 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("DocumentType")); + tmpl->ReadOnlyPrototype(); + + v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); + v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); + + instance->SetAccessor(v8::String::NewSymbol("name"), V8DocumentType::nameAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("entities"), V8DocumentType::entitiesAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("notations"), V8DocumentType::notationsAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("publicId"), V8DocumentType::publicIdAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("systemId"), V8DocumentType::systemIdAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("internalSubset"), V8DocumentType::internalSubsetAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + + + + tmpl->Inherit(V8Node::getTmpl()); + Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); + } + return Tmpl; + } }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.cpp index 680dd5e..d476daa 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.cpp @@ -6,297 +6,297 @@ namespace Arabica { namespace DOM { -v8::Persistent<v8::FunctionTemplate> V8Element::Tmpl; + v8::Persistent<v8::FunctionTemplate> V8Element::Tmpl; -v8::Handle<v8::Value> V8Element::tagNameAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8ElementPrivate* privData = V8DOM::toClassPtr<V8ElementPrivate >(self->GetInternalField(0)); + v8::Handle<v8::Value> V8Element::tagNameAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8ElementPrivate* privData = V8DOM::toClassPtr<V8ElementPrivate >(self->GetInternalField(0)); - return v8::String::New(privData->nativeObj->getTagName().c_str()); -} -v8::Handle<v8::Value> V8Element::getAttributeCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in getAttribute"); + return v8::String::New(privData->nativeObj->getTagName().c_str()); + } + v8::Handle<v8::Value> V8Element::getAttributeCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in getAttribute"); - v8::Local<v8::Object> self = args.Holder(); - struct V8ElementPrivate* privData = V8DOM::toClassPtr<V8ElementPrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localName(args[0]); + v8::Local<v8::Object> self = args.Holder(); + struct V8ElementPrivate* privData = V8DOM::toClassPtr<V8ElementPrivate >(self->GetInternalField(0)); + v8::String::AsciiValue localName(args[0]); - std::string retVal = privData->nativeObj->getAttribute(*localName); + std::string retVal = privData->nativeObj->getAttribute(*localName); - return v8::String::New(retVal.c_str()); -} + return v8::String::New(retVal.c_str()); + } -v8::Handle<v8::Value> V8Element::setAttributeCallback(const v8::Arguments& args) { - if (args.Length() < 2) - throw V8Exception("Wrong number of arguments in setAttribute"); + v8::Handle<v8::Value> V8Element::setAttributeCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in setAttribute"); - v8::Local<v8::Object> self = args.Holder(); - struct V8ElementPrivate* privData = V8DOM::toClassPtr<V8ElementPrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localName(args[0]); - v8::String::AsciiValue localValue(args[1]); + v8::Local<v8::Object> self = args.Holder(); + struct V8ElementPrivate* privData = V8DOM::toClassPtr<V8ElementPrivate >(self->GetInternalField(0)); + v8::String::AsciiValue localName(args[0]); + v8::String::AsciiValue localValue(args[1]); - privData->nativeObj->setAttribute(*localName, *localValue); + privData->nativeObj->setAttribute(*localName, *localValue); - return v8::Undefined(); -} + return v8::Undefined(); + } -v8::Handle<v8::Value> V8Element::removeAttributeCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in removeAttribute"); + v8::Handle<v8::Value> V8Element::removeAttributeCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in removeAttribute"); - v8::Local<v8::Object> self = args.Holder(); - struct V8ElementPrivate* privData = V8DOM::toClassPtr<V8ElementPrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localName(args[0]); + v8::Local<v8::Object> self = args.Holder(); + struct V8ElementPrivate* privData = V8DOM::toClassPtr<V8ElementPrivate >(self->GetInternalField(0)); + v8::String::AsciiValue localName(args[0]); - privData->nativeObj->removeAttribute(*localName); + privData->nativeObj->removeAttribute(*localName); - return v8::Undefined(); -} + return v8::Undefined(); + } -v8::Handle<v8::Value> V8Element::getAttributeNodeCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in getAttributeNode"); + v8::Handle<v8::Value> V8Element::getAttributeNodeCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in getAttributeNode"); - v8::Local<v8::Object> self = args.Holder(); - struct V8ElementPrivate* privData = V8DOM::toClassPtr<V8ElementPrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localName(args[0]); + v8::Local<v8::Object> self = args.Holder(); + struct V8ElementPrivate* privData = V8DOM::toClassPtr<V8ElementPrivate >(self->GetInternalField(0)); + v8::String::AsciiValue localName(args[0]); - Arabica::DOM::Attr<std::string>* retVal = new Arabica::DOM::Attr<std::string>(privData->nativeObj->getAttributeNode(*localName)); - v8::Handle<v8::Function> retCtor = V8Attr::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + Arabica::DOM::Attr<std::string>* retVal = new Arabica::DOM::Attr<std::string>(privData->nativeObj->getAttributeNode(*localName)); + v8::Handle<v8::Function> retCtor = V8Attr::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); - struct V8Attr::V8AttrPrivate* retPrivData = new V8Attr::V8AttrPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct V8Attr::V8AttrPrivate* retPrivData = new V8Attr::V8AttrPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, V8Attr::jsDestructor); - return retObj; + retObj.MakeWeak(0, V8Attr::jsDestructor); + return retObj; -} + } -v8::Handle<v8::Value> V8Element::setAttributeNodeCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in setAttributeNode"); - if (!(V8Attr::hasInstance(args[0]))) - throw V8Exception("Parameter mismatch while calling setAttributeNode"); + v8::Handle<v8::Value> V8Element::setAttributeNodeCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in setAttributeNode"); + if (!(V8Attr::hasInstance(args[0]))) + throw V8Exception("Parameter mismatch while calling setAttributeNode"); - v8::Local<v8::Object> self = args.Holder(); - struct V8ElementPrivate* privData = V8DOM::toClassPtr<V8ElementPrivate >(self->GetInternalField(0)); - Arabica::DOM::Attr<std::string>* localNewAttr = V8DOM::toClassPtr<V8Attr::V8AttrPrivate >(args[0]->ToObject()->GetInternalField(0))->nativeObj; + v8::Local<v8::Object> self = args.Holder(); + struct V8ElementPrivate* privData = V8DOM::toClassPtr<V8ElementPrivate >(self->GetInternalField(0)); + Arabica::DOM::Attr<std::string>* localNewAttr = V8DOM::toClassPtr<V8Attr::V8AttrPrivate >(args[0]->ToObject()->GetInternalField(0))->nativeObj; - Arabica::DOM::Attr<std::string>* retVal = new Arabica::DOM::Attr<std::string>(privData->nativeObj->setAttributeNode(*localNewAttr)); - v8::Handle<v8::Function> retCtor = V8Attr::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + Arabica::DOM::Attr<std::string>* retVal = new Arabica::DOM::Attr<std::string>(privData->nativeObj->setAttributeNode(*localNewAttr)); + v8::Handle<v8::Function> retCtor = V8Attr::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); - struct V8Attr::V8AttrPrivate* retPrivData = new V8Attr::V8AttrPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct V8Attr::V8AttrPrivate* retPrivData = new V8Attr::V8AttrPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, V8Attr::jsDestructor); - return retObj; + retObj.MakeWeak(0, V8Attr::jsDestructor); + return retObj; -} + } -v8::Handle<v8::Value> V8Element::removeAttributeNodeCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in removeAttributeNode"); - if (!(V8Attr::hasInstance(args[0]))) - throw V8Exception("Parameter mismatch while calling removeAttributeNode"); + v8::Handle<v8::Value> V8Element::removeAttributeNodeCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in removeAttributeNode"); + if (!(V8Attr::hasInstance(args[0]))) + throw V8Exception("Parameter mismatch while calling removeAttributeNode"); - v8::Local<v8::Object> self = args.Holder(); - struct V8ElementPrivate* privData = V8DOM::toClassPtr<V8ElementPrivate >(self->GetInternalField(0)); - Arabica::DOM::Attr<std::string>* localOldAttr = V8DOM::toClassPtr<V8Attr::V8AttrPrivate >(args[0]->ToObject()->GetInternalField(0))->nativeObj; + v8::Local<v8::Object> self = args.Holder(); + struct V8ElementPrivate* privData = V8DOM::toClassPtr<V8ElementPrivate >(self->GetInternalField(0)); + Arabica::DOM::Attr<std::string>* localOldAttr = V8DOM::toClassPtr<V8Attr::V8AttrPrivate >(args[0]->ToObject()->GetInternalField(0))->nativeObj; - Arabica::DOM::Attr<std::string>* retVal = new Arabica::DOM::Attr<std::string>(privData->nativeObj->removeAttributeNode(*localOldAttr)); - v8::Handle<v8::Function> retCtor = V8Attr::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + Arabica::DOM::Attr<std::string>* retVal = new Arabica::DOM::Attr<std::string>(privData->nativeObj->removeAttributeNode(*localOldAttr)); + v8::Handle<v8::Function> retCtor = V8Attr::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); - struct V8Attr::V8AttrPrivate* retPrivData = new V8Attr::V8AttrPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct V8Attr::V8AttrPrivate* retPrivData = new V8Attr::V8AttrPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, V8Attr::jsDestructor); - return retObj; + retObj.MakeWeak(0, V8Attr::jsDestructor); + return retObj; -} + } -v8::Handle<v8::Value> V8Element::getElementsByTagNameCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in getElementsByTagName"); + v8::Handle<v8::Value> V8Element::getElementsByTagNameCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in getElementsByTagName"); - v8::Local<v8::Object> self = args.Holder(); - struct V8ElementPrivate* privData = V8DOM::toClassPtr<V8ElementPrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localName(args[0]); + v8::Local<v8::Object> self = args.Holder(); + struct V8ElementPrivate* privData = V8DOM::toClassPtr<V8ElementPrivate >(self->GetInternalField(0)); + v8::String::AsciiValue localName(args[0]); - Arabica::DOM::NodeList<std::string>* retVal = new Arabica::DOM::NodeList<std::string>(privData->nativeObj->getElementsByTagName(*localName)); - v8::Handle<v8::Function> retCtor = V8NodeList::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + Arabica::DOM::NodeList<std::string>* retVal = new Arabica::DOM::NodeList<std::string>(privData->nativeObj->getElementsByTagName(*localName)); + v8::Handle<v8::Function> retCtor = V8NodeList::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); - struct V8NodeList::V8NodeListPrivate* retPrivData = new V8NodeList::V8NodeListPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct V8NodeList::V8NodeListPrivate* retPrivData = new V8NodeList::V8NodeListPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, V8NodeList::jsDestructor); - return retObj; + retObj.MakeWeak(0, V8NodeList::jsDestructor); + return retObj; -} + } -v8::Handle<v8::Value> V8Element::getAttributeNSCallback(const v8::Arguments& args) { - if (args.Length() < 2) - throw V8Exception("Wrong number of arguments in getAttributeNS"); + v8::Handle<v8::Value> V8Element::getAttributeNSCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in getAttributeNS"); - v8::Local<v8::Object> self = args.Holder(); - struct V8ElementPrivate* privData = V8DOM::toClassPtr<V8ElementPrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localNamespaceURI(args[0]); - v8::String::AsciiValue localLocalName(args[1]); + v8::Local<v8::Object> self = args.Holder(); + struct V8ElementPrivate* privData = V8DOM::toClassPtr<V8ElementPrivate >(self->GetInternalField(0)); + v8::String::AsciiValue localNamespaceURI(args[0]); + v8::String::AsciiValue localLocalName(args[1]); - std::string retVal = privData->nativeObj->getAttributeNS(*localNamespaceURI, *localLocalName); + std::string retVal = privData->nativeObj->getAttributeNS(*localNamespaceURI, *localLocalName); - return v8::String::New(retVal.c_str()); -} + return v8::String::New(retVal.c_str()); + } -v8::Handle<v8::Value> V8Element::setAttributeNSCallback(const v8::Arguments& args) { - if (args.Length() < 3) - throw V8Exception("Wrong number of arguments in setAttributeNS"); + v8::Handle<v8::Value> V8Element::setAttributeNSCallback(const v8::Arguments& args) { + if (args.Length() < 3) + throw V8Exception("Wrong number of arguments in setAttributeNS"); - v8::Local<v8::Object> self = args.Holder(); - struct V8ElementPrivate* privData = V8DOM::toClassPtr<V8ElementPrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localNamespaceURI(args[0]); - v8::String::AsciiValue localQualifiedName(args[1]); - v8::String::AsciiValue localValue(args[2]); + v8::Local<v8::Object> self = args.Holder(); + struct V8ElementPrivate* privData = V8DOM::toClassPtr<V8ElementPrivate >(self->GetInternalField(0)); + v8::String::AsciiValue localNamespaceURI(args[0]); + v8::String::AsciiValue localQualifiedName(args[1]); + v8::String::AsciiValue localValue(args[2]); - privData->nativeObj->setAttributeNS(*localNamespaceURI, *localQualifiedName, *localValue); + privData->nativeObj->setAttributeNS(*localNamespaceURI, *localQualifiedName, *localValue); - return v8::Undefined(); -} + return v8::Undefined(); + } -v8::Handle<v8::Value> V8Element::removeAttributeNSCallback(const v8::Arguments& args) { - if (args.Length() < 2) - throw V8Exception("Wrong number of arguments in removeAttributeNS"); + v8::Handle<v8::Value> V8Element::removeAttributeNSCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in removeAttributeNS"); - v8::Local<v8::Object> self = args.Holder(); - struct V8ElementPrivate* privData = V8DOM::toClassPtr<V8ElementPrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localNamespaceURI(args[0]); - v8::String::AsciiValue localLocalName(args[1]); + v8::Local<v8::Object> self = args.Holder(); + struct V8ElementPrivate* privData = V8DOM::toClassPtr<V8ElementPrivate >(self->GetInternalField(0)); + v8::String::AsciiValue localNamespaceURI(args[0]); + v8::String::AsciiValue localLocalName(args[1]); - privData->nativeObj->removeAttributeNS(*localNamespaceURI, *localLocalName); + privData->nativeObj->removeAttributeNS(*localNamespaceURI, *localLocalName); - return v8::Undefined(); -} + return v8::Undefined(); + } -v8::Handle<v8::Value> V8Element::getAttributeNodeNSCallback(const v8::Arguments& args) { - if (args.Length() < 2) - throw V8Exception("Wrong number of arguments in getAttributeNodeNS"); + v8::Handle<v8::Value> V8Element::getAttributeNodeNSCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in getAttributeNodeNS"); - v8::Local<v8::Object> self = args.Holder(); - struct V8ElementPrivate* privData = V8DOM::toClassPtr<V8ElementPrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localNamespaceURI(args[0]); - v8::String::AsciiValue localLocalName(args[1]); + v8::Local<v8::Object> self = args.Holder(); + struct V8ElementPrivate* privData = V8DOM::toClassPtr<V8ElementPrivate >(self->GetInternalField(0)); + v8::String::AsciiValue localNamespaceURI(args[0]); + v8::String::AsciiValue localLocalName(args[1]); - Arabica::DOM::Attr<std::string>* retVal = new Arabica::DOM::Attr<std::string>(privData->nativeObj->getAttributeNodeNS(*localNamespaceURI, *localLocalName)); - v8::Handle<v8::Function> retCtor = V8Attr::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + Arabica::DOM::Attr<std::string>* retVal = new Arabica::DOM::Attr<std::string>(privData->nativeObj->getAttributeNodeNS(*localNamespaceURI, *localLocalName)); + v8::Handle<v8::Function> retCtor = V8Attr::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); - struct V8Attr::V8AttrPrivate* retPrivData = new V8Attr::V8AttrPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct V8Attr::V8AttrPrivate* retPrivData = new V8Attr::V8AttrPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, V8Attr::jsDestructor); - return retObj; + retObj.MakeWeak(0, V8Attr::jsDestructor); + return retObj; -} + } -v8::Handle<v8::Value> V8Element::setAttributeNodeNSCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in setAttributeNodeNS"); - if (!(V8Attr::hasInstance(args[0]))) - throw V8Exception("Parameter mismatch while calling setAttributeNodeNS"); + v8::Handle<v8::Value> V8Element::setAttributeNodeNSCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in setAttributeNodeNS"); + if (!(V8Attr::hasInstance(args[0]))) + throw V8Exception("Parameter mismatch while calling setAttributeNodeNS"); - v8::Local<v8::Object> self = args.Holder(); - struct V8ElementPrivate* privData = V8DOM::toClassPtr<V8ElementPrivate >(self->GetInternalField(0)); - Arabica::DOM::Attr<std::string>* localNewAttr = V8DOM::toClassPtr<V8Attr::V8AttrPrivate >(args[0]->ToObject()->GetInternalField(0))->nativeObj; + v8::Local<v8::Object> self = args.Holder(); + struct V8ElementPrivate* privData = V8DOM::toClassPtr<V8ElementPrivate >(self->GetInternalField(0)); + Arabica::DOM::Attr<std::string>* localNewAttr = V8DOM::toClassPtr<V8Attr::V8AttrPrivate >(args[0]->ToObject()->GetInternalField(0))->nativeObj; - Arabica::DOM::Attr<std::string>* retVal = new Arabica::DOM::Attr<std::string>(privData->nativeObj->setAttributeNodeNS(*localNewAttr)); - v8::Handle<v8::Function> retCtor = V8Attr::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + Arabica::DOM::Attr<std::string>* retVal = new Arabica::DOM::Attr<std::string>(privData->nativeObj->setAttributeNodeNS(*localNewAttr)); + v8::Handle<v8::Function> retCtor = V8Attr::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); - struct V8Attr::V8AttrPrivate* retPrivData = new V8Attr::V8AttrPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct V8Attr::V8AttrPrivate* retPrivData = new V8Attr::V8AttrPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, V8Attr::jsDestructor); - return retObj; + retObj.MakeWeak(0, V8Attr::jsDestructor); + return retObj; -} + } -v8::Handle<v8::Value> V8Element::getElementsByTagNameNSCallback(const v8::Arguments& args) { - if (args.Length() < 2) - throw V8Exception("Wrong number of arguments in getElementsByTagNameNS"); + v8::Handle<v8::Value> V8Element::getElementsByTagNameNSCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in getElementsByTagNameNS"); - v8::Local<v8::Object> self = args.Holder(); - struct V8ElementPrivate* privData = V8DOM::toClassPtr<V8ElementPrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localNamespaceURI(args[0]); - v8::String::AsciiValue localLocalName(args[1]); + v8::Local<v8::Object> self = args.Holder(); + struct V8ElementPrivate* privData = V8DOM::toClassPtr<V8ElementPrivate >(self->GetInternalField(0)); + v8::String::AsciiValue localNamespaceURI(args[0]); + v8::String::AsciiValue localLocalName(args[1]); - Arabica::DOM::NodeList<std::string>* retVal = new Arabica::DOM::NodeList<std::string>(privData->nativeObj->getElementsByTagNameNS(*localNamespaceURI, *localLocalName)); - v8::Handle<v8::Function> retCtor = V8NodeList::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + Arabica::DOM::NodeList<std::string>* retVal = new Arabica::DOM::NodeList<std::string>(privData->nativeObj->getElementsByTagNameNS(*localNamespaceURI, *localLocalName)); + v8::Handle<v8::Function> retCtor = V8NodeList::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); - struct V8NodeList::V8NodeListPrivate* retPrivData = new V8NodeList::V8NodeListPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct V8NodeList::V8NodeListPrivate* retPrivData = new V8NodeList::V8NodeListPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, V8NodeList::jsDestructor); - return retObj; + retObj.MakeWeak(0, V8NodeList::jsDestructor); + return retObj; -} + } -v8::Handle<v8::Value> V8Element::hasAttributeCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in hasAttribute"); + v8::Handle<v8::Value> V8Element::hasAttributeCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in hasAttribute"); - v8::Local<v8::Object> self = args.Holder(); - struct V8ElementPrivate* privData = V8DOM::toClassPtr<V8ElementPrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localName(args[0]); + v8::Local<v8::Object> self = args.Holder(); + struct V8ElementPrivate* privData = V8DOM::toClassPtr<V8ElementPrivate >(self->GetInternalField(0)); + v8::String::AsciiValue localName(args[0]); - bool retVal = privData->nativeObj->hasAttribute(*localName); + bool retVal = privData->nativeObj->hasAttribute(*localName); - return v8::Boolean::New(retVal); -} + return v8::Boolean::New(retVal); + } -v8::Handle<v8::Value> V8Element::hasAttributeNSCallback(const v8::Arguments& args) { - if (args.Length() < 2) - throw V8Exception("Wrong number of arguments in hasAttributeNS"); + v8::Handle<v8::Value> V8Element::hasAttributeNSCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in hasAttributeNS"); - v8::Local<v8::Object> self = args.Holder(); - struct V8ElementPrivate* privData = V8DOM::toClassPtr<V8ElementPrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localNamespaceURI(args[0]); - v8::String::AsciiValue localLocalName(args[1]); + v8::Local<v8::Object> self = args.Holder(); + struct V8ElementPrivate* privData = V8DOM::toClassPtr<V8ElementPrivate >(self->GetInternalField(0)); + v8::String::AsciiValue localNamespaceURI(args[0]); + v8::String::AsciiValue localLocalName(args[1]); - bool retVal = privData->nativeObj->hasAttributeNS(*localNamespaceURI, *localLocalName); + bool retVal = privData->nativeObj->hasAttributeNS(*localNamespaceURI, *localLocalName); - return v8::Boolean::New(retVal); -} + return v8::Boolean::New(retVal); + } -bool V8Element::hasInstance(v8::Handle<v8::Value> value) { - return getTmpl()->HasInstance(value); -} + bool V8Element::hasInstance(v8::Handle<v8::Value> value) { + return getTmpl()->HasInstance(value); + } -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.h index e5a52bf..499ae0e 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.h @@ -33,85 +33,85 @@ namespace DOM { class V8Element { public: - struct V8ElementPrivate { - V8DOM* dom; - Arabica::DOM::Element<std::string>* nativeObj; - }; - - V8_DESTRUCTOR(V8ElementPrivate); - static bool hasInstance(v8::Handle<v8::Value>); - - static v8::Handle<v8::Value> getAttributeCallback(const v8::Arguments&); - static v8::Handle<v8::Value> setAttributeCallback(const v8::Arguments&); - static v8::Handle<v8::Value> removeAttributeCallback(const v8::Arguments&); - static v8::Handle<v8::Value> getAttributeNodeCallback(const v8::Arguments&); - static v8::Handle<v8::Value> setAttributeNodeCallback(const v8::Arguments&); - static v8::Handle<v8::Value> removeAttributeNodeCallback(const v8::Arguments&); - static v8::Handle<v8::Value> getElementsByTagNameCallback(const v8::Arguments&); - static v8::Handle<v8::Value> getAttributeNSCallback(const v8::Arguments&); - static v8::Handle<v8::Value> setAttributeNSCallback(const v8::Arguments&); - static v8::Handle<v8::Value> removeAttributeNSCallback(const v8::Arguments&); - static v8::Handle<v8::Value> getAttributeNodeNSCallback(const v8::Arguments&); - static v8::Handle<v8::Value> setAttributeNodeNSCallback(const v8::Arguments&); - static v8::Handle<v8::Value> getElementsByTagNameNSCallback(const v8::Arguments&); - static v8::Handle<v8::Value> hasAttributeCallback(const v8::Arguments&); - static v8::Handle<v8::Value> hasAttributeNSCallback(const v8::Arguments&); - - static v8::Handle<v8::Value> tagNameAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - - 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(); - (void)prototype; // surpress unused warnings - - instance->SetInternalFieldCount(1); - - 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("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("getElementsByTagNameNS"), - v8::FunctionTemplate::New(V8Element::getElementsByTagNameNSCallback, 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; - } + struct V8ElementPrivate { + V8DOM* dom; + Arabica::DOM::Element<std::string>* nativeObj; + }; + + V8_DESTRUCTOR(V8ElementPrivate); + static bool hasInstance(v8::Handle<v8::Value>); + + static v8::Handle<v8::Value> getAttributeCallback(const v8::Arguments&); + static v8::Handle<v8::Value> setAttributeCallback(const v8::Arguments&); + static v8::Handle<v8::Value> removeAttributeCallback(const v8::Arguments&); + static v8::Handle<v8::Value> getAttributeNodeCallback(const v8::Arguments&); + static v8::Handle<v8::Value> setAttributeNodeCallback(const v8::Arguments&); + static v8::Handle<v8::Value> removeAttributeNodeCallback(const v8::Arguments&); + static v8::Handle<v8::Value> getElementsByTagNameCallback(const v8::Arguments&); + static v8::Handle<v8::Value> getAttributeNSCallback(const v8::Arguments&); + static v8::Handle<v8::Value> setAttributeNSCallback(const v8::Arguments&); + static v8::Handle<v8::Value> removeAttributeNSCallback(const v8::Arguments&); + static v8::Handle<v8::Value> getAttributeNodeNSCallback(const v8::Arguments&); + static v8::Handle<v8::Value> setAttributeNodeNSCallback(const v8::Arguments&); + static v8::Handle<v8::Value> getElementsByTagNameNSCallback(const v8::Arguments&); + static v8::Handle<v8::Value> hasAttributeCallback(const v8::Arguments&); + static v8::Handle<v8::Value> hasAttributeNSCallback(const v8::Arguments&); + + static v8::Handle<v8::Value> tagNameAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + + 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(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); + + 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("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("getElementsByTagNameNS"), + v8::FunctionTemplate::New(V8Element::getElementsByTagNameNSCallback, 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; + } }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Entity.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Entity.cpp index f3ce21d..6db7b15 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Entity.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Entity.cpp @@ -4,32 +4,32 @@ namespace Arabica { namespace DOM { -v8::Persistent<v8::FunctionTemplate> V8Entity::Tmpl; + v8::Persistent<v8::FunctionTemplate> V8Entity::Tmpl; -v8::Handle<v8::Value> V8Entity::publicIdAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8EntityPrivate* privData = V8DOM::toClassPtr<V8EntityPrivate >(self->GetInternalField(0)); + v8::Handle<v8::Value> V8Entity::publicIdAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8EntityPrivate* privData = V8DOM::toClassPtr<V8EntityPrivate >(self->GetInternalField(0)); - return v8::String::New(privData->nativeObj->getPublicId().c_str()); -} + return v8::String::New(privData->nativeObj->getPublicId().c_str()); + } -v8::Handle<v8::Value> V8Entity::systemIdAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8EntityPrivate* privData = V8DOM::toClassPtr<V8EntityPrivate >(self->GetInternalField(0)); + v8::Handle<v8::Value> V8Entity::systemIdAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8EntityPrivate* privData = V8DOM::toClassPtr<V8EntityPrivate >(self->GetInternalField(0)); - return v8::String::New(privData->nativeObj->getSystemId().c_str()); -} + return v8::String::New(privData->nativeObj->getSystemId().c_str()); + } -v8::Handle<v8::Value> V8Entity::notationNameAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8EntityPrivate* privData = V8DOM::toClassPtr<V8EntityPrivate >(self->GetInternalField(0)); + v8::Handle<v8::Value> V8Entity::notationNameAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8EntityPrivate* privData = V8DOM::toClassPtr<V8EntityPrivate >(self->GetInternalField(0)); - return v8::String::New(privData->nativeObj->getNotationName().c_str()); -} -bool V8Entity::hasInstance(v8::Handle<v8::Value> value) { - return getTmpl()->HasInstance(value); -} + return v8::String::New(privData->nativeObj->getNotationName().c_str()); + } + bool V8Entity::hasInstance(v8::Handle<v8::Value> value) { + return getTmpl()->HasInstance(value); + } -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Entity.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Entity.h index 6e85585..acea6ea 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Entity.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Entity.h @@ -33,46 +33,46 @@ namespace DOM { class V8Entity { public: - struct V8EntityPrivate { - V8DOM* dom; - Arabica::DOM::Entity<std::string>* nativeObj; - }; - - V8_DESTRUCTOR(V8EntityPrivate); - static bool hasInstance(v8::Handle<v8::Value>); - - - static v8::Handle<v8::Value> publicIdAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> systemIdAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> notationNameAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - - 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("Entity")); - tmpl->ReadOnlyPrototype(); - - v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); - v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); - (void)prototype; // surpress unused warnings - - instance->SetInternalFieldCount(1); - - instance->SetAccessor(v8::String::NewSymbol("publicId"), V8Entity::publicIdAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("systemId"), V8Entity::systemIdAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("notationName"), V8Entity::notationNameAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - - - - tmpl->Inherit(V8Node::getTmpl()); - Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); - } - return Tmpl; - } + struct V8EntityPrivate { + V8DOM* dom; + Arabica::DOM::Entity<std::string>* nativeObj; + }; + + V8_DESTRUCTOR(V8EntityPrivate); + static bool hasInstance(v8::Handle<v8::Value>); + + + static v8::Handle<v8::Value> publicIdAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> systemIdAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> notationNameAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + + 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("Entity")); + tmpl->ReadOnlyPrototype(); + + v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); + v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); + + instance->SetAccessor(v8::String::NewSymbol("publicId"), V8Entity::publicIdAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("systemId"), V8Entity::systemIdAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("notationName"), V8Entity::notationNameAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + + + + tmpl->Inherit(V8Node::getTmpl()); + Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); + } + return Tmpl; + } }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8EntityReference.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8EntityReference.cpp index 197fadd..95ceee8 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8EntityReference.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8EntityReference.cpp @@ -4,11 +4,11 @@ namespace Arabica { namespace DOM { -v8::Persistent<v8::FunctionTemplate> V8EntityReference::Tmpl; + v8::Persistent<v8::FunctionTemplate> V8EntityReference::Tmpl; -bool V8EntityReference::hasInstance(v8::Handle<v8::Value> value) { - return getTmpl()->HasInstance(value); -} + bool V8EntityReference::hasInstance(v8::Handle<v8::Value> value) { + return getTmpl()->HasInstance(value); + } -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8EntityReference.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8EntityReference.h index 86dd61b..9bfb86d 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8EntityReference.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8EntityReference.h @@ -33,37 +33,37 @@ namespace DOM { class V8EntityReference { public: - struct V8EntityReferencePrivate { - V8DOM* dom; - Arabica::DOM::EntityReference<std::string>* nativeObj; - }; + struct V8EntityReferencePrivate { + V8DOM* dom; + Arabica::DOM::EntityReference<std::string>* nativeObj; + }; - V8_DESTRUCTOR(V8EntityReferencePrivate); - static bool hasInstance(v8::Handle<v8::Value>); + V8_DESTRUCTOR(V8EntityReferencePrivate); + static bool hasInstance(v8::Handle<v8::Value>); - 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("EntityReference")); - tmpl->ReadOnlyPrototype(); + 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("EntityReference")); + tmpl->ReadOnlyPrototype(); - v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); - v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); - (void)prototype; // surpress unused warnings + v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); + v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); - instance->SetInternalFieldCount(1); - - tmpl->Inherit(V8Node::getTmpl()); - Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); - } - return Tmpl; - } + tmpl->Inherit(V8Node::getTmpl()); + Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); + } + return Tmpl; + } }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NamedNodeMap.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NamedNodeMap.cpp index 037d651..e09bbb8 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NamedNodeMap.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NamedNodeMap.cpp @@ -4,185 +4,185 @@ namespace Arabica { namespace DOM { -v8::Persistent<v8::FunctionTemplate> V8NamedNodeMap::Tmpl; + 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(); - struct V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr<V8NamedNodeMapPrivate >(self->GetInternalField(0)); + v8::Handle<v8::Value> V8NamedNodeMap::lengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr<V8NamedNodeMapPrivate >(self->GetInternalField(0)); - return v8::Integer::New(privData->nativeObj->getLength()); -} -v8::Handle<v8::Value> V8NamedNodeMap::getNamedItemCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in getNamedItem"); + return v8::Integer::New(privData->nativeObj->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(); - struct V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr<V8NamedNodeMapPrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localName(args[0]); + v8::Local<v8::Object> self = args.Holder(); + struct 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->nativeObj->getNamedItem(*localName)); - v8::Handle<v8::Function> retCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->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->nativeObj = retVal; + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, V8Node::jsDestructor); - return retObj; + 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::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(); - struct V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr<V8NamedNodeMapPrivate >(self->GetInternalField(0)); - Arabica::DOM::Node<std::string>* localArg = V8DOM::toClassPtr<V8Node::V8NodePrivate >(args[0]->ToObject()->GetInternalField(0))->nativeObj; + v8::Local<v8::Object> self = args.Holder(); + struct V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr<V8NamedNodeMapPrivate >(self->GetInternalField(0)); + Arabica::DOM::Node<std::string>* localArg = V8DOM::toClassPtr<V8Node::V8NodePrivate >(args[0]->ToObject()->GetInternalField(0))->nativeObj; - Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->setNamedItem(*localArg)); - v8::Handle<v8::Function> retCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->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->nativeObj = retVal; + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, V8Node::jsDestructor); - return retObj; + 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::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(); - struct V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr<V8NamedNodeMapPrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localName(args[0]); + v8::Local<v8::Object> self = args.Holder(); + struct 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->nativeObj->removeNamedItem(*localName)); - v8::Handle<v8::Function> retCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->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->nativeObj = retVal; + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, V8Node::jsDestructor); - return retObj; + 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::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(); - struct V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr<V8NamedNodeMapPrivate >(self->GetInternalField(0)); - unsigned long localIndex = args[0]->ToNumber()->Uint32Value(); + v8::Local<v8::Object> self = args.Holder(); + struct 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->nativeObj->item(localIndex)); - v8::Handle<v8::Function> retCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->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->nativeObj = retVal; + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, V8Node::jsDestructor); - return retObj; + 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::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(); - struct V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr<V8NamedNodeMapPrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localNamespaceURI(args[0]); - v8::String::AsciiValue localLocalName(args[1]); + v8::Local<v8::Object> self = args.Holder(); + struct 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->nativeObj->getNamedItemNS(*localNamespaceURI, *localLocalName)); - v8::Handle<v8::Function> retCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->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->nativeObj = retVal; + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, V8Node::jsDestructor); - return retObj; + 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::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(); - struct V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr<V8NamedNodeMapPrivate >(self->GetInternalField(0)); - Arabica::DOM::Node<std::string>* localArg = V8DOM::toClassPtr<V8Node::V8NodePrivate >(args[0]->ToObject()->GetInternalField(0))->nativeObj; + v8::Local<v8::Object> self = args.Holder(); + struct V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr<V8NamedNodeMapPrivate >(self->GetInternalField(0)); + Arabica::DOM::Node<std::string>* localArg = V8DOM::toClassPtr<V8Node::V8NodePrivate >(args[0]->ToObject()->GetInternalField(0))->nativeObj; - Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->setNamedItemNS(*localArg)); - v8::Handle<v8::Function> retCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->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->nativeObj = retVal; + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, V8Node::jsDestructor); - return retObj; + 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::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(); - struct V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr<V8NamedNodeMapPrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localNamespaceURI(args[0]); - v8::String::AsciiValue localLocalName(args[1]); + v8::Local<v8::Object> self = args.Holder(); + struct 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->nativeObj->removeNamedItemNS(*localNamespaceURI, *localLocalName)); - v8::Handle<v8::Function> retCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->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->nativeObj = retVal; + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, V8Node::jsDestructor); - return retObj; + retObj.MakeWeak(0, V8Node::jsDestructor); + return retObj; -} + } -bool V8NamedNodeMap::hasInstance(v8::Handle<v8::Value> value) { - return getTmpl()->HasInstance(value); -} + bool V8NamedNodeMap::hasInstance(v8::Handle<v8::Value> value) { + return getTmpl()->HasInstance(value); + } -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NamedNodeMap.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NamedNodeMap.h index be89037..a98c5ee 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NamedNodeMap.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NamedNodeMap.h @@ -32,60 +32,60 @@ namespace DOM { class V8NamedNodeMap { public: - struct V8NamedNodeMapPrivate { - V8DOM* dom; - Arabica::DOM::NamedNodeMap<std::string>* nativeObj; - }; - - V8_DESTRUCTOR(V8NamedNodeMapPrivate); - static bool hasInstance(v8::Handle<v8::Value>); - - static v8::Handle<v8::Value> getNamedItemCallback(const v8::Arguments&); - static v8::Handle<v8::Value> setNamedItemCallback(const v8::Arguments&); - static v8::Handle<v8::Value> removeNamedItemCallback(const v8::Arguments&); - static v8::Handle<v8::Value> itemCallback(const v8::Arguments&); - static v8::Handle<v8::Value> getNamedItemNSCallback(const v8::Arguments&); - static v8::Handle<v8::Value> setNamedItemNSCallback(const v8::Arguments&); - static v8::Handle<v8::Value> removeNamedItemNSCallback(const v8::Arguments&); - - static v8::Handle<v8::Value> lengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - - 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("NamedNodeMap")); - tmpl->ReadOnlyPrototype(); - - v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); - v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); - (void)prototype; // surpress unused warnings - - instance->SetInternalFieldCount(1); - - instance->SetAccessor(v8::String::NewSymbol("length"), V8NamedNodeMap::lengthAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - - prototype->Set(v8::String::NewSymbol("getNamedItem"), - v8::FunctionTemplate::New(V8NamedNodeMap::getNamedItemCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("setNamedItem"), - v8::FunctionTemplate::New(V8NamedNodeMap::setNamedItemCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("removeNamedItem"), - v8::FunctionTemplate::New(V8NamedNodeMap::removeNamedItemCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("item"), - v8::FunctionTemplate::New(V8NamedNodeMap::itemCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("getNamedItemNS"), - v8::FunctionTemplate::New(V8NamedNodeMap::getNamedItemNSCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("setNamedItemNS"), - v8::FunctionTemplate::New(V8NamedNodeMap::setNamedItemNSCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("removeNamedItemNS"), - v8::FunctionTemplate::New(V8NamedNodeMap::removeNamedItemNSCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - - - Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); - } - return Tmpl; - } + struct V8NamedNodeMapPrivate { + V8DOM* dom; + Arabica::DOM::NamedNodeMap<std::string>* nativeObj; + }; + + V8_DESTRUCTOR(V8NamedNodeMapPrivate); + static bool hasInstance(v8::Handle<v8::Value>); + + static v8::Handle<v8::Value> getNamedItemCallback(const v8::Arguments&); + static v8::Handle<v8::Value> setNamedItemCallback(const v8::Arguments&); + static v8::Handle<v8::Value> removeNamedItemCallback(const v8::Arguments&); + static v8::Handle<v8::Value> itemCallback(const v8::Arguments&); + static v8::Handle<v8::Value> getNamedItemNSCallback(const v8::Arguments&); + static v8::Handle<v8::Value> setNamedItemNSCallback(const v8::Arguments&); + static v8::Handle<v8::Value> removeNamedItemNSCallback(const v8::Arguments&); + + static v8::Handle<v8::Value> lengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + + 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("NamedNodeMap")); + tmpl->ReadOnlyPrototype(); + + v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); + v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); + + instance->SetAccessor(v8::String::NewSymbol("length"), V8NamedNodeMap::lengthAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + + prototype->Set(v8::String::NewSymbol("getNamedItem"), + v8::FunctionTemplate::New(V8NamedNodeMap::getNamedItemCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("setNamedItem"), + v8::FunctionTemplate::New(V8NamedNodeMap::setNamedItemCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("removeNamedItem"), + v8::FunctionTemplate::New(V8NamedNodeMap::removeNamedItemCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("item"), + v8::FunctionTemplate::New(V8NamedNodeMap::itemCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("getNamedItemNS"), + v8::FunctionTemplate::New(V8NamedNodeMap::getNamedItemNSCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("setNamedItemNS"), + v8::FunctionTemplate::New(V8NamedNodeMap::setNamedItemNSCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("removeNamedItemNS"), + v8::FunctionTemplate::New(V8NamedNodeMap::removeNamedItemNSCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + + + Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); + } + return Tmpl; + } }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.cpp index b77f38e..31f6457 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.cpp @@ -1,401 +1,380 @@ #include "V8Document.h" -#include "V8NamedNodeMap.h" #include "V8Node.h" #include "V8NodeList.h" namespace Arabica { namespace DOM { -v8::Persistent<v8::FunctionTemplate> V8Node::Tmpl; + v8::Persistent<v8::FunctionTemplate> V8Node::Tmpl; -v8::Handle<v8::Value> V8Node::nodeNameAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); + v8::Handle<v8::Value> V8Node::nodeNameAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); - return v8::String::New(privData->nativeObj->getNodeName().c_str()); -} + return v8::String::New(privData->nativeObj->getNodeName().c_str()); + } -v8::Handle<v8::Value> V8Node::nodeValueAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); + v8::Handle<v8::Value> V8Node::nodeValueAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); - return v8::String::New(privData->nativeObj->getNodeValue().c_str()); -} + return v8::String::New(privData->nativeObj->getNodeValue().c_str()); + } -void V8Node::nodeValueAttrSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localNodeValue(value); - privData->nativeObj->setNodeValue(*localNodeValue); -} + void V8Node::nodeValueAttrSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); + v8::String::AsciiValue localNodeValue(value); + privData->nativeObj->setNodeValue(*localNodeValue); + } -v8::Handle<v8::Value> V8Node::nodeTypeAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); + v8::Handle<v8::Value> V8Node::nodeTypeAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); - return v8::Integer::New(privData->nativeObj->getNodeType()); -} + return v8::Integer::New(privData->nativeObj->getNodeType()); + } -v8::Handle<v8::Value> V8Node::parentNodeAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); + v8::Handle<v8::Value> V8Node::parentNodeAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); - if (!privData->nativeObj->getParentNode()) return v8::Undefined(); - Arabica::DOM::Node<std::string>* arbaicaRet = new Arabica::DOM::Node<std::string>(privData->nativeObj->getParentNode()); + if (!privData->nativeObj->getParentNode()) return v8::Undefined(); + Arabica::DOM::Node<std::string>* arbaicaRet = new Arabica::DOM::Node<std::string>(privData->nativeObj->getParentNode()); - v8::Handle<v8::Function> arbaicaRetCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance()); + v8::Handle<v8::Function> arbaicaRetCtor = V8Node::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance()); - struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = arbaicaRet; + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = arbaicaRet; + + arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + arbaicaRetObj.MakeWeak(0, V8Node::jsDestructor); + return arbaicaRetObj; - arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - arbaicaRetObj.MakeWeak(0, V8Node::jsDestructor); - return arbaicaRetObj; + } -} + v8::Handle<v8::Value> V8Node::childNodesAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); -v8::Handle<v8::Value> V8Node::childNodesAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); + + Arabica::DOM::NodeList<std::string>* arbaicaRet = new Arabica::DOM::NodeList<std::string>(privData->nativeObj->getChildNodes()); + v8::Handle<v8::Function> arbaicaRetCtor = V8NodeList::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance()); - Arabica::DOM::NodeList<std::string>* arbaicaRet = new Arabica::DOM::NodeList<std::string>(privData->nativeObj->getChildNodes()); + struct V8NodeList::V8NodeListPrivate* retPrivData = new V8NodeList::V8NodeListPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = arbaicaRet; + + arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + arbaicaRetObj.MakeWeak(0, V8NodeList::jsDestructor); + return arbaicaRetObj; - v8::Handle<v8::Function> arbaicaRetCtor = V8NodeList::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance()); + } - struct V8NodeList::V8NodeListPrivate* retPrivData = new V8NodeList::V8NodeListPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = arbaicaRet; + v8::Handle<v8::Value> V8Node::firstChildAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); - arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - arbaicaRetObj.MakeWeak(0, V8NodeList::jsDestructor); - return arbaicaRetObj; + if (!privData->nativeObj->getFirstChild()) return v8::Undefined(); + Arabica::DOM::Node<std::string>* arbaicaRet = new Arabica::DOM::Node<std::string>(privData->nativeObj->getFirstChild()); -} + v8::Handle<v8::Function> arbaicaRetCtor = V8Node::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance()); -v8::Handle<v8::Value> V8Node::firstChildAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = arbaicaRet; + + arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + arbaicaRetObj.MakeWeak(0, V8Node::jsDestructor); + return arbaicaRetObj; - if (!privData->nativeObj->getFirstChild()) return v8::Undefined(); - Arabica::DOM::Node<std::string>* arbaicaRet = new Arabica::DOM::Node<std::string>(privData->nativeObj->getFirstChild()); + } - v8::Handle<v8::Function> arbaicaRetCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance()); + v8::Handle<v8::Value> V8Node::lastChildAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); - struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = arbaicaRet; + if (!privData->nativeObj->getLastChild()) return v8::Undefined(); + Arabica::DOM::Node<std::string>* arbaicaRet = new Arabica::DOM::Node<std::string>(privData->nativeObj->getLastChild()); - arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - arbaicaRetObj.MakeWeak(0, V8Node::jsDestructor); - return arbaicaRetObj; + v8::Handle<v8::Function> arbaicaRetCtor = V8Node::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance()); -} + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = arbaicaRet; + + arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + arbaicaRetObj.MakeWeak(0, V8Node::jsDestructor); + return arbaicaRetObj; + + } + + v8::Handle<v8::Value> V8Node::previousSiblingAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); + + if (!privData->nativeObj->getPreviousSibling()) return v8::Undefined(); + Arabica::DOM::Node<std::string>* arbaicaRet = new Arabica::DOM::Node<std::string>(privData->nativeObj->getPreviousSibling()); + + v8::Handle<v8::Function> arbaicaRetCtor = V8Node::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance()); + + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = arbaicaRet; + + arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + arbaicaRetObj.MakeWeak(0, V8Node::jsDestructor); + return arbaicaRetObj; + + } -v8::Handle<v8::Value> V8Node::lastChildAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); + v8::Handle<v8::Value> V8Node::nextSiblingAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); - if (!privData->nativeObj->getLastChild()) return v8::Undefined(); - Arabica::DOM::Node<std::string>* arbaicaRet = new Arabica::DOM::Node<std::string>(privData->nativeObj->getLastChild()); + if (!privData->nativeObj->getNextSibling()) return v8::Undefined(); + Arabica::DOM::Node<std::string>* arbaicaRet = new Arabica::DOM::Node<std::string>(privData->nativeObj->getNextSibling()); + + v8::Handle<v8::Function> arbaicaRetCtor = V8Node::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance()); + + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = arbaicaRet; + + arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + arbaicaRetObj.MakeWeak(0, V8Node::jsDestructor); + return arbaicaRetObj; - v8::Handle<v8::Function> arbaicaRetCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance()); + } - struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = arbaicaRet; + v8::Handle<v8::Value> V8Node::ownerDocumentAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); - arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - arbaicaRetObj.MakeWeak(0, V8Node::jsDestructor); - return arbaicaRetObj; + if (!privData->nativeObj->getOwnerDocument()) return v8::Undefined(); + Arabica::DOM::Document<std::string>* arbaicaRet = new Arabica::DOM::Document<std::string>(privData->nativeObj->getOwnerDocument()); -} + v8::Handle<v8::Function> arbaicaRetCtor = V8Document::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance()); -v8::Handle<v8::Value> V8Node::previousSiblingAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); + struct V8Document::V8DocumentPrivate* retPrivData = new V8Document::V8DocumentPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = arbaicaRet; + + arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + arbaicaRetObj.MakeWeak(0, V8Document::jsDestructor); + return arbaicaRetObj; - if (!privData->nativeObj->getPreviousSibling()) return v8::Undefined(); - Arabica::DOM::Node<std::string>* arbaicaRet = new Arabica::DOM::Node<std::string>(privData->nativeObj->getPreviousSibling()); + } - v8::Handle<v8::Function> arbaicaRetCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance()); + v8::Handle<v8::Value> V8Node::namespaceURIAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); - struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = arbaicaRet; + return v8::String::New(privData->nativeObj->getNamespaceURI().c_str()); + } - arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - arbaicaRetObj.MakeWeak(0, V8Node::jsDestructor); - return arbaicaRetObj; + v8::Handle<v8::Value> V8Node::prefixAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); -} + return v8::String::New(privData->nativeObj->getPrefix().c_str()); + } -v8::Handle<v8::Value> V8Node::nextSiblingAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); + void V8Node::prefixAttrSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); + v8::String::AsciiValue localPrefix(value); + privData->nativeObj->setPrefix(*localPrefix); + } - if (!privData->nativeObj->getNextSibling()) return v8::Undefined(); - Arabica::DOM::Node<std::string>* arbaicaRet = new Arabica::DOM::Node<std::string>(privData->nativeObj->getNextSibling()); + v8::Handle<v8::Value> V8Node::localNameAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); - v8::Handle<v8::Function> arbaicaRetCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance()); + return v8::String::New(privData->nativeObj->getLocalName().c_str()); + } + v8::Handle<v8::Value> V8Node::insertBeforeCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in insertBefore"); + if (!((V8Node::hasInstance(args[0])) && (V8Node::hasInstance(args[1])))) + throw V8Exception("Parameter mismatch while calling insertBefore"); - struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = arbaicaRet; + v8::Local<v8::Object> self = args.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); + Arabica::DOM::Node<std::string>* localNewChild = V8DOM::toClassPtr<V8Node::V8NodePrivate >(args[0]->ToObject()->GetInternalField(0))->nativeObj; + Arabica::DOM::Node<std::string>* localRefChild = V8DOM::toClassPtr<V8Node::V8NodePrivate >(args[1]->ToObject()->GetInternalField(0))->nativeObj; - arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - arbaicaRetObj.MakeWeak(0, V8Node::jsDestructor); - return arbaicaRetObj; + Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->insertBefore(*localNewChild, *localRefChild)); + 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->nativeObj = retVal; -v8::Handle<v8::Value> V8Node::attributesAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj.MakeWeak(0, V8Node::jsDestructor); + return retObj; - Arabica::DOM::NamedNodeMap<std::string>* arbaicaRet = new Arabica::DOM::NamedNodeMap<std::string>(privData->nativeObj->getAttributes()); + } - v8::Handle<v8::Function> arbaicaRetCtor = V8NamedNodeMap::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance()); + v8::Handle<v8::Value> V8Node::replaceChildCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in replaceChild"); + if (!((V8Node::hasInstance(args[0])) && (V8Node::hasInstance(args[1])))) + throw V8Exception("Parameter mismatch while calling replaceChild"); - struct V8NamedNodeMap::V8NamedNodeMapPrivate* retPrivData = new V8NamedNodeMap::V8NamedNodeMapPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = arbaicaRet; + v8::Local<v8::Object> self = args.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); + Arabica::DOM::Node<std::string>* localNewChild = V8DOM::toClassPtr<V8Node::V8NodePrivate >(args[0]->ToObject()->GetInternalField(0))->nativeObj; + Arabica::DOM::Node<std::string>* localOldChild = V8DOM::toClassPtr<V8Node::V8NodePrivate >(args[1]->ToObject()->GetInternalField(0))->nativeObj; - arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - arbaicaRetObj.MakeWeak(0, V8NamedNodeMap::jsDestructor); - return arbaicaRetObj; + Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->replaceChild(*localNewChild, *localOldChild)); + 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->nativeObj = retVal; -v8::Handle<v8::Value> V8Node::ownerDocumentAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - if (!privData->nativeObj->getOwnerDocument()) return v8::Undefined(); - Arabica::DOM::Document<std::string>* arbaicaRet = new Arabica::DOM::Document<std::string>(privData->nativeObj->getOwnerDocument()); + retObj.MakeWeak(0, V8Node::jsDestructor); + return retObj; - v8::Handle<v8::Function> arbaicaRetCtor = V8Document::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance()); + } - struct V8Document::V8DocumentPrivate* retPrivData = new V8Document::V8DocumentPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = arbaicaRet; + v8::Handle<v8::Value> V8Node::removeChildCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in removeChild"); + if (!(V8Node::hasInstance(args[0]))) + throw V8Exception("Parameter mismatch while calling removeChild"); - arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - arbaicaRetObj.MakeWeak(0, V8Document::jsDestructor); - return arbaicaRetObj; + v8::Local<v8::Object> self = args.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); + Arabica::DOM::Node<std::string>* localOldChild = V8DOM::toClassPtr<V8Node::V8NodePrivate >(args[0]->ToObject()->GetInternalField(0))->nativeObj; -} + Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->removeChild(*localOldChild)); + v8::Handle<v8::Function> retCtor = V8Node::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); -v8::Handle<v8::Value> V8Node::namespaceURIAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - return v8::String::New(privData->nativeObj->getNamespaceURI().c_str()); -} + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); -v8::Handle<v8::Value> V8Node::prefixAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); + retObj.MakeWeak(0, V8Node::jsDestructor); + return retObj; - return v8::String::New(privData->nativeObj->getPrefix().c_str()); -} + } -void V8Node::prefixAttrSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localPrefix(value); - privData->nativeObj->setPrefix(*localPrefix); -} + v8::Handle<v8::Value> V8Node::appendChildCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in appendChild"); + if (!(V8Node::hasInstance(args[0]))) + throw V8Exception("Parameter mismatch while calling appendChild"); -v8::Handle<v8::Value> V8Node::localNameAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); + v8::Local<v8::Object> self = args.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); + Arabica::DOM::Node<std::string>* localNewChild = V8DOM::toClassPtr<V8Node::V8NodePrivate >(args[0]->ToObject()->GetInternalField(0))->nativeObj; - return v8::String::New(privData->nativeObj->getLocalName().c_str()); -} -v8::Handle<v8::Value> V8Node::insertBeforeCallback(const v8::Arguments& args) { - if (args.Length() < 2) - throw V8Exception("Wrong number of arguments in insertBefore"); - if (!((V8Node::hasInstance(args[0])) && (V8Node::hasInstance(args[1])))) - throw V8Exception("Parameter mismatch while calling insertBefore"); + Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->appendChild(*localNewChild)); + v8::Handle<v8::Function> retCtor = V8Node::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); - v8::Local<v8::Object> self = args.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); - Arabica::DOM::Node<std::string>* localNewChild = V8DOM::toClassPtr<V8Node::V8NodePrivate >(args[0]->ToObject()->GetInternalField(0))->nativeObj; - Arabica::DOM::Node<std::string>* localRefChild = V8DOM::toClassPtr<V8Node::V8NodePrivate >(args[1]->ToObject()->GetInternalField(0))->nativeObj; + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->insertBefore(*localNewChild, *localRefChild)); - v8::Handle<v8::Function> retCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + retObj.MakeWeak(0, V8Node::jsDestructor); + return retObj; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + } - retObj.MakeWeak(0, V8Node::jsDestructor); - return retObj; + v8::Handle<v8::Value> V8Node::hasChildNodesCallback(const v8::Arguments& args) { -} + v8::Local<v8::Object> self = args.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); -v8::Handle<v8::Value> V8Node::replaceChildCallback(const v8::Arguments& args) { - if (args.Length() < 2) - throw V8Exception("Wrong number of arguments in replaceChild"); - if (!((V8Node::hasInstance(args[0])) && (V8Node::hasInstance(args[1])))) - throw V8Exception("Parameter mismatch while calling replaceChild"); + bool retVal = privData->nativeObj->hasChildNodes(); - v8::Local<v8::Object> self = args.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); - Arabica::DOM::Node<std::string>* localNewChild = V8DOM::toClassPtr<V8Node::V8NodePrivate >(args[0]->ToObject()->GetInternalField(0))->nativeObj; - Arabica::DOM::Node<std::string>* localOldChild = V8DOM::toClassPtr<V8Node::V8NodePrivate >(args[1]->ToObject()->GetInternalField(0))->nativeObj; + return v8::Boolean::New(retVal); + } - Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->replaceChild(*localNewChild, *localOldChild)); - v8::Handle<v8::Function> retCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + v8::Handle<v8::Value> V8Node::cloneNodeCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in cloneNode"); - struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + v8::Local<v8::Object> self = args.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); + bool localDeep = args[0]->ToBoolean()->BooleanValue(); - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->cloneNode(localDeep)); + v8::Handle<v8::Function> retCtor = V8Node::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); - retObj.MakeWeak(0, V8Node::jsDestructor); - return retObj; + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; -} + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); -v8::Handle<v8::Value> V8Node::removeChildCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in removeChild"); - if (!(V8Node::hasInstance(args[0]))) - throw V8Exception("Parameter mismatch while calling removeChild"); + retObj.MakeWeak(0, V8Node::jsDestructor); + return retObj; - v8::Local<v8::Object> self = args.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); - Arabica::DOM::Node<std::string>* localOldChild = V8DOM::toClassPtr<V8Node::V8NodePrivate >(args[0]->ToObject()->GetInternalField(0))->nativeObj; + } - Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->removeChild(*localOldChild)); - v8::Handle<v8::Function> retCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + v8::Handle<v8::Value> V8Node::normalizeCallback(const v8::Arguments& args) { - struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + v8::Local<v8::Object> self = args.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + privData->nativeObj->normalize(); - retObj.MakeWeak(0, V8Node::jsDestructor); - return retObj; + return v8::Undefined(); + } -} + v8::Handle<v8::Value> V8Node::isSupportedCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in isSupported"); -v8::Handle<v8::Value> V8Node::appendChildCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in appendChild"); - if (!(V8Node::hasInstance(args[0]))) - throw V8Exception("Parameter mismatch while calling appendChild"); + v8::Local<v8::Object> self = args.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); + v8::String::AsciiValue localFeature(args[0]); + v8::String::AsciiValue localVersion(args[1]); - v8::Local<v8::Object> self = args.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); - Arabica::DOM::Node<std::string>* localNewChild = V8DOM::toClassPtr<V8Node::V8NodePrivate >(args[0]->ToObject()->GetInternalField(0))->nativeObj; + bool retVal = privData->nativeObj->isSupported(*localFeature, *localVersion); - Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->appendChild(*localNewChild)); - v8::Handle<v8::Function> retCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + return v8::Boolean::New(retVal); + } - struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + v8::Handle<v8::Value> V8Node::hasAttributesCallback(const v8::Arguments& args) { - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + v8::Local<v8::Object> self = args.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); - retObj.MakeWeak(0, V8Node::jsDestructor); - return retObj; + bool retVal = privData->nativeObj->hasAttributes(); -} + return v8::Boolean::New(retVal); + } -v8::Handle<v8::Value> V8Node::hasChildNodesCallback(const v8::Arguments& args) { + bool V8Node::hasInstance(v8::Handle<v8::Value> value) { + return getTmpl()->HasInstance(value); + } - v8::Local<v8::Object> self = args.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); - - bool retVal = privData->nativeObj->hasChildNodes(); - - return v8::Boolean::New(retVal); -} - -v8::Handle<v8::Value> V8Node::cloneNodeCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in cloneNode"); - - v8::Local<v8::Object> self = args.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); - bool localDeep = args[0]->ToBoolean()->BooleanValue(); - - Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->cloneNode(localDeep)); - 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->nativeObj = retVal; - - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - - retObj.MakeWeak(0, V8Node::jsDestructor); - return retObj; - -} - -v8::Handle<v8::Value> V8Node::normalizeCallback(const v8::Arguments& args) { - - v8::Local<v8::Object> self = args.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); - - privData->nativeObj->normalize(); - - return v8::Undefined(); -} - -v8::Handle<v8::Value> V8Node::isSupportedCallback(const v8::Arguments& args) { - if (args.Length() < 2) - throw V8Exception("Wrong number of arguments in isSupported"); - - v8::Local<v8::Object> self = args.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localFeature(args[0]); - v8::String::AsciiValue localVersion(args[1]); - - bool retVal = privData->nativeObj->isSupported(*localFeature, *localVersion); - - return v8::Boolean::New(retVal); -} - -v8::Handle<v8::Value> V8Node::hasAttributesCallback(const v8::Arguments& args) { - - v8::Local<v8::Object> self = args.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); - - bool retVal = privData->nativeObj->hasAttributes(); - - return v8::Boolean::New(retVal); -} - -bool V8Node::hasInstance(v8::Handle<v8::Value> value) { - return getTmpl()->HasInstance(value); -} - -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.h index bb6bbd2..6bb90f9 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.h @@ -32,131 +32,131 @@ namespace DOM { class V8Node { public: - struct V8NodePrivate { - V8DOM* dom; - Arabica::DOM::Node<std::string>* nativeObj; - }; - - V8_DESTRUCTOR(V8NodePrivate); - static bool hasInstance(v8::Handle<v8::Value>); - - static v8::Handle<v8::Value> insertBeforeCallback(const v8::Arguments&); - static v8::Handle<v8::Value> replaceChildCallback(const v8::Arguments&); - static v8::Handle<v8::Value> removeChildCallback(const v8::Arguments&); - static v8::Handle<v8::Value> appendChildCallback(const v8::Arguments&); - static v8::Handle<v8::Value> hasChildNodesCallback(const v8::Arguments&); - static v8::Handle<v8::Value> cloneNodeCallback(const v8::Arguments&); - static v8::Handle<v8::Value> normalizeCallback(const v8::Arguments&); - static v8::Handle<v8::Value> isSupportedCallback(const v8::Arguments&); - static v8::Handle<v8::Value> hasAttributesCallback(const v8::Arguments&); - - static v8::Handle<v8::Value> nodeNameAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> nodeValueAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static void nodeValueAttrSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> nodeTypeAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> parentNodeAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> childNodesAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> firstChildAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> lastChildAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> previousSiblingAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> nextSiblingAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> attributesAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> ownerDocumentAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> namespaceURIAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> prefixAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static void prefixAttrSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> localNameAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - - 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(); - (void)prototype; // surpress unused warnings - - instance->SetInternalFieldCount(1); - - 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)); - - 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)); - - tmpl->Set(v8::String::NewSymbol("ELEMENT_NODE"), v8::Integer::New(1), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); - prototype->Set(v8::String::NewSymbol("ELEMENT_NODE"), v8::Integer::New(1), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); - tmpl->Set(v8::String::NewSymbol("ATTRIBUTE_NODE"), v8::Integer::New(2), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); - prototype->Set(v8::String::NewSymbol("ATTRIBUTE_NODE"), v8::Integer::New(2), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); - tmpl->Set(v8::String::NewSymbol("TEXT_NODE"), v8::Integer::New(3), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); - prototype->Set(v8::String::NewSymbol("TEXT_NODE"), v8::Integer::New(3), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); - tmpl->Set(v8::String::NewSymbol("CDATA_SECTION_NODE"), v8::Integer::New(4), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); - prototype->Set(v8::String::NewSymbol("CDATA_SECTION_NODE"), v8::Integer::New(4), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); - tmpl->Set(v8::String::NewSymbol("ENTITY_REFERENCE_NODE"), v8::Integer::New(5), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); - prototype->Set(v8::String::NewSymbol("ENTITY_REFERENCE_NODE"), v8::Integer::New(5), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); - tmpl->Set(v8::String::NewSymbol("ENTITY_NODE"), v8::Integer::New(6), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); - prototype->Set(v8::String::NewSymbol("ENTITY_NODE"), v8::Integer::New(6), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); - tmpl->Set(v8::String::NewSymbol("PROCESSING_INSTRUCTION_NODE"), v8::Integer::New(7), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); - prototype->Set(v8::String::NewSymbol("PROCESSING_INSTRUCTION_NODE"), v8::Integer::New(7), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); - tmpl->Set(v8::String::NewSymbol("COMMENT_NODE"), v8::Integer::New(8), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); - prototype->Set(v8::String::NewSymbol("COMMENT_NODE"), v8::Integer::New(8), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); - tmpl->Set(v8::String::NewSymbol("DOCUMENT_NODE"), v8::Integer::New(9), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); - prototype->Set(v8::String::NewSymbol("DOCUMENT_NODE"), v8::Integer::New(9), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); - tmpl->Set(v8::String::NewSymbol("DOCUMENT_TYPE_NODE"), v8::Integer::New(10), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); - prototype->Set(v8::String::NewSymbol("DOCUMENT_TYPE_NODE"), v8::Integer::New(10), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); - tmpl->Set(v8::String::NewSymbol("DOCUMENT_FRAGMENT_NODE"), v8::Integer::New(11), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); - prototype->Set(v8::String::NewSymbol("DOCUMENT_FRAGMENT_NODE"), v8::Integer::New(11), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); - tmpl->Set(v8::String::NewSymbol("NOTATION_NODE"), v8::Integer::New(12), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); - prototype->Set(v8::String::NewSymbol("NOTATION_NODE"), v8::Integer::New(12), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); - - Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); - } - return Tmpl; - } + struct V8NodePrivate { + V8DOM* dom; + Arabica::DOM::Node<std::string>* nativeObj; + }; + + V8_DESTRUCTOR(V8NodePrivate); + static bool hasInstance(v8::Handle<v8::Value>); + + static v8::Handle<v8::Value> insertBeforeCallback(const v8::Arguments&); + static v8::Handle<v8::Value> replaceChildCallback(const v8::Arguments&); + static v8::Handle<v8::Value> removeChildCallback(const v8::Arguments&); + static v8::Handle<v8::Value> appendChildCallback(const v8::Arguments&); + static v8::Handle<v8::Value> hasChildNodesCallback(const v8::Arguments&); + static v8::Handle<v8::Value> cloneNodeCallback(const v8::Arguments&); + static v8::Handle<v8::Value> normalizeCallback(const v8::Arguments&); + static v8::Handle<v8::Value> isSupportedCallback(const v8::Arguments&); + static v8::Handle<v8::Value> hasAttributesCallback(const v8::Arguments&); + + static v8::Handle<v8::Value> nodeNameAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> nodeValueAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static void nodeValueAttrSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> nodeTypeAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> parentNodeAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> childNodesAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> firstChildAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> lastChildAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> previousSiblingAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> nextSiblingAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> attributesCustomAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> ownerDocumentAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> namespaceURIAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> prefixAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static void prefixAttrSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> localNameAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + + 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(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); + + 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::attributesCustomAttrGetter, 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)); + + 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)); + + tmpl->Set(v8::String::NewSymbol("ELEMENT_NODE"), v8::Integer::New(1), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("ELEMENT_NODE"), v8::Integer::New(1), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + tmpl->Set(v8::String::NewSymbol("ATTRIBUTE_NODE"), v8::Integer::New(2), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("ATTRIBUTE_NODE"), v8::Integer::New(2), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + tmpl->Set(v8::String::NewSymbol("TEXT_NODE"), v8::Integer::New(3), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("TEXT_NODE"), v8::Integer::New(3), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + tmpl->Set(v8::String::NewSymbol("CDATA_SECTION_NODE"), v8::Integer::New(4), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("CDATA_SECTION_NODE"), v8::Integer::New(4), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + tmpl->Set(v8::String::NewSymbol("ENTITY_REFERENCE_NODE"), v8::Integer::New(5), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("ENTITY_REFERENCE_NODE"), v8::Integer::New(5), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + tmpl->Set(v8::String::NewSymbol("ENTITY_NODE"), v8::Integer::New(6), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("ENTITY_NODE"), v8::Integer::New(6), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + tmpl->Set(v8::String::NewSymbol("PROCESSING_INSTRUCTION_NODE"), v8::Integer::New(7), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("PROCESSING_INSTRUCTION_NODE"), v8::Integer::New(7), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + tmpl->Set(v8::String::NewSymbol("COMMENT_NODE"), v8::Integer::New(8), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("COMMENT_NODE"), v8::Integer::New(8), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + tmpl->Set(v8::String::NewSymbol("DOCUMENT_NODE"), v8::Integer::New(9), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("DOCUMENT_NODE"), v8::Integer::New(9), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + tmpl->Set(v8::String::NewSymbol("DOCUMENT_TYPE_NODE"), v8::Integer::New(10), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("DOCUMENT_TYPE_NODE"), v8::Integer::New(10), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + tmpl->Set(v8::String::NewSymbol("DOCUMENT_FRAGMENT_NODE"), v8::Integer::New(11), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("DOCUMENT_FRAGMENT_NODE"), v8::Integer::New(11), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + tmpl->Set(v8::String::NewSymbol("NOTATION_NODE"), v8::Integer::New(12), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("NOTATION_NODE"), v8::Integer::New(12), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + + Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); + } + return Tmpl; + } }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeCustom.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeCustom.cpp new file mode 100644 index 0000000..09f9e1d --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeCustom.cpp @@ -0,0 +1,31 @@ +#include "V8Node.h" +#include "V8NamedNodeMap.h" + +namespace Arabica { +namespace DOM { + +v8::Handle<v8::Value> V8Node::attributesCustomAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); + + if (!privData->nativeObj->hasAttributes()) { + return v8::Undefined(); + } + + Arabica::DOM::NamedNodeMap<std::string>* arbaicaRet = new Arabica::DOM::NamedNodeMap<std::string>(privData->nativeObj->getAttributes()); + + v8::Handle<v8::Function> arbaicaRetCtor = V8NamedNodeMap::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance()); + + struct V8NamedNodeMap::V8NamedNodeMapPrivate* retPrivData = new V8NamedNodeMap::V8NamedNodeMapPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = arbaicaRet; + + arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + arbaicaRetObj.MakeWeak(0, V8NamedNodeMap::jsDestructor); + return arbaicaRetObj; + +} + +} +}
\ No newline at end of file diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeList.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeList.cpp index bee706e..bc2afb5 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeList.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeList.cpp @@ -4,41 +4,41 @@ namespace Arabica { namespace DOM { -v8::Persistent<v8::FunctionTemplate> V8NodeList::Tmpl; + v8::Persistent<v8::FunctionTemplate> V8NodeList::Tmpl; -v8::Handle<v8::Value> V8NodeList::lengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8NodeListPrivate* privData = V8DOM::toClassPtr<V8NodeListPrivate >(self->GetInternalField(0)); + v8::Handle<v8::Value> V8NodeList::lengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8NodeListPrivate* privData = V8DOM::toClassPtr<V8NodeListPrivate >(self->GetInternalField(0)); - return v8::Integer::New(privData->nativeObj->getLength()); -} -v8::Handle<v8::Value> V8NodeList::itemCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in item"); + return v8::Integer::New(privData->nativeObj->getLength()); + } + v8::Handle<v8::Value> V8NodeList::itemCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in item"); - v8::Local<v8::Object> self = args.Holder(); - struct V8NodeListPrivate* privData = V8DOM::toClassPtr<V8NodeListPrivate >(self->GetInternalField(0)); - unsigned long localIndex = args[0]->ToNumber()->Uint32Value(); + v8::Local<v8::Object> self = args.Holder(); + struct V8NodeListPrivate* privData = V8DOM::toClassPtr<V8NodeListPrivate >(self->GetInternalField(0)); + unsigned long localIndex = args[0]->ToNumber()->Uint32Value(); - Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->item(localIndex)); - v8::Handle<v8::Function> retCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->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->nativeObj = retVal; + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, V8Node::jsDestructor); - return retObj; + retObj.MakeWeak(0, V8Node::jsDestructor); + return retObj; -} + } -bool V8NodeList::hasInstance(v8::Handle<v8::Value> value) { - return getTmpl()->HasInstance(value); -} + bool V8NodeList::hasInstance(v8::Handle<v8::Value> value) { + return getTmpl()->HasInstance(value); + } -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeList.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeList.h index c454e65..8a07998 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeList.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeList.h @@ -32,44 +32,44 @@ namespace DOM { class V8NodeList { public: - struct V8NodeListPrivate { - V8DOM* dom; - Arabica::DOM::NodeList<std::string>* nativeObj; - }; + struct V8NodeListPrivate { + V8DOM* dom; + Arabica::DOM::NodeList<std::string>* nativeObj; + }; - V8_DESTRUCTOR(V8NodeListPrivate); - static bool hasInstance(v8::Handle<v8::Value>); + V8_DESTRUCTOR(V8NodeListPrivate); + static bool hasInstance(v8::Handle<v8::Value>); - static v8::Handle<v8::Value> itemCallback(const v8::Arguments&); + static v8::Handle<v8::Value> itemCallback(const v8::Arguments&); - static v8::Handle<v8::Value> lengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> indexedPropertyCustomGetter(uint32_t, const v8::AccessorInfo&); + static v8::Handle<v8::Value> lengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> indexedPropertyCustomGetter(uint32_t, const v8::AccessorInfo&); - 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("NodeList")); - tmpl->ReadOnlyPrototype(); + 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("NodeList")); + tmpl->ReadOnlyPrototype(); - v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); - v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); - (void)prototype; // surpress unused warnings + v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); + v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); - instance->SetInternalFieldCount(1); + instance->SetAccessor(v8::String::NewSymbol("length"), V8NodeList::lengthAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("length"), V8NodeList::lengthAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + instance->SetIndexedPropertyHandler(V8NodeList::indexedPropertyCustomGetter, 0); + prototype->Set(v8::String::NewSymbol("item"), + v8::FunctionTemplate::New(V8NodeList::itemCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - instance->SetIndexedPropertyHandler(V8NodeList::indexedPropertyCustomGetter, 0); - prototype->Set(v8::String::NewSymbol("item"), - v8::FunctionTemplate::New(V8NodeList::itemCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - - Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); - } - return Tmpl; - } + Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); + } + return Tmpl; + } }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.cpp index fade729..6f59a90 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.cpp @@ -3,35 +3,35 @@ namespace Arabica { namespace DOM { -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(); - struct V8NodeSetPrivate* privData = V8DOM::toClassPtr<V8NodeSetPrivate >(self->GetInternalField(0)); + v8::Handle<v8::Value> V8NodeSet::sizeAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8NodeSetPrivate* privData = V8DOM::toClassPtr<V8NodeSetPrivate >(self->GetInternalField(0)); - return v8::Integer::New(privData->nativeObj->size()); -} + return v8::Integer::New(privData->nativeObj->size()); + } -v8::Handle<v8::Value> V8NodeSet::emptyAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8NodeSetPrivate* privData = V8DOM::toClassPtr<V8NodeSetPrivate >(self->GetInternalField(0)); + v8::Handle<v8::Value> V8NodeSet::emptyAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8NodeSetPrivate* privData = V8DOM::toClassPtr<V8NodeSetPrivate >(self->GetInternalField(0)); - return v8::Boolean::New(privData->nativeObj->empty()); -} -v8::Handle<v8::Value> V8NodeSet::toDocumentOrderCallback(const v8::Arguments& args) { + return v8::Boolean::New(privData->nativeObj->empty()); + } + v8::Handle<v8::Value> V8NodeSet::toDocumentOrderCallback(const v8::Arguments& args) { - v8::Local<v8::Object> self = args.Holder(); - struct V8NodeSetPrivate* privData = V8DOM::toClassPtr<V8NodeSetPrivate >(self->GetInternalField(0)); + v8::Local<v8::Object> self = args.Holder(); + struct V8NodeSetPrivate* privData = V8DOM::toClassPtr<V8NodeSetPrivate >(self->GetInternalField(0)); - privData->nativeObj->to_document_order(); + privData->nativeObj->to_document_order(); - return v8::Undefined(); -} + return v8::Undefined(); + } -bool V8NodeSet::hasInstance(v8::Handle<v8::Value> value) { - return getTmpl()->HasInstance(value); -} + bool V8NodeSet::hasInstance(v8::Handle<v8::Value> value) { + return getTmpl()->HasInstance(value); + } -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.h index 97b5d4f..78e4410 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.h @@ -32,47 +32,47 @@ namespace DOM { class V8NodeSet { public: - struct V8NodeSetPrivate { - V8DOM* dom; - Arabica::XPath::NodeSet<std::string>* nativeObj; - }; - - V8_DESTRUCTOR(V8NodeSetPrivate); - static bool hasInstance(v8::Handle<v8::Value>); - - static v8::Handle<v8::Value> toDocumentOrderCallback(const v8::Arguments&); - - static v8::Handle<v8::Value> sizeAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> emptyAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> indexedPropertyCustomGetter(uint32_t, const v8::AccessorInfo&); - - 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(); - (void)prototype; // surpress unused warnings - - instance->SetInternalFieldCount(1); - - instance->SetAccessor(v8::String::NewSymbol("size"), V8NodeSet::sizeAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("empty"), V8NodeSet::emptyAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - - instance->SetIndexedPropertyHandler(V8NodeSet::indexedPropertyCustomGetter, 0); - prototype->Set(v8::String::NewSymbol("toDocumentOrder"), - v8::FunctionTemplate::New(V8NodeSet::toDocumentOrderCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - - - Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); - } - return Tmpl; - } + struct V8NodeSetPrivate { + V8DOM* dom; + Arabica::XPath::NodeSet<std::string>* nativeObj; + }; + + V8_DESTRUCTOR(V8NodeSetPrivate); + static bool hasInstance(v8::Handle<v8::Value>); + + static v8::Handle<v8::Value> toDocumentOrderCallback(const v8::Arguments&); + + static v8::Handle<v8::Value> sizeAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> emptyAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> indexedPropertyCustomGetter(uint32_t, const v8::AccessorInfo&); + + 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(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); + + instance->SetAccessor(v8::String::NewSymbol("size"), V8NodeSet::sizeAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("empty"), V8NodeSet::emptyAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + + instance->SetIndexedPropertyHandler(V8NodeSet::indexedPropertyCustomGetter, 0); + prototype->Set(v8::String::NewSymbol("toDocumentOrder"), + v8::FunctionTemplate::New(V8NodeSet::toDocumentOrderCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + + + Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); + } + return Tmpl; + } }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Notation.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Notation.cpp index 129563d..5ecdd10 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Notation.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Notation.cpp @@ -4,25 +4,25 @@ namespace Arabica { namespace DOM { -v8::Persistent<v8::FunctionTemplate> V8Notation::Tmpl; + v8::Persistent<v8::FunctionTemplate> V8Notation::Tmpl; -v8::Handle<v8::Value> V8Notation::publicIdAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8NotationPrivate* privData = V8DOM::toClassPtr<V8NotationPrivate >(self->GetInternalField(0)); + v8::Handle<v8::Value> V8Notation::publicIdAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8NotationPrivate* privData = V8DOM::toClassPtr<V8NotationPrivate >(self->GetInternalField(0)); - return v8::String::New(privData->nativeObj->getPublicId().c_str()); -} + return v8::String::New(privData->nativeObj->getPublicId().c_str()); + } -v8::Handle<v8::Value> V8Notation::systemIdAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8NotationPrivate* privData = V8DOM::toClassPtr<V8NotationPrivate >(self->GetInternalField(0)); + v8::Handle<v8::Value> V8Notation::systemIdAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8NotationPrivate* privData = V8DOM::toClassPtr<V8NotationPrivate >(self->GetInternalField(0)); - return v8::String::New(privData->nativeObj->getSystemId().c_str()); -} -bool V8Notation::hasInstance(v8::Handle<v8::Value> value) { - return getTmpl()->HasInstance(value); -} + return v8::String::New(privData->nativeObj->getSystemId().c_str()); + } + bool V8Notation::hasInstance(v8::Handle<v8::Value> value) { + return getTmpl()->HasInstance(value); + } -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Notation.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Notation.h index 0745728..2102a24 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Notation.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Notation.h @@ -33,43 +33,43 @@ namespace DOM { class V8Notation { public: - struct V8NotationPrivate { - V8DOM* dom; - Arabica::DOM::Notation<std::string>* nativeObj; - }; + struct V8NotationPrivate { + V8DOM* dom; + Arabica::DOM::Notation<std::string>* nativeObj; + }; - V8_DESTRUCTOR(V8NotationPrivate); - static bool hasInstance(v8::Handle<v8::Value>); + V8_DESTRUCTOR(V8NotationPrivate); + static bool hasInstance(v8::Handle<v8::Value>); - static v8::Handle<v8::Value> publicIdAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> systemIdAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> publicIdAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> systemIdAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - 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("Notation")); - tmpl->ReadOnlyPrototype(); + 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("Notation")); + tmpl->ReadOnlyPrototype(); - v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); - v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); - (void)prototype; // surpress unused warnings + v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); + v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); - instance->SetInternalFieldCount(1); + instance->SetAccessor(v8::String::NewSymbol("publicId"), V8Notation::publicIdAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("systemId"), V8Notation::systemIdAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("publicId"), V8Notation::publicIdAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("systemId"), V8Notation::systemIdAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - - tmpl->Inherit(V8Node::getTmpl()); - Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); - } - return Tmpl; - } + tmpl->Inherit(V8Node::getTmpl()); + Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); + } + return Tmpl; + } }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ProcessingInstruction.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ProcessingInstruction.cpp index c6d2b28..f28a56d 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ProcessingInstruction.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ProcessingInstruction.cpp @@ -4,32 +4,32 @@ namespace Arabica { namespace DOM { -v8::Persistent<v8::FunctionTemplate> V8ProcessingInstruction::Tmpl; + v8::Persistent<v8::FunctionTemplate> V8ProcessingInstruction::Tmpl; -v8::Handle<v8::Value> V8ProcessingInstruction::targetAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8ProcessingInstructionPrivate* privData = V8DOM::toClassPtr<V8ProcessingInstructionPrivate >(self->GetInternalField(0)); + v8::Handle<v8::Value> V8ProcessingInstruction::targetAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8ProcessingInstructionPrivate* privData = V8DOM::toClassPtr<V8ProcessingInstructionPrivate >(self->GetInternalField(0)); - return v8::String::New(privData->nativeObj->getTarget().c_str()); -} + return v8::String::New(privData->nativeObj->getTarget().c_str()); + } -v8::Handle<v8::Value> V8ProcessingInstruction::dataAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8ProcessingInstructionPrivate* privData = V8DOM::toClassPtr<V8ProcessingInstructionPrivate >(self->GetInternalField(0)); + v8::Handle<v8::Value> V8ProcessingInstruction::dataAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8ProcessingInstructionPrivate* privData = V8DOM::toClassPtr<V8ProcessingInstructionPrivate >(self->GetInternalField(0)); - return v8::String::New(privData->nativeObj->getData().c_str()); -} + return v8::String::New(privData->nativeObj->getData().c_str()); + } -void V8ProcessingInstruction::dataAttrSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8ProcessingInstructionPrivate* privData = V8DOM::toClassPtr<V8ProcessingInstructionPrivate >(self->GetInternalField(0)); - v8::String::AsciiValue localData(value); - privData->nativeObj->setData(*localData); -} -bool V8ProcessingInstruction::hasInstance(v8::Handle<v8::Value> value) { - return getTmpl()->HasInstance(value); -} + void V8ProcessingInstruction::dataAttrSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8ProcessingInstructionPrivate* privData = V8DOM::toClassPtr<V8ProcessingInstructionPrivate >(self->GetInternalField(0)); + v8::String::AsciiValue localData(value); + privData->nativeObj->setData(*localData); + } + bool V8ProcessingInstruction::hasInstance(v8::Handle<v8::Value> value) { + return getTmpl()->HasInstance(value); + } -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ProcessingInstruction.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ProcessingInstruction.h index 56b61eb..a588b1f 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ProcessingInstruction.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ProcessingInstruction.h @@ -33,44 +33,44 @@ namespace DOM { class V8ProcessingInstruction { public: - struct V8ProcessingInstructionPrivate { - V8DOM* dom; - Arabica::DOM::ProcessingInstruction<std::string>* nativeObj; - }; + struct V8ProcessingInstructionPrivate { + V8DOM* dom; + Arabica::DOM::ProcessingInstruction<std::string>* nativeObj; + }; - V8_DESTRUCTOR(V8ProcessingInstructionPrivate); - static bool hasInstance(v8::Handle<v8::Value>); + V8_DESTRUCTOR(V8ProcessingInstructionPrivate); + static bool hasInstance(v8::Handle<v8::Value>); - static v8::Handle<v8::Value> targetAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> dataAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static void dataAttrSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> targetAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> dataAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static void dataAttrSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info); - 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("ProcessingInstruction")); - tmpl->ReadOnlyPrototype(); + 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("ProcessingInstruction")); + tmpl->ReadOnlyPrototype(); - v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); - v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); - (void)prototype; // surpress unused warnings + v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); + v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); - instance->SetInternalFieldCount(1); + instance->SetAccessor(v8::String::NewSymbol("target"), V8ProcessingInstruction::targetAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("data"), V8ProcessingInstruction::dataAttrGetter, V8ProcessingInstruction::dataAttrSetter, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("target"), V8ProcessingInstruction::targetAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("data"), V8ProcessingInstruction::dataAttrGetter, V8ProcessingInstruction::dataAttrSetter, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - - tmpl->Inherit(V8Node::getTmpl()); - Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); - } - return Tmpl; - } + tmpl->Inherit(V8Node::getTmpl()); + Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); + } + return Tmpl; + } }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.cpp index 9679d74..54006d5 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.cpp @@ -4,74 +4,74 @@ namespace Arabica { namespace DOM { -v8::Persistent<v8::FunctionTemplate> V8SCXMLEvent::Tmpl; + v8::Persistent<v8::FunctionTemplate> V8SCXMLEvent::Tmpl; -v8::Handle<v8::Value> V8SCXMLEvent::nameAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr<V8SCXMLEventPrivate >(self->GetInternalField(0)); + v8::Handle<v8::Value> V8SCXMLEvent::nameAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr<V8SCXMLEventPrivate >(self->GetInternalField(0)); - return v8::String::New(privData->nativeObj->name.c_str()); -} + return v8::String::New(privData->nativeObj->name.c_str()); + } -v8::Handle<v8::Value> V8SCXMLEvent::originAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr<V8SCXMLEventPrivate >(self->GetInternalField(0)); + v8::Handle<v8::Value> V8SCXMLEvent::originAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr<V8SCXMLEventPrivate >(self->GetInternalField(0)); - if (privData->nativeObj->origin.length() == 0) - return v8::Undefined(); - return v8::String::New(privData->nativeObj->origin.c_str()); -} + if (privData->nativeObj->origin.length() == 0) + return v8::Undefined(); + return v8::String::New(privData->nativeObj->origin.c_str()); + } -v8::Handle<v8::Value> V8SCXMLEvent::origintypeAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr<V8SCXMLEventPrivate >(self->GetInternalField(0)); + v8::Handle<v8::Value> V8SCXMLEvent::origintypeAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr<V8SCXMLEventPrivate >(self->GetInternalField(0)); - if (privData->nativeObj->origintype.length() == 0) - return v8::Undefined(); - return v8::String::New(privData->nativeObj->origintype.c_str()); -} + if (privData->nativeObj->origintype.length() == 0) + return v8::Undefined(); + return v8::String::New(privData->nativeObj->origintype.c_str()); + } -v8::Handle<v8::Value> V8SCXMLEvent::rawAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr<V8SCXMLEventPrivate >(self->GetInternalField(0)); + v8::Handle<v8::Value> V8SCXMLEvent::rawAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr<V8SCXMLEventPrivate >(self->GetInternalField(0)); - if (privData->nativeObj->raw.length() == 0) - return v8::Undefined(); - return v8::String::New(privData->nativeObj->raw.c_str()); -} + if (privData->nativeObj->raw.length() == 0) + return v8::Undefined(); + return v8::String::New(privData->nativeObj->raw.c_str()); + } -v8::Handle<v8::Value> V8SCXMLEvent::domAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr<V8SCXMLEventPrivate >(self->GetInternalField(0)); + v8::Handle<v8::Value> V8SCXMLEvent::domAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr<V8SCXMLEventPrivate >(self->GetInternalField(0)); - if (!privData->nativeObj->dom) return v8::Undefined(); - Arabica::DOM::Node<std::string>* arbaicaRet = new Arabica::DOM::Node<std::string>(privData->nativeObj->dom); + if (!privData->nativeObj->dom) return v8::Undefined(); + Arabica::DOM::Node<std::string>* arbaicaRet = new Arabica::DOM::Node<std::string>(privData->nativeObj->dom); - v8::Handle<v8::Function> arbaicaRetCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance()); + v8::Handle<v8::Function> arbaicaRetCtor = V8Node::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance()); - struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = arbaicaRet; + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = arbaicaRet; + + arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + arbaicaRetObj.MakeWeak(0, V8Node::jsDestructor); + return arbaicaRetObj; - arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - arbaicaRetObj.MakeWeak(0, V8Node::jsDestructor); - return arbaicaRetObj; + } -} + v8::Handle<v8::Value> V8SCXMLEvent::invokeidAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr<V8SCXMLEventPrivate >(self->GetInternalField(0)); -v8::Handle<v8::Value> V8SCXMLEvent::invokeidAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr<V8SCXMLEventPrivate >(self->GetInternalField(0)); + if (privData->nativeObj->invokeid.length() == 0) + return v8::Undefined(); + return v8::String::New(privData->nativeObj->invokeid.c_str()); + } + bool V8SCXMLEvent::hasInstance(v8::Handle<v8::Value> value) { + return getTmpl()->HasInstance(value); + } - if (privData->nativeObj->invokeid.length() == 0) - return v8::Undefined(); - return v8::String::New(privData->nativeObj->invokeid.c_str()); -} -bool V8SCXMLEvent::hasInstance(v8::Handle<v8::Value> value) { - return getTmpl()->HasInstance(value); -} - -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.h index 670d818..992b83e 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.h @@ -32,66 +32,66 @@ namespace DOM { class V8SCXMLEvent { public: - struct V8SCXMLEventPrivate { - V8DOM* dom; - uscxml::Event* nativeObj; - }; - - V8_DESTRUCTOR(V8SCXMLEventPrivate); - static bool hasInstance(v8::Handle<v8::Value>); - - - static v8::Handle<v8::Value> typeCustomAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> nameAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> originAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> origintypeAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> rawAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> domAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> sendidCustomAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> invokeidAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - - 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("SCXMLEvent")); - tmpl->ReadOnlyPrototype(); - - v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); - v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); - (void)prototype; // surpress unused warnings - - instance->SetInternalFieldCount(1); - - instance->SetAccessor(v8::String::NewSymbol("type"), V8SCXMLEvent::typeCustomAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("name"), V8SCXMLEvent::nameAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("origin"), V8SCXMLEvent::originAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("origintype"), V8SCXMLEvent::origintypeAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("raw"), V8SCXMLEvent::rawAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("dom"), V8SCXMLEvent::domAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("sendid"), V8SCXMLEvent::sendidCustomAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("invokeid"), V8SCXMLEvent::invokeidAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - - - tmpl->Set(v8::String::NewSymbol("INTERNAL"), v8::Integer::New(1), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); - prototype->Set(v8::String::NewSymbol("INTERNAL"), v8::Integer::New(1), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); - tmpl->Set(v8::String::NewSymbol("EXTERNAL"), v8::Integer::New(2), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); - prototype->Set(v8::String::NewSymbol("EXTERNAL"), v8::Integer::New(2), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); - tmpl->Set(v8::String::NewSymbol("PLATFORM"), v8::Integer::New(3), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); - prototype->Set(v8::String::NewSymbol("PLATFORM"), v8::Integer::New(3), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); - - Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); - } - return Tmpl; - } + struct V8SCXMLEventPrivate { + V8DOM* dom; + uscxml::Event* nativeObj; + }; + + V8_DESTRUCTOR(V8SCXMLEventPrivate); + static bool hasInstance(v8::Handle<v8::Value>); + + + static v8::Handle<v8::Value> typeCustomAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> nameAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> originAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> origintypeAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> rawAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> domAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> sendidCustomAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> invokeidAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + + 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("SCXMLEvent")); + tmpl->ReadOnlyPrototype(); + + v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); + v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); + + instance->SetAccessor(v8::String::NewSymbol("type"), V8SCXMLEvent::typeCustomAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("name"), V8SCXMLEvent::nameAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("origin"), V8SCXMLEvent::originAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("origintype"), V8SCXMLEvent::origintypeAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("raw"), V8SCXMLEvent::rawAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("dom"), V8SCXMLEvent::domAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("sendid"), V8SCXMLEvent::sendidCustomAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("invokeid"), V8SCXMLEvent::invokeidAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + + + tmpl->Set(v8::String::NewSymbol("INTERNAL"), v8::Integer::New(1), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("INTERNAL"), v8::Integer::New(1), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + tmpl->Set(v8::String::NewSymbol("EXTERNAL"), v8::Integer::New(2), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("EXTERNAL"), v8::Integer::New(2), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + tmpl->Set(v8::String::NewSymbol("PLATFORM"), v8::Integer::New(3), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("PLATFORM"), v8::Integer::New(3), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + + Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); + } + return Tmpl; + } }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Text.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Text.cpp index 42b298a..fb027d5 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Text.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Text.cpp @@ -4,34 +4,34 @@ namespace Arabica { namespace DOM { -v8::Persistent<v8::FunctionTemplate> V8Text::Tmpl; + v8::Persistent<v8::FunctionTemplate> V8Text::Tmpl; -v8::Handle<v8::Value> V8Text::splitTextCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in splitText"); + v8::Handle<v8::Value> V8Text::splitTextCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in splitText"); - v8::Local<v8::Object> self = args.Holder(); - struct V8TextPrivate* privData = V8DOM::toClassPtr<V8TextPrivate >(self->GetInternalField(0)); - unsigned long localOffset = args[0]->ToNumber()->Uint32Value(); + v8::Local<v8::Object> self = args.Holder(); + struct V8TextPrivate* privData = V8DOM::toClassPtr<V8TextPrivate >(self->GetInternalField(0)); + unsigned long localOffset = args[0]->ToNumber()->Uint32Value(); - Arabica::DOM::Text<std::string>* retVal = new Arabica::DOM::Text<std::string>(privData->nativeObj->splitText(localOffset)); - v8::Handle<v8::Function> retCtor = V8Text::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + Arabica::DOM::Text<std::string>* retVal = new Arabica::DOM::Text<std::string>(privData->nativeObj->splitText(localOffset)); + v8::Handle<v8::Function> retCtor = V8Text::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); - struct V8Text::V8TextPrivate* retPrivData = new V8Text::V8TextPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct V8Text::V8TextPrivate* retPrivData = new V8Text::V8TextPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, V8Text::jsDestructor); - return retObj; + retObj.MakeWeak(0, V8Text::jsDestructor); + return retObj; -} + } -bool V8Text::hasInstance(v8::Handle<v8::Value> value) { - return getTmpl()->HasInstance(value); -} + bool V8Text::hasInstance(v8::Handle<v8::Value> value) { + return getTmpl()->HasInstance(value); + } -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Text.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Text.h index 61b92fb..bbf2577 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Text.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Text.h @@ -33,40 +33,40 @@ namespace DOM { class V8Text { public: - struct V8TextPrivate { - V8DOM* dom; - Arabica::DOM::Text<std::string>* nativeObj; - }; + struct V8TextPrivate { + V8DOM* dom; + Arabica::DOM::Text<std::string>* nativeObj; + }; - V8_DESTRUCTOR(V8TextPrivate); - static bool hasInstance(v8::Handle<v8::Value>); + V8_DESTRUCTOR(V8TextPrivate); + static bool hasInstance(v8::Handle<v8::Value>); - static v8::Handle<v8::Value> splitTextCallback(const v8::Arguments&); + static v8::Handle<v8::Value> splitTextCallback(const v8::Arguments&); - 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("Text")); - tmpl->ReadOnlyPrototype(); + 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("Text")); + tmpl->ReadOnlyPrototype(); - v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); - v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); - (void)prototype; // surpress unused warnings + v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); + v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); - instance->SetInternalFieldCount(1); + prototype->Set(v8::String::NewSymbol("splitText"), + v8::FunctionTemplate::New(V8Text::splitTextCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("splitText"), - v8::FunctionTemplate::New(V8Text::splitTextCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); - - tmpl->Inherit(V8CharacterData::getTmpl()); - Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); - } - return Tmpl; - } + tmpl->Inherit(V8CharacterData::getTmpl()); + Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); + } + return Tmpl; + } }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.cpp index 968e53d..38f69ae 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.cpp @@ -4,82 +4,82 @@ namespace Arabica { namespace DOM { -v8::Persistent<v8::FunctionTemplate> V8XPathResult::Tmpl; + v8::Persistent<v8::FunctionTemplate> V8XPathResult::Tmpl; -v8::Handle<v8::Value> V8XPathResult::numberValueAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8XPathResultPrivate* privData = V8DOM::toClassPtr<V8XPathResultPrivate >(self->GetInternalField(0)); + v8::Handle<v8::Value> V8XPathResult::numberValueAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8XPathResultPrivate* privData = V8DOM::toClassPtr<V8XPathResultPrivate >(self->GetInternalField(0)); - return v8::Number::New(privData->nativeObj->asNumber()); -} + return v8::Number::New(privData->nativeObj->asNumber()); + } -v8::Handle<v8::Value> V8XPathResult::stringValueAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8XPathResultPrivate* privData = V8DOM::toClassPtr<V8XPathResultPrivate >(self->GetInternalField(0)); + v8::Handle<v8::Value> V8XPathResult::stringValueAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8XPathResultPrivate* privData = V8DOM::toClassPtr<V8XPathResultPrivate >(self->GetInternalField(0)); - return v8::String::New(privData->nativeObj->asString().c_str()); -} + return v8::String::New(privData->nativeObj->asString().c_str()); + } -v8::Handle<v8::Value> V8XPathResult::booleanValueAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { - v8::Local<v8::Object> self = info.Holder(); - struct V8XPathResultPrivate* privData = V8DOM::toClassPtr<V8XPathResultPrivate >(self->GetInternalField(0)); + v8::Handle<v8::Value> V8XPathResult::booleanValueAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8XPathResultPrivate* privData = V8DOM::toClassPtr<V8XPathResultPrivate >(self->GetInternalField(0)); - return v8::Boolean::New(privData->nativeObj->asBool()); -} -v8::Handle<v8::Value> V8XPathResult::asNodeSetCallback(const v8::Arguments& args) { + return v8::Boolean::New(privData->nativeObj->asBool()); + } + v8::Handle<v8::Value> V8XPathResult::asNodeSetCallback(const v8::Arguments& args) { - v8::Local<v8::Object> self = args.Holder(); - struct V8XPathResultPrivate* privData = V8DOM::toClassPtr<V8XPathResultPrivate >(self->GetInternalField(0)); + v8::Local<v8::Object> self = args.Holder(); + struct V8XPathResultPrivate* privData = V8DOM::toClassPtr<V8XPathResultPrivate >(self->GetInternalField(0)); - Arabica::XPath::NodeSet<std::string>* retVal = new Arabica::XPath::NodeSet<std::string>(privData->nativeObj->asNodeSet()); - v8::Handle<v8::Function> retCtor = V8NodeSet::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + Arabica::XPath::NodeSet<std::string>* retVal = new Arabica::XPath::NodeSet<std::string>(privData->nativeObj->asNodeSet()); + v8::Handle<v8::Function> retCtor = V8NodeSet::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); - struct V8NodeSet::V8NodeSetPrivate* retPrivData = new V8NodeSet::V8NodeSetPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct V8NodeSet::V8NodeSetPrivate* retPrivData = new V8NodeSet::V8NodeSetPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, V8NodeSet::jsDestructor); - return retObj; + retObj.MakeWeak(0, V8NodeSet::jsDestructor); + return retObj; -} + } -v8::Handle<v8::Value> V8XPathResult::asBoolCallback(const v8::Arguments& args) { + v8::Handle<v8::Value> V8XPathResult::asBoolCallback(const v8::Arguments& args) { - v8::Local<v8::Object> self = args.Holder(); - struct V8XPathResultPrivate* privData = V8DOM::toClassPtr<V8XPathResultPrivate >(self->GetInternalField(0)); + v8::Local<v8::Object> self = args.Holder(); + struct V8XPathResultPrivate* privData = V8DOM::toClassPtr<V8XPathResultPrivate >(self->GetInternalField(0)); - bool retVal = privData->nativeObj->asBool(); + bool retVal = privData->nativeObj->asBool(); - return v8::Boolean::New(retVal); -} + return v8::Boolean::New(retVal); + } -v8::Handle<v8::Value> V8XPathResult::asStringCallback(const v8::Arguments& args) { + v8::Handle<v8::Value> V8XPathResult::asStringCallback(const v8::Arguments& args) { - v8::Local<v8::Object> self = args.Holder(); - struct V8XPathResultPrivate* privData = V8DOM::toClassPtr<V8XPathResultPrivate >(self->GetInternalField(0)); + v8::Local<v8::Object> self = args.Holder(); + struct V8XPathResultPrivate* privData = V8DOM::toClassPtr<V8XPathResultPrivate >(self->GetInternalField(0)); - std::string retVal = privData->nativeObj->asString(); + std::string retVal = privData->nativeObj->asString(); - return v8::String::New(retVal.c_str()); -} + return v8::String::New(retVal.c_str()); + } -v8::Handle<v8::Value> V8XPathResult::asNumberCallback(const v8::Arguments& args) { + v8::Handle<v8::Value> V8XPathResult::asNumberCallback(const v8::Arguments& args) { - v8::Local<v8::Object> self = args.Holder(); - struct V8XPathResultPrivate* privData = V8DOM::toClassPtr<V8XPathResultPrivate >(self->GetInternalField(0)); + v8::Local<v8::Object> self = args.Holder(); + struct V8XPathResultPrivate* privData = V8DOM::toClassPtr<V8XPathResultPrivate >(self->GetInternalField(0)); - double retVal = privData->nativeObj->asNumber(); + double retVal = privData->nativeObj->asNumber(); - return v8::Number::New(retVal); -} + return v8::Number::New(retVal); + } -bool V8XPathResult::hasInstance(v8::Handle<v8::Value> value) { - return getTmpl()->HasInstance(value); -} + bool V8XPathResult::hasInstance(v8::Handle<v8::Value> value) { + return getTmpl()->HasInstance(value); + } -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.h index f6a2d10..1fae618 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.h @@ -32,60 +32,60 @@ namespace DOM { class V8XPathResult { public: - struct V8XPathResultPrivate { - V8DOM* dom; - Arabica::XPath::XPathValue<std::string>* nativeObj; - }; - - V8_DESTRUCTOR(V8XPathResultPrivate); - static bool hasInstance(v8::Handle<v8::Value>); - - static v8::Handle<v8::Value> asNodeSetCallback(const v8::Arguments&); - static v8::Handle<v8::Value> asBoolCallback(const v8::Arguments&); - static v8::Handle<v8::Value> asStringCallback(const v8::Arguments&); - static v8::Handle<v8::Value> asNumberCallback(const v8::Arguments&); - - static v8::Handle<v8::Value> numberValueAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> stringValueAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> booleanValueAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - static v8::Handle<v8::Value> singleNodeValueCustomAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); - - 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(); - (void)prototype; // surpress unused warnings - - instance->SetInternalFieldCount(1); - - 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("singleNodeValue"), V8XPathResult::singleNodeValueCustomAttrGetter, 0, - v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); - - 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; - } + struct V8XPathResultPrivate { + V8DOM* dom; + Arabica::XPath::XPathValue<std::string>* nativeObj; + }; + + V8_DESTRUCTOR(V8XPathResultPrivate); + static bool hasInstance(v8::Handle<v8::Value>); + + static v8::Handle<v8::Value> asNodeSetCallback(const v8::Arguments&); + static v8::Handle<v8::Value> asBoolCallback(const v8::Arguments&); + static v8::Handle<v8::Value> asStringCallback(const v8::Arguments&); + static v8::Handle<v8::Value> asNumberCallback(const v8::Arguments&); + + static v8::Handle<v8::Value> numberValueAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> stringValueAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> booleanValueAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> singleNodeValueCustomAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + + 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(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); + + 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("singleNodeValue"), V8XPathResult::singleNodeValueCustomAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + + 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; + } }; diff --git a/src/uscxml/plugins/element/CMakeLists.txt b/src/uscxml/plugins/element/CMakeLists.txt index 0c9cbda..6697962 100644 --- a/src/uscxml/plugins/element/CMakeLists.txt +++ b/src/uscxml/plugins/element/CMakeLists.txt @@ -15,6 +15,23 @@ else() list (APPEND USCXML_FILES ${FETCH_ELEMENT}) endif() +# MMI elements + +# file(GLOB_RECURSE MMI_ELEMENT +# mmi/*.cpp +# mmi/*.h +# ) +# source_group("Element\\mmi" FILES ${MMI_ELEMENT}) +# if (BUILD_AS_PLUGINS) +# add_library( +# element_mmi SHARED +# ${MMI_ELEMENT}) +# target_link_libraries(element_mmi uscxml) +# set_target_properties(element_mmi PROPERTIES FOLDER "Plugin Element") +# else() +# list (APPEND USCXML_FILES ${MMI_ELEMENT}) +# endif() + # Postpone element diff --git a/src/uscxml/plugins/element/fetch/FetchElement.cpp b/src/uscxml/plugins/element/fetch/FetchElement.cpp index e6ceb3f..f2f18fc 100644 --- a/src/uscxml/plugins/element/fetch/FetchElement.cpp +++ b/src/uscxml/plugins/element/fetch/FetchElement.cpp @@ -19,9 +19,9 @@ bool connect(pluma::Host& host) { #endif boost::shared_ptr<ExecutableContentImpl> FetchElement::create(InterpreterImpl* interpreter) { - boost::shared_ptr<FetchElement> invoker = boost::shared_ptr<FetchElement>(new FetchElement()); - invoker->_interpreter = interpreter; - return invoker; + boost::shared_ptr<FetchElement> element = boost::shared_ptr<FetchElement>(new FetchElement()); + element->_interpreter = interpreter; + return element; } FetchElement::~FetchElement() { diff --git a/src/uscxml/plugins/element/mmi/MMIEvents.cpp b/src/uscxml/plugins/element/mmi/MMIEvents.cpp new file mode 100644 index 0000000..5d688ff --- /dev/null +++ b/src/uscxml/plugins/element/mmi/MMIEvents.cpp @@ -0,0 +1,42 @@ +#include "MMIEvents.h" + +namespace uscxml { + + void PrepareRequestElement::enterElement(const Arabica::DOM::Node<std::string>& node) { + } + void StartRequestElement::enterElement(const Arabica::DOM::Node<std::string>& node) { + } + void PauseRequestElement::enterElement(const Arabica::DOM::Node<std::string>& node) { + } + void ResumeRequestElement::enterElement(const Arabica::DOM::Node<std::string>& node) { + } + void CancelRequestElement::enterElement(const Arabica::DOM::Node<std::string>& node) { + } + void ClearContextRequestElement::enterElement(const Arabica::DOM::Node<std::string>& node) { + } + void StatusRequestElement::enterElement(const Arabica::DOM::Node<std::string>& node) { + } + void NewContextResponseElement::enterElement(const Arabica::DOM::Node<std::string>& node) { + } + void PrepareResponseElement::enterElement(const Arabica::DOM::Node<std::string>& node) { + } + void StartResponseElement::enterElement(const Arabica::DOM::Node<std::string>& node) { + } + void PauseResponseElement::enterElement(const Arabica::DOM::Node<std::string>& node) { + } + void ResumeResponseElement::enterElement(const Arabica::DOM::Node<std::string>& node) { + } + void CancelResponseElement::enterElement(const Arabica::DOM::Node<std::string>& node) { + } + void ClearContextResponseElement::enterElement(const Arabica::DOM::Node<std::string>& node) { + } + void StatusResponseElement::enterElement(const Arabica::DOM::Node<std::string>& node) { + } + void DoneNotificationElement::enterElement(const Arabica::DOM::Node<std::string>& node) { + } + void NewContextRequestElement::enterElement(const Arabica::DOM::Node<std::string>& node) { + } + void ExtensionNotificationElement::enterElement(const Arabica::DOM::Node<std::string>& node) { + } + +}
\ No newline at end of file diff --git a/src/uscxml/plugins/element/mmi/MMIEvents.h b/src/uscxml/plugins/element/mmi/MMIEvents.h new file mode 100644 index 0000000..3a31f2a --- /dev/null +++ b/src/uscxml/plugins/element/mmi/MMIEvents.h @@ -0,0 +1,58 @@ +#ifndef MMIEVENTS_H_QHO6VT3M +#define MMIEVENTS_H_QHO6VT3M + +#include <uscxml/Interpreter.h> + +#ifdef BUILD_AS_PLUGINS +#include "uscxml/plugins/Plugins.h" +#endif + +#define ELEMENT_CREATOR(elementName) \ +boost::shared_ptr<ExecutableContentImpl> create(InterpreterImpl* interpreter) { \ + boost::shared_ptr<elementName> element = boost::shared_ptr<elementName>(new elementName()); \ + element->_interpreter = interpreter; \ + return element; \ +} + +#define ELEMENT_MMI_CLASS(elementName) \ +class elementName##Element : public ExecutableContentImpl { \ +public:\ + elementName##Element () {}\ + virtual ~elementName##Element () {}\ + ELEMENT_CREATOR(elementName##Element);\ + std::string getLocalName() { return "elementName"; }\ + std::string getNamespace() { return "http://www.w3.org/2008/04/mmi-arch"; }\ + bool processChildren() { return false; }\ + void enterElement(const Arabica::DOM::Node<std::string>& node);\ + void exitElement(const Arabica::DOM::Node<std::string>& node) {}\ +}; + +namespace uscxml { + +ELEMENT_MMI_CLASS(PrepareRequest); +ELEMENT_MMI_CLASS(StartRequest); +ELEMENT_MMI_CLASS(PauseRequest); +ELEMENT_MMI_CLASS(ResumeRequest); +ELEMENT_MMI_CLASS(CancelRequest); +ELEMENT_MMI_CLASS(ClearContextRequest); +ELEMENT_MMI_CLASS(StatusRequest); +ELEMENT_MMI_CLASS(NewContextResponse); +ELEMENT_MMI_CLASS(PrepareResponse); +ELEMENT_MMI_CLASS(StartResponse); +ELEMENT_MMI_CLASS(PauseResponse); +ELEMENT_MMI_CLASS(ResumeResponse); +ELEMENT_MMI_CLASS(CancelResponse); +ELEMENT_MMI_CLASS(ClearContextResponse); +ELEMENT_MMI_CLASS(StatusResponse); +ELEMENT_MMI_CLASS(DoneNotification); +ELEMENT_MMI_CLASS(NewContextRequest); +ELEMENT_MMI_CLASS(ExtensionNotification); + +#ifdef BUILD_AS_PLUGINS +PLUMA_INHERIT_PROVIDER(FetchElement, ExecutableContentImpl); +#endif + +} + + +#endif /* end of include guard: MMIEVENTS_H_QHO6VT3M */ diff --git a/src/uscxml/plugins/invoker/ffmpeg/FFMPEGInvoker.cpp b/src/uscxml/plugins/invoker/ffmpeg/FFMPEGInvoker.cpp index aaf6bc4..c04c90d 100644 --- a/src/uscxml/plugins/invoker/ffmpeg/FFMPEGInvoker.cpp +++ b/src/uscxml/plugins/invoker/ffmpeg/FFMPEGInvoker.cpp @@ -24,7 +24,7 @@ FFMPEGInvoker::FFMPEGInvoker() { FFMPEGInvoker::~FFMPEGInvoker() { }; -boost::shared_ptr<IOProcessorImpl> FFMPEGInvoker::create(InterpreterImpl* interpreter) { +boost::shared_ptr<InvokerImpl> FFMPEGInvoker::create(InterpreterImpl* interpreter) { boost::shared_ptr<FFMPEGInvoker> invoker = boost::shared_ptr<FFMPEGInvoker>(new FFMPEGInvoker()); invoker->_interpreter = interpreter; return invoker; diff --git a/src/uscxml/plugins/invoker/ffmpeg/FFMPEGInvoker.h b/src/uscxml/plugins/invoker/ffmpeg/FFMPEGInvoker.h index 972c4ff..c29a173 100644 --- a/src/uscxml/plugins/invoker/ffmpeg/FFMPEGInvoker.h +++ b/src/uscxml/plugins/invoker/ffmpeg/FFMPEGInvoker.h @@ -13,7 +13,7 @@ class FFMPEGInvoker : public InvokerImpl { public: FFMPEGInvoker(); virtual ~FFMPEGInvoker(); - virtual boost::shared_ptr<IOProcessorImpl> create(InterpreterImpl* interpreter); + virtual boost::shared_ptr<InvokerImpl> create(InterpreterImpl* interpreter); virtual std::set<std::string> getNames() { std::set<std::string> names; diff --git a/src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.cpp b/src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.cpp index 8e3209a..5900cc8 100644 --- a/src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.cpp +++ b/src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.cpp @@ -37,7 +37,7 @@ DirMonInvoker::~DirMonInvoker() { _thread->join(); }; -boost::shared_ptr<IOProcessorImpl> DirMonInvoker::create(InterpreterImpl* interpreter) { +boost::shared_ptr<InvokerImpl> DirMonInvoker::create(InterpreterImpl* interpreter) { boost::shared_ptr<DirMonInvoker> invoker = boost::shared_ptr<DirMonInvoker>(new DirMonInvoker()); invoker->_interpreter = interpreter; return invoker; diff --git a/src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.h b/src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.h index a58da10..611106b 100644 --- a/src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.h +++ b/src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.h @@ -56,7 +56,7 @@ class DirMonInvoker : public InvokerImpl, public DirectoryWatchMonitor { public: DirMonInvoker(); virtual ~DirMonInvoker(); - virtual boost::shared_ptr<IOProcessorImpl> create(InterpreterImpl* interpreter); + virtual boost::shared_ptr<InvokerImpl> create(InterpreterImpl* interpreter); virtual std::set<std::string> getNames() { std::set<std::string> names; diff --git a/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp index 932452e..06141c3 100644 --- a/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp +++ b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp @@ -22,7 +22,7 @@ OSGInvoker::OSGInvoker() { OSGInvoker::~OSGInvoker() { }; -boost::shared_ptr<IOProcessorImpl> OSGInvoker::create(InterpreterImpl* interpreter) { +boost::shared_ptr<InvokerImpl> OSGInvoker::create(InterpreterImpl* interpreter) { boost::shared_ptr<OSGInvoker> invoker = boost::shared_ptr<OSGInvoker> (new OSGInvoker()); invoker->_interpreter = interpreter; return invoker; diff --git a/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.h b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.h index e79b250..bb46e79 100644 --- a/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.h +++ b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.h @@ -20,7 +20,7 @@ class OSGInvoker : public InvokerImpl, public Arabica::DOM::Events::EventListene public: OSGInvoker(); virtual ~OSGInvoker(); - virtual boost::shared_ptr<IOProcessorImpl> create(InterpreterImpl* interpreter); + virtual boost::shared_ptr<InvokerImpl> create(InterpreterImpl* interpreter); virtual std::set<std::string> getNames() { std::set<std::string> names; diff --git a/src/uscxml/plugins/invoker/graphics/openscenegraph/converter/OSGConverter.cpp b/src/uscxml/plugins/invoker/graphics/openscenegraph/converter/OSGConverter.cpp index de39424..e377e5c 100644 --- a/src/uscxml/plugins/invoker/graphics/openscenegraph/converter/OSGConverter.cpp +++ b/src/uscxml/plugins/invoker/graphics/openscenegraph/converter/OSGConverter.cpp @@ -52,7 +52,7 @@ OSGConverter::~OSGConverter() { } }; -boost::shared_ptr<IOProcessorImpl> OSGConverter::create(InterpreterImpl* interpreter) { +boost::shared_ptr<InvokerImpl> OSGConverter::create(InterpreterImpl* interpreter) { boost::shared_ptr<OSGConverter> invoker = boost::shared_ptr<OSGConverter>(new OSGConverter()); invoker->_interpreter = interpreter; return invoker; diff --git a/src/uscxml/plugins/invoker/graphics/openscenegraph/converter/OSGConverter.h b/src/uscxml/plugins/invoker/graphics/openscenegraph/converter/OSGConverter.h index d3cee30..78d6c6c 100644 --- a/src/uscxml/plugins/invoker/graphics/openscenegraph/converter/OSGConverter.h +++ b/src/uscxml/plugins/invoker/graphics/openscenegraph/converter/OSGConverter.h @@ -15,7 +15,7 @@ class OSGConverter : public InvokerImpl { public: OSGConverter(); virtual ~OSGConverter(); - virtual boost::shared_ptr<IOProcessorImpl> create(InterpreterImpl* interpreter); + virtual boost::shared_ptr<InvokerImpl> create(InterpreterImpl* interpreter); virtual std::set<std::string> getNames() { std::set<std::string> names; diff --git a/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp b/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp index b69f569..c7b91f6 100644 --- a/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp +++ b/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp @@ -22,7 +22,7 @@ HeartbeatInvoker::~HeartbeatInvoker() { cancel(""); }; -boost::shared_ptr<IOProcessorImpl> HeartbeatInvoker::create(InterpreterImpl* interpreter) { +boost::shared_ptr<InvokerImpl> HeartbeatInvoker::create(InterpreterImpl* interpreter) { boost::shared_ptr<HeartbeatInvoker> invoker = boost::shared_ptr<HeartbeatInvoker>(new HeartbeatInvoker()); invoker->_interpreter = interpreter; return invoker; diff --git a/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.h b/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.h index 5a6272e..ea83db9 100644 --- a/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.h +++ b/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.h @@ -13,7 +13,7 @@ class HeartbeatInvoker : public InvokerImpl { public: HeartbeatInvoker(); virtual ~HeartbeatInvoker(); - virtual boost::shared_ptr<IOProcessorImpl> create(InterpreterImpl* interpreter); + virtual boost::shared_ptr<InvokerImpl> create(InterpreterImpl* interpreter); virtual std::set<std::string> getNames() { std::set<std::string> names; diff --git a/src/uscxml/plugins/invoker/http/HTTPServletInvoker.cpp b/src/uscxml/plugins/invoker/http/HTTPServletInvoker.cpp index 03e62bd..771b159 100644 --- a/src/uscxml/plugins/invoker/http/HTTPServletInvoker.cpp +++ b/src/uscxml/plugins/invoker/http/HTTPServletInvoker.cpp @@ -25,7 +25,7 @@ HTTPServletInvoker::~HTTPServletInvoker() { }; -boost::shared_ptr<IOProcessorImpl> HTTPServletInvoker::create(InterpreterImpl* interpreter) { +boost::shared_ptr<InvokerImpl> HTTPServletInvoker::create(InterpreterImpl* interpreter) { boost::shared_ptr<HTTPServletInvoker> invoker = boost::shared_ptr<HTTPServletInvoker>(new HTTPServletInvoker()); invoker->_interpreter = interpreter; return invoker; diff --git a/src/uscxml/plugins/invoker/http/HTTPServletInvoker.h b/src/uscxml/plugins/invoker/http/HTTPServletInvoker.h index 06a286c..de9c300 100644 --- a/src/uscxml/plugins/invoker/http/HTTPServletInvoker.h +++ b/src/uscxml/plugins/invoker/http/HTTPServletInvoker.h @@ -14,7 +14,7 @@ class HTTPServletInvoker : public InvokerImpl, public HTTPServlet { public: HTTPServletInvoker(); virtual ~HTTPServletInvoker(); - virtual boost::shared_ptr<IOProcessorImpl> create(InterpreterImpl* interpreter); + virtual boost::shared_ptr<InvokerImpl> create(InterpreterImpl* interpreter); virtual std::set<std::string> getNames() { std::set<std::string> names; diff --git a/src/uscxml/plugins/invoker/miles/MilesSessionInvoker.h b/src/uscxml/plugins/invoker/miles/MilesSessionInvoker.h index c552d1f..d61dbfe 100644 --- a/src/uscxml/plugins/invoker/miles/MilesSessionInvoker.h +++ b/src/uscxml/plugins/invoker/miles/MilesSessionInvoker.h @@ -24,7 +24,7 @@ class MilesSessionInvoker : public InvokerImpl { public: MilesSessionInvoker(); virtual ~MilesSessionInvoker(); - virtual boost::shared_ptr<IOProcessorImpl> create(InterpreterImpl* interpreter); + virtual boost::shared_ptr<InvokerImpl> create(InterpreterImpl* interpreter); virtual std::set<std::string> getNames() { std::set<std::string> names; diff --git a/src/uscxml/plugins/invoker/sample/SampleInvoker.cpp b/src/uscxml/plugins/invoker/sample/SampleInvoker.cpp index d226784..4d514ef 100644 --- a/src/uscxml/plugins/invoker/sample/SampleInvoker.cpp +++ b/src/uscxml/plugins/invoker/sample/SampleInvoker.cpp @@ -21,7 +21,7 @@ SampleInvoker::SampleInvoker() { SampleInvoker::~SampleInvoker() { }; -boost::shared_ptr<IOProcessorImpl> SampleInvoker::create(InterpreterImpl* interpreter) { +boost::shared_ptr<InvokerImpl> SampleInvoker::create(InterpreterImpl* interpreter) { boost::shared_ptr<SampleInvoker> invoker = boost::shared_ptr<SampleInvoker>(new SampleInvoker()); invoker->_interpreter = interpreter; return invoker; diff --git a/src/uscxml/plugins/invoker/sample/SampleInvoker.h b/src/uscxml/plugins/invoker/sample/SampleInvoker.h index 9261f2e..30297b2 100644 --- a/src/uscxml/plugins/invoker/sample/SampleInvoker.h +++ b/src/uscxml/plugins/invoker/sample/SampleInvoker.h @@ -13,7 +13,7 @@ class SampleInvoker : public InvokerImpl { public: SampleInvoker(); virtual ~SampleInvoker(); - virtual boost::shared_ptr<IOProcessorImpl> create(InterpreterImpl* interpreter); + virtual boost::shared_ptr<InvokerImpl> create(InterpreterImpl* interpreter); virtual std::set<std::string> getNames() { std::set<std::string> names; diff --git a/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp b/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp index 9eafbcf..c697993 100644 --- a/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp +++ b/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp @@ -23,7 +23,7 @@ USCXMLInvoker::~USCXMLInvoker() { _cancelled = true; }; -boost::shared_ptr<IOProcessorImpl> USCXMLInvoker::create(InterpreterImpl* interpreter) { +boost::shared_ptr<InvokerImpl> USCXMLInvoker::create(InterpreterImpl* interpreter) { boost::shared_ptr<USCXMLInvoker> invoker = boost::shared_ptr<USCXMLInvoker>(new USCXMLInvoker()); invoker->_parentInterpreter = interpreter; return invoker; diff --git a/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.h b/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.h index 4b2c2d5..896eaa3 100644 --- a/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.h +++ b/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.h @@ -20,7 +20,7 @@ class USCXMLInvoker : public: USCXMLInvoker(); virtual ~USCXMLInvoker(); - virtual boost::shared_ptr<IOProcessorImpl> create(InterpreterImpl* interpreter); + virtual boost::shared_ptr<InvokerImpl> create(InterpreterImpl* interpreter); virtual std::set<std::string> getNames() { std::set<std::string> names; names.insert("scxml"); diff --git a/src/uscxml/plugins/invoker/sqlite3/Sqlite3Invoker.cpp b/src/uscxml/plugins/invoker/sqlite3/Sqlite3Invoker.cpp index 1d563ec..db65ab8 100644 --- a/src/uscxml/plugins/invoker/sqlite3/Sqlite3Invoker.cpp +++ b/src/uscxml/plugins/invoker/sqlite3/Sqlite3Invoker.cpp @@ -21,7 +21,7 @@ Sqlite3Invoker::Sqlite3Invoker() { Sqlite3Invoker::~Sqlite3Invoker() { }; -boost::shared_ptr<IOProcessorImpl> Sqlite3Invoker::create(InterpreterImpl* interpreter) { +boost::shared_ptr<InvokerImpl> Sqlite3Invoker::create(InterpreterImpl* interpreter) { boost::shared_ptr<Sqlite3Invoker> invoker = boost::shared_ptr<Sqlite3Invoker>(new Sqlite3Invoker()); invoker->_interpreter = interpreter; return invoker; diff --git a/src/uscxml/plugins/invoker/sqlite3/Sqlite3Invoker.h b/src/uscxml/plugins/invoker/sqlite3/Sqlite3Invoker.h index 35bfec4..b3a9fd7 100644 --- a/src/uscxml/plugins/invoker/sqlite3/Sqlite3Invoker.h +++ b/src/uscxml/plugins/invoker/sqlite3/Sqlite3Invoker.h @@ -13,7 +13,7 @@ class Sqlite3Invoker : public InvokerImpl { public: Sqlite3Invoker(); virtual ~Sqlite3Invoker(); - virtual boost::shared_ptr<IOProcessorImpl> create(InterpreterImpl* interpreter); + virtual boost::shared_ptr<InvokerImpl> create(InterpreterImpl* interpreter); virtual std::set<std::string> getNames() { std::set<std::string> names; diff --git a/src/uscxml/plugins/invoker/system/SystemInvoker.cpp b/src/uscxml/plugins/invoker/system/SystemInvoker.cpp index 468628c..d306cb9 100644 --- a/src/uscxml/plugins/invoker/system/SystemInvoker.cpp +++ b/src/uscxml/plugins/invoker/system/SystemInvoker.cpp @@ -21,7 +21,7 @@ SystemInvoker::SystemInvoker() { SystemInvoker::~SystemInvoker() { }; -boost::shared_ptr<IOProcessorImpl> SystemInvoker::create(InterpreterImpl* interpreter) { +boost::shared_ptr<InvokerImpl> SystemInvoker::create(InterpreterImpl* interpreter) { boost::shared_ptr<SystemInvoker> invoker = boost::shared_ptr<SystemInvoker>(new SystemInvoker()); invoker->_interpreter = interpreter; return invoker; diff --git a/src/uscxml/plugins/invoker/system/SystemInvoker.h b/src/uscxml/plugins/invoker/system/SystemInvoker.h index 0292d41..78903f6 100644 --- a/src/uscxml/plugins/invoker/system/SystemInvoker.h +++ b/src/uscxml/plugins/invoker/system/SystemInvoker.h @@ -13,7 +13,7 @@ class SystemInvoker : public InvokerImpl { public: SystemInvoker(); virtual ~SystemInvoker(); - virtual boost::shared_ptr<IOProcessorImpl> create(InterpreterImpl* interpreter); + virtual boost::shared_ptr<InvokerImpl> create(InterpreterImpl* interpreter); virtual std::set<std::string> getNames() { std::set<std::string> names; diff --git a/src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp b/src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp index 5439413..641d713 100644 --- a/src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp +++ b/src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp @@ -28,7 +28,7 @@ UmundoInvoker::~UmundoInvoker() { } }; -boost::shared_ptr<IOProcessorImpl> UmundoInvoker::create(InterpreterImpl* interpreter) { +boost::shared_ptr<InvokerImpl> UmundoInvoker::create(InterpreterImpl* interpreter) { boost::shared_ptr<UmundoInvoker> invoker = boost::shared_ptr<UmundoInvoker>(new UmundoInvoker()); invoker->_interpreter = interpreter; return invoker; diff --git a/src/uscxml/plugins/invoker/umundo/UmundoInvoker.h b/src/uscxml/plugins/invoker/umundo/UmundoInvoker.h index db944cd..f917819 100644 --- a/src/uscxml/plugins/invoker/umundo/UmundoInvoker.h +++ b/src/uscxml/plugins/invoker/umundo/UmundoInvoker.h @@ -20,7 +20,7 @@ class UmundoInvoker : public InvokerImpl, public umundo::TypedReceiver, public u public: UmundoInvoker(); virtual ~UmundoInvoker(); - virtual boost::shared_ptr<IOProcessorImpl> create(InterpreterImpl* interpreter); + virtual boost::shared_ptr<InvokerImpl> create(InterpreterImpl* interpreter); virtual std::set<std::string> getNames() { std::set<std::string> names; diff --git a/src/uscxml/plugins/invoker/vxml/VoiceXMLInvoker.cpp b/src/uscxml/plugins/invoker/vxml/VoiceXMLInvoker.cpp index e7d1440..6e0b2af 100644 --- a/src/uscxml/plugins/invoker/vxml/VoiceXMLInvoker.cpp +++ b/src/uscxml/plugins/invoker/vxml/VoiceXMLInvoker.cpp @@ -21,7 +21,7 @@ VoiceXMLInvoker::VoiceXMLInvoker() { VoiceXMLInvoker::~VoiceXMLInvoker() { }; -boost::shared_ptr<IOProcessorImpl> VoiceXMLInvoker::create(InterpreterImpl* interpreter) { +boost::shared_ptr<InvokerImpl> VoiceXMLInvoker::create(InterpreterImpl* interpreter) { boost::shared_ptr<VoiceXMLInvoker> invoker = boost::shared_ptr<VoiceXMLInvoker>(new VoiceXMLInvoker()); invoker->_interpreter = interpreter; invoker->_pub = umundo::TypedPublisher("mmi:jvoicexml"); diff --git a/src/uscxml/plugins/invoker/vxml/VoiceXMLInvoker.h b/src/uscxml/plugins/invoker/vxml/VoiceXMLInvoker.h index 450af5d..ca5f557 100644 --- a/src/uscxml/plugins/invoker/vxml/VoiceXMLInvoker.h +++ b/src/uscxml/plugins/invoker/vxml/VoiceXMLInvoker.h @@ -2,7 +2,7 @@ #define VOICEXMLINVOKER_H_W09J90F0 #include <uscxml/Interpreter.h> -#include <uscxml/plugins/ioprocessor/modality/MMIComponent.h> +#include <uscxml/plugins/ioprocessor/modality/MMIMessages.h> #include <uscxml/plugins/ioprocessor/modality/MMIProtoBridge.h> #include <umundo/core.h> @@ -18,7 +18,7 @@ class VoiceXMLInvoker : public InvokerImpl, public umundo::TypedReceiver { public: VoiceXMLInvoker(); virtual ~VoiceXMLInvoker(); - virtual boost::shared_ptr<IOProcessorImpl> create(InterpreterImpl* interpreter); + virtual boost::shared_ptr<InvokerImpl> create(InterpreterImpl* interpreter); virtual std::set<std::string> getNames() { std::set<std::string> names; diff --git a/src/uscxml/plugins/ioprocessor/modality/MMIComponent.cpp b/src/uscxml/plugins/ioprocessor/modality/MMIComponent.cpp deleted file mode 100644 index c1e973b..0000000 --- a/src/uscxml/plugins/ioprocessor/modality/MMIComponent.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "MMIComponent.h" -//#include <glog/logging.h> - -namespace uscxml { - -MMIComponent::MMIComponent() { -} - -MMIComponent::~MMIComponent() { -} - -}
\ No newline at end of file diff --git a/src/uscxml/plugins/ioprocessor/modality/MMIComponent.h b/src/uscxml/plugins/ioprocessor/modality/MMIComponent.h deleted file mode 100644 index 990222f..0000000 --- a/src/uscxml/plugins/ioprocessor/modality/MMIComponent.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef MMIIOPROCESSOR_H_W09J90F0 -#define MMIIOPROCESSOR_H_W09J90F0 - -#include "MMIMessages.h" - -namespace uscxml { - -class MMIComponent { -public: - MMIComponent(); - virtual ~MMIComponent(); - - /** Modality component */ - virtual PrepareResponse prepare(const PrepareRequest&) = 0; - virtual StartResponse start(const StartRequest&) = 0; - virtual CancelResponse cancel(const CancelRequest&) = 0; - virtual PauseResponse pause(const PauseRequest&) = 0; - virtual ResumeResponse resume(const ResumeRequest&) = 0; - virtual ExtensionNotification extension(const ExtensionNotification&) = 0; - virtual ClearContextRequest clearContext(const ClearContextRequest&) = 0; - virtual StatusResponse status(const StatusRequest&) = 0; - - /** Interaction Manager */ - virtual NewContextResponse newContext(const NewContextRequest&) = 0; - virtual DoneNotification done(const DoneNotification&) = 0; -// virtual ExtensionNotification extension(const ExtensionNotification&); - - -}; - -} - - -#endif /* end of include guard: MMIIOPROCESSOR_H_W09J90F0 */ diff --git a/src/uscxml/plugins/ioprocessor/modality/MMIHTTPIOProcessor.cpp b/src/uscxml/plugins/ioprocessor/modality/MMIHTTPIOProcessor.cpp new file mode 100644 index 0000000..4734ff5 --- /dev/null +++ b/src/uscxml/plugins/ioprocessor/modality/MMIHTTPIOProcessor.cpp @@ -0,0 +1,188 @@ +#include "uscxml/plugins/ioprocessor/modality/MMIHTTPIOProcessor.h" +#include "uscxml/Message.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 MMIHTTPIOProcessorProvider() ); + return true; +} +#endif + +MMIHTTPIOProcessor::MMIHTTPIOProcessor() { +} + +MMIHTTPIOProcessor::~MMIHTTPIOProcessor() { +} + +boost::shared_ptr<IOProcessorImpl> MMIHTTPIOProcessor::create(InterpreterImpl* interpreter) { + boost::shared_ptr<MMIHTTPIOProcessor> io = boost::shared_ptr<MMIHTTPIOProcessor>(new MMIHTTPIOProcessor()); + io->_interpreter = interpreter; + + // register at http server + std::string path = interpreter->getName(); + int i = 2; + while (!HTTPServer::registerServlet(path + "/mmihttp", io.get())) { + std::stringstream ss; + ss << interpreter->getName() << i++; + path = ss.str(); + } + + return io; +} + +void MMIHTTPIOProcessor::httpRecvRequest(const HTTPServer::Request& req) { + Event reqEvent = req; + reqEvent.type = Event::EXTERNAL; + bool scxmlStructFound = false; + + if (reqEvent.data.compound["header"].compound.find("Content-Type") != reqEvent.data.compound["header"].compound.end() && + boost::iequals(reqEvent.data.compound["header"].compound["Content-Type"].atom, "application/x-www-form-urlencoded")) { + std::stringstream ss(reqEvent.data.compound["content"].atom); + std::string term; + while(std::getline(ss, term, '&')) { + size_t split = term.find_first_of("="); + if (split != std::string::npos) { + std::string key = evhttp_decode_uri(term.substr(0, split).c_str()); + std::string value = evhttp_decode_uri(term.substr(split + 1).c_str()); + if (boost::iequals(key, "_scxmleventname")) { + reqEvent.name = value; + } else if (boost::iequals(key, "content")) { + reqEvent.initContent(value); + } else { + reqEvent.data.compound[key] = value; + reqEvent.params.insert(std::make_pair(key, value)); + } + } else { + // this is most likely wrong + reqEvent.content = evhttp_decode_uri(term.c_str()); + } + } + } else { + if (reqEvent.data.compound["header"].compound.find("_scxmleventstruct") != reqEvent.data.compound["header"].compound.end()) { + // TODO: this looses all other information + reqEvent = Event::fromXML(evhttp_decode_uri(reqEvent.data.compound["header"].compound["_scxmleventstruct"].atom.c_str())); + scxmlStructFound = true; + } + if (reqEvent.data.compound["header"].compound.find("_scxmleventname") != reqEvent.data.compound["header"].compound.end()) { + reqEvent.name = evhttp_decode_uri(reqEvent.data.compound["header"].compound["_scxmleventname"].atom.c_str()); + } + } + std::map<std::string, Data>::iterator headerIter = reqEvent.data.compound["header"].compound.begin(); + while(headerIter != reqEvent.data.compound["header"].compound.end()) { + reqEvent.data.compound[headerIter->first] = Data(evhttp_decode_uri(headerIter->second.atom.c_str()), Data::VERBATIM); + headerIter++; + } + +#if 0 + std::map<std::string, std::string>::const_iterator headerIter = req.headers.begin(); + while(headerIter != req.headers.end()) { + if (boost::iequals("_scxmleventstruct", headerIter->first)) { + reqEvent = Event::fromXML(evhttp_decode_uri(headerIter->second.c_str())); + scxmlStructFound = true; + break; + } else if (boost::iequals("_scxmleventname", headerIter->first)) { + reqEvent.name = evhttp_decode_uri(headerIter->second.c_str()); + } else { + reqEvent.data.compound[headerIter->first] = Data(evhttp_decode_uri(headerIter->second.c_str()), Data::VERBATIM); + } + headerIter++; + } +#endif + + /// test532 + if (reqEvent.name.length() == 0) + reqEvent.name = "http." + req.data.compound.at("type").atom; + + if (!scxmlStructFound) { + // get content into event + reqEvent.data.compound["content"] = Data(req.content, Data::VERBATIM); + } + + returnEvent(reqEvent); + evhttp_send_reply(req.curlReq, 200, "OK", NULL); +} + +void MMIHTTPIOProcessor::send(const SendRequest& req) { + + if (req.target.length() == 0) { + _interpreter->receiveInternal(Event("error.communication", Event::PLATFORM)); + return; + } + + bool isLocal = false; + std::string target; + if (!boost::equals(req.target, _url)) { + target = req.target; + } else { + isLocal = true; + target = _url; + } + URL targetURL(target); + std::stringstream kvps; + std::string kvpSeperator; + + // event name + if (req.name.size() > 0) { + kvps << kvpSeperator << evhttp_encode_uri("_scxmleventname") << "=" << evhttp_encode_uri(req.name.c_str()); + kvpSeperator = "&"; +// targetURL.addOutHeader("_scxmleventname", evhttp_encode_uri(req.name.c_str())); + } + + // event namelist + if (req.namelist.size() > 0) { + std::map<std::string, std::string>::const_iterator namelistIter = req.namelist.begin(); + while (namelistIter != req.namelist.end()) { + kvps << kvpSeperator << evhttp_encode_uri(namelistIter->first.c_str()) << "=" << evhttp_encode_uri(namelistIter->second.c_str()); + kvpSeperator = "&"; +// targetURL.addOutHeader(namelistIter->first, namelistIter->second); + namelistIter++; + } + } + + // event params + if (req.params.size() > 0) { + std::multimap<std::string, std::string>::const_iterator paramIter = req.params.begin(); + while (paramIter != req.params.end()) { + kvps << kvpSeperator << evhttp_encode_uri(paramIter->first.c_str()) << "=" << evhttp_encode_uri(paramIter->second.c_str()); + kvpSeperator = "&"; +// targetURL.addOutHeader(paramIter->first, paramIter->second); + paramIter++; + } + } + + // content + + if (req.content.size() > 0) { + kvps << kvpSeperator << evhttp_encode_uri("content") << "=" << evhttp_encode_uri(req.content.c_str()); + kvpSeperator = "&"; + } + if (req.dom) { + std::stringstream xmlStream; + xmlStream << req.dom; + kvps << kvpSeperator << evhttp_encode_uri("content") << "=" << evhttp_encode_uri(xmlStream.str().c_str()); + kvpSeperator = "&"; + } + targetURL.setOutContent(kvps.str()); + + targetURL.setRequestType("post"); + targetURL.addMonitor(this); + + _sendRequests[req.sendid] = std::make_pair(targetURL, req); + if (isLocal) { + // test201 use a blocking request with local communication + targetURL.download(true); + } else { + URLFetcher::fetchURL(targetURL); + } +} + + + +}
\ No newline at end of file diff --git a/src/uscxml/plugins/ioprocessor/modality/MMIHTTPIOProcessor.h b/src/uscxml/plugins/ioprocessor/modality/MMIHTTPIOProcessor.h new file mode 100644 index 0000000..2dbd595 --- /dev/null +++ b/src/uscxml/plugins/ioprocessor/modality/MMIHTTPIOProcessor.h @@ -0,0 +1,53 @@ +#ifndef MMIHTTPIOPROCESSOR_H_P1FN0YPL +#define MMIHTTPIOPROCESSOR_H_P1FN0YPL + +#include "uscxml/plugins/ioprocessor/basichttp/BasicHTTPIOProcessor.h" +#include "uscxml/Interpreter.h" +#include "uscxml/Factory.h" +#ifndef _WIN32 +#include <sys/time.h> +#endif + +#include <event2/http.h> +#include <event2/http_struct.h> + +#ifdef BUILD_AS_PLUGINS +#include "uscxml/plugins/Plugins.h" +#endif + +namespace uscxml { + + class MMIHTTPIOProcessor : public BasicHTTPIOProcessor { + public: + MMIHTTPIOProcessor(); + virtual ~MMIHTTPIOProcessor(); + virtual boost::shared_ptr<IOProcessorImpl> create(uscxml::InterpreterImpl* interpreter); + + virtual std::set<std::string> getNames() { + std::set<std::string> names; + names.insert("mmihttp"); + names.insert("http://www.w3.org/TR/mmi-arch/#HTTPTransport"); + return names; + } + + virtual void send(const SendRequest& req); + + /// HTTPServlet + void httpRecvRequest(const HTTPServer::Request& req); + + bool canAdaptPath() { + return false; + } + + protected: + std::string _url; + std::map<std::string, std::pair<URL, SendRequest> > _sendRequests; + }; + + #ifdef BUILD_AS_PLUGINS + PLUMA_INHERIT_PROVIDER(MMIHTTPIOProcessor, IOProcessorImpl); + #endif + +} + +#endif /* end of include guard: MMIHTTPIOPROCESSOR_H_P1FN0YPL */ diff --git a/src/uscxml/plugins/ioprocessor/modality/MMIInvokerImpl.h b/src/uscxml/plugins/ioprocessor/modality/MMIInvokerImpl.h deleted file mode 100644 index 45e316f..0000000 --- a/src/uscxml/plugins/ioprocessor/modality/MMIInvokerImpl.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef MMIINVOKER_H_612CXWUU -#define MMIINVOKER_H_612CXWUU - -#include "MMIComponent.h" - -namespace uscxml { - -class MMIInvokerImpl : public virtual InvokerImpl, public MMIIOProcessor { -}; - -} -#endif /* end of include guard: MMIINVOKER_H_612CXWUU */ diff --git a/src/uscxml/plugins/ioprocessor/modality/MMIMessages.cpp b/src/uscxml/plugins/ioprocessor/modality/MMIMessages.cpp index 717e174..bf32b9d 100644 --- a/src/uscxml/plugins/ioprocessor/modality/MMIMessages.cpp +++ b/src/uscxml/plugins/ioprocessor/modality/MMIMessages.cpp @@ -5,15 +5,86 @@ #include <DOM/SAX2DOM/SAX2DOM.hpp> #include <SAX/helpers/InputSourceResolver.hpp> +#include <uscxml/NameSpacingParser.h> + #include <boost/algorithm/string.hpp> +#define STRING_ATTR_OR_EXPR(element, name)\ +(element.hasAttributeNS(nameSpace, "name##Expr") && interpreter ? \ + interpreter->getDataModel().evalAsString(element.getAttributeNS(nameSpace, "name##Expr")) : \ + (element.hasAttributeNS(nameSpace, #name) ? element.getAttributeNS(nameSpace, #name) : "") \ +) + + namespace uscxml { using namespace Arabica::DOM; -std::string MMIMessage::nameSpace = "http://www.w3.org/2008/04/mmi-arch"; +std::string MMIEvent::nameSpace = "http://www.w3.org/2008/04/mmi-arch"; + + MMIEvent::Type MMIEvent::getType(Arabica::DOM::Node<std::string> node) { + if (!node) + return INVALID; + + if (boost::iequals(node.getLocalName(), "NEWCONTEXTREQUEST")) + return NEWCONTEXTREQUEST; + if (boost::iequals(node.getLocalName(), "NEWCONTEXTRESPONSE")) + return NEWCONTEXTRESPONSE; + if (boost::iequals(node.getLocalName(), "PREPAREREQUEST")) + return PREPAREREQUEST; + if (boost::iequals(node.getLocalName(), "PREPARERESPONSE")) + return PREPARERESPONSE; + if (boost::iequals(node.getLocalName(), "STARTREQUEST")) + return STARTREQUEST; + if (boost::iequals(node.getLocalName(), "STARTRESPONSE")) + return STARTRESPONSE; + if (boost::iequals(node.getLocalName(), "DONENOTIFICATION")) + return DONENOTIFICATION; + if (boost::iequals(node.getLocalName(), "CANCELREQUEST")) + return CANCELREQUEST; + if (boost::iequals(node.getLocalName(), "CANCELRESPONSE")) + return CANCELRESPONSE; + if (boost::iequals(node.getLocalName(), "PAUSEREQUEST")) + return PAUSEREQUEST; + if (boost::iequals(node.getLocalName(), "PAUSERESPONSE")) + return PAUSERESPONSE; + if (boost::iequals(node.getLocalName(), "RESUMEREQUEST")) + return RESUMEREQUEST; + if (boost::iequals(node.getLocalName(), "RESUMERESPONSE")) + return RESUMERESPONSE; + if (boost::iequals(node.getLocalName(), "EXTENSIONNOTIFICATION")) + return EXTENSIONNOTIFICATION; + if (boost::iequals(node.getLocalName(), "CLEARCONTEXTREQUEST")) + return CLEARCONTEXTREQUEST; + if (boost::iequals(node.getLocalName(), "CLEARCONTEXTRESPONSE")) + return CLEARCONTEXTRESPONSE; + if (boost::iequals(node.getLocalName(), "STATUSREQUEST")) + return STATUSREQUEST; + if (boost::iequals(node.getLocalName(), "STATUSRESPONSE")) + return STATUSRESPONSE; + return INVALID; + } + + Arabica::DOM::Node<std::string> MMIEvent::getEventNode(Arabica::DOM::Node<std::string> node) { + if (node.getNodeType() == Node_base::DOCUMENT_NODE) + node = Arabica::DOM::Document<std::string>(node).getDocumentElement(); + + // get the first element + while (node && node.getNodeType() != Node_base::ELEMENT_NODE) { + node = node.getNextSibling(); + } + // get the contained message + if (node && getType(node) == INVALID) { + node = node.getFirstChild(); + while (node && node.getNodeType() != Node_base::ELEMENT_NODE && getType(node) == INVALID) { + node = node.getNextSibling(); + } + } + return node; + } -Arabica::DOM::Document<std::string> MMIMessage::toXML() { + +Arabica::DOM::Document<std::string> MMIEvent::toXML() const { Arabica::DOM::DOMImplementation<std::string> domFactory = Arabica::SimpleDOM::DOMImplementation<std::string>::getDOMImplementation(); Document<std::string> doc = domFactory.createDocument(nameSpace, "", 0); Element<std::string> mmiElem = doc.createElementNS(nameSpace, "mmi"); @@ -23,7 +94,7 @@ Arabica::DOM::Document<std::string> MMIMessage::toXML() { msgElem.setAttributeNS(nameSpace, "RequestID", requestId); if (data.size() > 0) { - Element<std::string> dataElem = doc.createElementNS(nameSpace, "data"); + Element<std::string> dataElem = doc.createElementNS(nameSpace, "Data"); // try to parse content std::stringstream* ss = new std::stringstream(); @@ -32,7 +103,7 @@ Arabica::DOM::Document<std::string> MMIMessage::toXML() { Arabica::SAX::InputSource<std::string> inputSource; inputSource.setByteStream(ssPtr); - Arabica::SAX2DOM::Parser<std::string> parser; + NameSpacingParser parser; if(parser.parse(inputSource)) { Node<std::string> importedNode = doc.importNode(parser.getDocument().getDocumentElement(), true); dataElem.appendChild(importedNode); @@ -45,18 +116,17 @@ Arabica::DOM::Document<std::string> MMIMessage::toXML() { mmiElem.appendChild(msgElem); doc.appendChild(mmiElem); - std::cout << doc; return doc; } -Arabica::DOM::Document<std::string> ContextualizedRequest::toXML() { - Document<std::string> doc = MMIMessage::toXML(); +Arabica::DOM::Document<std::string> ContextualizedRequest::toXML() const { + Document<std::string> doc = MMIEvent::toXML(); Element<std::string> msgElem = Element<std::string>(doc.getDocumentElement().getFirstChild()); msgElem.setAttributeNS(nameSpace, "Context", context); return doc; } -Arabica::DOM::Document<std::string> ContentRequest::toXML() { +Arabica::DOM::Document<std::string> ContentRequest::toXML() const { Document<std::string> doc = ContextualizedRequest::toXML(); Element<std::string> msgElem = Element<std::string>(doc.getDocumentElement().getFirstChild()); @@ -92,14 +162,14 @@ Arabica::DOM::Document<std::string> ContentRequest::toXML() { return doc; } -Arabica::DOM::Document<std::string> ExtensionNotification::toXML() { +Arabica::DOM::Document<std::string> ExtensionNotification::toXML() const { Document<std::string> doc = ContextualizedRequest::toXML(); Element<std::string> msgElem = Element<std::string>(doc.getDocumentElement().getFirstChild()); msgElem.setAttributeNS(nameSpace, "Name", name); return doc; } -Arabica::DOM::Document<std::string> StatusResponse::toXML() { +Arabica::DOM::Document<std::string> StatusResponse::toXML() const { Document<std::string> doc = ContextualizedRequest::toXML(); Element<std::string> msgElem = Element<std::string>(doc.getDocumentElement().getFirstChild()); if (status == ALIVE) { @@ -114,7 +184,7 @@ Arabica::DOM::Document<std::string> StatusResponse::toXML() { return doc; } -Arabica::DOM::Document<std::string> StatusInfoResponse::toXML() { +Arabica::DOM::Document<std::string> StatusInfoResponse::toXML() const { Document<std::string> doc = StatusResponse::toXML(); Element<std::string> msgElem = Element<std::string>(doc.getDocumentElement().getFirstChild()); @@ -126,7 +196,7 @@ Arabica::DOM::Document<std::string> StatusInfoResponse::toXML() { return doc; } -Arabica::DOM::Document<std::string> StatusRequest::toXML() { +Arabica::DOM::Document<std::string> StatusRequest::toXML() const { Document<std::string> doc = ContextualizedRequest::toXML(); Element<std::string> msgElem = Element<std::string>(doc.getDocumentElement().getFirstChild()); @@ -139,19 +209,18 @@ Arabica::DOM::Document<std::string> StatusRequest::toXML() { return doc; } -MMIMessage MMIMessage::fromXML(const Arabica::DOM::Document<std::string>& doc) { - MMIMessage msg; - Node<std::string> node = doc.getDocumentElement().getFirstChild(); +MMIEvent MMIEvent::fromXML(Arabica::DOM::Node<std::string> node, InterpreterImpl* interpreter) { + MMIEvent msg; while (node) { if (node.getNodeType() == Node_base::ELEMENT_NODE) break; node = node.getNextSibling(); } Element<std::string> msgElem(node); - msg.source = msgElem.getAttributeNS("http://www.w3.org/2008/04/mmi-arch", "Source"); - msg.target = msgElem.getAttributeNS("http://www.w3.org/2008/04/mmi-arch", "Target"); -// msg.data = msgElem.getAttributeNS("http://www.w3.org/2008/04/mmi-arch", "Data"); - msg.requestId = msgElem.getAttributeNS("http://www.w3.org/2008/04/mmi-arch", "RequestID"); + msg.source = STRING_ATTR_OR_EXPR(msgElem, Source); + msg.target = STRING_ATTR_OR_EXPR(msgElem, Target); +// msg.data = STRING_ATTR_OR_EXPR(msgElem, Data); + msg.requestId = STRING_ATTR_OR_EXPR(msgElem, RequestID); msg.tagName = msgElem.getLocalName(); Element<std::string> dataElem; @@ -167,35 +236,47 @@ MMIMessage MMIMessage::fromXML(const Arabica::DOM::Document<std::string>& doc) { if (dataElem && boost::iequals(dataElem.getLocalName(), "data")) { std::stringstream ss; node = dataElem.getFirstChild(); - while (node) { - if (node.getNodeType() == Node_base::ELEMENT_NODE) { - ss << node; - break; - } - node = node.getNextSibling(); - } + if (node) + ss << node; msg.data = ss.str(); } return msg; } -ContextualizedRequest ContextualizedRequest::fromXML(const Arabica::DOM::Document<std::string>& doc) { - ContextualizedRequest msg(NewContextRequest::fromXML(doc)); - Node<std::string> node = doc.getDocumentElement().getFirstChild(); +MMIEvent::operator Event() const { + Event ev; + ev.setOriginType("mmi.event"); + ev.setOrigin(source); + ev.setRaw(data); + ev.setSendId(requestId); + if (data.length() > 0) { + ev.initContent(data); + } + return ev; +} + +ContextualizedRequest ContextualizedRequest::fromXML(Arabica::DOM::Node<std::string> node, InterpreterImpl* interpreter) { + ContextualizedRequest msg(MMIEvent::fromXML(node, interpreter)); while (node) { if (node.getNodeType() == Node_base::ELEMENT_NODE) break; node = node.getNextSibling(); } Element<std::string> msgElem(node); - msg.context = msgElem.getAttributeNS("http://www.w3.org/2008/04/mmi-arch", "Context"); + msg.context = STRING_ATTR_OR_EXPR(msgElem, Context); return msg; } -ContentRequest ContentRequest::fromXML(const Arabica::DOM::Document<std::string>& doc) { - ContentRequest msg(ContextualizedRequest::fromXML(doc)); - Node<std::string> node = doc.getDocumentElement().getFirstChild(); +ContextualizedRequest::operator Event() const { + Event ev = MMIEvent::operator Event(); + // do we want to represent the context? It's the interpreters name already + return ev; +} + + +ContentRequest ContentRequest::fromXML(Arabica::DOM::Node<std::string> node, InterpreterImpl* interpreter) { + ContentRequest msg(ContextualizedRequest::fromXML(node, interpreter)); while (node) { if (node.getNodeType() == Node_base::ELEMENT_NODE) break; @@ -228,39 +309,48 @@ ContentRequest ContentRequest::fromXML(const Arabica::DOM::Document<std::string> } msg.content = ss.str(); } else if(boost::iequals(contentElem.getLocalName(), "contentURL")) { - msg.contentURL.href = contentElem.getAttributeNS("http://www.w3.org/2008/04/mmi-arch", "href"); - msg.contentURL.maxAge = contentElem.getAttributeNS("http://www.w3.org/2008/04/mmi-arch", "max-age"); - msg.contentURL.fetchTimeout = contentElem.getAttributeNS("http://www.w3.org/2008/04/mmi-arch", "fetchtimeout"); + msg.contentURL.href = STRING_ATTR_OR_EXPR(contentElem, href); + msg.contentURL.maxAge = STRING_ATTR_OR_EXPR(contentElem, max-age); + msg.contentURL.fetchTimeout = STRING_ATTR_OR_EXPR(contentElem, fetchtimeout); } } - //msg.content = msgElem.getAttributeNS("http://www.w3.org/2008/04/mmi-arch", "Context"); + //msg.content = msgElem.getAttributeNS(nameSpace, "Context"); return msg; } -ExtensionNotification ExtensionNotification::fromXML(const Arabica::DOM::Document<std::string>& doc) { - ExtensionNotification msg(ContextualizedRequest::fromXML(doc)); - Node<std::string> node = doc.getDocumentElement().getFirstChild(); +ExtensionNotification ExtensionNotification::fromXML(Arabica::DOM::Node<std::string> node, InterpreterImpl* interpreter) { + ExtensionNotification msg(ContextualizedRequest::fromXML(node, interpreter)); while (node) { if (node.getNodeType() == Node_base::ELEMENT_NODE) break; node = node.getNextSibling(); } Element<std::string> msgElem(node); - msg.name = msgElem.getAttributeNS("http://www.w3.org/2008/04/mmi-arch", "Name"); + msg.name = STRING_ATTR_OR_EXPR(msgElem, Name); + msg.type = EXTENSIONNOTIFICATION; return msg; } -StatusResponse StatusResponse::fromXML(const Arabica::DOM::Document<std::string>& doc) { - StatusResponse msg(ContextualizedRequest::fromXML(doc)); - Node<std::string> node = doc.getDocumentElement().getFirstChild(); +ExtensionNotification::operator Event() const { + Event ev = ContextualizedRequest::operator Event(); + if (name.length() > 0) { + ev.setName("mmi.extensionnotification." + name); + } else { + ev.setName("mmi.extensionnotification"); + } + return ev; +} + +StatusResponse StatusResponse::fromXML(Arabica::DOM::Node<std::string> node, InterpreterImpl* interpreter) { + StatusResponse msg(ContextualizedRequest::fromXML(node, interpreter)); while (node) { if (node.getNodeType() == Node_base::ELEMENT_NODE) break; node = node.getNextSibling(); } Element<std::string> msgElem(node); - std::string status = msgElem.getAttributeNS("http://www.w3.org/2008/04/mmi-arch", "Status"); + std::string status = STRING_ATTR_OR_EXPR(msgElem, Status); if (boost::iequals(status, "ALIVE")) { msg.status = ALIVE; @@ -271,12 +361,12 @@ StatusResponse StatusResponse::fromXML(const Arabica::DOM::Document<std::string> } else if(boost::iequals(status, "SUCCESS")) { msg.status = SUCCESS; } + msg.type = STATUSRESPONSE; return msg; } -StatusInfoResponse StatusInfoResponse::fromXML(const Arabica::DOM::Document<std::string>& doc) { - StatusInfoResponse msg(StatusResponse::fromXML(doc)); - Node<std::string> node = doc.getDocumentElement().getFirstChild(); +StatusInfoResponse StatusInfoResponse::fromXML(Arabica::DOM::Node<std::string> node, InterpreterImpl* interpreter) { + StatusInfoResponse msg(StatusResponse::fromXML(node, interpreter)); while (node) { if (node.getNodeType() == Node_base::ELEMENT_NODE) break; @@ -305,21 +395,19 @@ StatusInfoResponse StatusInfoResponse::fromXML(const Arabica::DOM::Document<std: node = node.getNextSibling(); } } - return msg; } -StatusRequest StatusRequest::fromXML(const Arabica::DOM::Document<std::string>& doc) { - StatusRequest msg(ContextualizedRequest::fromXML(doc)); - Node<std::string> node = doc.getDocumentElement().getFirstChild(); +StatusRequest StatusRequest::fromXML(Arabica::DOM::Node<std::string> node, InterpreterImpl* interpreter) { + StatusRequest msg(ContextualizedRequest::fromXML(node, interpreter)); while (node) { if (node.getNodeType() == Node_base::ELEMENT_NODE) break; node = node.getNextSibling(); } Element<std::string> msgElem(node); - std::string autoUpdate = msgElem.getAttributeNS("http://www.w3.org/2008/04/mmi-arch", "RequestAutomaticUpdate"); + std::string autoUpdate = STRING_ATTR_OR_EXPR(msgElem, RequestAutomaticUpdate); if (boost::iequals(autoUpdate, "true")) { msg.automaticUpdate = true; @@ -332,7 +420,9 @@ StatusRequest StatusRequest::fromXML(const Arabica::DOM::Document<std::string>& } else { msg.automaticUpdate = false; } + msg.type = STATUSREQUEST; return msg; } + }
\ No newline at end of file diff --git a/src/uscxml/plugins/ioprocessor/modality/MMIMessages.h b/src/uscxml/plugins/ioprocessor/modality/MMIMessages.h index a5328ac..b7d017f 100644 --- a/src/uscxml/plugins/ioprocessor/modality/MMIMessages.h +++ b/src/uscxml/plugins/ioprocessor/modality/MMIMessages.h @@ -1,69 +1,142 @@ -#ifndef MMIMESSAGES_H_OS0SE7H5 -#define MMIMESSAGES_H_OS0SE7H5 +#ifndef MMIEVENT_H_OS0SE7H5 +#define MMIEVENT_H_OS0SE7H5 #include <DOM/Node.hpp> #include <DOM/Document.hpp> +#include <uscxml/Interpreter.h> namespace uscxml { -class MMIMessage { +class MMIEvent { public: - virtual Arabica::DOM::Document<std::string> toXML(); - static MMIMessage fromXML(const Arabica::DOM::Document<std::string>& doc); - + enum Type { + NEWCONTEXTREQUEST, + NEWCONTEXTRESPONSE, + PREPAREREQUEST, + PREPARERESPONSE, + STARTREQUEST, + STARTRESPONSE, + DONENOTIFICATION, + CANCELREQUEST, + CANCELRESPONSE, + PAUSEREQUEST, + PAUSERESPONSE, + RESUMEREQUEST, + RESUMERESPONSE, + EXTENSIONNOTIFICATION, + CLEARCONTEXTREQUEST, + CLEARCONTEXTRESPONSE, + STATUSREQUEST, + STATUSRESPONSE, + INVALID + }; + + static Type getType(Arabica::DOM::Node<std::string> node); + static Arabica::DOM::Node<std::string> getEventNode(Arabica::DOM::Node<std::string> node); + + virtual Arabica::DOM::Document<std::string> toXML() const; + static MMIEvent fromXML(Arabica::DOM::Node<std::string> node, + InterpreterImpl* interpreter = NULL); + + // conversion operator + operator Event() const; + std::string source; std::string target; std::string data; std::string requestId; std::string tagName; - + Type type; + static std::string nameSpace; protected: - MMIMessage() {} + MMIEvent() {} }; -class NewContextRequest : public MMIMessage { +class MMIEventReceiver { public: - NewContextRequest() { - tagName = "NewContextRequest"; - } - NewContextRequest(const MMIMessage& father) : MMIMessage(father) {} - static NewContextRequest fromXML(const Arabica::DOM::Document<std::string>& doc) { - return MMIMessage::fromXML(doc); - } + virtual void received(const MMIEvent& mmiEvent) = 0; +}; +class MMIEventSender { +public: + virtual void send(const MMIEvent& mmiEvent) = 0; }; -class ContextualizedRequest : public NewContextRequest { +class NewContextRequest : public MMIEvent { public: - virtual Arabica::DOM::Document<std::string> toXML(); - static ContextualizedRequest fromXML(const Arabica::DOM::Document<std::string>& doc); + NewContextRequest() { + tagName = "NewContextRequest"; + type = NEWCONTEXTREQUEST; + } + NewContextRequest(const MMIEvent& father) : MMIEvent(father) {} + static NewContextRequest fromXML(Arabica::DOM::Node<std::string> node, + InterpreterImpl* interpreter = NULL) { + MMIEvent event = MMIEvent::fromXML(node, interpreter); + event.type = NEWCONTEXTREQUEST; + return event; + } + operator Event() const { + Event ev = MMIEvent::operator Event(); + ev.setName("mmi.newcontextrequest"); + ev.setDOM(toXML()); + return ev; + } + std::string token; ///< special token for server-less modality components +}; +class ContextualizedRequest : public MMIEvent { +public: + virtual Arabica::DOM::Document<std::string> toXML() const; + static ContextualizedRequest fromXML(Arabica::DOM::Node<std::string> node, + InterpreterImpl* interpreter = NULL); + operator Event() const; std::string context; protected: ContextualizedRequest() {} - ContextualizedRequest(const NewContextRequest& father) : NewContextRequest(father) {} + ContextualizedRequest(const MMIEvent& father) : MMIEvent(father) {} }; class PauseRequest : public ContextualizedRequest { public: PauseRequest() { tagName = "PauseRequest"; + type = PAUSEREQUEST; } PauseRequest(const ContextualizedRequest& father) : ContextualizedRequest(father) {} - static PauseRequest fromXML(const Arabica::DOM::Document<std::string>& doc) { - return ContextualizedRequest::fromXML(doc); + static PauseRequest fromXML(Arabica::DOM::Node<std::string> node, + InterpreterImpl* interpreter = NULL) { + PauseRequest event = ContextualizedRequest::fromXML(node, interpreter); + event.type = PAUSEREQUEST; + return event; } + operator Event() const { + Event ev = ContextualizedRequest::operator Event(); + ev.setName("mmi.pauserequest"); + ev.setDOM(toXML()); + return ev; + } + }; class ResumeRequest : public ContextualizedRequest { public: ResumeRequest() { tagName = "ResumeRequest"; + type = RESUMEREQUEST; } ResumeRequest(const ContextualizedRequest& father) : ContextualizedRequest(father) {} - static ResumeRequest fromXML(const Arabica::DOM::Document<std::string>& doc) { - return ContextualizedRequest::fromXML(doc); + static ResumeRequest fromXML(Arabica::DOM::Node<std::string> node, + InterpreterImpl* interpreter = NULL) { + ResumeRequest event = ContextualizedRequest::fromXML(node, interpreter); + event.type = RESUMEREQUEST; + return event; + } + operator Event() const { + Event ev = ContextualizedRequest::operator Event(); + ev.setDOM(toXML()); + ev.setName("mmi.resumerequest"); + return ev; } }; @@ -71,10 +144,20 @@ class CancelRequest : public ContextualizedRequest { public: CancelRequest() { tagName = "CancelRequest"; + type = CANCELREQUEST; } CancelRequest(const ContextualizedRequest& father) : ContextualizedRequest(father) {} - static CancelRequest fromXML(const Arabica::DOM::Document<std::string>& doc) { - return ContextualizedRequest::fromXML(doc); + static CancelRequest fromXML(Arabica::DOM::Node<std::string> node, + InterpreterImpl* interpreter = NULL) { + CancelRequest event = ContextualizedRequest::fromXML(node, interpreter); + event.type = CANCELREQUEST; + return event; + } + operator Event() const { + Event ev = ContextualizedRequest::operator Event(); + ev.setName("mmi.cancelrequest"); + ev.setDOM(toXML()); + return ev; } }; @@ -82,10 +165,20 @@ class ClearContextRequest : public ContextualizedRequest { public: ClearContextRequest() { tagName = "ClearContextRequest"; + type = CLEARCONTEXTREQUEST; } ClearContextRequest(const ContextualizedRequest& father) : ContextualizedRequest(father) {} - static ClearContextRequest fromXML(const Arabica::DOM::Document<std::string>& doc) { - return ContextualizedRequest::fromXML(doc); + static ClearContextRequest fromXML(Arabica::DOM::Node<std::string> node, + InterpreterImpl* interpreter = NULL) { + ClearContextRequest event = ContextualizedRequest::fromXML(node, interpreter); + event.type = CLEARCONTEXTREQUEST; + return event; + } + operator Event() const { + Event ev = ContextualizedRequest::operator Event(); + ev.setName("mmi.clearcontextrequest"); + ev.setDOM(toXML()); + return ev; } }; @@ -93,10 +186,12 @@ class StatusRequest : public ContextualizedRequest { public: StatusRequest() { tagName = "StatusRequest"; + type = STARTREQUEST; } - virtual Arabica::DOM::Document<std::string> toXML(); - static StatusRequest fromXML(const Arabica::DOM::Document<std::string>& doc); - + virtual Arabica::DOM::Document<std::string> toXML() const; + static StatusRequest fromXML(Arabica::DOM::Node<std::string> node, + InterpreterImpl* interpreter = NULL); + operator Event() const; bool automaticUpdate; protected: StatusRequest(const ContextualizedRequest& father) : ContextualizedRequest(father) {} @@ -110,8 +205,10 @@ public: std::string fetchTimeout; }; - virtual Arabica::DOM::Document<std::string> toXML(); - static ContentRequest fromXML(const Arabica::DOM::Document<std::string>& doc); + virtual Arabica::DOM::Document<std::string> toXML() const; + static ContentRequest fromXML(Arabica::DOM::Node<std::string> node, + InterpreterImpl* interpreter = NULL); + operator Event() const; std::string content; ContentURL contentURL; protected: @@ -123,10 +220,20 @@ class PrepareRequest : public ContentRequest { public: PrepareRequest() { tagName = "PrepareRequest"; + type = PREPAREREQUEST; } PrepareRequest(const ContentRequest& father) : ContentRequest(father) {} - static PrepareRequest fromXML(const Arabica::DOM::Document<std::string>& doc) { - return ContentRequest::fromXML(doc); + static PrepareRequest fromXML(Arabica::DOM::Node<std::string> node, + InterpreterImpl* interpreter = NULL) { + PrepareRequest event = ContentRequest::fromXML(node, interpreter); + event.type = PREPAREREQUEST; + return event; + } + operator Event() const { + Event ev = ContentRequest::operator Event(); + ev.setName("mmi.preparerequest"); + ev.setDOM(toXML()); + return ev; } }; @@ -134,10 +241,20 @@ class StartRequest : public ContentRequest { public: StartRequest() { tagName = "StartRequest"; + type = STARTREQUEST; } StartRequest(const ContentRequest& father) : ContentRequest(father) {} - static StartRequest fromXML(const Arabica::DOM::Document<std::string>& doc) { - return ContentRequest::fromXML(doc); + static StartRequest fromXML(Arabica::DOM::Node<std::string> node, + InterpreterImpl* interpreter = NULL) { + StartRequest event = ContentRequest::fromXML(node, interpreter); + event.type = STARTREQUEST; + return event; + } + operator Event() const { + Event ev = ContentRequest::operator Event(); + ev.setName("mmi.startrequest"); + ev.setDOM(toXML()); + return ev; } }; @@ -146,10 +263,12 @@ class ExtensionNotification : public ContextualizedRequest { public: ExtensionNotification() { tagName = "ExtensionNotification"; + type = EXTENSIONNOTIFICATION; } - virtual Arabica::DOM::Document<std::string> toXML(); - static ExtensionNotification fromXML(const Arabica::DOM::Document<std::string>& doc); - + virtual Arabica::DOM::Document<std::string> toXML() const; + static ExtensionNotification fromXML(Arabica::DOM::Node<std::string> node, + InterpreterImpl* interpreter = NULL); + operator Event() const; std::string name; protected: ExtensionNotification(const ContextualizedRequest& father) : ContextualizedRequest(father) {} @@ -167,33 +286,45 @@ public: StatusResponse() { tagName = "StatusResponse"; + type = STATUSRESPONSE; } - virtual Arabica::DOM::Document<std::string> toXML(); - static StatusResponse fromXML(const Arabica::DOM::Document<std::string>& doc); + virtual Arabica::DOM::Document<std::string> toXML() const; + static StatusResponse fromXML(Arabica::DOM::Node<std::string> node, + InterpreterImpl* interpreter = NULL); Status status; protected: StatusResponse(const ContextualizedRequest& father) : ContextualizedRequest(father) {} - }; class StatusInfoResponse : public StatusResponse { public: - virtual Arabica::DOM::Document<std::string> toXML(); - static StatusInfoResponse fromXML(const Arabica::DOM::Document<std::string>& doc); + virtual Arabica::DOM::Document<std::string> toXML() const; + StatusInfoResponse(const StatusResponse& father) : StatusResponse(father) {} + static StatusInfoResponse fromXML(Arabica::DOM::Node<std::string> node, + InterpreterImpl* interpreter = NULL); std::string statusInfo; protected: StatusInfoResponse() {} - StatusInfoResponse(const StatusResponse& father) : StatusResponse(father) {} }; class PrepareResponse : public StatusInfoResponse { public: PrepareResponse() { tagName = "PrepareResponse"; + type = PREPARERESPONSE; } PrepareResponse(const StatusInfoResponse& father) : StatusInfoResponse(father) {} - static PrepareResponse fromXML(const Arabica::DOM::Document<std::string>& doc) { - return StatusInfoResponse::fromXML(doc); + static PrepareResponse fromXML(Arabica::DOM::Node<std::string> node, + InterpreterImpl* interpreter = NULL) { + PrepareResponse event = StatusInfoResponse::fromXML(node, interpreter); + event.type = PREPARERESPONSE; + return event; + } + operator Event() const { + Event ev = StatusInfoResponse::operator Event(); + ev.setName("mmi.prepareresponse"); + ev.setDOM(toXML()); + return ev; } }; @@ -201,10 +332,20 @@ class StartResponse : public StatusInfoResponse { public: StartResponse() { tagName = "StartResponse"; + type = STARTRESPONSE; } StartResponse(const StatusInfoResponse& father) : StatusInfoResponse(father) {} - static StartResponse fromXML(const Arabica::DOM::Document<std::string>& doc) { - return StatusInfoResponse::fromXML(doc); + static StartResponse fromXML(Arabica::DOM::Node<std::string> node, + InterpreterImpl* interpreter = NULL) { + StartResponse event = StatusInfoResponse::fromXML(node, interpreter); + event.type = STARTRESPONSE; + return event; + } + operator Event() const { + Event ev = StatusInfoResponse::operator Event(); + ev.setName("mmi.startresponse"); + ev.setDOM(toXML()); + return ev; } }; @@ -212,10 +353,20 @@ class CancelResponse : public StatusInfoResponse { public: CancelResponse() { tagName = "CancelResponse"; + type = CANCELRESPONSE; } CancelResponse(const StatusInfoResponse& father) : StatusInfoResponse(father) {} - static CancelResponse fromXML(const Arabica::DOM::Document<std::string>& doc) { - return StatusInfoResponse::fromXML(doc); + static CancelResponse fromXML(Arabica::DOM::Node<std::string> node, + InterpreterImpl* interpreter = NULL) { + CancelResponse event = StatusInfoResponse::fromXML(node, interpreter); + event.type = CANCELRESPONSE; + return event; + } + operator Event() const { + Event ev = StatusInfoResponse::operator Event(); + ev.setName("mmi.cancelresponse"); + ev.setDOM(toXML()); + return ev; } }; @@ -223,10 +374,20 @@ class PauseResponse : public StatusInfoResponse { public: PauseResponse() { tagName = "PauseResponse"; + type = PAUSERESPONSE; } PauseResponse(const StatusInfoResponse& father) : StatusInfoResponse(father) {} - static PauseResponse fromXML(const Arabica::DOM::Document<std::string>& doc) { - return StatusInfoResponse::fromXML(doc); + static PauseResponse fromXML(Arabica::DOM::Node<std::string> node, + InterpreterImpl* interpreter = NULL) { + PauseResponse event = StatusInfoResponse::fromXML(node, interpreter); + event.type = PAUSERESPONSE; + return event; + } + operator Event() const { + Event ev = StatusInfoResponse::operator Event(); + ev.setName("mmi.pauseresponse"); + ev.setDOM(toXML()); + return ev; } }; @@ -234,10 +395,20 @@ class ResumeResponse : public StatusInfoResponse { public: ResumeResponse() { tagName = "ResumeResponse"; + type = RESUMERESPONSE; } ResumeResponse(const StatusInfoResponse& father) : StatusInfoResponse(father) {} - static ResumeResponse fromXML(const Arabica::DOM::Document<std::string>& doc) { - return StatusInfoResponse::fromXML(doc); + static ResumeResponse fromXML(Arabica::DOM::Node<std::string> node, + InterpreterImpl* interpreter = NULL) { + ResumeResponse event = StatusInfoResponse::fromXML(node, interpreter); + event.type = RESUMERESPONSE; + return event; + } + operator Event() const { + Event ev = StatusInfoResponse::operator Event(); + ev.setName("mmi.resumeresponse"); + ev.setDOM(toXML()); + return ev; } }; @@ -245,10 +416,20 @@ class ClearContextResponse : public StatusInfoResponse { public: ClearContextResponse() { tagName = "ClearContextResponse"; + type = CLEARCONTEXTRESPONSE; } ClearContextResponse(const StatusInfoResponse& father) : StatusInfoResponse(father) {} - static ClearContextResponse fromXML(const Arabica::DOM::Document<std::string>& doc) { - return StatusInfoResponse::fromXML(doc); + static ClearContextResponse fromXML(Arabica::DOM::Node<std::string> node, + InterpreterImpl* interpreter = NULL) { + ClearContextResponse event = StatusInfoResponse::fromXML(node, interpreter); + event.type = CLEARCONTEXTRESPONSE; + return event; + } + operator Event() const { + Event ev = StatusInfoResponse::operator Event(); + ev.setName("mmi.clearcontextresponse"); + ev.setDOM(toXML()); + return ev; } }; @@ -256,10 +437,20 @@ class NewContextResponse : public StatusInfoResponse { public: NewContextResponse() { tagName = "NewContextResponse"; + type = NEWCONTEXTRESPONSE; } NewContextResponse(const StatusInfoResponse& father) : StatusInfoResponse(father) {} - static NewContextResponse fromXML(const Arabica::DOM::Document<std::string>& doc) { - return StatusInfoResponse::fromXML(doc); + static NewContextResponse fromXML(Arabica::DOM::Node<std::string> node, + InterpreterImpl* interpreter = NULL) { + NewContextResponse event = StatusInfoResponse::fromXML(node, interpreter); + event.type = NEWCONTEXTRESPONSE; + return event; + } + operator Event() const { + Event ev = StatusInfoResponse::operator Event(); + ev.setName("mmi.newcontextresponse"); + ev.setDOM(toXML()); + return ev; } }; @@ -268,13 +459,23 @@ class DoneNotification : public StatusInfoResponse { public: DoneNotification() { tagName = "DoneNotification"; + type = DONENOTIFICATION; } DoneNotification(const StatusInfoResponse& father) : StatusInfoResponse(father) {} - static DoneNotification fromXML(const Arabica::DOM::Document<std::string>& doc) { - return StatusInfoResponse::fromXML(doc); + static DoneNotification fromXML(Arabica::DOM::Node<std::string> node, + InterpreterImpl* interpreter = NULL) { + DoneNotification event = StatusInfoResponse::fromXML(node, interpreter); + event.type = DONENOTIFICATION; + return event; + } + operator Event() const { + Event ev = StatusInfoResponse::operator Event(); + ev.setName("mmi.donenotification"); + ev.setDOM(toXML()); + return ev; } }; } -#endif /* end of include guard: MMIMESSAGES_H_OS0SE7H5 */ +#endif /* end of include guard: MMIEVENT_H_OS0SE7H5 */ diff --git a/src/uscxml/server/HTTPServer.cpp b/src/uscxml/server/HTTPServer.cpp index 70b272f..bd24326 100644 --- a/src/uscxml/server/HTTPServer.cpp +++ b/src/uscxml/server/HTTPServer.cpp @@ -164,6 +164,10 @@ void HTTPServer::httpRecvReqCallback(struct evhttp_request *req, void *callbackD request.data.compound["path"] = Data(evhttp_uri_get_path(evhttp_request_get_evhttp_uri(req)), Data::VERBATIM); raw << " " << request.data.compound["path"].atom; + const char* query = evhttp_uri_get_query(evhttp_request_get_evhttp_uri(req)); + if (query) + raw << "?" << std::string(query); + raw << " HTTP/" << request.data.compound["httpMajor"].atom << "." << request.data.compound["httpMinor"].atom; raw << std::endl; @@ -197,7 +201,6 @@ void HTTPServer::httpRecvReqCallback(struct evhttp_request *req, void *callbackD // parse query string struct evkeyvalq params; struct evkeyval *param; - const char* query = evhttp_uri_get_query(evhttp_request_get_evhttp_uri(req)); evhttp_parse_query_str(query, ¶ms); for (param = params.tqh_first; param; param = param->next.tqe_next) { diff --git a/src/uscxml/server/HTTPServer.h b/src/uscxml/server/HTTPServer.h index 7356737..bd54166 100644 --- a/src/uscxml/server/HTTPServer.h +++ b/src/uscxml/server/HTTPServer.h @@ -20,6 +20,10 @@ public: Request() : curlReq(NULL) {} std::string content; struct evhttp_request* curlReq; + + operator bool() { + return curlReq != NULL; + } }; class Reply { |