diff options
Diffstat (limited to 'src/uscxml/plugins')
10 files changed, 86 insertions, 85 deletions
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp index 73a3744..64b61af 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp @@ -394,7 +394,7 @@ Data JSCDataModel::getValueAsData(const JSValueRef value) { if (JSValueIsObjectOfClass(_ctx, value, JSCArrayBuffer::getTmpl())) { // binary data JSCArrayBuffer::JSCArrayBufferPrivate* privObj = (JSCArrayBuffer::JSCArrayBufferPrivate*)JSObjectGetPrivate(objValue); - data.binary = privObj->nativeObj->_buffer; + data.binary = privObj->nativeObj->_blob; return data; } else if (JSValueIsObjectOfClass(_ctx, value, JSCNode::getTmpl())) { // dom node @@ -403,6 +403,7 @@ Data JSCDataModel::getValueAsData(const JSValueRef value) { return data; } std::set<std::string> propertySet; + JSPropertyNameArrayRef properties = JSObjectCopyPropertyNames(_ctx, objValue); size_t paramCount = JSPropertyNameArrayGetCount(properties); bool isArray = true; diff --git a/src/uscxml/plugins/datamodel/ecmascript/TypedArray.cpp b/src/uscxml/plugins/datamodel/ecmascript/TypedArray.cpp index 5b34181..913d2ce 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/TypedArray.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/TypedArray.cpp @@ -23,51 +23,51 @@ #define DATAVIEW_TYPED_GET(type) \ type retVal;\ -if (index + _start + sizeof(type) > _buffer->size)\ +if (index + _start + sizeof(type) > _blob._impl->size)\ return 0;\ -memcpy(&retVal, _buffer->data + (_start + index), sizeof(type)); +memcpy(&retVal, _blob._impl->data + (_start + index), sizeof(type)); #define DATAVIEW_TYPED_SET(type) \ -if (index + _start + sizeof(type) > _buffer->size)\ +if (index + _start + sizeof(type) > _blob._impl->size)\ return;\ -memcpy(_buffer->data + (_start + index), &value, sizeof(type)); +memcpy(_blob._impl->data + (_start + index), &value, sizeof(type)); namespace uscxml { ArrayBuffer::ArrayBuffer(unsigned long length) { - _buffer = boost::shared_ptr<Blob>(new Blob(length)); + _blob = Blob(length); } -ArrayBuffer::ArrayBuffer(boost::shared_ptr<Blob> buffer) : _buffer(buffer) { +ArrayBuffer::ArrayBuffer(const Blob& blob) : _blob(blob) { } ArrayBuffer::ArrayBuffer(void* data, unsigned int size) { - _buffer = boost::shared_ptr<Blob>(new Blob((const char*)data, size, "application/octet-stream")); + _blob = Blob((const char*)data, size, "application/octet-stream"); } unsigned long ArrayBuffer::getByteLength() { - if (!_buffer) + if (!_blob) return 0; - return _buffer->size; + return _blob._impl->size; } ArrayBuffer ArrayBuffer::slice(long begin, long end) { - if (!_buffer) { + if (!_blob) { return ArrayBuffer(0); } - unsigned int realBegin = (begin + _buffer->size) % _buffer->size; - unsigned int realEnd = (end + _buffer->size) % _buffer->size; + unsigned int realBegin = (begin + _blob._impl->size) % _blob._impl->size; + unsigned int realEnd = (end + _blob._impl->size) % _blob._impl->size; if (realEnd < realBegin) { return ArrayBuffer(0); } ArrayBuffer arrBuffer(realEnd - realBegin); - memcpy(arrBuffer._buffer->data, _buffer->data + realBegin, realEnd - realBegin); + memcpy(arrBuffer._blob._impl->data, _blob._impl->data + realBegin, realEnd - realBegin); return arrBuffer; } ArrayBuffer ArrayBuffer::slice(long begin) { - return slice(begin, _buffer->size); + return slice(begin, _blob._impl->size); } bool ArrayBuffer::isView(void*) { @@ -75,35 +75,35 @@ bool ArrayBuffer::isView(void*) { } ArrayBuffer::operator bool() { - return _buffer; + return _blob; } ArrayBuffer ArrayBufferView::getBuffer() { - return ArrayBuffer(_buffer); + return ArrayBuffer(_blob); } DataView::DataView(ArrayBuffer* buffer, unsigned long byteOffset, unsigned long byteLength) { _start = byteOffset; - if (_start > buffer->_buffer->size) + if (_start > buffer->_blob._impl->size) return; _end = _start + byteLength; - if (_end > buffer->_buffer->size) + if (_end > buffer->_blob._impl->size) return; - _buffer = buffer->_buffer; + _blob = buffer->_blob; } DataView::DataView(ArrayBuffer* buffer , unsigned long byteOffset) { _start = byteOffset; - _end = buffer->_buffer->size; - if (_start > buffer->_buffer->size) + _end = buffer->_blob._impl->size; + if (_start > buffer->_blob._impl->size) return; - _buffer = buffer->_buffer; + _blob = buffer->_blob; } DataView::DataView(ArrayBuffer* buffer) { _start = 0; - _end = (buffer->_buffer->size); - _buffer = buffer->_buffer; + _end = (buffer->_blob._impl->size); + _blob = buffer->_blob; } unsigned long DataView::getByteOffset() { diff --git a/src/uscxml/plugins/datamodel/ecmascript/TypedArray.h b/src/uscxml/plugins/datamodel/ecmascript/TypedArray.h index 205ef5a..7509390 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/TypedArray.h +++ b/src/uscxml/plugins/datamodel/ecmascript/TypedArray.h @@ -51,7 +51,7 @@ public: * be allocated an exception is raised. */ ArrayBuffer(unsigned long length); - ArrayBuffer(boost::shared_ptr<Blob>); + ArrayBuffer(const Blob&); /** * The length of the ArrayBuffer in bytes, as fixed at construction time. @@ -78,42 +78,42 @@ public: } operator bool(); bool operator== (const ArrayBuffer& other) { - return other._buffer == _buffer; + return other._blob == _blob; } // unsigned char get(unsigned long index) { // if (index >= getLength()) // return 0; // unsigned char retVal; -// memcpy(&retVal, _buffer->_data + index * sizeof(unsigned char), sizeof(unsigned char)); +// memcpy(&retVal, _blob->_data + index * sizeof(unsigned char), sizeof(unsigned char)); // return retVal; // } // // void set(unsigned long index, unsigned char value) { -// memcpy(_buffer->_data + index * sizeof(unsigned char), &value, sizeof(unsigned char)); +// memcpy(_blob->_data + index * sizeof(unsigned char), &value, sizeof(unsigned char)); // } // non-standard extension - std::string md5() { - return _buffer->md5(); + std::string md5() const { + return _blob.md5(); } // non-standard extension - std::string base64() { - return _buffer->base64(); + std::string base64() const { + return _blob.base64(); } - std::string getMimeType() { - if (_buffer) - return _buffer->mimeType; + std::string getMimeType() const { + if (_blob) + return _blob.getMimeType(); return ""; } void setMimeType(const std::string& mimeType) { - if (_buffer) - _buffer->mimeType = mimeType; + if (_blob) + _blob.setMimeType(mimeType); } - boost::shared_ptr<Blob> _buffer; + Blob _blob; }; class ArrayBufferView { @@ -139,7 +139,7 @@ public: virtual unsigned long getByteLength() = 0; virtual unsigned long getLength() = 0; protected: - boost::shared_ptr<Blob> _buffer; + Blob _blob; unsigned long _start; unsigned long _end; }; @@ -239,36 +239,36 @@ public: _start = byteOffset / sizeof(S); _end = _start + length; - if (_end > buffer->_buffer->size / sizeof(S)) + if (_end > buffer->_blob._impl->size / sizeof(S)) return; - _buffer = buffer->_buffer; + _blob = buffer->_blob; } TypedArray(uscxml::ArrayBuffer* buffer, unsigned long byteOffset) { if (byteOffset % sizeof(S)) return; _start = byteOffset / sizeof(S); - _end = buffer->_buffer->size / sizeof(S); - _buffer = buffer->_buffer; + _end = buffer->_blob._impl->size / sizeof(S); + _blob = buffer->_blob; } TypedArray(uscxml::ArrayBuffer* buffer) { _start = 0; - _end = (buffer->_buffer->size) / sizeof(S); - _buffer = buffer->_buffer; + _end = (buffer->_blob._impl->size) / sizeof(S); + _blob = buffer->_blob; } - TypedArray(boost::shared_ptr<Blob> buffer, unsigned long byteOffset, unsigned long length) { + TypedArray(Blob blob, unsigned long byteOffset, unsigned long length) { if (byteOffset % sizeof(S)) return; _start = byteOffset / sizeof(S); _end = _start + length; - if (_end > buffer->size / sizeof(S)) + if (_end > blob._impl->size / sizeof(S)) return; - _buffer = buffer; + _blob = blob; } /** @@ -281,7 +281,7 @@ public: TypedArray(unsigned long length) { _start = 0; _end = length; - _buffer = boost::shared_ptr<Blob>(new Blob(length * sizeof(S))); + _blob = Blob(length * sizeof(S)); } /** @@ -294,13 +294,13 @@ public: TypedArray(std::vector<T> data) { _start = 0; _end = data.size(); - _buffer = boost::shared_ptr<Blob>(new Blob(data.size() * sizeof(S))); + _blob = Blob(data.size() * sizeof(S)); set(data, 0); } TypedArray(TypedArray* other) { _start = other->_start; _end = other->_end; - _buffer = other->_buffer; + _blob = other->_blob; } /** @@ -311,7 +311,7 @@ public: if (index >= getLength()) return static_cast<T>(0); S retVal; - memcpy(&retVal, _buffer->data + (_start + index) * sizeof(S), sizeof(S)); + memcpy(&retVal, _blob._impl->data + (_start + index) * sizeof(S), sizeof(S)); return retVal; } @@ -320,7 +320,7 @@ public: * Sets the element at the given numeric index to the given value. */ void set(unsigned long index, T value) { - memcpy(_buffer->data + (_start + index) * sizeof(S), &value, sizeof(S)); + memcpy(_blob._impl->data + (_start + index) * sizeof(S), &value, sizeof(S)); } /** @@ -336,15 +336,15 @@ public: * current TypedArray, an exception is raised. */ void set(TypedArray<T, S>* value, unsigned long offset) { - if (!_buffer) + if (!_blob) return; - if (offset * sizeof(S) + value->getByteLength() > _buffer->size) + if (offset * sizeof(S) + value->getByteLength() > _blob._impl->size) return; unsigned long otherOffset = value->_start * sizeof(S); // will this work if we use the same buffer? - memcpy(_buffer->data + (_start + offset) * sizeof(S), value->_buffer->data + otherOffset, value->getByteLength()); + memcpy(_blob._impl->data + (_start + offset) * sizeof(S), value->_blob._impl->data + otherOffset, value->getByteLength()); } void set(TypedArray<T, S>* value) { @@ -364,13 +364,13 @@ public: * current TypedArray, an exception is raised. */ void set(std::vector<T> data, unsigned long offset) { - if (!_buffer) + if (!_blob) return; if (data.size() + offset > _end) return; if (sizeof(T) == sizeof(S)) { - memcpy(_buffer->data + offset, (void*)&data[0], data.size() * sizeof(S)); + memcpy(_blob._impl->data + offset, (void*)&data[0], data.size() * sizeof(S)); } else { S* buffer = (S*)malloc(data.size() * sizeof(S)); typename std::vector<T>::const_iterator dataIter = data.begin(); @@ -380,7 +380,7 @@ public: dataIter++; i++; } - memcpy(_buffer->data + offset, buffer, data.size() * sizeof(S)); + memcpy(_blob._impl->data + offset, buffer, data.size() * sizeof(S)); free (buffer); } } @@ -403,7 +403,7 @@ public: * method is invoked. */ TypedArray* subarray(long begin, long end) { - if (!_buffer) + if (!_blob) return NULL; unsigned int length = getLength(); unsigned int realBegin = (begin + length) % length; @@ -414,29 +414,29 @@ public: if (realEnd < realBegin) return NULL; - return new TypedArray<T, S>(_buffer, realBegin * sizeof(S), realEnd - realBegin); + return new TypedArray<T, S>(_blob, realBegin * sizeof(S), realEnd - realBegin); } TypedArray* subarray(long begin) { - if (!_buffer) + if (!_blob) return NULL; return subarray(begin, getLength()); } unsigned long getLength() { - if (!_buffer) + if (!_blob) return 0; return _end - _start; } unsigned long getByteLength() { - if (!_buffer) + if (!_blob) return 0; return (_end - _start) * sizeof(S); } unsigned long getByteOffset() { - if (!_buffer) + if (!_blob) return 0; return _start * sizeof(S); } diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp index 51a2167..f4bfabd 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp @@ -328,7 +328,7 @@ Data V8DataModel::getValueAsData(const v8::Handle<v8::Value>& value, std::set<v8 } else if (value->IsObject()) { if (V8ArrayBuffer::hasInstance(value)) { uscxml::V8ArrayBuffer::V8ArrayBufferPrivate* privObj = V8DOM::toClassPtr<V8ArrayBuffer::V8ArrayBufferPrivate >(value->ToObject()->GetInternalField(0)); - data.binary = privObj->nativeObj->_buffer; + data.binary = privObj->nativeObj->_blob; return data; } if (V8Node::hasInstance(value)) { diff --git a/src/uscxml/plugins/element/file/FileElement.cpp b/src/uscxml/plugins/element/file/FileElement.cpp index 606cddc..d5908ec 100644 --- a/src/uscxml/plugins/element/file/FileElement.cpp +++ b/src/uscxml/plugins/element/file/FileElement.cpp @@ -99,8 +99,8 @@ void FileElement::enterElement(const Arabica::DOM::Node<std::string>& node) { } else { Data data = _interpreter->getDataModel().getStringAsData(ATTR(node, "contentexpr")); if (data.binary) { - content = data.binary->data; - contentSize = data.binary->size; + content = data.binary.getData(); + contentSize = data.binary.getSize(); } else if (data.atom.length() > 0) { contentStr = data.atom; } diff --git a/src/uscxml/plugins/element/respond/RespondElement.cpp b/src/uscxml/plugins/element/respond/RespondElement.cpp index 06d89a7..6445249 100644 --- a/src/uscxml/plugins/element/respond/RespondElement.cpp +++ b/src/uscxml/plugins/element/respond/RespondElement.cpp @@ -89,8 +89,8 @@ void RespondElement::enterElement(const Arabica::DOM::Node<std::string>& node) { httpReply.content = contentData.atom; httpReply.headers["Content-Type"] = "text/plain"; } else if (contentData.binary) { - httpReply.content = std::string(contentData.binary->data, contentData.binary->size); - httpReply.headers["Content-Type"] = contentData.binary->mimeType; + httpReply.content = std::string(contentData.binary.getData(), contentData.binary.getSize()); + httpReply.headers["Content-Type"] = contentData.binary.getMimeType(); } else if (contentData.node) { std::stringstream ss; ss << contentData.node; diff --git a/src/uscxml/plugins/invoker/ffmpeg/FFMPEGInvoker.cpp b/src/uscxml/plugins/invoker/ffmpeg/FFMPEGInvoker.cpp index 4a0ec00..eda4ce8 100644 --- a/src/uscxml/plugins/invoker/ffmpeg/FFMPEGInvoker.cpp +++ b/src/uscxml/plugins/invoker/ffmpeg/FFMPEGInvoker.cpp @@ -373,7 +373,7 @@ void FFMPEGInvoker::openVideo(EncodingContext* ctx, AVFormatContext *oc, AVCodec *((AVPicture *)ctx->frame) = ctx->dst_picture; } -void FFMPEGInvoker::writeVideoFrame(EncodingContext* ctx, AVFormatContext *oc, AVStream *st, boost::shared_ptr<Blob> image) { +void FFMPEGInvoker::writeVideoFrame(EncodingContext* ctx, AVFormatContext *oc, AVStream *st, Blob image) { int ret; AVCodecContext *c = st->codec; @@ -392,14 +392,14 @@ void FFMPEGInvoker::writeVideoFrame(EncodingContext* ctx, AVFormatContext *oc, A } uint32_t headerOffset = 0; - headerOffset += image->data[10] << 0; - headerOffset += image->data[11] << 8; - headerOffset += image->data[12] << 16; - headerOffset += image->data[13] << 24; + headerOffset += image._impl->data[10] << 0; + headerOffset += image._impl->data[11] << 8; + headerOffset += image._impl->data[12] << 16; + headerOffset += image._impl->data[13] << 24; // std::cout << headerOffset + (c->width * c->height) << " / " << image->_size << std::endl; - ret = avpicture_fill(&ctx->src_picture, (uint8_t*)(image->data + headerOffset), BMP_FORMAT, c->width, c->height); + ret = avpicture_fill(&ctx->src_picture, (uint8_t*)(image._impl->data + headerOffset), BMP_FORMAT, c->width, c->height); if (ret < 0) { fprintf(stderr, "Could not fill image from given bitmap\n"); @@ -408,7 +408,7 @@ void FFMPEGInvoker::writeVideoFrame(EncodingContext* ctx, AVFormatContext *oc, A (const uint8_t * const *)ctx->src_picture.data, ctx->src_picture.linesize, 0, c->height, ctx->dst_picture.data, ctx->dst_picture.linesize); } else { - avpicture_fill(&ctx->dst_picture, (uint8_t*)image->data, c->pix_fmt, c->width, c->height); + avpicture_fill(&ctx->dst_picture, (uint8_t*)image._impl->data, c->pix_fmt, c->width, c->height); } if (oc->oformat->flags & AVFMT_RAWPICTURE) { diff --git a/src/uscxml/plugins/invoker/ffmpeg/FFMPEGInvoker.h b/src/uscxml/plugins/invoker/ffmpeg/FFMPEGInvoker.h index 964681b..81589bb 100644 --- a/src/uscxml/plugins/invoker/ffmpeg/FFMPEGInvoker.h +++ b/src/uscxml/plugins/invoker/ffmpeg/FFMPEGInvoker.h @@ -92,7 +92,7 @@ protected: AVStream* addStream(EncodingContext* ctx, AVFormatContext *oc, AVCodec **codec, enum AVCodecID codec_id); void openVideo(EncodingContext* ctx, AVFormatContext *oc, AVCodec *codec, AVStream *st); - void writeVideoFrame(EncodingContext* ctx, AVFormatContext *oc, AVStream *st, boost::shared_ptr<Blob> image); + void writeVideoFrame(EncodingContext* ctx, AVFormatContext *oc, AVStream *st, Blob image); void closeVideo(EncodingContext* ctx, AVFormatContext *oc, AVStream *st); static void run(void*); diff --git a/src/uscxml/plugins/invoker/smtp/SMTPInvoker.cpp b/src/uscxml/plugins/invoker/smtp/SMTPInvoker.cpp index 2a974ab..90b777c 100644 --- a/src/uscxml/plugins/invoker/smtp/SMTPInvoker.cpp +++ b/src/uscxml/plugins/invoker/smtp/SMTPInvoker.cpp @@ -101,8 +101,8 @@ void SMTPInvoker::getAttachments(std::list<Data> list, std::list<Data>& attachme Data att = data; if (!att.hasKey("mimetype")) { - if (att["data"].binary && att["data"].binary->mimeType.size() > 0) { - att.compound["mimetype"] = Data(att["data"].binary->mimeType, Data::VERBATIM); + if (att["data"].binary && att["data"].binary.getMimeType().size() > 0) { + att.compound["mimetype"] = Data(att["data"].binary.getMimeType(), Data::VERBATIM); } else { att.compound["mimetype"] = Data("text/plain", Data::VERBATIM); } @@ -127,8 +127,8 @@ void SMTPInvoker::getAttachments(std::list<Data> list, std::list<Data>& attachme att.compound["data"].binary = data.binary; - if (data.binary->mimeType.size() > 0) { - att.compound["mimetype"] = Data(attachments.back()["data"].binary->mimeType, Data::VERBATIM); + if (data.binary.getMimeType().size() > 0) { + att.compound["mimetype"] = Data(attachments.back()["data"].binary.getMimeType(), Data::VERBATIM); } else { att.compound["mimetype"] = Data("application/octet-stream", Data::VERBATIM); } @@ -271,7 +271,7 @@ void SMTPInvoker::send(const SendRequest& req) { if (attIter->compound["data"].binary) { contentSS << "Content-Transfer-Encoding: base64"; contentSS << "\n\n"; - contentSS << attIter->compound["data"].binary->base64(); + contentSS << attIter->compound["data"].binary.base64(); } else { contentSS << "Content-Transfer-Encoding: 7Bit"; contentSS << "\n\n"; diff --git a/src/uscxml/plugins/ioprocessor/basichttp/BasicHTTPIOProcessor.cpp b/src/uscxml/plugins/ioprocessor/basichttp/BasicHTTPIOProcessor.cpp index bd62467..845e142 100644 --- a/src/uscxml/plugins/ioprocessor/basichttp/BasicHTTPIOProcessor.cpp +++ b/src/uscxml/plugins/ioprocessor/basichttp/BasicHTTPIOProcessor.cpp @@ -247,7 +247,7 @@ void BasicHTTPIOProcessor::send(const SendRequest& req) { xmlStream << req.data.node; valueCStr = evhttp_encode_uri(xmlStream.str().c_str()); } else if(req.data.binary) { - valueCStr = evhttp_encode_uri(req.data.binary->base64().c_str()); + valueCStr = evhttp_encode_uri(req.data.binary.base64().c_str()); } if (valueCStr != NULL) { kvps << kvpSeperator << keyCStr << "=" << valueCStr; |