diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-08-01 12:55:04 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-08-01 12:55:04 (GMT) |
commit | 3df6c9c6630f3b3b9b0876ae5bc8f2d12a15b253 (patch) | |
tree | 41f234c33e1e04015ef92a6b94212d9c7e97ad72 /src/uscxml | |
parent | 720bbe5c1b8c0789b5c7ad9ffca33e52bf77f1da (diff) | |
download | uscxml-3df6c9c6630f3b3b9b0876ae5bc8f2d12a15b253.zip uscxml-3df6c9c6630f3b3b9b0876ae5bc8f2d12a15b253.tar.gz uscxml-3df6c9c6630f3b3b9b0876ae5bc8f2d12a15b253.tar.bz2 |
Bug fixes and version bump
- New calendar invoker
- Fixed memory leaks with JavaScriptCore
- Compiles on windows again
- Beautified source code indentation
Diffstat (limited to 'src/uscxml')
41 files changed, 1151 insertions, 434 deletions
diff --git a/src/uscxml/Factory.cpp b/src/uscxml/Factory.cpp index 0d5f401..b8bf60a 100644 --- a/src/uscxml/Factory.cpp +++ b/src/uscxml/Factory.cpp @@ -49,6 +49,10 @@ # include "uscxml/plugins/invoker/calendar/CalendarInvoker.h" # endif +# ifdef CORELOCATION_FOUND +# include "uscxml/plugins/invoker/location/CoreLocation/LocationInvoker.h" +# endif + # ifdef V8_FOUND # include "uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h" # endif @@ -134,8 +138,9 @@ Factory::Factory() { #ifdef MILES_FOUND { - MilesSessionInvoker* invoker = new MilesSessionInvoker(); - registerInvoker(invoker); + // eats 8MB of RAM! +// MilesSessionInvoker* invoker = new MilesSessionInvoker(); +// registerInvoker(invoker); } { SpatialAudio* invoker = new SpatialAudio(); @@ -150,6 +155,13 @@ Factory::Factory() { } #endif +#ifdef LIBICAL_FOUND + { + CalendarInvoker* invoker = new CalendarInvoker(); + registerInvoker(invoker); + } +#endif + #ifdef OPENSCENEGRAPH_FOUND { OSGInvoker* invoker = new OSGInvoker(); @@ -448,7 +460,7 @@ size_t DataModelImpl::replaceExpressions(std::string& content) { } if (replacements) content = ss.str(); - + return replacements; } diff --git a/src/uscxml/Factory.h b/src/uscxml/Factory.h index 58002fe..3ddd9ad 100644 --- a/src/uscxml/Factory.h +++ b/src/uscxml/Factory.h @@ -15,7 +15,7 @@ namespace uscxml { inline bool isnan(double x) { - return x != x; + return x != x; } // see http://stackoverflow.com/questions/228005/alternative-to-itoa-for-converting-integer-to-string-c @@ -259,7 +259,7 @@ public: virtual Data getStringAsData(const std::string& content) = 0; size_t replaceExpressions(std::string& content); - + // foreach virtual uint32_t getLength(const std::string& expr) = 0; virtual void setForeach(const std::string& item, @@ -270,8 +270,8 @@ public: virtual void popContext() = 0; virtual void eval(const Arabica::DOM::Element<std::string>& scriptElem, - const std::string& expr) = 0; - + const std::string& expr) = 0; + virtual std::string evalAsString(const std::string& expr) = 0; virtual bool evalAsBool(const std::string& expr) = 0; @@ -333,7 +333,7 @@ public: } virtual void eval(const Arabica::DOM::Element<std::string>& scriptElem, - const std::string& expr) { + const std::string& expr) { return _impl->eval(scriptElem, expr); } virtual std::string evalAsString(const std::string& expr) { diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp index 4e33c8b..77c6805 100644 --- a/src/uscxml/Interpreter.cpp +++ b/src/uscxml/Interpreter.cpp @@ -473,9 +473,9 @@ void InterpreterImpl::processDOMorText(const Arabica::DOM::Node<std::string>& no std::auto_ptr<std::istream> ssPtr(ss); Arabica::SAX::InputSource<std::string> inputSource; inputSource.setByteStream(ssPtr); - + // parser.setFeature(Arabica::SAX::FeatureNames<std::string>().external_general, true); - + if (parser.parse(inputSource) && parser.getDocument()) { dom = parser.getDocument(); //std::cout << dom; @@ -498,7 +498,7 @@ void InterpreterImpl::processDOMorText(const Arabica::DOM::Node<std::string>& no Node<std::string> child = node.getFirstChild(); while(child) { - if (child.getNodeType() == Node_base::TEXT_NODE) { + if (child.getNodeType() == Node_base::TEXT_NODE || child.getNodeType() == Node_base::CDATA_SECTION_NODE) { std::string trimmed = child.getNodeValue(); boost::trim(trimmed); if (trimmed.length() > 0) @@ -515,8 +515,13 @@ void InterpreterImpl::processDOMorText(const Arabica::DOM::Node<std::string>& no // we need to import the parent - to support xpath test150 Node<std::string> newNode = dom.importNode(child.getParentNode(), true); dom.appendChild(newNode); - } else if(child && child.getNodeType() == Node_base::TEXT_NODE) { - text = child.getNodeValue(); + } else if(child && (child.getNodeType() == Node_base::TEXT_NODE || child.getNodeType() == Node_base::CDATA_SECTION_NODE)) { + while(child) { + if ((child.getNodeType() == Node_base::TEXT_NODE || child.getNodeType() == Node_base::CDATA_SECTION_NODE)) { + text += child.getNodeValue(); + } + child = child.getNextSibling(); + } } else { LOG(ERROR) << LOCALNAME(node) << " has neither text nor element children."; } @@ -638,7 +643,7 @@ void InterpreterImpl::send(const Arabica::DOM::Node<std::string>& element) { } if (delay.size() > 0) { boost::trim(delay); - + NumAttr delayAttr(delay); if (boost::iequals(delayAttr.unit, "ms")) { sendReq.delayMs = strTo<uint32_t>(delayAttr.value); @@ -1076,7 +1081,7 @@ void InterpreterImpl::executeContent(const Arabica::DOM::Node<std::string>& cont CATCH_AND_DISTRIBUTE("Syntax error in expr attribute of log element:") } else { if (logElem.hasAttribute("label")) - std::cout << std::endl; + std::cout << std::endl; } } else if (boost::iequals(TAGNAME(content), _xmlNSPrefix + "assign")) { // --- ASSIGN -------------------------- @@ -1131,9 +1136,14 @@ void InterpreterImpl::executeContent(const Arabica::DOM::Node<std::string>& cont } else { if (content.hasChildNodes()) { // search for the text node with the actual script - if (content.getFirstChild().getNodeType() == Node_base::TEXT_NODE) { + std::string scriptContent; + for (Node<std::string> child = content.getFirstChild(); child; child = child.getNextSibling()) { + if (child.getNodeType() == Node_base::TEXT_NODE || child.getNodeType() == Node_base::CDATA_SECTION_NODE) + scriptContent += child.getNodeValue(); + } + if (scriptContent.size() > 0) { try { - _dataModel.eval((Element<std::string>)content, content.getFirstChild().getNodeValue()); + _dataModel.eval((Element<std::string>)content, scriptContent); } CATCH_AND_DISTRIBUTE("Syntax error while executing script element") } diff --git a/src/uscxml/Interpreter.h b/src/uscxml/Interpreter.h index 56454db..d0da78f 100644 --- a/src/uscxml/Interpreter.h +++ b/src/uscxml/Interpreter.h @@ -188,6 +188,10 @@ public: return _sessionId; } + DelayedEventQueue* getDelayQueue() { + return _sendQueue; + } + const std::map<std::string, IOProcessor>& getIOProcessors() { return _ioProcessors; } @@ -204,7 +208,7 @@ public: bool hasLegalConfiguration(); bool isLegalConfiguration(const Arabica::XPath::NodeSet<std::string>&); bool isLegalConfiguration(const std::vector<std::string>&); - + static bool isState(const Arabica::DOM::Node<std::string>& state); static bool isPseudoState(const Arabica::DOM::Node<std::string>& state); static bool isTransitionTarget(const Arabica::DOM::Node<std::string>& elem); @@ -215,12 +219,12 @@ public: static bool isParallel(const Arabica::DOM::Node<std::string>& state); static bool isCompound(const Arabica::DOM::Node<std::string>& state); static bool isDescendant(const Arabica::DOM::Node<std::string>& s1, const Arabica::DOM::Node<std::string>& s2); - + static std::vector<std::string> tokenizeIdRefs(const std::string& idRefs); static std::string spaceNormalize(const std::string& text); bool isInEmbeddedDocument(const Arabica::DOM::Node<std::string>& node); - bool isInitial(const Arabica::DOM::Node<std::string>& state); + bool isInitial(const Arabica::DOM::Node<std::string>& state); Arabica::XPath::NodeSet<std::string> getInitialStates(Arabica::DOM::Node<std::string> state = Arabica::DOM::Node<std::string>()); static Arabica::XPath::NodeSet<std::string> getChildStates(const Arabica::DOM::Node<std::string>& state); static Arabica::DOM::Node<std::string> getParentState(const Arabica::DOM::Node<std::string>& element); @@ -484,6 +488,9 @@ public: const std::string& getSessionId() { return _impl->getSessionId(); } + DelayedEventQueue* getDelayQueue() { + return _impl->getDelayQueue(); + } const std::map<std::string, IOProcessor>& getIOProcessors() { return _impl->getIOProcessors(); diff --git a/src/uscxml/NameSpacingParser.h b/src/uscxml/NameSpacingParser.h index 50cc260..47dd9eb 100644 --- a/src/uscxml/NameSpacingParser.h +++ b/src/uscxml/NameSpacingParser.h @@ -12,7 +12,7 @@ class ScriptEntityResolver : public Arabica::SAX::EntityResolver<std::string> { return is; } }; - + class NameSpacingParser : public Arabica::SAX2DOM::Parser<std::string> { public: NameSpacingParser(); diff --git a/src/uscxml/URL.cpp b/src/uscxml/URL.cpp index 45aba88..ac947d7 100644 --- a/src/uscxml/URL.cpp +++ b/src/uscxml/URL.cpp @@ -8,7 +8,6 @@ #ifdef _WIN32 #include <fcntl.h> #include <sys/types.h> -#include <sys/stat.h> #include <io.h> #include <direct.h> #define getcwd _getcwd @@ -25,6 +24,30 @@ namespace uscxml { +std::string URL::tmpDir() { + // try hard to find a temporary directory + const char* tmpDir = NULL; + if (tmpDir == NULL) + tmpDir = getenv("TMPDIR"); + if (tmpDir == NULL) + tmpDir = getenv("TMP"); + if (tmpDir == NULL) + tmpDir = getenv("TEMP"); + if (tmpDir == NULL) + tmpDir = getenv("USERPROFILE"); + if (tmpDir == NULL) + tmpDir = "/tmp/"; + + char* tmpl = (char*)malloc(strlen(tmpDir) + 11); + char* writePtr = tmpl; + memcpy(writePtr, tmpDir, strlen(tmpDir)); + writePtr += strlen(tmpDir); + memcpy(writePtr, "scxmlXXXXXX", 11); + writePtr += 11; + tmpl[writePtr - tmpl] = 0; + return tmpl; +} + URLImpl::URLImpl(const std::string& url) : _handle(NULL), _uri(url), _isDownloaded(false), _hasFailed(false) { std::stringstream ss(_uri.path()); std::string item; diff --git a/src/uscxml/URL.h b/src/uscxml/URL.h index 402666f..bb33a7c 100644 --- a/src/uscxml/URL.h +++ b/src/uscxml/URL.h @@ -10,6 +10,7 @@ #include <set> #include <boost/shared_ptr.hpp> #include <boost/enable_shared_from_this.hpp> +#include <sys/stat.h> #include "uscxml/concurrency/tinythread.h" @@ -219,6 +220,8 @@ public: return _impl->asString(); } + static std::string tmpDir(); + friend class URLFetcher; friend std::ostream & operator<<(std::ostream &stream, const URL& p); diff --git a/src/uscxml/interpreter/InterpreterDraft6.cpp b/src/uscxml/interpreter/InterpreterDraft6.cpp index b3e76bd..9140d17 100644 --- a/src/uscxml/interpreter/InterpreterDraft6.cpp +++ b/src/uscxml/interpreter/InterpreterDraft6.cpp @@ -91,7 +91,7 @@ void InterpreterDraft6::interpret() { histStates.push_back(getState(_userDefinedStartConfiguration[i])); } _historyValue[histId] = histStates; - + Element<std::string> initialElem = _document.createElementNS(_nsURL, "initial"); initialElem.setAttribute("generated", "true"); Element<std::string> transitionElem = _document.createElementNS(_nsURL, "transition"); @@ -119,7 +119,7 @@ void InterpreterDraft6::interpret() { } } } - + assert(initialTransitions.size() > 0); enterStates(initialTransitions); // _mutex.unlock(); diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp index 1326fb9..33746a5 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp @@ -15,7 +15,7 @@ namespace uscxml { using namespace Arabica::XPath; using namespace Arabica::DOM; - + #ifdef BUILD_AS_PLUGINS PLUMA_CONNECTOR bool connect(pluma::Host& host) { @@ -25,19 +25,28 @@ bool connect(pluma::Host& host) { #endif JSCDataModel::JSCDataModel() { + _dom = NULL; + _ctx = NULL; +} + +JSCDataModel::~JSCDataModel() { + if (_dom) + delete _dom; + if (_ctx) + JSGlobalContextRelease(_ctx); } #if 0 typedef struct { int version; /* current (and only) version is 0 */ JSClassAttributes attributes; - + const char* className; JSClassRef parentClass; - + const JSStaticValue* staticValues; const JSStaticFunction* staticFunctions; - + JSObjectInitializeCallback initialize; JSObjectFinalizeCallback finalize; JSObjectHasPropertyCallback hasProperty; @@ -51,7 +60,7 @@ typedef struct { JSObjectConvertToTypeCallback convertToType; } JSClassDefinition; #endif - + // functions need to be objects to hold private data in JSC JSClassDefinition JSCDataModel::jsInClassDef = { 0, 0, "In", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, jsIn, 0, 0, 0 }; JSClassDefinition JSCDataModel::jsPrintClassDef = { 0, 0, "print", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, jsPrint, 0, 0, 0 }; @@ -113,7 +122,10 @@ boost::shared_ptr<DataModelImpl> JSCDataModel::create(InterpreterImpl* interpret JSObjectRef documentObject = JSObjectMake(dm->_ctx, JSCDocument::getTmpl(), privData); JSObjectRef globalObject = JSContextGetGlobalObject(dm->_ctx); - JSObjectSetProperty(dm->_ctx, globalObject, JSStringCreateWithUTF8CString("document"), documentObject, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, NULL); + JSStringRef documentName = JSStringCreateWithUTF8CString("document"); + + JSObjectSetProperty(dm->_ctx, globalObject, documentName, documentObject, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, NULL); + JSStringRelease(documentName); } dm->eval(Element<std::string>(), "_x = {};"); @@ -121,10 +133,6 @@ boost::shared_ptr<DataModelImpl> JSCDataModel::create(InterpreterImpl* interpret return dm; } -JSCDataModel::~JSCDataModel() { - JSGlobalContextRelease(_ctx); -} - void JSCDataModel::pushContext() { } @@ -138,7 +146,7 @@ void JSCDataModel::setEvent(const Event& event) { JSObjectRef eventObj = JSObjectMake(_ctx, JSCSCXMLEvent::getTmpl(), privData); JSObjectRef globalObject = JSContextGetGlobalObject(_ctx); - + JSValueRef exception = NULL; if (event.dom) { @@ -199,8 +207,9 @@ void JSCDataModel::setEvent(const Event& event) { handleException(exception); } } - - JSObjectSetProperty(_ctx, globalObject, JSStringCreateWithUTF8CString("_event"), eventObj, kJSPropertyAttributeDontDelete, &exception); + JSStringRef eventName = JSStringCreateWithUTF8CString("_event"); + JSObjectSetProperty(_ctx, globalObject, eventName, eventObj, kJSPropertyAttributeDontDelete, &exception); + JSStringRelease(eventName); if (exception) handleException(exception); @@ -365,7 +374,7 @@ bool JSCDataModel::isDeclared(const std::string& expr) { } void JSCDataModel::eval(const Element<std::string>& scriptElem, - const std::string& expr) { + const std::string& expr) { evalAsValue(expr); } @@ -511,7 +520,9 @@ JSValueRef JSCDataModel::jsPrint(JSContextRef ctx, JSObjectRef function, JSObjec char* buffer = new char[maxSize]; JSStringGetUTF8CString(stringRef, buffer, maxSize); + JSStringRelease(stringRef); std::string msg(buffer); + free(buffer); std::cout << msg; } @@ -532,7 +543,10 @@ JSValueRef JSCDataModel::jsIn(JSContextRef ctx, JSObjectRef function, JSObjectRe char* buffer = new char[maxSize]; JSStringGetUTF8CString(stringRef, buffer, maxSize); + JSStringRelease(stringRef); std::string stateName(buffer); + free(buffer); + if (Interpreter::isMember(INSTANCE->_interpreter->getState(stateName), INSTANCE->_interpreter->getConfiguration())) { continue; } @@ -579,31 +593,31 @@ void JSCDataModel::jsIOProcessorListProps(JSContextRef ctx, JSObjectRef object, JSStringRef ioProcName = JSStringCreateWithUTF8CString(ioProcIter->first.c_str()); JSPropertyNameAccumulatorAddName(propertyNames, ioProcName); ioProcIter++; - } + } } - + bool JSCDataModel::jsInvokerHasProp(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName) { JSCDataModel* INSTANCE = (JSCDataModel*)JSObjectGetPrivate(object); std::map<std::string, Invoker> invokers = INSTANCE->_interpreter->getInvokers(); - + size_t maxSize = JSStringGetMaximumUTF8CStringSize(propertyName); char buffer[maxSize]; JSStringGetUTF8CString(propertyName, buffer, maxSize); std::string prop(buffer); - + return invokers.find(prop) != invokers.end(); } JSValueRef JSCDataModel::jsInvokerGetProp(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) { JSCDataModel* INSTANCE = (JSCDataModel*)JSObjectGetPrivate(object); std::map<std::string, Invoker> invokers = INSTANCE->_interpreter->getInvokers(); - + size_t maxSize = JSStringGetMaximumUTF8CStringSize(propertyName); char buffer[maxSize]; JSStringGetUTF8CString(propertyName, buffer, maxSize); std::string prop(buffer); - + if (invokers.find(prop) != invokers.end()) { return INSTANCE->getDataAsValue(invokers.find(prop)->second.getDataModelVariables()); } @@ -613,13 +627,14 @@ JSValueRef JSCDataModel::jsInvokerGetProp(JSContextRef ctx, JSObjectRef object, void JSCDataModel::jsInvokerListProps(JSContextRef ctx, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames) { JSCDataModel* INSTANCE = (JSCDataModel*)JSObjectGetPrivate(object); std::map<std::string, Invoker> invokers = INSTANCE->_interpreter->getInvokers(); - + std::map<std::string, Invoker>::const_iterator invokerIter = invokers.begin(); while(invokerIter != invokers.end()) { JSStringRef invokeName = JSStringCreateWithUTF8CString(invokerIter->first.c_str()); JSPropertyNameAccumulatorAddName(propertyNames, invokeName); + JSStringRelease(invokeName); invokerIter++; - } + } } }
\ No newline at end of file diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h index 9e70a8f..c5e9587 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h @@ -43,7 +43,7 @@ public: virtual void popContext(); virtual void eval(const Arabica::DOM::Element<std::string>& scriptElem, - const std::string& expr); + const std::string& expr); virtual std::string evalAsString(const std::string& expr); virtual bool evalAsBool(const std::string& expr); diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCAttr.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCAttr.cpp index 4de0efa..6ceb642 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCAttr.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCAttr.cpp @@ -22,8 +22,11 @@ JSStaticFunction JSCAttr::staticFunctions[] = { JSValueRef JSCAttr::nameAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { struct JSCAttrPrivate* privData = (struct JSCAttrPrivate*)JSObjectGetPrivate(object); + JSStringRef stringRef = JSStringCreateWithUTF8CString(privData->nativeObj->getName().c_str()); - return JSValueMakeString(ctx, stringRef); + JSValueRef retVal = JSValueMakeString(ctx, stringRef); + JSStringRelease(stringRef); + return retVal; } @@ -36,8 +39,11 @@ JSValueRef JSCAttr::specifiedAttrGetter(JSContextRef ctx, JSObjectRef object, JS JSValueRef JSCAttr::valueAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { struct JSCAttrPrivate* privData = (struct JSCAttrPrivate*)JSObjectGetPrivate(object); + JSStringRef stringRef = JSStringCreateWithUTF8CString(privData->nativeObj->getValue().c_str()); - return JSValueMakeString(ctx, stringRef); + JSValueRef retVal = JSValueMakeString(ctx, stringRef); + JSStringRelease(stringRef); + return retVal; } diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCharacterData.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCharacterData.cpp index 46dbdae..c7ce20a 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCharacterData.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCharacterData.cpp @@ -24,8 +24,11 @@ JSStaticFunction JSCCharacterData::staticFunctions[] = { JSValueRef JSCCharacterData::dataAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { struct JSCCharacterDataPrivate* privData = (struct JSCCharacterDataPrivate*)JSObjectGetPrivate(object); + JSStringRef stringRef = JSStringCreateWithUTF8CString(privData->nativeObj->getData().c_str()); - return JSValueMakeString(ctx, stringRef); + JSValueRef retVal = JSValueMakeString(ctx, stringRef); + JSStringRelease(stringRef); + return retVal; } @@ -68,6 +71,7 @@ JSValueRef JSCCharacterData::substringDataCallback(JSContextRef ctx, JSObjectRef JSStringRef jscString = JSStringCreateWithUTF8CString(retVal.c_str()); JSValueRef jscRetVal = JSValueMakeString(ctx, jscString); + JSStringRelease(jscString); return jscRetVal; } diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.cpp index bd66f8c..1b5aaef 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.cpp @@ -4,7 +4,12 @@ namespace Arabica { namespace DOM { JSCDOM::JSCDOM() { + xpath = NULL; +} +JSCDOM::~JSCDOM() { + if (xpath) + delete(xpath); } } diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h index 2cd30f6..e2b8a4d 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h @@ -17,7 +17,7 @@ namespace DOM { class JSCDOM { public: JSCDOM(); - virtual ~JSCDOM() { }; + virtual ~JSCDOM(); Arabica::XPath::XPath<std::string>* xpath; }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentType.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentType.cpp index 07bfbc1..954f748 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentType.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentType.cpp @@ -24,8 +24,11 @@ JSStaticFunction JSCDocumentType::staticFunctions[] = { JSValueRef JSCDocumentType::nameAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { struct JSCDocumentTypePrivate* privData = (struct JSCDocumentTypePrivate*)JSObjectGetPrivate(object); + JSStringRef stringRef = JSStringCreateWithUTF8CString(privData->nativeObj->getName().c_str()); - return JSValueMakeString(ctx, stringRef); + JSValueRef retVal = JSValueMakeString(ctx, stringRef); + JSStringRelease(stringRef); + return retVal; } @@ -65,22 +68,31 @@ JSValueRef JSCDocumentType::notationsAttrGetter(JSContextRef ctx, JSObjectRef ob JSValueRef JSCDocumentType::publicIdAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { struct JSCDocumentTypePrivate* privData = (struct JSCDocumentTypePrivate*)JSObjectGetPrivate(object); + JSStringRef stringRef = JSStringCreateWithUTF8CString(privData->nativeObj->getPublicId().c_str()); - return JSValueMakeString(ctx, stringRef); + JSValueRef retVal = JSValueMakeString(ctx, stringRef); + JSStringRelease(stringRef); + return retVal; } JSValueRef JSCDocumentType::systemIdAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { struct JSCDocumentTypePrivate* privData = (struct JSCDocumentTypePrivate*)JSObjectGetPrivate(object); + JSStringRef stringRef = JSStringCreateWithUTF8CString(privData->nativeObj->getSystemId().c_str()); - return JSValueMakeString(ctx, stringRef); + JSValueRef retVal = JSValueMakeString(ctx, stringRef); + JSStringRelease(stringRef); + return retVal; } JSValueRef JSCDocumentType::internalSubsetAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { struct JSCDocumentTypePrivate* privData = (struct JSCDocumentTypePrivate*)JSObjectGetPrivate(object); + JSStringRef stringRef = JSStringCreateWithUTF8CString(privData->nativeObj->getInternalSubset().c_str()); - return JSValueMakeString(ctx, stringRef); + JSValueRef retVal = JSValueMakeString(ctx, stringRef); + JSStringRelease(stringRef); + return retVal; } diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCElement.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCElement.cpp index aa4b242..ce77091 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCElement.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCElement.cpp @@ -35,8 +35,11 @@ JSStaticFunction JSCElement::staticFunctions[] = { JSValueRef JSCElement::tagNameAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { struct JSCElementPrivate* privData = (struct JSCElementPrivate*)JSObjectGetPrivate(object); + JSStringRef stringRef = JSStringCreateWithUTF8CString(privData->nativeObj->getTagName().c_str()); - return JSValueMakeString(ctx, stringRef); + JSValueRef retVal = JSValueMakeString(ctx, stringRef); + JSStringRelease(stringRef); + return retVal; } JSValueRef JSCElement::getAttributeCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { @@ -63,6 +66,7 @@ JSValueRef JSCElement::getAttributeCallback(JSContextRef ctx, JSObjectRef functi JSStringRef jscString = JSStringCreateWithUTF8CString(retVal.c_str()); JSValueRef jscRetVal = JSValueMakeString(ctx, jscString); + JSStringRelease(jscString); return jscRetVal; } @@ -276,6 +280,7 @@ JSValueRef JSCElement::getAttributeNSCallback(JSContextRef ctx, JSObjectRef func JSStringRef jscString = JSStringCreateWithUTF8CString(retVal.c_str()); JSValueRef jscRetVal = JSValueMakeString(ctx, jscString); + JSStringRelease(jscString); return jscRetVal; } diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntity.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntity.cpp index 9466f27..6b51ad0 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntity.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntity.cpp @@ -20,22 +20,31 @@ JSStaticFunction JSCEntity::staticFunctions[] = { JSValueRef JSCEntity::publicIdAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { struct JSCEntityPrivate* privData = (struct JSCEntityPrivate*)JSObjectGetPrivate(object); + JSStringRef stringRef = JSStringCreateWithUTF8CString(privData->nativeObj->getPublicId().c_str()); - return JSValueMakeString(ctx, stringRef); + JSValueRef retVal = JSValueMakeString(ctx, stringRef); + JSStringRelease(stringRef); + return retVal; } JSValueRef JSCEntity::systemIdAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { struct JSCEntityPrivate* privData = (struct JSCEntityPrivate*)JSObjectGetPrivate(object); + JSStringRef stringRef = JSStringCreateWithUTF8CString(privData->nativeObj->getSystemId().c_str()); - return JSValueMakeString(ctx, stringRef); + JSValueRef retVal = JSValueMakeString(ctx, stringRef); + JSStringRelease(stringRef); + return retVal; } JSValueRef JSCEntity::notationNameAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { struct JSCEntityPrivate* privData = (struct JSCEntityPrivate*)JSObjectGetPrivate(object); + JSStringRef stringRef = JSStringCreateWithUTF8CString(privData->nativeObj->getNotationName().c_str()); - return JSValueMakeString(ctx, stringRef); + JSValueRef retVal = JSValueMakeString(ctx, stringRef); + JSStringRelease(stringRef); + return retVal; } diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.cpp index fc7513b..0e84442 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.cpp @@ -53,15 +53,21 @@ JSStaticFunction JSCNode::staticFunctions[] = { JSValueRef JSCNode::nodeNameAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { struct JSCNodePrivate* privData = (struct JSCNodePrivate*)JSObjectGetPrivate(object); + JSStringRef stringRef = JSStringCreateWithUTF8CString(privData->nativeObj->getNodeName().c_str()); - return JSValueMakeString(ctx, stringRef); + JSValueRef retVal = JSValueMakeString(ctx, stringRef); + JSStringRelease(stringRef); + return retVal; } JSValueRef JSCNode::nodeValueAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { struct JSCNodePrivate* privData = (struct JSCNodePrivate*)JSObjectGetPrivate(object); + JSStringRef stringRef = JSStringCreateWithUTF8CString(privData->nativeObj->getNodeValue().c_str()); - return JSValueMakeString(ctx, stringRef); + JSValueRef retVal = JSValueMakeString(ctx, stringRef); + JSStringRelease(stringRef); + return retVal; } @@ -207,15 +213,21 @@ JSValueRef JSCNode::ownerDocumentAttrGetter(JSContextRef ctx, JSObjectRef object JSValueRef JSCNode::namespaceURIAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { struct JSCNodePrivate* privData = (struct JSCNodePrivate*)JSObjectGetPrivate(object); + JSStringRef stringRef = JSStringCreateWithUTF8CString(privData->nativeObj->getNamespaceURI().c_str()); - return JSValueMakeString(ctx, stringRef); + JSValueRef retVal = JSValueMakeString(ctx, stringRef); + JSStringRelease(stringRef); + return retVal; } JSValueRef JSCNode::prefixAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { struct JSCNodePrivate* privData = (struct JSCNodePrivate*)JSObjectGetPrivate(object); + JSStringRef stringRef = JSStringCreateWithUTF8CString(privData->nativeObj->getPrefix().c_str()); - return JSValueMakeString(ctx, stringRef); + JSValueRef retVal = JSValueMakeString(ctx, stringRef); + JSStringRelease(stringRef); + return retVal; } @@ -235,8 +247,11 @@ bool JSCNode::prefixAttrSetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRe JSValueRef JSCNode::localNameAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { struct JSCNodePrivate* privData = (struct JSCNodePrivate*)JSObjectGetPrivate(object); + JSStringRef stringRef = JSStringCreateWithUTF8CString(privData->nativeObj->getLocalName().c_str()); - return JSValueMakeString(ctx, stringRef); + JSValueRef retVal = JSValueMakeString(ctx, stringRef); + JSStringRelease(stringRef); + return retVal; } JSValueRef JSCNode::ELEMENT_NODEConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef *exception) { diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNotation.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNotation.cpp index 35cdc61..8ea57ff 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNotation.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNotation.cpp @@ -19,15 +19,21 @@ JSStaticFunction JSCNotation::staticFunctions[] = { JSValueRef JSCNotation::publicIdAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { struct JSCNotationPrivate* privData = (struct JSCNotationPrivate*)JSObjectGetPrivate(object); + JSStringRef stringRef = JSStringCreateWithUTF8CString(privData->nativeObj->getPublicId().c_str()); - return JSValueMakeString(ctx, stringRef); + JSValueRef retVal = JSValueMakeString(ctx, stringRef); + JSStringRelease(stringRef); + return retVal; } JSValueRef JSCNotation::systemIdAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { struct JSCNotationPrivate* privData = (struct JSCNotationPrivate*)JSObjectGetPrivate(object); + JSStringRef stringRef = JSStringCreateWithUTF8CString(privData->nativeObj->getSystemId().c_str()); - return JSValueMakeString(ctx, stringRef); + JSValueRef retVal = JSValueMakeString(ctx, stringRef); + JSStringRelease(stringRef); + return retVal; } diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCProcessingInstruction.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCProcessingInstruction.cpp index 037af1b..d60c39b 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCProcessingInstruction.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCProcessingInstruction.cpp @@ -19,15 +19,21 @@ JSStaticFunction JSCProcessingInstruction::staticFunctions[] = { JSValueRef JSCProcessingInstruction::targetAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { struct JSCProcessingInstructionPrivate* privData = (struct JSCProcessingInstructionPrivate*)JSObjectGetPrivate(object); + JSStringRef stringRef = JSStringCreateWithUTF8CString(privData->nativeObj->getTarget().c_str()); - return JSValueMakeString(ctx, stringRef); + JSValueRef retVal = JSValueMakeString(ctx, stringRef); + JSStringRelease(stringRef); + return retVal; } JSValueRef JSCProcessingInstruction::dataAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { struct JSCProcessingInstructionPrivate* privData = (struct JSCProcessingInstructionPrivate*)JSObjectGetPrivate(object); + JSStringRef stringRef = JSStringCreateWithUTF8CString(privData->nativeObj->getData().c_str()); - return JSValueMakeString(ctx, stringRef); + JSValueRef retVal = JSValueMakeString(ctx, stringRef); + JSStringRelease(stringRef); + return retVal; } diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCSCXMLEvent.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCSCXMLEvent.cpp index 9b6f34f..de3a93f 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCSCXMLEvent.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCSCXMLEvent.cpp @@ -7,19 +7,18 @@ namespace DOM { JSClassRef JSCSCXMLEvent::Tmpl; JSStaticValue JSCSCXMLEvent::staticValues[] = { + { "type", typeCustomAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, { "name", nameAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, { "origin", originAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "origintype", origintypeAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, { "raw", rawAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, - { "invokeid", invokeidAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, { "dom", domAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, - { "origintype", origintypeAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, - - { "type", typeCustomAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, { "sendid", sendidCustomAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "invokeid", invokeidAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, - { "INTERNAL", INTERNALConstGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum }, - { "EXTERNAL", EXTERNALConstGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum }, - { "PLATFORM", PLATFORMConstGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum }, + { "INTERNAL", INTERNALConstGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "EXTERNAL", EXTERNALConstGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "PLATFORM", PLATFORMConstGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, { 0, 0, 0, 0 } }; @@ -29,8 +28,11 @@ JSStaticFunction JSCSCXMLEvent::staticFunctions[] = { JSValueRef JSCSCXMLEvent::nameAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { struct JSCSCXMLEventPrivate* privData = (struct JSCSCXMLEventPrivate*)JSObjectGetPrivate(object); + JSStringRef stringRef = JSStringCreateWithUTF8CString(privData->nativeObj->name.c_str()); - return JSValueMakeString(ctx, stringRef); + JSValueRef retVal = JSValueMakeString(ctx, stringRef); + JSStringRelease(stringRef); + return retVal; } @@ -40,7 +42,9 @@ JSValueRef JSCSCXMLEvent::originAttrGetter(JSContextRef ctx, JSObjectRef object, if (privData->nativeObj->origin.length() == 0) return JSValueMakeUndefined(ctx); JSStringRef stringRef = JSStringCreateWithUTF8CString(privData->nativeObj->origin.c_str()); - return JSValueMakeString(ctx, stringRef); + JSValueRef retVal = JSValueMakeString(ctx, stringRef); + JSStringRelease(stringRef); + return retVal; } @@ -50,7 +54,9 @@ JSValueRef JSCSCXMLEvent::origintypeAttrGetter(JSContextRef ctx, JSObjectRef obj if (privData->nativeObj->origintype.length() == 0) return JSValueMakeUndefined(ctx); JSStringRef stringRef = JSStringCreateWithUTF8CString(privData->nativeObj->origintype.c_str()); - return JSValueMakeString(ctx, stringRef); + JSValueRef retVal = JSValueMakeString(ctx, stringRef); + JSStringRelease(stringRef); + return retVal; } @@ -60,7 +66,9 @@ JSValueRef JSCSCXMLEvent::rawAttrGetter(JSContextRef ctx, JSObjectRef object, JS if (privData->nativeObj->raw.length() == 0) return JSValueMakeUndefined(ctx); JSStringRef stringRef = JSStringCreateWithUTF8CString(privData->nativeObj->raw.c_str()); - return JSValueMakeString(ctx, stringRef); + JSValueRef retVal = JSValueMakeString(ctx, stringRef); + JSStringRelease(stringRef); + return retVal; } @@ -87,7 +95,9 @@ JSValueRef JSCSCXMLEvent::invokeidAttrGetter(JSContextRef ctx, JSObjectRef objec if (privData->nativeObj->invokeid.length() == 0) return JSValueMakeUndefined(ctx); JSStringRef stringRef = JSStringCreateWithUTF8CString(privData->nativeObj->invokeid.c_str()); - return JSValueMakeString(ctx, stringRef); + JSValueRef retVal = JSValueMakeString(ctx, stringRef); + JSStringRelease(stringRef); + return retVal; } JSValueRef JSCSCXMLEvent::INTERNALConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef *exception) { diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCSCXMLEventCustom.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCSCXMLEventCustom.cpp index de81244..1033034 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCSCXMLEventCustom.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCSCXMLEventCustom.cpp @@ -21,8 +21,10 @@ JSValueRef JSCSCXMLEvent::typeCustomAttrGetter(JSContextRef ctx, JSObjectRef thi stringRef = JSStringCreateWithUTF8CString("undefined"); break; } - - return JSValueMakeString(ctx, stringRef); + + JSValueRef retVal = JSValueMakeString(ctx, stringRef); + JSStringRelease(stringRef); + return retVal; } JSValueRef JSCSCXMLEvent::sendidCustomAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { @@ -33,7 +35,9 @@ JSValueRef JSCSCXMLEvent::sendidCustomAttrGetter(JSContextRef ctx, JSObjectRef t return JSValueMakeUndefined(ctx); } else { stringRef = JSStringCreateWithUTF8CString(privData->nativeObj->sendid.c_str()); - return JSValueMakeString(ctx, stringRef); + JSValueRef retVal = JSValueMakeString(ctx, stringRef); + JSStringRelease(stringRef); + return retVal; } } diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCXPathResult.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCXPathResult.cpp index 4ac7d17..69b7969 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCXPathResult.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCXPathResult.cpp @@ -32,8 +32,11 @@ JSValueRef JSCXPathResult::numberValueAttrGetter(JSContextRef ctx, JSObjectRef o JSValueRef JSCXPathResult::stringValueAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { struct JSCXPathResultPrivate* privData = (struct JSCXPathResultPrivate*)JSObjectGetPrivate(object); + JSStringRef stringRef = JSStringCreateWithUTF8CString(privData->nativeObj->asString().c_str()); - return JSValueMakeString(ctx, stringRef); + JSValueRef retVal = JSValueMakeString(ctx, stringRef); + JSStringRelease(stringRef); + return retVal; } @@ -81,6 +84,7 @@ JSValueRef JSCXPathResult::asStringCallback(JSContextRef ctx, JSObjectRef functi JSStringRef jscString = JSStringCreateWithUTF8CString(retVal.c_str()); JSValueRef jscRetVal = JSValueMakeString(ctx, jscString); + JSStringRelease(jscString); return jscRetVal; } diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp index 2eb41db..f912455 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp @@ -174,7 +174,7 @@ void V8DataModel::setEvent(const Event& event) { nameListIter++; } } - if (eventCopy.data > 0) { + if (eventCopy.data) { eventObj->Set(v8::String::New("data"), getDataAsValue(eventCopy.data)); // set data part of _event } else { // test 343 / test 488 diff --git a/src/uscxml/plugins/datamodel/null/NULLDataModel.cpp b/src/uscxml/plugins/datamodel/null/NULLDataModel.cpp index 53eaffa..e351b1d 100644 --- a/src/uscxml/plugins/datamodel/null/NULLDataModel.cpp +++ b/src/uscxml/plugins/datamodel/null/NULLDataModel.cpp @@ -62,7 +62,7 @@ void NULLDataModel::setForeach(const std::string& item, } void NULLDataModel::eval(const Arabica::DOM::Element<std::string>& scriptElem, - const std::string& expr) { + const std::string& expr) { } bool NULLDataModel::isDeclared(const std::string& expr) { diff --git a/src/uscxml/plugins/datamodel/null/NULLDataModel.h b/src/uscxml/plugins/datamodel/null/NULLDataModel.h index 924bc8c..b86c01c 100644 --- a/src/uscxml/plugins/datamodel/null/NULLDataModel.h +++ b/src/uscxml/plugins/datamodel/null/NULLDataModel.h @@ -55,7 +55,7 @@ public: virtual bool isDeclared(const std::string& expr); virtual void eval(const Arabica::DOM::Element<std::string>& scriptElem, - const std::string& expr); + const std::string& expr); virtual std::string evalAsString(const std::string& expr); virtual bool evalAsBool(const std::string& expr); virtual double evalAsNumber(const std::string& expr); diff --git a/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp b/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp index 462b661..a52af4b 100644 --- a/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp +++ b/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp @@ -13,7 +13,7 @@ _dmPtr = this; #define PL_MODULE \ _interpreter.getSessionId().c_str() \ - + #define UNSET_PL_ENGINE(dm) \ PL_set_engine(NULL, NULL); @@ -49,7 +49,7 @@ SWIDataModel::~SWIDataModel() { _swiEngines.erase(this); } } - + boost::shared_ptr<DataModelImpl> SWIDataModel::create(InterpreterImpl* interpreter) { boost::shared_ptr<SWIDataModel> dm = boost::shared_ptr<SWIDataModel>(new SWIDataModel()); dm->_interpreter = interpreter; @@ -76,18 +76,18 @@ boost::shared_ptr<DataModelImpl> SWIDataModel::create(InterpreterImpl* interpret } else { LOG(WARNING) << "Instantiating more than one SWI prolog datamodel will lead to weird effects as I cannot seperate the environments"; } - + PL_set_engine(PL_ENGINE_CURRENT, &engine); - + // load SWI XML parser try { PlCall("use_module", PlCompound("library", PlTerm("sgml"))); } catch (PlException plex) { - + LOG(ERROR) << "Cannot load prolog sgml module - make sure you have it installed in your prolog runtime: " << (char*)plex; throw plex; } - + // load json parser try { PlCall("use_module", PlCompound("library", PlTerm("http/json"))); @@ -100,11 +100,11 @@ boost::shared_ptr<DataModelImpl> SWIDataModel::create(InterpreterImpl* interpret } else { engine = PL_create_engine(NULL); } - + assert(engine); - _swiEngines[dm.get()] = engine; + _swiEngines[dm.get()] = engine; _dmPtr = dm.get(); - + int rc = PL_set_engine(engine, NULL); assert(rc == PL_ENGINE_SET); @@ -119,7 +119,7 @@ boost::shared_ptr<DataModelImpl> SWIDataModel::create(InterpreterImpl* interpret boost::replace_all(_plModule, "7", "n"); boost::replace_all(_plModule, "8", "o"); boost::replace_all(_plModule, "9", "p"); - + // use atoms for double quoted PlCall("set_prolog_flag(double_quotes,atom)."); diff --git a/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.h b/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.h index b4532cf..123e938 100644 --- a/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.h +++ b/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.h @@ -52,8 +52,8 @@ public: virtual void init(const std::string& location, const Data& data); virtual void eval(const Arabica::DOM::Element<std::string>& scriptElem, - const std::string& expr); - + const std::string& expr); + virtual bool isDeclared(const std::string& expr); virtual Data getStringAsData(const std::string& content); diff --git a/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp b/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp index 1f6a7cc..c38aef3 100644 --- a/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp +++ b/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp @@ -300,7 +300,7 @@ bool XPathDataModel::isValidIdentifier(const std::string& identifier) { void XPathDataModel::eval(const Arabica::DOM::Element<std::string>& scriptElem, - const std::string& expr) { + const std::string& expr) { XPathValue<std::string> result = _xpath.evaluate_expr(expr, _doc); } diff --git a/src/uscxml/plugins/datamodel/xpath/XPathDataModel.h b/src/uscxml/plugins/datamodel/xpath/XPathDataModel.h index 761661a..240c62c 100644 --- a/src/uscxml/plugins/datamodel/xpath/XPathDataModel.h +++ b/src/uscxml/plugins/datamodel/xpath/XPathDataModel.h @@ -87,7 +87,7 @@ public: virtual void popContext(); virtual void eval(const Arabica::DOM::Element<std::string>& scriptElem, - const std::string& expr); + const std::string& expr); virtual void assign(const Arabica::DOM::Element<std::string>& assignElem, const Arabica::DOM::Document<std::string>& doc, const std::string& content); diff --git a/src/uscxml/plugins/invoker/CMakeLists.txt b/src/uscxml/plugins/invoker/CMakeLists.txt index 67d356a..4f13aaf 100644 --- a/src/uscxml/plugins/invoker/CMakeLists.txt +++ b/src/uscxml/plugins/invoker/CMakeLists.txt @@ -147,6 +147,27 @@ if (LIBICAL_FOUND) endif() +# location invoker + +if (CORELOCATION_LIBRARY AND OFF) + file(GLOB_RECURSE LOCATION_INVOKER + location/CoreLocation/*.cpp + location/CoreLocation/*.mm + location/CoreLocation/*.h + ) + source_group("Invoker\\location" FILES ${LOCATION_INVOKER}) + if (BUILD_AS_PLUGINS) + add_library( + invoker_location SHARED + ${LOCATION_INVOKER}) + target_link_libraries(invoker_location uscxml) + set_target_properties(invoker_location PROPERTIES FOLDER "Plugin Invoker") + else() + list (APPEND USCXML_FILES ${LOCATION_INVOKER}) + endif() +endif() + + # UMUNDO invoker if (UMUNDO_FOUND) diff --git a/src/uscxml/plugins/invoker/calendar/CalendarInvoker.cpp b/src/uscxml/plugins/invoker/calendar/CalendarInvoker.cpp index 7ea3fc3..947c86c 100644 --- a/src/uscxml/plugins/invoker/calendar/CalendarInvoker.cpp +++ b/src/uscxml/plugins/invoker/calendar/CalendarInvoker.cpp @@ -16,14 +16,42 @@ bool connect(pluma::Host& host) { #endif CalendarInvoker::CalendarInvoker() { + _icalSet = NULL; + _icalComp = NULL; } CalendarInvoker::~CalendarInvoker() { + tthread::lock_guard<tthread::recursive_mutex> lock(_mutex); + std::set<std::string>::iterator _eventIdIter = _eventIds.begin(); + while(_eventIdIter != _eventIds.end()) { + _interpreter->getDelayQueue()->cancelEvent(*_eventIdIter); + _eventIds.erase(_eventIdIter++); + + } + + std::map<std::string, CalendarEvent*>::iterator eventIter = _events.begin(); + while(eventIter != _events.end()) { + delete eventIter->second; + eventIter++; + } + + if (_icalComp) + icalcomponent_free(_icalComp); }; boost::shared_ptr<InvokerImpl> CalendarInvoker::create(InterpreterImpl* interpreter) { boost::shared_ptr<CalendarInvoker> invoker = boost::shared_ptr<CalendarInvoker>(new CalendarInvoker()); invoker->_interpreter = interpreter; + + icalerror_set_error_state(ICAL_PARSE_ERROR, ICAL_ERROR_NONFATAL); + +// invoker->_calFile = URL::tmpFile(); +// invoker->_icalSet = icalfileset_new(invoker->_calFile.c_str()); + +// if (!invoker->_icalSet) { +// LOG(WARNING) << "Could not create new ical fileset: " << icalerror_perror(); +// } + return invoker; } @@ -33,12 +61,567 @@ Data CalendarInvoker::getDataModelVariables() { } void CalendarInvoker::send(const SendRequest& req) { + tthread::lock_guard<tthread::recursive_mutex> lock(_mutex); } void CalendarInvoker::cancel(const std::string sendId) { + tthread::lock_guard<tthread::recursive_mutex> lock(_mutex); + std::set<std::string>::iterator _eventIdIter = _eventIds.begin(); + while(_eventIdIter != _eventIds.end()) { + _interpreter->getDelayQueue()->cancelEvent(*_eventIdIter); + _eventIds.erase(_eventIdIter++); + } } void CalendarInvoker::invoke(const InvokeRequest& req) { + tthread::lock_guard<tthread::recursive_mutex> lock(_mutex); + + _icalComp = addIcal(req.content); +// dumpComponent(_icalComp); + setupEvents(_icalComp); + +} + +icalcomponent* CalendarInvoker::addIcal(const std::string& icalString) { + + icalcomponent* root = icalparser_parse_string(icalString.c_str()); + if (!root) { + LOG(WARNING) << "Could not parse ical data: " << icalerror_perror(); + return NULL; + } +// icalerrorenum err; +// err = icalset_add_component(_icalSet, root); +// icalfileset_commit(_icalSet); + + return root; +} + +void CalendarInvoker::setupEvents(icalcomponent* comp) { +// dumpComponent(comp); + + switch (icalcomponent_isa(comp)) { + case ICAL_VCALENDAR_COMPONENT: + case ICAL_XROOT_COMPONENT: + break; + case ICAL_VALARM_COMPONENT: { + break; + } + case ICAL_VEVENT_COMPONENT: { + // event to map + CalendarEvent* event = new CalendarEvent(comp); + _events[toStr((uintptr_t)event)] = event; + queueEvent(event); + break; + } + default: +// dumpComponent(comp); + break; + } + + icalcomponent* child = icalcomponent_get_first_component(comp, ICAL_ANY_COMPONENT); + while(child) { + setupEvents(child); + child = icalcomponent_get_next_component(comp, ICAL_ANY_COMPONENT); + } + +} + +void CalendarInvoker::queueEvent(CalendarEvent* event) { + if (_events.find(toStr((uintptr_t)event)) == _events.end()) { + _events[toStr((uintptr_t)event)] = event; + } + time_t now = time(NULL); + struct icaltime_span span; + + if (event->_nextSpan.start > 0) { + span = event->getNextDuration(event->_nextSpan.start + 1); + } else { + span = event->getNextDuration(now); + } + +#if 0 + if (span.end > 0) { + std::cout << "\t\t" << ctime(&span.start); + std::cout << "\t\t" << ctime(&span.end); + span = event->getNextDuration(span.end); + } +#endif + + if (span.start <= 0 || span.end <= 0) { + event->_nextSpan.start = 0; + event->_nextSpan.end = 0; + return; + } + + int beginSecs = span.start - now; + int endSecs = span.end - now; + + if (beginSecs > endSecs) { + LOG(WARNING) << "Event ends before it starts"; + return; + } + + event->_nextSpan = span; + + std::string beginEventId = event->getId() + "." + toStr(span.start) + ".started"; + std::string endEventId = event->getId() + "." + toStr(span.end) + ".ended"; + +#if 1 + beginSecs = 1; + endSecs = 2; +#endif + if (beginSecs > 0) { + _interpreter->getDelayQueue()->addEvent(beginEventId, CalendarInvoker::raiseEvent, beginSecs * 1000, this); + _eventIds.insert(beginEventId); + } else { + raiseEvent(this, beginEventId); + } + _interpreter->getDelayQueue()->addEvent(endEventId, CalendarInvoker::raiseEvent, endSecs * 1000, this); + _eventIds.insert(endEventId); + +} + +void CalendarInvoker::raiseEvent(void* userdata, const std::string eventId) { + CalendarInvoker* INSTANCE = (CalendarInvoker*)userdata; + tthread::lock_guard<tthread::recursive_mutex> lock(INSTANCE->_mutex); + + std::string address = eventId.substr(0, eventId.find_first_of(".")); + + if (INSTANCE->_events.find(address) == INSTANCE->_events.end()) { + LOG(WARNING) << "No such event: " << eventId; + return; + } + + if(INSTANCE->_eventIds.find(eventId) != INSTANCE->_eventIds.end()) { + INSTANCE->_eventIds.erase(eventId); + } + + CalendarEvent* calEvent = INSTANCE->_events[address]; + Event event; + + event.data = *calEvent; + if (boost::ends_with(eventId, ".started")) { + event.name = "event.started." + calEvent->getId(); + assert(!calEvent->_active); + calEvent->_active = true; + } else { + event.name = "event.ended." + calEvent->getId(); + assert(calEvent->_active); + calEvent->_active = false; + } + INSTANCE->returnEvent(event); + + // event ended, reschedule next event + if (boost::ends_with(eventId, ".ended")) + INSTANCE->queueEvent(calEvent); } +/** + * Get the next duration for this event starting no earlier + * than the given time. + */ +icaltime_span CalendarEvent::getNextDuration(time_t time) { + if (!_icalComp) + return icaltime_span_new(icaltime_null_time(), icaltime_null_time(), 0); + + // see icalcomponent_foreach_recurrence + icalproperty *rrule; + + icaltimetype calTime = icaltime_from_timet_with_zone(time, 0, 0); + + // actual occurence, without reocurrence + if (!icalproperty_recurrence_is_excluded(_icalComp, &_dtstart, &_dtend)) { + if (icaltime_compare(_dtstart, calTime) >= 0) { + // start is still in the future + return icaltime_span_new(_dtstart, _dtend, 0); + } + } + + icaltime_span recDur = icaltime_span_new(icaltime_null_time(), icaltime_null_time(), 0); + + // iterate all rrules + for (rrule = icalcomponent_get_first_property(_icalComp, ICAL_RRULE_PROPERTY); + rrule != NULL; + rrule = icalcomponent_get_next_property(_icalComp, ICAL_RRULE_PROPERTY)) { + + struct icalrecurrencetype recurType = icalproperty_get_rrule(rrule); + icalrecur_iterator *ritr; + struct icaltimetype rtime; + + // do we have an old iterator that has not yet passed time? + if (_recIters.find(rrule) != _recIters.end()) { + if (_recIters[rrule].second > time) { + icalrecur_iterator_free(_recIters[rrule].first); + _recIters[rrule].first = icalrecur_iterator_new(recurType, _dtstart); + + // skip initial non-reoccurence + if(_recIters[rrule].first) + rtime = icalrecur_iterator_next(_recIters[rrule].first); + + } + ritr = _recIters[rrule].first; + } else { + // create a new iterator for this rrule + _recIters[rrule] = std::make_pair(icalrecur_iterator_new(recurType, _dtstart), 0); + ritr = _recIters[rrule].first; + } + +// std::cout << icalrecurrencetype_as_string(&recurType) << std::endl; + + while (ritr) { + rtime = icalrecur_iterator_next(ritr); + +#if 0 + time_t tt = icaltime_as_timet(rtime); + std::cout << "\t\t" << ctime(&tt); +#endif + + if (icaltime_is_null_time(rtime)) { + // remove iterator + icalrecur_iterator_free(_recIters[rrule].first); + _recIters.erase(rrule); + break; // for next rule + } + _recIters[rrule].second = icaltime_as_timet(rtime); + + if (icaltime_compare(rtime, calTime) < 0) + continue; // until we are after given time + + if (icalproperty_recurrence_is_excluded(_icalComp, &_dtstart, &rtime)) + continue; + + icaltime_span thisDur = icaltime_span_new(rtime, rtime, 1); + thisDur.end += _dtduration; + + if (recDur.start == 0 || thisDur.start < recDur.start) { + // update soonest reoccurence with the one from this rule + recDur = thisDur; + } + break; // we are after the event + } + } + return recDur; +} + +CalendarEvent::~CalendarEvent() { + std::map<icalproperty*, std::pair<icalrecur_iterator*, time_t> >::iterator recItersIter = _recIters.begin(); + while(recItersIter != _recIters.end()) { + icalrecur_iterator_free(recItersIter->second.first); + recItersIter++; + } +} + +CalendarEvent::CalendarEvent(icalcomponent* icalComp) { + _nextSpan.start = 0; + _nextSpan.end = 0; + _icalComp = NULL; + _active = false; + + + _dtstart = icalcomponent_get_dtstart(icalComp); + _dtend = icalcomponent_get_dtend(icalComp); + + if (!icaltime_is_valid_time(_dtstart)) { + LOG(WARNING) << "Start of event not a valid time"; + return; + } + + if (!icaltime_is_valid_time(_dtend)) { + LOG(WARNING) << "End of event not a valid time"; + return; + } + + _dtduration = icaldurationtype_as_int(icaltime_subtract(_dtend, _dtstart)); + + if (_dtduration <= 0) { + LOG(WARNING) << "Event has negative or zero duration"; + return; + } + + _icalComp = icalComp; + + // initialize all iterators - not really needed anymore + for (icalproperty* rrule = icalcomponent_get_first_property(_icalComp, ICAL_RRULE_PROPERTY); + rrule != NULL; + rrule = icalcomponent_get_next_property(_icalComp, ICAL_RRULE_PROPERTY)) { + + struct icalrecurrencetype recurType = icalproperty_get_rrule(rrule); + icalrecur_iterator *ritr = icalrecur_iterator_new(recurType, _dtstart); + + _recIters[rrule] = std::make_pair(ritr, 0); + } + + +} + +CalendarEvent::operator Data() { + Data data; + data = CalendarInvoker::toData(_icalComp); + return data; +} + +Data CalendarInvoker::toData(icalcomponent* comp) { + Data data; + data.compound["kind"] = Data(icalcomponent_kind_to_string(icalcomponent_isa(comp)), Data::VERBATIM); + + // iterate all properties + icalproperty* prop = icalcomponent_get_first_property(comp, ICAL_ANY_PROPERTY); + while(prop) { + std::string propName = icalproperty_kind_to_string(icalproperty_isa(prop)); + boost::to_lower(propName); + +#if 0 + // iterate all parameters + icalparameter* para = icalproperty_get_first_parameter(prop, ICAL_ANY_PARAMETER); + while(para) { + std::string paraName = icalparameter_kind_to_string(icalparameter_isa(para)); + + switch(icalparameter_get_value(para)) { + case ICAL_VALUE_X: + data.compound[propName].compound[paraName] = Data(icalparameter_get_x(para), Data::VERBATIM); + break; + case ICAL_VALUE_BOOLEAN: + case ICAL_VALUE_BINARY: + case ICAL_VALUE_DATE: + case ICAL_VALUE_DURATION: + case ICAL_VALUE_FLOAT: + case ICAL_VALUE_INTEGER: + case ICAL_VALUE_PERIOD: + case ICAL_VALUE_RECUR: + case ICAL_VALUE_TEXT: + case ICAL_VALUE_URI: + case ICAL_VALUE_ERROR: + case ICAL_VALUE_DATETIME: + case ICAL_VALUE_UTCOFFSET: + case ICAL_VALUE_CALADDRESS: + case ICAL_VALUE_NONE: + data.compound[propName].compound[paraName] = Data("", Data::VERBATIM); + break; + } + + para = icalproperty_get_next_parameter(prop, ICAL_ANY_PARAMETER); + } + data.compound[propName].compound["value"] = Data(icalproperty_get_value_as_string(prop), Data::VERBATIM); +#endif +#if 0 + data.compound[propName] = Data(icalproperty_as_ical_string(prop), Data::VERBATIM); +#endif + data.compound[propName] = Data(icalproperty_get_value_as_string(prop), Data::VERBATIM); + + prop = icalcomponent_get_next_property(comp, ICAL_ANY_PROPERTY); + } + + + icalcomponent* child = icalcomponent_get_first_component(comp, ICAL_ANY_COMPONENT); + while(child) { + data.compound["childs"].array.push_back(toData(child)); + child = icalcomponent_get_next_component(comp, ICAL_ANY_COMPONENT); + } + + return data; +} + +void CalendarInvoker::dumpComponent(icalcomponent* comp) { + std::cout << icalcomponent_kind_to_string(icalcomponent_isa(comp)) << std::endl; + + struct icaltimetype start, end; + time_t tt; + + icalproperty *startProp = icalcomponent_get_first_property(comp, ICAL_DTSTART_PROPERTY); + if (startProp) { + start = icalproperty_get_dtstart(startProp); + } + + icalproperty *endProp = icalcomponent_get_first_property(comp, ICAL_DTEND_PROPERTY); + if (endProp) { + end = icalproperty_get_dtend(endProp); + } + + icalproperty *prop = icalcomponent_get_first_property(comp, ICAL_ANY_PROPERTY); + + while(prop) { + std::cout << "\t" << icalproperty_kind_to_string(icalproperty_isa(prop)) << std::endl; + switch (icalproperty_isa(prop)) { + case ICAL_ANY_PROPERTY: + case ICAL_ACKNOWLEDGED_PROPERTY: + case ICAL_ACTION_PROPERTY: + case ICAL_ALLOWCONFLICT_PROPERTY: + case ICAL_ATTACH_PROPERTY: + case ICAL_ATTENDEE_PROPERTY: + case ICAL_CALID_PROPERTY: + case ICAL_CALMASTER_PROPERTY: + case ICAL_CALSCALE_PROPERTY: + case ICAL_CAPVERSION_PROPERTY: + case ICAL_CARLEVEL_PROPERTY: + case ICAL_CARID_PROPERTY: + case ICAL_CATEGORIES_PROPERTY: + case ICAL_CLASS_PROPERTY: + case ICAL_CMD_PROPERTY: + case ICAL_COMMENT_PROPERTY: + case ICAL_COMPLETED_PROPERTY: + case ICAL_COMPONENTS_PROPERTY: + case ICAL_CONTACT_PROPERTY: + case ICAL_CREATED_PROPERTY: + case ICAL_CSID_PROPERTY: + case ICAL_DATEMAX_PROPERTY: + case ICAL_DATEMIN_PROPERTY: + case ICAL_DECREED_PROPERTY: + case ICAL_DEFAULTCHARSET_PROPERTY: + case ICAL_DEFAULTLOCALE_PROPERTY: + case ICAL_DEFAULTTZID_PROPERTY: + case ICAL_DEFAULTVCARS_PROPERTY: + case ICAL_DENY_PROPERTY: + break; + case ICAL_DESCRIPTION_PROPERTY: + std::cout << "\t\t" << icalproperty_get_description(prop) << std::endl; + break; + case ICAL_DTEND_PROPERTY: { + end = icalproperty_get_dtend(prop); + tt = icaltime_as_timet(start); + std::cout << "\t\t" << ctime(&tt) << std::endl; + break; + } + case ICAL_DTSTAMP_PROPERTY: + break; + case ICAL_DTSTART_PROPERTY: { + start = icalproperty_get_dtstart(prop); + tt = icaltime_as_timet(start); + std::cout << "\t\t" << ctime(&tt) << std::endl; + break; + } + case ICAL_DUE_PROPERTY: + case ICAL_DURATION_PROPERTY: + case ICAL_EXDATE_PROPERTY: + case ICAL_EXPAND_PROPERTY: + case ICAL_EXRULE_PROPERTY: + case ICAL_FREEBUSY_PROPERTY: + case ICAL_GEO_PROPERTY: + case ICAL_GRANT_PROPERTY: + case ICAL_ITIPVERSION_PROPERTY: + case ICAL_LASTMODIFIED_PROPERTY: + case ICAL_LOCATION_PROPERTY: + case ICAL_MAXCOMPONENTSIZE_PROPERTY: + case ICAL_MAXDATE_PROPERTY: + case ICAL_MAXRESULTS_PROPERTY: + case ICAL_MAXRESULTSSIZE_PROPERTY: + case ICAL_METHOD_PROPERTY: + case ICAL_MINDATE_PROPERTY: + case ICAL_MULTIPART_PROPERTY: + case ICAL_NAME_PROPERTY: + case ICAL_ORGANIZER_PROPERTY: + case ICAL_OWNER_PROPERTY: + case ICAL_PERCENTCOMPLETE_PROPERTY: + case ICAL_PERMISSION_PROPERTY: + case ICAL_PRIORITY_PROPERTY: + case ICAL_PRODID_PROPERTY: + case ICAL_QUERY_PROPERTY: + case ICAL_QUERYLEVEL_PROPERTY: + case ICAL_QUERYID_PROPERTY: + case ICAL_QUERYNAME_PROPERTY: + case ICAL_RDATE_PROPERTY: + case ICAL_RECURACCEPTED_PROPERTY: + case ICAL_RECUREXPAND_PROPERTY: + case ICAL_RECURLIMIT_PROPERTY: + case ICAL_RECURRENCEID_PROPERTY: + case ICAL_RELATEDTO_PROPERTY: + case ICAL_RELCALID_PROPERTY: + case ICAL_REPEAT_PROPERTY: + case ICAL_REQUESTSTATUS_PROPERTY: + case ICAL_RESOURCES_PROPERTY: + case ICAL_RESTRICTION_PROPERTY: + break; + case ICAL_RRULE_PROPERTY: { + // struct icaltimetype start = icaltime_from_timet(1,0); + // struct icaltimetype start = icalproperty_get_dtstart(icalcomponent_get_first_property(comp,ICAL_DTSTART_PROPERTY)); + + // struct icaltimetype end = icaltime_today(); + struct icalrecurrencetype recur = icalproperty_get_rrule(prop); + struct icaltimetype next; + + icalrecur_iterator* ritr; + for(ritr = icalrecur_iterator_new(recur,start), + next = icalrecur_iterator_next(ritr); + !icaltime_is_null_time(next); + next = icalrecur_iterator_next(ritr)) { + + tt = icaltime_as_timet(next); + printf(" %s",ctime(&tt )); + + } + icalrecur_iterator_free(ritr); + + break; + } + case ICAL_SCOPE_PROPERTY: + case ICAL_SEQUENCE_PROPERTY: + case ICAL_STATUS_PROPERTY: + case ICAL_STORESEXPANDED_PROPERTY: + case ICAL_SUMMARY_PROPERTY: + case ICAL_TARGET_PROPERTY: + case ICAL_TRANSP_PROPERTY: + case ICAL_TRIGGER_PROPERTY: + case ICAL_TZID_PROPERTY: + case ICAL_TZNAME_PROPERTY: + case ICAL_TZOFFSETFROM_PROPERTY: + case ICAL_TZOFFSETTO_PROPERTY: + case ICAL_TZURL_PROPERTY: + case ICAL_UID_PROPERTY: + case ICAL_URL_PROPERTY: + case ICAL_VERSION_PROPERTY: + case ICAL_X_PROPERTY: + case ICAL_XLICCLASS_PROPERTY: + case ICAL_XLICCLUSTERCOUNT_PROPERTY: + case ICAL_XLICERROR_PROPERTY: + case ICAL_XLICMIMECHARSET_PROPERTY: + case ICAL_XLICMIMECID_PROPERTY: + case ICAL_XLICMIMECONTENTTYPE_PROPERTY: + case ICAL_XLICMIMEENCODING_PROPERTY: + case ICAL_XLICMIMEFILENAME_PROPERTY: + case ICAL_XLICMIMEOPTINFO_PROPERTY: + case ICAL_NO_PROPERTY: + break; + } + prop = icalcomponent_get_next_property(comp, ICAL_ANY_PROPERTY); + } + + switch (icalcomponent_isa(comp)) { + case ICAL_NO_COMPONENT: + case ICAL_ANY_COMPONENT: + break; + case ICAL_XROOT_COMPONENT: { + icalcomponent* child = icalcomponent_get_first_component(comp, ICAL_ANY_COMPONENT); + while(child) { + dumpComponent(child); + child = icalcomponent_get_next_component(comp, ICAL_ANY_COMPONENT); + } + break; + } + case ICAL_XATTACH_COMPONENT: + case ICAL_VEVENT_COMPONENT: + case ICAL_VTODO_COMPONENT: + case ICAL_VJOURNAL_COMPONENT: + case ICAL_VCALENDAR_COMPONENT: + case ICAL_VAGENDA_COMPONENT: + case ICAL_VFREEBUSY_COMPONENT: + case ICAL_VALARM_COMPONENT: + case ICAL_XAUDIOALARM_COMPONENT: + case ICAL_XDISPLAYALARM_COMPONENT: + case ICAL_XEMAILALARM_COMPONENT: + case ICAL_XPROCEDUREALARM_COMPONENT: + case ICAL_VTIMEZONE_COMPONENT: + case ICAL_XSTANDARD_COMPONENT: + case ICAL_XDAYLIGHT_COMPONENT: + case ICAL_X_COMPONENT: + case ICAL_VSCHEDULE_COMPONENT: + case ICAL_VQUERY_COMPONENT: + case ICAL_VREPLY_COMPONENT: + case ICAL_VCAR_COMPONENT: + case ICAL_VCOMMAND_COMPONENT: + case ICAL_XLICINVALID_COMPONENT: + case ICAL_XLICMIMEPART_COMPONENT: + break; + } +} + + }
\ No newline at end of file diff --git a/src/uscxml/plugins/invoker/calendar/CalendarInvoker.h b/src/uscxml/plugins/invoker/calendar/CalendarInvoker.h index 45dc8d0..3faf570 100644 --- a/src/uscxml/plugins/invoker/calendar/CalendarInvoker.h +++ b/src/uscxml/plugins/invoker/calendar/CalendarInvoker.h @@ -2,6 +2,10 @@ #define CALENDARINVOKER_H_W09J90F0 #include <uscxml/Interpreter.h> +extern "C" { +# include <libical/ical.h> +# include <libical/icalss.h> +} #ifdef BUILD_AS_PLUGINS #include "uscxml/plugins/Plugins.h" @@ -9,6 +13,25 @@ namespace uscxml { +class CalendarEvent { +public: + CalendarEvent(icalcomponent* _icalComp); + ~CalendarEvent(); + icalcomponent* _icalComp; + icaltime_span _nextSpan; + bool _active; + struct icaltimetype _dtstart, _dtend; + time_t _dtduration; + + icaltime_span getNextDuration(time_t time); + std::string getId() { + return toStr((uintptr_t)this); + } + + std::map<icalproperty*, std::pair<icalrecur_iterator*, time_t> > _recIters; + operator Data(); +}; + class CalendarInvoker : public InvokerImpl { public: CalendarInvoker(); @@ -27,7 +50,23 @@ public: virtual void cancel(const std::string sendId); virtual void invoke(const InvokeRequest& req); + static void raiseEvent(void* userdata, const std::string eventId); + static Data toData(icalcomponent* comp); protected: + icalcomponent* addIcal(const std::string& icalString); + void setupEvents(icalcomponent* comp); + void queueEvent(CalendarEvent* event); + + void dumpComponent(icalcomponent* comp); + + tthread::recursive_mutex _mutex; + + std::string _calFile; + icalset* _icalSet; + icalcomponent* _icalComp; + + std::set<std::string> _eventIds; + std::map<std::string, CalendarEvent*> _events; }; #ifdef BUILD_AS_PLUGINS diff --git a/src/uscxml/plugins/invoker/location/LocationInvoker.cpp b/src/uscxml/plugins/invoker/location/LocationInvoker.cpp deleted file mode 100644 index 9aeb6b4..0000000 --- a/src/uscxml/plugins/invoker/location/LocationInvoker.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include "LocationInvoker.h" -#include <glog/logging.h> - -#ifdef BUILD_AS_PLUGINS -#include <Pluma/Connector.hpp> -#endif - -namespace uscxml { - -#ifdef BUILD_AS_PLUGINS -PLUMA_CONNECTOR -bool connect(pluma::Host& host) { - host.add( new LocationInvokerProvider() ); - return true; -} -#endif - -LocationInvoker::LocationInvoker() { -} - -LocationInvoker::~LocationInvoker() { -}; - -boost::shared_ptr<InvokerImpl> LocationInvoker::create(InterpreterImpl* interpreter) { - boost::shared_ptr<LocationInvoker> invoker = boost::shared_ptr<LocationInvoker>(new LocationInvoker()); - invoker->_interpreter = interpreter; - return invoker; -} - -Data LocationInvoker::getDataModelVariables() { - Data data; - return data; -} - -void LocationInvoker::send(const SendRequest& req) { -} - -void LocationInvoker::cancel(const std::string sendId) { -} - -void LocationInvoker::invoke(const InvokeRequest& req) { -} - -}
\ No newline at end of file diff --git a/src/uscxml/plugins/invoker/location/LocationInvoker.h b/src/uscxml/plugins/invoker/location/LocationInvoker.h deleted file mode 100644 index 2eb4833..0000000 --- a/src/uscxml/plugins/invoker/location/LocationInvoker.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef LOCATIONINVOKER_H_W09J90F0 -#define LOCATIONINVOKER_H_W09J90F0 - -#include <uscxml/Interpreter.h> - -#ifdef BUILD_AS_PLUGINS -#include "uscxml/plugins/Plugins.h" -#endif - -namespace uscxml { - -class LocationInvoker : public InvokerImpl { -public: - LocationInvoker(); - virtual ~LocationInvoker(); - virtual boost::shared_ptr<InvokerImpl> create(InterpreterImpl* interpreter); - - virtual std::set<std::string> getNames() { - std::set<std::string> names; - names.insert("location"); - names.insert("http://uscxml.tk.informatik.tu-darmstadt.de/#location"); - return names; - } - - virtual Data getDataModelVariables(); - virtual void send(const SendRequest& req); - virtual void cancel(const std::string sendId); - virtual void invoke(const InvokeRequest& req); - -protected: -}; - -#ifdef BUILD_AS_PLUGINS -PLUMA_INHERIT_PROVIDER(LocationInvoker, InvokerImpl); -#endif - -} - - -#endif /* end of include guard: LOCATIONINVOKER_H_W09J90F0 */ diff --git a/src/uscxml/plugins/invoker/miles/SpatialAudio.cpp b/src/uscxml/plugins/invoker/miles/SpatialAudio.cpp index 298b15f..fb91e40 100644 --- a/src/uscxml/plugins/invoker/miles/SpatialAudio.cpp +++ b/src/uscxml/plugins/invoker/miles/SpatialAudio.cpp @@ -70,11 +70,11 @@ void SpatialAudio::send(const SendRequest& req) { miles_audio_device_control(MILES_AUDIO_IO_OPENAL, _audioDev, MILES_AUDIO_DEVICE_CTRL_SET_POSITION, _pos); - + char* buffer = (char*)malloc(_audioDev->chunk_size); // skip wav header _dataStream.seekg(44); - + while(_dataStream.readsome(buffer, _audioDev->chunk_size) != 0) { int written = 0; while(written < _audioDev->chunk_size) { @@ -187,7 +187,7 @@ void SpatialAudio::getPosFromParams(const std::multimap<std::string, std::string } catch (boost::bad_lexical_cast& e) { LOG(ERROR) << "Cannot interpret circle as float value in params: " << e.what(); } - + position[0] = position[0] / _maxPos[0]; position[1] = position[1] / _maxPos[1]; position[2] = position[2] / _maxPos[2]; diff --git a/src/uscxml/plugins/invoker/umundo/JSON.pb.h b/src/uscxml/plugins/invoker/umundo/JSON.pb.h index fe4ee57..a8125bf 100644 --- a/src/uscxml/plugins/invoker/umundo/JSON.pb.h +++ b/src/uscxml/plugins/invoker/umundo/JSON.pb.h @@ -36,127 +36,129 @@ class JSONProto; // =================================================================== class JSONProto : public ::google::protobuf::Message { - public: - JSONProto(); - virtual ~JSONProto(); - - JSONProto(const JSONProto& from); - - inline JSONProto& operator=(const JSONProto& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const JSONProto& default_instance(); - - void Swap(JSONProto* other); - - // implements Message ---------------------------------------------- - - JSONProto* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const JSONProto& from); - void MergeFrom(const JSONProto& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - // repeated .JSONProto compound = 1; - inline int compound_size() const; - inline void clear_compound(); - static const int kCompoundFieldNumber = 1; - inline const ::JSONProto& compound(int index) const; - inline ::JSONProto* mutable_compound(int index); - inline ::JSONProto* add_compound(); - inline const ::google::protobuf::RepeatedPtrField< ::JSONProto >& - compound() const; - inline ::google::protobuf::RepeatedPtrField< ::JSONProto >* - mutable_compound(); - - // optional string key = 2; - inline bool has_key() const; - inline void clear_key(); - static const int kKeyFieldNumber = 2; - inline const ::std::string& key() const; - inline void set_key(const ::std::string& value); - inline void set_key(const char* value); - inline void set_key(const char* value, size_t size); - inline ::std::string* mutable_key(); - inline ::std::string* release_key(); - inline void set_allocated_key(::std::string* key); - - // optional string atom = 3; - inline bool has_atom() const; - inline void clear_atom(); - static const int kAtomFieldNumber = 3; - inline const ::std::string& atom() const; - inline void set_atom(const ::std::string& value); - inline void set_atom(const char* value); - inline void set_atom(const char* value, size_t size); - inline ::std::string* mutable_atom(); - inline ::std::string* release_atom(); - inline void set_allocated_atom(::std::string* atom); - - // optional bool verbatim = 4; - inline bool has_verbatim() const; - inline void clear_verbatim(); - static const int kVerbatimFieldNumber = 4; - inline bool verbatim() const; - inline void set_verbatim(bool value); - - // @@protoc_insertion_point(class_scope:JSONProto) - private: - inline void set_has_key(); - inline void clear_has_key(); - inline void set_has_atom(); - inline void clear_has_atom(); - inline void set_has_verbatim(); - inline void clear_has_verbatim(); - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::google::protobuf::RepeatedPtrField< ::JSONProto > compound_; - ::std::string* key_; - ::std::string* atom_; - bool verbatim_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(4 + 31) / 32]; - - friend void protobuf_AddDesc_JSON_2eproto(); - friend void protobuf_AssignDesc_JSON_2eproto(); - friend void protobuf_ShutdownFile_JSON_2eproto(); - - void InitAsDefaultInstance(); - static JSONProto* default_instance_; +public: + JSONProto(); + virtual ~JSONProto(); + + JSONProto(const JSONProto& from); + + inline JSONProto& operator=(const JSONProto& from) { + CopyFrom(from); + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { + return _unknown_fields_; + } + + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { + return &_unknown_fields_; + } + + static const ::google::protobuf::Descriptor* descriptor(); + static const JSONProto& default_instance(); + + void Swap(JSONProto* other); + + // implements Message ---------------------------------------------- + + JSONProto* New() const; + void CopyFrom(const ::google::protobuf::Message& from); + void MergeFrom(const ::google::protobuf::Message& from); + void CopyFrom(const JSONProto& from); + void MergeFrom(const JSONProto& from); + void Clear(); + bool IsInitialized() const; + + int ByteSize() const; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input); + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + int GetCachedSize() const { + return _cached_size_; + } +private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const; +public: + + ::google::protobuf::Metadata GetMetadata() const; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // repeated .JSONProto compound = 1; + inline int compound_size() const; + inline void clear_compound(); + static const int kCompoundFieldNumber = 1; + inline const ::JSONProto& compound(int index) const; + inline ::JSONProto* mutable_compound(int index); + inline ::JSONProto* add_compound(); + inline const ::google::protobuf::RepeatedPtrField< ::JSONProto >& + compound() const; + inline ::google::protobuf::RepeatedPtrField< ::JSONProto >* + mutable_compound(); + + // optional string key = 2; + inline bool has_key() const; + inline void clear_key(); + static const int kKeyFieldNumber = 2; + inline const ::std::string& key() const; + inline void set_key(const ::std::string& value); + inline void set_key(const char* value); + inline void set_key(const char* value, size_t size); + inline ::std::string* mutable_key(); + inline ::std::string* release_key(); + inline void set_allocated_key(::std::string* key); + + // optional string atom = 3; + inline bool has_atom() const; + inline void clear_atom(); + static const int kAtomFieldNumber = 3; + inline const ::std::string& atom() const; + inline void set_atom(const ::std::string& value); + inline void set_atom(const char* value); + inline void set_atom(const char* value, size_t size); + inline ::std::string* mutable_atom(); + inline ::std::string* release_atom(); + inline void set_allocated_atom(::std::string* atom); + + // optional bool verbatim = 4; + inline bool has_verbatim() const; + inline void clear_verbatim(); + static const int kVerbatimFieldNumber = 4; + inline bool verbatim() const; + inline void set_verbatim(bool value); + + // @@protoc_insertion_point(class_scope:JSONProto) +private: + inline void set_has_key(); + inline void clear_has_key(); + inline void set_has_atom(); + inline void clear_has_atom(); + inline void set_has_verbatim(); + inline void clear_has_verbatim(); + + ::google::protobuf::UnknownFieldSet _unknown_fields_; + + ::google::protobuf::RepeatedPtrField< ::JSONProto > compound_; + ::std::string* key_; + ::std::string* atom_; + bool verbatim_; + + mutable int _cached_size_; + ::google::protobuf::uint32 _has_bits_[(4 + 31) / 32]; + + friend void protobuf_AddDesc_JSON_2eproto(); + friend void protobuf_AssignDesc_JSON_2eproto(); + friend void protobuf_ShutdownFile_JSON_2eproto(); + + void InitAsDefaultInstance(); + static JSONProto* default_instance_; }; // =================================================================== @@ -167,189 +169,189 @@ class JSONProto : public ::google::protobuf::Message { // repeated .JSONProto compound = 1; inline int JSONProto::compound_size() const { - return compound_.size(); + return compound_.size(); } inline void JSONProto::clear_compound() { - compound_.Clear(); + compound_.Clear(); } inline const ::JSONProto& JSONProto::compound(int index) const { - return compound_.Get(index); + return compound_.Get(index); } inline ::JSONProto* JSONProto::mutable_compound(int index) { - return compound_.Mutable(index); + return compound_.Mutable(index); } inline ::JSONProto* JSONProto::add_compound() { - return compound_.Add(); + return compound_.Add(); } inline const ::google::protobuf::RepeatedPtrField< ::JSONProto >& JSONProto::compound() const { - return compound_; + return compound_; } inline ::google::protobuf::RepeatedPtrField< ::JSONProto >* JSONProto::mutable_compound() { - return &compound_; + return &compound_; } // optional string key = 2; inline bool JSONProto::has_key() const { - return (_has_bits_[0] & 0x00000002u) != 0; + return (_has_bits_[0] & 0x00000002u) != 0; } inline void JSONProto::set_has_key() { - _has_bits_[0] |= 0x00000002u; + _has_bits_[0] |= 0x00000002u; } inline void JSONProto::clear_has_key() { - _has_bits_[0] &= ~0x00000002u; + _has_bits_[0] &= ~0x00000002u; } inline void JSONProto::clear_key() { - if (key_ != &::google::protobuf::internal::kEmptyString) { - key_->clear(); - } - clear_has_key(); + if (key_ != &::google::protobuf::internal::kEmptyString) { + key_->clear(); + } + clear_has_key(); } inline const ::std::string& JSONProto::key() const { - return *key_; + return *key_; } inline void JSONProto::set_key(const ::std::string& value) { - set_has_key(); - if (key_ == &::google::protobuf::internal::kEmptyString) { - key_ = new ::std::string; - } - key_->assign(value); + set_has_key(); + if (key_ == &::google::protobuf::internal::kEmptyString) { + key_ = new ::std::string; + } + key_->assign(value); } inline void JSONProto::set_key(const char* value) { - set_has_key(); - if (key_ == &::google::protobuf::internal::kEmptyString) { - key_ = new ::std::string; - } - key_->assign(value); + set_has_key(); + if (key_ == &::google::protobuf::internal::kEmptyString) { + key_ = new ::std::string; + } + key_->assign(value); } inline void JSONProto::set_key(const char* value, size_t size) { - set_has_key(); - if (key_ == &::google::protobuf::internal::kEmptyString) { - key_ = new ::std::string; - } - key_->assign(reinterpret_cast<const char*>(value), size); + set_has_key(); + if (key_ == &::google::protobuf::internal::kEmptyString) { + key_ = new ::std::string; + } + key_->assign(reinterpret_cast<const char*>(value), size); } inline ::std::string* JSONProto::mutable_key() { - set_has_key(); - if (key_ == &::google::protobuf::internal::kEmptyString) { - key_ = new ::std::string; - } - return key_; + set_has_key(); + if (key_ == &::google::protobuf::internal::kEmptyString) { + key_ = new ::std::string; + } + return key_; } inline ::std::string* JSONProto::release_key() { - clear_has_key(); - if (key_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = key_; - key_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } + clear_has_key(); + if (key_ == &::google::protobuf::internal::kEmptyString) { + return NULL; + } else { + ::std::string* temp = key_; + key_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + return temp; + } } inline void JSONProto::set_allocated_key(::std::string* key) { - if (key_ != &::google::protobuf::internal::kEmptyString) { - delete key_; - } - if (key) { - set_has_key(); - key_ = key; - } else { - clear_has_key(); - key_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } + if (key_ != &::google::protobuf::internal::kEmptyString) { + delete key_; + } + if (key) { + set_has_key(); + key_ = key; + } else { + clear_has_key(); + key_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + } } // optional string atom = 3; inline bool JSONProto::has_atom() const { - return (_has_bits_[0] & 0x00000004u) != 0; + return (_has_bits_[0] & 0x00000004u) != 0; } inline void JSONProto::set_has_atom() { - _has_bits_[0] |= 0x00000004u; + _has_bits_[0] |= 0x00000004u; } inline void JSONProto::clear_has_atom() { - _has_bits_[0] &= ~0x00000004u; + _has_bits_[0] &= ~0x00000004u; } inline void JSONProto::clear_atom() { - if (atom_ != &::google::protobuf::internal::kEmptyString) { - atom_->clear(); - } - clear_has_atom(); + if (atom_ != &::google::protobuf::internal::kEmptyString) { + atom_->clear(); + } + clear_has_atom(); } inline const ::std::string& JSONProto::atom() const { - return *atom_; + return *atom_; } inline void JSONProto::set_atom(const ::std::string& value) { - set_has_atom(); - if (atom_ == &::google::protobuf::internal::kEmptyString) { - atom_ = new ::std::string; - } - atom_->assign(value); + set_has_atom(); + if (atom_ == &::google::protobuf::internal::kEmptyString) { + atom_ = new ::std::string; + } + atom_->assign(value); } inline void JSONProto::set_atom(const char* value) { - set_has_atom(); - if (atom_ == &::google::protobuf::internal::kEmptyString) { - atom_ = new ::std::string; - } - atom_->assign(value); + set_has_atom(); + if (atom_ == &::google::protobuf::internal::kEmptyString) { + atom_ = new ::std::string; + } + atom_->assign(value); } inline void JSONProto::set_atom(const char* value, size_t size) { - set_has_atom(); - if (atom_ == &::google::protobuf::internal::kEmptyString) { - atom_ = new ::std::string; - } - atom_->assign(reinterpret_cast<const char*>(value), size); + set_has_atom(); + if (atom_ == &::google::protobuf::internal::kEmptyString) { + atom_ = new ::std::string; + } + atom_->assign(reinterpret_cast<const char*>(value), size); } inline ::std::string* JSONProto::mutable_atom() { - set_has_atom(); - if (atom_ == &::google::protobuf::internal::kEmptyString) { - atom_ = new ::std::string; - } - return atom_; + set_has_atom(); + if (atom_ == &::google::protobuf::internal::kEmptyString) { + atom_ = new ::std::string; + } + return atom_; } inline ::std::string* JSONProto::release_atom() { - clear_has_atom(); - if (atom_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = atom_; - atom_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } + clear_has_atom(); + if (atom_ == &::google::protobuf::internal::kEmptyString) { + return NULL; + } else { + ::std::string* temp = atom_; + atom_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + return temp; + } } inline void JSONProto::set_allocated_atom(::std::string* atom) { - if (atom_ != &::google::protobuf::internal::kEmptyString) { - delete atom_; - } - if (atom) { - set_has_atom(); - atom_ = atom; - } else { - clear_has_atom(); - atom_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } + if (atom_ != &::google::protobuf::internal::kEmptyString) { + delete atom_; + } + if (atom) { + set_has_atom(); + atom_ = atom; + } else { + clear_has_atom(); + atom_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + } } // optional bool verbatim = 4; inline bool JSONProto::has_verbatim() const { - return (_has_bits_[0] & 0x00000008u) != 0; + return (_has_bits_[0] & 0x00000008u) != 0; } inline void JSONProto::set_has_verbatim() { - _has_bits_[0] |= 0x00000008u; + _has_bits_[0] |= 0x00000008u; } inline void JSONProto::clear_has_verbatim() { - _has_bits_[0] &= ~0x00000008u; + _has_bits_[0] &= ~0x00000008u; } inline void JSONProto::clear_verbatim() { - verbatim_ = false; - clear_has_verbatim(); + verbatim_ = false; + clear_has_verbatim(); } inline bool JSONProto::verbatim() const { - return verbatim_; + return verbatim_; } inline void JSONProto::set_verbatim(bool value) { - set_has_verbatim(); - verbatim_ = value; + set_has_verbatim(); + verbatim_ = value; } diff --git a/src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp b/src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp index 081842f..bbfdabd 100644 --- a/src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp +++ b/src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp @@ -59,12 +59,12 @@ void UmundoInvoker::send(const SendRequest& req) { LOG(ERROR) << "Cannot transform content to data object per datamodel"; return; } - + std::string type; if (req.params.find("type") != req.params.end()) { // we are supposed to build a typed object type = req.params.find("type")->second; - + const google::protobuf::Message* protoMsg = umundo::PBSerializer::getProto(type); if (protoMsg == NULL) { LOG(ERROR) << "No type '" << type << "' is known, pass a directory with proto .desc files via types param when invoking"; @@ -76,7 +76,7 @@ void UmundoInvoker::send(const SendRequest& req) { LOG(ERROR) << "Cannot create message from JSON - not sending"; return; } - + if (!_isService) { // add all s11n properties _pub->prepareMsg(&msg, type, pbMsg); @@ -90,12 +90,12 @@ void UmundoInvoker::send(const SendRequest& req) { void* rv = NULL; stub->callStubMethod(req.name, pbMsg, type, rv, ""); protobufToData(event.data, *(const google::protobuf::Message*)rv); - + event.name = _invokeId + ".reply." + req.name; event.origin = msg.getMeta("um.channel"); event.origintype = "umundo"; event.type = Event::EXTERNAL; - + returnEvent(event); svcIter++; } @@ -116,7 +116,7 @@ void UmundoInvoker::send(const SendRequest& req) { LOG(ERROR) << "Cannot invoke services with untyped JSON"; return; } - + } } catch (Event e) { LOG(ERROR) << "Syntax error when invoking umundo:" << std::endl << e << std::endl; @@ -125,7 +125,7 @@ void UmundoInvoker::send(const SendRequest& req) { } else { LOG(ERROR) << "Required JSON object in content" << std::endl; return; - } + } } void UmundoInvoker::cancel(const std::string sendId) { @@ -187,7 +187,7 @@ void UmundoInvoker::invoke(const InvokeRequest& req) { _pub->setGreeter(this); _sub->registerType("JSON", new JSONProto()); - + _node->addPublisher(*_pub); _node->addSubscriber(*_sub); @@ -237,7 +237,7 @@ void UmundoInvoker::receive(void* object, umundo::Message* msg) { if (object != NULL) { if (msg->getMeta().find("um.s11n.type") != msg->getMeta().end() && - boost::equals(msg->getMeta().find("um.s11n.type")->second, "JSON")) { + boost::equals(msg->getMeta().find("um.s11n.type")->second, "JSON")) { jsonbufToData(event.data, *(JSONProto*)object); } else { protobufToData(event.data, *(const google::protobuf::Message*)object); @@ -349,7 +349,7 @@ bool UmundoInvoker::jsonbufToData(Data& data, const JSONProto& json) { data.type = Data::INTERPRETED; } } - + return true; } @@ -485,7 +485,7 @@ bool UmundoInvoker::dataToJSONbuf(JSONProto* msg, Data& data) { } else if (!data.array.empty()) { const google::protobuf::FieldDescriptor* fieldDesc = desc->FindFieldByName("compound"); - std::list<Data>::iterator arrayIter = data.array.begin(); + std::list<Data>::iterator arrayIter = data.array.begin(); while(arrayIter != data.array.end()) { JSONProto* arrayMsg = (JSONProto*)reflect->AddMessage(msg, fieldDesc); dataToJSONbuf(arrayMsg, *arrayIter); diff --git a/src/uscxml/plugins/invoker/umundo/UmundoInvoker.h b/src/uscxml/plugins/invoker/umundo/UmundoInvoker.h index 4d81e79..c013a52 100644 --- a/src/uscxml/plugins/invoker/umundo/UmundoInvoker.h +++ b/src/uscxml/plugins/invoker/umundo/UmundoInvoker.h @@ -18,7 +18,7 @@ namespace uscxml { class Interpreter; - class UmundoInvoker : public InvokerImpl, public umundo::TypedReceiver, public umundo::ResultSet<umundo::ServiceDescription>, public umundo::TypedGreeter { +class UmundoInvoker : public InvokerImpl, public umundo::TypedReceiver, public umundo::ResultSet<umundo::ServiceDescription>, public umundo::TypedGreeter { public: UmundoInvoker(); virtual ~UmundoInvoker(); diff --git a/src/uscxml/plugins/invoker/vxml/VoiceXMLInvoker.cpp b/src/uscxml/plugins/invoker/vxml/VoiceXMLInvoker.cpp index a18be8e..ddca2eb 100644 --- a/src/uscxml/plugins/invoker/vxml/VoiceXMLInvoker.cpp +++ b/src/uscxml/plugins/invoker/vxml/VoiceXMLInvoker.cpp @@ -61,7 +61,7 @@ void VoiceXMLInvoker::send(const SendRequest& req) { domSS << req.getFirstDOMElement(); start.content = domSS.str(); _interpreter->getDataModel().replaceExpressions(start.content); - + start.requestId = "asdf"; start.source = "asdf"; start.target = "umundo://mmi/jvoicexml"; diff --git a/src/uscxml/plugins/invoker/xhtml/XHTMLInvoker.cpp b/src/uscxml/plugins/invoker/xhtml/XHTMLInvoker.cpp index 4e2c01a..82e0a48 100644 --- a/src/uscxml/plugins/invoker/xhtml/XHTMLInvoker.cpp +++ b/src/uscxml/plugins/invoker/xhtml/XHTMLInvoker.cpp @@ -92,7 +92,7 @@ bool XHTMLInvoker::httpRecvRequest(const HTTPServer::Request& req) { } else if(_invokeReq.data) { ss << _invokeReq.data; content = ss.str(); - } else if (_invokeReq.content.length() > 0){ + } else if (_invokeReq.content.length() > 0) { content = _invokeReq.content; } else { URL templateURL("templates/xhtml-invoker.html"); @@ -100,10 +100,10 @@ bool XHTMLInvoker::httpRecvRequest(const HTTPServer::Request& req) { templateURL.download(true); content = templateURL.getInContent(); } - + _interpreter->getDataModel().replaceExpressions(content); reply.content = content; - + // application/xhtml+xml reply.headers["Content-Type"] = "text/html; charset=utf-8"; // reply.headers["Content-Type"] = "application/xhtml+xml; charset=utf-8"; @@ -140,7 +140,7 @@ void XHTMLInvoker::send(const SendRequest& req) { if (json) { reqCopy.data = json; } - + if (!_longPoll) { _outQueue.push_back(reqCopy); return; @@ -154,7 +154,7 @@ void XHTMLInvoker::reply(const SendRequest& req, const HTTPServer::Request& long // is there JSON in the content? std::string content = req.content; - + if (req.dom) { std::stringstream ss; Arabica::DOM::Node<std::string> content = req.dom.getDocumentElement(); |