summaryrefslogtreecommitdiffstats
path: root/src/uscxml
diff options
context:
space:
mode:
Diffstat (limited to 'src/uscxml')
-rw-r--r--src/uscxml/CMakeLists.txt8
-rw-r--r--src/uscxml/Interpreter.cpp4
-rw-r--r--src/uscxml/Interpreter.h2
-rw-r--r--src/uscxml/URL.cpp43
-rw-r--r--src/uscxml/URL.h2
-rw-r--r--src/uscxml/URL.mm28
-rw-r--r--src/uscxml/debug/SCXMLDotWriter.cpp464
-rw-r--r--src/uscxml/debug/SCXMLDotWriter.cpp.old359
-rw-r--r--src/uscxml/debug/SCXMLDotWriter.h57
-rw-r--r--src/uscxml/interpreter/InterpreterDraft6.cpp29
-rw-r--r--src/uscxml/plugins/datamodel/CMakeLists.txt4
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.cpp (renamed from src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.cpp)3
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h (renamed from src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h)3
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp4
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCAttr.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCDATASection.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCharacterData.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCComment.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOMImplementation.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.cpp1
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.h3
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentCustom.cpp18
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentFragment.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentType.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCElement.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntity.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntityReference.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNamedNodeMap.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.cpp.old60
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.h.old223
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeCustom.cpp23
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeList.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeSet.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNotation.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCProcessingInstruction.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCSCXMLEvent.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCStorage.cpp155
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCStorage.h73
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCText.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCXPathResult.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/Storage.cpp74
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/Storage.h30
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/V8DOM.cpp17
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h (renamed from src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h)4
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp20
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Attr.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CDATASection.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CharacterData.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Comment.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.cpp11
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOMImplementation.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.h5
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentCustom.cpp19
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentFragment.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentType.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Entity.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8EntityReference.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NamedNodeMap.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeList.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Notation.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ProcessingInstruction.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Storage.cpp83
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Storage.h90
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Text.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.h2
-rw-r--r--src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp3
-rw-r--r--src/uscxml/plugins/invoker/audio/AudioToolbox.mm18
-rw-r--r--src/uscxml/plugins/invoker/audio/OpenALInvoker.cpp13
-rw-r--r--src/uscxml/plugins/invoker/audio/OpenALInvoker.h1
-rw-r--r--src/uscxml/plugins/invoker/audio/OpenALPlayer.h2
-rw-r--r--src/uscxml/plugins/invoker/xhtml/XHTMLInvoker.cpp3
78 files changed, 1302 insertions, 737 deletions
diff --git a/src/uscxml/CMakeLists.txt b/src/uscxml/CMakeLists.txt
index d96895e..391b498 100644
--- a/src/uscxml/CMakeLists.txt
+++ b/src/uscxml/CMakeLists.txt
@@ -30,6 +30,14 @@ file(GLOB_RECURSE USCXML_INTERPRETERS
source_group("Interpreter" FILES ${USCXML_INTERPRETERS})
list (APPEND USCXML_FILES ${USCXML_INTERPRETERS})
+if(APPLE OR IOS)
+ file(GLOB_RECURSE USCXML_APPLE
+ *.mm
+ )
+ source_group("Interpreter" FILES ${USCXML_APPLE})
+ list (APPEND USCXML_FILES ${USCXML_APPLE})
+endif()
+
file(GLOB USCXML_CORE
${CMAKE_SOURCE_DIR}/contrib/src/jsmn/jsmn.c
*.cpp
diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp
index a58de6b..6b17d94 100644
--- a/src/uscxml/Interpreter.cpp
+++ b/src/uscxml/Interpreter.cpp
@@ -108,11 +108,13 @@ Interpreter Interpreter::fromURI(const std::string& uri) {
Arabica::SAX::InputSource<std::string> inputSource;
inputSource.setSystemId(absUrl.asString());
interpreter = fromInputSource(inputSource);
+#if 0
} else if (boost::iequals(absUrl.scheme(), "http")) {
- // handle http per arabica
+ // handle http per arabica - this will not follow redirects
Arabica::SAX::InputSource<std::string> inputSource;
inputSource.setSystemId(absUrl.asString());
interpreter = fromInputSource(inputSource);
+#endif
} else {
// use curl for everything else
std::stringstream ss;
diff --git a/src/uscxml/Interpreter.h b/src/uscxml/Interpreter.h
index f7ce708..f8cf823 100644
--- a/src/uscxml/Interpreter.h
+++ b/src/uscxml/Interpreter.h
@@ -65,6 +65,8 @@ enum Capabilities {
class InterpreterImpl : public boost::enable_shared_from_this<InterpreterImpl> {
public:
+ typedef std::set<InterpreterMonitor*>::iterator monIter_t;
+
enum Binding {
EARLY = 0,
LATE = 1
diff --git a/src/uscxml/URL.cpp b/src/uscxml/URL.cpp
index a58818a..4d60999 100644
--- a/src/uscxml/URL.cpp
+++ b/src/uscxml/URL.cpp
@@ -14,6 +14,8 @@
#define getcwd _getcwd
#else
#include <unistd.h>
+#include <sys/types.h>
+#include <pwd.h>
#endif
#include <cstdlib> // mkstemp
@@ -49,6 +51,42 @@ std::string URL::tmpDir() {
return tmpl;
}
+#if (!defined APPLE && !defined IOS)
+std::string URL::getResourceDir() {
+#ifdef _WIN32
+ TCHAR szPath[MAX_PATH];
+ if (SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, 0, szPath)) {
+ return szPath;
+ } else {
+ return getenv("APPDATA");
+ }
+#else
+ struct passwd* pw = getpwuid(getuid());
+ std::string homedir(pw->pw_dir);
+ struct stat dirStat;
+ int err = 0;
+
+ err = stat(std::string(homedir + PATH_SEPERATOR + ".config").c_str(), &dirStat);
+ if (err == ENOENT) {
+ err = mkdir(std::string(homedir + PATH_SEPERATOR + ".config").c_str(), S_IWUSR | S_IRUSR | S_IROTH);
+ }
+
+ err = stat(std::string(homedir + PATH_SEPERATOR + ".config" + PATH_SEPERATOR + "uscxml").c_str(), &dirStat);
+ if (err != 0) {
+ std::cout << std::string(homedir + PATH_SEPERATOR + ".config" + PATH_SEPERATOR + "uscxml") << std::endl;
+ err = mkdir(std::string(homedir + PATH_SEPERATOR + ".config" + PATH_SEPERATOR + "uscxml").c_str(),
+ S_IWUSR | S_IRUSR | S_IROTH | S_IRGRP | S_IXUSR | S_IXOTH | S_IXGRP);
+ }
+
+ err = stat(std::string(homedir + PATH_SEPERATOR + ".config" + PATH_SEPERATOR + "uscxml").c_str(), &dirStat);
+ if (err == 0) {
+ return homedir + PATH_SEPERATOR + ".config" + PATH_SEPERATOR + "uscxml";
+ }
+ return "";
+#endif
+}
+#endif
+
URLImpl::URLImpl(const std::string& url) : _handle(NULL), _uri(url), _isDownloaded(false), _hasFailed(false) {
std::stringstream ss(_uri.path());
std::string item;
@@ -461,6 +499,11 @@ void URLFetcher::fetchURL(URL& url) {
(curlError = curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, false)) == CURLE_OK ||
LOG(ERROR) << "Cannot forfeit peer verification: " << curl_easy_strerror(curlError);
+ (curlError = curl_easy_setopt(handle, CURLOPT_USERAGENT, "curl/7.31.0")) == CURLE_OK ||
+ LOG(ERROR) << "Cannot set our user agent string: " << curl_easy_strerror(curlError);
+
+ (curlError = curl_easy_setopt(handle, CURLOPT_FOLLOWLOCATION, true)) == CURLE_OK ||
+ LOG(ERROR) << "Cannot enable follow redirects: " << curl_easy_strerror(curlError);
if (boost::iequals(url._impl->_requestType, "post")) {
diff --git a/src/uscxml/URL.h b/src/uscxml/URL.h
index b6d8a86..3acd462 100644
--- a/src/uscxml/URL.h
+++ b/src/uscxml/URL.h
@@ -204,6 +204,8 @@ public:
static URL asBaseURL(const URL& url);
static void toBaseURL(URL& uri);
+ static std::string getResourceDir();
+
static URL toLocalFile(const std::string& content, const std::string& suffix) {
boost::shared_ptr<URLImpl> impl = URLImpl::toLocalFile(content, suffix);
return URL(impl);
diff --git a/src/uscxml/URL.mm b/src/uscxml/URL.mm
new file mode 100644
index 0000000..46975a0
--- /dev/null
+++ b/src/uscxml/URL.mm
@@ -0,0 +1,28 @@
+#include "URL.h"
+#include "Foundation/Foundation.h"
+
+#ifdef __has_feature
+# if __has_feature(objc_arc)
+# define(HAS_AUTORELEASE_POOL)
+# endif
+#endif
+
+namespace uscxml {
+
+std::string URL::getResourceDir() {
+#if HAS_AUTORELEASE_POOL
+ @autoreleasepool {
+#else
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+#endif
+ NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
+ return [resourcePath cStringUsingEncoding:NSUTF8StringEncoding];
+
+#if HAS_AUTORELEASE_POOL
+ }
+#else
+ [pool drain];
+#endif
+}
+
+}
diff --git a/src/uscxml/debug/SCXMLDotWriter.cpp b/src/uscxml/debug/SCXMLDotWriter.cpp
new file mode 100644
index 0000000..d6a9a49
--- /dev/null
+++ b/src/uscxml/debug/SCXMLDotWriter.cpp
@@ -0,0 +1,464 @@
+#include "uscxml/Common.h"
+#include "SCXMLDotWriter.h"
+#include <boost/algorithm/string.hpp> // replace_all
+#include <iomanip>
+
+namespace uscxml {
+
+using namespace Arabica::DOM;
+
+SCXMLDotWriter::SCXMLDotWriter() {
+ _iteration = 0;
+ _indentation = 0;
+}
+
+SCXMLDotWriter::SCXMLDotWriter(Interpreter interpreter, const Arabica::XPath::NodeSet<std::string>& transitions) {
+ _interpreter = interpreter;
+ _transitions = transitions;
+ _iteration = 0;
+ _indentation = 0;
+}
+
+SCXMLDotWriter::~SCXMLDotWriter() {
+
+}
+
+void SCXMLDotWriter::onStableConfiguration(Interpreter interpreter) {
+ std::ostringstream fileSS;
+ fileSS << interpreter.getName() << "." << std::setw(6) << std::setfill('0') << _iteration++ << ".dot";
+ toDot(fileSS.str(), interpreter);
+}
+
+void SCXMLDotWriter::afterCompletion(Interpreter interpreter) {
+ std::ostringstream fileSS;
+ fileSS << interpreter.getName() << "." << std::setw(6) << std::setfill('0') << _iteration++ << ".dot";
+ toDot(fileSS.str(), interpreter);
+}
+
+void SCXMLDotWriter::beforeMicroStep(Interpreter interpreter) {
+// std::ostringstream fileSS;
+// fileSS << interpreter.getName() << "." << std::setw(6) << std::setfill('0') << _iteration++ << ".dot";
+// toDot(fileSS.str(), interpreter);
+}
+
+void SCXMLDotWriter::beforeTakingTransitions(Interpreter interpreter, const Arabica::XPath::NodeSet<std::string>& transitions) {
+ std::ostringstream fileSS;
+ fileSS << interpreter.getName() << "." << std::setw(6) << std::setfill('0') << _iteration++ << ".dot";
+ toDot(fileSS.str(), interpreter, transitions);
+}
+
+std::string SCXMLDotWriter::getPrefix() {
+ std::string prefix = "";
+ for (int i = 0; i < _indentation; i++)
+ prefix += " ";
+ return prefix;
+}
+
+void SCXMLDotWriter::toDot(const std::string& filename, Interpreter interpreter, const Arabica::XPath::NodeSet<std::string>& transitions) {
+ std::ofstream outfile(filename.c_str());
+ NodeList<std::string > scxmlElems = interpreter.getDocument().getElementsByTagName("scxml");
+ SCXMLDotWriter writer(interpreter, transitions);
+ if (scxmlElems.getLength() > 0) {
+ writer._indentation++;
+ outfile << "digraph {" << std::endl;
+ outfile << "rankdir=TB; fontsize=10;" << std::endl;
+ writer.writeSCXMLElement(outfile, (Arabica::DOM::Element<std::string>)scxmlElems.item(0));
+ writer._indentation--;
+ outfile << "}" << std::endl;
+ }
+
+}
+
+void SCXMLDotWriter::writeSCXMLElement(std::ostream& os, const Arabica::DOM::Element<std::string>& elem) {
+ writeStateElement(os, elem);
+
+// std::string elemId = idForNode(elem);
+// os << getPrefix() << "subgraph \"cluster" << elemId.substr(1, elemId.length() - 1) << " {" << std::endl;
+// _indentation++;
+// os << getPrefix() << "label=\"" << nameForNode(elem) << "\"" << std::endl;
+// writeStateElement(os, (Arabica::DOM::Element<std::string>)_interpreter->getInitialState());
+// os << getPrefix() << "} " << std::endl;
+
+}
+
+void SCXMLDotWriter::writeStateElement(std::ostream& os, const Arabica::DOM::Element<std::string>& elem) {
+
+ std::string elemId = idForNode(elem);
+ NodeList<std::string > childElems = elem.getChildNodes();
+
+ if (_knownIds.find(elemId) != _knownIds.end())
+ return;
+ _knownIds.insert(elemId);
+
+ bool subgraph = Interpreter::isCompound(elem) || Interpreter::isParallel(elem);
+ if (subgraph) {
+ _indentation++;
+ os << getPrefix() << "subgraph \"cluster_" << elemId << "\" {" << std::endl;
+ os << getPrefix() << "label=\"" << nameForNode(elem) << "\\l\"" << std::endl;
+ }
+
+ os << getPrefix() << "\"" << elemId << "\"[";
+ os << "fontsize=10,";
+ os << "label=<<b>State</b><br />" << nameForNode(elem) << ">,";
+
+ // is the state initial?
+ if (_interpreter.isInitial(elem))
+ os << "style=filled, fillcolor=lightgrey, ";
+
+ // is this state final?
+ if (_interpreter.isFinal(elem))
+ os << "shape=doublecircle,";
+
+ // is the current state in the basic configuration?
+ if (_interpreter.isMember(elem, _interpreter.getBasicConfiguration()))
+ os << "color=red, penwidth=3,";
+
+ // is the current state a target state?
+#if 0
+ for (int i = 0; i < _transitions.size(); i++) {
+ if (_interpreter.isMember(elem, _interpreter.getTargetStates(_transitions[i]))) {
+ os << "color=red, penwidth=3,";
+ break;
+ }
+ }
+#endif
+
+ os << "];" << std::endl;
+
+ std::string details = getDetailedLabel(elem);
+// std::cout << details << std::endl;
+
+ if (details.size() > 0) {
+ os << getPrefix() << "\"" << elemId << "Exec\"[";
+ os << "fontsize=8,";
+ os << "shape=box,";
+ os << "color=grey,";
+ os << "label=<" << details << ">";
+ os << "]" << std::endl;
+ os << getPrefix() << "\"" << elemId << "\" -> \"" << elemId << "Exec\" [arrowhead=none, color=grey]" << std::endl;
+ }
+
+// NodeList<std::string > childElems = elem.getChildNodes();
+// for (int i = 0; i < childElems.getLength(); i++) {
+// if (Interpreter::isState(childElems.item(i))) {
+// writeStateElement(os, (Arabica::DOM::Element<std::string>)childElems.item(i));
+// }
+// }
+
+ for (int i = 0; i < childElems.getLength(); i++) {
+ if (childElems.item(i).getNodeType() == Node_base::ELEMENT_NODE && boost::iequals(TAGNAME(childElems.item(i)), "transition")) {
+ writeTransitionElement(os, (Arabica::DOM::Element<std::string>)childElems.item(i));
+ bool active = Interpreter::isMember(childElems.item(i), _transitions);
+ os << getPrefix() << "\"" << elemId << "\" -> \"" << idForNode(childElems.item(i)) << "\" [arrowhead=none" << std::endl;
+ if (active) {
+ os << ", penwidth=3, color=red]" << std::endl;
+ } else {
+ os << "]" << std::endl;
+ }
+ }
+ if (Interpreter::isState(childElems.item(i))) {
+ writeStateElement(os, (Arabica::DOM::Element<std::string>)childElems.item(i));
+ }
+ if (childElems.item(i).getNodeType() == Node_base::ELEMENT_NODE && boost::iequals(TAGNAME(childElems.item(i)), "initial")) {
+ NodeList<std::string > grandChildElems = childElems.item(i).getChildNodes();
+ for (int j = 0; j < grandChildElems.getLength(); j++) {
+ if (grandChildElems.item(j).getNodeType() == Node_base::ELEMENT_NODE && boost::iequals(TAGNAME(grandChildElems.item(j)), "transition")) {
+ writeTransitionElement(os, (Arabica::DOM::Element<std::string>)grandChildElems.item(j));
+ os << getPrefix() << "\"" << elemId << "\" -> \"" << idForNode(grandChildElems.item(j)) << "\"" << std::endl;
+ }
+ }
+ }
+ }
+
+ if (subgraph) {
+ _indentation--;
+ os << getPrefix() << "} " << std::endl;
+ }
+
+}
+
+void SCXMLDotWriter::writeTransitionElement(std::ostream& os, const Arabica::DOM::Element<std::string>& elem) {
+ std::string elemId = idForNode(elem);
+
+ Arabica::XPath::NodeSet<std::string> targetStates = _interpreter.getTargetStates(elem);
+
+ bool active = Interpreter::isMember(elem, _transitions);
+
+ std::string label;
+ os << getPrefix() << "\"" << elemId << "\"[";
+ if (active) {
+ os << "color=red, penwidth=3, ";
+ }
+ os << "fontsize=10,";
+ os << "shape=box,";
+ os << "label=<<b>Transition</b><br align=\"left\" />";
+ if (HAS_ATTR(elem, "event"))
+ os << "event: " << ATTR(elem, "event");
+ if (HAS_ATTR(elem, "cond"))
+ os << "cond: " << dotEscape(ATTR(elem, "cond"));
+ if (!HAS_ATTR(elem, "cond") && !HAS_ATTR(elem, "event"))
+ os << "unconditional";
+ os << ">";
+ os << "]" << std::endl;
+
+ for (int i = 0; i < targetStates.size(); i++) {
+ os << getPrefix() << "\"" << elemId << "\" -> \"" << idForNode(targetStates[i]) << "\"";
+ if (active) {
+ os << " [penwidth=3, color=red]" << std::endl;
+ } else {
+ os << std::endl;
+ }
+ writeStateElement(os, (Arabica::DOM::Element<std::string>)targetStates[i]);
+ }
+
+}
+
+std::string SCXMLDotWriter::getDetailedLabel(const Arabica::DOM::Element<std::string>& elem, int indentation) {
+
+ /*
+ <table>
+ <tr>
+ <td colspan="2">onEntry</td>
+ </tr>
+ <tr>
+ <td>Details</td>
+ <td bgcolor="#eee">
+ Nested Content
+ </td>
+ </tr>
+ </table>
+ */
+
+ std::list<struct ElemDetails> content;
+
+ NodeList<std::string > childElems = elem.getChildNodes();
+ for (int i = 0; i < childElems.getLength(); i++) {
+ if (childElems.item(i).getNodeType() != Node_base::ELEMENT_NODE)
+ continue;
+
+ if (Interpreter::isState(childElems.item(i)) ||
+ boost::iequals(TAGNAME(childElems.item(i)), "transition") ||
+ boost::iequals(TAGNAME(childElems.item(i)), "initial") ||
+ false)
+ continue;
+
+ struct ElemDetails details;
+ details.name = "<b>" + TAGNAME(childElems.item(i)) + ":</b>";
+
+ // provide details for special elements here
+
+ // param ---------
+ if (boost::iequals(TAGNAME(childElems.item(i)), "param")) {
+ if (HAS_ATTR(childElems.item(i), "name"))
+ details.name += " " + ATTR(childElems.item(i), "name") + " = ";
+ if (HAS_ATTR(childElems.item(i), "expr"))
+ details.name += ATTR(childElems.item(i), "expr");
+ if (HAS_ATTR(childElems.item(i), "location"))
+ details.name += ATTR(childElems.item(i), "location");
+ }
+
+ // data ---------
+ if (boost::iequals(TAGNAME(childElems.item(i)), "data")) {
+ if (HAS_ATTR(childElems.item(i), "id"))
+ details.name += " " + ATTR(childElems.item(i), "id");
+ if (HAS_ATTR(childElems.item(i), "src"))
+ details.name += ATTR(childElems.item(i), "src");
+ if (HAS_ATTR(childElems.item(i), "expr"))
+ details.name += " = " + ATTR(childElems.item(i), "expr");
+ NodeList<std::string > grandChildElems = childElems.item(i).getChildNodes();
+ for (int j = 0; j < grandChildElems.getLength(); j++) {
+ if (grandChildElems.item(j).getNodeType() == Node_base::TEXT_NODE) {
+ details.name += dotEscape(grandChildElems.item(j).getNodeValue());
+ }
+ }
+ }
+
+ // invoke ---------
+ if (boost::iequals(TAGNAME(childElems.item(i)), "invoke")) {
+ if (HAS_ATTR(childElems.item(i), "type"))
+ details.name += "<br />type = " + ATTR(childElems.item(i), "type");
+ if (HAS_ATTR(childElems.item(i), "typeexpr"))
+ details.name += "<br />type = " + ATTR(childElems.item(i), "typeexpr");
+ if (HAS_ATTR(childElems.item(i), "src"))
+ details.name += "<br />src = " + ATTR(childElems.item(i), "src");
+ if (HAS_ATTR(childElems.item(i), "srcexpr"))
+ details.name += "<br />src = " + ATTR(childElems.item(i), "srcexpr");
+ if (HAS_ATTR(childElems.item(i), "id"))
+ details.name += "<br />id = " + ATTR(childElems.item(i), "id");
+ if (HAS_ATTR(childElems.item(i), "idlocation"))
+ details.name += "<br />id = " + ATTR(childElems.item(i), "idlocation");
+ }
+
+ // send ---------
+ if (boost::iequals(TAGNAME(childElems.item(i)), "send")) {
+ if (HAS_ATTR(childElems.item(i), "type"))
+ details.name += "<br />type = " + ATTR(childElems.item(i), "type");
+ if (HAS_ATTR(childElems.item(i), "typeexpr"))
+ details.name += "<br />type = " + ATTR(childElems.item(i), "typeexpr");
+ if (HAS_ATTR(childElems.item(i), "event"))
+ details.name += "<br />event = " + ATTR(childElems.item(i), "event");
+ if (HAS_ATTR(childElems.item(i), "eventexpr"))
+ details.name += "<br />event = " + ATTR(childElems.item(i), "eventexpr");
+ if (HAS_ATTR(childElems.item(i), "target"))
+ details.name += "<br />target = " + ATTR(childElems.item(i), "target");
+ if (HAS_ATTR(childElems.item(i), "targetexpr"))
+ details.name += "<br />target = " + ATTR(childElems.item(i), "targetexpr");
+ if (HAS_ATTR(childElems.item(i), "delay"))
+ details.name += "<br />delay = " + ATTR(childElems.item(i), "delay");
+ if (HAS_ATTR(childElems.item(i), "delayexpr"))
+ details.name += "<br />delay = " + ATTR(childElems.item(i), "delayexpr");
+ }
+
+ // script ---------
+ if (boost::iequals(TAGNAME(childElems.item(i)), "script")) {
+ details.name += " ";
+ if (HAS_ATTR(childElems.item(i), "src"))
+ details.name += ATTR(childElems.item(i), "src");
+ NodeList<std::string > grandChildElems = childElems.item(i).getChildNodes();
+ for (int j = 0; j < grandChildElems.getLength(); j++) {
+ if (grandChildElems.item(j).getNodeType() == Node_base::TEXT_NODE) {
+ details.name += dotEscape(grandChildElems.item(j).getNodeValue());
+ }
+ }
+ }
+
+ // if ---------
+ if (boost::iequals(TAGNAME(childElems.item(i)), "if")) {
+ if (HAS_ATTR(childElems.item(i), "cond"))
+ details.name += " cond = " + dotEscape(ATTR(childElems.item(i), "cond"));
+ }
+
+ // elseif ---------
+ if (boost::iequals(TAGNAME(childElems.item(i)), "elseif")) {
+ if (HAS_ATTR(childElems.item(i), "cond"))
+ details.name += " cond = " + dotEscape(ATTR(childElems.item(i), "cond"));
+ }
+
+ // log ---------
+ if (boost::iequals(TAGNAME(childElems.item(i)), "log")) {
+ details.name += " ";
+ if (HAS_ATTR(childElems.item(i), "label"))
+ details.name += ATTR(childElems.item(i), "label") + " = ";
+ if (HAS_ATTR(childElems.item(i), "expr"))
+ details.name += ATTR(childElems.item(i), "expr");
+ }
+
+ // foreach ---------
+ if (boost::iequals(TAGNAME(childElems.item(i)), "foreach")) {
+ if (HAS_ATTR(childElems.item(i), "item"))
+ details.name += "<br />&nbsp;&nbsp;item = " + ATTR(childElems.item(i), "item");
+ if (HAS_ATTR(childElems.item(i), "array"))
+ details.name += "<br />&nbsp;&nbsp;array = " + ATTR(childElems.item(i), "array");
+ if (HAS_ATTR(childElems.item(i), "index"))
+ details.name += "<br />&nbsp;&nbsp;index = " + ATTR(childElems.item(i), "index");
+ }
+
+ // recurse
+ details.content = getDetailedLabel((Arabica::DOM::Element<std::string>)childElems.item(i), indentation + 1);
+ content.push_back(details);
+ }
+
+ std::stringstream ssContent;
+
+ if (content.size() > 0) {
+ ssContent << "<table cellspacing=\"2\" cellpadding=\"0\" border=\"0\">";
+
+ std::list<struct ElemDetails>::iterator contentIter = content.begin();
+ while(contentIter != content.end()) {
+ ssContent << "<tr>";
+// ssContent << "<td align=\"left\" colspan=\"2\">" << contentIter->name << "</td>";
+ ssContent << "<td balign=\"left\" align=\"left\">" << contentIter->name << "</td>";
+ ssContent << "</tr>";
+
+ if (contentIter->content.size() > 0) {
+ ssContent << "<tr>";
+// ssContent << "<td>" << contentIter->details << "</td>";
+ ssContent << "<td bgcolor=\"#" << colorForIndent(indentation + 1) << "\">" << contentIter->content << "</td>";
+ ssContent << "</tr>";
+ }
+ contentIter++;
+
+ }
+ ssContent << "</table>";
+ }
+ return ssContent.str();
+}
+
+std::string SCXMLDotWriter::dotEscape(const std::string& text) {
+ std::string escaped(text);
+ boost::replace_all(escaped, " ", "&nbsp;");
+ boost::replace_all(escaped, "\t", "&nbsp;&nbsp;&nbsp;");
+ boost::replace_all(escaped, "<", "&lt;");
+ boost::replace_all(escaped, ">", "&gt;");
+ boost::replace_all(escaped, "\"", "&quot;");
+ boost::replace_all(escaped, "\n", "<br />");
+
+ return escaped;
+}
+
+std::string SCXMLDotWriter::colorForIndent(int indent) {
+ int color = 255 - (16 * indent);
+ std::stringstream ss;
+ ss << std::hex << color;
+ ss << std::hex << color;
+ ss << std::hex << color;
+ return ss.str();
+}
+
+std::string SCXMLDotWriter::nameForNode(const Arabica::DOM::Node<std::string>& node) {
+ std::string elemName;
+ if (node.getNodeType() == Node_base::ELEMENT_NODE) {
+ Arabica::DOM::Element<std::string> elem = (Arabica::DOM::Element<std::string>)node;
+ if (elem.hasAttribute("name")) {
+ elemName = elem.getAttribute("name");
+ } else if (elem.hasAttribute("id")) {
+ elemName = elem.getAttribute("id");
+ }
+ }
+ if (elemName.size() == 0)
+ elemName = boost::lexical_cast<std::string>(node.getLocalName());
+
+ return elemName;
+
+}
+
+std::string SCXMLDotWriter::idForNode(const Arabica::DOM::Node<std::string>& node) {
+ std::string elemId;
+
+ // try to get the id as the name or id attribute
+ if (node.getNodeType() == Node_base::ELEMENT_NODE) {
+ Arabica::DOM::Element<std::string> elem = (Arabica::DOM::Element<std::string>)node;
+ if (elem.hasAttribute("name")) {
+ elemId = elem.getAttribute("name");
+ } else if (elem.hasAttribute("id")) {
+ elemId = elem.getAttribute("id");
+ }
+ }
+
+ // no luck, create id from position in tree
+ if (elemId.size() == 0) {
+ Arabica::DOM::Node<std::string> tmpParent = node;
+ Arabica::DOM::Node<std::string> tmpIndex;
+ do {
+ if (tmpParent.getNodeType() != Node_base::ELEMENT_NODE)
+ continue;
+
+ tmpIndex = tmpParent;
+ int index = 0;
+
+ while((tmpIndex = tmpIndex.getPreviousSibling()))
+ index++;
+
+ std::stringstream ssElemId;
+ ssElemId << TAGNAME(tmpParent) << index << ".";
+ elemId = ssElemId.str() + elemId;
+ } while ((tmpParent = tmpParent.getParentNode()));
+// elemId = ssElemId.str();
+ }
+
+ std::replace(elemId.begin(), elemId.end(), '-', '_');
+
+ return elemId;
+}
+
+} \ No newline at end of file
diff --git a/src/uscxml/debug/SCXMLDotWriter.cpp.old b/src/uscxml/debug/SCXMLDotWriter.cpp.old
deleted file mode 100644
index 20d82c9..0000000
--- a/src/uscxml/debug/SCXMLDotWriter.cpp.old
+++ /dev/null
@@ -1,359 +0,0 @@
-#include "uscxml/Common.h"
-#include "SCXMLDotWriter.h"
-#include "uscxml/Interpreter.h"
-#include <boost/algorithm/string.hpp> // replace_all
-
-namespace uscxml {
-
-using namespace Arabica::DOM;
-
-int SCXMLDotWriter::_indentation = 0;
-
-SCXMLDotWriter::SCXMLDotWriter(Interpreter* interpreter) {
- _interpreter = interpreter;
-}
-
-SCXMLDotWriter::~SCXMLDotWriter() {
-
-}
-
-std::string SCXMLDotWriter::getPrefix() {
- std::string prefix = "";
- for (int i = 0; i < _indentation; i++)
- prefix += " ";
- return prefix;
-}
-
-void SCXMLDotWriter::toDot(const std::string& filename, Interpreter* interpreter) {
- std::ofstream outfile(filename.c_str());
- NodeList<std::string > scxmlElems = interpreter->getDocument().getElementsByTagName("scxml");
- SCXMLDotWriter writer(interpreter);
- if (scxmlElems.getLength() > 0) {
- _indentation++;
- outfile << "digraph {" << std::endl;
- outfile << "rankdir=LR;" << std::endl;
- writer.writeSCXMLElement(outfile, (Arabica::DOM::Element<std::string>)scxmlElems.item(0));
- _indentation--;
- outfile << "}" << std::endl;
- }
-
-}
-
-void SCXMLDotWriter::writeSCXMLElement(std::ostream& os, const Arabica::DOM::Element<std::string>& elem) {
- writeStateElement(os, elem);
-
-// std::string elemId = idForNode(elem);
-// os << getPrefix() << "subgraph \"cluster" << elemId.substr(1, elemId.length() - 1) << " {" << std::endl;
-// _indentation++;
-// os << getPrefix() << "label=\"" << nameForNode(elem) << "\"" << std::endl;
-// writeStateElement(os, (Arabica::DOM::Element<std::string>)_interpreter->getInitialState());
-// os << getPrefix() << "} " << std::endl;
-
-}
-
-void SCXMLDotWriter::writeStateElement(std::ostream& os, const Arabica::DOM::Element<std::string>& elem) {
-
- std::string elemId = idForNode(elem);
- NodeList<std::string > childElems = elem.getChildNodes();
-
- if (_knownIds.find(elemId) != _knownIds.end())
- return;
- _knownIds.insert(elemId);
-
- bool subgraph = Interpreter::isCompound(elem) || Interpreter::isParallel(elem);
- if (subgraph) {
- _indentation++;
- os << getPrefix() << "subgraph \"cluster_" << elemId << "\" {" << std::endl;
- os << getPrefix() << "label=\"" << nameForNode(elem) << "\\l\"" << std::endl;
- }
-
- os << getPrefix() << "\"" << elemId << "\"[";
- os << "label=<<b>State</b><br />" << nameForNode(elem) << ">,";
- if (_interpreter->isInitial(elem))
- os << "style=filled,";
- if (_interpreter->isFinal(elem))
- os << "shape=doublecircle,";
- os << "];" << std::endl;
-
- std::string details = getDetailedLabel(elem);
-// std::cout << details << std::endl;
-
- if (details.size() > 0) {
- os << getPrefix() << "\"" << elemId << "Exec\"[";
-// os << "fontsize=10,";
- os << "shape=box,";
- os << "color=grey,";
- os << "label=<" << details << ">";
- os << "]" << std::endl;
- os << getPrefix() << "\"" << elemId << "\" -> \"" << elemId << "Exec\" [arrowhead=none, color=grey]" << std::endl;
- }
-
-// NodeList<std::string > childElems = elem.getChildNodes();
-// for (int i = 0; i < childElems.getLength(); i++) {
-// if (Interpreter::isState(childElems.item(i))) {
-// writeStateElement(os, (Arabica::DOM::Element<std::string>)childElems.item(i));
-// }
-// }
-
- for (int i = 0; i < childElems.getLength(); i++) {
- if (childElems.item(i).getNodeType() == Node_base::ELEMENT_NODE && boost::iequals(TAGNAME(childElems.item(i)), "transition")) {
- writeTransitionElement(os, (Arabica::DOM::Element<std::string>)childElems.item(i));
- os << getPrefix() << "\"" << elemId << "\" -> \"" << idForNode(childElems.item(i)) << "\"" << std::endl;
- }
- if (Interpreter::isState(childElems.item(i))) {
- writeStateElement(os, (Arabica::DOM::Element<std::string>)childElems.item(i));
- }
- if (childElems.item(i).getNodeType() == Node_base::ELEMENT_NODE && boost::iequals(TAGNAME(childElems.item(i)), "initial")) {
- NodeList<std::string > grandChildElems = childElems.item(i).getChildNodes();
- for (int j = 0; j < grandChildElems.getLength(); j++) {
- if (grandChildElems.item(j).getNodeType() == Node_base::ELEMENT_NODE && boost::iequals(TAGNAME(grandChildElems.item(j)), "transition")) {
- writeTransitionElement(os, (Arabica::DOM::Element<std::string>)grandChildElems.item(j));
- os << getPrefix() << "\"" << elemId << "\" -> \"" << idForNode(grandChildElems.item(j)) << "\"" << std::endl;
- }
- }
- }
- }
-
- if (subgraph) {
- _indentation--;
- os << getPrefix() << "} " << std::endl;
- }
-
-}
-
-void SCXMLDotWriter::writeTransitionElement(std::ostream& os, const Arabica::DOM::Element<std::string>& elem) {
- std::string elemId = idForNode(elem);
-
- Arabica::XPath::NodeSet<std::string> targetStates = _interpreter->getTargetStates(elem);
-
- std::string label;
- os << getPrefix() << "\"" << elemId << "\"[";
-// os << "fontsize=10,";
- os << "shape=box,";
- os << "label=<<b>Transition</b><br align=\"left\" />";
- if (HAS_ATTR(elem, "event"))
- os << "event: " << ATTR(elem, "event");
- if (HAS_ATTR(elem, "cond"))
- os << "cond: " << ATTR(elem, "cond");
- if (!HAS_ATTR(elem, "cond") && !HAS_ATTR(elem, "event"))
- os << "unconditional";
- os << ">";
- os << "]" << std::endl;
-
- for (int i = 0; i < targetStates.size(); i++) {
- os << getPrefix() << "\"" << elemId << "\" -> \"" << idForNode(targetStates[i]) << "\"" << std::endl;
- writeStateElement(os, (Arabica::DOM::Element<std::string>)targetStates[i]);
- }
-
-}
-
-std::string SCXMLDotWriter::getDetailedLabel(const Arabica::DOM::Element<std::string>& elem, int indentation) {
-
-/*
- <table>
- <tr>
- <td colspan="2">onEntry</td>
- </tr>
- <tr>
- <td>Details</td>
- <td bgcolor="#eee">
- Nested Content
- </td>
- </tr>
- </table>
-*/
-
- std::list<struct ElemDetails> content;
-
- NodeList<std::string > childElems = elem.getChildNodes();
- for (int i = 0; i < childElems.getLength(); i++) {
- if (childElems.item(i).getNodeType() != Node_base::ELEMENT_NODE)
- continue;
-
- if (Interpreter::isState(childElems.item(i)) ||
- boost::iequals(TAGNAME(childElems.item(i)), "transition") ||
- boost::iequals(TAGNAME(childElems.item(i)), "initial") ||
- false)
- continue;
-
- struct ElemDetails details;
- details.name = "<b>" + TAGNAME(childElems.item(i)) + "</b>";
-
- // provide details for special elements here
-
- // param ---------
- if (boost::iequals(TAGNAME(childElems.item(i)), "param")) {
- if (HAS_ATTR(childElems.item(i), "name"))
- details.name += " " + ATTR(childElems.item(i), "name") + " = ";
- if (HAS_ATTR(childElems.item(i), "expr"))
- details.name += ATTR(childElems.item(i), "expr");
- if (HAS_ATTR(childElems.item(i), "location"))
- details.name += ATTR(childElems.item(i), "location");
- }
-
- // data ---------
- if (boost::iequals(TAGNAME(childElems.item(i)), "data")) {
- if (HAS_ATTR(childElems.item(i), "id"))
- details.name += " " + ATTR(childElems.item(i), "id") + " = ";
- if (HAS_ATTR(childElems.item(i), "src"))
- details.name += ATTR(childElems.item(i), "src");
- if (HAS_ATTR(childElems.item(i), "expr"))
- details.name += ATTR(childElems.item(i), "expr");
- NodeList<std::string > grandChildElems = childElems.item(i).getChildNodes();
- for (int j = 0; j < grandChildElems.getLength(); j++) {
- if (grandChildElems.item(j).getNodeType() == Node_base::TEXT_NODE) {
- details.name += dotEscape(grandChildElems.item(j).getNodeValue());
- }
- }
- }
-
- // invoke ---------
- if (boost::iequals(TAGNAME(childElems.item(i)), "invoke")) {
- if (HAS_ATTR(childElems.item(i), "type"))
- details.name += "<br />type = " + ATTR(childElems.item(i), "type");
- if (HAS_ATTR(childElems.item(i), "typeexpr"))
- details.name += "<br />type = " + ATTR(childElems.item(i), "typeexpr");
- if (HAS_ATTR(childElems.item(i), "src"))
- details.name += "<br />src = " + ATTR(childElems.item(i), "src");
- if (HAS_ATTR(childElems.item(i), "srcexpr"))
- details.name += "<br />src = " + ATTR(childElems.item(i), "srcexpr");
- if (HAS_ATTR(childElems.item(i), "id"))
- details.name += "<br />id = " + ATTR(childElems.item(i), "id");
- if (HAS_ATTR(childElems.item(i), "idlocation"))
- details.name += "<br />id = " + ATTR(childElems.item(i), "idlocation");
- }
-
- // send ---------
- if (boost::iequals(TAGNAME(childElems.item(i)), "send")) {
- if (HAS_ATTR(childElems.item(i), "type"))
- details.name += "<br />type = " + ATTR(childElems.item(i), "type");
- if (HAS_ATTR(childElems.item(i), "typeexpr"))
- details.name += "<br />type = " + ATTR(childElems.item(i), "typeexpr");
- if (HAS_ATTR(childElems.item(i), "event"))
- details.name += "<br />event = " + ATTR(childElems.item(i), "event");
- if (HAS_ATTR(childElems.item(i), "eventexpr"))
- details.name += "<br />event = " + ATTR(childElems.item(i), "eventexpr");
- if (HAS_ATTR(childElems.item(i), "target"))
- details.name += "<br />target = " + ATTR(childElems.item(i), "target");
- if (HAS_ATTR(childElems.item(i), "targetexpr"))
- details.name += "<br />target = " + ATTR(childElems.item(i), "targetexpr");
- if (HAS_ATTR(childElems.item(i), "delay"))
- details.name += "<br />delay = " + ATTR(childElems.item(i), "delay");
- if (HAS_ATTR(childElems.item(i), "delayexpr"))
- details.name += "<br />delay = " + ATTR(childElems.item(i), "delayexpr");
- }
-
- // script ---------
- if (boost::iequals(TAGNAME(childElems.item(i)), "script")) {
- details.name += " ";
- if (HAS_ATTR(childElems.item(i), "src"))
- details.name += ATTR(childElems.item(i), "src");
- NodeList<std::string > grandChildElems = childElems.item(i).getChildNodes();
- for (int j = 0; j < grandChildElems.getLength(); j++) {
- if (grandChildElems.item(j).getNodeType() == Node_base::TEXT_NODE) {
- details.name += dotEscape(grandChildElems.item(j).getNodeValue());
- }
- }
- }
-
- // recurse
- details.content = getDetailedLabel((Arabica::DOM::Element<std::string>)childElems.item(i), indentation + 1);
- content.push_back(details);
- }
-
- std::stringstream ssContent;
-
- if (content.size() > 0) {
- ssContent << "<table cellspacing=\"2\" cellpadding=\"0\" border=\"0\">";
-
- std::list<struct ElemDetails>::iterator contentIter = content.begin();
- while(contentIter != content.end()) {
- ssContent << "<tr>";
-// ssContent << "<td align=\"left\" colspan=\"2\">" << contentIter->name << "</td>";
- ssContent << "<td balign=\"left\" align=\"left\">" << contentIter->name << "</td>";
- ssContent << "</tr>";
-
- if (contentIter->content.size() > 0) {
- ssContent << "<tr>";
-// ssContent << "<td>" << contentIter->details << "</td>";
- ssContent << "<td bgcolor=\"#" << colorForIndent(indentation + 1) << "\">" << contentIter->content << "</td>";
- ssContent << "</tr>";
- }
- contentIter++;
-
- }
- ssContent << "</table>";
- }
- return ssContent.str();
-}
-
-std::string SCXMLDotWriter::dotEscape(const std::string& text) {
- std::string escaped(text);
- boost::replace_all(escaped, "", "");
-
- return escaped;
-}
-
-std::string SCXMLDotWriter::colorForIndent(int indent) {
- int color = 255 - (16 * indent);
- std::stringstream ss;
- ss << std::hex << color;
- ss << std::hex << color;
- ss << std::hex << color;
- return ss.str();
-}
-
-std::string SCXMLDotWriter::nameForNode(const Arabica::DOM::Node<std::string>& node) {
- std::string elemName;
- if (node.getNodeType() == Node_base::ELEMENT_NODE) {
- Arabica::DOM::Element<std::string> elem = (Arabica::DOM::Element<std::string>)node;
- if (elem.hasAttribute("name")) {
- elemName = elem.getAttribute("name");
- } else if (elem.hasAttribute("id")) {
- elemName = elem.getAttribute("id");
- }
- }
- if (elemName.size() == 0)
- elemName = boost::lexical_cast<std::string>(node.getLocalName());
-
- return elemName;
-
-}
-
-std::string SCXMLDotWriter::idForNode(const Arabica::DOM::Node<std::string>& node) {
- std::string elemId;
- if (node.getNodeType() == Node_base::ELEMENT_NODE) {
- Arabica::DOM::Element<std::string> elem = (Arabica::DOM::Element<std::string>)node;
- if (elem.hasAttribute("name")) {
- elemId = elem.getAttribute("name");
- } else if (elem.hasAttribute("id")) {
- elemId = elem.getAttribute("id");
- }
- }
- if (elemId.size() == 0) {
- Arabica::DOM::Node<std::string> tmpParent = node;
- Arabica::DOM::Node<std::string> tmpIndex;
- do {
- if (tmpParent.getNodeType() != Node_base::ELEMENT_NODE)
- continue;
-
- tmpIndex = tmpParent;
- int index = 0;
-
- while((tmpIndex = tmpIndex.getPreviousSibling()))
- index++;
-
- std::stringstream ssElemId;
- ssElemId << TAGNAME(tmpParent) << index << ".";
- elemId = ssElemId.str() + elemId;
- } while ((tmpParent = tmpParent.getParentNode()));
-// elemId = ssElemId.str();
- }
-
- std::replace(elemId.begin(), elemId.end(), '-', '_');
-// std::replace(elemId.begin(), elemId.end(), '.', '_');
-
- return elemId;
-}
-
-} \ No newline at end of file
diff --git a/src/uscxml/debug/SCXMLDotWriter.h b/src/uscxml/debug/SCXMLDotWriter.h
index 0666aa5..07b34b1 100644
--- a/src/uscxml/debug/SCXMLDotWriter.h
+++ b/src/uscxml/debug/SCXMLDotWriter.h
@@ -1,7 +1,9 @@
#ifndef SCXMLDOTWRITER_H_AOP0OHXX
#define SCXMLDOTWRITER_H_AOP0OHXX
+#include "uscxml/Interpreter.h"
#include <DOM/Document.hpp>
+#include <XPath/XPath.hpp>
#include <fstream>
#include <set>
@@ -9,7 +11,28 @@ namespace uscxml {
class Interpreter;
-class SCXMLDotWriter {
+
+
+/**
+ * This writer, added as a monitor will output .dot files.
+ *
+ * # create a set of pdfs form the dot files
+ * $ dot -Tpdf -O *.dot
+ * or
+ * $ find . -name "*.dot" -exec dot -Tpdf -O {} \;
+ *
+ * # create a movie from the pdfs
+ * $ dot -Tgif -O *.dot
+ * or
+ * $ find . -name "*.dot" -exec dot -Tgif -O {} \;
+ *
+ * $ ffmpeg -r 3 -i <NAME>.%06d.dot.gif -r 25 movie.mpg
+ * $ convert -delay 20 *.gif animated.gif
+ *
+ * # unflatten can be used to create more compact graphs
+ * find . -name "*.dot" -exec unflatten -f -l2 -o {}.flat.dot {} \;
+ */
+class SCXMLDotWriter : public InterpreterMonitor {
public:
struct ElemDetails {
@@ -18,25 +41,43 @@ public:
std::string content;
};
- SCXMLDotWriter(InterpreterImpl* interpreter);
+ SCXMLDotWriter();
~SCXMLDotWriter();
- static void toDot(const std::string& filename, InterpreterImpl* interpreter);
- void writeSCXMLElement(std::ostream& os, const Arabica::DOM::Element<std::string>& elem);
- void writeStateElement(std::ostream& os, const Arabica::DOM::Element<std::string>& elem);
- void writeTransitionElement(std::ostream& os, const Arabica::DOM::Element<std::string>& elem);
+ virtual void onStableConfiguration(Interpreter interpreter);
+ virtual void afterCompletion(Interpreter interpreter);
+ virtual void beforeTakingTransitions(Interpreter interpreter, const Arabica::XPath::NodeSet<std::string>& transitions);
+ virtual void beforeMicroStep(Interpreter interpreter);
+
+ static void toDot(const std::string& filename,
+ Interpreter interpreter,
+ const Arabica::XPath::NodeSet<std::string>& transitions = Arabica::XPath::NodeSet<std::string>());
std::string getDetailedLabel(const Arabica::DOM::Element<std::string>& elem, int indentation = 0);
std::string colorForIndent(int indent);
std::string idForNode(const Arabica::DOM::Node<std::string>& node);
std::string nameForNode(const Arabica::DOM::Node<std::string>& node);
+ std::string getPrefix();
- static std::string getPrefix();
static std::string dotEscape(const std::string& text);
+protected:
+
+ SCXMLDotWriter(Interpreter interpreter,
+ const Arabica::XPath::NodeSet<std::string>& transitions);
+
+ void writeSCXMLElement(std::ostream& os, const Arabica::DOM::Element<std::string>& elem);
+ void writeStateElement(std::ostream& os, const Arabica::DOM::Element<std::string>& elem);
+ void writeTransitionElement(std::ostream& os, const Arabica::DOM::Element<std::string>& elem);
+
+ int _iteration;
std::set<std::string> _knownIds;
- static int _indentation;
+ int _indentation;
+
+ // these are only set in ephemeral instances per monitor call
+ Arabica::XPath::NodeSet<std::string> _transitions;
+ Interpreter _interpreter;
};
}
diff --git a/src/uscxml/interpreter/InterpreterDraft6.cpp b/src/uscxml/interpreter/InterpreterDraft6.cpp
index aa09b53..881fa8b 100644
--- a/src/uscxml/interpreter/InterpreterDraft6.cpp
+++ b/src/uscxml/interpreter/InterpreterDraft6.cpp
@@ -121,6 +121,21 @@ void InterpreterDraft6::interpret() {
}
assert(initialTransitions.size() > 0);
+
+ monIter_t monIter = _monitors.begin();
+ while(monIter != _monitors.end()) {
+ try {
+ (*monIter)->beforeTakingTransitions(shared_from_this(), initialTransitions);
+ } catch (Event e) {
+ LOG(ERROR) << "Syntax error when calling beforeTakingTransitions on monitors: " << std::endl << e << std::endl;
+ } catch (boost::bad_weak_ptr e) {
+ LOG(ERROR) << "Unclean shutdown " << std::endl << std::endl;
+ } catch (...) {
+ LOG(ERROR) << "An exception occured when calling beforeTakingTransitions on monitors";
+ }
+ monIter++;
+ }
+
enterStates(initialTransitions);
// _mutex.unlock();
@@ -135,7 +150,7 @@ void InterpreterDraft6::interpret() {
void InterpreterDraft6::mainEventLoop() {
- std::set<InterpreterMonitor*>::iterator monIter;
+ monIter_t monIter;
while(_running) {
NodeSet<std::string> enabledTransitions;
@@ -218,6 +233,14 @@ void InterpreterDraft6::mainEventLoop() {
// assume that we have a legal configuration as soon as the internal queue is empty
assert(hasLegalConfiguration());
+#if 0
+ std::cout << "Configuration: ";
+ for (int i = 0; i < _configuration.size(); i++) {
+ std::cout << ATTR(_configuration[i], "id") << ", ";
+ }
+ std::cout << std::endl;
+#endif
+
monIter = _monitors.begin();
// if (!_sendQueue || _sendQueue->isEmpty()) {
while(monIter != _monitors.end()) {
@@ -614,7 +637,7 @@ void InterpreterDraft6::exitInterpreter() {
void InterpreterDraft6::exitStates(const Arabica::XPath::NodeSet<std::string>& enabledTransitions) {
NodeSet<std::string> statesToExit;
- std::set<InterpreterMonitor*>::iterator monIter;
+ monIter_t monIter;
#if VERBOSE
std::cout << "Enabled exit transitions: " << std::endl;
@@ -768,7 +791,7 @@ void InterpreterDraft6::exitStates(const Arabica::XPath::NodeSet<std::string>& e
void InterpreterDraft6::enterStates(const Arabica::XPath::NodeSet<std::string>& enabledTransitions) {
NodeSet<std::string> statesToEnter;
NodeSet<std::string> statesForDefaultEntry;
- std::set<InterpreterMonitor*>::iterator monIter;
+ monIter_t monIter;
#if VERBOSE
std::cout << "Enabled enter transitions: " << std::endl;
diff --git a/src/uscxml/plugins/datamodel/CMakeLists.txt b/src/uscxml/plugins/datamodel/CMakeLists.txt
index 731e316..ce13cdb 100644
--- a/src/uscxml/plugins/datamodel/CMakeLists.txt
+++ b/src/uscxml/plugins/datamodel/CMakeLists.txt
@@ -3,6 +3,8 @@ if (JSC_FOUND AND BUILD_DM_ECMA)
file(GLOB JSC_DATAMODEL
ecmascript/JavaScriptCore/*.cpp
ecmascript/JavaScriptCore/*.h
+ ecmascript/*.cpp
+ ecmascript/*.h
)
source_group("Datamodel\\jsc" FILES ${JSC_DATAMODEL})
file(GLOB_RECURSE JSC_DOM
@@ -32,6 +34,8 @@ else()
file(GLOB V8_DATAMODEL
ecmascript/v8/*.cpp
ecmascript/v8/*.h
+ ecmascript/*.cpp
+ ecmascript/*.h
)
source_group("Datamodel\\v8" FILES ${V8_DATAMODEL})
file(GLOB_RECURSE V8_DOM
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.cpp
index 1b5aaef..f2c3a8e 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.cpp
@@ -5,11 +5,14 @@ namespace DOM {
JSCDOM::JSCDOM() {
xpath = NULL;
+ storage = NULL;
}
JSCDOM::~JSCDOM() {
if (xpath)
delete(xpath);
+ if (storage)
+ delete(storage);
}
}
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h
index bffeab8..e88851e 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h
@@ -4,6 +4,7 @@
#include "uscxml/Interpreter.h"
#include <JavaScriptCore/JavaScriptCore.h>
#include <XPath/XPath.hpp>
+#include "../Storage.h"
#define JSC_DESTRUCTOR(type) \
static void jsDestructor(JSObjectRef object) { \
@@ -28,7 +29,7 @@ class JSCDOM {
public:
JSCDOM();
virtual ~JSCDOM();
-
+ uscxml::Storage* storage;
Arabica::XPath::XPath<std::string>* xpath;
};
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp
index 7f6a9e7..712799c 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp
@@ -1,6 +1,7 @@
#include "uscxml/Common.h"
+#include "uscxml/config.h"
#include "JSCDataModel.h"
-#include "dom/JSCDOM.h"
+#include "JSCDOM.h"
#include "dom/JSCDocument.h"
#include "dom/JSCSCXMLEvent.h"
@@ -77,6 +78,7 @@ boost::shared_ptr<DataModelImpl> JSCDataModel::create(InterpreterImpl* interpret
dm->_dom = new JSCDOM();
dm->_dom->xpath = new XPath<std::string>();
dm->_dom->xpath->setNamespaceContext(interpreter->getNSContext());
+ dm->_dom->storage = new Storage(URL::getResourceDir() + PATH_SEPERATOR + interpreter->getName() + ".storage");
// introduce global functions as objects for private data
JSClassRef jsInClassRef = JSClassCreate(&jsInClassDef);
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h
index c5e9587..f7360d4 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h
@@ -4,7 +4,7 @@
#include "uscxml/Interpreter.h"
#include <list>
#include <JavaScriptCore/JavaScriptCore.h>
-#include "dom/JSCDOM.h"
+#include "JSCDOM.h"
#ifdef BUILD_AS_PLUGINS
#include "uscxml/plugins/Plugins.h"
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCAttr.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCAttr.h
index 01628a6..3e98cab 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCAttr.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCAttr.h
@@ -25,7 +25,7 @@
#include "DOM/Node.hpp"
#include "JSCNode.h"
#include <JavaScriptCore/JavaScriptCore.h>
-#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h"
namespace Arabica {
namespace DOM {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCDATASection.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCDATASection.h
index 9fe225b..f0ec864 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCDATASection.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCDATASection.h
@@ -25,7 +25,7 @@
#include "DOM/Node.hpp"
#include "JSCText.h"
#include <JavaScriptCore/JavaScriptCore.h>
-#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h"
namespace Arabica {
namespace DOM {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCharacterData.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCharacterData.h
index 0bdca74..1155a0a 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCharacterData.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCharacterData.h
@@ -25,7 +25,7 @@
#include "DOM/Node.hpp"
#include "JSCNode.h"
#include <JavaScriptCore/JavaScriptCore.h>
-#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h"
namespace Arabica {
namespace DOM {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCComment.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCComment.h
index 7c4e96f..63bf840 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCComment.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCComment.h
@@ -25,7 +25,7 @@
#include "DOM/Node.hpp"
#include "JSCCharacterData.h"
#include <JavaScriptCore/JavaScriptCore.h>
-#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h"
namespace Arabica {
namespace DOM {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOMImplementation.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOMImplementation.h
index 551c2fe..9169604 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOMImplementation.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOMImplementation.h
@@ -24,7 +24,7 @@
#include <string>
#include "DOM/Node.hpp"
#include <JavaScriptCore/JavaScriptCore.h>
-#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h"
namespace Arabica {
namespace DOM {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.cpp
index 4fae6c9..a7f170f 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.cpp
@@ -21,6 +21,7 @@ JSStaticValue JSCDocument::staticValues[] = {
{ "doctype", doctypeAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
{ "implementation", implementationAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
{ "documentElement", documentElementAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
+ { "localStorage", localStorageCustomAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
{ 0, 0, 0, 0 }
};
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.h
index 6657f3b..7663d98 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.h
@@ -25,7 +25,7 @@
#include "DOM/Node.hpp"
#include "JSCNode.h"
#include <JavaScriptCore/JavaScriptCore.h>
-#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h"
namespace Arabica {
namespace DOM {
@@ -58,6 +58,7 @@ public:
static JSValueRef doctypeAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception);
static JSValueRef implementationAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception);
static JSValueRef documentElementAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception);
+ static JSValueRef localStorageCustomAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception);
static JSStaticValue staticValues[];
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentCustom.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentCustom.cpp
index c6fdce1..52d6a88 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentCustom.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentCustom.cpp
@@ -1,4 +1,5 @@
#include "JSCDocument.h"
+#include "JSCStorage.h"
#include "JSCXPathResult.h"
#include "JSCNode.h"
#include <XPath/XPath.hpp>
@@ -6,6 +7,23 @@
namespace Arabica {
namespace DOM {
+JSValueRef JSCDocument::localStorageCustomAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) {
+ struct JSCDocumentPrivate* privData = (struct JSCDocumentPrivate*)JSObjectGetPrivate(object);
+
+ if (!privData->dom->storage) {
+ return JSValueMakeUndefined(ctx);
+ }
+
+ JSClassRef retClass = JSCStorage::getTmpl();
+ struct JSCStorage::JSCStoragePrivate* retPrivData = new JSCStorage::JSCStoragePrivate();
+ retPrivData->dom = privData->dom;
+ retPrivData->nativeObj = retPrivData->dom->storage;
+
+ JSObjectRef arbaicaRetObj = JSObjectMake(ctx, retClass, retPrivData);
+ return arbaicaRetObj;
+
+}
+
JSValueRef JSCDocument::evaluateCustomCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef object, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) {
struct JSCDocumentPrivate* privData = (struct JSCDocumentPrivate*)JSObjectGetPrivate(object);
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentFragment.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentFragment.h
index 3a9d8d6..fbe47e9 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentFragment.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentFragment.h
@@ -25,7 +25,7 @@
#include "DOM/Node.hpp"
#include "JSCNode.h"
#include <JavaScriptCore/JavaScriptCore.h>
-#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h"
namespace Arabica {
namespace DOM {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentType.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentType.h
index 3dc46f4..635f78d 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentType.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentType.h
@@ -25,7 +25,7 @@
#include "DOM/Node.hpp"
#include "JSCNode.h"
#include <JavaScriptCore/JavaScriptCore.h>
-#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h"
namespace Arabica {
namespace DOM {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCElement.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCElement.h
index 9520a8b..43df02d 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCElement.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCElement.h
@@ -25,7 +25,7 @@
#include "DOM/Node.hpp"
#include "JSCNode.h"
#include <JavaScriptCore/JavaScriptCore.h>
-#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h"
namespace Arabica {
namespace DOM {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntity.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntity.h
index 69f54a3..b952750 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntity.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntity.h
@@ -25,7 +25,7 @@
#include "DOM/Node.hpp"
#include "JSCNode.h"
#include <JavaScriptCore/JavaScriptCore.h>
-#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h"
namespace Arabica {
namespace DOM {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntityReference.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntityReference.h
index 428274f..2dddf57 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntityReference.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntityReference.h
@@ -25,7 +25,7 @@
#include "DOM/Node.hpp"
#include "JSCNode.h"
#include <JavaScriptCore/JavaScriptCore.h>
-#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h"
namespace Arabica {
namespace DOM {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNamedNodeMap.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNamedNodeMap.h
index c82bfdd..251ab72 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNamedNodeMap.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNamedNodeMap.h
@@ -24,7 +24,7 @@
#include <string>
#include "DOM/Node.hpp"
#include <JavaScriptCore/JavaScriptCore.h>
-#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h"
namespace Arabica {
namespace DOM {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.cpp.old b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.cpp.old
deleted file mode 100644
index 7d38f9f..0000000
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.cpp.old
+++ /dev/null
@@ -1,60 +0,0 @@
-#include "JSCNode.h"
-#include <DOM/Node.hpp>
-
-namespace uscxml {
-
-using namespace Arabica::DOM;
-
-JSStaticValue JSCNode::staticValues[] = {
- { "nodeName", nodeNameAttrGetter, nodeValueAttrSetter, kJSPropertyAttributeDontDelete },
- { "nodeValue", nodeValueAttrGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
- { "nodeType", nodeValueAttrGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
- { "parentNode", nodeValueAttrGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
- { "childNodes", nodeValueAttrGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
- { "firstChild", nodeValueAttrGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
- { "lastChild", nodeValueAttrGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
- { "previousSibling", nodeValueAttrGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
- { "nextSibling", nodeValueAttrGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
- { "attributes", nodeValueAttrGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
- { "ownerDocument", nodeValueAttrGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
- { "namespaceURI", nodeValueAttrGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
- { "prefix", nodeValueAttrGetter, prefixAttrSetter, kJSPropertyAttributeDontDelete },
- { "localName", nodeValueAttrGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
- { "baseURI", nodeValueAttrGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
- { "textContent", nodeValueAttrGetter, textContentAttrSetter, kJSPropertyAttributeDontDelete },
- { "parentElement", nodeValueAttrGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
- { "ELEMENT_NODE", ELEMENT_NODEConstGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
- { "ATTRIBUTE_NODE", ATTRIBUTE_NODEConstGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
- { "TEXT_NODE", TEXT_NODEConstGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
- { "CDATA_SECTION_NODE", CDATA_SECTION_NODEConstGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
- { "ENTITY_REFERENCE_NODE", ENTITY_REFERENCE_NODEConstGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
- { "ENTITY_NODE", ENTITY_NODEConstGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
- { "PROCESSING_INSTRUCTION_NODE", PROCESSING_INSTRUCTION_NODEConstGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
- { "COMMENT_NODE", COMMENT_NODEConstGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
- { "DOCUMENT_NODE", DOCUMENT_NODEConstGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
- { "DOCUMENT_TYPE_NODE", DOCUMENT_TYPE_NODEConstGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
- { "DOCUMENT_FRAGMENT_NODE", DOCUMENT_FRAGMENT_NODEConstGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
- { "NOTATION_NODE", NOTATION_NODEConstGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
- { "MAX_TYPE", MAX_TYPEConstGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
- { 0, 0, 0, 0 }
-};
-
-JSStaticFunction JSCNode::staticFunctions[] = {
- { "insertBefore", insertBeforeCallback, kJSPropertyAttributeDontDelete },
- { "replaceChild", replaceChildCallback, kJSPropertyAttributeDontDelete },
- { "removeChild", removeChildCallback, kJSPropertyAttributeDontDelete },
- { "appendChild", appendChildCallback, kJSPropertyAttributeDontDelete },
- { "hasChildNodes", hasChildNodesCallback, kJSPropertyAttributeDontDelete },
- { "cloneNode", cloneNodeCallback, kJSPropertyAttributeDontDelete },
- { "normalize", normalizeCallback, kJSPropertyAttributeDontDelete },
- { "isSupported", isSupportedCallback, kJSPropertyAttributeDontDelete },
- { "hasAttributes", hasAttributesCallback, kJSPropertyAttributeDontDelete },
- { "lookupPrefix", lookupPrefixCallback, kJSPropertyAttributeDontDelete },
- { "isDefaultNamespace", isDefaultNamespaceCallback, kJSPropertyAttributeDontDelete },
- { "lookupNamespaceURI", lookupNamespaceURICallback, kJSPropertyAttributeDontDelete },
- { "addEventListener", addEventListenerCallback, kJSPropertyAttributeDontDelete },
- { "removeEventListener", removeEventListenerCallback, kJSPropertyAttributeDontDelete },
- { 0, 0, 0 }
-};
-
-} \ No newline at end of file
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.h
index d833ecb..9849d72 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.h
@@ -24,7 +24,7 @@
#include <string>
#include "DOM/Node.hpp"
#include <JavaScriptCore/JavaScriptCore.h>
-#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h"
namespace Arabica {
namespace DOM {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.h.old b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.h.old
deleted file mode 100644
index 677a63b..0000000
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.h.old
+++ /dev/null
@@ -1,223 +0,0 @@
-#ifndef JSCNODE_H_6BAK1S3C
-#define JSCNODE_H_6BAK1S3C
-
-#include "JSCDOM.h"
-
-namespace uscxml {
-
-class JSCNode {
-public:
- static JSValueRef nodeNameAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) {
- assert(false);
- return JSValueMakeUndefined(ctx);
- }
- static JSValueRef nodeValueAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) {
- assert(false);
- return JSValueMakeUndefined(ctx);
- }
- static JSValueRef nodeTypeAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) {
- assert(false);
- return JSValueMakeUndefined(ctx);
- }
- static JSValueRef parentNodeAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) {
- assert(false);
- return JSValueMakeUndefined(ctx);
- }
- static JSValueRef childNodesAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) {
- assert(false);
- return JSValueMakeUndefined(ctx);
- }
- static JSValueRef firstChildAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) {
- assert(false);
- return JSValueMakeUndefined(ctx);
- }
- static JSValueRef lastChildAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) {
- assert(false);
- return JSValueMakeUndefined(ctx);
- }
- static JSValueRef previousSiblingAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) {
- assert(false);
- return JSValueMakeUndefined(ctx);
- }
- static JSValueRef nextSiblingAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) {
- assert(false);
- return JSValueMakeUndefined(ctx);
- }
- static JSValueRef attributesAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) {
- assert(false);
- return JSValueMakeUndefined(ctx);
- }
- static JSValueRef ownerDocumentAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) {
- assert(false);
- return JSValueMakeUndefined(ctx);
- }
- static JSValueRef namespaceURIAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) {
- assert(false);
- return JSValueMakeUndefined(ctx);
- }
- static JSValueRef prefixAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) {
- assert(false);
- return JSValueMakeUndefined(ctx);
- }
- static JSValueRef localNameAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) {
- assert(false);
- return JSValueMakeUndefined(ctx);
- }
- static JSValueRef baseURIAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) {
- assert(false);
- return JSValueMakeUndefined(ctx);
- }
- static JSValueRef textContentAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) {
- assert(false);
- return JSValueMakeUndefined(ctx);
- }
- static JSValueRef parentElementAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) {
- assert(false);
- return JSValueMakeUndefined(ctx);
- }
-
- static bool nodeValueAttrSetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) {
- return false;
- }
- static bool prefixAttrSetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) {
- return false;
- }
- static bool textContentAttrSetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) {
- return false;
- }
-
- static JSValueRef insertBeforeCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) {
- assert(false);
- return JSValueMakeUndefined(ctx);
- }
- static JSValueRef replaceChildCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) {
- assert(false);
- return JSValueMakeUndefined(ctx);
- }
- static JSValueRef removeChildCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) {
- assert(false);
- return JSValueMakeUndefined(ctx);
- }
- static JSValueRef appendChildCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) {
- assert(false);
- return JSValueMakeUndefined(ctx);
- }
- static JSValueRef hasChildNodesCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) {
- assert(false);
- return JSValueMakeUndefined(ctx);
- }
- static JSValueRef cloneNodeCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) {
- assert(false);
- return JSValueMakeUndefined(ctx);
- }
- static JSValueRef normalizeCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) {
- assert(false);
- return JSValueMakeUndefined(ctx);
- }
- static JSValueRef isSupportedCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) {
- assert(false);
- return JSValueMakeUndefined(ctx);
- }
- static JSValueRef hasAttributesCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) {
- assert(false);
- return JSValueMakeUndefined(ctx);
- }
- static JSValueRef lookupPrefixCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) {
- assert(false);
- return JSValueMakeUndefined(ctx);
- }
- static JSValueRef isDefaultNamespaceCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) {
- assert(false);
- return JSValueMakeUndefined(ctx);
- }
- static JSValueRef lookupNamespaceURICallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) {
- assert(false);
- return JSValueMakeUndefined(ctx);
- }
- static JSValueRef addEventListenerCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) {
- assert(false);
- return JSValueMakeUndefined(ctx);
- }
- static JSValueRef removeEventListenerCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) {
- assert(false);
- return JSValueMakeUndefined(ctx);
- }
-
- static JSValueRef ELEMENT_NODEConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) {
- assert(false);
- return JSValueMakeNumber(ctx, Arabica::DOM::Node_base::ELEMENT_NODE);
- }
- static JSValueRef ATTRIBUTE_NODEConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) {
- assert(false);
- return JSValueMakeNumber(ctx, Arabica::DOM::Node_base::ATTRIBUTE_NODE);
- }
- static JSValueRef TEXT_NODEConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) {
- assert(false);
- return JSValueMakeNumber(ctx, Arabica::DOM::Node_base::TEXT_NODE);
- }
- static JSValueRef CDATA_SECTION_NODEConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) {
- assert(false);
- return JSValueMakeNumber(ctx, Arabica::DOM::Node_base::CDATA_SECTION_NODE);
- }
- static JSValueRef ENTITY_REFERENCE_NODEConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) {
- assert(false);
- return JSValueMakeNumber(ctx, Arabica::DOM::Node_base::ENTITY_REFERENCE_NODE);
- }
- static JSValueRef ENTITY_NODEConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) {
- assert(false);
- return JSValueMakeNumber(ctx, Arabica::DOM::Node_base::ENTITY_NODE);
- }
- static JSValueRef PROCESSING_INSTRUCTION_NODEConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) {
- assert(false);
- return JSValueMakeNumber(ctx, Arabica::DOM::Node_base::PROCESSING_INSTRUCTION_NODE);
- }
- static JSValueRef COMMENT_NODEConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) {
- assert(false);
- return JSValueMakeNumber(ctx, Arabica::DOM::Node_base::COMMENT_NODE);
- }
- static JSValueRef DOCUMENT_NODEConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) {
- assert(false);
- return JSValueMakeNumber(ctx, Arabica::DOM::Node_base::DOCUMENT_NODE);
- }
- static JSValueRef DOCUMENT_TYPE_NODEConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) {
- assert(false);
- return JSValueMakeNumber(ctx, Arabica::DOM::Node_base::DOCUMENT_TYPE_NODE);
- }
- static JSValueRef DOCUMENT_FRAGMENT_NODEConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) {
- assert(false);
- return JSValueMakeNumber(ctx, Arabica::DOM::Node_base::DOCUMENT_FRAGMENT_NODE);
- }
- static JSValueRef NOTATION_NODEConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) {
- assert(false);
- return JSValueMakeNumber(ctx, Arabica::DOM::Node_base::NOTATION_NODE);
- }
- static JSValueRef MAX_TYPEConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) {
- assert(false);
- return JSValueMakeNumber(ctx, Arabica::DOM::Node_base::MAX_TYPE);
- }
-
- JSC_DESTRUCTOR(Arabica::DOM::Node<std::string>);
-
- static JSStaticValue staticValues[];
- static JSStaticFunction staticFunctions[];
-
- static JSClassRef Tmpl;
- static JSClassRef getTmpl() {
- if (Tmpl == NULL) {
- JSClassDefinition classDef = kJSClassDefinitionEmpty;
- classDef.staticValues = staticValues;
- classDef.staticFunctions = staticFunctions;
- classDef.finalize = jsDestructor;
-
- Tmpl = JSClassCreate(&classDef);
- JSClassRetain(Tmpl);
- }
- return Tmpl;
- }
-
-};
-
-}
-
-
-#endif /* end of include guard: JSCNODE_H_6BAK1S3C */
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeCustom.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeCustom.cpp
index 82965ad..159ff56 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeCustom.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeCustom.cpp
@@ -5,28 +5,23 @@ namespace Arabica {
namespace DOM {
JSValueRef JSCNode::attributesCustomAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) {
-#if 0
- v8::Local<v8::Object> self = info.Holder();
- struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0));
+
+ struct JSCNodePrivate* privData = (struct JSCNodePrivate*)JSObjectGetPrivate(thisObj);
if (!privData->nativeObj->hasAttributes()) {
- return v8::Undefined();
+ return JSValueMakeUndefined(ctx);
}
- 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());
+ Arabica::DOM::NamedNodeMap<std::string>* retVal = new Arabica::DOM::NamedNodeMap<std::string>(privData->nativeObj->getAttributes());
+ JSClassRef retClass = JSCNamedNodeMap::getTmpl();
- struct V8NamedNodeMap::V8NamedNodeMapPrivate* retPrivData = new V8NamedNodeMap::V8NamedNodeMapPrivate();
+ struct JSCNamedNodeMap::JSCNamedNodeMapPrivate* retPrivData = new JSCNamedNodeMap::JSCNamedNodeMapPrivate();
retPrivData->dom = privData->dom;
- retPrivData->nativeObj = arbaicaRet;
+ retPrivData->nativeObj = retVal;
- arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
- arbaicaRetObj.MakeWeak(0, V8NamedNodeMap::jsDestructor);
- return arbaicaRetObj;
+ JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData);
-#endif
+ return retObj;
}
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeList.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeList.h
index fca81b8..feb9be5 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeList.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeList.h
@@ -24,7 +24,7 @@
#include <string>
#include "DOM/Node.hpp"
#include <JavaScriptCore/JavaScriptCore.h>
-#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h"
namespace Arabica {
namespace DOM {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeSet.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeSet.h
index b38d04e..5db3af8 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeSet.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeSet.h
@@ -24,7 +24,7 @@
#include <string>
#include "DOM/Node.hpp"
#include <JavaScriptCore/JavaScriptCore.h>
-#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h"
namespace Arabica {
namespace DOM {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNotation.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNotation.h
index bb84c50..b043d14 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNotation.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNotation.h
@@ -25,7 +25,7 @@
#include "DOM/Node.hpp"
#include "JSCNode.h"
#include <JavaScriptCore/JavaScriptCore.h>
-#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h"
namespace Arabica {
namespace DOM {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCProcessingInstruction.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCProcessingInstruction.h
index fc8c44b..4ebdefb 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCProcessingInstruction.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCProcessingInstruction.h
@@ -25,7 +25,7 @@
#include "DOM/Node.hpp"
#include "JSCNode.h"
#include <JavaScriptCore/JavaScriptCore.h>
-#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h"
namespace Arabica {
namespace DOM {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCSCXMLEvent.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCSCXMLEvent.h
index 8e00401..d3a25d5 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCSCXMLEvent.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCSCXMLEvent.h
@@ -24,7 +24,7 @@
#include <string>
#include "DOM/Node.hpp"
#include <JavaScriptCore/JavaScriptCore.h>
-#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h"
namespace Arabica {
namespace DOM {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCStorage.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCStorage.cpp
new file mode 100644
index 0000000..f3c709b
--- /dev/null
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCStorage.cpp
@@ -0,0 +1,155 @@
+#include "JSCStorage.h"
+
+namespace Arabica {
+namespace DOM {
+
+JSClassRef JSCStorage::Tmpl;
+
+JSStaticValue JSCStorage::staticValues[] = {
+ { "length", lengthAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
+
+ { 0, 0, 0, 0 }
+};
+
+JSStaticFunction JSCStorage::staticFunctions[] = {
+ { "key", keyCallback, kJSPropertyAttributeDontDelete },
+ { "getItem", getItemCallback, kJSPropertyAttributeDontDelete },
+ { "setItem", setItemCallback, kJSPropertyAttributeDontDelete },
+ { "removeItem", removeItemCallback, kJSPropertyAttributeDontDelete },
+ { "clear", clearCallback, kJSPropertyAttributeDontDelete },
+ { 0, 0, 0 }
+};
+
+JSValueRef JSCStorage::lengthAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) {
+ struct JSCStoragePrivate* privData = (struct JSCStoragePrivate*)JSObjectGetPrivate(object);
+
+ return JSValueMakeNumber(ctx, privData->nativeObj->getLength());
+}
+
+JSValueRef JSCStorage::keyCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) {
+ if (argumentCount < 1) {
+ std::string errorMsg = "Wrong number of arguments in key";
+ JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str());
+ JSValueRef exceptionString =JSValueMakeString(ctx, string);
+ JSStringRelease(string);
+ *exception = JSValueToObject(ctx, exceptionString, NULL);
+ return NULL;
+ }
+
+ struct JSCStoragePrivate* privData = (struct JSCStoragePrivate*)JSObjectGetPrivate(thisObj);
+
+ unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception);
+
+ std::string retVal = privData->nativeObj->key(localIndex);
+
+ JSStringRef jscString = JSStringCreateWithUTF8CString(retVal.c_str());
+ JSValueRef jscRetVal = JSValueMakeString(ctx, jscString);
+ JSStringRelease(jscString);
+ return jscRetVal;
+}
+
+JSValueRef JSCStorage::getItemCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) {
+ if (argumentCount < 1) {
+ std::string errorMsg = "Wrong number of arguments in getItem";
+ JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str());
+ JSValueRef exceptionString =JSValueMakeString(ctx, string);
+ JSStringRelease(string);
+ *exception = JSValueToObject(ctx, exceptionString, NULL);
+ return NULL;
+ }
+
+ struct JSCStoragePrivate* privData = (struct JSCStoragePrivate*)JSObjectGetPrivate(thisObj);
+
+ JSStringRef stringReflocalKey = JSValueToStringCopy(ctx, arguments[0], exception);
+ size_t localKeyMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalKey);
+ char* localKeyBuffer = new char[localKeyMaxSize];
+ JSStringGetUTF8CString(stringReflocalKey, localKeyBuffer, localKeyMaxSize);
+ std::string localKey(localKeyBuffer);
+ JSStringRelease(stringReflocalKey);
+ free(localKeyBuffer);
+
+
+ std::string retVal = privData->nativeObj->getItem(localKey);
+
+ JSStringRef jscString = JSStringCreateWithUTF8CString(retVal.c_str());
+ JSValueRef jscRetVal = JSValueMakeString(ctx, jscString);
+ JSStringRelease(jscString);
+ return jscRetVal;
+}
+
+JSValueRef JSCStorage::setItemCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) {
+ if (argumentCount < 2) {
+ std::string errorMsg = "Wrong number of arguments in setItem";
+ JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str());
+ JSValueRef exceptionString =JSValueMakeString(ctx, string);
+ JSStringRelease(string);
+ *exception = JSValueToObject(ctx, exceptionString, NULL);
+ return NULL;
+ }
+
+ struct JSCStoragePrivate* privData = (struct JSCStoragePrivate*)JSObjectGetPrivate(thisObj);
+
+ JSStringRef stringReflocalKey = JSValueToStringCopy(ctx, arguments[0], exception);
+ size_t localKeyMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalKey);
+ char* localKeyBuffer = new char[localKeyMaxSize];
+ JSStringGetUTF8CString(stringReflocalKey, localKeyBuffer, localKeyMaxSize);
+ std::string localKey(localKeyBuffer);
+ JSStringRelease(stringReflocalKey);
+ free(localKeyBuffer);
+
+ JSStringRef stringReflocalValue = JSValueToStringCopy(ctx, arguments[1], exception);
+ size_t localValueMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalValue);
+ char* localValueBuffer = new char[localValueMaxSize];
+ JSStringGetUTF8CString(stringReflocalValue, localValueBuffer, localValueMaxSize);
+ std::string localValue(localValueBuffer);
+ JSStringRelease(stringReflocalValue);
+ free(localValueBuffer);
+
+
+ privData->nativeObj->setItem(localKey, localValue);
+
+ JSValueRef jscRetVal = JSValueMakeUndefined(ctx);
+ return jscRetVal;
+}
+
+JSValueRef JSCStorage::removeItemCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) {
+ if (argumentCount < 1) {
+ std::string errorMsg = "Wrong number of arguments in removeItem";
+ JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str());
+ JSValueRef exceptionString =JSValueMakeString(ctx, string);
+ JSStringRelease(string);
+ *exception = JSValueToObject(ctx, exceptionString, NULL);
+ return NULL;
+ }
+
+ struct JSCStoragePrivate* privData = (struct JSCStoragePrivate*)JSObjectGetPrivate(thisObj);
+
+ JSStringRef stringReflocalKey = JSValueToStringCopy(ctx, arguments[0], exception);
+ size_t localKeyMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalKey);
+ char* localKeyBuffer = new char[localKeyMaxSize];
+ JSStringGetUTF8CString(stringReflocalKey, localKeyBuffer, localKeyMaxSize);
+ std::string localKey(localKeyBuffer);
+ JSStringRelease(stringReflocalKey);
+ free(localKeyBuffer);
+
+
+ privData->nativeObj->removeItem(localKey);
+
+ JSValueRef jscRetVal = JSValueMakeUndefined(ctx);
+ return jscRetVal;
+}
+
+JSValueRef JSCStorage::clearCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) {
+
+ struct JSCStoragePrivate* privData = (struct JSCStoragePrivate*)JSObjectGetPrivate(thisObj);
+
+
+ privData->nativeObj->clear();
+
+ JSValueRef jscRetVal = JSValueMakeUndefined(ctx);
+ return jscRetVal;
+}
+
+
+}
+}
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCStorage.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCStorage.h
new file mode 100644
index 0000000..afb9714
--- /dev/null
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCStorage.h
@@ -0,0 +1,73 @@
+/*
+ This file is part of the Wrapper open source project.
+ This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef JSCStorage_h
+#define JSCStorage_h
+
+#include <string>
+#include "DOM/Node.hpp"
+#include <JavaScriptCore/JavaScriptCore.h>
+#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h"
+
+namespace Arabica {
+namespace DOM {
+
+class JSCStorage {
+public:
+ struct JSCStoragePrivate {
+ JSCDOM* dom;
+ uscxml::Storage* nativeObj;
+ };
+
+ JSC_DESTRUCTOR_KEEP_WRAPPED(JSCStoragePrivate);
+
+ static JSValueRef keyCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception);
+ static JSValueRef getItemCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception);
+ static JSValueRef setItemCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception);
+ static JSValueRef removeItemCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception);
+ static JSValueRef clearCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception);
+
+ static JSValueRef lengthAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception);
+
+
+ static JSStaticValue staticValues[];
+ static JSStaticFunction staticFunctions[];
+
+ static JSClassRef Tmpl;
+ static JSClassRef getTmpl() {
+ if (Tmpl == NULL) {
+ JSClassDefinition classDef = kJSClassDefinitionEmpty;
+ classDef.staticValues = staticValues;
+ classDef.staticFunctions = staticFunctions;
+ classDef.finalize = jsDestructor;
+
+ Tmpl = JSClassCreate(&classDef);
+ JSClassRetain(Tmpl);
+ }
+ return Tmpl;
+ }
+
+
+};
+
+}
+}
+
+#endif // JSCStorage_h
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCText.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCText.h
index 786df27..663124f 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCText.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCText.h
@@ -25,7 +25,7 @@
#include "DOM/Node.hpp"
#include "JSCCharacterData.h"
#include <JavaScriptCore/JavaScriptCore.h>
-#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h"
namespace Arabica {
namespace DOM {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCXPathResult.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCXPathResult.h
index cd6ead7..9686a2c 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCXPathResult.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCXPathResult.h
@@ -24,7 +24,7 @@
#include <string>
#include "DOM/Node.hpp"
#include <JavaScriptCore/JavaScriptCore.h>
-#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h"
namespace Arabica {
namespace DOM {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/Storage.cpp b/src/uscxml/plugins/datamodel/ecmascript/Storage.cpp
new file mode 100644
index 0000000..9131784
--- /dev/null
+++ b/src/uscxml/plugins/datamodel/ecmascript/Storage.cpp
@@ -0,0 +1,74 @@
+#include "Storage.h"
+#include <iostream>
+
+namespace uscxml {
+
+Storage::Storage(const std::string& filename) {
+ _filename = filename;
+ std::cout << _filename << std::endl;
+ std::fstream file;
+ file.open(_filename.c_str(), std::ios_base::in);
+ // read content into data
+ std::string key;
+ std::string value;
+
+ while(std::getline(file, key, '\0')) {
+ if(std::getline(file, value, '\0')) {
+ _data[key] = value;
+ }
+ }
+ file.close();
+}
+
+Storage::~Storage() {
+ std::fstream file;
+ file.open(_filename.c_str(), std::ios_base::out);
+// file.clear();
+
+ std::map<std::string, std::string>::iterator dataIter = _data.begin();
+ while(dataIter != _data.end()) {
+ // include trailing \0
+ file.write(dataIter->first.c_str(), dataIter->first.length() + 1);
+ file.write(dataIter->second.c_str(), dataIter->second.length() + 1);
+ dataIter++;
+ }
+// file.flush();
+ file.close();
+}
+
+unsigned long Storage::getLength() {
+ return _data.size();
+}
+
+std::string Storage::key(unsigned long index) {
+ if (index > getLength())
+ return "";
+
+ std::map<std::string, std::string>::iterator dataIter = _data.begin();
+ for (int i = 0; i < index; i++) {
+ dataIter++;
+ }
+ return dataIter->first;
+}
+
+std::string Storage::getItem(const std::string& key) {
+ if (_data.find(key) == _data.end())
+ return "";
+ return _data[key];
+}
+
+void Storage::setItem(const std::string& key, const std::string& value) {
+ _data[key] = value;
+}
+
+void Storage::removeItem(const std::string& key) {
+ if (_data.find(key) == _data.end())
+ return;
+ _data.erase(key);
+}
+
+void Storage::clear() {
+ _data.clear();
+}
+
+} \ No newline at end of file
diff --git a/src/uscxml/plugins/datamodel/ecmascript/Storage.h b/src/uscxml/plugins/datamodel/ecmascript/Storage.h
new file mode 100644
index 0000000..7caeb76
--- /dev/null
+++ b/src/uscxml/plugins/datamodel/ecmascript/Storage.h
@@ -0,0 +1,30 @@
+#ifndef STORAGE_H_L672TNX
+#define STORAGE_H_L672TNX
+
+#include <string>
+#include <map>
+#include <fstream>
+#include <istream>
+
+namespace uscxml {
+
+class Storage {
+public:
+ Storage(const std::string& filename);
+ ~Storage();
+
+ unsigned long getLength();
+ std::string key(unsigned long index);
+ std::string getItem(const std::string& key);
+ void setItem(const std::string& key, const std::string& value);
+ void removeItem(const std::string& key);
+ void clear();
+
+protected:
+ std::map<std::string, std::string> _data;
+ std::string _filename;
+};
+
+}
+
+#endif /* end of include guard: STORAGE_H_L672TNX */
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DOM.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DOM.cpp
new file mode 100644
index 0000000..be20bee
--- /dev/null
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DOM.cpp
@@ -0,0 +1,17 @@
+#include "V8DOM.h"
+
+namespace Arabica {
+namespace DOM {
+
+V8DOM::V8DOM() {
+}
+
+V8DOM::~V8DOM() {
+ if (xpath)
+ delete(xpath);
+ if (storage)
+ delete(storage);
+}
+
+}
+} \ No newline at end of file
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h
index 10528e8..43b98ce 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h
@@ -4,6 +4,7 @@
#include "uscxml/Interpreter.h"
#include <v8.h>
#include <XPath/XPath.hpp>
+#include "../Storage.h"
#define V8_DESTRUCTOR(type) \
static void jsDestructor(v8::Persistent<v8::Value> object, void* data) { \
@@ -30,7 +31,7 @@ namespace DOM {
class V8DOM {
public:
V8DOM();
- virtual ~V8DOM() { };
+ virtual ~V8DOM();
template <typename T>
static T* toClassPtr(v8::Local<v8::Value> data) {
@@ -48,6 +49,7 @@ public:
}
Arabica::XPath::XPath<std::string>* xpath;
+ uscxml::Storage* storage;
};
class V8Exception : public std::runtime_error {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp
index b394171..017b2eb 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp
@@ -1,6 +1,7 @@
#include "uscxml/Common.h"
+#include "uscxml/config.h"
#include "V8DataModel.h"
-#include "dom/V8DOM.h"
+#include "V8DOM.h"
#include "dom/V8Document.h"
#include "dom/V8Node.h"
#include "dom/V8SCXMLEvent.h"
@@ -29,6 +30,15 @@ V8DataModel::V8DataModel() {
// _contexts.push_back(v8::Context::New());
}
+V8DataModel::~V8DataModel() {
+ while(_contexts.size() > 0) {
+ _contexts.back().Dispose();
+ _contexts.pop_back();
+ }
+ if (_dom)
+ delete _dom;
+}
+
boost::shared_ptr<DataModelImpl> V8DataModel::create(InterpreterImpl* interpreter) {
boost::shared_ptr<V8DataModel> dm = boost::shared_ptr<V8DataModel>(new V8DataModel());
dm->_interpreter = interpreter;
@@ -39,6 +49,7 @@ boost::shared_ptr<DataModelImpl> V8DataModel::create(InterpreterImpl* interprete
// dom->interpreter = interpreter;
dm->_dom->xpath = new XPath<std::string>();
dm->_dom->xpath->setNamespaceContext(interpreter->getNSContext());
+ dm->_dom->storage = new Storage(URL::getResourceDir() + PATH_SEPERATOR + interpreter->getName() + ".storage");
// see http://stackoverflow.com/questions/3171418/v8-functiontemplate-class-instance
@@ -111,13 +122,6 @@ v8::Handle<v8::Value> V8DataModel::getIOProcessors(v8::Local<v8::String> propert
return dataModel->_ioProcessors;
}
-V8DataModel::~V8DataModel() {
- while(_contexts.size() > 0) {
- _contexts.back().Dispose();
- _contexts.pop_back();
- }
-}
-
void V8DataModel::pushContext() {
_contexts.push_back(_contexts.back().New(_contexts.back()));
}
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h
index da69c4f..9d17093 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h
@@ -4,7 +4,7 @@
#include "uscxml/Interpreter.h"
#include <list>
#include <v8.h>
-#include "dom/V8DOM.h"
+#include "V8DOM.h"
#ifdef BUILD_AS_PLUGINS
#include "uscxml/plugins/Plugins.h"
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Attr.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Attr.h
index 9829023..f216215 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Attr.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Attr.h
@@ -25,7 +25,7 @@
#include "DOM/Node.hpp"
#include "V8Node.h"
#include "string"
-#include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h"
#include <v8.h>
namespace Arabica {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CDATASection.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CDATASection.h
index 3b95b84..5f936d2 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CDATASection.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CDATASection.h
@@ -25,7 +25,7 @@
#include "DOM/Node.hpp"
#include "V8Text.h"
#include "string"
-#include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h"
#include <v8.h>
namespace Arabica {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CharacterData.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CharacterData.h
index 6c51ca7..d5846e4 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CharacterData.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CharacterData.h
@@ -25,7 +25,7 @@
#include "DOM/Node.hpp"
#include "V8Node.h"
#include "string"
-#include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h"
#include <v8.h>
namespace Arabica {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Comment.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Comment.h
index 074da74..a19462d 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Comment.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Comment.h
@@ -25,7 +25,7 @@
#include "DOM/Node.hpp"
#include "V8CharacterData.h"
#include "string"
-#include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h"
#include <v8.h>
namespace Arabica {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.cpp
deleted file mode 100644
index 4562fe3..0000000
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.cpp
+++ /dev/null
@@ -1,11 +0,0 @@
-#include "V8DOM.h"
-
-namespace Arabica {
-namespace DOM {
-
-V8DOM::V8DOM() {
-
-}
-
-}
-} \ No newline at end of file
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOMImplementation.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOMImplementation.h
index 5c58e22..58d6f9a 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOMImplementation.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOMImplementation.h
@@ -24,7 +24,7 @@
#include <string>
#include "DOM/Node.hpp"
#include "string"
-#include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h"
#include <v8.h>
namespace Arabica {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.h
index 2db4b54..a023ac9 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.h
@@ -25,7 +25,7 @@
#include "DOM/Node.hpp"
#include "V8Node.h"
#include "string"
-#include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h"
#include <v8.h>
namespace Arabica {
@@ -60,6 +60,7 @@ public:
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::Handle<v8::Value> localStorageCustomAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info);
static v8::Persistent<v8::FunctionTemplate> Tmpl;
static v8::Handle<v8::FunctionTemplate> getTmpl() {
@@ -80,6 +81,8 @@ public:
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));
+ instance->SetAccessor(v8::String::NewSymbol("localStorage"), V8Document::localStorageCustomAttrGetter, 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));
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentCustom.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentCustom.cpp
index 1e0b700..cd7f942 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentCustom.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentCustom.cpp
@@ -1,9 +1,28 @@
#include "V8Document.h"
#include "V8XPathResult.h"
+#include "V8Storage.h"
namespace Arabica {
namespace DOM {
+v8::Handle<v8::Value> V8Document::localStorageCustomAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) {
+ v8::Local<v8::Object> self = info.Holder();
+ V8DocumentPrivate* privData = V8DOM::toClassPtr<V8DocumentPrivate >(self->GetInternalField(0));
+
+ v8::Handle<v8::Function> retCtor = V8Storage::getTmpl()->GetFunction();
+ v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance());
+
+ V8Storage::V8StoragePrivate* retPrivData = new V8Storage::V8StoragePrivate();
+ retPrivData->dom = privData->dom;
+ retPrivData->nativeObj = privData->dom->storage;
+
+ retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
+
+ retObj.MakeWeak(0, V8XPathResult::jsDestructor);
+ return retObj;
+
+}
+
v8::Handle<v8::Value> V8Document::evaluateCustomCallback(const v8::Arguments& args) {
if (args.Length() < 1)
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentFragment.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentFragment.h
index c669b05..641aacd 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentFragment.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentFragment.h
@@ -25,7 +25,7 @@
#include "DOM/Node.hpp"
#include "V8Node.h"
#include "string"
-#include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h"
#include <v8.h>
namespace Arabica {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentType.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentType.h
index 59c2607..d1551a3 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentType.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentType.h
@@ -25,7 +25,7 @@
#include "DOM/Node.hpp"
#include "V8Node.h"
#include "string"
-#include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h"
#include <v8.h>
namespace Arabica {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.h
index e5a52bf..7263ab1 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.h
@@ -25,7 +25,7 @@
#include "DOM/Node.hpp"
#include "V8Node.h"
#include "string"
-#include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h"
#include <v8.h>
namespace Arabica {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Entity.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Entity.h
index 6e85585..88a284b 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Entity.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Entity.h
@@ -25,7 +25,7 @@
#include "DOM/Node.hpp"
#include "V8Node.h"
#include "string"
-#include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h"
#include <v8.h>
namespace Arabica {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8EntityReference.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8EntityReference.h
index 86dd61b..cc25213 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8EntityReference.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8EntityReference.h
@@ -25,7 +25,7 @@
#include "DOM/Node.hpp"
#include "V8Node.h"
#include "string"
-#include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h"
#include <v8.h>
namespace Arabica {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NamedNodeMap.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NamedNodeMap.h
index be89037..d918186 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NamedNodeMap.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NamedNodeMap.h
@@ -24,7 +24,7 @@
#include <string>
#include "DOM/Node.hpp"
#include "string"
-#include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h"
#include <v8.h>
namespace Arabica {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.h
index 2ea8ddc..b4fbad4 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.h
@@ -24,7 +24,7 @@
#include <string>
#include "DOM/Node.hpp"
#include "string"
-#include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h"
#include <v8.h>
namespace Arabica {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeList.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeList.h
index c454e65..341c63a 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeList.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeList.h
@@ -24,7 +24,7 @@
#include <string>
#include "DOM/Node.hpp"
#include "string"
-#include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h"
#include <v8.h>
namespace Arabica {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.h
index 97b5d4f..b95f4c1 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.h
@@ -24,7 +24,7 @@
#include <string>
#include "DOM/Node.hpp"
#include "string"
-#include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h"
#include <v8.h>
namespace Arabica {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Notation.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Notation.h
index 0745728..51f324b 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Notation.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Notation.h
@@ -25,7 +25,7 @@
#include "DOM/Node.hpp"
#include "V8Node.h"
#include "string"
-#include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h"
#include <v8.h>
namespace Arabica {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ProcessingInstruction.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ProcessingInstruction.h
index 56b61eb..d31d5d9 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ProcessingInstruction.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ProcessingInstruction.h
@@ -25,7 +25,7 @@
#include "DOM/Node.hpp"
#include "V8Node.h"
#include "string"
-#include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h"
#include <v8.h>
namespace Arabica {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.h
index 8b71ed7..3c5e6ee 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.h
@@ -24,7 +24,7 @@
#include <string>
#include "DOM/Node.hpp"
#include "string"
-#include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h"
#include <v8.h>
namespace Arabica {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Storage.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Storage.cpp
new file mode 100644
index 0000000..d9ab828
--- /dev/null
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Storage.cpp
@@ -0,0 +1,83 @@
+#include "V8Storage.h"
+
+namespace Arabica {
+namespace DOM {
+
+v8::Persistent<v8::FunctionTemplate> V8Storage::Tmpl;
+
+
+v8::Handle<v8::Value> V8Storage::lengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) {
+ v8::Local<v8::Object> self = info.Holder();
+ struct V8StoragePrivate* privData = V8DOM::toClassPtr<V8StoragePrivate >(self->GetInternalField(0));
+
+ return v8::Integer::New(privData->nativeObj->getLength());
+}
+v8::Handle<v8::Value> V8Storage::keyCallback(const v8::Arguments& args) {
+ if (args.Length() < 1)
+ throw V8Exception("Wrong number of arguments in key");
+
+ v8::Local<v8::Object> self = args.Holder();
+ struct V8StoragePrivate* privData = V8DOM::toClassPtr<V8StoragePrivate >(self->GetInternalField(0));
+ unsigned long localIndex = args[0]->ToNumber()->Uint32Value();
+
+ std::string retVal = privData->nativeObj->key(localIndex);
+
+ return v8::String::New(retVal.c_str());
+}
+
+v8::Handle<v8::Value> V8Storage::getItemCallback(const v8::Arguments& args) {
+ if (args.Length() < 1)
+ throw V8Exception("Wrong number of arguments in getItem");
+
+ v8::Local<v8::Object> self = args.Holder();
+ struct V8StoragePrivate* privData = V8DOM::toClassPtr<V8StoragePrivate >(self->GetInternalField(0));
+ v8::String::AsciiValue localKey(args[0]);
+
+ std::string retVal = privData->nativeObj->getItem(*localKey);
+
+ return v8::String::New(retVal.c_str());
+}
+
+v8::Handle<v8::Value> V8Storage::setItemCallback(const v8::Arguments& args) {
+ if (args.Length() < 2)
+ throw V8Exception("Wrong number of arguments in setItem");
+
+ v8::Local<v8::Object> self = args.Holder();
+ struct V8StoragePrivate* privData = V8DOM::toClassPtr<V8StoragePrivate >(self->GetInternalField(0));
+ v8::String::AsciiValue localKey(args[0]);
+ v8::String::AsciiValue localValue(args[1]);
+
+ privData->nativeObj->setItem(*localKey, *localValue);
+
+ return v8::Undefined();
+}
+
+v8::Handle<v8::Value> V8Storage::removeItemCallback(const v8::Arguments& args) {
+ if (args.Length() < 1)
+ throw V8Exception("Wrong number of arguments in removeItem");
+
+ v8::Local<v8::Object> self = args.Holder();
+ struct V8StoragePrivate* privData = V8DOM::toClassPtr<V8StoragePrivate >(self->GetInternalField(0));
+ v8::String::AsciiValue localKey(args[0]);
+
+ privData->nativeObj->removeItem(*localKey);
+
+ return v8::Undefined();
+}
+
+v8::Handle<v8::Value> V8Storage::clearCallback(const v8::Arguments& args) {
+
+ v8::Local<v8::Object> self = args.Holder();
+ struct V8StoragePrivate* privData = V8DOM::toClassPtr<V8StoragePrivate >(self->GetInternalField(0));
+
+ privData->nativeObj->clear();
+
+ return v8::Undefined();
+}
+
+bool V8Storage::hasInstance(v8::Handle<v8::Value> value) {
+ return getTmpl()->HasInstance(value);
+}
+
+}
+}
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Storage.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Storage.h
new file mode 100644
index 0000000..4d6692d
--- /dev/null
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Storage.h
@@ -0,0 +1,90 @@
+/*
+ This file is part of the Wrapper open source project.
+ This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef V8Storage_h
+#define V8Storage_h
+
+#include <string>
+#include "DOM/Node.hpp"
+#include "string"
+#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h"
+#include <v8.h>
+
+namespace Arabica {
+namespace DOM {
+
+class V8Storage {
+public:
+ struct V8StoragePrivate {
+ V8DOM* dom;
+ uscxml::Storage* nativeObj;
+ };
+
+ V8_DESTRUCTOR_KEEP_WRAPPED(V8StoragePrivate);
+ static bool hasInstance(v8::Handle<v8::Value>);
+
+ static v8::Handle<v8::Value> keyCallback(const v8::Arguments&);
+ static v8::Handle<v8::Value> getItemCallback(const v8::Arguments&);
+ static v8::Handle<v8::Value> setItemCallback(const v8::Arguments&);
+ static v8::Handle<v8::Value> removeItemCallback(const v8::Arguments&);
+ static v8::Handle<v8::Value> clearCallback(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("Storage"));
+ 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"), V8Storage::lengthAttrGetter, 0,
+ v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None));
+
+ prototype->Set(v8::String::NewSymbol("key"),
+ v8::FunctionTemplate::New(V8Storage::keyCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete));
+ prototype->Set(v8::String::NewSymbol("getItem"),
+ v8::FunctionTemplate::New(V8Storage::getItemCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete));
+ prototype->Set(v8::String::NewSymbol("setItem"),
+ v8::FunctionTemplate::New(V8Storage::setItemCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete));
+ prototype->Set(v8::String::NewSymbol("removeItem"),
+ v8::FunctionTemplate::New(V8Storage::removeItemCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete));
+ prototype->Set(v8::String::NewSymbol("clear"),
+ v8::FunctionTemplate::New(V8Storage::clearCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete));
+
+
+ Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl);
+ }
+ return Tmpl;
+ }
+
+
+};
+
+}
+}
+
+#endif // V8Storage_h
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Text.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Text.h
index 61b92fb..0604984 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Text.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Text.h
@@ -25,7 +25,7 @@
#include "DOM/Node.hpp"
#include "V8CharacterData.h"
#include "string"
-#include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h"
#include <v8.h>
namespace Arabica {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.h
index f6a2d10..b613b93 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.h
@@ -24,7 +24,7 @@
#include <string>
#include "DOM/Node.hpp"
#include "string"
-#include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h"
+#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h"
#include <v8.h>
namespace Arabica {
diff --git a/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp b/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp
index 4a1ce05..a72fc6c 100644
--- a/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp
+++ b/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp
@@ -73,8 +73,6 @@ boost::shared_ptr<DataModelImpl> SWIDataModel::create(InterpreterImpl* interpret
LOG(ERROR) << "Error intializing prolog engine";
PL_halt(1);
return boost::shared_ptr<DataModelImpl>();
- } else {
- LOG(WARNING) << "Instantiating more than one SWI prolog datamodel will lead to weird effects as I cannot seperate the environments";
}
PL_set_engine(PL_ENGINE_CURRENT, &engine);
@@ -98,6 +96,7 @@ boost::shared_ptr<DataModelImpl> SWIDataModel::create(InterpreterImpl* interpret
}
} else {
+ LOG(WARNING) << "Instantiating more than one SWI prolog datamodel will lead to weird effects as I cannot seperate the environments";
engine = PL_create_engine(NULL);
}
diff --git a/src/uscxml/plugins/invoker/audio/AudioToolbox.mm b/src/uscxml/plugins/invoker/audio/AudioToolbox.mm
index 44720b1..58e0224 100644
--- a/src/uscxml/plugins/invoker/audio/AudioToolbox.mm
+++ b/src/uscxml/plugins/invoker/audio/AudioToolbox.mm
@@ -4,10 +4,20 @@
#import <Foundation/Foundation.h>
#import <Foundation/NSURL.h>
+#ifdef __has_feature
+# if __has_feature(objc_arc)
+# define(HAS_AUTORELEASE_POOL)
+# endif
+#endif
+
namespace uscxml {
AudioToolbox::AudioToolbox(const std::string filename) {
- @autoreleasepool {
+#if HAS_AUTORELEASE_POOL
+ @autoreleasepool {
+#else
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+#endif
_afId = 0;
NSString* filePath = [NSString stringWithCString:filename.c_str() encoding:NSASCIIStringEncoding];
NSURL* afUrl = [NSURL fileURLWithPath:filePath];
@@ -44,7 +54,11 @@ AudioToolbox::AudioToolbox(const std::string filename) {
return;
}
- }
+#if HAS_AUTORELEASE_POOL
+ }
+#else
+ [pool drain];
+#endif
}
AudioToolbox::~AudioToolbox() {
diff --git a/src/uscxml/plugins/invoker/audio/OpenALInvoker.cpp b/src/uscxml/plugins/invoker/audio/OpenALInvoker.cpp
index 6b52c8c..6403a80 100644
--- a/src/uscxml/plugins/invoker/audio/OpenALInvoker.cpp
+++ b/src/uscxml/plugins/invoker/audio/OpenALInvoker.cpp
@@ -29,6 +29,7 @@ OpenALInvoker::OpenALInvoker() {
_alContext = NULL;
_alDevice = NULL;
_thread = NULL;
+ _listenerPos[0] = _listenerPos[1] = _listenerPos[2] = 0;
}
OpenALInvoker::~OpenALInvoker() {
@@ -131,6 +132,18 @@ void OpenALInvoker::send(const SendRequest& req) {
returnErrorExecution(ex.what());
}
}
+
+ if (boost::iequals(req.name, "move.listener")) {
+ getPosFromParams(req.params, _listenerPos);
+ try {
+ alcMakeContextCurrent(_alContext);
+ alListenerfv(AL_POSITION, _listenerPos);
+ OpenALPlayer::checkOpenALError(__LINE__);
+ } catch (std::exception ex) {
+ returnErrorExecution(ex.what());
+ }
+ }
+
}
void OpenALInvoker::start() {
diff --git a/src/uscxml/plugins/invoker/audio/OpenALInvoker.h b/src/uscxml/plugins/invoker/audio/OpenALInvoker.h
index 086bfe8..2ef567b 100644
--- a/src/uscxml/plugins/invoker/audio/OpenALInvoker.h
+++ b/src/uscxml/plugins/invoker/audio/OpenALInvoker.h
@@ -66,6 +66,7 @@ protected:
bool _isStarted;
bool _isRunning;
+ float _listenerPos[3];
static void fillBuffers(void* userdata);
void start();
diff --git a/src/uscxml/plugins/invoker/audio/OpenALPlayer.h b/src/uscxml/plugins/invoker/audio/OpenALPlayer.h
index 4d7d189..7ea069d 100644
--- a/src/uscxml/plugins/invoker/audio/OpenALPlayer.h
+++ b/src/uscxml/plugins/invoker/audio/OpenALPlayer.h
@@ -63,7 +63,6 @@ private:
void updateBuffers();
void init();
- void checkOpenALError(int line);
// static wrapper as an entry point for pthreads
static void updateBuffersWrapper(void *obj);
@@ -76,6 +75,7 @@ public:
virtual ~OpenALPlayer();
unsigned int isPlaying();
+ static void checkOpenALError(int line);
ALfloat* getPosition();
void setPosition(ALfloat[3]);
diff --git a/src/uscxml/plugins/invoker/xhtml/XHTMLInvoker.cpp b/src/uscxml/plugins/invoker/xhtml/XHTMLInvoker.cpp
index f53eb67..059e7f5 100644
--- a/src/uscxml/plugins/invoker/xhtml/XHTMLInvoker.cpp
+++ b/src/uscxml/plugins/invoker/xhtml/XHTMLInvoker.cpp
@@ -2,6 +2,7 @@
#include "XHTMLInvoker.h"
#include <glog/logging.h>
#include <uscxml/plugins/ioprocessor/comet/CometIOProcessor.h>
+#include <DOM/io/Stream.hpp>
#ifdef BUILD_AS_PLUGINS
#include <Pluma/Connector.hpp>
@@ -101,6 +102,8 @@ bool XHTMLInvoker::httpRecvRequest(const HTTPServer::Request& req) {
content = templateURL.getInContent();
}
+ std::cout << content;
+
_interpreter->getDataModel().replaceExpressions(content);
reply.content = content;