summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/mmi-browser.cpp12
-rw-r--r--src/uscxml/Factory.cpp22
-rw-r--r--src/uscxml/Factory.h22
-rw-r--r--src/uscxml/Interpreter.cpp1304
-rw-r--r--src/uscxml/Interpreter.h94
-rw-r--r--src/uscxml/Message.cpp352
-rw-r--r--src/uscxml/Message.h14
-rw-r--r--src/uscxml/URL.cpp785
-rw-r--r--src/uscxml/URL.h248
-rw-r--r--src/uscxml/concurrency/eventqueue/DelayedEventQueue.cpp2
-rw-r--r--src/uscxml/concurrency/eventqueue/DelayedEventQueue.h8
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp14
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Attr.cpp84
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Attr.h88
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CDATASection.cpp12
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CDATASection.h44
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CharacterData.cpp144
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CharacterData.h106
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Comment.cpp12
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Comment.h44
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOMImplementation.cpp108
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOMImplementation.h60
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.cpp558
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.h170
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentFragment.cpp12
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentFragment.h44
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentType.cpp112
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentType.h98
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.cpp418
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.h158
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Entity.cpp42
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Entity.h80
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8EntityReference.cpp12
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8EntityReference.h44
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NamedNodeMap.cpp258
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NamedNodeMap.h108
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.cpp594
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.h250
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeList.cpp54
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeList.h54
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.cpp44
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.h82
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Notation.cpp32
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Notation.h56
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ProcessingInstruction.cpp44
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ProcessingInstruction.h58
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.cpp102
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.h114
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Text.cpp44
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Text.h50
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.cpp104
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.h108
-rw-r--r--src/uscxml/plugins/element/fetch/FetchElement.cpp134
-rw-r--r--src/uscxml/plugins/element/fetch/FetchElement.h20
-rw-r--r--src/uscxml/plugins/element/response/ResponseElement.cpp76
-rw-r--r--src/uscxml/plugins/element/response/ResponseElement.h10
-rw-r--r--src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.cpp2
-rw-r--r--src/uscxml/plugins/invoker/graphics/openscenegraph/OSGConverter.cpp8
-rw-r--r--src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp2
-rw-r--r--src/uscxml/plugins/invoker/http/HTTPServletInvoker.cpp172
-rw-r--r--src/uscxml/plugins/invoker/http/HTTPServletInvoker.h34
-rw-r--r--src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.cpp106
-rw-r--r--src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.h16
-rw-r--r--src/uscxml/server/HTTPServer.cpp176
-rw-r--r--src/uscxml/server/HTTPServer.h68
-rw-r--r--test/src/scxml-test-framework-client.cpp280
-rw-r--r--test/src/test-curl-multi-api.cpp633
-rw-r--r--test/src/test-url.cpp34
68 files changed, 4700 insertions, 4554 deletions
diff --git a/apps/mmi-browser.cpp b/apps/mmi-browser.cpp
index 7cdd392..4090135 100644
--- a/apps/mmi-browser.cpp
+++ b/apps/mmi-browser.cpp
@@ -28,7 +28,7 @@ int main(int argc, char** argv) {
}
#ifndef _WIN32
- opterr = 0;
+ opterr = 0;
#endif
int option;
while ((option = getopt(argc, argv, "l:p:")) != -1) {
@@ -39,8 +39,8 @@ int main(int argc, char** argv) {
case 'p':
uscxml::Factory::pluginPath = optarg;
break;
- case '?':
- break;
+ case '?':
+ break;
default:
printUsageAndExit();
break;
@@ -50,14 +50,14 @@ int main(int argc, char** argv) {
// for (int i = 0; i < argc; i++)
// std::cout << argv[i] << std::endl;
// std::cout << optind << std::endl;
-
+
Interpreter* interpreter = Interpreter::fromURI(argv[optind]);
if (interpreter) {
- interpreter->setCmdLineOptions(argc, argv);
+ interpreter->setCmdLineOptions(argc, argv);
interpreter->start();
while(interpreter->runOnMainThread(25));
- delete interpreter;
+ delete interpreter;
}
return EXIT_SUCCESS;
diff --git a/src/uscxml/Factory.cpp b/src/uscxml/Factory.cpp
index d299e7b..d14b91a 100644
--- a/src/uscxml/Factory.cpp
+++ b/src/uscxml/Factory.cpp
@@ -150,11 +150,11 @@ Factory::Factory() {
registerIOProcessor(ioProcessor);
}
- {
+ {
FetchElement* element = new FetchElement();
registerExecutableContent(element);
}
- {
+ {
ResponseElement* element = new ResponseElement();
registerExecutableContent(element);
}
@@ -208,9 +208,9 @@ void Factory::registerInvoker(InvokerImpl* invoker) {
}
void Factory::registerExecutableContent(ExecutableContentImpl* executableContent) {
- std::string localName = executableContent->getLocalName();
- std::string nameSpace = executableContent->getNamespace();
- _executableContent[std::make_pair(localName, nameSpace)] = executableContent;
+ std::string localName = executableContent->getLocalName();
+ std::string nameSpace = executableContent->getNamespace();
+ _executableContent[std::make_pair(localName, nameSpace)] = executableContent;
}
@@ -263,13 +263,13 @@ boost::shared_ptr<IOProcessorImpl> Factory::createIOProcessor(const std::string&
}
boost::shared_ptr<ExecutableContentImpl> Factory::createExecutableContent(const std::string& localName, const std::string& nameSpace, Interpreter* interpreter) {
- Factory* factory = getInstance();
- std::string actualNameSpace = (nameSpace.length() == 0 ? "http://www.w3.org/2005/07/scxml" : nameSpace);
+ Factory* factory = getInstance();
+ 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()) {
- LOG(ERROR) << "Executable content " << localName << " in " << actualNameSpace << " not available in factory";
+ 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 factory->_executableContent[std::make_pair(localName, actualNameSpace)]->create(interpreter);
}
@@ -292,7 +292,7 @@ void IOProcessorImpl::returnEvent(Event& event) {
_interpreter->receive(event);
}
-
+
Factory* Factory::_instance = NULL;
std::string Factory::pluginPath;
} \ No newline at end of file
diff --git a/src/uscxml/Factory.h b/src/uscxml/Factory.h
index 9397e36..9cfc202 100644
--- a/src/uscxml/Factory.h
+++ b/src/uscxml/Factory.h
@@ -83,15 +83,25 @@ public:
_impl->setInterpreter(interpreter);
}
- std::string getLocalName() { return _impl->getLocalName(); }
- std::string getNamespace() { return _impl->getNamespace(); }
- void enterElement(const Arabica::DOM::Node<std::string>& node) { return _impl->enterElement(node); }
- void exitElement(const Arabica::DOM::Node<std::string>& node) { return _impl->exitElement(node); }
- bool processChildren() { return _impl->processChildren(); }
+ std::string getLocalName() {
+ return _impl->getLocalName();
+ }
+ std::string getNamespace() {
+ return _impl->getNamespace();
+ }
+ void enterElement(const Arabica::DOM::Node<std::string>& node) {
+ return _impl->enterElement(node);
+ }
+ void exitElement(const Arabica::DOM::Node<std::string>& node) {
+ return _impl->exitElement(node);
+ }
+ bool processChildren() {
+ return _impl->processChildren();
+ }
protected:
boost::shared_ptr<ExecutableContentImpl> _impl;
- };
+};
class IOProcessorImpl {
public:
diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp
index 448bb7c..4e5b279 100644
--- a/src/uscxml/Interpreter.cpp
+++ b/src/uscxml/Interpreter.cpp
@@ -33,11 +33,11 @@ const std::string Interpreter::getUUID() {
Interpreter::Interpreter() : Arabica::SAX2DOM::Parser<std::string>() {
_lastRunOnMainThread = 0;
- _nsURL = "*";
+ _nsURL = "*";
_thread = NULL;
_sendQueue = NULL;
_parentQueue = NULL;
- _httpServlet = NULL;
+ _httpServlet = NULL;
_running = false;
_done = false;
@@ -71,14 +71,14 @@ Interpreter* Interpreter::fromURI(const std::string& uri) {
return NULL;
}
}
- Arabica::SAX::InputSource<std::string> inputSource;
-
- // this is required for windows filenames and does not harm on unices
- if (boost::iequals(absUrl.scheme(), "file")) {
- inputSource.setSystemId(absUrl.path());
- } else {
- inputSource.setSystemId(absUrl.asString());
- }
+ Arabica::SAX::InputSource<std::string> inputSource;
+
+ // this is required for windows filenames and does not harm on unices
+ if (boost::iequals(absUrl.scheme(), "file")) {
+ inputSource.setSystemId(absUrl.path());
+ } else {
+ inputSource.setSystemId(absUrl.asString());
+ }
Interpreter* interpreter = fromInputSource(inputSource);
// try to establish URI root for relative src attributes in document
@@ -88,11 +88,11 @@ Interpreter* Interpreter::fromURI(const std::string& uri) {
}
void Interpreter::setName(const std::string& name) {
- if (!_running) {
- _name = name;
- } else {
- LOG(ERROR) << "Cannot change name of running interpreter";
- }
+ if (!_running) {
+ _name = name;
+ } else {
+ LOG(ERROR) << "Cannot change name of running interpreter";
+ }
}
URL Interpreter::toBaseURI(const URL& uri) {
@@ -129,22 +129,22 @@ bool Interpreter::toAbsoluteURI(URL& uri) {
void Interpreter::startPrefixMapping(const std::string& prefix, const std::string& uri) {
#if 0
- std::cout << "starting prefix mapping " << prefix << ": " << uri << std::endl;
+ std::cout << "starting prefix mapping " << prefix << ": " << uri << std::endl;
#endif
- 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");
- } else {
- _xpathPrefix = prefix + ":";
- _xmlNSPrefix = _xpathPrefix;
- _nsContext.addNamespaceDeclaration(uri, prefix);
- }
- } else {
- _nsContext.addNamespaceDeclaration(uri, prefix);
- }
+ 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");
+ } else {
+ _xpathPrefix = prefix + ":";
+ _xmlNSPrefix = _xpathPrefix;
+ _nsContext.addNamespaceDeclaration(uri, prefix);
+ }
+ } else {
+ _nsContext.addNamespaceDeclaration(uri, prefix);
+ }
}
Interpreter* Interpreter::fromInputSource(Arabica::SAX::InputSource<std::string>& source) {
@@ -177,20 +177,20 @@ void Interpreter::init() {
if (scxmls.getLength() > 0) {
_scxml = (Arabica::DOM::Element<std::string>)scxmls.item(0);
- // setup xpath and check that it works
+ // setup xpath and check that it works
_xpath.setNamespaceContext(_nsContext);
- Arabica::XPath::NodeSet<std::string> scxmls = _xpath.evaluate("/" + _xpathPrefix + "scxml", _document).asNodeSet();
- assert(scxmls.size() > 0);
- assert(scxmls[0] == _scxml);
+ Arabica::XPath::NodeSet<std::string> scxmls = _xpath.evaluate("/" + _xpathPrefix + "scxml", _document).asNodeSet();
+ assert(scxmls.size() > 0);
+ assert(scxmls[0] == _scxml);
- if (_name.length() == 0)
- _name = (HAS_ATTR(_scxml, "name") ? ATTR(_scxml, "name") : getUUID());
+ if (_name.length() == 0)
+ _name = (HAS_ATTR(_scxml, "name") ? ATTR(_scxml, "name") : getUUID());
normalize(_document);
- _sendQueue = new DelayedEventQueue();
- _httpServlet = new HTTPServletInvoker(this);
- _sendQueue->start();
+ _sendQueue = new DelayedEventQueue();
+ _httpServlet = new HTTPServletInvoker(this);
+ _sendQueue->start();
} else {
LOG(ERROR) << "Cannot find SCXML element" << std::endl;
@@ -262,19 +262,19 @@ void Interpreter::interpret() {
_sessionId = getUUID();
- std::string datamodelName;
- if (datamodelName.length() == 0 && HAS_ATTR(_scxml, "datamodel"))
- datamodelName = ATTR(_scxml, "datamodel");
- if (datamodelName.length() == 0 && HAS_ATTR(_scxml, "profile")) // SCION SCXML uses profile to specify datamodel
- datamodelName = ATTR(_scxml, "profile");
- _dataModel = Factory::createDataModel(datamodelName, this);
- if(datamodelName.length() > 0 && !_dataModel) {
- LOG(ERROR) << "No datamodel for " << datamodelName << " registered";
- }
-
- if (_dataModel)
- _dataModel.assign("_x.args", _cmdLineOptions);
-
+ std::string datamodelName;
+ if (datamodelName.length() == 0 && HAS_ATTR(_scxml, "datamodel"))
+ datamodelName = ATTR(_scxml, "datamodel");
+ if (datamodelName.length() == 0 && HAS_ATTR(_scxml, "profile")) // SCION SCXML uses profile to specify datamodel
+ datamodelName = ATTR(_scxml, "profile");
+ _dataModel = Factory::createDataModel(datamodelName, this);
+ if(datamodelName.length() > 0 && !_dataModel) {
+ LOG(ERROR) << "No datamodel for " << datamodelName << " registered";
+ }
+
+ if (_dataModel)
+ _dataModel.assign("_x.args", _cmdLineOptions);
+
setupIOProcessors();
_running = true;
@@ -319,10 +319,10 @@ void Interpreter::interpret() {
// assert(hasLegalConfiguration());
mainEventLoop();
-
- // set datamodel to null from this thread
- if(_dataModel)
- _dataModel = DataModel();
+
+ // set datamodel to null from this thread
+ if(_dataModel)
+ _dataModel = DataModel();
}
@@ -349,12 +349,12 @@ void Interpreter::initializeData(const Arabica::DOM::Node<std::string>& data) {
toAbsoluteURI(srcURL);
std::stringstream ss;
- if (_cachedURLs.find(srcURL.asString()) != _cachedURLs.end()) {
- ss << _cachedURLs[srcURL.asString()];
- } else {
- ss << srcURL;
- _cachedURLs[srcURL.asString()] = srcURL;
- }
+ if (_cachedURLs.find(srcURL.asString()) != _cachedURLs.end()) {
+ ss << _cachedURLs[srcURL.asString()];
+ } else {
+ ss << srcURL;
+ _cachedURLs[srcURL.asString()] = srcURL;
+ }
_dataModel.assign(ATTR(data, "id"), ss.str());
} else if (data.hasChildNodes()) {
@@ -435,7 +435,7 @@ void Interpreter::normalize(const Arabica::DOM::Document<std::string>& node) {
}
void Interpreter::mainEventLoop() {
- std::set<InterpreterMonitor*>::iterator monIter;
+ std::set<InterpreterMonitor*>::iterator monIter;
while(_running) {
NodeSet<std::string> enabledTransitions;
@@ -451,11 +451,11 @@ void Interpreter::mainEventLoop() {
}
std::cout << std::endl;
#endif
- monIter = _monitors.begin();
- while(monIter != _monitors.end()) {
- (*monIter)->beforeMicroStep(this);
- monIter++;
- }
+ monIter = _monitors.begin();
+ while(monIter != _monitors.end()) {
+ (*monIter)->beforeMicroStep(this);
+ monIter++;
+ }
enabledTransitions = selectEventlessTransitions();
if (enabledTransitions.size() == 0) {
@@ -473,13 +473,13 @@ void Interpreter::mainEventLoop() {
}
}
if (!enabledTransitions.empty()) {
- monIter = _monitors.begin();
- while(monIter != _monitors.end()) {
- (*monIter)->beforeTakingTransitions(this, enabledTransitions);
- monIter++;
- }
+ monIter = _monitors.begin();
+ while(monIter != _monitors.end()) {
+ (*monIter)->beforeTakingTransitions(this, enabledTransitions);
+ monIter++;
+ }
microstep(enabledTransitions);
- }
+ }
}
for (unsigned int i = 0; i < _statesToInvoke.size(); i++) {
@@ -493,17 +493,17 @@ void Interpreter::mainEventLoop() {
if (!_internalQueue.empty())
continue;
- // assume that we have a legal configuration as soon as the internal queue is empty
+ // assume that we have a legal configuration as soon as the internal queue is empty
// assert(hasLegalConfiguration());
- monIter = _monitors.begin();
+ monIter = _monitors.begin();
// if (!_sendQueue || _sendQueue->isEmpty()) {
- while(monIter != _monitors.end()) {
- (*monIter)->onStableConfiguration(this);
- monIter++;
- }
+ while(monIter != _monitors.end()) {
+ (*monIter)->onStableConfiguration(this);
+ monIter++;
+ }
// }
-
+
// whenever we have a stable configuration, run the mainThread hooks with 200fps
while(_externalQueue.isEmpty() && _thread == NULL) {
runOnMainThread(200);
@@ -511,7 +511,7 @@ void Interpreter::mainEventLoop() {
Event externalEvent = _externalQueue.pop();
#if VERBOSE
- std::cout << "Received externalEvent event " << externalEvent.name << std::endl;
+ std::cout << "Received externalEvent event " << externalEvent.name << std::endl;
#endif
externalEvent.type = Event::EXTERNAL; // make sure it is set to external
if (!_running)
@@ -530,11 +530,11 @@ void Interpreter::mainEventLoop() {
NodeSet<std::string> invokes = filterChildElements(_xmlNSPrefix + "invoke", _configuration[i]);
for (unsigned int j = 0; j < invokes.size(); j++) {
Arabica::DOM::Element<std::string> invokeElem = (Arabica::DOM::Element<std::string>)invokes[j];
- std::string invokeId;
- if (HAS_ATTR(invokeElem, "id"))
- invokeId = ATTR(invokeElem, "id");
- if (HAS_ATTR(invokeElem, "idlocation") && _dataModel)
- invokeId = _dataModel.evalAsString(ATTR(invokeElem, "idlocation"));
+ std::string invokeId;
+ if (HAS_ATTR(invokeElem, "id"))
+ invokeId = ATTR(invokeElem, "id");
+ if (HAS_ATTR(invokeElem, "idlocation") && _dataModel)
+ invokeId = _dataModel.evalAsString(ATTR(invokeElem, "idlocation"));
std::string autoForward = invokeElem.getAttribute("autoforward");
if (boost::iequals(invokeId, externalEvent.invokeid)) {
@@ -547,7 +547,7 @@ void Interpreter::mainEventLoop() {
}
if (boost::iequals(autoForward, "true")) {
- _invokers[invokeId].send(externalEvent);
+ _invokers[invokeId].send(externalEvent);
}
}
}
@@ -555,19 +555,19 @@ void Interpreter::mainEventLoop() {
if (!enabledTransitions.empty())
microstep(enabledTransitions);
}
- monIter = _monitors.begin();
- while(monIter != _monitors.end()) {
- (*monIter)->beforeCompletion(this);
- monIter++;
- }
+ monIter = _monitors.begin();
+ while(monIter != _monitors.end()) {
+ (*monIter)->beforeCompletion(this);
+ monIter++;
+ }
exitInterpreter();
- monIter = _monitors.begin();
- while(monIter != _monitors.end()) {
- (*monIter)->afterCompletion(this);
- monIter++;
- }
+ monIter = _monitors.begin();
+ while(monIter != _monitors.end()) {
+ (*monIter)->afterCompletion(this);
+ monIter++;
+ }
}
@@ -700,16 +700,16 @@ void Interpreter::send(const Arabica::DOM::Node<std::string>& element) {
}
// namelist
if (HAS_ATTR(element, "namelist")) {
- if (_dataModel) {
- std::vector<std::string> names = tokenizeIdRefs(ATTR(element, "namelist"));
- for (int i = 0; i < names.size(); i++) {
- std::string namelistValue = _dataModel.evalAsString(names[i]);
- sendReq.namelist[names[i]] = namelistValue;
- sendReq.data.compound[names[i]] = Data(namelistValue, Data::VERBATIM);
- }
- } else {
+ if (_dataModel) {
+ std::vector<std::string> names = tokenizeIdRefs(ATTR(element, "namelist"));
+ for (int i = 0; i < names.size(); i++) {
+ std::string namelistValue = _dataModel.evalAsString(names[i]);
+ sendReq.namelist[names[i]] = namelistValue;
+ sendReq.data.compound[names[i]] = Data(namelistValue, Data::VERBATIM);
+ }
+ } else {
LOG(ERROR) << "Namelist attribute at send requires datamodel to be defined";
- }
+ }
}
// params
@@ -728,10 +728,10 @@ void Interpreter::send(const Arabica::DOM::Node<std::string>& element) {
LOG(ERROR) << "param element is missing expr or location or no datamodel is specified";
continue;
}
- std::string paramKey = ATTR(params[i], "name");
- boost::algorithm::to_lower(paramKey);
+ std::string paramKey = ATTR(params[i], "name");
+ boost::algorithm::to_lower(paramKey);
sendReq.params.insert(std::make_pair(paramKey, paramValue));
- sendReq.data.compound[paramKey] = Data(paramValue, Data::VERBATIM);
+ sendReq.data.compound[paramKey] = Data(paramValue, Data::VERBATIM);
}
// content
@@ -741,7 +741,7 @@ void Interpreter::send(const Arabica::DOM::Node<std::string>& element) {
if (contents.size() > 0) {
if (HAS_ATTR(contents[0], "expr")) {
if (_dataModel) {
- std::string contentValue = _dataModel.evalAsString(ATTR(contents[0], "expr"));
+ std::string contentValue = _dataModel.evalAsString(ATTR(contents[0], "expr"));
sendReq.content = contentValue;
// sendReq.data.atom = contentValue;
// sendReq.data.type = Data::VERBATIM;
@@ -783,8 +783,8 @@ void Interpreter::delayedSend(void* userdata, std::string eventName) {
} else {
LOG(ERROR) << "Can not send to parent, we were not invoked" << std::endl;
}
- } else if (boost::iequals(sendReq.target, "#_internal")) {
- INSTANCE->_internalQueue.push_back(sendReq);
+ } else if (boost::iequals(sendReq.target, "#_internal")) {
+ INSTANCE->_internalQueue.push_back(sendReq);
} else if (sendReq.target.find_first_of("#_") == 0) {
// send to invoker
std::string invokeId = sendReq.target.substr(2, sendReq.target.length() - 2);
@@ -874,7 +874,7 @@ void Interpreter::invoke(const Arabica::DOM::Node<std::string>& element) {
if (_dataModel) {
paramValue = _dataModel.evalAsString(ATTR(params[i], "expr"));
} else {
- LOG(ERROR) << "Cannot use param expr without a datamodel!";
+ LOG(ERROR) << "Cannot use param expr without a datamodel!";
}
} else if(HAS_ATTR(params[i], "location") && _dataModel) {
paramValue = _dataModel.evalAsString(ATTR(params[i], "location"));
@@ -882,8 +882,8 @@ void Interpreter::invoke(const Arabica::DOM::Node<std::string>& element) {
LOG(ERROR) << "param element is missing expr or location or no datamodel is specified";
continue;
}
- std::string paramKey = ATTR(params[i], "name");
- boost::algorithm::to_lower(paramKey);
+ std::string paramKey = ATTR(params[i], "name");
+ boost::algorithm::to_lower(paramKey);
invokeReq.params.insert(std::make_pair(paramKey, paramValue));
}
@@ -899,19 +899,19 @@ void Interpreter::invoke(const Arabica::DOM::Node<std::string>& element) {
Invoker invoker(Factory::createInvoker(invokeReq.type, this));
if (invoker) {
tthread::lock_guard<tthread::mutex> lock(_mutex);
- try {
- invoker.setInvokeId(invokeReq.invokeid);
- invoker.setType(invokeReq.type);
- invoker.setInterpreter(this);
- _invokers[invokeReq.invokeid] = invoker;
- LOG(INFO) << "Added invoker " << invokeReq.type << " at " << invokeReq.invokeid;
- invoker.invoke(invokeReq);
- if (_dataModel) {
- _dataModel.assign("_invokers['" + invokeReq.invokeid + "']", invoker.getDataModelVariables());
- }
- } catch (...) {
- LOG(ERROR) << "Invoker " << invokeReq.type << " threw an exception";
- }
+ try {
+ invoker.setInvokeId(invokeReq.invokeid);
+ invoker.setType(invokeReq.type);
+ invoker.setInterpreter(this);
+ _invokers[invokeReq.invokeid] = invoker;
+ LOG(INFO) << "Added invoker " << invokeReq.type << " at " << invokeReq.invokeid;
+ invoker.invoke(invokeReq);
+ if (_dataModel) {
+ _dataModel.assign("_invokers['" + invokeReq.invokeid + "']", invoker.getDataModelVariables());
+ }
+ } catch (...) {
+ LOG(ERROR) << "Invoker " << invokeReq.type << " threw an exception";
+ }
} else {
LOG(ERROR) << "No invoker known for type " << invokeReq.type;
}
@@ -932,14 +932,14 @@ void Interpreter::cancelInvoke(const Arabica::DOM::Node<std::string>& element) {
}
if (_invokers.find(invokeId) != _invokers.end()) {
LOG(INFO) << "Removed invoker at " << invokeId;
- if (_dataModel) {
- try {
- _dataModel.assign("_invokers['" + invokeId + "']", "''");
- } catch (Event e) {
- LOG(ERROR) << "Syntax when removing invoker:" << std::endl << e << std::endl;
- }
-
- }
+ if (_dataModel) {
+ try {
+ _dataModel.assign("_invokers['" + invokeId + "']", "''");
+ } catch (Event e) {
+ LOG(ERROR) << "Syntax when removing invoker:" << std::endl << e << std::endl;
+ }
+
+ }
_invokers.erase(invokeId);
} else {
LOG(ERROR) << "Cannot cancel invoke for id " << invokeId << ": no soch invokation";
@@ -959,28 +959,28 @@ Arabica::XPath::NodeSet<std::string> Interpreter::selectTransitions(const std::s
for (unsigned int i = 0; i < atomicStates.size(); i++) {
NodeSet<std::string> ancestors = getProperAncestors(atomicStates[i], Arabica::DOM::Node<std::string>());
- NodeSet<std::string> sortedAncestors;
- sortedAncestors.push_back(atomicStates[i]);
- sortedAncestors.insert(sortedAncestors.end(), ancestors.begin(), ancestors.end());
+ NodeSet<std::string> sortedAncestors;
+ sortedAncestors.push_back(atomicStates[i]);
+ sortedAncestors.insert(sortedAncestors.end(), ancestors.begin(), ancestors.end());
for (unsigned int j = 0; j < sortedAncestors.size(); j++) {
NodeSet<std::string> transitions = filterChildElements(_xmlNSPrefix + "transition", sortedAncestors[j]);
for (unsigned int k = 0; k < transitions.size(); k++) {
- std::string eventName;
- if (HAS_ATTR(transitions[k], "event")) {
- eventName = ATTR(transitions[k], "event");
- } else if(HAS_ATTR(transitions[k], "eventexpr")) {
- if (_dataModel) {
- eventName = _dataModel.evalAsString(ATTR(transitions[k], "eventexpr"));
- } else {
- LOG(ERROR) << "Transition has eventexpr attribute with no datamodel defined";
- goto LOOP;
- }
- } else {
- LOG(ERROR) << "Transition has neither event nor eventexpr attribute";
+ std::string eventName;
+ if (HAS_ATTR(transitions[k], "event")) {
+ eventName = ATTR(transitions[k], "event");
+ } else if(HAS_ATTR(transitions[k], "eventexpr")) {
+ if (_dataModel) {
+ eventName = _dataModel.evalAsString(ATTR(transitions[k], "eventexpr"));
+ } else {
+ LOG(ERROR) << "Transition has eventexpr attribute with no datamodel defined";
+ goto LOOP;
+ }
+ } else {
+ LOG(ERROR) << "Transition has neither event nor eventexpr attribute";
goto LOOP;
- }
-
+ }
+
if (eventName.length() > 0 &&
nameMatch(eventName, event) &&
hasConditionMatch(transitions[k])) {
@@ -992,7 +992,7 @@ Arabica::XPath::NodeSet<std::string> Interpreter::selectTransitions(const std::s
LOOP:
;
}
-
+
enabledTransitions = filterPreempted(enabledTransitions);
return enabledTransitions;
}
@@ -1080,19 +1080,19 @@ LOOP:
}
bool Interpreter::hasConditionMatch(const Arabica::DOM::Node<std::string>& conditional) {
-
- if (HAS_ATTR(conditional, "cond")) {
- if (!_dataModel) {
- LOG(ERROR) << "Cannot check a condition without a datamodel";
- return false;
- }
- try {
- return _dataModel.evalAsBool(ATTR(conditional, "cond"));
- } catch (Event e) {
- LOG(ERROR) << "Syntax error in cond attribute of " << TAGNAME(conditional) << " element:" << std::endl << e << std::endl;
- return false;
- }
- }
+
+ if (HAS_ATTR(conditional, "cond")) {
+ if (!_dataModel) {
+ LOG(ERROR) << "Cannot check a condition without a datamodel";
+ return false;
+ }
+ try {
+ return _dataModel.evalAsBool(ATTR(conditional, "cond"));
+ } catch (Event e) {
+ LOG(ERROR) << "Syntax error in cond attribute of " << TAGNAME(conditional) << " element:" << std::endl << e << std::endl;
+ return false;
+ }
+ }
return true; // no condition is always true
}
@@ -1104,10 +1104,10 @@ Arabica::XPath::NodeSet<std::string> Interpreter::filterPreempted(const Arabica:
Arabica::DOM::Node<std::string> t2 = enabledTransitions[j];
if (isPreemptingTransition(t2, t)) {
#if VERBOSE
- std::cout << "Transition preempted!: " << std::endl << t2 << std::endl << t << std::endl;
+ std::cout << "Transition preempted!: " << std::endl << t2 << std::endl << t << std::endl;
#endif
goto LOOP;
- }
+ }
}
filteredTransitions.push_back(t);
LOOP:
@@ -1117,13 +1117,13 @@ LOOP:
}
bool Interpreter::isPreemptingTransition(const Arabica::DOM::Node<std::string>& t1, const Arabica::DOM::Node<std::string>& t2) {
- assert(t1);
- assert(t2);
+ assert(t1);
+ assert(t2);
#if VERBOSE
- std::cout << "Checking preemption: " << std::endl << t1 << std::endl << t2 << std::endl;
+ std::cout << "Checking preemption: " << std::endl << t1 << std::endl << t2 << std::endl;
#endif
-
+
#if 1
if (t1 == t2)
return false;
@@ -1135,17 +1135,17 @@ bool Interpreter::isPreemptingTransition(const Arabica::DOM::Node<std::string>&
#endif
#if 0
- // isPreempted from chris nuernberger
- if (isTargetless(t1))
- return false;
-
- Arabica::DOM::Node<std::string> existingRoot = getTransitionSubgraph(t1);
- Arabica::DOM::Node<std::string> nextRoot = getTransitionSubgraph(t2);
-
- if (existingRoot == nextRoot || isDescendant(existingRoot, nextRoot) || isDescendant(nextRoot, existingRoot))
- return true;
-
- return false;
+ // isPreempted from chris nuernberger
+ if (isTargetless(t1))
+ return false;
+
+ Arabica::DOM::Node<std::string> existingRoot = getTransitionSubgraph(t1);
+ Arabica::DOM::Node<std::string> nextRoot = getTransitionSubgraph(t2);
+
+ if (existingRoot == nextRoot || isDescendant(existingRoot, nextRoot) || isDescendant(nextRoot, existingRoot))
+ return true;
+
+ return false;
#endif
}
@@ -1154,29 +1154,29 @@ bool Interpreter::isPreemptingTransition(const Arabica::DOM::Node<std::string>&
*/
#if 0
Arabica::DOM::Node<std::string> Interpreter::getTransitionSubgraph(const Arabica::DOM::Node<std::string>& transition) {
- Arabica::XPath::NodeSet<std::string> targets = getTargetStates(transition);
- Arabica::DOM::Node<std::string> source = getSourceState(transition);
-
- if (!targets.size() == 0)
- return source;
-
- if (boost::iequals(ATTR(transition, "type"), "internal") && isCompound(source)) {
- bool allDescendants = true;
- for (int i = 0; i < targets.size(); i++) {
- if (!isDescendant(targets[i], source)) {
- allDescendants = false;
- break;
- }
- }
- if (allDescendants)
- return source;
- }
-
- targets.push_back(source);
- return findLCCA(targets);
+ Arabica::XPath::NodeSet<std::string> targets = getTargetStates(transition);
+ Arabica::DOM::Node<std::string> source = getSourceState(transition);
+
+ if (!targets.size() == 0)
+ return source;
+
+ if (boost::iequals(ATTR(transition, "type"), "internal") && isCompound(source)) {
+ bool allDescendants = true;
+ for (int i = 0; i < targets.size(); i++) {
+ if (!isDescendant(targets[i], source)) {
+ allDescendants = false;
+ break;
+ }
+ }
+ if (allDescendants)
+ return source;
+ }
+
+ targets.push_back(source);
+ return findLCCA(targets);
}
#endif
-
+
void Interpreter::microstep(const Arabica::XPath::NodeSet<std::string>& enabledTransitions) {
#if 0
std::cout << "Transitions: ";
@@ -1217,7 +1217,7 @@ void Interpreter::exitInterpreter() {
}
void Interpreter::executeTransitionContent(const Arabica::XPath::NodeSet<std::string>& enabledTransitions) {
- executeContent(enabledTransitions);
+ executeContent(enabledTransitions);
}
void Interpreter::executeContent(const NodeList<std::string>& content) {
@@ -1229,11 +1229,11 @@ void Interpreter::executeContent(const NodeList<std::string>& content) {
}
void Interpreter::executeContent(const NodeSet<std::string>& content) {
- for (unsigned int i = 0; i < content.size(); i++) {
- if (content[i].getNodeType() != Node_base::ELEMENT_NODE)
- continue;
- executeContent(content[i]);
- }
+ for (unsigned int i = 0; i < content.size(); i++) {
+ if (content[i].getNodeType() != Node_base::ELEMENT_NODE)
+ continue;
+ executeContent(content[i]);
+ }
}
void Interpreter::executeContent(const Arabica::DOM::Node<std::string>& content) {
@@ -1242,13 +1242,13 @@ void Interpreter::executeContent(const Arabica::DOM::Node<std::string>& content)
if (false) {
} else if (boost::iequals(TAGNAME(content), _xmlNSPrefix + "onentry") ||
- boost::iequals(TAGNAME(content), _xmlNSPrefix + "onexit") ||
- boost::iequals(TAGNAME(content), _xmlNSPrefix + "transition")) {
+ boost::iequals(TAGNAME(content), _xmlNSPrefix + "onexit") ||
+ boost::iequals(TAGNAME(content), _xmlNSPrefix + "transition")) {
// --- CONVENIENCE LOOP --------------------------
- NodeList<std::string> executable = content.getChildNodes();
- for (int i = 0; i < executable.getLength(); i++) {
- executeContent(executable.item(i));
- }
+ NodeList<std::string> executable = content.getChildNodes();
+ for (int i = 0; i < executable.getLength(); i++) {
+ executeContent(executable.item(i));
+ }
} else if (boost::iequals(TAGNAME(content), _xmlNSPrefix + "raise")) {
// --- RAISE --------------------------
if (HAS_ATTR(content, "event")) {
@@ -1260,8 +1260,8 @@ void Interpreter::executeContent(const Arabica::DOM::Node<std::string>& content)
// --- IF / ELSEIF / ELSE --------------
Arabica::DOM::Element<std::string> ifElem = (Arabica::DOM::Element<std::string>)content;
#if 0
- if (HAS_ATTR(ifElem, "cond"))
- std::cout << ATTR(ifElem, "cond") << std::endl;
+ if (HAS_ATTR(ifElem, "cond"))
+ std::cout << ATTR(ifElem, "cond") << std::endl;
#endif
if(hasConditionMatch(ifElem)) {
// condition is true, execute all content up to an elseif, else or end
@@ -1282,8 +1282,8 @@ void Interpreter::executeContent(const Arabica::DOM::Node<std::string>& content)
NodeList<std::string> elseifElem = ifElem.getElementsByTagNameNS(_nsURL, "elseif");
for (unsigned int i = 0; i < elseifElem.getLength(); i++) {
#if 0
- if (HAS_ATTR(elseifElem.item(i), "cond"))
- std::cout << ATTR(elseifElem.item(i), "cond") << std::endl;
+ if (HAS_ATTR(elseifElem.item(i), "cond"))
+ std::cout << ATTR(elseifElem.item(i), "cond") << std::endl;
#endif
if (hasConditionMatch(elseifElem.item(i))) {
executeContent(elseifElem.item(i).getChildNodes());
@@ -1372,14 +1372,14 @@ ELSIF_ELEM_MATCH:
}
std::stringstream srcContent;
- if (_cachedURLs.find(scriptUrl.asString()) != _cachedURLs.end()) {
- srcContent << _cachedURLs[scriptUrl.asString()];
- } else {
- srcContent << scriptUrl;
- _cachedURLs[scriptUrl.asString()] = scriptUrl;
- }
-
-
+ if (_cachedURLs.find(scriptUrl.asString()) != _cachedURLs.end()) {
+ srcContent << _cachedURLs[scriptUrl.asString()];
+ } else {
+ srcContent << scriptUrl;
+ _cachedURLs[scriptUrl.asString()] = scriptUrl;
+ }
+
+
try {
_dataModel.eval(srcContent.str());
} catch (Event e) {
@@ -1422,27 +1422,27 @@ ELSIF_ELEM_MATCH:
} else if (boost::iequals(TAGNAME(content), _xmlNSPrefix + "invoke")) {
// --- INVOKE --------------------------
} else {
- // --- Custom Executable Content
- ExecutableContent execContent;
- if (_executableContent.find(content) == _executableContent.end()) {
- execContent = Factory::createExecutableContent(content.getLocalName(), content.getNamespaceURI(), this);
- if (!execContent) {
- LOG(ERROR) << "No custom executable content known for " << content.getLocalName() << " in " << content.getNamespaceURI();
- return;
- }
- _executableContent[content] = execContent;
- } else {
- execContent = _executableContent[content];
- }
-
- execContent.enterElement(content);
- if (execContent.processChildren()) {
- NodeList<std::string> executable = content.getChildNodes();
- for (int i = 0; i < executable.getLength(); i++) {
- executeContent(executable.item(i));
- }
- }
- execContent.exitElement(content);
+ // --- Custom Executable Content
+ ExecutableContent execContent;
+ if (_executableContent.find(content) == _executableContent.end()) {
+ execContent = Factory::createExecutableContent(content.getLocalName(), content.getNamespaceURI(), this);
+ if (!execContent) {
+ LOG(ERROR) << "No custom executable content known for " << content.getLocalName() << " in " << content.getNamespaceURI();
+ return;
+ }
+ _executableContent[content] = execContent;
+ } else {
+ execContent = _executableContent[content];
+ }
+
+ execContent.enterElement(content);
+ if (execContent.processChildren()) {
+ NodeList<std::string> executable = content.getChildNodes();
+ for (int i = 0; i < executable.getLength(); i++) {
+ executeContent(executable.item(i));
+ }
+ }
+ execContent.exitElement(content);
}
}
@@ -1451,16 +1451,16 @@ void Interpreter::returnDoneEvent(const Arabica::DOM::Node<std::string>& state)
void Interpreter::exitStates(const Arabica::XPath::NodeSet<std::string>& enabledTransitions) {
NodeSet<std::string> statesToExit;
- std::set<InterpreterMonitor*>::iterator monIter;
-
+ std::set<InterpreterMonitor*>::iterator monIter;
+
#if VERBOSE
- std::cout << "Enabled exit transitions: " << std::endl;
+ std::cout << "Enabled exit transitions: " << std::endl;
for (int i = 0; i < enabledTransitions.size(); i++) {
- std::cout << enabledTransitions[i] << std::endl;
- }
- std::cout << std::endl;
+ std::cout << enabledTransitions[i] << std::endl;
+ }
+ std::cout << std::endl;
#endif
-
+
for (int i = 0; i < enabledTransitions.size(); i++) {
Arabica::DOM::Element<std::string> transition = ((Arabica::DOM::Element<std::string>)enabledTransitions[i]);
if (!isTargetless(transition)) {
@@ -1486,17 +1486,17 @@ void Interpreter::exitStates(const Arabica::XPath::NodeSet<std::string>& enabled
tmpStates.insert(tmpStates.end(), tStates.begin(), tStates.end());
#if VERBOSE
- std::cout << "tmpStates: ";
- for (int i = 0; i < tmpStates.size(); i++) {
- std::cout << ATTR(tmpStates[i], "id") << ", ";
- }
- std::cout << std::endl;
+ std::cout << "tmpStates: ";
+ for (int i = 0; i < tmpStates.size(); i++) {
+ std::cout << ATTR(tmpStates[i], "id") << ", ";
+ }
+ std::cout << std::endl;
#endif
ancestor = findLCCA(tmpStates);
}
#if VERBOSE
- std::cout << "Ancestor: " << ATTR(ancestor, "id") << std::endl;;
+ std::cout << "Ancestor: " << ATTR(ancestor, "id") << std::endl;;
#endif
for (int j = 0; j < _configuration.size(); j++) {
@@ -1505,13 +1505,13 @@ void Interpreter::exitStates(const Arabica::XPath::NodeSet<std::string>& enabled
}
}
}
-
+
#if VERBOSE
- std::cout << "States to exit: ";
- for (int i = 0; i < statesToExit.size(); i++) {
- std::cout << LOCALNAME(statesToExit[i]) << ":" << ATTR(statesToExit[i], "id") << ", ";
- }
- std::cout << std::endl;
+ std::cout << "States to exit: ";
+ for (int i = 0; i < statesToExit.size(); i++) {
+ std::cout << LOCALNAME(statesToExit[i]) << ":" << ATTR(statesToExit[i], "id") << ", ";
+ }
+ std::cout << std::endl;
#endif
@@ -1528,11 +1528,11 @@ void Interpreter::exitStates(const Arabica::XPath::NodeSet<std::string>& enabled
statesToExit.to_document_order();
statesToExit.reverse();
- monIter = _monitors.begin();
- while(monIter != _monitors.end()) {
- (*monIter)->beforeExitingStates(this, statesToExit);
- monIter++;
- }
+ monIter = _monitors.begin();
+ while(monIter != _monitors.end()) {
+ (*monIter)->beforeExitingStates(this, statesToExit);
+ monIter++;
+ }
for (int i = 0; i < statesToExit.size(); i++) {
NodeSet<std::string> histories = filterChildElements(_xmlNSPrefix + "history", statesToExit[i]);
@@ -1540,7 +1540,7 @@ void Interpreter::exitStates(const Arabica::XPath::NodeSet<std::string>& enabled
Arabica::DOM::Element<std::string> historyElem = (Arabica::DOM::Element<std::string>)histories[j];
std::string historyType = (historyElem.hasAttribute("type") ? historyElem.getAttribute("type") : "shallow");
NodeSet<std::string> historyNodes;
- for (int k = 0; k < _configuration.size(); k++) {
+ for (int k = 0; k < _configuration.size(); k++) {
if (boost::iequals(historyType, "deep")) {
if (isAtomic(_configuration[k]) && isDescendant(_configuration[k], statesToExit[i]))
historyNodes.push_back(_configuration[k]);
@@ -1551,11 +1551,11 @@ void Interpreter::exitStates(const Arabica::XPath::NodeSet<std::string>& enabled
}
_historyValue[historyElem.getAttribute("id")] = historyNodes;
#if 0
- std::cout << "History node " << ATTR(historyElem, "id") << " contains: ";
- for (int i = 0; i < historyNodes.size(); i++) {
- std::cout << ATTR(historyNodes[i], "id") << ", ";
- }
- std::cout << std::endl;
+ std::cout << "History node " << ATTR(historyElem, "id") << " contains: ";
+ for (int i = 0; i < historyNodes.size(); i++) {
+ std::cout << ATTR(historyNodes[i], "id") << ", ";
+ }
+ std::cout << std::endl;
#endif
@@ -1585,11 +1585,11 @@ void Interpreter::exitStates(const Arabica::XPath::NodeSet<std::string>& enabled
_configuration = NodeSet<std::string>();
_configuration.insert(_configuration.end(), tmp.begin(), tmp.end());
- monIter = _monitors.begin();
- while(monIter != _monitors.end()) {
- (*monIter)->afterExitingStates(this);
- monIter++;
- }
+ monIter = _monitors.begin();
+ while(monIter != _monitors.end()) {
+ (*monIter)->afterExitingStates(this);
+ monIter++;
+ }
}
@@ -1597,14 +1597,14 @@ void Interpreter::exitStates(const Arabica::XPath::NodeSet<std::string>& enabled
void Interpreter::enterStates(const Arabica::XPath::NodeSet<std::string>& enabledTransitions) {
NodeSet<std::string> statesToEnter;
NodeSet<std::string> statesForDefaultEntry;
- std::set<InterpreterMonitor*>::iterator monIter;
+ std::set<InterpreterMonitor*>::iterator monIter;
#if VERBOSE
- std::cout << "Enabled enter transitions: " << std::endl;
+ std::cout << "Enabled enter transitions: " << std::endl;
for (int i = 0; i < enabledTransitions.size(); i++) {
- std::cout << enabledTransitions[i] << std::endl;
- }
- std::cout << std::endl;
+ std::cout << enabledTransitions[i] << std::endl;
+ }
+ std::cout << std::endl;
#endif
for (int i = 0; i < enabledTransitions.size(); i++) {
@@ -1614,17 +1614,17 @@ void Interpreter::enterStates(const Arabica::XPath::NodeSet<std::string>& enable
NodeSet<std::string> tStates = getTargetStates(transition);
#if VERBOSE
- std::cout << "Target States: ";
- for (int i = 0; i < tStates.size(); i++) {
- std::cout << ATTR(tStates[i], "id") << ", ";
- }
- std::cout << std::endl;
+ std::cout << "Target States: ";
+ for (int i = 0; i < tStates.size(); i++) {
+ std::cout << ATTR(tStates[i], "id") << ", ";
+ }
+ std::cout << std::endl;
#endif
Arabica::DOM::Node<std::string> ancestor;
Arabica::DOM::Node<std::string> source = getSourceState(transition);
#if VERBOSE
- std::cout << "Source States: " << ATTR(source, "id") << std::endl;
+ std::cout << "Source States: " << ATTR(source, "id") << std::endl;
#endif
assert(source);
@@ -1648,7 +1648,7 @@ void Interpreter::enterStates(const Arabica::XPath::NodeSet<std::string>& enable
}
#if VERBOSE
- std::cout << "Ancestor: " << ATTR(ancestor, "id") << std::endl;
+ std::cout << "Ancestor: " << ATTR(ancestor, "id") << std::endl;
#endif
for (int j = 0; j < tStates.size(); j++) {
@@ -1656,25 +1656,25 @@ void Interpreter::enterStates(const Arabica::XPath::NodeSet<std::string>& enable
}
#if VERBOSE
- std::cout << "States to enter: ";
- for (int i = 0; i < statesToEnter.size(); i++) {
- std::cout << LOCALNAME(statesToEnter[i]) << ":" << ATTR(statesToEnter[i], "id") << ", ";
- }
- std::cout << std::endl;
+ std::cout << "States to enter: ";
+ for (int i = 0; i < statesToEnter.size(); i++) {
+ std::cout << LOCALNAME(statesToEnter[i]) << ":" << ATTR(statesToEnter[i], "id") << ", ";
+ }
+ std::cout << std::endl;
#endif
-
+
for (int j = 0; j < tStates.size(); j++) {
NodeSet<std::string> ancestors = getProperAncestors(tStates[j], ancestor);
#if VERBOSE
- std::cout << "Proper Ancestors of " << ATTR(tStates[j], "id") << " and " << ATTR(ancestor, "id") << ": ";
- for (int i = 0; i < ancestors.size(); i++) {
- std::cout << ATTR(ancestors[i], "id") << ", ";
- }
- std::cout << std::endl;
+ std::cout << "Proper Ancestors of " << ATTR(tStates[j], "id") << " and " << ATTR(ancestor, "id") << ": ";
+ for (int i = 0; i < ancestors.size(); i++) {
+ std::cout << ATTR(ancestors[i], "id") << ", ";
+ }
+ std::cout << std::endl;
#endif
-
- for (int k = 0; k < ancestors.size(); k++) {
+
+ for (int k = 0; k < ancestors.size(); k++) {
statesToEnter.push_back(ancestors[k]);
if(isParallel(ancestors[k])) {
NodeSet<std::string> childs = getChildStates(ancestors[k]);
@@ -1696,12 +1696,12 @@ void Interpreter::enterStates(const Arabica::XPath::NodeSet<std::string>& enable
}
}
statesToEnter.to_document_order();
-
- monIter = _monitors.begin();
- while(monIter != _monitors.end()) {
- (*monIter)->beforeEnteringStates(this, statesToEnter);
- monIter++;
- }
+
+ monIter = _monitors.begin();
+ while(monIter != _monitors.end()) {
+ (*monIter)->beforeEnteringStates(this, statesToEnter);
+ monIter++;
+ }
for (int i = 0; i < statesToEnter.size(); i++) {
Arabica::DOM::Element<std::string> stateElem = (Arabica::DOM::Element<std::string>)statesToEnter[i];
@@ -1719,7 +1719,7 @@ void Interpreter::enterStates(const Arabica::XPath::NodeSet<std::string>& enable
}
// execute onentry executable content
NodeSet<std::string> onEntryElems = filterChildElements(_xmlNSPrefix + "onEntry", stateElem);
- executeContent(onEntryElems);
+ executeContent(onEntryElems);
if (isMember(stateElem, statesForDefaultEntry)) {
// execute initial transition content for compund states
@@ -1757,89 +1757,89 @@ void Interpreter::enterStates(const Arabica::XPath::NodeSet<std::string>& enable
_done = true;
}
}
-
- monIter = _monitors.begin();
- while(monIter != _monitors.end()) {
- (*monIter)->afterEnteringStates(this);
- monIter++;
- }
+
+ monIter = _monitors.begin();
+ while(monIter != _monitors.end()) {
+ (*monIter)->afterEnteringStates(this);
+ monIter++;
+ }
}
-
+
void Interpreter::addStatesToEnter(const Arabica::DOM::Node<std::string>& state,
Arabica::XPath::NodeSet<std::string>& statesToEnter,
Arabica::XPath::NodeSet<std::string>& statesForDefaultEntry) {
- std::string stateId = ((Arabica::DOM::Element<std::string>)state).getAttribute("id");
-
+ std::string stateId = ((Arabica::DOM::Element<std::string>)state).getAttribute("id");
+
#if VERBOSE
- std::cout << "Adding state to enter: " << stateId << std::endl;
+ std::cout << "Adding state to enter: " << stateId << std::endl;
#endif
- if (isHistory(state)) {
- if (_historyValue.find(stateId) != _historyValue.end()) {
- Arabica::XPath::NodeSet<std::string> historyValue = _historyValue[stateId];
-
+ if (isHistory(state)) {
+ if (_historyValue.find(stateId) != _historyValue.end()) {
+ Arabica::XPath::NodeSet<std::string> historyValue = _historyValue[stateId];
+
#if VERBOSE
- std::cout << "History State " << ATTR(state, "id") << ": ";
- for (int i = 0; i < historyValue.size(); i++) {
- std::cout << ATTR(historyValue[i], "id") << ", ";
- }
- std::cout << std::endl;
+ std::cout << "History State " << ATTR(state, "id") << ": ";
+ for (int i = 0; i < historyValue.size(); i++) {
+ std::cout << ATTR(historyValue[i], "id") << ", ";
+ }
+ std::cout << std::endl;
#endif
-
- for (int i = 0; i < historyValue.size(); i++) {
- addStatesToEnter(historyValue[i], statesToEnter, statesForDefaultEntry);
- NodeSet<std::string> ancestors = getProperAncestors(historyValue[i], state);
-
+
+ for (int i = 0; i < historyValue.size(); i++) {
+ addStatesToEnter(historyValue[i], statesToEnter, statesForDefaultEntry);
+ NodeSet<std::string> ancestors = getProperAncestors(historyValue[i], state);
+
#if VERBOSE
- std::cout << "Proper Ancestors: ";
- for (int i = 0; i < ancestors.size(); i++) {
- std::cout << ATTR(ancestors[i], "id") << ", ";
- }
- std::cout << std::endl;
+ std::cout << "Proper Ancestors: ";
+ for (int i = 0; i < ancestors.size(); i++) {
+ std::cout << ATTR(ancestors[i], "id") << ", ";
+ }
+ std::cout << std::endl;
#endif
-
- for (int j = 0; j < ancestors.size(); j++) {
- statesToEnter.push_back(ancestors[j]);
- }
- }
- } else {
- NodeSet<std::string> transitions = filterChildElements(_xmlNSPrefix + "transition", state);
- for (int i = 0; i < transitions.size(); i++) {
- NodeSet<std::string> targets = getTargetStates(transitions[i]);
- for (int j = 0; j < targets.size(); j++) {
- addStatesToEnter(targets[j], statesToEnter, statesForDefaultEntry);
-
- // Modifications from chris nuernberger
- NodeSet<std::string> ancestors = getProperAncestors(targets[j], state);
- for (int k = 0; k < ancestors.size(); k++) {
- statesToEnter.push_back(ancestors[k]);
- }
- }
- }
- }
- } else {
- statesToEnter.push_back(state);
- if (isCompound(state)) {
- statesForDefaultEntry.push_back(state);
-
- addStatesToEnter(getInitialState(state), statesToEnter, statesForDefaultEntry);
-
+
+ for (int j = 0; j < ancestors.size(); j++) {
+ statesToEnter.push_back(ancestors[j]);
+ }
+ }
+ } else {
+ NodeSet<std::string> transitions = filterChildElements(_xmlNSPrefix + "transition", state);
+ for (int i = 0; i < transitions.size(); i++) {
+ NodeSet<std::string> targets = getTargetStates(transitions[i]);
+ for (int j = 0; j < targets.size(); j++) {
+ addStatesToEnter(targets[j], statesToEnter, statesForDefaultEntry);
+
+ // Modifications from chris nuernberger
+ NodeSet<std::string> ancestors = getProperAncestors(targets[j], state);
+ for (int k = 0; k < ancestors.size(); k++) {
+ statesToEnter.push_back(ancestors[k]);
+ }
+ }
+ }
+ }
+ } else {
+ statesToEnter.push_back(state);
+ if (isCompound(state)) {
+ statesForDefaultEntry.push_back(state);
+
+ addStatesToEnter(getInitialState(state), statesToEnter, statesForDefaultEntry);
+
# if 0
- NodeSet<std::string> tStates = getTargetStates(getInitialState(state));
- for (int i = 0; i < tStates.size(); i++) {
- addStatesToEnter(tStates[i], statesToEnter, statesForDefaultEntry);
- }
+ NodeSet<std::string> tStates = getTargetStates(getInitialState(state));
+ for (int i = 0; i < tStates.size(); i++) {
+ addStatesToEnter(tStates[i], statesToEnter, statesForDefaultEntry);
+ }
# endif
- // addStatesToEnter(getInitialState(state), statesToEnter, statesForDefaultEntry);
- // NodeSet<std::string> tStates = getTargetStates(getInitialState(state));
-
- } else if(isParallel(state)) {
- NodeSet<std::string> childStates = getChildStates(state);
- for (int i = 0; i < childStates.size(); i++) {
- addStatesToEnter(childStates[i], statesToEnter, statesForDefaultEntry);
- }
- }
- }
+ // addStatesToEnter(getInitialState(state), statesToEnter, statesForDefaultEntry);
+ // NodeSet<std::string> tStates = getTargetStates(getInitialState(state));
+
+ } else if(isParallel(state)) {
+ NodeSet<std::string> childStates = getChildStates(state);
+ for (int i = 0; i < childStates.size(); i++) {
+ addStatesToEnter(childStates[i], statesToEnter, statesForDefaultEntry);
+ }
+ }
+ }
}
#endif
@@ -1847,16 +1847,16 @@ void Interpreter::addStatesToEnter(const Arabica::DOM::Node<std::string>& state,
void Interpreter::enterStates(const Arabica::XPath::NodeSet<std::string>& enabledTransitions) {
NodeSet<std::string> statesToEnter;
NodeSet<std::string> statesForDefaultEntry;
- std::set<InterpreterMonitor*>::iterator monIter;
-
- computeEntrySet(enabledTransitions, statesToEnter, statesForDefaultEntry);
- statesToEnter.sort(); // entry order is document order
- for (int i = 0; i < statesToEnter.size(); i++) {
- Arabica::DOM::Element<std::string> s = (Arabica::DOM::Element<std::string>)statesToEnter[i];
- _configuration.push_back(s);
- _statesToInvoke.push_back(s);
-
- if (_binding == LATE && ATTR(s, "isFirstEntry").size() > 0) {
+ std::set<InterpreterMonitor*>::iterator monIter;
+
+ computeEntrySet(enabledTransitions, statesToEnter, statesForDefaultEntry);
+ statesToEnter.sort(); // entry order is document order
+ for (int i = 0; i < statesToEnter.size(); i++) {
+ Arabica::DOM::Element<std::string> s = (Arabica::DOM::Element<std::string>)statesToEnter[i];
+ _configuration.push_back(s);
+ _statesToInvoke.push_back(s);
+
+ if (_binding == LATE && ATTR(s, "isFirstEntry").size() > 0) {
NodeSet<std::string> dataModelElems = filterChildElements(_xmlNSPrefix + "datamodel", s);
if(dataModelElems.size() > 0 && _dataModel) {
Arabica::XPath::NodeSet<std::string> dataElems = filterChildElements(_xmlNSPrefix + "data", dataModelElems[0]);
@@ -1866,146 +1866,146 @@ void Interpreter::enterStates(const Arabica::XPath::NodeSet<std::string>& enable
}
s.setAttribute("isFirstEntry", "");
}
- executeContent(filterChildElements(_xmlNSPrefix + "onEntry", s));
- if (isMember(s, statesForDefaultEntry)) {
- executeContent(getInitialState(s)); // TODO: This part is unclear
- }
-
+ executeContent(filterChildElements(_xmlNSPrefix + "onEntry", s));
+ if (isMember(s, statesForDefaultEntry)) {
+ executeContent(getInitialState(s)); // TODO: This part is unclear
+ }
+
#if VERBOSE
- std::cout << "Is state " << ATTR(s, "id") << " final?";
+ std::cout << "Is state " << ATTR(s, "id") << " final?";
#endif
- if (isFinal(s)) {
- if (parentIsScxmlState(s)) {
- _running = false;
- _done = true;
- } else {
- Arabica::DOM::Element<std::string> parent = (Arabica::DOM::Element<std::string>)s.getParentNode();
- Arabica::DOM::Element<std::string> grandParent = (Arabica::DOM::Element<std::string>)parent.getParentNode();
- internalDoneSend(parent);
-
- if (isParallel(grandParent)) {
- Arabica::XPath::NodeSet<std::string> childs = getChildStates(grandParent);
- bool inFinalState = true;
- for (int j = 0; j < childs.size(); j++) {
- if (!isInFinalState(childs[j])) {
- inFinalState = false;
- break;
- }
- }
- if (inFinalState) {
- internalDoneSend(grandParent);
- }
- }
- }
- }
- }
+ if (isFinal(s)) {
+ if (parentIsScxmlState(s)) {
+ _running = false;
+ _done = true;
+ } else {
+ Arabica::DOM::Element<std::string> parent = (Arabica::DOM::Element<std::string>)s.getParentNode();
+ Arabica::DOM::Element<std::string> grandParent = (Arabica::DOM::Element<std::string>)parent.getParentNode();
+ internalDoneSend(parent);
+
+ if (isParallel(grandParent)) {
+ Arabica::XPath::NodeSet<std::string> childs = getChildStates(grandParent);
+ bool inFinalState = true;
+ for (int j = 0; j < childs.size(); j++) {
+ if (!isInFinalState(childs[j])) {
+ inFinalState = false;
+ break;
+ }
+ }
+ if (inFinalState) {
+ internalDoneSend(grandParent);
+ }
+ }
+ }
+ }
+ }
}
void Interpreter::computeEntrySet(const Arabica::XPath::NodeSet<std::string>& transitions,
Arabica::XPath::NodeSet<std::string>& statesToEnter,
Arabica::XPath::NodeSet<std::string>& statesForDefaultEntry) {
- for (int i = 0; i < transitions.size(); i++) {
- NodeSet<std::string> targets = getTargetStates(transitions[i]);
- for (int j = 0; j < targets.size(); j++) {
- statesToEnter.push_back(targets[i]);
- }
- }
- for (int i = 0; i < transitions.size(); i++) {
- Arabica::DOM::Node<std::string> ancestor = getTransitionDomain(transitions[i]);
- NodeSet<std::string> targets = getTargetStates(transitions[i]);
- for (int j = 0; j < targets.size(); j++) {
- addAncestorStatesToEnter(targets[j], ancestor, statesToEnter, statesForDefaultEntry);
- }
- }
+ for (int i = 0; i < transitions.size(); i++) {
+ NodeSet<std::string> targets = getTargetStates(transitions[i]);
+ for (int j = 0; j < targets.size(); j++) {
+ statesToEnter.push_back(targets[i]);
+ }
+ }
+ for (int i = 0; i < transitions.size(); i++) {
+ Arabica::DOM::Node<std::string> ancestor = getTransitionDomain(transitions[i]);
+ NodeSet<std::string> targets = getTargetStates(transitions[i]);
+ for (int j = 0; j < targets.size(); j++) {
+ addAncestorStatesToEnter(targets[j], ancestor, statesToEnter, statesForDefaultEntry);
+ }
+ }
}
void Interpreter::addDescendentStatesToEnter(const Arabica::DOM::Node<std::string>& state,
- Arabica::XPath::NodeSet<std::string>& statesToEnter,
- Arabica::XPath::NodeSet<std::string>& statesForDefaultEntry) {
- if (isHistory(state)) {
- if (_historyValue.find(ATTR(state, "id")) != _historyValue.end()) {
- Arabica::XPath::NodeSet<std::string> history = _historyValue[ATTR(state, "id")];
- for (int i = 0; i < history.size(); i++) {
- addDescendentStatesToEnter(history[i], statesToEnter, statesForDefaultEntry);
- addAncestorStatesToEnter(history[i], state.getParentNode(), statesToEnter, statesForDefaultEntry);
- }
- } else {
- NodeSet<std::string> transitions = filterChildElements(_xmlNSPrefix + "transition", state);
- for (int i = 0; i < transitions.size(); i++) {
- NodeSet<std::string> targets = getTargetStates(transitions[i]);
- for (int j = 0; j < targets.size(); j++) {
- addDescendentStatesToEnter(targets[j],statesToEnter,statesForDefaultEntry);
- addAncestorStatesToEnter(targets[j], state.getParentNode(), statesToEnter, statesForDefaultEntry);
- }
- }
- }
- } else {
- statesToEnter.push_back(state);
- if (isCompound(state)) {
- statesForDefaultEntry.push_back(state);
- Node<std::string> initial = getInitialState(state);
- addDescendentStatesToEnter(initial, statesToEnter, statesForDefaultEntry);
- addAncestorStatesToEnter(initial, state.getParentNode(), statesToEnter, statesForDefaultEntry);
- } else if (isParallel(state)) {
- NodeSet<std::string> childs = getChildStates(state);
- for (int i = 0; i < childs.size(); i++) {
- bool someAreDescendants = false;
- for (int j = 0; i < statesToEnter.size(); j++) {
- if (isDescendant(statesToEnter[j], childs[i]))
- someAreDescendants = true;
- }
- if (!someAreDescendants) {
- addDescendentStatesToEnter(childs[i], statesToEnter, statesForDefaultEntry);
- }
- }
- }
- }
-}
-
+ Arabica::XPath::NodeSet<std::string>& statesToEnter,
+ Arabica::XPath::NodeSet<std::string>& statesForDefaultEntry) {
+ if (isHistory(state)) {
+ if (_historyValue.find(ATTR(state, "id")) != _historyValue.end()) {
+ Arabica::XPath::NodeSet<std::string> history = _historyValue[ATTR(state, "id")];
+ for (int i = 0; i < history.size(); i++) {
+ addDescendentStatesToEnter(history[i], statesToEnter, statesForDefaultEntry);
+ addAncestorStatesToEnter(history[i], state.getParentNode(), statesToEnter, statesForDefaultEntry);
+ }
+ } else {
+ NodeSet<std::string> transitions = filterChildElements(_xmlNSPrefix + "transition", state);
+ for (int i = 0; i < transitions.size(); i++) {
+ NodeSet<std::string> targets = getTargetStates(transitions[i]);
+ for (int j = 0; j < targets.size(); j++) {
+ addDescendentStatesToEnter(targets[j],statesToEnter,statesForDefaultEntry);
+ addAncestorStatesToEnter(targets[j], state.getParentNode(), statesToEnter, statesForDefaultEntry);
+ }
+ }
+ }
+ } else {
+ statesToEnter.push_back(state);
+ if (isCompound(state)) {
+ statesForDefaultEntry.push_back(state);
+ Node<std::string> initial = getInitialState(state);
+ addDescendentStatesToEnter(initial, statesToEnter, statesForDefaultEntry);
+ addAncestorStatesToEnter(initial, state.getParentNode(), statesToEnter, statesForDefaultEntry);
+ } else if (isParallel(state)) {
+ NodeSet<std::string> childs = getChildStates(state);
+ for (int i = 0; i < childs.size(); i++) {
+ bool someAreDescendants = false;
+ for (int j = 0; i < statesToEnter.size(); j++) {
+ if (isDescendant(statesToEnter[j], childs[i]))
+ someAreDescendants = true;
+ }
+ if (!someAreDescendants) {
+ addDescendentStatesToEnter(childs[i], statesToEnter, statesForDefaultEntry);
+ }
+ }
+ }
+ }
+}
+
void Interpreter::addAncestorStatesToEnter(const Arabica::DOM::Node<std::string>& state,
- const Arabica::DOM::Node<std::string>& ancestor,
- Arabica::XPath::NodeSet<std::string>& statesToEnter,
- Arabica::XPath::NodeSet<std::string>& statesForDefaultEntry) {
- NodeSet<std::string> properAncs = getProperAncestors(state, ancestor);
- for (int k = 0; k < properAncs.size(); k++) {
- statesToEnter.push_back(properAncs[k]);
- if (isParallel(properAncs[k])) {
- NodeSet<std::string> childs = getChildStates(properAncs[k]);
- for (int i = 0; i < childs.size(); i++) {
- bool someAreDescendants = false;
- for (int j = 0; i < statesToEnter.size(); j++) {
- if (isDescendant(statesToEnter[j], childs[i]))
- someAreDescendants = true;
- }
- if (!someAreDescendants) {
- addDescendentStatesToEnter(childs[i], statesToEnter, statesForDefaultEntry);
- }
- }
- }
- }
+ const Arabica::DOM::Node<std::string>& ancestor,
+ Arabica::XPath::NodeSet<std::string>& statesToEnter,
+ Arabica::XPath::NodeSet<std::string>& statesForDefaultEntry) {
+ NodeSet<std::string> properAncs = getProperAncestors(state, ancestor);
+ for (int k = 0; k < properAncs.size(); k++) {
+ statesToEnter.push_back(properAncs[k]);
+ if (isParallel(properAncs[k])) {
+ NodeSet<std::string> childs = getChildStates(properAncs[k]);
+ for (int i = 0; i < childs.size(); i++) {
+ bool someAreDescendants = false;
+ for (int j = 0; i < statesToEnter.size(); j++) {
+ if (isDescendant(statesToEnter[j], childs[i]))
+ someAreDescendants = true;
+ }
+ if (!someAreDescendants) {
+ addDescendentStatesToEnter(childs[i], statesToEnter, statesForDefaultEntry);
+ }
+ }
+ }
+ }
}
Arabica::DOM::Node<std::string> Interpreter::getTransitionDomain(const Arabica::DOM::Node<std::string>& transition) {
- Arabica::DOM::Node<std::string> source = getSourceState(transition);
- if (isTargetless(transition)) {
- return source;
- }
-
- Arabica::XPath::NodeSet<std::string> targets = getTargetStates(transition);
- if (boost::iequals(ATTR(transition, "type"), "internal") && isCompound(source)) {
- bool allDescendants = true;
- for (int i = 0; i < targets.size(); i++) {
- if (!isDescendant(targets[i], source)) {
- allDescendants = false;
- break;
- }
- }
- if (allDescendants)
- return source;
- }
-
- targets.push_back(source);
- return findLCCA(targets);
-}
-
+ Arabica::DOM::Node<std::string> source = getSourceState(transition);
+ if (isTargetless(transition)) {
+ return source;
+ }
+
+ Arabica::XPath::NodeSet<std::string> targets = getTargetStates(transition);
+ if (boost::iequals(ATTR(transition, "type"), "internal") && isCompound(source)) {
+ bool allDescendants = true;
+ for (int i = 0; i < targets.size(); i++) {
+ if (!isDescendant(targets[i], source)) {
+ allDescendants = false;
+ break;
+ }
+ }
+ if (allDescendants)
+ return source;
+ }
+
+ targets.push_back(source);
+ return findLCCA(targets);
+}
+
#endif
bool Interpreter::parentIsScxmlState(Arabica::DOM::Node<std::string> state) {
@@ -2056,30 +2056,30 @@ Arabica::XPath::NodeSet<std::string> Interpreter::getChildStates(const Arabica::
/**
See: http://www.w3.org/TR/scxml/#LCCA
- The Least Common Compound Ancestor is the <state> or <scxml> element s such that s is a proper ancestor
- of all states on stateList and no descendant of s has this property. Note that there is guaranteed to be
- such an element since the <scxml> wrapper element is a common ancestor of all states. Note also that since
+ The Least Common Compound Ancestor is the <state> or <scxml> element s such that s is a proper ancestor
+ of all states on stateList and no descendant of s has this property. Note that there is guaranteed to be
+ such an element since the <scxml> wrapper element is a common ancestor of all states. Note also that since
we are speaking of proper ancestor (parent or parent of a parent, etc.) the LCCA is never a member of stateList.
*/
-
+
Arabica::DOM::Node<std::string> Interpreter::findLCCA(const Arabica::XPath::NodeSet<std::string>& states) {
#if 0
- std::cout << "findLCCA: ";
- for (int i = 0; i < states.size(); i++) {
- std::cout << ATTR(states[i], "id") << " - " << TAGNAME(states[i]) << ", ";
- }
- std::cout << std::endl << std::flush;
+ std::cout << "findLCCA: ";
+ for (int i = 0; i < states.size(); i++) {
+ std::cout << ATTR(states[i], "id") << " - " << TAGNAME(states[i]) << ", ";
+ }
+ std::cout << std::endl << std::flush;
#endif
-
+
Arabica::XPath::NodeSet<std::string> ancestors = getProperAncestors(states[0], Arabica::DOM::Node<std::string>());
// ancestors.push_back(states[0]); // state[0] may already be the ancestor - bug in W3C spec?
Arabica::DOM::Node<std::string> ancestor;
for (int i = 0; i < ancestors.size(); i++) {
- if (!isCompound(ancestors[i]))
- continue;
+ if (!isCompound(ancestors[i]))
+ continue;
for (int j = 0; j < states.size(); j++) {
#if 0
- std::cout << "Checking " << TAGNAME(states[j]) << " and " << TAGNAME(ancestors[i]) << std::endl;
+ std::cout << "Checking " << TAGNAME(states[j]) << " and " << TAGNAME(ancestors[i]) << std::endl;
#endif
if (!isDescendant(states[j], ancestors[i]) && (states[j] != ancestors[i]))
goto NEXT_ANCESTOR;
@@ -2089,13 +2089,13 @@ Arabica::DOM::Node<std::string> Interpreter::findLCCA(const Arabica::XPath::Node
NEXT_ANCESTOR:
;
}
-
- // take uppermost root as ancestor
- if (!ancestor)
- ancestor = _scxml;
+
+ // take uppermost root as ancestor
+ if (!ancestor)
+ ancestor = _scxml;
assert(ancestor);
#if 0
- std::cout << " -> " << ATTR(ancestor, "id") << " " << ancestor.getLocalName() << std::endl;
+ std::cout << " -> " << ATTR(ancestor, "id") << " " << ancestor.getLocalName() << std::endl;
#endif
return ancestor;
}
@@ -2121,13 +2121,13 @@ Arabica::DOM::Node<std::string> Interpreter::getState(const std::string& stateId
if (target.size() > 0)
goto FOUND;
- // now history states
+ // now history states
target = _xpath.evaluate("//" + _xpathPrefix + "history[@id='" + stateId + "']", _document).asNodeSet();
if (target.size() > 0)
goto FOUND;
- LOG(ERROR) << "No state with id " << stateId << " found!";
-
+ LOG(ERROR) << "No state with id " << stateId << " found!";
+
FOUND:
if (target.size() > 0) {
assert(target.size() == 1);
@@ -2159,7 +2159,7 @@ Arabica::DOM::Node<std::string> Interpreter::getInitialState(Arabica::DOM::Node<
}
#if VERBOSE
- std::cout << "Getting initial state of " << TAGNAME(state) << " " << ATTR(state, "id") << std::endl;
+ std::cout << "Getting initial state of " << TAGNAME(state) << " " << ATTR(state, "id") << std::endl;
#endif
assert(isCompound(state) || isParallel(state));
@@ -2188,8 +2188,8 @@ Arabica::DOM::Node<std::string> Interpreter::getInitialState(Arabica::DOM::Node<
NodeSet<std::string> Interpreter::getTargetStates(const Arabica::DOM::Node<std::string>& transition) {
NodeSet<std::string> targetStates;
- assert(boost::iequals(LOCALNAME(transition), "transition"));
-
+ assert(boost::iequals(LOCALNAME(transition), "transition"));
+
// if we are called with a state, process all its transitions
if (isState(transition) || (transition.getNodeType() == Node_base::ELEMENT_NODE && boost::iequals(_xmlNSPrefix + "initial", TAGNAME(transition)))) {
NodeList<std::string> childs = transition.getChildNodes();
@@ -2288,7 +2288,7 @@ bool Interpreter::isTargetless(const Arabica::DOM::Node<std::string>& transition
bool Interpreter::isWithinSameChild(const Arabica::DOM::Node<std::string>& transition) {
if (!isTargetless(transition)) {
std::string target = ((Arabica::DOM::Element<std::string>)transition).getAttribute("target");
- assert(transition.getParentNode());
+ assert(transition.getParentNode());
// @todo: do we need to look at parallel as well?
if (_xpath.evaluate("" + _xpathPrefix + "state[id=\"" + target + "\"]", transition.getParentNode()).asNodeSet().size() > 0)
return true;
@@ -2431,118 +2431,118 @@ IOProcessor Interpreter::getIOProcessor(const std::string& type) {
}
void Interpreter::setCmdLineOptions(int argc, char** argv) {
- char* key = NULL;
- char* value = NULL;
- for (int i = 0; i < argc; i++) {
- if (false) {
- } else if (strlen(argv[i]) > 2 && strncmp(&argv[i][0], "-", 1) == 0 && strncmp(&argv[i][1], "-", 1) == 0) {
- // longopt
- key = &argv[i][2];
- } else if (strlen(argv[i]) > 1 && strncmp(&argv[i][0], "-", 1) == 0 && strncmp(&argv[i][1], "-", 1) != 0) {
- // shortopt
- key = &argv[i][1];
- }
- if (key != NULL) {
- if (i + 1 < argc && strncmp(&argv[i + 1][0], "-", 1) != 0) {
- value = argv[++i];
- _cmdLineOptions.compound[key] = Data(value, Data::VERBATIM);
- } else {
- _cmdLineOptions.compound[key] = Data("true");
- }
- }
- }
+ char* key = NULL;
+ char* value = NULL;
+ for (int i = 0; i < argc; i++) {
+ if (false) {
+ } else if (strlen(argv[i]) > 2 && strncmp(&argv[i][0], "-", 1) == 0 && strncmp(&argv[i][1], "-", 1) == 0) {
+ // longopt
+ key = &argv[i][2];
+ } else if (strlen(argv[i]) > 1 && strncmp(&argv[i][0], "-", 1) == 0 && strncmp(&argv[i][1], "-", 1) != 0) {
+ // shortopt
+ key = &argv[i][1];
+ }
+ if (key != NULL) {
+ if (i + 1 < argc && strncmp(&argv[i + 1][0], "-", 1) != 0) {
+ value = argv[++i];
+ _cmdLineOptions.compound[key] = Data(value, Data::VERBATIM);
+ } else {
+ _cmdLineOptions.compound[key] = Data("true");
+ }
+ }
+ }
}
/**
* See: http://www.w3.org/TR/scxml/#LegalStateConfigurations
*/
bool Interpreter::hasLegalConfiguration() {
-
+
#if 0
- std::cout << "Checking whether {";
- std::string seperator;
- for (int i = 0; i < _configuration.size(); i++) {
- std::cout << seperator << ATTR(_configuration[i], "id");
- seperator = ", ";
- }
- std::cout << "} is legal" << std::endl;
+ std::cout << "Checking whether {";
+ std::string seperator;
+ for (int i = 0; i < _configuration.size(); i++) {
+ std::cout << seperator << ATTR(_configuration[i], "id");
+ seperator = ", ";
+ }
+ std::cout << "} is legal" << std::endl;
#endif
-
- // The configuration contains exactly one child of the <scxml> element.
- NodeSet<std::string> scxmlChilds = getChildStates(_scxml);
- bool foundScxmlChild = false;
- for (int i = 0; i < scxmlChilds.size(); i++) {
- if (isMember(scxmlChilds[i], _configuration)) {
- if (foundScxmlChild)
- return false;
- foundScxmlChild = true;
- }
- }
- if (!foundScxmlChild)
- return false;
-
- // The configuration contains one or more atomic states.
- bool foundAtomicState = false;
- for (int i = 0; i < _configuration.size(); i++) {
- if (isAtomic(_configuration[i])) {
- foundAtomicState = true;
- break;
- }
- }
- if (!foundAtomicState)
- return false;
-
- // When the configuration contains an atomic state, it contains all of its <state> and <parallel> ancestors.
- for (int i = 0; i < _configuration.size(); i++) {
- if (isAtomic(_configuration[i])) {
- Node<std::string> parent = _configuration[i];
- while((parent = parent.getParentNode())) {
- if (isState(parent) &&
- (boost::iequals(LOCALNAME(parent), "state") ||
- boost::iequals(LOCALNAME(parent), "parallel"))) {
- if (!isMember(parent, _configuration))
- return false;
- }
- }
- }
- }
-
- // When the configuration contains a non-atomic <state>, it contains one and only one of the state's children
- for (int i = 0; i < _configuration.size(); i++) {
- if (!isAtomic(_configuration[i]) && !isParallel(_configuration[i])) {
- bool foundChildState = false;
- NodeSet<std::string> childs = getChildStates(_configuration[i]);
- for (int j = 0; j < childs.size(); j++) {
- if (isMember(childs[j], _configuration)) {
- if (foundChildState)
- return false;
- foundChildState = true;
- }
- }
- if (!foundChildState)
- return false;
- }
- }
-
- // If the configuration contains a <parallel> state, it contains all of its children
- for (int i = 0; i < _configuration.size(); i++) {
- if (isParallel(_configuration[i])) {
- NodeSet<std::string> childs = getChildStates(_configuration[i]);
- for (int j = 0; j < childs.size(); j++) {
- if (!isMember(childs[j], _configuration) && !isHistory(childs[j]))
- return false;
- }
- }
- }
-
- // everything worked out fine!
- return true;
-}
-
+
+ // The configuration contains exactly one child of the <scxml> element.
+ NodeSet<std::string> scxmlChilds = getChildStates(_scxml);
+ bool foundScxmlChild = false;
+ for (int i = 0; i < scxmlChilds.size(); i++) {
+ if (isMember(scxmlChilds[i], _configuration)) {
+ if (foundScxmlChild)
+ return false;
+ foundScxmlChild = true;
+ }
+ }
+ if (!foundScxmlChild)
+ return false;
+
+ // The configuration contains one or more atomic states.
+ bool foundAtomicState = false;
+ for (int i = 0; i < _configuration.size(); i++) {
+ if (isAtomic(_configuration[i])) {
+ foundAtomicState = true;
+ break;
+ }
+ }
+ if (!foundAtomicState)
+ return false;
+
+ // When the configuration contains an atomic state, it contains all of its <state> and <parallel> ancestors.
+ for (int i = 0; i < _configuration.size(); i++) {
+ if (isAtomic(_configuration[i])) {
+ Node<std::string> parent = _configuration[i];
+ while((parent = parent.getParentNode())) {
+ if (isState(parent) &&
+ (boost::iequals(LOCALNAME(parent), "state") ||
+ boost::iequals(LOCALNAME(parent), "parallel"))) {
+ if (!isMember(parent, _configuration))
+ return false;
+ }
+ }
+ }
+ }
+
+ // When the configuration contains a non-atomic <state>, it contains one and only one of the state's children
+ for (int i = 0; i < _configuration.size(); i++) {
+ if (!isAtomic(_configuration[i]) && !isParallel(_configuration[i])) {
+ bool foundChildState = false;
+ NodeSet<std::string> childs = getChildStates(_configuration[i]);
+ for (int j = 0; j < childs.size(); j++) {
+ if (isMember(childs[j], _configuration)) {
+ if (foundChildState)
+ return false;
+ foundChildState = true;
+ }
+ }
+ if (!foundChildState)
+ return false;
+ }
+ }
+
+ // If the configuration contains a <parallel> state, it contains all of its children
+ for (int i = 0; i < _configuration.size(); i++) {
+ if (isParallel(_configuration[i])) {
+ NodeSet<std::string> childs = getChildStates(_configuration[i]);
+ for (int j = 0; j < childs.size(); j++) {
+ if (!isMember(childs[j], _configuration) && !isHistory(childs[j]))
+ return false;
+ }
+ }
+ }
+
+ // everything worked out fine!
+ return true;
+}
+
void Interpreter::dump() {
if (!_document)
return;
- std::cout << _document;
+ std::cout << _document;
}
diff --git a/src/uscxml/Interpreter.h b/src/uscxml/Interpreter.h
index 9ec4eb1..48e08b4 100644
--- a/src/uscxml/Interpreter.h
+++ b/src/uscxml/Interpreter.h
@@ -29,21 +29,21 @@
namespace uscxml {
class HTTPServletInvoker;
-
+
class InterpreterMonitor {
public:
- virtual ~InterpreterMonitor() {}
- virtual void onStableConfiguration(Interpreter* interpreter) {}
- virtual void beforeCompletion(Interpreter* interpreter) {}
- virtual void afterCompletion(Interpreter* interpreter) {}
- virtual void beforeMicroStep(Interpreter* interpreter) {}
- virtual void beforeTakingTransitions(Interpreter* interpreter, const Arabica::XPath::NodeSet<std::string>& transitions) {}
- virtual void beforeEnteringStates(Interpreter* interpreter, const Arabica::XPath::NodeSet<std::string>& statesToEnter) {}
- virtual void afterEnteringStates(Interpreter* interpreter) {}
- virtual void beforeExitingStates(Interpreter* interpreter, const Arabica::XPath::NodeSet<std::string>& statesToExit) {}
- virtual void afterExitingStates(Interpreter* interpreter) {}
+ virtual ~InterpreterMonitor() {}
+ virtual void onStableConfiguration(Interpreter* interpreter) {}
+ virtual void beforeCompletion(Interpreter* interpreter) {}
+ virtual void afterCompletion(Interpreter* interpreter) {}
+ virtual void beforeMicroStep(Interpreter* interpreter) {}
+ virtual void beforeTakingTransitions(Interpreter* interpreter, const Arabica::XPath::NodeSet<std::string>& transitions) {}
+ virtual void beforeEnteringStates(Interpreter* interpreter, const Arabica::XPath::NodeSet<std::string>& statesToEnter) {}
+ virtual void afterEnteringStates(Interpreter* interpreter) {}
+ virtual void beforeExitingStates(Interpreter* interpreter, const Arabica::XPath::NodeSet<std::string>& statesToExit) {}
+ virtual void afterExitingStates(Interpreter* interpreter) {}
};
-
+
class NumAttr {
public:
NumAttr(const std::string& str) {
@@ -93,13 +93,13 @@ public:
void interpret();
- void addMonitor(InterpreterMonitor* monitor) {
- _monitors.insert(monitor);
- }
+ void addMonitor(InterpreterMonitor* monitor) {
+ _monitors.insert(monitor);
+ }
- void removeMonitor(InterpreterMonitor* monitor) {
- _monitors.erase(monitor);
- }
+ void removeMonitor(InterpreterMonitor* monitor) {
+ _monitors.erase(monitor);
+ }
void setBaseURI(std::string baseURI) {
_baseURI = URL(baseURI);
@@ -109,9 +109,11 @@ public:
}
bool toAbsoluteURI(URL& uri);
- void setCmdLineOptions(int argc, char** argv);
- Data getCmdLineOptions() { return _cmdLineOptions; }
-
+ void setCmdLineOptions(int argc, char** argv);
+ Data getCmdLineOptions() {
+ return _cmdLineOptions;
+ }
+
DataModel getDataModel() {
return _dataModel;
}
@@ -142,7 +144,7 @@ public:
return _document;
}
- void setName(const std::string& name);
+ void setName(const std::string& name);
const std::string& getName() {
return _name;
}
@@ -150,15 +152,17 @@ public:
return _sessionId;
}
- HTTPServletInvoker* getHTTPServlet() { return _httpServlet; }
-
+ HTTPServletInvoker* getHTTPServlet() {
+ return _httpServlet;
+ }
+
bool runOnMainThread(int fps, bool blocking = true);
static bool isMember(const Arabica::DOM::Node<std::string>& node, const Arabica::XPath::NodeSet<std::string>& set);
void dump();
- bool hasLegalConfiguration();
-
+ bool hasLegalConfiguration();
+
static bool isState(const Arabica::DOM::Node<std::string>& state);
static bool isPseudoState(const Arabica::DOM::Node<std::string>& state);
static bool isTransitionTarget(const Arabica::DOM::Node<std::string>& elem);
@@ -215,10 +219,10 @@ protected:
uscxml::concurrency::BlockingQueue<Event>* _parentQueue;
DelayedEventQueue* _sendQueue;
- HTTPServletInvoker* _httpServlet;
-
- std::set<InterpreterMonitor*> _monitors;
-
+ HTTPServletInvoker* _httpServlet;
+
+ std::set<InterpreterMonitor*> _monitors;
+
static URL toBaseURI(const URL& url);
void microstep(const Arabica::XPath::NodeSet<std::string>& enabledTransitions);
@@ -235,20 +239,20 @@ protected:
Arabica::XPath::NodeSet<std::string>& statesToEnter,
Arabica::XPath::NodeSet<std::string>& statesForDefaultEntry);
#endif
-
+
#ifdef ENTERSTATES_02_2013
void enterStates(const Arabica::XPath::NodeSet<std::string>& enabledTransitions);
- void computeEntrySet(const Arabica::XPath::NodeSet<std::string>& transitions,
- Arabica::XPath::NodeSet<std::string>& statesToEnter,
- Arabica::XPath::NodeSet<std::string>& statesForDefaultEntry);
- void addDescendentStatesToEnter(const Arabica::DOM::Node<std::string>& state,
- Arabica::XPath::NodeSet<std::string>& statesToEnter,
- Arabica::XPath::NodeSet<std::string>& statesForDefaultEntry);
- void addAncestorStatesToEnter(const Arabica::DOM::Node<std::string>& state,
- const Arabica::DOM::Node<std::string>& ancestor,
- Arabica::XPath::NodeSet<std::string>& statesToEnter,
- Arabica::XPath::NodeSet<std::string>& statesForDefaultEntry);
- Arabica::DOM::Node<std::string> getTransitionDomain(const Arabica::DOM::Node<std::string>& transition);
+ void computeEntrySet(const Arabica::XPath::NodeSet<std::string>& transitions,
+ Arabica::XPath::NodeSet<std::string>& statesToEnter,
+ Arabica::XPath::NodeSet<std::string>& statesForDefaultEntry);
+ void addDescendentStatesToEnter(const Arabica::DOM::Node<std::string>& state,
+ Arabica::XPath::NodeSet<std::string>& statesToEnter,
+ Arabica::XPath::NodeSet<std::string>& statesForDefaultEntry);
+ void addAncestorStatesToEnter(const Arabica::DOM::Node<std::string>& state,
+ const Arabica::DOM::Node<std::string>& ancestor,
+ Arabica::XPath::NodeSet<std::string>& statesToEnter,
+ Arabica::XPath::NodeSet<std::string>& statesForDefaultEntry);
+ Arabica::DOM::Node<std::string> getTransitionDomain(const Arabica::DOM::Node<std::string>& transition);
#endif
@@ -258,7 +262,7 @@ protected:
Arabica::XPath::NodeSet<std::string> selectTransitions(const std::string& event);
Arabica::DOM::Node<std::string> getSourceState(const Arabica::DOM::Node<std::string>& transition);
Arabica::DOM::Node<std::string> findLCCA(const Arabica::XPath::NodeSet<std::string>& states);
- Arabica::XPath::NodeSet<std::string> getProperAncestors(const Arabica::DOM::Node<std::string>& s1, const Arabica::DOM::Node<std::string>& s2);
+ Arabica::XPath::NodeSet<std::string> getProperAncestors(const Arabica::DOM::Node<std::string>& s1, const Arabica::DOM::Node<std::string>& s2);
void send(const Arabica::DOM::Node<std::string>& element);
@@ -286,7 +290,7 @@ protected:
std::string _name;
std::string _sessionId;
- Data _cmdLineOptions;
+ Data _cmdLineOptions;
IOProcessor getIOProcessor(const std::string& type);
// IOProcessor* getIOProcessorForId(const std::string& sendId);
@@ -299,7 +303,7 @@ protected:
/// We need to remember to adapt them when the DOM is operated upon
std::map<std::string, Arabica::DOM::Node<std::string> > _cachedStates;
- std::map<std::string, URL> _cachedURLs;
+ std::map<std::string, URL> _cachedURLs;
};
}
diff --git a/src/uscxml/Message.cpp b/src/uscxml/Message.cpp
index 1466b6a..c8c4b28 100644
--- a/src/uscxml/Message.cpp
+++ b/src/uscxml/Message.cpp
@@ -178,95 +178,95 @@ Data Data::fromXML(const std::string& xmlString) {
}
Data Data::fromJSON(const std::string& jsonString) {
- Data data;
- jsmn_parser p;
-
- jsmntok_t* t = NULL;
-
- // we do not know the number of tokens beforehand, start with something sensible and increase
- int rv;
- int frac = 32; // this will get decreased to 16 to first iteration for 1/16 length/token ratio
- do {
- jsmn_init(&p);
-
- frac /= 2;
- int nrTokens = jsonString.size() / frac;
- if (t != NULL) {
- free(t);
+ Data data;
+ jsmn_parser p;
+
+ jsmntok_t* t = NULL;
+
+ // we do not know the number of tokens beforehand, start with something sensible and increase
+ int rv;
+ int frac = 32; // this will get decreased to 16 to first iteration for 1/16 length/token ratio
+ do {
+ jsmn_init(&p);
+
+ frac /= 2;
+ int nrTokens = jsonString.size() / frac;
+ if (t != NULL) {
+ free(t);
// LOG(INFO) << "Increasing JSON length to token ratio to 1/" << frac;
- }
- t = (jsmntok_t*)malloc(nrTokens * sizeof(jsmntok_t));
- if (t == NULL) {
- LOG(ERROR) << "Cannot parse JSON, ran out of memory!";
- return data;
- }
- memset(t, 0, nrTokens * sizeof(jsmntok_t));
-
- rv = jsmn_parse(&p, jsonString.c_str(), t, nrTokens);
- } while (rv == JSMN_ERROR_NOMEM && frac > 1);
-
- if (rv != 0) {
- switch (rv) {
- case JSMN_ERROR_NOMEM:
- LOG(ERROR) << "Cannot parse JSON, not enough tokens were provided!";
- break;
- case JSMN_ERROR_INVAL:
- LOG(ERROR) << "Cannot parse JSON, invalid character inside JSON string!";
- break;
- case JSMN_ERROR_PART:
- LOG(ERROR) << "Cannot parse JSON, the string is not a full JSON packet, more bytes expected!";
- break;
- default:
- break;
- }
- free(t);
- return data;
- }
-
- std::list<Data*> dataStack;
- std::list<jsmntok_t> tokenStack;
- dataStack.push_back(&data);
-
- size_t currTok = 0;
- do {
- switch (t[currTok].type) {
- case JSMN_STRING:
- dataStack.back()->type = Data::VERBATIM;
- case JSMN_PRIMITIVE:
- dataStack.back()->atom = jsonString.substr(t[currTok].start, t[currTok].end - t[currTok].start);
- dataStack.pop_back();
- currTok++;
- break;
- case JSMN_OBJECT:
- case JSMN_ARRAY:
- tokenStack.push_back(t[currTok]);
- currTok++;
- break;
- }
-
- // there are no more tokens
- if (t[currTok].end == 0 || tokenStack.empty())
- break;
-
- // next token starts after current one => pop
- if (t[currTok].end > tokenStack.back().end)
- tokenStack.pop_back();
-
- if (tokenStack.back().type == JSMN_OBJECT && (t[currTok].type == JSMN_PRIMITIVE || t[currTok].type == JSMN_STRING)) {
- // grab key and push new data
- dataStack.push_back(&(dataStack.back()->compound[jsonString.substr(t[currTok].start, t[currTok].end - t[currTok].start)]));
- currTok++;
- }
- if (tokenStack.back().type == JSMN_ARRAY) {
- // push new index
- dataStack.back()->array.push_back(Data());
- dataStack.push_back(&(dataStack.back()->array.back()));
- }
-
- } while (true);
-
- free(t);
- return data;
+ }
+ t = (jsmntok_t*)malloc(nrTokens * sizeof(jsmntok_t));
+ if (t == NULL) {
+ LOG(ERROR) << "Cannot parse JSON, ran out of memory!";
+ return data;
+ }
+ memset(t, 0, nrTokens * sizeof(jsmntok_t));
+
+ rv = jsmn_parse(&p, jsonString.c_str(), t, nrTokens);
+ } while (rv == JSMN_ERROR_NOMEM && frac > 1);
+
+ if (rv != 0) {
+ switch (rv) {
+ case JSMN_ERROR_NOMEM:
+ LOG(ERROR) << "Cannot parse JSON, not enough tokens were provided!";
+ break;
+ case JSMN_ERROR_INVAL:
+ LOG(ERROR) << "Cannot parse JSON, invalid character inside JSON string!";
+ break;
+ case JSMN_ERROR_PART:
+ LOG(ERROR) << "Cannot parse JSON, the string is not a full JSON packet, more bytes expected!";
+ break;
+ default:
+ break;
+ }
+ free(t);
+ return data;
+ }
+
+ std::list<Data*> dataStack;
+ std::list<jsmntok_t> tokenStack;
+ dataStack.push_back(&data);
+
+ size_t currTok = 0;
+ do {
+ switch (t[currTok].type) {
+ case JSMN_STRING:
+ dataStack.back()->type = Data::VERBATIM;
+ case JSMN_PRIMITIVE:
+ dataStack.back()->atom = jsonString.substr(t[currTok].start, t[currTok].end - t[currTok].start);
+ dataStack.pop_back();
+ currTok++;
+ break;
+ case JSMN_OBJECT:
+ case JSMN_ARRAY:
+ tokenStack.push_back(t[currTok]);
+ currTok++;
+ break;
+ }
+
+ // there are no more tokens
+ if (t[currTok].end == 0 || tokenStack.empty())
+ break;
+
+ // next token starts after current one => pop
+ if (t[currTok].end > tokenStack.back().end)
+ tokenStack.pop_back();
+
+ if (tokenStack.back().type == JSMN_OBJECT && (t[currTok].type == JSMN_PRIMITIVE || t[currTok].type == JSMN_STRING)) {
+ // grab key and push new data
+ dataStack.push_back(&(dataStack.back()->compound[jsonString.substr(t[currTok].start, t[currTok].end - t[currTok].start)]));
+ currTok++;
+ }
+ if (tokenStack.back().type == JSMN_ARRAY) {
+ // push new index
+ dataStack.back()->array.push_back(Data());
+ dataStack.push_back(&(dataStack.back()->array.back()));
+ }
+
+ } while (true);
+
+ free(t);
+ return data;
}
Event Event::fromXML(const std::string& xmlString) {
@@ -326,94 +326,94 @@ InvokeRequest InvokeRequest::fromXML(const std::string& xmlString) {
#ifndef SWIGJAVA
std::ostream& operator<< (std::ostream& os, const InvokeRequest& invokeReq) {
-
- std::string indent;
- for (int i = 0; i < _dataIndentation; i++) {
- indent += " ";
- }
-
- os << indent << "InvokeReq" << (invokeReq.autoForward ? " with autoforward" : "") << std::endl;
-
- if (invokeReq.type.size() > 0)
- os << indent << " type: " << invokeReq.type << std::endl;
-
- if (invokeReq.src.size() > 0)
- os<< indent << " src: " << invokeReq.src << std::endl;
-
- if (invokeReq.namelist.size() > 0) {
- os << indent << " namelist: " << std::endl;
- InvokeRequest::namelist_t::const_iterator namelistIter = invokeReq.namelist.begin();
- while(namelistIter != invokeReq.namelist.end()) {
- os << indent << " " << namelistIter->first << ": " << namelistIter->second << std::endl;
- namelistIter++;
- }
- }
-
- if (invokeReq.params.size() > 0) {
- os << indent << " params: " << std::endl;
- SendRequest::params_t::const_iterator paramIter = invokeReq.params.begin();
- while(paramIter != invokeReq.params.end()) {
- os << indent << " " << paramIter->first << ": " << paramIter->second << std::endl;
- paramIter++;
- }
- }
-
- if (invokeReq.content.size() > 0)
- os << indent << " content: " << invokeReq.content << std::endl;
-
- _dataIndentation++;
- os << (Event)invokeReq;
- _dataIndentation--;
- return os;
-
+
+ std::string indent;
+ for (int i = 0; i < _dataIndentation; i++) {
+ indent += " ";
+ }
+
+ os << indent << "InvokeReq" << (invokeReq.autoForward ? " with autoforward" : "") << std::endl;
+
+ if (invokeReq.type.size() > 0)
+ os << indent << " type: " << invokeReq.type << std::endl;
+
+ if (invokeReq.src.size() > 0)
+ os<< indent << " src: " << invokeReq.src << std::endl;
+
+ if (invokeReq.namelist.size() > 0) {
+ os << indent << " namelist: " << std::endl;
+ InvokeRequest::namelist_t::const_iterator namelistIter = invokeReq.namelist.begin();
+ while(namelistIter != invokeReq.namelist.end()) {
+ os << indent << " " << namelistIter->first << ": " << namelistIter->second << std::endl;
+ namelistIter++;
+ }
+ }
+
+ if (invokeReq.params.size() > 0) {
+ os << indent << " params: " << std::endl;
+ SendRequest::params_t::const_iterator paramIter = invokeReq.params.begin();
+ while(paramIter != invokeReq.params.end()) {
+ os << indent << " " << paramIter->first << ": " << paramIter->second << std::endl;
+ paramIter++;
+ }
+ }
+
+ if (invokeReq.content.size() > 0)
+ os << indent << " content: " << invokeReq.content << std::endl;
+
+ _dataIndentation++;
+ os << (Event)invokeReq;
+ _dataIndentation--;
+ return os;
+
}
#endif
-
+
#ifndef SWIGJAVA
std::ostream& operator<< (std::ostream& os, const SendRequest& sendReq) {
- std::string indent;
- for (int i = 0; i < _dataIndentation; i++) {
- indent += " ";
- }
+ std::string indent;
+ for (int i = 0; i < _dataIndentation; i++) {
+ indent += " ";
+ }
- os << indent<< "SendReq" << std::endl;
+ os << indent<< "SendReq" << std::endl;
- if (sendReq.target.size() > 0)
- os << indent << " target: " << sendReq.target << std::endl;
+ if (sendReq.target.size() > 0)
+ os << indent << " target: " << sendReq.target << std::endl;
- if (sendReq.type.size() > 0)
- os << indent << " type: " << sendReq.type << std::endl;
+ if (sendReq.type.size() > 0)
+ os << indent << " type: " << sendReq.type << std::endl;
- if (sendReq.delayMs > 0)
- os<< indent << " delay: " << sendReq.delayMs << std::endl;
+ if (sendReq.delayMs > 0)
+ os<< indent << " delay: " << sendReq.delayMs << std::endl;
- if (sendReq.namelist.size() > 0) {
- os << indent << " namelist: " << std::endl;
- SendRequest::namelist_t::const_iterator namelistIter = sendReq.namelist.begin();
- while(namelistIter != sendReq.namelist.end()) {
- os << indent << " " << namelistIter->first << ": " << namelistIter->second << std::endl;
- namelistIter++;
- }
- }
+ if (sendReq.namelist.size() > 0) {
+ os << indent << " namelist: " << std::endl;
+ SendRequest::namelist_t::const_iterator namelistIter = sendReq.namelist.begin();
+ while(namelistIter != sendReq.namelist.end()) {
+ os << indent << " " << namelistIter->first << ": " << namelistIter->second << std::endl;
+ namelistIter++;
+ }
+ }
- if (sendReq.params.size() > 0) {
- os << indent << " params: " << std::endl;
- SendRequest::params_t::const_iterator paramIter = sendReq.params.begin();
- while(paramIter != sendReq.params.end()) {
- os << indent << " " << paramIter->first << ": " << paramIter->second << std::endl;
- paramIter++;
- }
- }
+ if (sendReq.params.size() > 0) {
+ os << indent << " params: " << std::endl;
+ SendRequest::params_t::const_iterator paramIter = sendReq.params.begin();
+ while(paramIter != sendReq.params.end()) {
+ os << indent << " " << paramIter->first << ": " << paramIter->second << std::endl;
+ paramIter++;
+ }
+ }
- if (sendReq.content.size() > 0)
- os << indent << " content: " << sendReq.content << std::endl;
+ if (sendReq.content.size() > 0)
+ os << indent << " content: " << sendReq.content << std::endl;
- _dataIndentation++;
- os << (Event)sendReq;
- _dataIndentation--;
- return os;
+ _dataIndentation++;
+ os << (Event)sendReq;
+ _dataIndentation--;
+ return os;
}
#endif
@@ -424,7 +424,7 @@ std::ostream& operator<< (std::ostream& os, const Event& event) {
for (int i = 0; i < _dataIndentation; i++) {
indent += " ";
}
-
+
os << indent << (event.type == Event::EXTERNAL ? "External" : "Internal") << " Event " << (event.dom ? "with DOM attached" : "") << std::endl;
if (event.name.size() > 0)
@@ -459,29 +459,29 @@ std::ostream& operator<< (std::ostream& os, const Data& data) {
for (unsigned int i = 0; i < longestKey; i++)
keyPadding += " ";
- std::string seperator;
+ std::string seperator;
os << std::endl << indent << "{";
compoundIter = data.compound.begin();
while(compoundIter != data.compound.end()) {
os << seperator << std::endl << indent << " \"" << compoundIter->first << "\": " << keyPadding.substr(0, longestKey - compoundIter->first.size());
- _dataIndentation += 1;
- os << compoundIter->second;
- _dataIndentation -= 1;
- seperator = ", ";
+ _dataIndentation += 1;
+ os << compoundIter->second;
+ _dataIndentation -= 1;
+ seperator = ", ";
compoundIter++;
}
os << std::endl << indent << "}";
} else if (data.array.size() > 0) {
- std::string seperator;
+ std::string seperator;
os << std::endl << indent << "[";
std::list<Data>::const_iterator arrayIter = data.array.begin();
while(arrayIter != data.array.end()) {
- _dataIndentation += 1;
- os << seperator << *arrayIter;
- _dataIndentation -= 1;
- seperator = ", ";
- arrayIter++;
+ _dataIndentation += 1;
+ os << seperator << *arrayIter;
+ _dataIndentation -= 1;
+ seperator = ", ";
+ arrayIter++;
}
os << std::endl << indent << "]";
} else if (data.atom.size() > 0) {
@@ -491,8 +491,8 @@ std::ostream& operator<< (std::ostream& os, const Data& data) {
os << data.atom;
}
} else {
- os << "undefined";
- }
+ os << "undefined";
+ }
return os;
}
#endif
diff --git a/src/uscxml/Message.h b/src/uscxml/Message.h
index 96ff6c8..a746710 100644
--- a/src/uscxml/Message.h
+++ b/src/uscxml/Message.h
@@ -70,8 +70,8 @@ public:
Arabica::DOM::Node<std::string> dom;
std::string sendid;
std::string invokeid;
- Data data;
-
+ Data data;
+
static Event fromXML(const std::string& xmlString);
Arabica::DOM::Document<std::string> toDocument();
std::string toXMLString() {
@@ -87,8 +87,8 @@ public:
class InvokeRequest : public Event {
public:
- InvokeRequest(Event event) : Event(event) {}
- InvokeRequest() {}
+ InvokeRequest(Event event) : Event(event) {}
+ InvokeRequest() {}
std::string type;
std::string src;
std::map<std::string, std::string> namelist;
@@ -115,8 +115,8 @@ public:
class SendRequest : public Event {
public:
- SendRequest() {}
- SendRequest(Event event) : Event(event) {}
+ SendRequest() {}
+ SendRequest(Event event) : Event(event) {}
std::string target;
std::string type;
uint32_t delayMs;
@@ -134,7 +134,7 @@ public:
// std::cout << ss.str() << std::endl;
return ss.str();
}
-
+
#ifndef SWIGJAVA
friend std::ostream& operator<< (std::ostream& os, const SendRequest& sendReq);
#endif
diff --git a/src/uscxml/URL.cpp b/src/uscxml/URL.cpp
index 8656cd2..024bb0c 100644
--- a/src/uscxml/URL.cpp
+++ b/src/uscxml/URL.cpp
@@ -26,485 +26,486 @@
namespace uscxml {
URLImpl::URLImpl(const std::string& url) : _handle(NULL), _uri(url), _isDownloaded(false), _hasFailed(false) {
- _handle = curl_easy_init();
- if (_handle == NULL) {
- LOG(ERROR) << "curl_easy_init returned NULL, this is bad!";
- }
+ _handle = curl_easy_init();
+ if (_handle == NULL) {
+ LOG(ERROR) << "curl_easy_init returned NULL, this is bad!";
+ }
}
-
+
URLImpl::~URLImpl() {
- if (_handle != NULL)
- curl_easy_cleanup(_handle);
+ if (_handle != NULL)
+ curl_easy_cleanup(_handle);
}
-
+
size_t URLImpl::writeHandler(void *ptr, size_t size, size_t nmemb, void *userdata) {
- URLImpl* url = (URLImpl*)userdata;
- url->_inContent.write((char*)ptr, size * nmemb);
+ URLImpl* url = (URLImpl*)userdata;
+ url->_inContent.write((char*)ptr, size * nmemb);
- monIter_t monIter = url->_monitors.begin();
- while(monIter != url->_monitors.end()) {
- (*monIter)->contentChunkReceived(URL(url->shared_from_this()), std::string((char*)ptr, size * nmemb));
- monIter++;
- }
+ monIter_t monIter = url->_monitors.begin();
+ while(monIter != url->_monitors.end()) {
+ (*monIter)->contentChunkReceived(URL(url->shared_from_this()), std::string((char*)ptr, size * nmemb));
+ monIter++;
+ }
- return size * nmemb;
+ return size * nmemb;
}
size_t URLImpl::headerHandler(void *ptr, size_t size, size_t nmemb, void *userdata) {
- URLImpl* url = (URLImpl*)userdata;
- url->_inHeader.write((char*)ptr, size * nmemb);
+ URLImpl* url = (URLImpl*)userdata;
+ url->_inHeader.write((char*)ptr, size * nmemb);
- monIter_t monIter = url->_monitors.begin();
- while(monIter != url->_monitors.end()) {
- (*monIter)->headerChunkReceived(URL(url->shared_from_this()), std::string((char*)ptr, size * nmemb));
- monIter++;
- }
+ monIter_t monIter = url->_monitors.begin();
+ while(monIter != url->_monitors.end()) {
+ (*monIter)->headerChunkReceived(URL(url->shared_from_this()), std::string((char*)ptr, size * nmemb));
+ monIter++;
+ }
- return size * nmemb;
+ return size * nmemb;
}
void URLImpl::downloadStarted() {
- LOG(INFO) << "Starting download of " << asString() << std::endl;
- _inContent.str("");
- _inContent.clear();
- _inHeader.str("");
- _inHeader.clear();
-
- monIter_t monIter = _monitors.begin();
- while(monIter != _monitors.end()) {
- (*monIter)->downloadStarted(URL(shared_from_this()));
- monIter++;
- }
+ LOG(INFO) << "Starting download of " << asString() << std::endl;
+ _inContent.str("");
+ _inContent.clear();
+ _inHeader.str("");
+ _inHeader.clear();
+
+ monIter_t monIter = _monitors.begin();
+ while(monIter != _monitors.end()) {
+ (*monIter)->downloadStarted(URL(shared_from_this()));
+ monIter++;
+ }
}
void URLImpl::downloadCompleted() {
- tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
+ tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
- LOG(INFO) << "Finished downloading " << asString() << " with " << _inContent.str().size() << " bytes";
+ LOG(INFO) << "Finished downloading " << asString() << " with " << _inContent.str().size() << " bytes";
- _hasFailed = false;
- _isDownloaded = true;
- _condVar.notify_all();
+ _hasFailed = false;
+ _isDownloaded = true;
+ _condVar.notify_all();
- monIter_t monIter = _monitors.begin();
- while(monIter != _monitors.end()) {
- (*monIter)->downloadCompleted(URL(shared_from_this()));
- monIter++;
- }
+ monIter_t monIter = _monitors.begin();
+ while(monIter != _monitors.end()) {
+ (*monIter)->downloadCompleted(URL(shared_from_this()));
+ monIter++;
+ }
}
void URLImpl::downloadFailed(int errorCode) {
- tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
-
- LOG(ERROR) << "Downloading " << asString() << " failed: " << strerror(errorCode);
-
- _hasFailed = true;
- _isDownloaded = false;
- _condVar.notify_all();
-
- monIter_t monIter = _monitors.begin();
- while(monIter != _monitors.end()) {
- (*monIter)->downloadFailed(URL(shared_from_this()), errorCode);
- monIter++;
- }
+ tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
+
+ LOG(ERROR) << "Downloading " << asString() << " failed: " << strerror(errorCode);
+
+ _hasFailed = true;
+ _isDownloaded = false;
+ _condVar.notify_all();
+
+ monIter_t monIter = _monitors.begin();
+ while(monIter != _monitors.end()) {
+ (*monIter)->downloadFailed(URL(shared_from_this()), errorCode);
+ monIter++;
+ }
}
-
+
const std::map<std::string, std::string> URLImpl::getInHeaderFields() {
- if (!_isDownloaded) {
- download(true);
- }
-
- std::map<std::string, std::string> headerFields;
- std::string line;
- while (std::getline(_inHeader, line)) {
- size_t colon = line.find_first_of(":");
- size_t newline = line.find_first_of("\r\n");
- if (newline == std::string::npos)
- newline = line.size();
-
- if (colon == std::string::npos) {
- if (headerFields.size() == 0) {
- // put http status in a key that can never occur otherwise
- headerFields["status:"] = line.substr(0, newline);
- } else {
- headerFields[line.substr(0, newline)] = line.substr(0, newline); // this should never happen
- }
- } else {
- std::string key = line.substr(0, colon);
- size_t firstChar = line.find_first_not_of(": ", colon, 2);
- if (firstChar == std::string::npos) {
- // nothing but spaces?
- headerFields[line.substr(0, newline)] = "";
- } else {
- std::string value = line.substr(firstChar, newline - firstChar);
- headerFields[key] = value;
- }
- }
- }
-
- return headerFields;
+ if (!_isDownloaded) {
+ download(true);
+ }
+
+ std::map<std::string, std::string> headerFields;
+ std::string line;
+ while (std::getline(_inHeader, line)) {
+ size_t colon = line.find_first_of(":");
+ size_t newline = line.find_first_of("\r\n");
+ if (newline == std::string::npos)
+ newline = line.size();
+
+ if (colon == std::string::npos) {
+ if (headerFields.size() == 0) {
+ // put http status in a key that can never occur otherwise
+ headerFields["status:"] = line.substr(0, newline);
+ } else {
+ headerFields[line.substr(0, newline)] = line.substr(0, newline); // this should never happen
+ }
+ } else {
+ std::string key = line.substr(0, colon);
+ size_t firstChar = line.find_first_not_of(": ", colon, 2);
+ if (firstChar == std::string::npos) {
+ // nothing but spaces?
+ headerFields[line.substr(0, newline)] = "";
+ } else {
+ std::string value = line.substr(firstChar, newline - firstChar);
+ headerFields[key] = value;
+ }
+ }
+ }
+
+ return headerFields;
}
void URLImpl::setRequestType(const std::string& requestType) {
- _requestType = requestType;
+ _requestType = requestType;
}
void URLImpl::setOutContent(const std::string& content) {
- _outContent = content;
+ _outContent = content;
}
const std::string URLImpl::getInContent(bool forceReload) {
- if (!_isDownloaded) {
- download(true);
- }
- return _inContent.str();
+ if (!_isDownloaded) {
+ download(true);
+ }
+ return _inContent.str();
}
const void URLImpl::download(bool blocking) {
- tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
-
- if (_isDownloaded)
- return;
-
- URL url(shared_from_this());
- URLFetcher::fetchURL(url);
-
- if (blocking) {
- while(!_isDownloaded && !_hasFailed) {
- _condVar.wait(_mutex); // wait for notification
- }
- }
+ tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
+
+ if (_isDownloaded)
+ return;
+
+ URL url(shared_from_this());
+ URLFetcher::fetchURL(url);
+
+ if (blocking) {
+ while(!_isDownloaded && !_hasFailed) {
+ _condVar.wait(_mutex); // wait for notification
+ }
+ }
}
const bool URLImpl::toAbsoluteCwd() {
- char currPath[FILENAME_MAX];
- if (!getcwd(currPath, sizeof(currPath))) {
- return false;
- }
- currPath[sizeof(currPath) - 1] = '\0'; /* not really required */
- return toAbsolute(std::string("file://" + std::string(currPath) + "/"));
+ char currPath[FILENAME_MAX];
+ if (!getcwd(currPath, sizeof(currPath))) {
+ return false;
+ }
+ currPath[sizeof(currPath) - 1] = '\0'; /* not really required */
+ return toAbsolute(std::string("file://" + std::string(currPath) + "/"));
}
std::string URLImpl::getLocalFilename(const std::string& suffix) {
- if (_localFile.length() > 0)
- return _localFile;
-
- if (_uri.scheme().compare("file") == 0)
- return _uri.path();
-
- // try hard to find a temporary directory
- const char* tmpDir = NULL;
- if (tmpDir == NULL)
- tmpDir = getenv("TMPDIR");
- if (tmpDir == NULL)
- tmpDir = getenv("TMP");
- if (tmpDir == NULL)
- tmpDir = getenv("TEMP");
- if (tmpDir == NULL)
- tmpDir = getenv("USERPROFILE");
- if (tmpDir == NULL)
- tmpDir = "/tmp/";
-
- char* tmpl = (char*)malloc(strlen(tmpDir) + 11 + suffix.length());
- char* writePtr = tmpl;
- memcpy(writePtr, tmpDir, strlen(tmpDir));
- writePtr += strlen(tmpDir);
- memcpy(writePtr, "scxmlXXXXXX", 11);
- writePtr += 11;
- memcpy(writePtr, suffix.c_str(), suffix.length());
- writePtr += suffix.length();
- tmpl[writePtr - tmpl] = 0;
-
+ if (_localFile.length() > 0)
+ return _localFile;
+
+ if (_uri.scheme().compare("file") == 0)
+ return _uri.path();
+
+ // try hard to find a temporary directory
+ const char* tmpDir = NULL;
+ if (tmpDir == NULL)
+ tmpDir = getenv("TMPDIR");
+ if (tmpDir == NULL)
+ tmpDir = getenv("TMP");
+ if (tmpDir == NULL)
+ tmpDir = getenv("TEMP");
+ if (tmpDir == NULL)
+ tmpDir = getenv("USERPROFILE");
+ if (tmpDir == NULL)
+ tmpDir = "/tmp/";
+
+ char* tmpl = (char*)malloc(strlen(tmpDir) + 11 + suffix.length());
+ char* writePtr = tmpl;
+ memcpy(writePtr, tmpDir, strlen(tmpDir));
+ writePtr += strlen(tmpDir);
+ memcpy(writePtr, "scxmlXXXXXX", 11);
+ writePtr += 11;
+ memcpy(writePtr, suffix.c_str(), suffix.length());
+ writePtr += suffix.length();
+ tmpl[writePtr - tmpl] = 0;
+
#ifdef _WIN32
- _mktemp_s(tmpl, strlen(tmpl) + 1);
- int fd = _open(tmpl, _O_CREAT, _S_IREAD | _S_IWRITE);
+ _mktemp_s(tmpl, strlen(tmpl) + 1);
+ int fd = _open(tmpl, _O_CREAT, _S_IREAD | _S_IWRITE);
#else
- int fd = mkstemps(tmpl, suffix.length());
+ int fd = mkstemps(tmpl, suffix.length());
#endif
- if (fd < 0) {
- LOG(ERROR) << "mkstemp " << tmpl << ": " << strerror(errno) << std::endl;
- return "";
- }
+ if (fd < 0) {
+ LOG(ERROR) << "mkstemp " << tmpl << ": " << strerror(errno) << std::endl;
+ return "";
+ }
#ifdef WIN32
- _close(fd);
+ _close(fd);
#else
- close(fd);
+ close(fd);
#endif
- return std::string(tmpl);
+ return std::string(tmpl);
}
const bool URLImpl::toAbsolute(const std::string& baseUrl) {
- if (_uri.is_absolute())
- return true;
- _uri = Arabica::io::URI(baseUrl, _uri.as_string());
- if (!_uri.is_absolute())
- return false;
- return true;
+ if (_uri.is_absolute())
+ return true;
+ _uri = Arabica::io::URI(baseUrl, _uri.as_string());
+ if (!_uri.is_absolute())
+ return false;
+ return true;
}
boost::shared_ptr<URLImpl> URLImpl::toLocalFile(const std::string& content, const std::string& suffix) {
- boost::shared_ptr<URLImpl> urlImpl = boost::shared_ptr<URLImpl>(new URLImpl());
- urlImpl->_localFile = urlImpl->getLocalFilename(suffix);
- urlImpl->_uri = std::string("file://") + urlImpl->_localFile;
-
- std::ofstream file(urlImpl->_localFile.c_str(), std::ios_base::out);
- if(file.is_open()) {
- file << content;
- file.close();
- } else {
- return boost::shared_ptr<URLImpl>();
- }
-
- return urlImpl;
+ boost::shared_ptr<URLImpl> urlImpl = boost::shared_ptr<URLImpl>(new URLImpl());
+ urlImpl->_localFile = urlImpl->getLocalFilename(suffix);
+ urlImpl->_uri = std::string("file://") + urlImpl->_localFile;
+
+ std::ofstream file(urlImpl->_localFile.c_str(), std::ios_base::out);
+ if(file.is_open()) {
+ file << content;
+ file.close();
+ } else {
+ return boost::shared_ptr<URLImpl>();
+ }
+
+ return urlImpl;
}
-
+
const std::string URLImpl::asLocalFile(const std::string& suffix, bool reload) {
- // this is already a local file
- if (_uri.scheme().compare("file") == 0)
- return _uri.path();
-
- if (_localFile.length() > 0 && !reload)
- return _localFile;
-
- if (_localFile.length() > 0)
- remove(_localFile.c_str());
-
- _localFile = getLocalFilename(suffix);
-
- std::ofstream file(_localFile.c_str(), std::ios_base::out);
- if(file.is_open()) {
- file << URL(this->shared_from_this());
- file.close();
- } else {
- _localFile = "";
- }
-
- return _localFile;
+ // this is already a local file
+ if (_uri.scheme().compare("file") == 0)
+ return _uri.path();
+
+ if (_localFile.length() > 0 && !reload)
+ return _localFile;
+
+ if (_localFile.length() > 0)
+ remove(_localFile.c_str());
+
+ _localFile = getLocalFilename(suffix);
+
+ std::ofstream file(_localFile.c_str(), std::ios_base::out);
+ if(file.is_open()) {
+ file << URL(this->shared_from_this());
+ file.close();
+ } else {
+ _localFile = "";
+ }
+
+ return _localFile;
}
std::ostream & operator<<(std::ostream & stream, const URL& url) {
- URL nonConstUrl = url; // this is a hack
- stream << nonConstUrl.getInContent();
- return stream;
+ URL nonConstUrl = url; // this is a hack
+ stream << nonConstUrl.getInContent();
+ return stream;
}
URLFetcher::URLFetcher() {
- _isStarted = false;
- _multiHandle = curl_multi_init();
- start();
+ _isStarted = false;
+ _multiHandle = curl_multi_init();
+ start();
}
-
+
URLFetcher::~URLFetcher() {
- stop();
- curl_multi_cleanup(_multiHandle);
+ stop();
+ curl_multi_cleanup(_multiHandle);
}
-
+
void URLFetcher::fetchURL(URL& url) {
- URLFetcher* instance = getInstance();
- tthread::lock_guard<tthread::recursive_mutex> lock(instance->_mutex);
-
- assert(url._impl->_handle != NULL);
- if (url._impl->_handle == NULL)
- return;
-
- if (instance->_handlesToURLs.find(url._impl->_handle) == instance->_handlesToURLs.end()) {
- CURLcode curlError;
- CURL* handle = url._impl->_handle;
-
- (curlError = curl_easy_setopt(handle, CURLOPT_URL, url.asString().c_str())) == CURLE_OK ||
- LOG(ERROR) << "Cannot set url to " << url.asString() << ": " << curl_easy_strerror(curlError);
-
- (curlError = curl_easy_setopt(handle, CURLOPT_WRITEDATA, url._impl.get())) == CURLE_OK ||
- LOG(ERROR) << "Cannot register this as write userdata: " << curl_easy_strerror(curlError);
-
- (curlError = curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, URLImpl::writeHandler)) == CURLE_OK ||
- LOG(ERROR) << "Cannot set write callback: " << curl_easy_strerror(curlError);
-
- (curlError = curl_easy_setopt(handle, CURLOPT_HEADERFUNCTION, URLImpl::headerHandler)) == CURLE_OK ||
- LOG(ERROR) << "Cannot request header from curl: " << curl_easy_strerror(curlError);
-
- (curlError = curl_easy_setopt(handle, CURLOPT_HEADERDATA, url._impl.get())) == CURLE_OK ||
- LOG(ERROR) << "Cannot register this as header userdata: " << curl_easy_strerror(curlError);
-
-
- if (boost::iequals(url._impl->_requestType, "post")) {
-
- (curlError = curl_easy_setopt(handle, CURLOPT_POST, 1)) == CURLE_OK ||
- LOG(ERROR) << "Cannot set request type to post for " << url.asString() << ": " << curl_easy_strerror(curlError);
-
- (curlError = curl_easy_setopt(handle, CURLOPT_COPYPOSTFIELDS, url._impl->_outContent.c_str())) == CURLE_OK ||
- LOG(ERROR) << "Cannot set post data " << url.asString() << ": " << curl_easy_strerror(curlError);
-
- struct curl_slist* headers = NULL;
- std::map<std::string, std::string>::iterator paramIter = url._impl->_outHeader.begin();
- while(paramIter != url._impl->_outHeader.end()) {
- char* key = curl_easy_escape(handle, paramIter->first.c_str(), paramIter->first.length());
- char* value = curl_easy_escape(handle, paramIter->second.c_str(), paramIter->second.length());
-
- char* header = (char*)malloc(paramIter->first.size() + strlen(value) + 3);
- sprintf(header,"%s: %s", paramIter->first.c_str(), value);
- headers = curl_slist_append(headers, header);
-
- curl_free(key);
- curl_free(value);
- paramIter++;
- }
- (curlError = curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers)) == CURLE_OK ||
- LOG(ERROR) << "Cannot headers for " << url.asString() << ": " << curl_easy_strerror(curlError);
-
- //curl_slist_free_all(headers);
-
-
- } else if (boost::iequals(url._impl->_requestType, "get")) {
- (curlError = curl_easy_setopt(handle, CURLOPT_HTTPGET, 1)) == CURLE_OK ||
- LOG(ERROR) << "Cannot set request type to get for " << url.asString() << ": " << curl_easy_strerror(curlError);
- }
-
- url.downloadStarted();
- instance->_handlesToURLs[handle] = url;
- assert(instance->_handlesToURLs.size() > 0);
-
- curl_multi_add_handle(instance->_multiHandle, handle);
- instance->_condVar.notify_all();
- }
+ URLFetcher* instance = getInstance();
+ tthread::lock_guard<tthread::recursive_mutex> lock(instance->_mutex);
+
+ assert(url._impl->_handle != NULL);
+ if (url._impl->_handle == NULL)
+ return;
+
+ if (instance->_handlesToURLs.find(url._impl->_handle) == instance->_handlesToURLs.end()) {
+ CURLcode curlError;
+ CURL* handle = url._impl->_handle;
+
+ (curlError = curl_easy_setopt(handle, CURLOPT_URL, url.asString().c_str())) == CURLE_OK ||
+ LOG(ERROR) << "Cannot set url to " << url.asString() << ": " << curl_easy_strerror(curlError);
+
+ (curlError = curl_easy_setopt(handle, CURLOPT_WRITEDATA, url._impl.get())) == CURLE_OK ||
+ LOG(ERROR) << "Cannot register this as write userdata: " << curl_easy_strerror(curlError);
+
+ (curlError = curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, URLImpl::writeHandler)) == CURLE_OK ||
+ LOG(ERROR) << "Cannot set write callback: " << curl_easy_strerror(curlError);
+
+ (curlError = curl_easy_setopt(handle, CURLOPT_HEADERFUNCTION, URLImpl::headerHandler)) == CURLE_OK ||
+ LOG(ERROR) << "Cannot request header from curl: " << curl_easy_strerror(curlError);
+
+ (curlError = curl_easy_setopt(handle, CURLOPT_HEADERDATA, url._impl.get())) == CURLE_OK ||
+ LOG(ERROR) << "Cannot register this as header userdata: " << curl_easy_strerror(curlError);
+
+
+ if (boost::iequals(url._impl->_requestType, "post")) {
+
+ (curlError = curl_easy_setopt(handle, CURLOPT_POST, 1)) == CURLE_OK ||
+ LOG(ERROR) << "Cannot set request type to post for " << url.asString() << ": " << curl_easy_strerror(curlError);
+
+ (curlError = curl_easy_setopt(handle, CURLOPT_COPYPOSTFIELDS, url._impl->_outContent.c_str())) == CURLE_OK ||
+ LOG(ERROR) << "Cannot set post data " << url.asString() << ": " << curl_easy_strerror(curlError);
+
+ struct curl_slist* headers = NULL;
+ std::map<std::string, std::string>::iterator paramIter = url._impl->_outHeader.begin();
+ while(paramIter != url._impl->_outHeader.end()) {
+ char* key = curl_easy_escape(handle, paramIter->first.c_str(), paramIter->first.length());
+ char* value = curl_easy_escape(handle, paramIter->second.c_str(), paramIter->second.length());
+
+ char* header = (char*)malloc(paramIter->first.size() + strlen(value) + 3);
+ sprintf(header,"%s: %s", paramIter->first.c_str(), value);
+ headers = curl_slist_append(headers, header);
+
+ curl_free(key);
+ curl_free(value);
+ paramIter++;
+ }
+ (curlError = curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers)) == CURLE_OK ||
+ LOG(ERROR) << "Cannot headers for " << url.asString() << ": " << curl_easy_strerror(curlError);
+
+ //curl_slist_free_all(headers);
+
+
+ } else if (boost::iequals(url._impl->_requestType, "get")) {
+ (curlError = curl_easy_setopt(handle, CURLOPT_HTTPGET, 1)) == CURLE_OK ||
+ LOG(ERROR) << "Cannot set request type to get for " << url.asString() << ": " << curl_easy_strerror(curlError);
+ }
+
+ url.downloadStarted();
+ instance->_handlesToURLs[handle] = url;
+ assert(instance->_handlesToURLs.size() > 0);
+
+ curl_multi_add_handle(instance->_multiHandle, handle);
+ instance->_condVar.notify_all();
+ }
}
void URLFetcher::breakURL(URL& url) {
- URLFetcher* instance = getInstance();
- CURL* handle = url._impl->_handle;
-
- tthread::lock_guard<tthread::recursive_mutex> lock(instance->_mutex);
- if (instance->_handlesToURLs.find(handle) != instance->_handlesToURLs.end()) {
- url.downloadFailed(0);
- curl_multi_remove_handle(instance->_multiHandle, handle);
- instance->_handlesToURLs.erase(handle);
- }
+ URLFetcher* instance = getInstance();
+ CURL* handle = url._impl->_handle;
+
+ tthread::lock_guard<tthread::recursive_mutex> lock(instance->_mutex);
+ if (instance->_handlesToURLs.find(handle) != instance->_handlesToURLs.end()) {
+ url.downloadFailed(0);
+ curl_multi_remove_handle(instance->_multiHandle, handle);
+ instance->_handlesToURLs.erase(handle);
+ }
}
void URLFetcher::start() {
- tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
- if (!_isStarted) {
- _isStarted = true;
- _thread = new tthread::thread(URLFetcher::run, this);
- }
+ tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
+ if (!_isStarted) {
+ _isStarted = true;
+ _thread = new tthread::thread(URLFetcher::run, this);
+ }
}
-
+
void URLFetcher::stop() {
- tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
- if (_isStarted) {
- _isStarted = false;
- _thread->join();
- delete _thread;
- }
+ tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
+ if (_isStarted) {
+ _isStarted = false;
+ _thread->join();
+ delete _thread;
+ }
}
void URLFetcher::run(void* instance) {
- URLFetcher* fetcher = (URLFetcher*)instance;
- while(fetcher->_isStarted) {
- fetcher->perform();
- }
- LOG(ERROR) << "URLFetcher thread stopped!";
+ URLFetcher* fetcher = (URLFetcher*)instance;
+ while(fetcher->_isStarted) {
+ fetcher->perform();
+ }
+ LOG(ERROR) << "URLFetcher thread stopped!";
}
-
+
void URLFetcher::perform() {
- CURLMsg *msg; /* for picking up messages with the transfer status */
- int msgsLeft; /* how many messages are left */
- int stillRunning;
-
- {
- tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
- if (_handlesToURLs.empty()) {
- std::cout << "Waiting for work" << std::endl;
- _condVar.wait(_mutex);
- }
- curl_multi_perform(_multiHandle, &stillRunning);
- }
-
- do {
- struct timeval timeout;
- int rc; /* select() return code */
-
- fd_set fdread, fdwrite, fdexcep;
- FD_ZERO(&fdread); FD_ZERO(&fdwrite); FD_ZERO(&fdexcep);
-
- int maxfd = -1;
- long curlTimeOut = -1;
-
- /* set a suitable timeout to play around with */
- timeout.tv_sec = 1;
- timeout.tv_usec = 0;
-
- {
- tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
- curl_multi_timeout(_multiHandle, &curlTimeOut);
- }
-
- if(curlTimeOut >= 0) {
- timeout.tv_sec = curlTimeOut / 1000;
- if(timeout.tv_sec > 1)
- timeout.tv_sec = 1;
- else
- timeout.tv_usec = (curlTimeOut % 1000) * 1000;
- }
-
- /* get file descriptors from the transfers */
- {
- tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
- curl_multi_fdset(_multiHandle, &fdread, &fdwrite, &fdexcep, &maxfd);
- }
-
- rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
-
- switch(rc) {
- case -1:
- /* select error */
- break;
- case 0: /* timeout */
- default: /* action */
- {
- tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
- curl_multi_perform(_multiHandle, &stillRunning);
- }
- break;
- }
-
- {
- tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
- while ((msg = curl_multi_info_read(_multiHandle, &msgsLeft))) {
- if (msg->msg == CURLMSG_DONE) {
- switch (msg->data.result) {
- case CURLM_OK:
- _handlesToURLs[msg->easy_handle].downloadCompleted();
- curl_multi_remove_handle(_multiHandle, msg->easy_handle);
- _handlesToURLs.erase(msg->easy_handle);
- break;
- case CURLM_BAD_HANDLE:
- case CURLM_BAD_EASY_HANDLE:
- case CURLM_OUT_OF_MEMORY:
- case CURLM_INTERNAL_ERROR:
- case CURLM_BAD_SOCKET:
- case CURLM_UNKNOWN_OPTION:
- case CURLM_LAST:
- _handlesToURLs[msg->easy_handle].downloadFailed(msg->data.result);
- curl_multi_remove_handle(_multiHandle, msg->easy_handle);
- _handlesToURLs.erase(msg->easy_handle);
- default:
- break;
- }
- } else {
- LOG(ERROR) << "Curl reports info on unfinished download?!";
- }
- }
- }
- } while(stillRunning && _isStarted);
+ CURLMsg *msg; /* for picking up messages with the transfer status */
+ int msgsLeft; /* how many messages are left */
+ int stillRunning;
+
+ {
+ tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
+ if (_handlesToURLs.empty()) {
+ std::cout << "Waiting for work" << std::endl;
+ _condVar.wait(_mutex);
+ }
+ curl_multi_perform(_multiHandle, &stillRunning);
+ }
+
+ do {
+ struct timeval timeout;
+ int rc; /* select() return code */
+
+ fd_set fdread, fdwrite, fdexcep;
+ FD_ZERO(&fdread);
+ FD_ZERO(&fdwrite);
+ FD_ZERO(&fdexcep);
+
+ int maxfd = -1;
+ long curlTimeOut = -1;
+
+ /* set a suitable timeout to play around with */
+ timeout.tv_sec = 1;
+ timeout.tv_usec = 0;
+
+ {
+ tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
+ curl_multi_timeout(_multiHandle, &curlTimeOut);
+ }
+
+ if(curlTimeOut >= 0) {
+ timeout.tv_sec = curlTimeOut / 1000;
+ if(timeout.tv_sec > 1)
+ timeout.tv_sec = 1;
+ else
+ timeout.tv_usec = (curlTimeOut % 1000) * 1000;
+ }
+
+ /* get file descriptors from the transfers */
+ {
+ tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
+ curl_multi_fdset(_multiHandle, &fdread, &fdwrite, &fdexcep, &maxfd);
+ }
+
+ rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
+
+ switch(rc) {
+ case -1:
+ /* select error */
+ break;
+ case 0: /* timeout */
+ default: { /* action */
+ tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
+ curl_multi_perform(_multiHandle, &stillRunning);
+ }
+ break;
+ }
+
+ {
+ tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
+ while ((msg = curl_multi_info_read(_multiHandle, &msgsLeft))) {
+ if (msg->msg == CURLMSG_DONE) {
+ switch (msg->data.result) {
+ case CURLM_OK:
+ _handlesToURLs[msg->easy_handle].downloadCompleted();
+ curl_multi_remove_handle(_multiHandle, msg->easy_handle);
+ _handlesToURLs.erase(msg->easy_handle);
+ break;
+ case CURLM_BAD_HANDLE:
+ case CURLM_BAD_EASY_HANDLE:
+ case CURLM_OUT_OF_MEMORY:
+ case CURLM_INTERNAL_ERROR:
+ case CURLM_BAD_SOCKET:
+ case CURLM_UNKNOWN_OPTION:
+ case CURLM_LAST:
+ _handlesToURLs[msg->easy_handle].downloadFailed(msg->data.result);
+ curl_multi_remove_handle(_multiHandle, msg->easy_handle);
+ _handlesToURLs.erase(msg->easy_handle);
+ default:
+ break;
+ }
+ } else {
+ LOG(ERROR) << "Curl reports info on unfinished download?!";
+ }
+ }
+ }
+ } while(stillRunning && _isStarted);
}
URLFetcher* URLFetcher::_instance = NULL;
URLFetcher* URLFetcher::getInstance() {
- if (_instance == NULL) {
+ if (_instance == NULL) {
_instance = new URLFetcher();
}
return _instance;
diff --git a/src/uscxml/URL.h b/src/uscxml/URL.h
index 0858626..df93e60 100644
--- a/src/uscxml/URL.h
+++ b/src/uscxml/URL.h
@@ -21,86 +21,110 @@ class URL;
class URLMonitor {
public:
- virtual void downloadStarted(const URL& url) {};
- virtual void downloadCompleted(const URL& url) {};
- virtual void downloadFailed(const URL& url, int errorCode) {};
- virtual void headerChunkReceived(const URL& url, const std::string& headerChunk) {};
- virtual void contentChunkReceived(const URL& url, const std::string& contentChunk) {};
+ virtual void downloadStarted(const URL& url) {};
+ virtual void downloadCompleted(const URL& url) {};
+ virtual void downloadFailed(const URL& url, int errorCode) {};
+ virtual void headerChunkReceived(const URL& url, const std::string& headerChunk) {};
+ virtual void contentChunkReceived(const URL& url, const std::string& contentChunk) {};
};
class URLImpl : public boost::enable_shared_from_this<URLImpl> {
public:
URLImpl(const std::string& url);
~URLImpl();
- static boost::shared_ptr<URLImpl> toLocalFile(const std::string& content, const std::string& suffix);
-
+ static boost::shared_ptr<URLImpl> toLocalFile(const std::string& content, const std::string& suffix);
+
static size_t writeHandler(void *ptr, size_t size, size_t nmemb, void *userdata);
static size_t headerHandler(void *ptr, size_t size, size_t nmemb, void *userdata);
- void addMonitor(URLMonitor* monitor) { _monitors.insert(monitor); }
- void removeMonitor(URLMonitor* monitor) { _monitors.erase(monitor); }
-
- const bool isAbsolute() const { return _uri.is_absolute(); }
- const std::string scheme() const { return _uri.scheme(); }
- const std::string host() const { return _uri.host(); }
- const std::string port() const { return _uri.port(); }
- const std::string path() const { return _uri.path(); }
- const std::string asString() const { return _uri.as_string(); }
-
- const bool toAbsoluteCwd();
+ void addMonitor(URLMonitor* monitor) {
+ _monitors.insert(monitor);
+ }
+ void removeMonitor(URLMonitor* monitor) {
+ _monitors.erase(monitor);
+ }
+
+ const bool isAbsolute() const {
+ return _uri.is_absolute();
+ }
+ const std::string scheme() const {
+ return _uri.scheme();
+ }
+ const std::string host() const {
+ return _uri.host();
+ }
+ const std::string port() const {
+ return _uri.port();
+ }
+ const std::string path() const {
+ return _uri.path();
+ }
+ const std::string asString() const {
+ return _uri.as_string();
+ }
+
+ const bool toAbsoluteCwd();
const bool toAbsolute(const std::string& baseUrl);
const std::string asLocalFile(const std::string& suffix, bool reload = false);
- void addOutHeader(const std::string& key, const std::string& value) { _outHeader[key] = value; }
- void setOutContent(const std::string& content);
- void setRequestType(const std::string& requestType);
-
- const std::map<std::string, std::string> getInHeaderFields();
+ void addOutHeader(const std::string& key, const std::string& value) {
+ _outHeader[key] = value;
+ }
+ void setOutContent(const std::string& content);
+ void setRequestType(const std::string& requestType);
+
+ const std::map<std::string, std::string> getInHeaderFields();
const std::string getInContent(bool forceReload = false);
- const void download(bool blocking = false);
-
- void downloadStarted();
- void downloadCompleted();
- void downloadFailed(int errorCode);
+ const void download(bool blocking = false);
- friend class URLFetcher;
+ void downloadStarted();
+ void downloadCompleted();
+ void downloadFailed(int errorCode);
+
+ friend class URLFetcher;
protected:
URLImpl() : _handle(NULL), _isDownloaded(false), _hasFailed(false) {}
std::string getLocalFilename(const std::string& suffix);
- std::string _outContent;
- std::map<std::string, std::string> _outHeader;
- std::string _requestType;
+ std::string _outContent;
+ std::map<std::string, std::string> _outHeader;
+ std::string _requestType;
+
+ CURL* _handle;
+ std::stringstream _inContent;
+ std::stringstream _inHeader;
- CURL* _handle;
- std::stringstream _inContent;
- std::stringstream _inHeader;
+ Arabica::io::URI _uri;
+ bool _isDownloaded;
+ bool _hasFailed;
- Arabica::io::URI _uri;
- bool _isDownloaded;
- bool _hasFailed;
+ std::string _localFile;
- std::string _localFile;
-
- tthread::condition_variable _condVar;
+ tthread::condition_variable _condVar;
tthread::recursive_mutex _mutex;
- std::set<URLMonitor*> _monitors;
- typedef std::set<URLMonitor*>::iterator monIter_t;
+ std::set<URLMonitor*> _monitors;
+ typedef std::set<URLMonitor*>::iterator monIter_t;
};
class URL {
-public:
+public:
URL() : _impl() {}
URL(const std::string url) : _impl(new URLImpl(url)) {}
URL(boost::shared_ptr<URLImpl> const impl) : _impl(impl) { }
URL(const URL& other) : _impl(other._impl) { }
virtual ~URL() {};
-
- operator bool() const { return _impl; }
- bool operator< (const URL& other) const { return _impl < other._impl; }
- bool operator==(const URL& other) const { return _impl == other._impl; }
+
+ operator bool() const {
+ return _impl;
+ }
+ bool operator< (const URL& other) const {
+ return _impl < other._impl;
+ }
+ bool operator==(const URL& other) const {
+ return _impl == other._impl;
+ }
bool operator!=(const URL& other) const {
return _impl != other._impl;
}
@@ -109,41 +133,83 @@ public:
return *this;
}
- const std::map<std::string, std::string> getInHeaderFields() const { return _impl->getInHeaderFields(); }
- const std::string getInContent() const { return _impl->getInContent(); }
- const void download(bool blocking = false) const { return _impl->download(blocking); }
-
- void addOutHeader(const std::string& key, const std::string& value) { _impl->addOutHeader(key, value); }
- void setRequestType(const std::string& requestType) { _impl->setRequestType(requestType); }
- void setOutContent(const std::string& content) { _impl->setOutContent(content); }
-
- const bool toAbsoluteCwd() { return _impl->toAbsoluteCwd(); }
- const bool toAbsolute(const std::string& baseUrl) { return _impl->toAbsolute(baseUrl); }
- const bool toAbsolute(const URL& baseUrl) { return _impl->toAbsolute(baseUrl.asString()); }
- const std::string asLocalFile(const std::string& suffix, bool reload = false) { return _impl->asLocalFile(suffix, reload); }
-
- static URL toLocalFile(const std::string& content, const std::string& suffix) {
- boost::shared_ptr<URLImpl> impl = URLImpl::toLocalFile(content, suffix);
- return URL(impl);
- }
-
- void addMonitor(URLMonitor* monitor) { _impl->addMonitor(monitor); }
- void removeMonitor(URLMonitor* monitor) { _impl->removeMonitor(monitor); }
-
- const bool isAbsolute() const { return _impl->isAbsolute(); }
- const std::string scheme() const { return _impl->scheme(); }
- const std::string host() const { return _impl->host(); }
- const std::string port() const { return _impl->port(); }
- const std::string path() const { return _impl->path(); }
- const std::string asString() const { return _impl->asString(); }
-
- friend class URLFetcher;
+ const std::map<std::string, std::string> getInHeaderFields() const {
+ return _impl->getInHeaderFields();
+ }
+ const std::string getInContent() const {
+ return _impl->getInContent();
+ }
+ const void download(bool blocking = false) const {
+ return _impl->download(blocking);
+ }
+
+ void addOutHeader(const std::string& key, const std::string& value) {
+ _impl->addOutHeader(key, value);
+ }
+ void setRequestType(const std::string& requestType) {
+ _impl->setRequestType(requestType);
+ }
+ void setOutContent(const std::string& content) {
+ _impl->setOutContent(content);
+ }
+
+ const bool toAbsoluteCwd() {
+ return _impl->toAbsoluteCwd();
+ }
+ const bool toAbsolute(const std::string& baseUrl) {
+ return _impl->toAbsolute(baseUrl);
+ }
+ const bool toAbsolute(const URL& baseUrl) {
+ return _impl->toAbsolute(baseUrl.asString());
+ }
+ const std::string asLocalFile(const std::string& suffix, bool reload = false) {
+ return _impl->asLocalFile(suffix, reload);
+ }
+
+ static URL toLocalFile(const std::string& content, const std::string& suffix) {
+ boost::shared_ptr<URLImpl> impl = URLImpl::toLocalFile(content, suffix);
+ return URL(impl);
+ }
+
+ void addMonitor(URLMonitor* monitor) {
+ _impl->addMonitor(monitor);
+ }
+ void removeMonitor(URLMonitor* monitor) {
+ _impl->removeMonitor(monitor);
+ }
+
+ const bool isAbsolute() const {
+ return _impl->isAbsolute();
+ }
+ const std::string scheme() const {
+ return _impl->scheme();
+ }
+ const std::string host() const {
+ return _impl->host();
+ }
+ const std::string port() const {
+ return _impl->port();
+ }
+ const std::string path() const {
+ return _impl->path();
+ }
+ const std::string asString() const {
+ return _impl->asString();
+ }
+
+ friend class URLFetcher;
friend std::ostream & operator<<(std::ostream &stream, const URL& p);
protected:
- void downloadStarted() { return _impl->downloadStarted(); }
- void downloadCompleted() { return _impl->downloadCompleted(); }
- void downloadFailed(int errorCode) { return _impl->downloadFailed(errorCode); }
+ void downloadStarted() {
+ return _impl->downloadStarted();
+ }
+ void downloadCompleted() {
+ return _impl->downloadCompleted();
+ }
+ void downloadFailed(int errorCode) {
+ return _impl->downloadFailed(errorCode);
+ }
boost::shared_ptr<URLImpl> _impl;
};
@@ -152,7 +218,7 @@ class URLFetcher {
public:
URLFetcher();
~URLFetcher();
-
+
static void fetchURL(URL& url);
static void breakURL(URL& url);
@@ -160,19 +226,19 @@ public:
void stop();
protected:
- static URLFetcher* _instance;
- static URLFetcher* getInstance();
-
+ static URLFetcher* _instance;
+ static URLFetcher* getInstance();
+
static void run(void* instance);
void perform();
-
- tthread::thread* _thread;
- tthread::condition_variable _condVar;
+
+ tthread::thread* _thread;
+ tthread::condition_variable _condVar;
tthread::recursive_mutex _mutex;
- bool _isStarted;
-
- std::map<CURL*, URL> _handlesToURLs;
- CURLM* _multiHandle;
+ bool _isStarted;
+
+ std::map<CURL*, URL> _handlesToURLs;
+ CURLM* _multiHandle;
};
}
diff --git a/src/uscxml/concurrency/eventqueue/DelayedEventQueue.cpp b/src/uscxml/concurrency/eventqueue/DelayedEventQueue.cpp
index c4eb0f9..950c7c6 100644
--- a/src/uscxml/concurrency/eventqueue/DelayedEventQueue.cpp
+++ b/src/uscxml/concurrency/eventqueue/DelayedEventQueue.cpp
@@ -12,7 +12,7 @@ DelayedEventQueue::DelayedEventQueue() {
#endif
_eventLoop = event_base_new();
_thread = NULL;
- _isStarted = false;
+ _isStarted = false;
}
DelayedEventQueue::~DelayedEventQueue() {
diff --git a/src/uscxml/concurrency/eventqueue/DelayedEventQueue.h b/src/uscxml/concurrency/eventqueue/DelayedEventQueue.h
index fc00ec0..7ce766b 100644
--- a/src/uscxml/concurrency/eventqueue/DelayedEventQueue.h
+++ b/src/uscxml/concurrency/eventqueue/DelayedEventQueue.h
@@ -37,10 +37,10 @@ public:
void stop();
static void run(void*);
- bool isEmpty() {
- return _callbackData.empty();
- }
-
+ bool isEmpty() {
+ return _callbackData.empty();
+ }
+
static void timerCallback(evutil_socket_t fd, short what, void *arg);
static void dummyCallback(evutil_socket_t fd, short what, void *arg);
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp
index c190e3b..dfa8585 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp
@@ -111,13 +111,13 @@ void V8DataModel::setEvent(const Event& event) {
v8::Handle<v8::Object> global = _contexts.front()->Global();
v8::Handle<v8::Function> eventCtor = Arabica::DOM::V8SCXMLEvent::getTmpl()->GetFunction();
- v8::Persistent<v8::Object> eventObj = v8::Persistent<v8::Object>::New(eventCtor->NewInstance());
+ v8::Persistent<v8::Object> eventObj = v8::Persistent<v8::Object>::New(eventCtor->NewInstance());
Arabica::DOM::V8SCXMLEvent::V8SCXMLEventPrivate* privData = new Arabica::DOM::V8SCXMLEvent::V8SCXMLEventPrivate();
privData->nativeObj = new Event(event);
privData->dom = _dom;
eventObj->SetInternalField(0, Arabica::DOM::V8DOM::toExternal(privData));
- eventObj.MakeWeak(0, Arabica::DOM::V8SCXMLEvent::jsDestructor);
+ eventObj.MakeWeak(0, Arabica::DOM::V8SCXMLEvent::jsDestructor);
eventObj->Set(v8::String::New("data"), getDataAsValue(event.data)); // set data part of _event
global->Set(v8::String::New("_event"), eventObj);
@@ -185,7 +185,7 @@ Data V8DataModel::getValueAsData(const v8::Handle<v8::Value>& value) {
} else if(value->IsUint32()) {
LOG(ERROR) << "IsUint32 is unimplemented" << std::endl;
} else if(value->IsUndefined()) {
- data.atom = "undefined";
+ data.atom = "undefined";
}
return data;
}
@@ -271,10 +271,10 @@ std::string V8DataModel::evalAsString(const std::string& expr) {
v8::HandleScope handleScope;
v8::Context::Scope contextScope(_contexts.back());
v8::Handle<v8::Value> result = evalAsValue(expr);
- if (result->IsObject()) {
- Data data = getValueAsData(result);
- return toStr(data);
- }
+ if (result->IsObject()) {
+ Data data = getValueAsData(result);
+ return toStr(data);
+ }
v8::String::AsciiValue data(result->ToString());
return std::string(*data);
}
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Attr.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Attr.cpp
index d16f81b..bee6042 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;
-
- arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
- arbaicaRetObj.MakeWeak(0, V8Element::jsDestructor);
- return arbaicaRetObj;
+ struct V8Element::V8ElementPrivate* retPrivData = new V8Element::V8ElementPrivate();
+ retPrivData->dom = privData->dom;
+ retPrivData->nativeObj = arbaicaRet;
- }
- bool V8Attr::hasInstance(v8::Handle<v8::Value> value) {
- return getTmpl()->HasInstance(value);
- }
+ 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);
+}
+
+}
+}
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Attr.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Attr.h
index e317698..9829023 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 90495f4..a9e5ac9 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 f9767a0..3b95b84 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
-
- instance->SetInternalFieldCount(1);
+ v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate();
+ v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate();
+ (void)prototype; // surpress unused warnings
+ 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 74c80ea..459cf96 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 fe93896..6c51ca7 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 e470a70..f754ea7 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 c659150..074da74 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
-
- instance->SetInternalFieldCount(1);
+ v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate();
+ v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate();
+ (void)prototype; // surpress unused warnings
+ 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 0f81958..f7a7575 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 6fb8c7e..5c58e22 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
-
- instance->SetInternalFieldCount(1);
+ v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate();
+ v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate();
+ (void)prototype; // surpress unused warnings
+ 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 d9d123a..06191ea 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;
-
- arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
- arbaicaRetObj.MakeWeak(0, V8DocumentType::jsDestructor);
- return arbaicaRetObj;
+ 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;
- 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());
+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::Function> arbaicaRetCtor = V8DOMImplementation::getTmpl()->GetFunction();
- v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance());
+ if (!privData->nativeObj->getImplementation()) return v8::Undefined();
+ Arabica::DOM::DOMImplementation<std::string>* arbaicaRet = new Arabica::DOM::DOMImplementation<std::string>(privData->nativeObj->getImplementation());
- 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::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;
- 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));
+ arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
+ arbaicaRetObj.MakeWeak(0, V8DOMImplementation::jsDestructor);
+ return arbaicaRetObj;
- 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::Function> arbaicaRetCtor = V8Element::getTmpl()->GetFunction();
- v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance());
+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));
- 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;
+ 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::createElementCallback(const v8::Arguments& args) {
- if (args.Length() < 1)
- throw V8Exception("Wrong number of arguments in createElement");
+ v8::Handle<v8::Function> arbaicaRetCtor = V8Element::getTmpl()->GetFunction();
+ v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance());
- v8::Local<v8::Object> self = args.Holder();
- struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0));
- v8::String::AsciiValue localTagName(args[0]);
+ struct V8Element::V8ElementPrivate* retPrivData = new V8Element::V8ElementPrivate();
+ retPrivData->dom = privData->dom;
+ retPrivData->nativeObj = arbaicaRet;
- 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());
+ arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
+ arbaicaRetObj.MakeWeak(0, V8Element::jsDestructor);
+ return arbaicaRetObj;
- struct V8Element::V8ElementPrivate* retPrivData = new V8Element::V8ElementPrivate();
- retPrivData->dom = privData->dom;
- retPrivData->nativeObj = retVal;
+}
+v8::Handle<v8::Value> V8Document::createElementCallback(const v8::Arguments& args) {
+ if (args.Length() < 1)
+ throw V8Exception("Wrong number of arguments in createElement");
- retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
+ v8::Local<v8::Object> self = args.Holder();
+ struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0));
+ v8::String::AsciiValue localTagName(args[0]);
- retObj.MakeWeak(0, V8Element::jsDestructor);
- return retObj;
+ 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());
- }
+ struct V8Element::V8ElementPrivate* retPrivData = new V8Element::V8ElementPrivate();
+ retPrivData->dom = privData->dom;
+ retPrivData->nativeObj = retVal;
- v8::Handle<v8::Value> V8Document::createDocumentFragmentCallback(const v8::Arguments& args) {
+ retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
- v8::Local<v8::Object> self = args.Holder();
- struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0));
+ retObj.MakeWeak(0, V8Element::jsDestructor);
+ return retObj;
- 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());
+}
- struct V8DocumentFragment::V8DocumentFragmentPrivate* retPrivData = new V8DocumentFragment::V8DocumentFragmentPrivate();
- retPrivData->dom = privData->dom;
- retPrivData->nativeObj = retVal;
+v8::Handle<v8::Value> V8Document::createDocumentFragmentCallback(const v8::Arguments& args) {
- retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
+ v8::Local<v8::Object> self = args.Holder();
+ struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0));
- retObj.MakeWeak(0, V8DocumentFragment::jsDestructor);
- return retObj;
+ 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());
- }
+ struct V8DocumentFragment::V8DocumentFragmentPrivate* retPrivData = new V8DocumentFragment::V8DocumentFragmentPrivate();
+ retPrivData->dom = privData->dom;
+ retPrivData->nativeObj = retVal;
- v8::Handle<v8::Value> V8Document::createTextNodeCallback(const v8::Arguments& args) {
- if (args.Length() < 1)
- throw V8Exception("Wrong number of arguments in createTextNode");
+ retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
- v8::Local<v8::Object> self = args.Holder();
- struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0));
- v8::String::AsciiValue localData(args[0]);
+ retObj.MakeWeak(0, V8DocumentFragment::jsDestructor);
+ return retObj;
- 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());
+}
- struct V8Text::V8TextPrivate* retPrivData = new V8Text::V8TextPrivate();
- retPrivData->dom = privData->dom;
- retPrivData->nativeObj = retVal;
+v8::Handle<v8::Value> V8Document::createTextNodeCallback(const v8::Arguments& args) {
+ if (args.Length() < 1)
+ throw V8Exception("Wrong number of arguments in createTextNode");
- retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
+ v8::Local<v8::Object> self = args.Holder();
+ struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0));
+ v8::String::AsciiValue localData(args[0]);
- retObj.MakeWeak(0, V8Text::jsDestructor);
- return retObj;
+ 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());
- }
+ struct V8Text::V8TextPrivate* retPrivData = new V8Text::V8TextPrivate();
+ retPrivData->dom = privData->dom;
+ retPrivData->nativeObj = retVal;
- v8::Handle<v8::Value> V8Document::createCommentCallback(const v8::Arguments& args) {
- if (args.Length() < 1)
- throw V8Exception("Wrong number of arguments in createComment");
+ retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
- v8::Local<v8::Object> self = args.Holder();
- struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0));
- v8::String::AsciiValue localData(args[0]);
+ retObj.MakeWeak(0, V8Text::jsDestructor);
+ return retObj;
- 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());
+}
- struct V8Comment::V8CommentPrivate* retPrivData = new V8Comment::V8CommentPrivate();
- retPrivData->dom = privData->dom;
- retPrivData->nativeObj = retVal;
+v8::Handle<v8::Value> V8Document::createCommentCallback(const v8::Arguments& args) {
+ if (args.Length() < 1)
+ throw V8Exception("Wrong number of arguments in createComment");
- retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
+ v8::Local<v8::Object> self = args.Holder();
+ struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0));
+ v8::String::AsciiValue localData(args[0]);
- retObj.MakeWeak(0, V8Comment::jsDestructor);
- return retObj;
+ 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());
- }
+ struct V8Comment::V8CommentPrivate* retPrivData = new V8Comment::V8CommentPrivate();
+ retPrivData->dom = privData->dom;
+ retPrivData->nativeObj = retVal;
- v8::Handle<v8::Value> V8Document::createCDATASectionCallback(const v8::Arguments& args) {
- if (args.Length() < 1)
- throw V8Exception("Wrong number of arguments in createCDATASection");
+ retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
- v8::Local<v8::Object> self = args.Holder();
- struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0));
- v8::String::AsciiValue localData(args[0]);
+ retObj.MakeWeak(0, V8Comment::jsDestructor);
+ return retObj;
- 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());
+}
- struct V8CDATASection::V8CDATASectionPrivate* retPrivData = new V8CDATASection::V8CDATASectionPrivate();
- retPrivData->dom = privData->dom;
- retPrivData->nativeObj = retVal;
+v8::Handle<v8::Value> V8Document::createCDATASectionCallback(const v8::Arguments& args) {
+ if (args.Length() < 1)
+ throw V8Exception("Wrong number of arguments in createCDATASection");
- retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
+ v8::Local<v8::Object> self = args.Holder();
+ struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0));
+ v8::String::AsciiValue localData(args[0]);
- retObj.MakeWeak(0, V8CDATASection::jsDestructor);
- return retObj;
+ 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());
- }
+ struct V8CDATASection::V8CDATASectionPrivate* retPrivData = new V8CDATASection::V8CDATASectionPrivate();
+ retPrivData->dom = privData->dom;
+ retPrivData->nativeObj = retVal;
- v8::Handle<v8::Value> V8Document::createProcessingInstructionCallback(const v8::Arguments& args) {
- if (args.Length() < 2)
- throw V8Exception("Wrong number of arguments in createProcessingInstruction");
+ retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
- 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.MakeWeak(0, V8CDATASection::jsDestructor);
+ return retObj;
- 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());
+}
- struct V8ProcessingInstruction::V8ProcessingInstructionPrivate* retPrivData = new V8ProcessingInstruction::V8ProcessingInstructionPrivate();
- retPrivData->dom = privData->dom;
- retPrivData->nativeObj = retVal;
+v8::Handle<v8::Value> V8Document::createProcessingInstructionCallback(const v8::Arguments& args) {
+ if (args.Length() < 2)
+ throw V8Exception("Wrong number of arguments in createProcessingInstruction");
- retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
+ 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.MakeWeak(0, V8ProcessingInstruction::jsDestructor);
- return retObj;
+ 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());
- }
+ struct V8ProcessingInstruction::V8ProcessingInstructionPrivate* retPrivData = new V8ProcessingInstruction::V8ProcessingInstructionPrivate();
+ retPrivData->dom = privData->dom;
+ retPrivData->nativeObj = retVal;
- v8::Handle<v8::Value> V8Document::createAttributeCallback(const v8::Arguments& args) {
- if (args.Length() < 1)
- throw V8Exception("Wrong number of arguments in createAttribute");
+ retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
- v8::Local<v8::Object> self = args.Holder();
- struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0));
- v8::String::AsciiValue localName(args[0]);
+ retObj.MakeWeak(0, V8ProcessingInstruction::jsDestructor);
+ return retObj;
- 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());
+}
- struct V8Attr::V8AttrPrivate* retPrivData = new V8Attr::V8AttrPrivate();
- retPrivData->dom = privData->dom;
- retPrivData->nativeObj = retVal;
+v8::Handle<v8::Value> V8Document::createAttributeCallback(const v8::Arguments& args) {
+ if (args.Length() < 1)
+ throw V8Exception("Wrong number of arguments in createAttribute");
- retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
+ v8::Local<v8::Object> self = args.Holder();
+ struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0));
+ v8::String::AsciiValue localName(args[0]);
- retObj.MakeWeak(0, V8Attr::jsDestructor);
- return retObj;
+ 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());
- }
+ struct V8Attr::V8AttrPrivate* retPrivData = new V8Attr::V8AttrPrivate();
+ retPrivData->dom = privData->dom;
+ retPrivData->nativeObj = retVal;
- v8::Handle<v8::Value> V8Document::createEntityReferenceCallback(const v8::Arguments& args) {
- if (args.Length() < 1)
- throw V8Exception("Wrong number of arguments in createEntityReference");
+ retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
- v8::Local<v8::Object> self = args.Holder();
- struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0));
- v8::String::AsciiValue localName(args[0]);
+ retObj.MakeWeak(0, V8Attr::jsDestructor);
+ return retObj;
- 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());
+}
- struct V8EntityReference::V8EntityReferencePrivate* retPrivData = new V8EntityReference::V8EntityReferencePrivate();
- retPrivData->dom = privData->dom;
- retPrivData->nativeObj = retVal;
+v8::Handle<v8::Value> V8Document::createEntityReferenceCallback(const v8::Arguments& args) {
+ if (args.Length() < 1)
+ throw V8Exception("Wrong number of arguments in createEntityReference");
- retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
+ v8::Local<v8::Object> self = args.Holder();
+ struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0));
+ v8::String::AsciiValue localName(args[0]);
- retObj.MakeWeak(0, V8EntityReference::jsDestructor);
- return retObj;
+ 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());
- }
+ struct V8EntityReference::V8EntityReferencePrivate* retPrivData = new V8EntityReference::V8EntityReferencePrivate();
+ retPrivData->dom = privData->dom;
+ retPrivData->nativeObj = retVal;
- v8::Handle<v8::Value> V8Document::getElementsByTagNameCallback(const v8::Arguments& args) {
- if (args.Length() < 1)
- throw V8Exception("Wrong number of arguments in getElementsByTagName");
+ retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
- v8::Local<v8::Object> self = args.Holder();
- struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0));
- v8::String::AsciiValue localTagname(args[0]);
+ retObj.MakeWeak(0, V8EntityReference::jsDestructor);
+ return retObj;
- 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());
+}
- struct V8NodeList::V8NodeListPrivate* retPrivData = new V8NodeList::V8NodeListPrivate();
- retPrivData->dom = privData->dom;
- retPrivData->nativeObj = retVal;
+v8::Handle<v8::Value> V8Document::getElementsByTagNameCallback(const v8::Arguments& args) {
+ if (args.Length() < 1)
+ throw V8Exception("Wrong number of arguments in getElementsByTagName");
- retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
+ v8::Local<v8::Object> self = args.Holder();
+ struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0));
+ v8::String::AsciiValue localTagname(args[0]);
- retObj.MakeWeak(0, V8NodeList::jsDestructor);
- return retObj;
+ 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());
- }
+ struct V8NodeList::V8NodeListPrivate* retPrivData = new V8NodeList::V8NodeListPrivate();
+ retPrivData->dom = privData->dom;
+ retPrivData->nativeObj = retVal;
- 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->SetInternalField(0, V8DOM::toExternal(retPrivData));
- 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.MakeWeak(0, V8NodeList::jsDestructor);
+ return retObj;
- 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());
+}
- struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate();
- retPrivData->dom = privData->dom;
- retPrivData->nativeObj = retVal;
+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->SetInternalField(0, V8DOM::toExternal(retPrivData));
+ 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.MakeWeak(0, V8Node::jsDestructor);
- return retObj;
+ 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());
- }
+ struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate();
+ retPrivData->dom = privData->dom;
+ retPrivData->nativeObj = retVal;
- v8::Handle<v8::Value> V8Document::createElementNSCallback(const v8::Arguments& args) {
- if (args.Length() < 2)
- throw V8Exception("Wrong number of arguments in createElementNS");
+ retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
- 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.MakeWeak(0, V8Node::jsDestructor);
+ return retObj;
- 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());
+}
- struct V8Element::V8ElementPrivate* retPrivData = new V8Element::V8ElementPrivate();
- retPrivData->dom = privData->dom;
- retPrivData->nativeObj = retVal;
+v8::Handle<v8::Value> V8Document::createElementNSCallback(const v8::Arguments& args) {
+ if (args.Length() < 2)
+ throw V8Exception("Wrong number of arguments in createElementNS");
- retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
+ 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.MakeWeak(0, V8Element::jsDestructor);
- return retObj;
+ 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());
- }
+ struct V8Element::V8ElementPrivate* retPrivData = new V8Element::V8ElementPrivate();
+ retPrivData->dom = privData->dom;
+ retPrivData->nativeObj = retVal;
- v8::Handle<v8::Value> V8Document::createAttributeNSCallback(const v8::Arguments& args) {
- if (args.Length() < 2)
- throw V8Exception("Wrong number of arguments in createAttributeNS");
+ retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
- 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.MakeWeak(0, V8Element::jsDestructor);
+ return retObj;
- 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());
+}
- struct V8Attr::V8AttrPrivate* retPrivData = new V8Attr::V8AttrPrivate();
- retPrivData->dom = privData->dom;
- retPrivData->nativeObj = retVal;
+v8::Handle<v8::Value> V8Document::createAttributeNSCallback(const v8::Arguments& args) {
+ if (args.Length() < 2)
+ throw V8Exception("Wrong number of arguments in createAttributeNS");
- retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
+ 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.MakeWeak(0, V8Attr::jsDestructor);
- return retObj;
+ 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());
- }
+ struct V8Attr::V8AttrPrivate* retPrivData = new V8Attr::V8AttrPrivate();
+ retPrivData->dom = privData->dom;
+ retPrivData->nativeObj = retVal;
- v8::Handle<v8::Value> V8Document::getElementsByTagNameNSCallback(const v8::Arguments& args) {
- if (args.Length() < 2)
- throw V8Exception("Wrong number of arguments in getElementsByTagNameNS");
+ retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
- 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.MakeWeak(0, V8Attr::jsDestructor);
+ return retObj;
- 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;
+v8::Handle<v8::Value> V8Document::getElementsByTagNameNSCallback(const v8::Arguments& args) {
+ if (args.Length() < 2)
+ throw V8Exception("Wrong number of arguments in getElementsByTagNameNS");
- retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
+ 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.MakeWeak(0, V8NodeList::jsDestructor);
- return retObj;
+ 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;
- v8::Handle<v8::Value> V8Document::getElementByIdCallback(const v8::Arguments& args) {
- if (args.Length() < 1)
- throw V8Exception("Wrong number of arguments in getElementById");
+ retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
- v8::Local<v8::Object> self = args.Holder();
- struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0));
- v8::String::AsciiValue localElementId(args[0]);
+ retObj.MakeWeak(0, V8NodeList::jsDestructor);
+ return retObj;
- 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());
+}
- struct V8Element::V8ElementPrivate* retPrivData = new V8Element::V8ElementPrivate();
- retPrivData->dom = privData->dom;
- retPrivData->nativeObj = retVal;
+v8::Handle<v8::Value> V8Document::getElementByIdCallback(const v8::Arguments& args) {
+ if (args.Length() < 1)
+ throw V8Exception("Wrong number of arguments in getElementById");
- retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
+ v8::Local<v8::Object> self = args.Holder();
+ struct V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0));
+ v8::String::AsciiValue localElementId(args[0]);
- retObj.MakeWeak(0, V8Element::jsDestructor);
- return retObj;
+ 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());
- }
+ struct V8Element::V8ElementPrivate* retPrivData = new V8Element::V8ElementPrivate();
+ retPrivData->dom = privData->dom;
+ retPrivData->nativeObj = retVal;
- bool V8Document::hasInstance(v8::Handle<v8::Value> value) {
- return getTmpl()->HasInstance(value);
- }
+ retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
-}
-}
+ 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 c12e0dc..2db4b54 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 e6bec84..1403574 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 cf7f6ba..c669b05 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
-
- instance->SetInternalFieldCount(1);
+ v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate();
+ v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate();
+ (void)prototype; // surpress unused warnings
+ 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 a2098f2..6b9a7b0 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());
- v8::Handle<v8::Function> arbaicaRetCtor = V8NamedNodeMap::getTmpl()->GetFunction();
- v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance());
+ Arabica::DOM::NamedNodeMap<std::string>* arbaicaRet = new Arabica::DOM::NamedNodeMap<std::string>(privData->nativeObj->getEntities());
- 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::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;
- 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));
+ 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::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));
- 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::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::Function> arbaicaRetCtor = V8NamedNodeMap::getTmpl()->GetFunction();
+ v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance());
- return v8::String::New(privData->nativeObj->getPublicId().c_str());
- }
+ struct V8NamedNodeMap::V8NamedNodeMapPrivate* retPrivData = new V8NamedNodeMap::V8NamedNodeMapPrivate();
+ retPrivData->dom = privData->dom;
+ retPrivData->nativeObj = arbaicaRet;
- 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));
+ arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
+ arbaicaRetObj.MakeWeak(0, V8NamedNodeMap::jsDestructor);
+ return arbaicaRetObj;
- 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));
+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));
- return v8::String::New(privData->nativeObj->getInternalSubset().c_str());
- }
- bool V8DocumentType::hasInstance(v8::Handle<v8::Value> value) {
- return getTmpl()->HasInstance(value);
- }
+ return v8::String::New(privData->nativeObj->getPublicId().c_str());
+}
-}
-}
+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 65ce30c..59c2607 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 d476daa..680dd5e 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 499ae0e..e5a52bf 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 6db7b15..f3ce21d 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 acea6ea..6e85585 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 95ceee8..197fadd 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 9bfb86d..86dd61b 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
-
- instance->SetInternalFieldCount(1);
+ v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate();
+ v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate();
+ (void)prototype; // surpress unused warnings
+ 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 e09bbb8..037d651 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 a98c5ee..be89037 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 7de50f6..b77f38e 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.cpp
@@ -6,396 +6,396 @@
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;
-
- arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
- arbaicaRetObj.MakeWeak(0, V8Node::jsDestructor);
- return arbaicaRetObj;
+ 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::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::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::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;
-
- arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
- arbaicaRetObj.MakeWeak(0, V8NodeList::jsDestructor);
- return arbaicaRetObj;
+ 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());
- 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 V8NodeList::V8NodeListPrivate* retPrivData = new V8NodeList::V8NodeListPrivate();
+ retPrivData->dom = privData->dom;
+ retPrivData->nativeObj = arbaicaRet;
- if (!privData->nativeObj->getFirstChild()) return v8::Undefined();
- Arabica::DOM::Node<std::string>* arbaicaRet = new Arabica::DOM::Node<std::string>(privData->nativeObj->getFirstChild());
+ arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
+ arbaicaRetObj.MakeWeak(0, V8NodeList::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::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));
- }
+ 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::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::Function> arbaicaRetCtor = V8Node::getTmpl()->GetFunction();
+ v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance());
- if (!privData->nativeObj->getLastChild()) return v8::Undefined();
- Arabica::DOM::Node<std::string>* arbaicaRet = new Arabica::DOM::Node<std::string>(privData->nativeObj->getLastChild());
+ struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate();
+ retPrivData->dom = privData->dom;
+ retPrivData->nativeObj = arbaicaRet;
- v8::Handle<v8::Function> arbaicaRetCtor = V8Node::getTmpl()->GetFunction();
- v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance());
+ arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
+ arbaicaRetObj.MakeWeak(0, V8Node::jsDestructor);
+ return arbaicaRetObj;
- 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::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->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::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));
- }
+ if (!privData->nativeObj->getLastChild()) return v8::Undefined();
+ Arabica::DOM::Node<std::string>* arbaicaRet = new Arabica::DOM::Node<std::string>(privData->nativeObj->getLastChild());
- 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));
+ v8::Handle<v8::Function> arbaicaRetCtor = V8Node::getTmpl()->GetFunction();
+ v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance());
-
- 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;
+ 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::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));
+}
- 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::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));
- v8::Handle<v8::Function> arbaicaRetCtor = V8Document::getTmpl()->GetFunction();
- v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance());
+ if (!privData->nativeObj->getPreviousSibling()) return v8::Undefined();
+ Arabica::DOM::Node<std::string>* arbaicaRet = new Arabica::DOM::Node<std::string>(privData->nativeObj->getPreviousSibling());
- 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;
+ 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::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));
+ arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
+ arbaicaRetObj.MakeWeak(0, V8Node::jsDestructor);
+ return arbaicaRetObj;
- return v8::String::New(privData->nativeObj->getNamespaceURI().c_str());
- }
+}
- 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));
+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));
- return v8::String::New(privData->nativeObj->getPrefix().c_str());
- }
+ if (!privData->nativeObj->getNextSibling()) return v8::Undefined();
+ Arabica::DOM::Node<std::string>* arbaicaRet = new Arabica::DOM::Node<std::string>(privData->nativeObj->getNextSibling());
- 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::Function> arbaicaRetCtor = V8Node::getTmpl()->GetFunction();
+ v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance());
- 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));
+ struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate();
+ retPrivData->dom = privData->dom;
+ retPrivData->nativeObj = arbaicaRet;
- 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");
+ arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
+ arbaicaRetObj.MakeWeak(0, V8Node::jsDestructor);
+ return arbaicaRetObj;
- 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;
+}
- 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());
+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));
- struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate();
- retPrivData->dom = privData->dom;
- retPrivData->nativeObj = retVal;
- retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
+ Arabica::DOM::NamedNodeMap<std::string>* arbaicaRet = new Arabica::DOM::NamedNodeMap<std::string>(privData->nativeObj->getAttributes());
- retObj.MakeWeak(0, V8Node::jsDestructor);
- return retObj;
+ 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;
- 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");
+ arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
+ arbaicaRetObj.MakeWeak(0, V8NamedNodeMap::jsDestructor);
+ return arbaicaRetObj;
- 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;
+}
- 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::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));
- struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate();
- retPrivData->dom = privData->dom;
- retPrivData->nativeObj = retVal;
+ if (!privData->nativeObj->getOwnerDocument()) return v8::Undefined();
+ Arabica::DOM::Document<std::string>* arbaicaRet = new Arabica::DOM::Document<std::string>(privData->nativeObj->getOwnerDocument());
- retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
+ v8::Handle<v8::Function> arbaicaRetCtor = V8Document::getTmpl()->GetFunction();
+ v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance());
- retObj.MakeWeak(0, V8Node::jsDestructor);
- return retObj;
+ 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;
- 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");
+}
- 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;
+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));
- 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());
+ return v8::String::New(privData->nativeObj->getNamespaceURI().c_str());
+}
- struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate();
- retPrivData->dom = privData->dom;
- retPrivData->nativeObj = retVal;
+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->SetInternalField(0, V8DOM::toExternal(retPrivData));
+ return v8::String::New(privData->nativeObj->getPrefix().c_str());
+}
- retObj.MakeWeak(0, V8Node::jsDestructor);
- return retObj;
+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::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::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");
+ 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");
- 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;
+ 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;
- 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());
+ 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;
+ 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> V8Node::hasChildNodesCallback(const v8::Arguments& args) {
+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");
- v8::Local<v8::Object> self = args.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;
+ Arabica::DOM::Node<std::string>* localOldChild = V8DOM::toClassPtr<V8Node::V8NodePrivate >(args[1]->ToObject()->GetInternalField(0))->nativeObj;
- bool retVal = privData->nativeObj->hasChildNodes();
+ 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());
- return v8::Boolean::New(retVal);
- }
+ struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate();
+ retPrivData->dom = privData->dom;
+ retPrivData->nativeObj = retVal;
- v8::Handle<v8::Value> V8Node::cloneNodeCallback(const v8::Arguments& args) {
- if (args.Length() < 1)
- throw V8Exception("Wrong number of arguments in cloneNode");
+ retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
- v8::Local<v8::Object> self = args.Holder();
- struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0));
- bool localDeep = args[0]->ToBoolean()->BooleanValue();
+ retObj.MakeWeak(0, V8Node::jsDestructor);
+ return retObj;
- 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;
+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->SetInternalField(0, V8DOM::toExternal(retPrivData));
+ 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;
- retObj.MakeWeak(0, V8Node::jsDestructor);
- return retObj;
+ 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());
- }
+ struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate();
+ retPrivData->dom = privData->dom;
+ retPrivData->nativeObj = retVal;
- v8::Handle<v8::Value> V8Node::normalizeCallback(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;
- privData->nativeObj->normalize();
+}
- return v8::Undefined();
- }
+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::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));
+ Arabica::DOM::Node<std::string>* localNewChild = V8DOM::toClassPtr<V8Node::V8NodePrivate >(args[0]->ToObject()->GetInternalField(0))->nativeObj;
- 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]);
+ 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());
- bool retVal = privData->nativeObj->isSupported(*localFeature, *localVersion);
+ struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate();
+ retPrivData->dom = privData->dom;
+ retPrivData->nativeObj = retVal;
- return v8::Boolean::New(retVal);
- }
+ retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
- v8::Handle<v8::Value> V8Node::hasAttributesCallback(const v8::Arguments& args) {
+ retObj.MakeWeak(0, V8Node::jsDestructor);
+ return retObj;
- v8::Local<v8::Object> self = args.Holder();
- struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0));
+}
- bool retVal = privData->nativeObj->hasAttributes();
+v8::Handle<v8::Value> V8Node::hasChildNodesCallback(const v8::Arguments& args) {
- return v8::Boolean::New(retVal);
- }
+ v8::Local<v8::Object> self = args.Holder();
+ struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0));
- bool V8Node::hasInstance(v8::Handle<v8::Value> value) {
- return getTmpl()->HasInstance(value);
- }
+ 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 cd427e5..bb6bbd2 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> 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;
+ }
};
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeList.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeList.cpp
index bc2afb5..bee706e 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 667af40..fb1b510 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeList.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeList.h
@@ -32,42 +32,42 @@ 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> 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("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
-
- instance->SetInternalFieldCount(1);
+ v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate();
+ v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate();
+ (void)prototype; // surpress unused warnings
- 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->SetInternalFieldCount(1);
- prototype->Set(v8::String::NewSymbol("item"),
- v8::FunctionTemplate::New(V8NodeList::itemCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete));
+ 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));
+ 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 6f59a90..fade729 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 78e4410..97b5d4f 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 5ecdd10..129563d 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 2102a24..0745728 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
-
- instance->SetInternalFieldCount(1);
+ v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate();
+ v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate();
+ (void)prototype; // surpress unused warnings
- 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->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));
- 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 f28a56d..c6d2b28 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 a588b1f..56b61eb 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
-
- instance->SetInternalFieldCount(1);
+ v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate();
+ v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate();
+ (void)prototype; // surpress unused warnings
- 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->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));
- 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 72c0651..ed6133a 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.cpp
@@ -4,73 +4,73 @@
namespace Arabica {
namespace DOM {
- v8::Persistent<v8::FunctionTemplate> V8SCXMLEvent::Tmpl;
+v8::Persistent<v8::FunctionTemplate> V8SCXMLEvent::Tmpl;
- v8::Handle<v8::Value> V8SCXMLEvent::typeAttrGetter(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::typeAttrGetter(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::Integer::New(privData->nativeObj->type);
- }
+ return v8::Integer::New(privData->nativeObj->type);
+}
- 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));
- return v8::String::New(privData->nativeObj->origin.c_str());
- }
+ 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));
- return v8::String::New(privData->nativeObj->origintype.c_str());
- }
+ return v8::String::New(privData->nativeObj->origintype.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;
-
- arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
- arbaicaRetObj.MakeWeak(0, V8Node::jsDestructor);
- return arbaicaRetObj;
+ 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> V8SCXMLEvent::sendidAttrGetter(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->sendid.c_str());
- }
+v8::Handle<v8::Value> V8SCXMLEvent::sendidAttrGetter(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));
+ return v8::String::New(privData->nativeObj->sendid.c_str());
+}
- return v8::String::New(privData->nativeObj->invokeid.c_str());
- }
- bool V8SCXMLEvent::hasInstance(v8::Handle<v8::Value> value) {
- return getTmpl()->HasInstance(value);
- }
+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));
-}
-}
+ 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 a1c76c1..62495cf 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.h
@@ -32,63 +32,63 @@ 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> typeAttrGetter(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> domAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info);
- static v8::Handle<v8::Value> sendidAttrGetter(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::typeAttrGetter, 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("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::sendidAttrGetter, 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> typeAttrGetter(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> domAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info);
+ static v8::Handle<v8::Value> sendidAttrGetter(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::typeAttrGetter, 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("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::sendidAttrGetter, 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 fb027d5..42b298a 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 bbf2577..61b92fb 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
-
- instance->SetInternalFieldCount(1);
+ v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate();
+ v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate();
+ (void)prototype; // surpress unused warnings
+ 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 38f69ae..968e53d 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 1fae618..f6a2d10 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/fetch/FetchElement.cpp b/src/uscxml/plugins/element/fetch/FetchElement.cpp
index 33cb76e..eabe0a2 100644
--- a/src/uscxml/plugins/element/fetch/FetchElement.cpp
+++ b/src/uscxml/plugins/element/fetch/FetchElement.cpp
@@ -19,90 +19,90 @@ bool connect(pluma::Host& host) {
#endif
boost::shared_ptr<ExecutableContentImpl> FetchElement::create(Interpreter* interpreter) {
- boost::shared_ptr<FetchElement> invoker = boost::shared_ptr<FetchElement>(new FetchElement());
+ boost::shared_ptr<FetchElement> invoker = boost::shared_ptr<FetchElement>(new FetchElement());
invoker->_interpreter = interpreter;
return invoker;
}
FetchElement::~FetchElement() {
- URLFetcher::breakURL(_targetUrl);
+ URLFetcher::breakURL(_targetUrl);
}
-
+
void FetchElement::downloadCompleted(const URL& url) {
- Event event;
- event.name = _callback;
-
- std::string content = url.getInContent();
- std::map<std::string, std::string> headerFields = url.getInHeaderFields();
-
- if (false) {
- } else if (boost::iequals(_type, "text")) {
- event.data.atom = content;
- event.data.type = Data::VERBATIM;
- } else if (boost::iequals(_type, "url")) {
- } else if (boost::iequals(_type, "json")) {
- event.data = Data::fromJSON(content);
- } else if (boost::iequals(_type, "xml")) {
- event = Event::fromXML(content);
- }
-
- _interpreter->receive(event);
+ Event event;
+ event.name = _callback;
+
+ std::string content = url.getInContent();
+ std::map<std::string, std::string> headerFields = url.getInHeaderFields();
+
+ if (false) {
+ } else if (boost::iequals(_type, "text")) {
+ event.data.atom = content;
+ event.data.type = Data::VERBATIM;
+ } else if (boost::iequals(_type, "url")) {
+ } else if (boost::iequals(_type, "json")) {
+ event.data = Data::fromJSON(content);
+ } else if (boost::iequals(_type, "xml")) {
+ event = Event::fromXML(content);
+ }
+
+ _interpreter->receive(event);
}
-
+
void FetchElement::downloadFailed(const URL& url, int errorCode) {
- Event event;
- event.name = _callback + ".failed";
-
- _interpreter->receive(event);
+ Event event;
+ event.name = _callback + ".failed";
+
+ _interpreter->receive(event);
}
void FetchElement::enterElement(const Arabica::DOM::Node<std::string>& node) {
- if (!HAS_ATTR(node, "target") && !HAS_ATTR(node, "targetexpr")) {
- LOG(ERROR) << "Fetch element requires target or targetexpr";
- return;
- }
- if (HAS_ATTR(node, "targetexpr") && !_interpreter->getDataModel()) {
- LOG(ERROR) << "Fetch element with targetexpr requires datamodel";
- return;
- }
- _target = (HAS_ATTR(node, "target") ? ATTR(node, "target") : _interpreter->getDataModel().evalAsString(ATTR(node, "targetexpr")));
-
- if (!HAS_ATTR(node, "callback") && !HAS_ATTR(node, "callbackexpr")) {
- LOG(ERROR) << "Fetch element requires callback or callbackexpr";
- return;
- }
- if (HAS_ATTR(node, "callbackexpr") && !_interpreter->getDataModel()) {
- LOG(ERROR) << "Fetch element with callbackexpr requires datamodel";
- return;
- }
- _callback = (HAS_ATTR(node, "callback") ? ATTR(node, "callback") : _interpreter->getDataModel().evalAsString(ATTR(node, "callbackexpr")));
-
- _type = (HAS_ATTR(node, "type") ? ATTR(node, "type") : "text");
- if (!boost::iequals(_type, "text") &&
- !boost::iequals(_type, "url") &&
- !boost::iequals(_type, "json") &&
- !boost::iequals(_type, "xml")) {
- LOG(ERROR) << "Fetch element type attribute not one of text, url, json, xml.";
- return;
- }
-
- _targetUrl = URL(_target);
- if (!_targetUrl.isAbsolute()) {
- if (!_interpreter->toAbsoluteURI(_targetUrl)) {
- LOG(ERROR) << "Cannot transform " << _target << " into absolute URL";
- return;
- }
- }
-
- _targetUrl.addMonitor(this);
- URLFetcher::fetchURL(_targetUrl);
-
+ if (!HAS_ATTR(node, "target") && !HAS_ATTR(node, "targetexpr")) {
+ LOG(ERROR) << "Fetch element requires target or targetexpr";
+ return;
+ }
+ if (HAS_ATTR(node, "targetexpr") && !_interpreter->getDataModel()) {
+ LOG(ERROR) << "Fetch element with targetexpr requires datamodel";
+ return;
+ }
+ _target = (HAS_ATTR(node, "target") ? ATTR(node, "target") : _interpreter->getDataModel().evalAsString(ATTR(node, "targetexpr")));
+
+ if (!HAS_ATTR(node, "callback") && !HAS_ATTR(node, "callbackexpr")) {
+ LOG(ERROR) << "Fetch element requires callback or callbackexpr";
+ return;
+ }
+ if (HAS_ATTR(node, "callbackexpr") && !_interpreter->getDataModel()) {
+ LOG(ERROR) << "Fetch element with callbackexpr requires datamodel";
+ return;
+ }
+ _callback = (HAS_ATTR(node, "callback") ? ATTR(node, "callback") : _interpreter->getDataModel().evalAsString(ATTR(node, "callbackexpr")));
+
+ _type = (HAS_ATTR(node, "type") ? ATTR(node, "type") : "text");
+ if (!boost::iequals(_type, "text") &&
+ !boost::iequals(_type, "url") &&
+ !boost::iequals(_type, "json") &&
+ !boost::iequals(_type, "xml")) {
+ LOG(ERROR) << "Fetch element type attribute not one of text, url, json, xml.";
+ return;
+ }
+
+ _targetUrl = URL(_target);
+ if (!_targetUrl.isAbsolute()) {
+ if (!_interpreter->toAbsoluteURI(_targetUrl)) {
+ LOG(ERROR) << "Cannot transform " << _target << " into absolute URL";
+ return;
+ }
+ }
+
+ _targetUrl.addMonitor(this);
+ URLFetcher::fetchURL(_targetUrl);
+
}
void FetchElement::exitElement(const Arabica::DOM::Node<std::string>& node) {
-
+
}
} \ No newline at end of file
diff --git a/src/uscxml/plugins/element/fetch/FetchElement.h b/src/uscxml/plugins/element/fetch/FetchElement.h
index 0229048..aadbb7c 100644
--- a/src/uscxml/plugins/element/fetch/FetchElement.h
+++ b/src/uscxml/plugins/element/fetch/FetchElement.h
@@ -8,7 +8,7 @@
#endif
namespace uscxml {
-
+
class FetchElement : public ExecutableContentImpl, public URLMonitor {
public:
FetchElement() {}
@@ -22,23 +22,23 @@ public:
std::string getNamespace() {
return "http://www.w3.org/2005/07/scxml";
}
-
+
bool processChildren() {
return false;
}
-
+
void enterElement(const Arabica::DOM::Node<std::string>& node);
void exitElement(const Arabica::DOM::Node<std::string>& node);
- void downloadCompleted(const URL& url);
- void downloadFailed(const URL& url, int errorCode);
+ void downloadCompleted(const URL& url);
+ void downloadFailed(const URL& url, int errorCode);
protected:
- URL _targetUrl;
- std::string _target;
- std::string _callback;
- std::string _type;
+ URL _targetUrl;
+ std::string _target;
+ std::string _callback;
+ std::string _type;
};
-
+
#ifdef BUILD_AS_PLUGINS
PLUMA_INHERIT_PROVIDER(FetchElement, Element);
#endif
diff --git a/src/uscxml/plugins/element/response/ResponseElement.cpp b/src/uscxml/plugins/element/response/ResponseElement.cpp
index ce25036..814f726 100644
--- a/src/uscxml/plugins/element/response/ResponseElement.cpp
+++ b/src/uscxml/plugins/element/response/ResponseElement.cpp
@@ -17,52 +17,52 @@ bool connect(pluma::Host& host) {
#endif
boost::shared_ptr<ExecutableContentImpl> ResponseElement::create(Interpreter* interpreter) {
- boost::shared_ptr<ResponseElement> invoker = boost::shared_ptr<ResponseElement>(new ResponseElement());
+ boost::shared_ptr<ResponseElement> invoker = boost::shared_ptr<ResponseElement>(new ResponseElement());
invoker->_interpreter = interpreter;
return invoker;
}
void ResponseElement::enterElement(const Arabica::DOM::Node<std::string>& node) {
- if (!HAS_ATTR(node, "request") && !HAS_ATTR(node, "requestexpr")) {
- LOG(ERROR) << "Response element requires request or requestexpr";
- return;
- }
- if (HAS_ATTR(node, "requestexpr") && !_interpreter->getDataModel()) {
- LOG(ERROR) << "Response element with requestexpr requires datamodel";
- return;
- }
- if (HAS_ATTR(node, "close")) {
-
- }
-
- std::string requestId = (HAS_ATTR(node, "request") ? ATTR(node, "request") : _interpreter->getDataModel().evalAsString(ATTR(node, "requestexpr")));
-
- HTTPServletInvoker* servlet = _interpreter->getHTTPServlet();
- tthread::lock_guard<tthread::recursive_mutex> lock(servlet->getMutex());
-
- if (servlet->getRequests().find(requestId) == servlet->getRequests().end()) {
- LOG(ERROR) << "No matching HTTP request for response element";
- return;
- }
-
- std::string statusStr = (HAS_ATTR(node, "status") ? ATTR(node, "status") : "200");
- if (!isNumeric(statusStr.c_str(), 10)) {
- LOG(ERROR) << "Response element with non-numeric status " << statusStr;
- return;
- }
- int status = strTo<int>(statusStr);
-
- HTTPServer::Request httpReq = servlet->getRequests()[requestId];
-
- HTTPServer::Reply httpReply(httpReq);
- httpReply.status = status;
-
- HTTPServer::reply(httpReply);
- servlet->getRequests().erase(requestId);
+ if (!HAS_ATTR(node, "request") && !HAS_ATTR(node, "requestexpr")) {
+ LOG(ERROR) << "Response element requires request or requestexpr";
+ return;
+ }
+ if (HAS_ATTR(node, "requestexpr") && !_interpreter->getDataModel()) {
+ LOG(ERROR) << "Response element with requestexpr requires datamodel";
+ return;
+ }
+ if (HAS_ATTR(node, "close")) {
+
+ }
+
+ std::string requestId = (HAS_ATTR(node, "request") ? ATTR(node, "request") : _interpreter->getDataModel().evalAsString(ATTR(node, "requestexpr")));
+
+ HTTPServletInvoker* servlet = _interpreter->getHTTPServlet();
+ tthread::lock_guard<tthread::recursive_mutex> lock(servlet->getMutex());
+
+ if (servlet->getRequests().find(requestId) == servlet->getRequests().end()) {
+ LOG(ERROR) << "No matching HTTP request for response element";
+ return;
+ }
+
+ std::string statusStr = (HAS_ATTR(node, "status") ? ATTR(node, "status") : "200");
+ if (!isNumeric(statusStr.c_str(), 10)) {
+ LOG(ERROR) << "Response element with non-numeric status " << statusStr;
+ return;
+ }
+ int status = strTo<int>(statusStr);
+
+ HTTPServer::Request httpReq = servlet->getRequests()[requestId];
+
+ HTTPServer::Reply httpReply(httpReq);
+ httpReply.status = status;
+
+ HTTPServer::reply(httpReply);
+ servlet->getRequests().erase(requestId);
}
void ResponseElement::exitElement(const Arabica::DOM::Node<std::string>& node) {
-
+
}
} \ No newline at end of file
diff --git a/src/uscxml/plugins/element/response/ResponseElement.h b/src/uscxml/plugins/element/response/ResponseElement.h
index 97ff9db..9b3ce61 100644
--- a/src/uscxml/plugins/element/response/ResponseElement.h
+++ b/src/uscxml/plugins/element/response/ResponseElement.h
@@ -8,7 +8,7 @@
#endif
namespace uscxml {
-
+
class ResponseElement : public ExecutableContentImpl {
public:
ResponseElement() {}
@@ -22,16 +22,16 @@ public:
std::string getNamespace() {
return "http://www.w3.org/2005/07/scxml";
}
-
+
bool processChildren() {
return false;
}
-
+
void enterElement(const Arabica::DOM::Node<std::string>& node);
void exitElement(const Arabica::DOM::Node<std::string>& node);
-
+
};
-
+
#ifdef BUILD_AS_PLUGINS
PLUMA_INHERIT_PROVIDER(ResponseElement, Element);
#endif
diff --git a/src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.cpp b/src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.cpp
index 2d308ce..9486de3 100644
--- a/src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.cpp
+++ b/src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.cpp
@@ -158,7 +158,7 @@ void DirMonInvoker::reportExistingIn(const std::string dir, FW::WatchID watchid)
if (boost::iequals(dname, ".") || boost::iequals(dname, ".."))
continue;
- char* filename = (char*)malloc(dir.size() + dname.size() + 2);
+ char* filename = (char*)malloc(dir.size() + dname.size() + 2);
sprintf(filename, "%s/%s", dir.c_str(), dname.c_str());
struct stat fileStat;
diff --git a/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGConverter.cpp b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGConverter.cpp
index eb3d810..49c9ccb 100644
--- a/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGConverter.cpp
+++ b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGConverter.cpp
@@ -33,10 +33,10 @@ Data OSGConverter::getDataModelVariables() {
}
void OSGConverter::send(const SendRequest& req) {
- std::cout << req << std::endl;
- Event event;
- event.name = "error";
- returnEvent(event);
+ std::cout << req << std::endl;
+ Event event;
+ event.name = "error";
+ returnEvent(event);
}
void OSGConverter::cancel(const std::string sendId) {
diff --git a/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp b/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp
index 0272ca8..f89c1b0 100644
--- a/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp
+++ b/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp
@@ -19,7 +19,7 @@ HeartbeatInvoker::HeartbeatInvoker() {
}
HeartbeatInvoker::~HeartbeatInvoker() {
- cancel("");
+ cancel("");
};
boost::shared_ptr<IOProcessorImpl> HeartbeatInvoker::create(Interpreter* interpreter) {
diff --git a/src/uscxml/plugins/invoker/http/HTTPServletInvoker.cpp b/src/uscxml/plugins/invoker/http/HTTPServletInvoker.cpp
index 40f8b66..78e3bea 100644
--- a/src/uscxml/plugins/invoker/http/HTTPServletInvoker.cpp
+++ b/src/uscxml/plugins/invoker/http/HTTPServletInvoker.cpp
@@ -16,24 +16,24 @@ bool connect(pluma::Host& host) {
#endif
HTTPServletInvoker::HTTPServletInvoker() {
- _isInterpreterGlobal = false;
+ _isInterpreterGlobal = false;
}
HTTPServletInvoker::HTTPServletInvoker(Interpreter* interpreter) {
- _isInterpreterGlobal = true;
- _interpreter = interpreter;
- std::stringstream path;
- path << _interpreter->getName();
- int i = 2;
- while(!HTTPServer::registerServlet(path.str(), this)) {
- path.clear();
- path.str();
- path << _interpreter->getName() << toStr(i++);
- }
+ _isInterpreterGlobal = true;
+ _interpreter = interpreter;
+ std::stringstream path;
+ path << _interpreter->getName();
+ int i = 2;
+ while(!HTTPServer::registerServlet(path.str(), this)) {
+ path.clear();
+ path.str();
+ path << _interpreter->getName() << toStr(i++);
+ }
}
HTTPServletInvoker::~HTTPServletInvoker() {
- HTTPServer::unregisterServlet(this);
+ HTTPServer::unregisterServlet(this);
};
@@ -51,97 +51,97 @@ Data HTTPServletInvoker::getDataModelVariables() {
}
void HTTPServletInvoker::send(const SendRequest& req) {
- assert(!_isInterpreterGlobal);
-
- if (req.name.find("reply.", 0, req.name.length())) {
- // this is a reply
- const std::string requestId = req.name.substr(6);
- if (_requests.find(requestId) == _requests.end()) {
- LOG(ERROR) << "Replying to non existing request " << requestId;
- return;
- }
-
- HTTPServer::Request httpRequest = _requests[requestId];
- HTTPServer::Reply httpReply(httpRequest);
- httpReply.content = req.content;
-
- std::map<std::string, std::string>::const_iterator nameListIter = req.namelist.begin();
- while(nameListIter != req.namelist.end()) {
- httpReply.headers[nameListIter->first] = nameListIter->second;
- nameListIter++;
- }
-
- std::multimap<std::string, std::string>::const_iterator paramIter = req.params.begin();
- while(paramIter != req.params.end()) {
- httpReply.headers[paramIter->first] = paramIter->second;
- paramIter++;
- }
-
- HTTPServer::reply(httpReply);
- return;
- }
+ assert(!_isInterpreterGlobal);
+
+ if (req.name.find("reply.", 0, req.name.length())) {
+ // this is a reply
+ const std::string requestId = req.name.substr(6);
+ if (_requests.find(requestId) == _requests.end()) {
+ LOG(ERROR) << "Replying to non existing request " << requestId;
+ return;
+ }
+
+ HTTPServer::Request httpRequest = _requests[requestId];
+ HTTPServer::Reply httpReply(httpRequest);
+ httpReply.content = req.content;
+
+ std::map<std::string, std::string>::const_iterator nameListIter = req.namelist.begin();
+ while(nameListIter != req.namelist.end()) {
+ httpReply.headers[nameListIter->first] = nameListIter->second;
+ nameListIter++;
+ }
+
+ std::multimap<std::string, std::string>::const_iterator paramIter = req.params.begin();
+ while(paramIter != req.params.end()) {
+ httpReply.headers[paramIter->first] = paramIter->second;
+ paramIter++;
+ }
+
+ HTTPServer::reply(httpReply);
+ return;
+ }
}
void HTTPServletInvoker::cancel(const std::string sendId) {
- assert(!_isInterpreterGlobal);
+ assert(!_isInterpreterGlobal);
}
void HTTPServletInvoker::invoke(const InvokeRequest& req) {
- assert(!_isInterpreterGlobal);
-
- _invokeId = req.invokeid;
- if (req.params.find("path") == req.params.end()) {
- LOG(ERROR) << "Path parameter required with httpserver";
- }
- _path = (*req.params.find("path")).second;
-
- if (req.params.find("callback") != req.params.end()) {
- _callback = (*req.params.find("callback")).second;
- } else {
- _callback = _path;
- std::replace(_callback.begin(), _callback.end(), '/', '.');
- }
-
- if (!HTTPServer::registerServlet(_path, this)) {
- LOG(ERROR) << "Cannot register http servlet at " << _path << ": " << " already taken";
- }
+ assert(!_isInterpreterGlobal);
+
+ _invokeId = req.invokeid;
+ if (req.params.find("path") == req.params.end()) {
+ LOG(ERROR) << "Path parameter required with httpserver";
+ }
+ _path = (*req.params.find("path")).second;
+
+ if (req.params.find("callback") != req.params.end()) {
+ _callback = (*req.params.find("callback")).second;
+ } else {
+ _callback = _path;
+ std::replace(_callback.begin(), _callback.end(), '/', '.');
+ }
+
+ if (!HTTPServer::registerServlet(_path, this)) {
+ LOG(ERROR) << "Cannot register http servlet at " << _path << ": " << " already taken";
+ }
}
/**
* Receive a request and deliver it to the interpreter
*/
void HTTPServletInvoker::httpRecvRequest(const HTTPServer::Request& req) {
- tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
-
+ tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
+
// evhttp_request_own(req.curlReq);
- _requests[toStr((uintptr_t)req.curlReq)] = req;
-
- Event event;
-
- if (_isInterpreterGlobal) {
- event.name = "http." + req.type;
- event.origin = toStr((uintptr_t)req.curlReq);
- } else {
- event.name = _callback;
- event.data.compound["reqId"] = Data(toStr((uintptr_t)req.curlReq), Data::VERBATIM);
- }
-
- std::map<std::string, std::string>::const_iterator headerIter = req.headers.begin();
- while(headerIter != req.headers.end()) {
- event.data.compound["headers"].compound[headerIter->first] = Data(headerIter->second, Data::VERBATIM);
- headerIter++;
- }
-
- event.data.compound["content"] = Data(req.content, Data::VERBATIM);
- event.data.compound["type"] = Data(req.type, Data::VERBATIM);
-
- returnEvent(event);
+ _requests[toStr((uintptr_t)req.curlReq)] = req;
+
+ Event event;
+
+ if (_isInterpreterGlobal) {
+ event.name = "http." + req.type;
+ event.origin = toStr((uintptr_t)req.curlReq);
+ } else {
+ event.name = _callback;
+ event.data.compound["reqId"] = Data(toStr((uintptr_t)req.curlReq), Data::VERBATIM);
+ }
+
+ std::map<std::string, std::string>::const_iterator headerIter = req.headers.begin();
+ while(headerIter != req.headers.end()) {
+ event.data.compound["headers"].compound[headerIter->first] = Data(headerIter->second, Data::VERBATIM);
+ headerIter++;
+ }
+
+ event.data.compound["content"] = Data(req.content, Data::VERBATIM);
+ event.data.compound["type"] = Data(req.type, Data::VERBATIM);
+
+ returnEvent(event);
}
-
+
std::string HTTPServletInvoker::getPath() {
- return _path;
+ return _path;
}
} \ No newline at end of file
diff --git a/src/uscxml/plugins/invoker/http/HTTPServletInvoker.h b/src/uscxml/plugins/invoker/http/HTTPServletInvoker.h
index 1d667de..4ac87e0 100644
--- a/src/uscxml/plugins/invoker/http/HTTPServletInvoker.h
+++ b/src/uscxml/plugins/invoker/http/HTTPServletInvoker.h
@@ -13,7 +13,7 @@ namespace uscxml {
class HTTPServletInvoker : public InvokerImpl, public HTTPServlet {
public:
HTTPServletInvoker();
- HTTPServletInvoker(Interpreter* interpreter);
+ HTTPServletInvoker(Interpreter* interpreter);
virtual ~HTTPServletInvoker();
virtual boost::shared_ptr<IOProcessorImpl> create(Interpreter* interpreter);
@@ -29,21 +29,27 @@ public:
virtual void cancel(const std::string sendId);
virtual void invoke(const InvokeRequest& req);
- // HTTPServlet
- virtual void httpRecvRequest(const HTTPServer::Request& req);
- virtual std::string getPath();
- virtual void setURL(const std::string& url) { _url = url; }
+ // HTTPServlet
+ virtual void httpRecvRequest(const HTTPServer::Request& req);
+ virtual std::string getPath();
+ virtual void setURL(const std::string& url) {
+ _url = url;
+ }
+
+ tthread::recursive_mutex& getMutex() {
+ return _mutex;
+ }
+ std::map<std::string, HTTPServer::Request>& getRequests() {
+ return _requests;
+ }
- tthread::recursive_mutex& getMutex() { return _mutex; }
- std::map<std::string, HTTPServer::Request>& getRequests() { return _requests; }
-
protected:
- tthread::recursive_mutex _mutex;
- std::map<std::string, HTTPServer::Request> _requests;
- std::string _path;
- std::string _callback;
- std::string _url;
- bool _isInterpreterGlobal;
+ tthread::recursive_mutex _mutex;
+ std::map<std::string, HTTPServer::Request> _requests;
+ std::string _path;
+ std::string _callback;
+ std::string _url;
+ bool _isInterpreterGlobal;
};
#ifdef BUILD_AS_PLUGINS
diff --git a/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.cpp b/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.cpp
index ed51ef8..1b58785 100644
--- a/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.cpp
+++ b/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.cpp
@@ -50,11 +50,11 @@ boost::shared_ptr<IOProcessorImpl> EventIOProcessor::create(Interpreter* interpr
io->_interpreter = interpreter;
// register at http server
- std::string path = interpreter->getName();
- path += "/basichttp";
- if (!HTTPServer::registerServlet(path, io.get())) {
- LOG(ERROR) << "Cannot register basichttp ioprocessor at " << path << ": " << " already taken";
- }
+ std::string path = interpreter->getName();
+ path += "/basichttp";
+ if (!HTTPServer::registerServlet(path, io.get())) {
+ LOG(ERROR) << "Cannot register basichttp ioprocessor at " << path << ": " << " already taken";
+ }
return io;
}
@@ -67,13 +67,13 @@ Data EventIOProcessor::getDataModelVariables() {
}
void EventIOProcessor::httpRecvRequest(const HTTPServer::Request& req) {
- Event reqEvent;
+ Event reqEvent;
reqEvent.type = Event::EXTERNAL;
bool scxmlStructFound = false;
-
- std::map<std::string, std::string>::const_iterator headerIter = req.headers.begin();
- while(headerIter != req.headers.end()) {
- if (boost::iequals("_scxmleventstruct", headerIter->first)) {
+
+ 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;
@@ -81,33 +81,33 @@ void EventIOProcessor::httpRecvRequest(const HTTPServer::Request& req) {
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++;
- }
-
+ }
+ headerIter++;
+ }
+
if (reqEvent.name.length() == 0)
reqEvent.name = req.type;
-
+
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 EventIOProcessor::send(const SendRequest& req) {
- std::string target = req.target;
- URL targetURL(target);
+ std::string target = req.target;
+ URL targetURL(target);
- // event name
+ // event name
if (req.name.size() > 0) {
- targetURL.addOutHeader("_scxmleventname", evhttp_encode_uri(req.name.c_str()));
+ targetURL.addOutHeader("_scxmleventname", evhttp_encode_uri(req.name.c_str()));
}
- // event namelist
+ // event namelist
if (req.namelist.size() > 0) {
std::map<std::string, std::string>::const_iterator namelistIter = req.namelist.begin();
while (namelistIter != req.namelist.end()) {
@@ -116,7 +116,7 @@ void EventIOProcessor::send(const SendRequest& req) {
}
}
- // event params
+ // event params
if (req.params.size() > 0) {
std::multimap<std::string, std::string>::const_iterator paramIter = req.params.begin();
while (paramIter != req.params.end()) {
@@ -124,47 +124,47 @@ void EventIOProcessor::send(const SendRequest& req) {
paramIter++;
}
}
-
+
// content
if (req.content.size() > 0)
- targetURL.setOutContent(req.content);
+ targetURL.setOutContent(req.content);
- targetURL.setRequestType("post");
- targetURL.addMonitor(this);
-
- _sendRequests[req.sendid] = std::make_pair(targetURL, req);
- URLFetcher::fetchURL(targetURL);
+ targetURL.setRequestType("post");
+ targetURL.addMonitor(this);
+
+ _sendRequests[req.sendid] = std::make_pair(targetURL, req);
+ URLFetcher::fetchURL(targetURL);
}
-
+
void EventIOProcessor::downloadStarted(const URL& url) {}
void EventIOProcessor::downloadCompleted(const URL& url) {
- std::map<std::string, std::pair<URL, SendRequest> >::iterator reqIter = _sendRequests.begin();
- while(reqIter != _sendRequests.end()) {
- if (reqIter->second.first == url) {
- _sendRequests.erase(reqIter);
- return;
- }
- reqIter++;
- }
- assert(false);
+ std::map<std::string, std::pair<URL, SendRequest> >::iterator reqIter = _sendRequests.begin();
+ while(reqIter != _sendRequests.end()) {
+ if (reqIter->second.first == url) {
+ _sendRequests.erase(reqIter);
+ return;
+ }
+ reqIter++;
+ }
+ assert(false);
}
void EventIOProcessor::downloadFailed(const URL& url, int errorCode) {
-
- std::map<std::string, std::pair<URL, SendRequest> >::iterator reqIter = _sendRequests.begin();
- while(reqIter != _sendRequests.end()) {
- if (reqIter->second.first == url) {
- Event failEvent;
- failEvent.name = "error.communication";
- returnEvent(failEvent);
-
- _sendRequests.erase(reqIter);
- return;
- }
- reqIter++;
- }
- assert(false);
+
+ std::map<std::string, std::pair<URL, SendRequest> >::iterator reqIter = _sendRequests.begin();
+ while(reqIter != _sendRequests.end()) {
+ if (reqIter->second.first == url) {
+ Event failEvent;
+ failEvent.name = "error.communication";
+ returnEvent(failEvent);
+
+ _sendRequests.erase(reqIter);
+ return;
+ }
+ reqIter++;
+ }
+ assert(false);
}
diff --git a/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.h b/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.h
index 416761f..70c6bea 100644
--- a/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.h
+++ b/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.h
@@ -37,18 +37,20 @@ public:
Data getDataModelVariables();
- /// HTTPServlet
+ /// HTTPServlet
void httpRecvRequest(const HTTPServer::Request& req);
- void setURL(const std::string& url) { _url = url; }
+ void setURL(const std::string& url) {
+ _url = url;
+ }
- // URLMonitor
- void downloadStarted(const URL& url);
- void downloadCompleted(const URL& url);
- void downloadFailed(const URL& url, int errorCode);
+ // URLMonitor
+ void downloadStarted(const URL& url);
+ void downloadCompleted(const URL& url);
+ void downloadFailed(const URL& url, int errorCode);
protected:
std::string _url;
- std::map<std::string, std::pair<URL, SendRequest> > _sendRequests;
+ std::map<std::string, std::pair<URL, SendRequest> > _sendRequests;
};
#ifdef BUILD_AS_PLUGINS
diff --git a/src/uscxml/server/HTTPServer.cpp b/src/uscxml/server/HTTPServer.cpp
index e151f9e..fccc8a9 100644
--- a/src/uscxml/server/HTTPServer.cpp
+++ b/src/uscxml/server/HTTPServer.cpp
@@ -51,9 +51,9 @@ HTTPServer* HTTPServer::getInstance(int port) {
tthread::lock_guard<tthread::recursive_mutex> lock(_instanceMutex);
if (_instance == NULL) {
#ifndef _WIN32
- evthread_use_pthreads();
+ evthread_use_pthreads();
#else
- evthread_use_windows_threads();
+ evthread_use_windows_threads();
#endif
_instance = new HTTPServer(port);
_instance->start();
@@ -65,87 +65,87 @@ void HTTPServer::httpRecvReqCallback(struct evhttp_request *req, void *callbackD
// std::cout << (uintptr_t)req << ": Replying" << std::endl;
// evhttp_send_reply(req, 200, NULL, NULL);
// return;
-
- Request request;
- request.curlReq = req;
-
- switch (evhttp_request_get_command(req)) {
- case EVHTTP_REQ_GET:
- request.type = "GET";
- break;
- case EVHTTP_REQ_POST:
- request.type = "POST";
- break;
- case EVHTTP_REQ_HEAD:
- request.type = "HEAD";
- break;
- case EVHTTP_REQ_PUT:
- request.type = "PUT";
- break;
- case EVHTTP_REQ_DELETE:
- request.type = "DELETE";
- break;
- case EVHTTP_REQ_OPTIONS:
- request.type = "OPTIONS";
- break;
- case EVHTTP_REQ_TRACE:
- request.type = "TRACE";
- break;
- case EVHTTP_REQ_CONNECT:
- request.type = "CONNECT";
- break;
- case EVHTTP_REQ_PATCH:
- request.type = "PATCH";
- break;
- default:
- request.type = "unknown";
- break;
+
+ Request request;
+ request.curlReq = req;
+
+ switch (evhttp_request_get_command(req)) {
+ case EVHTTP_REQ_GET:
+ request.type = "GET";
+ break;
+ case EVHTTP_REQ_POST:
+ request.type = "POST";
+ break;
+ case EVHTTP_REQ_HEAD:
+ request.type = "HEAD";
+ break;
+ case EVHTTP_REQ_PUT:
+ request.type = "PUT";
+ break;
+ case EVHTTP_REQ_DELETE:
+ request.type = "DELETE";
+ break;
+ case EVHTTP_REQ_OPTIONS:
+ request.type = "OPTIONS";
+ break;
+ case EVHTTP_REQ_TRACE:
+ request.type = "TRACE";
+ break;
+ case EVHTTP_REQ_CONNECT:
+ request.type = "CONNECT";
+ break;
+ case EVHTTP_REQ_PATCH:
+ request.type = "PATCH";
+ break;
+ default:
+ request.type = "unknown";
+ break;
}
- struct evkeyvalq *headers;
+ struct evkeyvalq *headers;
struct evkeyval *header;
struct evbuffer *buf;
- // map headers to event structure
+ // map headers to event structure
headers = evhttp_request_get_input_headers(req);
for (header = headers->tqh_first; header; header = header->next.tqe_next) {
- request.headers[header->key] = header->value;
+ request.headers[header->key] = header->value;
+ }
+
+ request.remoteHost = req->remote_host;
+ request.remotePort = req->remote_port;
+ request.httpMajor = req->major;
+ request.httpMinor = req->minor;
+ request.uri = req->uri;
+
+ // get content
+ buf = evhttp_request_get_input_buffer(req);
+ while (evbuffer_get_length(buf)) {
+ int n;
+ char cbuf[1024];
+ n = evbuffer_remove(buf, cbuf, sizeof(buf)-1);
+ if (n > 0) {
+ request.content.append(cbuf, n);
+ }
}
- request.remoteHost = req->remote_host;
- request.remotePort = req->remote_port;
- request.httpMajor = req->major;
- request.httpMinor = req->minor;
- request.uri = req->uri;
-
- // get content
- buf = evhttp_request_get_input_buffer(req);
- while (evbuffer_get_length(buf)) {
- int n;
- char cbuf[1024];
- n = evbuffer_remove(buf, cbuf, sizeof(buf)-1);
- if (n > 0) {
- request.content.append(cbuf, n);
- }
- }
-
- ((HTTPServlet*)callbackData)->httpRecvRequest(request);
+ ((HTTPServlet*)callbackData)->httpRecvRequest(request);
}
void HTTPServer::reply(const Reply& reply) {
- struct evbuffer *evb = evbuffer_new();
-
- std::map<std::string, std::string>::const_iterator headerIter = reply.headers.begin();
- while(headerIter != reply.headers.end()) {
- evhttp_add_header(evhttp_request_get_output_headers(reply.curlReq), headerIter->first.c_str(), headerIter->second.c_str());
- headerIter++;
- }
-
- if (!boost::iequals(reply.type, "HEAD"))
- evbuffer_add(evb, reply.content.data(), reply.content.size());
-
- evhttp_send_reply(reply.curlReq, reply.status, NULL, evb);
- evbuffer_free(evb);
+ struct evbuffer *evb = evbuffer_new();
+
+ std::map<std::string, std::string>::const_iterator headerIter = reply.headers.begin();
+ while(headerIter != reply.headers.end()) {
+ evhttp_add_header(evhttp_request_get_output_headers(reply.curlReq), headerIter->first.c_str(), headerIter->second.c_str());
+ headerIter++;
+ }
+
+ if (!boost::iequals(reply.type, "HEAD"))
+ evbuffer_add(evb, reply.content.data(), reply.content.size());
+
+ evhttp_send_reply(reply.curlReq, reply.status, NULL, evb);
+ evbuffer_free(evb);
// evhttp_request_free(reply.curlReq);
}
@@ -162,27 +162,27 @@ bool HTTPServer::registerServlet(const std::string& path, HTTPServlet* servlet)
* until we have an available path.
*
* If the interpreter does not specify a name, take its sessionid.
- *
- * Responsibility moved to individual servlets.
+ *
+ * Responsibility moved to individual servlets.
*/
if(INSTANCE->_servlets.find(path) != INSTANCE->_servlets.end()) {
- return false;
+ return false;
}
std::stringstream servletURL;
servletURL << "http://" << INSTANCE->_address << ":" << INSTANCE->_port << "/" << path;
- servlet->setURL(servletURL.str());
-
+ servlet->setURL(servletURL.str());
+
INSTANCE->_servlets[path] = servlet;
LOG(INFO) << "HTTP Servlet listening at: " << servletURL.str() << std::endl;
- // register callback
+ // register callback
evhttp_set_cb(INSTANCE->_http, ("/" + path).c_str(), HTTPServer::httpRecvReqCallback, servlet);
- return true;
- // generic callback
+ return true;
+ // generic callback
// evhttp_set_cb(THIS->_http, "/", EventIOProcessor::httpRecvReq, processor);
// evhttp_set_gencb(THIS->_http, EventIOProcessor::httpRecvReq, NULL);
}
@@ -190,15 +190,15 @@ bool HTTPServer::registerServlet(const std::string& path, HTTPServlet* servlet)
void HTTPServer::unregisterServlet(HTTPServlet* servlet) {
HTTPServer* INSTANCE = getInstance();
tthread::lock_guard<tthread::recursive_mutex> lock(INSTANCE->_mutex);
- servlet_iter_t servletIter = INSTANCE->_servlets.begin();
- while(servletIter != INSTANCE->_servlets.end()) {
- if (servletIter->second == servlet) {
- evhttp_del_cb(INSTANCE->_http, std::string("/" + servletIter->first).c_str());
- INSTANCE->_servlets.erase(servletIter);
- break;
- }
- servletIter++;
- }
+ servlet_iter_t servletIter = INSTANCE->_servlets.begin();
+ while(servletIter != INSTANCE->_servlets.end()) {
+ if (servletIter->second == servlet) {
+ evhttp_del_cb(INSTANCE->_http, std::string("/" + servletIter->first).c_str());
+ INSTANCE->_servlets.erase(servletIter);
+ break;
+ }
+ servletIter++;
+ }
}
void HTTPServer::start() {
diff --git a/src/uscxml/server/HTTPServer.h b/src/uscxml/server/HTTPServer.h
index 597c749..a387e1f 100644
--- a/src/uscxml/server/HTTPServer.h
+++ b/src/uscxml/server/HTTPServer.h
@@ -11,42 +11,42 @@
namespace uscxml {
class HTTPServlet;
-
+
class HTTPServer {
public:
- class Request {
- public:
- Request() : curlReq(NULL) {}
- std::string type;
- std::map<std::string, std::string> headers;
- std::string content;
- std::string remoteHost;
- unsigned short remotePort;
- std::string httpMajor;
- std::string httpMinor;
- std::string uri;
- struct evhttp_request* curlReq;
- };
-
- class Reply {
- public:
- Reply(Request req) : status(200), type(req.type), curlReq(req.curlReq) {}
- int status;
- std::string type;
- std::map<std::string, std::string> headers;
- std::string content;
- struct evhttp_request* curlReq;
- };
-
- struct CallbackData {
+ class Request {
+ public:
+ Request() : curlReq(NULL) {}
+ std::string type;
+ std::map<std::string, std::string> headers;
+ std::string content;
+ std::string remoteHost;
+ unsigned short remotePort;
+ std::string httpMajor;
+ std::string httpMinor;
+ std::string uri;
+ struct evhttp_request* curlReq;
+ };
+
+ class Reply {
+ public:
+ Reply(Request req) : status(200), type(req.type), curlReq(req.curlReq) {}
+ int status;
+ std::string type;
+ std::map<std::string, std::string> headers;
+ std::string content;
+ struct evhttp_request* curlReq;
+ };
+
+ struct CallbackData {
HTTPServlet* servlet;
evhttp_request* httpReq;
};
- static HTTPServer* getInstance(int port = 8080);
- static void reply(const Reply& reply);
-
- static bool registerServlet(const std::string& path, HTTPServlet* servlet); ///< Register a servlet, returns false if path is already taken
+ static HTTPServer* getInstance(int port = 8080);
+ static void reply(const Reply& reply);
+
+ static bool registerServlet(const std::string& path, HTTPServlet* servlet); ///< Register a servlet, returns false if path is already taken
static void unregisterServlet(HTTPServlet* servlet);
private:
@@ -58,7 +58,7 @@ private:
static void run(void* instance);
void determineAddress();
-
+
static void httpRecvReqCallback(struct evhttp_request *req, void *callbackData);
std::map<std::string, HTTPServlet*> _servlets;
@@ -72,7 +72,7 @@ private:
std::string _address;
static HTTPServer* _instance;
-
+
static tthread::recursive_mutex _instanceMutex;
tthread::thread* _thread;
tthread::recursive_mutex _mutex;
@@ -83,8 +83,8 @@ private:
class HTTPServlet {
public:
- virtual void httpRecvRequest(const HTTPServer::Request& request) = 0;
- virtual void setURL(const std::string& url) = 0; /// Called by the server with the actual URL
+ virtual void httpRecvRequest(const HTTPServer::Request& request) = 0;
+ virtual void setURL(const std::string& url) = 0; /// Called by the server with the actual URL
};
}
diff --git a/test/src/scxml-test-framework-client.cpp b/test/src/scxml-test-framework-client.cpp
index 1eeab9c..58f1057 100644
--- a/test/src/scxml-test-framework-client.cpp
+++ b/test/src/scxml-test-framework-client.cpp
@@ -16,155 +16,155 @@ extern "C" {
content-type: application/json
content-length: 92
Connection: keep-alive
-
+
{"load":"http://localhost:9999/scxml-test-framework/test/targetless-transition/test3.scxml"}
*/
class TestIOProcessor : public uscxml::HTTPServlet, public uscxml::InterpreterMonitor {
public:
- static int lastToken;
- static bool alreadyAnswered; // we need this for delayed events
- static std::map<std::string, std::pair<uscxml::Interpreter*, uscxml::HTTPServer::Request> > _interpreters;
-
- TestIOProcessor() {}
-
- virtual void beforeCompletion(uscxml::Interpreter* interpreter) {
- _interpreters[interpreter->getName()].second.curlReq = NULL;
- }
-
- virtual void afterCompletion(uscxml::Interpreter* interpreter) {}
- virtual void beforeMicroStep(uscxml::Interpreter* interpreter) {}
- virtual void beforeTakingTransitions(uscxml::Interpreter* interpreter, const Arabica::XPath::NodeSet<std::string>& transitions) {}
-
- virtual void beforeEnteringStates(uscxml::Interpreter* interpreter, const Arabica::XPath::NodeSet<std::string>& statesToEnter) {
- std::cout << "Entering states: ";
- for (int i = 0; i < statesToEnter.size(); i++) {
- std::cout << ATTR(statesToEnter[i], "id") << ", ";
- }
- std::cout << std::endl;
- }
-
- virtual void afterEnteringStates(uscxml::Interpreter* interpreter) {
- std::cout << "After entering states: ";
- for (int i = 0; i < interpreter->getConfiguration().size(); i++) {
- std::cout << ATTR(interpreter->getConfiguration()[i], "id") << ", ";
- }
- std::cout << std::endl;
- }
-
- virtual void beforeExitingStates(uscxml::Interpreter* interpreter, const Arabica::XPath::NodeSet<std::string>& statesToExit) {
- std::cout << "Configuration: ";
- for (int i = 0; i < interpreter->getConfiguration().size(); i++) {
- std::cout << ATTR(interpreter->getConfiguration()[i], "id") << ", ";
- }
- std::cout << std::endl;
- std::cout << "Exiting states: ";
- for (int i = 0; i < statesToExit.size(); i++) {
- std::cout << ATTR(statesToExit[i], "id") << ", ";
- }
- std::cout << std::endl;
- }
-
- virtual void afterExitingStates(uscxml::Interpreter* interpreter) {
- std::cout << "After exiting states: ";
- for (int i = 0; i < interpreter->getConfiguration().size(); i++) {
- std::cout << ATTR(interpreter->getConfiguration()[i], "id") << ", ";
- }
- std::cout << std::endl;
- }
-
- virtual void onStableConfiguration(uscxml::Interpreter* interpreter) {
- if (alreadyAnswered)
- return;
-
- Arabica::XPath::NodeSet<std::string> configuration = interpreter->getConfiguration();
-
- uscxml::Data reply;
- reply.compound["sessionToken"] = uscxml::Data(interpreter->getName());
- std::string seperator;
- for (size_t i = 0; i < configuration.size(); i++) {
- if (uscxml::Interpreter::isAtomic(configuration[i]))
- reply.compound["nextConfiguration"].array.push_back(uscxml::Data(ATTR(configuration[i], "id"), uscxml::Data::VERBATIM));
- }
-
- std::cout << "---- reply:" << std::endl;
- std::cout << reply << std::endl;
-
- std::stringstream replyString;
- replyString << reply;
-
- alreadyAnswered = true;
-
- uscxml::HTTPServer::Request httpRequest = _interpreters[interpreter->getName()].second;
- uscxml::HTTPServer::Reply httpReply(httpRequest);
- httpReply.content = replyString.str();
- uscxml::HTTPServer::reply(httpReply);
-
- }
-
- void httpRecvRequest(const uscxml::HTTPServer::Request& request) {
-
+ static int lastToken;
+ static bool alreadyAnswered; // we need this for delayed events
+ static std::map<std::string, std::pair<uscxml::Interpreter*, uscxml::HTTPServer::Request> > _interpreters;
+
+ TestIOProcessor() {}
+
+ virtual void beforeCompletion(uscxml::Interpreter* interpreter) {
+ _interpreters[interpreter->getName()].second.curlReq = NULL;
+ }
+
+ virtual void afterCompletion(uscxml::Interpreter* interpreter) {}
+ virtual void beforeMicroStep(uscxml::Interpreter* interpreter) {}
+ virtual void beforeTakingTransitions(uscxml::Interpreter* interpreter, const Arabica::XPath::NodeSet<std::string>& transitions) {}
+
+ virtual void beforeEnteringStates(uscxml::Interpreter* interpreter, const Arabica::XPath::NodeSet<std::string>& statesToEnter) {
+ std::cout << "Entering states: ";
+ for (int i = 0; i < statesToEnter.size(); i++) {
+ std::cout << ATTR(statesToEnter[i], "id") << ", ";
+ }
+ std::cout << std::endl;
+ }
+
+ virtual void afterEnteringStates(uscxml::Interpreter* interpreter) {
+ std::cout << "After entering states: ";
+ for (int i = 0; i < interpreter->getConfiguration().size(); i++) {
+ std::cout << ATTR(interpreter->getConfiguration()[i], "id") << ", ";
+ }
+ std::cout << std::endl;
+ }
+
+ virtual void beforeExitingStates(uscxml::Interpreter* interpreter, const Arabica::XPath::NodeSet<std::string>& statesToExit) {
+ std::cout << "Configuration: ";
+ for (int i = 0; i < interpreter->getConfiguration().size(); i++) {
+ std::cout << ATTR(interpreter->getConfiguration()[i], "id") << ", ";
+ }
+ std::cout << std::endl;
+ std::cout << "Exiting states: ";
+ for (int i = 0; i < statesToExit.size(); i++) {
+ std::cout << ATTR(statesToExit[i], "id") << ", ";
+ }
+ std::cout << std::endl;
+ }
+
+ virtual void afterExitingStates(uscxml::Interpreter* interpreter) {
+ std::cout << "After exiting states: ";
+ for (int i = 0; i < interpreter->getConfiguration().size(); i++) {
+ std::cout << ATTR(interpreter->getConfiguration()[i], "id") << ", ";
+ }
+ std::cout << std::endl;
+ }
+
+ virtual void onStableConfiguration(uscxml::Interpreter* interpreter) {
+ if (alreadyAnswered)
+ return;
+
+ Arabica::XPath::NodeSet<std::string> configuration = interpreter->getConfiguration();
+
+ uscxml::Data reply;
+ reply.compound["sessionToken"] = uscxml::Data(interpreter->getName());
+ std::string seperator;
+ for (size_t i = 0; i < configuration.size(); i++) {
+ if (uscxml::Interpreter::isAtomic(configuration[i]))
+ reply.compound["nextConfiguration"].array.push_back(uscxml::Data(ATTR(configuration[i], "id"), uscxml::Data::VERBATIM));
+ }
+
+ std::cout << "---- reply:" << std::endl;
+ std::cout << reply << std::endl;
+
+ std::stringstream replyString;
+ replyString << reply;
+
+ alreadyAnswered = true;
+
+ uscxml::HTTPServer::Request httpRequest = _interpreters[interpreter->getName()].second;
+ uscxml::HTTPServer::Reply httpReply(httpRequest);
+ httpReply.content = replyString.str();
+ uscxml::HTTPServer::reply(httpReply);
+
+ }
+
+ void httpRecvRequest(const uscxml::HTTPServer::Request& request) {
+
// uscxml::HTTPServer::Reply httpReply(request);
// uscxml::HTTPServer::reply(httpReply);
// return;
-
- std::cout << "---- received:" << std::endl;
- evhttp_request_own(request.curlReq);
-
- std::cout << request.content << std::endl;
- uscxml::Data jsonReq = uscxml::Data::fromJSON(request.content);
- std::cout << jsonReq << std::endl;
-
-
- // is this a load request?
- if (jsonReq.compound.find("load") != jsonReq.compound.end()) {
- std::string filename = jsonReq.compound["load"].atom;
- std::cout << "Starting Interpreter with " << filename << std::endl;
- alreadyAnswered = false;
-
- std::map<std::string, std::pair<uscxml::Interpreter*, uscxml::HTTPServer::Request> >::iterator interpreterIter = _interpreters.begin();
- while(interpreterIter != _interpreters.end()) {
+
+ std::cout << "---- received:" << std::endl;
+ evhttp_request_own(request.curlReq);
+
+ std::cout << request.content << std::endl;
+ uscxml::Data jsonReq = uscxml::Data::fromJSON(request.content);
+ std::cout << jsonReq << std::endl;
+
+
+ // is this a load request?
+ if (jsonReq.compound.find("load") != jsonReq.compound.end()) {
+ std::string filename = jsonReq.compound["load"].atom;
+ std::cout << "Starting Interpreter with " << filename << std::endl;
+ alreadyAnswered = false;
+
+ std::map<std::string, std::pair<uscxml::Interpreter*, uscxml::HTTPServer::Request> >::iterator interpreterIter = _interpreters.begin();
+ while(interpreterIter != _interpreters.end()) {
// if (interpreterIter->second.second.curlReq == NULL) {
- delete interpreterIter->second.first;
- _interpreters.erase(interpreterIter++);
+ delete interpreterIter->second.first;
+ _interpreters.erase(interpreterIter++);
// } else {
// interpreterIter++;
// }
- }
-
-
- uscxml::Interpreter* interpreter = uscxml::Interpreter::fromURI(filename);
- if (interpreter) {
- std::string token = uscxml::toStr(lastToken++);
- assert(_interpreters.find(token) == _interpreters.end());
- interpreter->setName(token);
- interpreter->addMonitor(this);
- interpreter->start();
- _interpreters[token] = std::make_pair(interpreter, request);
- }
- return;
- }
-
- if(jsonReq.compound.find("event") != jsonReq.compound.end()) {
- assert(jsonReq.compound["event"].compound.find("sessionToken") != jsonReq.compound["event"].compound.end());
- std::string token = jsonReq.compound["event"].compound["sessionToken"].atom;
- assert(_interpreters.find(token) != _interpreters.end());
- uscxml::Event event;
- event.type = uscxml::Event::INTERNAL;
- event.name = jsonReq.compound["event"].compound["name"].atom;
- std::cout << "Sending event " << event << std::endl;
+ }
+
+
+ uscxml::Interpreter* interpreter = uscxml::Interpreter::fromURI(filename);
+ if (interpreter) {
+ std::string token = uscxml::toStr(lastToken++);
+ assert(_interpreters.find(token) == _interpreters.end());
+ interpreter->setName(token);
+ interpreter->addMonitor(this);
+ interpreter->start();
+ _interpreters[token] = std::make_pair(interpreter, request);
+ }
+ return;
+ }
+
+ if(jsonReq.compound.find("event") != jsonReq.compound.end()) {
+ assert(jsonReq.compound["event"].compound.find("sessionToken") != jsonReq.compound["event"].compound.end());
+ std::string token = jsonReq.compound["event"].compound["sessionToken"].atom;
+ assert(_interpreters.find(token) != _interpreters.end());
+ uscxml::Event event;
+ event.type = uscxml::Event::INTERNAL;
+ event.name = jsonReq.compound["event"].compound["name"].atom;
+ std::cout << "Sending event " << event << std::endl;
// evhttp_request_free(_interpreters[token].second);
- alreadyAnswered = false;
- _interpreters[token].second = request;
- _interpreters[token].first->receive(event);
- }
-
- }
-
- void setURL(const std::string& url) {
- std::cout << "Listening at " << url << std::endl;
- }
+ alreadyAnswered = false;
+ _interpreters[token].second = request;
+ _interpreters[token].first->receive(event);
+ }
+
+ }
+
+ void setURL(const std::string& url) {
+ std::cout << "Listening at " << url << std::endl;
+ }
};
int TestIOProcessor::lastToken;
@@ -172,10 +172,10 @@ bool TestIOProcessor::alreadyAnswered;
std::map<std::string, std::pair<uscxml::Interpreter*, uscxml::HTTPServer::Request> > TestIOProcessor::_interpreters;
int main(int argc, char** argv) {
- TestIOProcessor* testServer = new TestIOProcessor();
- uscxml::HTTPServer::registerServlet("test", testServer);
+ TestIOProcessor* testServer = new TestIOProcessor();
+ uscxml::HTTPServer::registerServlet("test", testServer);
+
+ while(true)
+ tthread::this_thread::sleep_for(tthread::chrono::milliseconds(20));
- while(true)
- tthread::this_thread::sleep_for(tthread::chrono::milliseconds(20));
-
} \ No newline at end of file
diff --git a/test/src/test-curl-multi-api.cpp b/test/src/test-curl-multi-api.cpp
index fac06dc..67735d2 100644
--- a/test/src/test-curl-multi-api.cpp
+++ b/test/src/test-curl-multi-api.cpp
@@ -17,108 +17,124 @@ class URL;
class URLMonitor {
public:
- virtual void downloadStarted(const URL& url) {};
- virtual void downloadCompleted(const URL& url) {};
- virtual void downloadFailed(const URL& url, int errorCode) {};
- virtual void headerChunkReceived(const URL& url, const std::string& headerChunk) {};
- virtual void contentChunkReceived(const URL& url, const std::string& contentChunk) {};
+ virtual void downloadStarted(const URL& url) {};
+ virtual void downloadCompleted(const URL& url) {};
+ virtual void downloadFailed(const URL& url, int errorCode) {};
+ virtual void headerChunkReceived(const URL& url, const std::string& headerChunk) {};
+ virtual void contentChunkReceived(const URL& url, const std::string& contentChunk) {};
};
class URLImpl : public boost::enable_shared_from_this<URLImpl> {
public:
- URLImpl(const std::string& url) : _handle(NULL), _uri(url), _isDownloaded(false) {
- _handle = curl_easy_init();
- if (_handle != NULL) {
- CURLcode curlError;
- curlError = curl_easy_setopt(_handle, CURLOPT_URL, _uri.as_string().c_str());
- if (curlError != CURLE_OK)
- LOG(ERROR) << "Cannot set url to " << _uri.as_string() << ": " << curl_easy_strerror(curlError);
-
- curlError = curl_easy_setopt(_handle, CURLOPT_WRITEDATA, this);
- if (curlError != CURLE_OK)
- LOG(ERROR) << "Cannot register this as write userdata: " << curl_easy_strerror(curlError);
-
- curlError = curl_easy_setopt(_handle, CURLOPT_WRITEFUNCTION, URLImpl::writeHandler);
- if (curlError != CURLE_OK)
- LOG(ERROR) << "Cannot set write callback: " << curl_easy_strerror(curlError);
-
- curlError = curl_easy_setopt(_handle, CURLOPT_HEADERFUNCTION, URLImpl::headerHandler);
- if (curlError != CURLE_OK)
- LOG(ERROR) << "Cannot request header from curl: " << curl_easy_strerror(curlError);
-
- curlError = curl_easy_setopt(_handle, CURLOPT_HEADERDATA, this);
- if (curlError != CURLE_OK)
- LOG(ERROR) << "Cannot register this as header userdata: " << curl_easy_strerror(curlError);
- } else {
- LOG(ERROR) << "curl_easy_init returned NULL, this is bad!";
- }
- }
-
- ~URLImpl() {
- if (_handle != NULL)
- curl_easy_cleanup(_handle);
- }
-
- static size_t writeHandler(void *ptr, size_t size, size_t nmemb, void *userdata) {
- URLImpl* url = (URLImpl*)userdata;
- url->_content.write((char*)ptr, size * nmemb);
- return size * nmemb;
- }
-
- static size_t headerHandler(void *ptr, size_t size, size_t nmemb, void *userdata) {
- URLImpl* url = (URLImpl*)userdata;
- url->_header.write((char*)ptr, size * nmemb);
- return size * nmemb;
- }
-
- void addMonitor(URLMonitor* monitor) { _monitors.insert(monitor); }
- void removeMonitor(URLMonitor* monitor) { _monitors.erase(monitor); }
-
- const bool isAbsolute() const { return _uri.is_absolute(); }
- const std::string scheme() const { return _uri.scheme(); }
- const std::string host() const { return _uri.host(); }
- const std::string port() const { return _uri.port(); }
- const std::string path() const { return _uri.path(); }
- const std::string asString() const { return _uri.as_string(); }
-
- void downloadStarted() {
- std::cout << "Starting download of " << asString() << std::endl;
- _content.str("");
- _content.clear();
- _header.str("");
- _header.clear();
- monIter_t monIter = _monitors.begin();
- while(monIter != _monitors.end()) {
+ URLImpl(const std::string& url) : _handle(NULL), _uri(url), _isDownloaded(false) {
+ _handle = curl_easy_init();
+ if (_handle != NULL) {
+ CURLcode curlError;
+ curlError = curl_easy_setopt(_handle, CURLOPT_URL, _uri.as_string().c_str());
+ if (curlError != CURLE_OK)
+ LOG(ERROR) << "Cannot set url to " << _uri.as_string() << ": " << curl_easy_strerror(curlError);
+
+ curlError = curl_easy_setopt(_handle, CURLOPT_WRITEDATA, this);
+ if (curlError != CURLE_OK)
+ LOG(ERROR) << "Cannot register this as write userdata: " << curl_easy_strerror(curlError);
+
+ curlError = curl_easy_setopt(_handle, CURLOPT_WRITEFUNCTION, URLImpl::writeHandler);
+ if (curlError != CURLE_OK)
+ LOG(ERROR) << "Cannot set write callback: " << curl_easy_strerror(curlError);
+
+ curlError = curl_easy_setopt(_handle, CURLOPT_HEADERFUNCTION, URLImpl::headerHandler);
+ if (curlError != CURLE_OK)
+ LOG(ERROR) << "Cannot request header from curl: " << curl_easy_strerror(curlError);
+
+ curlError = curl_easy_setopt(_handle, CURLOPT_HEADERDATA, this);
+ if (curlError != CURLE_OK)
+ LOG(ERROR) << "Cannot register this as header userdata: " << curl_easy_strerror(curlError);
+ } else {
+ LOG(ERROR) << "curl_easy_init returned NULL, this is bad!";
+ }
+ }
+
+ ~URLImpl() {
+ if (_handle != NULL)
+ curl_easy_cleanup(_handle);
+ }
+
+ static size_t writeHandler(void *ptr, size_t size, size_t nmemb, void *userdata) {
+ URLImpl* url = (URLImpl*)userdata;
+ url->_content.write((char*)ptr, size * nmemb);
+ return size * nmemb;
+ }
+
+ static size_t headerHandler(void *ptr, size_t size, size_t nmemb, void *userdata) {
+ URLImpl* url = (URLImpl*)userdata;
+ url->_header.write((char*)ptr, size * nmemb);
+ return size * nmemb;
+ }
+
+ void addMonitor(URLMonitor* monitor) {
+ _monitors.insert(monitor);
+ }
+ void removeMonitor(URLMonitor* monitor) {
+ _monitors.erase(monitor);
+ }
+
+ const bool isAbsolute() const {
+ return _uri.is_absolute();
+ }
+ const std::string scheme() const {
+ return _uri.scheme();
+ }
+ const std::string host() const {
+ return _uri.host();
+ }
+ const std::string port() const {
+ return _uri.port();
+ }
+ const std::string path() const {
+ return _uri.path();
+ }
+ const std::string asString() const {
+ return _uri.as_string();
+ }
+
+ void downloadStarted() {
+ std::cout << "Starting download of " << asString() << std::endl;
+ _content.str("");
+ _content.clear();
+ _header.str("");
+ _header.clear();
+ monIter_t monIter = _monitors.begin();
+ while(monIter != _monitors.end()) {
// (*monIter)->downloadStarted(URL(shared_from_this()));
- monIter++;
- }
- }
-
- void downloadCompleted() {
- std::cout << "Finished loading " << asString() << " with " << _content.str().size() << " bytes" << std::endl;
- _isDownloaded = true;
- }
-
- void downloadFailed(int errorCode) {
- std::cout << "FAILED!" << strerror(errorCode) << std::endl;
- }
-
- std::string getHeader(bool forceReload = false) {
- return _header.str();
- }
-
- std::string getContent(bool forceReload = false) {
- return _content.str();
- }
-
- std::stringstream _content;
- std::stringstream _header;
- CURL* _handle;
- Arabica::io::URI _uri;
- bool _isDownloaded;
-
- std::set<URLMonitor*> _monitors;
- typedef std::set<URLMonitor*>::iterator monIter_t;
+ monIter++;
+ }
+ }
+
+ void downloadCompleted() {
+ std::cout << "Finished loading " << asString() << " with " << _content.str().size() << " bytes" << std::endl;
+ _isDownloaded = true;
+ }
+
+ void downloadFailed(int errorCode) {
+ std::cout << "FAILED!" << strerror(errorCode) << std::endl;
+ }
+
+ std::string getHeader(bool forceReload = false) {
+ return _header.str();
+ }
+
+ std::string getContent(bool forceReload = false) {
+ return _content.str();
+ }
+
+ std::stringstream _content;
+ std::stringstream _header;
+ CURL* _handle;
+ Arabica::io::URI _uri;
+ bool _isDownloaded;
+
+ std::set<URLMonitor*> _monitors;
+ typedef std::set<URLMonitor*>::iterator monIter_t;
};
class URL {
@@ -128,10 +144,16 @@ public:
URL(boost::shared_ptr<URLImpl> const impl) : _impl(impl) { }
URL(const URL& other) : _impl(other._impl) { }
virtual ~URL() {};
-
- operator bool() const { return _impl; }
- bool operator< (const URL& other) const { return _impl < other._impl; }
- bool operator==(const URL& other) const { return _impl == other._impl; }
+
+ operator bool() const {
+ return _impl;
+ }
+ bool operator< (const URL& other) const {
+ return _impl < other._impl;
+ }
+ bool operator==(const URL& other) const {
+ return _impl == other._impl;
+ }
bool operator!=(const URL& other) const {
return _impl != other._impl;
}
@@ -140,208 +162,243 @@ public:
return *this;
}
- std::string getHeader() { return _impl->getHeader(); }
- std::string getContent() { return _impl->getContent(); }
-
- const bool toAbsoluteCwd() { return _impl->toAbsoluteCwd(); }
- const bool toAbsolute(const std::string& baseUrl) { return _impl->toAbsolute(baseUrl); }
- const bool toAbsolute(const URL& baseUrl) { return _impl->toAbsolute(baseUrl.asString()); }
- const std::string asLocalFile(const std::string& suffix, bool reload = false) { return _impl->asLocalFile(suffix, reload); }
+ std::string getHeader() {
+ return _impl->getHeader();
+ }
+ std::string getContent() {
+ return _impl->getContent();
+ }
- void addMonitor(URLMonitor* monitor) { _impl->addMonitor(monitor); }
- void removeMonitor(URLMonitor* monitor) { _impl->removeMonitor(monitor); }
+ const bool toAbsoluteCwd() {
+ return _impl->toAbsoluteCwd();
+ }
+ const bool toAbsolute(const std::string& baseUrl) {
+ return _impl->toAbsolute(baseUrl);
+ }
+ const bool toAbsolute(const URL& baseUrl) {
+ return _impl->toAbsolute(baseUrl.asString());
+ }
+ const std::string asLocalFile(const std::string& suffix, bool reload = false) {
+ return _impl->asLocalFile(suffix, reload);
+ }
- const bool isAbsolute() const { return _impl->isAbsolute(); }
- const std::string scheme() const { return _impl->scheme(); }
- const std::string host() const { return _impl->host(); }
- const std::string port() const { return _impl->port(); }
- const std::string path() const { return _impl->path(); }
- const std::string asString() const { return _impl->asString(); }
+ void addMonitor(URLMonitor* monitor) {
+ _impl->addMonitor(monitor);
+ }
+ void removeMonitor(URLMonitor* monitor) {
+ _impl->removeMonitor(monitor);
+ }
- friend class URLFetcher;
+ const bool isAbsolute() const {
+ return _impl->isAbsolute();
+ }
+ const std::string scheme() const {
+ return _impl->scheme();
+ }
+ const std::string host() const {
+ return _impl->host();
+ }
+ const std::string port() const {
+ return _impl->port();
+ }
+ const std::string path() const {
+ return _impl->path();
+ }
+ const std::string asString() const {
+ return _impl->asString();
+ }
+
+ friend class URLFetcher;
friend std::ostream & operator<<(std::ostream &stream, const URL& p);
protected:
- void downloadStarted() { return _impl->downloadStarted(); }
- void downloadCompleted() { return _impl->downloadCompleted(); }
- void downloadFailed(int errorCode) { return _impl->downloadFailed(errorCode); }
+ void downloadStarted() {
+ return _impl->downloadStarted();
+ }
+ void downloadCompleted() {
+ return _impl->downloadCompleted();
+ }
+ void downloadFailed(int errorCode) {
+ return _impl->downloadFailed(errorCode);
+ }
boost::shared_ptr<URLImpl> _impl;
};
class URLFetcher {
public:
- URLFetcher() {
- _multiHandle = curl_multi_init();
- start();
- }
-
- ~URLFetcher() {
- curl_multi_cleanup(_multiHandle);
- stop();
- }
-
- void fetchURL(URL& url) {
- tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
- url.downloadStarted();
- _handlesToURLs[url._impl->_handle] = url;
- curl_multi_add_handle(_multiHandle, url._impl->_handle);
- _condVar.notify_all();
- }
-
- void breakURL(URL& url) {
- tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
- if (_handlesToURLs.find(url._impl->_handle) != _handlesToURLs.end()) {
- url.downloadFailed(0);
- curl_multi_remove_handle(_multiHandle, url._impl->_handle);
- _handlesToURLs.erase(url._impl->_handle);
- }
- }
-
- void start() {
- tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
- if (!_isStarted) {
- _isStarted = true;
- _thread = new tthread::thread(URLFetcher::run, this);
- }
- }
-
- void stop() {
- tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
- if (_isStarted) {
- _isStarted = false;
- _thread->join();
- delete _thread;
- }
- }
-
- static void run(void* instance) {
- URLFetcher* THIS = (URLFetcher*)instance;
- THIS->_mutex.lock();
- while(THIS->_isStarted) {
- if(THIS->_handlesToURLs.size() > 0) {
- THIS->_mutex.unlock();
- THIS->perform();
- THIS->_mutex.lock();
- }
- THIS->_condVar.wait(THIS->_mutex);
- }
- THIS->_mutex.unlock();
- }
-
- void perform() {
-
- CURLMsg *msg; /* for picking up messages with the transfer status */
- int msgsLeft; /* how many messages are left */
- int stillRunning;
-
- {
- tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
- curl_multi_perform(_multiHandle, &stillRunning);
- }
-
- do {
- struct timeval timeout;
- int rc; /* select() return code */
-
- fd_set fdread, fdwrite, fdexcep;
- FD_ZERO(&fdread); FD_ZERO(&fdwrite); FD_ZERO(&fdexcep);
-
- int maxfd = -1;
- long curlTimeOut = -1;
-
- /* set a suitable timeout to play around with */
- timeout.tv_sec = 1;
- timeout.tv_usec = 0;
-
- {
- tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
- curl_multi_timeout(_multiHandle, &curlTimeOut);
- }
-
- if(curlTimeOut >= 0) {
- timeout.tv_sec = curlTimeOut / 1000;
- if(timeout.tv_sec > 1)
- timeout.tv_sec = 1;
- else
- timeout.tv_usec = (curlTimeOut % 1000) * 1000;
- }
-
- /* get file descriptors from the transfers */
- {
- tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
- curl_multi_fdset(_multiHandle, &fdread, &fdwrite, &fdexcep, &maxfd);
- }
-
- rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
-
- switch(rc) {
- case -1:
- /* select error */
- break;
- case 0: /* timeout */
- default: /* action */
- {
- tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
- curl_multi_perform(_multiHandle, &stillRunning);
- }
- break;
- }
-
- {
- tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
- while ((msg = curl_multi_info_read(_multiHandle, &msgsLeft))) {
- if (msg->msg == CURLMSG_DONE) {
- _handlesToURLs[msg->easy_handle].downloadCompleted();
- curl_multi_remove_handle(_multiHandle, msg->easy_handle);
- _handlesToURLs.erase(msg->easy_handle);
- } else {
- switch (msg->data.result) {
- case CURLM_OK:
- break;
- case CURLM_BAD_HANDLE:
- case CURLM_BAD_EASY_HANDLE:
- case CURLM_OUT_OF_MEMORY:
- case CURLM_INTERNAL_ERROR:
- case CURLM_BAD_SOCKET:
- case CURLM_UNKNOWN_OPTION:
- case CURLM_LAST:
- _handlesToURLs[msg->easy_handle].downloadFailed(msg->data.result);
- curl_multi_remove_handle(_multiHandle, msg->easy_handle);
- _handlesToURLs.erase(msg->easy_handle);
- default:
- break;
- }
- }
- }
- }
- } while(stillRunning && _isStarted);
-
- }
-
- tthread::condition_variable _condVar;
- tthread::thread* _thread;
+ URLFetcher() {
+ _multiHandle = curl_multi_init();
+ start();
+ }
+
+ ~URLFetcher() {
+ curl_multi_cleanup(_multiHandle);
+ stop();
+ }
+
+ void fetchURL(URL& url) {
+ tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
+ url.downloadStarted();
+ _handlesToURLs[url._impl->_handle] = url;
+ curl_multi_add_handle(_multiHandle, url._impl->_handle);
+ _condVar.notify_all();
+ }
+
+ void breakURL(URL& url) {
+ tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
+ if (_handlesToURLs.find(url._impl->_handle) != _handlesToURLs.end()) {
+ url.downloadFailed(0);
+ curl_multi_remove_handle(_multiHandle, url._impl->_handle);
+ _handlesToURLs.erase(url._impl->_handle);
+ }
+ }
+
+ void start() {
+ tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
+ if (!_isStarted) {
+ _isStarted = true;
+ _thread = new tthread::thread(URLFetcher::run, this);
+ }
+ }
+
+ void stop() {
+ tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
+ if (_isStarted) {
+ _isStarted = false;
+ _thread->join();
+ delete _thread;
+ }
+ }
+
+ static void run(void* instance) {
+ URLFetcher* THIS = (URLFetcher*)instance;
+ THIS->_mutex.lock();
+ while(THIS->_isStarted) {
+ if(THIS->_handlesToURLs.size() > 0) {
+ THIS->_mutex.unlock();
+ THIS->perform();
+ THIS->_mutex.lock();
+ }
+ THIS->_condVar.wait(THIS->_mutex);
+ }
+ THIS->_mutex.unlock();
+ }
+
+ void perform() {
+
+ CURLMsg *msg; /* for picking up messages with the transfer status */
+ int msgsLeft; /* how many messages are left */
+ int stillRunning;
+
+ {
+ tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
+ curl_multi_perform(_multiHandle, &stillRunning);
+ }
+
+ do {
+ struct timeval timeout;
+ int rc; /* select() return code */
+
+ fd_set fdread, fdwrite, fdexcep;
+ FD_ZERO(&fdread);
+ FD_ZERO(&fdwrite);
+ FD_ZERO(&fdexcep);
+
+ int maxfd = -1;
+ long curlTimeOut = -1;
+
+ /* set a suitable timeout to play around with */
+ timeout.tv_sec = 1;
+ timeout.tv_usec = 0;
+
+ {
+ tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
+ curl_multi_timeout(_multiHandle, &curlTimeOut);
+ }
+
+ if(curlTimeOut >= 0) {
+ timeout.tv_sec = curlTimeOut / 1000;
+ if(timeout.tv_sec > 1)
+ timeout.tv_sec = 1;
+ else
+ timeout.tv_usec = (curlTimeOut % 1000) * 1000;
+ }
+
+ /* get file descriptors from the transfers */
+ {
+ tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
+ curl_multi_fdset(_multiHandle, &fdread, &fdwrite, &fdexcep, &maxfd);
+ }
+
+ rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
+
+ switch(rc) {
+ case -1:
+ /* select error */
+ break;
+ case 0: /* timeout */
+ default: { /* action */
+ tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
+ curl_multi_perform(_multiHandle, &stillRunning);
+ }
+ break;
+ }
+
+ {
+ tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
+ while ((msg = curl_multi_info_read(_multiHandle, &msgsLeft))) {
+ if (msg->msg == CURLMSG_DONE) {
+ _handlesToURLs[msg->easy_handle].downloadCompleted();
+ curl_multi_remove_handle(_multiHandle, msg->easy_handle);
+ _handlesToURLs.erase(msg->easy_handle);
+ } else {
+ switch (msg->data.result) {
+ case CURLM_OK:
+ break;
+ case CURLM_BAD_HANDLE:
+ case CURLM_BAD_EASY_HANDLE:
+ case CURLM_OUT_OF_MEMORY:
+ case CURLM_INTERNAL_ERROR:
+ case CURLM_BAD_SOCKET:
+ case CURLM_UNKNOWN_OPTION:
+ case CURLM_LAST:
+ _handlesToURLs[msg->easy_handle].downloadFailed(msg->data.result);
+ curl_multi_remove_handle(_multiHandle, msg->easy_handle);
+ _handlesToURLs.erase(msg->easy_handle);
+ default:
+ break;
+ }
+ }
+ }
+ }
+ } while(stillRunning && _isStarted);
+
+ }
+
+ tthread::condition_variable _condVar;
+ tthread::thread* _thread;
tthread::recursive_mutex _mutex;
- bool _isStarted;
-
- std::map<CURL*, URL> _handlesToURLs;
- CURLM* _multiHandle;
+ bool _isStarted;
+
+ std::map<CURL*, URL> _handlesToURLs;
+ CURLM* _multiHandle;
};
int main(int argc, char** argv) {
- URLFetcher fetcher;
- URL heise("http://www.heise.de");
- URL localFile("file:///Users/sradomski/Desktop/scxml.xsd");
- URL slashdot("http://slashdot.org");
- URL asdf("daf://localhost:234");
- URL bahn("http://www.bahn.de");
-
- fetcher.fetchURL(heise);
- fetcher.fetchURL(localFile);
- fetcher.fetchURL(asdf);
- fetcher.fetchURL(slashdot);
- fetcher.fetchURL(bahn);
-
- while(1) {}
+ URLFetcher fetcher;
+ URL heise("http://www.heise.de");
+ URL localFile("file:///Users/sradomski/Desktop/scxml.xsd");
+ URL slashdot("http://slashdot.org");
+ URL asdf("daf://localhost:234");
+ URL bahn("http://www.bahn.de");
+
+ fetcher.fetchURL(heise);
+ fetcher.fetchURL(localFile);
+ fetcher.fetchURL(asdf);
+ fetcher.fetchURL(slashdot);
+ fetcher.fetchURL(bahn);
+
+ while(1) {}
} \ No newline at end of file
diff --git a/test/src/test-url.cpp b/test/src/test-url.cpp
index e3ca1e3..d4ae9bb 100644
--- a/test/src/test-url.cpp
+++ b/test/src/test-url.cpp
@@ -9,23 +9,23 @@ using namespace boost;
int main(int argc, char** argv) {
- {
- Data data = Data::fromJSON("asdf");
- std::cout << data << std::endl;
- }
- {
- Data data = Data::fromJSON("[ '1', '2', '3', '4' ]");
- std::cout << data << std::endl;
- }
- {
- Data data = Data::fromJSON("{'foo1': 'bar2', 'foo3': { 'foo4': 'bar5' }, 'foo6': 'bar7', 'foo8': { 'foo9': 'foo10': { 'foo11': 'bar12' } } }");
- std::cout << data << std::endl;
- }
- {
- Data data = Data::fromJSON("{\"firstName\": \"John\", \"lastName\": \"Smith\", \"age\": 25, \"address\": { \"streetAddress\": \"21 2nd Street\", \"city\": \"New York\",\"state\": \"NY\",\"postalCode\": 10021},\"phoneNumber\": [{\"type\": \"home\",\"number\": \"212 555-1234\"},{ \"type\": \"fax\",\"number\": \"646 555-4567\"}]}");
- std::cout << data << std::endl;
- }
-
+ {
+ Data data = Data::fromJSON("asdf");
+ std::cout << data << std::endl;
+ }
+ {
+ Data data = Data::fromJSON("[ '1', '2', '3', '4' ]");
+ std::cout << data << std::endl;
+ }
+ {
+ Data data = Data::fromJSON("{'foo1': 'bar2', 'foo3': { 'foo4': 'bar5' }, 'foo6': 'bar7', 'foo8': { 'foo9': 'foo10': { 'foo11': 'bar12' } } }");
+ std::cout << data << std::endl;
+ }
+ {
+ Data data = Data::fromJSON("{\"firstName\": \"John\", \"lastName\": \"Smith\", \"age\": 25, \"address\": { \"streetAddress\": \"21 2nd Street\", \"city\": \"New York\",\"state\": \"NY\",\"postalCode\": 10021},\"phoneNumber\": [{\"type\": \"home\",\"number\": \"212 555-1234\"},{ \"type\": \"fax\",\"number\": \"646 555-4567\"}]}");
+ std::cout << data << std::endl;
+ }
+
{
URL url("http://www.heise.de/index.html");
std::cout << url.asString() << std::endl;