diff options
author | Stefan Radomski <github@mintwerk.de> | 2017-01-23 22:31:54 (GMT) |
---|---|---|
committer | Stefan Radomski <github@mintwerk.de> | 2017-01-23 22:31:54 (GMT) |
commit | 24ac6c39a89f5b94ede80b745f68ea5f0b762640 (patch) | |
tree | 2a32c53a43caab1358cf9b66ff3bb0819c3d1b60 /src/uscxml/plugins/datamodel/ecmascript | |
parent | b8a20c656537e4be748c3485d2c9541bd51e2b3d (diff) | |
download | uscxml-24ac6c39a89f5b94ede80b745f68ea5f0b762640.zip uscxml-24ac6c39a89f5b94ede80b745f68ea5f0b762640.tar.gz uscxml-24ac6c39a89f5b94ede80b745f68ea5f0b762640.tar.bz2 |
Made GCC/CLang pedantic and fixed warnings
Diffstat (limited to 'src/uscxml/plugins/datamodel/ecmascript')
-rw-r--r-- | src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp index bcde9c9..5ce6128 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp @@ -28,6 +28,8 @@ #include "uscxml/util/DOM.h" #include "uscxml/interpreter/Logging.h" +#include <vector> +#include <string> #include <boost/algorithm/string.hpp> #define EVENT_STRING_OR_UNDEF(field, cond) \ @@ -451,14 +453,15 @@ JSValueRef JSCDataModel::getDataAsValue(const Data& data) { return value; } if (data.array.size() > 0) { - JSValueRef elements[data.array.size()]; + std::vector<JSValueRef> elements(data.array.size()); +// JSValueRef elements[data.array.size()]; std::list<Data>::const_iterator arrayIter = data.array.begin(); uint32_t index = 0; while(arrayIter != data.array.end()) { elements[index++] = getDataAsValue(*arrayIter); arrayIter++; } - JSObjectRef value = JSObjectMakeArray(_ctx, data.array.size(), elements, &exception); + JSObjectRef value = JSObjectMakeArray(_ctx, data.array.size(), &elements[0], &exception); if (exception) handleException(exception); return value; @@ -736,8 +739,10 @@ void JSCDataModel::init(const std::string& location, const Data& data, const std void JSCDataModel::handleException(JSValueRef exception) { JSStringRef exceptionStringRef = JSValueToStringCopy(_ctx, exception, NULL); size_t maxSize = JSStringGetMaximumUTF8CStringSize(exceptionStringRef); - char buffer[maxSize]; - JSStringGetUTF8CString(exceptionStringRef, buffer, maxSize); +// char buffer[maxSize]; + std::string buffer; + buffer.resize(maxSize); + JSStringGetUTF8CString(exceptionStringRef, &buffer[0], maxSize); JSStringRelease(exceptionStringRef); std::string exceptionMsg(buffer); @@ -799,8 +804,10 @@ bool JSCDataModel::jsIOProcessorHasProp(JSContextRef ctx, JSObjectRef object, JS std::map<std::string, IOProcessor> ioProcessors = INSTANCE->_callbacks->getIOProcessors(); size_t maxSize = JSStringGetMaximumUTF8CStringSize(propertyName); - char buffer[maxSize]; - JSStringGetUTF8CString(propertyName, buffer, maxSize); +// char buffer[maxSize]; + std::string buffer; + buffer.resize(maxSize); + JSStringGetUTF8CString(propertyName, &buffer[0], maxSize); std::string prop(buffer); return ioProcessors.find(prop) != ioProcessors.end(); @@ -811,8 +818,10 @@ JSValueRef JSCDataModel::jsIOProcessorGetProp(JSContextRef ctx, JSObjectRef obje std::map<std::string, IOProcessor> ioProcessors = INSTANCE->_callbacks->getIOProcessors(); size_t maxSize = JSStringGetMaximumUTF8CStringSize(propertyName); - char buffer[maxSize]; - JSStringGetUTF8CString(propertyName, buffer, maxSize); +// char buffer[maxSize]; + std::string buffer; + buffer.resize(maxSize); + JSStringGetUTF8CString(propertyName, &buffer[0], maxSize); std::string prop(buffer); if (ioProcessors.find(prop) != ioProcessors.end()) { @@ -839,8 +848,10 @@ bool JSCDataModel::jsInvokerHasProp(JSContextRef ctx, JSObjectRef object, JSStri std::map<std::string, Invoker> invokers = INSTANCE->_callbacks->getInvokers(); size_t maxSize = JSStringGetMaximumUTF8CStringSize(propertyName); - char buffer[maxSize]; - JSStringGetUTF8CString(propertyName, buffer, maxSize); +// char buffer[maxSize]; + std::string buffer; + buffer.resize(maxSize); + JSStringGetUTF8CString(propertyName, &buffer[0], maxSize); std::string prop(buffer); return invokers.find(prop) != invokers.end(); @@ -851,8 +862,10 @@ JSValueRef JSCDataModel::jsInvokerGetProp(JSContextRef ctx, JSObjectRef object, std::map<std::string, Invoker> invokers = INSTANCE->_callbacks->getInvokers(); size_t maxSize = JSStringGetMaximumUTF8CStringSize(propertyName); - char buffer[maxSize]; - JSStringGetUTF8CString(propertyName, buffer, maxSize); +// char buffer[maxSize]; + std::string buffer; + buffer.resize(maxSize); + JSStringGetUTF8CString(propertyName, &buffer[0], maxSize); std::string prop(buffer); if (invokers.find(prop) != invokers.end()) { |