summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2014-05-14 16:51:56 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2014-05-14 16:51:56 (GMT)
commit49127140ed2ad91bfcf532b3d2265582cb80b0db (patch)
treeb31c1537973792f4ac9216de82c0f041e9e8aeae /src
parent6920a312918f989cd2970277a853fbed52cf0c38 (diff)
downloaduscxml-49127140ed2ad91bfcf532b3d2265582cb80b0db.zip
uscxml-49127140ed2ad91bfcf532b3d2265582cb80b0db.tar.gz
uscxml-49127140ed2ad91bfcf532b3d2265582cb80b0db.tar.bz2
Retain interpreter instance for DataModels in Java (Rhino)
Diffstat (limited to 'src')
-rw-r--r--src/bindings/swig/java/JavaDataModel.h7
-rw-r--r--src/bindings/swig/java/uscxml.i12
-rw-r--r--src/uscxml/interpreter/InterpreterDraft6.cpp4
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp2
4 files changed, 21 insertions, 4 deletions
diff --git a/src/bindings/swig/java/JavaDataModel.h b/src/bindings/swig/java/JavaDataModel.h
index fcfb665..4fe6cbe 100644
--- a/src/bindings/swig/java/JavaDataModel.h
+++ b/src/bindings/swig/java/JavaDataModel.h
@@ -12,12 +12,13 @@ public:
JavaDataModel();
virtual ~JavaDataModel();
- virtual JavaDataModel* create(Interpreter interpreter) {
+ virtual JavaDataModel* create(const Interpreter& interpreter) {
return new JavaDataModel();
}
virtual boost::shared_ptr<DataModelImpl> create(InterpreterImpl* interpreter) {
- return boost::shared_ptr<DataModelImpl>(create(interpreter->shared_from_this()));
+ _interpreter = interpreter->shared_from_this();
+ return boost::shared_ptr<DataModelImpl>(create(_interpreter));
}
virtual std::set<std::string> getNames() {
return std::set<std::string>();
@@ -131,6 +132,8 @@ public:
virtual void assign(const std::string& assignElem, const std::string& location, const std::string& content) {}
virtual void eval(const std::string& scriptElem, const std::string& expr) {}
+private:
+ Interpreter _interpreter;
};
}
diff --git a/src/bindings/swig/java/uscxml.i b/src/bindings/swig/java/uscxml.i
index a88ebf1..5dac9d2 100644
--- a/src/bindings/swig/java/uscxml.i
+++ b/src/bindings/swig/java/uscxml.i
@@ -101,6 +101,7 @@ using namespace Arabica::DOM;
%template(ParamPair) std::pair<std::string, uscxml::Data>;
%template(ParamPairVector) std::vector<std::pair<std::string, uscxml::Data> >;
%template(IOProcMap) std::map<std::string, uscxml::IOProcessor>;
+%template(InvokerMap) std::map<std::string, uscxml::Invoker>;
%rename Data DataNative;
# %typemap(jstype) uscxml::Data "Data"
@@ -140,6 +141,17 @@ using namespace Arabica::DOM;
}
return keys;
}
+
+ std::vector<std::string> getInvokerKeys() {
+ std::vector<std::string> keys;
+ std::map<std::string, Invoker>::const_iterator iter = self->getInvokers().begin();
+ while(iter != self->getInvokers().end()) {
+ keys.push_back(iter->first);
+ iter++;
+ }
+ return keys;
+ }
+
};
%extend uscxml::Data {
diff --git a/src/uscxml/interpreter/InterpreterDraft6.cpp b/src/uscxml/interpreter/InterpreterDraft6.cpp
index 31c433c..f80ad24 100644
--- a/src/uscxml/interpreter/InterpreterDraft6.cpp
+++ b/src/uscxml/interpreter/InterpreterDraft6.cpp
@@ -23,6 +23,8 @@
#include "uscxml/UUID.h"
#include "uscxml/DOMUtils.h"
+#define VERBOSE 0
+
namespace uscxml {
using namespace Arabica::XPath;
@@ -185,7 +187,7 @@ void InterpreterDraft6::mainEventLoop() {
// Here we handle eventless transitions and transitions
// triggered by internal events until machine is stable
while(_running && !_stable) {
-#if 0
+#if VERBOSE
std::cout << "Configuration: ";
for (int i = 0; i < _configuration.size(); i++) {
std::cout << ATTR(_configuration[i], "id") << ", ";
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp
index 385ee1c..bddea83 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp
@@ -712,7 +712,7 @@ void V8DataModel::throwExceptionEvent(const v8::TryCatch& tryCatch) {
std::string sourceLine(*v8::String::AsciiValue(message->GetSourceLine()));
size_t startpos = sourceLine.find_first_not_of(" \t");
- if(std::string::npos != startpos) // removoe leading white space
+ if(std::string::npos != startpos) // remove leading white space
sourceLine = sourceLine.substr(startpos);
exceptionEvent.data.compound["sourceline"] = Data(sourceLine, Data::VERBATIM);