summaryrefslogtreecommitdiffstats
path: root/src/uscxml/plugins/datamodel/ecmascript
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-04-05 12:24:46 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-04-05 12:24:46 (GMT)
commit48009e6bafca54d117bee81ea2a8b41f2aae1d70 (patch)
treee791f120ce5de86484c8fb3c3d5bc2163e8773d0 /src/uscxml/plugins/datamodel/ecmascript
parent5a7c8fd646d77139f216755085e1252a1dee334d (diff)
downloaduscxml-48009e6bafca54d117bee81ea2a8b41f2aae1d70.zip
uscxml-48009e6bafca54d117bee81ea2a8b41f2aae1d70.tar.gz
uscxml-48009e6bafca54d117bee81ea2a8b41f2aae1d70.tar.bz2
Redownloaded tests and fixed some more w3c issues
Diffstat (limited to 'src/uscxml/plugins/datamodel/ecmascript')
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp38
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h3
2 files changed, 29 insertions, 12 deletions
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp
index e86472b..1d01e12 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp
@@ -99,6 +99,7 @@ v8::Handle<v8::Value> V8DataModel::getIOProcessors(v8::Local<v8::String> propert
std::map<std::string, IOProcessor> ioProcessors = dataModel->_interpreter->getIOProcessors();
std::map<std::string, IOProcessor>::const_iterator ioProcIter = ioProcessors.begin();
while(ioProcIter != ioProcessors.end()) {
+ std::cout << ioProcIter->first << std::endl;
dataModel->_ioProcessors->Set(v8::String::New(ioProcIter->first.c_str()),
dataModel->getDataAsValue(ioProcIter->second.getDataModelVariables()));
ioProcIter++;
@@ -143,18 +144,7 @@ void V8DataModel::setEvent(const Event& event) {
eventObj->SetInternalField(0, Arabica::DOM::V8DOM::toExternal(privData));
eventObj.MakeWeak(0, Arabica::DOM::V8SCXMLEvent::jsDestructor);
if (event.dom) {
- // _event.data is a DOM document
- v8::Handle<v8::Function> retCtor = Arabica::DOM::V8Document::getTmpl()->GetFunction();
- v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance());
-
- struct Arabica::DOM::V8Document::V8DocumentPrivate* retPrivData = new Arabica::DOM::V8Document::V8DocumentPrivate();
- retPrivData->dom = privData->dom;
- retPrivData->nativeObj = (Arabica::DOM::Document<std::string>*)&event.dom;
-
- retObj->SetInternalField(0, Arabica::DOM::V8DOM::toExternal(retPrivData));
- retObj.MakeWeak(0, Arabica::DOM::V8Document::jsDestructor);
-
- eventObj->Set(v8::String::New("data"), retObj);
+ eventObj->Set(v8::String::New("data"), getDocumentAsValue(event.dom));
} else if (event.content.length() > 0) {
// _event.data is a string
eventObj->Set(v8::String::New("data"), v8::String::New(event.content.c_str()));
@@ -253,6 +243,20 @@ Data V8DataModel::getValueAsData(const v8::Handle<v8::Value>& value) {
return data;
}
+v8::Handle<v8::Value> V8DataModel::getDocumentAsValue(const Arabica::DOM::Document<std::string>& doc) {
+ v8::Handle<v8::Function> retCtor = Arabica::DOM::V8Document::getTmpl()->GetFunction();
+ v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance());
+
+ struct Arabica::DOM::V8Document::V8DocumentPrivate* retPrivData = new Arabica::DOM::V8Document::V8DocumentPrivate();
+ retPrivData->dom = _dom;
+ retPrivData->nativeObj = new Arabica::DOM::Document<std::string>(doc);
+
+ retObj->SetInternalField(0, Arabica::DOM::V8DOM::toExternal(retPrivData));
+ retObj.MakeWeak(0, Arabica::DOM::V8Document::jsDestructor);
+
+ return retObj;
+}
+
v8::Handle<v8::Value> V8DataModel::getDataAsValue(const Data& data) {
if (data.compound.size() > 0) {
v8::Handle<v8::Object> value = v8::Object::New();
@@ -385,6 +389,16 @@ double V8DataModel::evalAsNumber(const std::string& expr) {
return 0;
}
+void V8DataModel::assign(const std::string& location, const Arabica::DOM::Document<std::string>& doc) {
+ v8::Locker locker;
+ v8::HandleScope handleScope;
+ v8::Context::Scope contextScope(_contexts.front());
+ v8::Handle<v8::Object> global = _contexts.front()->Global();
+
+ global->Set(v8::String::New(location.c_str()), getDocumentAsValue(doc));
+
+}
+
void V8DataModel::assign(const std::string& location, const Data& data) {
v8::Locker locker;
v8::HandleScope handleScope;
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h
index 6348cbc..e67e4ca 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h
@@ -40,11 +40,13 @@ public:
virtual void popContext();
virtual void eval(const std::string& expr);
+ virtual void assign(const std::string& location, const Arabica::DOM::Document<std::string>& doc);
virtual void assign(const std::string& location, const std::string& expr);
virtual void assign(const std::string& location, const Data& data);
virtual Data getStringAsData(const std::string& content);
virtual Data getValueAsData(const v8::Handle<v8::Value>& value);
+
virtual bool isDeclared(const std::string& expr);
virtual std::string evalAsString(const std::string& expr);
@@ -66,6 +68,7 @@ protected:
v8::Handle<v8::Value> evalAsValue(const std::string& expr);
v8::Handle<v8::Value> getDataAsValue(const Data& data);
+ v8::Handle<v8::Value> getDocumentAsValue(const Arabica::DOM::Document<std::string>& doc);
void throwExceptionEvent(const v8::TryCatch& tryCatch);
};