diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-09-23 16:30:04 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-09-23 16:30:04 (GMT) |
commit | be3c180fec71866a91b5f9297708d581bc1d6435 (patch) | |
tree | 830acee295b8456d1e629a0db6c3734f629074a3 /src/uscxml/plugins/datamodel/ecmascript | |
parent | 8dde1311719b29c63efb379566916cb1aa9a7cd7 (diff) | |
download | uscxml-be3c180fec71866a91b5f9297708d581bc1d6435.zip uscxml-be3c180fec71866a91b5f9297708d581bc1d6435.tar.gz uscxml-be3c180fec71866a91b5f9297708d581bc1d6435.tar.bz2 |
Added instant messaging invoker
Diffstat (limited to 'src/uscxml/plugins/datamodel/ecmascript')
-rw-r--r-- | src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp | 39 | ||||
-rw-r--r-- | src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h | 2 |
2 files changed, 30 insertions, 11 deletions
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp index 0e72c67..d479a63 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp @@ -124,11 +124,14 @@ boost::shared_ptr<DataModelImpl> V8DataModel::create(InterpreterImpl* interprete V8DataModel::getIOProcessors, V8DataModel::setWithException, v8::External::New(reinterpret_cast<void*>(dm.get()))); + context->Global()->SetAccessor(v8::String::New("_invokers"), + V8DataModel::getInvokers, + V8DataModel::setWithException, + v8::External::New(reinterpret_cast<void*>(dm.get()))); dm->_contexts.push_back(context); // instantiate objects - we have to have a context for that! - dm->eval(Element<std::string>(), "_invokers = {};"); dm->eval(Element<std::string>(), "_x = {};"); return dm; @@ -147,21 +150,35 @@ 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()); - if (dataModel->_ioProcessors.IsEmpty()) { - 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()) { + 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->_ioProcessors->Set(v8::String::New(ioProcIter->first.c_str()), + dataModel->getDataAsValue(ioProcIter->second.getDataModelVariables())); + ioProcIter++; } return dataModel->_ioProcessors; } +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++; + } + return dataModel->_invokers; +} + 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 0dffa27..1672919 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h @@ -81,7 +81,9 @@ protected: Arabica::DOM::V8DOM* _dom; 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); + static v8::Handle<v8::Value> getInvokers(v8::Local<v8::String> property, const v8::AccessorInfo& info); static v8::Handle<v8::Value> getAttribute(v8::Local<v8::String> property, const v8::AccessorInfo& info); static void setWithException(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info); |