diff options
Diffstat (limited to 'src/uscxml')
-rw-r--r-- | src/uscxml/interpreter/EventQueue.h | 2 | ||||
-rw-r--r-- | src/uscxml/interpreter/FastMicroStep.cpp | 4 | ||||
-rw-r--r-- | src/uscxml/interpreter/InterpreterImpl.h | 2 | ||||
-rw-r--r-- | src/uscxml/messages/Data.h | 8 | ||||
-rw-r--r-- | src/uscxml/plugins/ExecutableContentImpl.h | 1 | ||||
-rw-r--r-- | src/uscxml/plugins/Factory.h | 6 | ||||
-rw-r--r-- | src/uscxml/plugins/IOProcessor.h | 2 | ||||
-rw-r--r-- | src/uscxml/plugins/Invoker.h | 2 | ||||
-rw-r--r-- | src/uscxml/plugins/InvokerImpl.h | 22 | ||||
-rw-r--r-- | src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp | 37 | ||||
-rw-r--r-- | src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp | 40 |
11 files changed, 70 insertions, 56 deletions
diff --git a/src/uscxml/interpreter/EventQueue.h b/src/uscxml/interpreter/EventQueue.h index 76fdaa2..dec24d6 100644 --- a/src/uscxml/interpreter/EventQueue.h +++ b/src/uscxml/interpreter/EventQueue.h @@ -56,7 +56,7 @@ protected: */ class USCXML_API DelayedEventQueue : public EventQueue { public: - PIMPL_OPERATORS_INHERIT(DelayedEventQueue, EventQueue); + PIMPL_OPERATORS_INHERIT(DelayedEventQueue, EventQueue) void enqueueDelayed(const Event& event, size_t delayMs, const std::string& eventUUID); void cancelDelayed(const std::string& eventUUID); diff --git a/src/uscxml/interpreter/FastMicroStep.cpp b/src/uscxml/interpreter/FastMicroStep.cpp index a5dcb58..3edd3e4 100644 --- a/src/uscxml/interpreter/FastMicroStep.cpp +++ b/src/uscxml/interpreter/FastMicroStep.cpp @@ -293,7 +293,7 @@ void FastMicroStep::init(XERCESC_NS::DOMElement* scxml) { auto currState = cache.compound["states"].array.begin(); auto endState = cache.compound["states"].array.end(); #endif - + for (i = 0; i < _states.size(); i++) { #ifdef WITH_CACHE_FILES Data* cachedState = NULL; @@ -437,7 +437,7 @@ COMPLETION_STABLISHED: auto currTrans = cache.compound["transitions"].array.begin(); auto endTrans = cache.compound["transitions"].array.end(); #endif - + for (i = 0; i < _transitions.size(); i++) { #ifdef WITH_CACHE_FILES diff --git a/src/uscxml/interpreter/InterpreterImpl.h b/src/uscxml/interpreter/InterpreterImpl.h index a4948b4..5b73939 100644 --- a/src/uscxml/interpreter/InterpreterImpl.h +++ b/src/uscxml/interpreter/InterpreterImpl.h @@ -54,7 +54,7 @@ class USCXML_API InterpreterImpl : public IOProcessorCallbacks, public ContentExecutorCallbacks, public DelayedEventQueueCallbacks, - public InvokerCallbacks, + public InvokerCallbacks, public std::enable_shared_from_this<InterpreterImpl> { public: enum Binding { diff --git a/src/uscxml/messages/Data.h b/src/uscxml/messages/Data.h index 6d4af3e..48323ed 100644 --- a/src/uscxml/messages/Data.h +++ b/src/uscxml/messages/Data.h @@ -69,13 +69,13 @@ public: #ifndef SWIGIMPORTED // swig barfs on this one, have them explictly template < - typename T, - typename = typename std::enable_if<std::is_arithmetic<T>::value, T>::type - > + typename T, + typename = typename std::enable_if<std::is_arithmetic<T>::value, T>::type + > explicit Data(T value) : node(NULL), atom(toStr(value)), type(INTERPRETED) {} #endif - + template <typename T> explicit Data(T value, Type type) : node(NULL), atom(toStr(value)), type(type) {} diff --git a/src/uscxml/plugins/ExecutableContentImpl.h b/src/uscxml/plugins/ExecutableContentImpl.h index 3f987bb..f186e84 100644 --- a/src/uscxml/plugins/ExecutableContentImpl.h +++ b/src/uscxml/plugins/ExecutableContentImpl.h @@ -27,6 +27,7 @@ #include <sstream> namespace XERCESC_NS { +class DOMElement; class DOMDocument; class DOMNode; } diff --git a/src/uscxml/plugins/Factory.h b/src/uscxml/plugins/Factory.h index 50df6ed..48bfae8 100644 --- a/src/uscxml/plugins/Factory.h +++ b/src/uscxml/plugins/Factory.h @@ -44,7 +44,7 @@ class DataModelCallbacks; class InvokerImpl; class InvokerCallbacks; class ExecutableContentImpl; - + class USCXML_API Factory { public: Factory(Factory* parentFactory); @@ -53,7 +53,7 @@ public: void registerIOProcessor(IOProcessorImpl* ioProcessor); void registerDataModel(DataModelImpl* dataModel); void registerInvoker(InvokerImpl* invoker); - void registerExecutableContent(ExecutableContentImpl* executableContent); + void registerExecutableContent(ExecutableContentImpl* executableContent); std::shared_ptr<DataModelImpl> createDataModel(const std::string& type, DataModelCallbacks* callbacks); std::shared_ptr<IOProcessorImpl> createIOProcessor(const std::string& type, IOProcessorCallbacks* callbacks); @@ -83,7 +83,7 @@ protected: std::map<std::string, std::string> _invokerAliases; std::map<std::pair<std::string, std::string>, ExecutableContentImpl*> _executableContent; - + #ifdef BUILD_AS_PLUGINS pluma::Pluma pluma; #endif diff --git a/src/uscxml/plugins/IOProcessor.h b/src/uscxml/plugins/IOProcessor.h index c2b6e30..55c7109 100644 --- a/src/uscxml/plugins/IOProcessor.h +++ b/src/uscxml/plugins/IOProcessor.h @@ -37,7 +37,7 @@ class InterpreterImpl; class USCXML_API IOProcessor : public EventHandler { public: - PIMPL_OPERATORS_INHERIT(IOProcessor, EventHandler); + PIMPL_OPERATORS_INHERIT(IOProcessor, EventHandler) /// @copydoc IOProcessorImpl::eventFromSCXML virtual void eventFromSCXML(const std::string& target, const Event& event); diff --git a/src/uscxml/plugins/Invoker.h b/src/uscxml/plugins/Invoker.h index bb01ddd..c61900e 100644 --- a/src/uscxml/plugins/Invoker.h +++ b/src/uscxml/plugins/Invoker.h @@ -42,7 +42,7 @@ class InvokerImpl; */ class USCXML_API Invoker : public EventHandler { public: - PIMPL_OPERATORS_INHERIT(Invoker, EventHandler); + PIMPL_OPERATORS_INHERIT(Invoker, EventHandler) /// @copydoc InvokerImpl::invoke virtual void invoke(const std::string& source, const Event& invokeEvent); diff --git a/src/uscxml/plugins/InvokerImpl.h b/src/uscxml/plugins/InvokerImpl.h index 9d159a8..96a6492 100644 --- a/src/uscxml/plugins/InvokerImpl.h +++ b/src/uscxml/plugins/InvokerImpl.h @@ -29,9 +29,9 @@ #include <set> namespace XERCESC_NS { - class DOMElement; - class DOMDocument; - class DOMNode; +class DOMElement; +class DOMDocument; +class DOMNode; } namespace uscxml { @@ -40,7 +40,7 @@ class Interpreter; class InterpreterMonitor; class ActionLanguage; class Logger; - + /** * @ingroup invoker * @ingroup callback @@ -48,13 +48,13 @@ class Logger; */ class USCXML_API InvokerCallbacks { public: - virtual ~InvokerCallbacks() {} ///< silence virtual destructor warning from swig - virtual void enqueueInternal(const Event& event) = 0; - virtual void enqueueExternal(const Event& event) = 0; - virtual ActionLanguage getActionLanguage() = 0; - virtual std::set<InterpreterMonitor*> getMonitors() = 0; - virtual std::string getBaseURL() = 0; - virtual Logger getLogger() = 0; + virtual ~InvokerCallbacks() {} ///< silence virtual destructor warning from swig + virtual void enqueueInternal(const Event& event) = 0; + virtual void enqueueExternal(const Event& event) = 0; + virtual ActionLanguage getActionLanguage() = 0; + virtual std::set<InterpreterMonitor*> getMonitors() = 0; + virtual std::string getBaseURL() = 0; + virtual Logger getLogger() = 0; }; /** diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp index bcde9c9..5ce6128 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp @@ -28,6 +28,8 @@ #include "uscxml/util/DOM.h" #include "uscxml/interpreter/Logging.h" +#include <vector> +#include <string> #include <boost/algorithm/string.hpp> #define EVENT_STRING_OR_UNDEF(field, cond) \ @@ -451,14 +453,15 @@ JSValueRef JSCDataModel::getDataAsValue(const Data& data) { return value; } if (data.array.size() > 0) { - JSValueRef elements[data.array.size()]; + std::vector<JSValueRef> elements(data.array.size()); +// JSValueRef elements[data.array.size()]; std::list<Data>::const_iterator arrayIter = data.array.begin(); uint32_t index = 0; while(arrayIter != data.array.end()) { elements[index++] = getDataAsValue(*arrayIter); arrayIter++; } - JSObjectRef value = JSObjectMakeArray(_ctx, data.array.size(), elements, &exception); + JSObjectRef value = JSObjectMakeArray(_ctx, data.array.size(), &elements[0], &exception); if (exception) handleException(exception); return value; @@ -736,8 +739,10 @@ void JSCDataModel::init(const std::string& location, const Data& data, const std void JSCDataModel::handleException(JSValueRef exception) { JSStringRef exceptionStringRef = JSValueToStringCopy(_ctx, exception, NULL); size_t maxSize = JSStringGetMaximumUTF8CStringSize(exceptionStringRef); - char buffer[maxSize]; - JSStringGetUTF8CString(exceptionStringRef, buffer, maxSize); +// char buffer[maxSize]; + std::string buffer; + buffer.resize(maxSize); + JSStringGetUTF8CString(exceptionStringRef, &buffer[0], maxSize); JSStringRelease(exceptionStringRef); std::string exceptionMsg(buffer); @@ -799,8 +804,10 @@ bool JSCDataModel::jsIOProcessorHasProp(JSContextRef ctx, JSObjectRef object, JS std::map<std::string, IOProcessor> ioProcessors = INSTANCE->_callbacks->getIOProcessors(); size_t maxSize = JSStringGetMaximumUTF8CStringSize(propertyName); - char buffer[maxSize]; - JSStringGetUTF8CString(propertyName, buffer, maxSize); +// char buffer[maxSize]; + std::string buffer; + buffer.resize(maxSize); + JSStringGetUTF8CString(propertyName, &buffer[0], maxSize); std::string prop(buffer); return ioProcessors.find(prop) != ioProcessors.end(); @@ -811,8 +818,10 @@ JSValueRef JSCDataModel::jsIOProcessorGetProp(JSContextRef ctx, JSObjectRef obje std::map<std::string, IOProcessor> ioProcessors = INSTANCE->_callbacks->getIOProcessors(); size_t maxSize = JSStringGetMaximumUTF8CStringSize(propertyName); - char buffer[maxSize]; - JSStringGetUTF8CString(propertyName, buffer, maxSize); +// char buffer[maxSize]; + std::string buffer; + buffer.resize(maxSize); + JSStringGetUTF8CString(propertyName, &buffer[0], maxSize); std::string prop(buffer); if (ioProcessors.find(prop) != ioProcessors.end()) { @@ -839,8 +848,10 @@ bool JSCDataModel::jsInvokerHasProp(JSContextRef ctx, JSObjectRef object, JSStri std::map<std::string, Invoker> invokers = INSTANCE->_callbacks->getInvokers(); size_t maxSize = JSStringGetMaximumUTF8CStringSize(propertyName); - char buffer[maxSize]; - JSStringGetUTF8CString(propertyName, buffer, maxSize); +// char buffer[maxSize]; + std::string buffer; + buffer.resize(maxSize); + JSStringGetUTF8CString(propertyName, &buffer[0], maxSize); std::string prop(buffer); return invokers.find(prop) != invokers.end(); @@ -851,8 +862,10 @@ JSValueRef JSCDataModel::jsInvokerGetProp(JSContextRef ctx, JSObjectRef object, std::map<std::string, Invoker> invokers = INSTANCE->_callbacks->getInvokers(); size_t maxSize = JSStringGetMaximumUTF8CStringSize(propertyName); - char buffer[maxSize]; - JSStringGetUTF8CString(propertyName, buffer, maxSize); +// char buffer[maxSize]; + std::string buffer; + buffer.resize(maxSize); + JSStringGetUTF8CString(propertyName, &buffer[0], maxSize); std::string prop(buffer); if (invokers.find(prop) != invokers.end()) { diff --git a/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp b/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp index e776022..44b975e 100644 --- a/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp +++ b/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp @@ -176,30 +176,30 @@ void USCXMLInvoker::invoke(const std::string& source, const Event& invokeEvent) if (_invokedInterpreter) { _invokedInterpreter.getImpl()->_parentQueue = _parentQueue; _invokedInterpreter.getImpl()->_invokeId = invokeEvent.invokeid; - - // test240 assumes that invoke request params will carry over to the datamodel + + // test240 assumes that invoke request params will carry over to the datamodel _invokedInterpreter.getImpl()->_invokeReq = invokeEvent; // create new instances from the parent's ActionLanguage InterpreterImpl* invoked = _invokedInterpreter.getImpl().get(); - ActionLanguage al = _callbacks->getActionLanguage(); - - al.execContent = al.execContent.getImpl()->create(invoked); - al.delayQueue = al.delayQueue.getImplDelayed()->create(invoked); - al.internalQueue = al.internalQueue.getImplBase()->create(); - al.externalQueue = al.externalQueue.getImplBase()->create(); - al.microStepper = al.microStepper.getImpl()->create(invoked); - - _invokedInterpreter.setActionLanguage(al); - // TODO: setup invokers dom, check datamodel attribute and create new instance from parent if matching? - - // copy monitors - std::set<InterpreterMonitor*> monitors = _callbacks->getMonitors(); - for (auto monitor : monitors) { - if (monitor->copyToInvokers()) { - _invokedInterpreter.getImpl()->_monitors.insert(monitor); - } - } + ActionLanguage al = _callbacks->getActionLanguage(); + + al.execContent = al.execContent.getImpl()->create(invoked); + al.delayQueue = al.delayQueue.getImplDelayed()->create(invoked); + al.internalQueue = al.internalQueue.getImplBase()->create(); + al.externalQueue = al.externalQueue.getImplBase()->create(); + al.microStepper = al.microStepper.getImpl()->create(invoked); + + _invokedInterpreter.setActionLanguage(al); + // TODO: setup invokers dom, check datamodel attribute and create new instance from parent if matching? + + // copy monitors + std::set<InterpreterMonitor*> monitors = _callbacks->getMonitors(); + for (auto monitor : monitors) { + if (monitor->copyToInvokers()) { + _invokedInterpreter.getImpl()->_monitors.insert(monitor); + } + } _isActive = true; |