diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-08-28 07:32:19 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-08-28 07:32:19 (GMT) |
commit | 2b64614618fc79728ba447ed9e15c5e7fd06af5e (patch) | |
tree | 341f49721360b123d331cab866b60a4de91f4bc5 /src/uscxml | |
parent | 9d4e46c90f8674ecf60848549a48825069b88046 (diff) | |
download | uscxml-2b64614618fc79728ba447ed9e15c5e7fd06af5e.zip uscxml-2b64614618fc79728ba447ed9e15c5e7fd06af5e.tar.gz uscxml-2b64614618fc79728ba447ed9e15c5e7fd06af5e.tar.bz2 |
Retain ioProcs and invokers object in V8 and moved ctests from contrib to tests
Diffstat (limited to 'src/uscxml')
-rw-r--r-- | src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp | 50 | ||||
-rw-r--r-- | src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h | 2 |
2 files changed, 33 insertions, 19 deletions
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp index 7b0b8e9..f8c9203 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp @@ -17,6 +17,11 @@ * @endcond */ +/* + * Later v8 changed API considerably, have a look at the node.js(!) documentatio for an overview: + * http://strongloop.com/strongblog/node-js-v0-12-c-apis-breaking/ + */ + #include "uscxml/Common.h" #include "uscxml/config.h" #include "V8DataModel.h" @@ -72,7 +77,7 @@ bool pluginConnect(pluma::Host& host) { } #endif -V8DataModel::V8DataModel() { +V8DataModel::V8DataModel() : _ioProcessorsAreSet(false), _invokersAreSet(false) { // _contexts.push_back(v8::Context::New()); } @@ -170,15 +175,18 @@ void V8DataModel::setWithException(v8::Local<v8::String> property, v8::Local<v8: v8::Handle<v8::Value> V8DataModel::getIOProcessors(v8::Local<v8::String> property, const v8::AccessorInfo& info) { V8DataModel* dataModel = V8DOM::toClassPtr<V8DataModel>(info.Data()); - dataModel->_ioProcessors = v8::Persistent<v8::Object>::New(v8::Object::New()); - //v8::Handle<v8::Object> ioProcessorObj = v8::Object::New(); - 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++; + if (!dataModel->_ioProcessorsAreSet) { + dataModel->_ioProcessors = v8::Persistent<v8::Object>::New(v8::Object::New()); + //v8::Handle<v8::Object> ioProcessorObj = v8::Object::New(); + 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++; + } + dataModel->_ioProcessorsAreSet = true; } return dataModel->_ioProcessors; } @@ -186,15 +194,19 @@ v8::Handle<v8::Value> V8DataModel::getIOProcessors(v8::Local<v8::String> propert v8::Handle<v8::Value> V8DataModel::getInvokers(v8::Local<v8::String> property, const v8::AccessorInfo& info) { V8DataModel* dataModel = V8DOM::toClassPtr<V8DataModel>(info.Data()); - dataModel->_invokers = v8::Persistent<v8::Object>::New(v8::Object::New()); - //v8::Handle<v8::Object> ioProcessorObj = v8::Object::New(); - std::map<std::string, Invoker> invokers = dataModel->_interpreter->getInvokers(); - std::map<std::string, Invoker>::const_iterator invokerIter = invokers.begin(); - while(invokerIter != invokers.end()) { - // std::cout << ioProcIter->first << std::endl; - dataModel->_invokers->Set(v8::String::New(invokerIter->first.c_str()), - dataModel->getDataAsValue(invokerIter->second.getDataModelVariables())); - invokerIter++; + if (!dataModel->_invokersAreSet) { + dataModel->_invokers = v8::Persistent<v8::Object>::New(v8::Object::New()); + //v8::Handle<v8::Object> ioProcessorObj = v8::Object::New(); + std::map<std::string, Invoker> invokers = dataModel->_interpreter->getInvokers(); + std::map<std::string, Invoker>::const_iterator invokerIter = invokers.begin(); + while(invokerIter != invokers.end()) { + // std::cout << ioProcIter->first << std::endl; + dataModel->_invokers->Set(v8::String::New(invokerIter->first.c_str()), + dataModel->getDataAsValue(invokerIter->second.getDataModelVariables())); + invokerIter++; + } + dataModel->_invokersAreSet = true; + } return dataModel->_invokers; } diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h index e67a5ab..b114550 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h @@ -104,6 +104,8 @@ protected: Arabica::DOM::V8DOM* _dom; + bool _ioProcessorsAreSet; + bool _invokersAreSet; v8::Persistent<v8::Object> _ioProcessors; v8::Persistent<v8::Object> _invokers; static v8::Handle<v8::Value> getIOProcessors(v8::Local<v8::String> property, const v8::AccessorInfo& info); |