diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-07-06 16:04:18 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-07-06 16:04:18 (GMT) |
commit | 9cc762d85afffea42de3e1d156a6b8838d88a00c (patch) | |
tree | bff170c0493759c7f1bffca2648960b6f43ca139 /src | |
parent | be98a8297b4e10e169290f497e649e803e43d791 (diff) | |
download | uscxml-9cc762d85afffea42de3e1d156a6b8838d88a00c.zip uscxml-9cc762d85afffea42de3e1d156a6b8838d88a00c.tar.gz uscxml-9cc762d85afffea42de3e1d156a6b8838d88a00c.tar.bz2 |
Made Blob into Pimpl to better support language bindings
Diffstat (limited to 'src')
18 files changed, 205 insertions, 119 deletions
diff --git a/src/bindings/swig/csharp/uscxml.i b/src/bindings/swig/csharp/uscxml.i index bd8c669..7625c8d 100644 --- a/src/bindings/swig/csharp/uscxml.i +++ b/src/bindings/swig/csharp/uscxml.i @@ -13,6 +13,7 @@ %include <boost_shared_ptr.i> // these are needed at least for the templates to work +typedef uscxml::Blob Blob; typedef uscxml::Data Data; typedef uscxml::Event Event; typedef uscxml::InvokeRequest InvokeRequest; @@ -161,11 +162,16 @@ WRAP_TO_STRING(uscxml::InvokeRequest); // byte[] signature for Blob get/setData // see http://permalink.gmane.org/gmane.comp.programming.swig/5804 +%csmethodmodifiers uscxml::Blob::setData(const char* data, size_t length) "private"; +%csmethodmodifiers uscxml::Blob::setMimeType(const std::string& mimeType) "private"; %csmethodmodifiers uscxml::Blob::Blob(const char* data, size_t size, const std::string& mimeType) "private"; +%csmethodmodifiers uscxml::Blob::Blob(const char* data, size_t size) "private"; + %typemap(cscode) uscxml::Blob %{ - public Blob(byte[] data, string mimeType) : this(uscxmlNativeCSharpPINVOKE.new_Blob(data, (uint)data.Length, mimeType), true) { + public Blob(byte[] data, string mimeType) : this(uscxmlNativeCSharpPINVOKE.new_Blob__SWIG_2(data, (uint)data.Length, mimeType), true) { if (uscxmlNativeCSharpPINVOKE.SWIGPendingException.Pending) throw uscxmlNativeCSharpPINVOKE.SWIGPendingException.Retrieve(); } + %} %typemap(imtype, out="System.IntPtr") const char *data "byte[]" @@ -251,6 +257,10 @@ using System.Runtime.InteropServices; %} %typemap(cscode) uscxml::Data %{ + public Data(byte[] data, String mimeType) : this() { + setBinary(new Blob(data, mimeType)); + } + public Data(List<Data> arr) : this() { setArray(arr); } diff --git a/src/bindings/swig/java/uscxml.i b/src/bindings/swig/java/uscxml.i index 9610e77..654ea91 100644 --- a/src/bindings/swig/java/uscxml.i +++ b/src/bindings/swig/java/uscxml.i @@ -13,6 +13,7 @@ %include <boost_shared_ptr.i> // these are needed at least for the templates to work +typedef uscxml::Blob Blob; typedef uscxml::Data Data; typedef uscxml::Event Event; typedef uscxml::InvokeRequest InvokeRequest; @@ -184,7 +185,6 @@ BEAUTIFY_NATIVE(uscxml::InvokeRequest, InvokeRequest, InvokeRequestNative); JCALL4(SetByteArrayRegion, jenv, $result, 0, ((uscxml::Blob const *)arg1)->getSize(), (jbyte *)$1); } - //*********************************************** // Beautify important classes //*********************************************** @@ -254,7 +254,8 @@ import java.util.LinkedList; %typemap(javacode) uscxml::Data %{ public Data(byte[] data, String mimeType) { - + this(uscxmlNativeJavaJNI.new_Data__SWIG_0(), true); + setBinary(new Blob(data, mimeType)); } public Data(Map<String, Data> compound) { diff --git a/src/bindings/swig/uscxml_ignores.i b/src/bindings/swig/uscxml_ignores.i index 5e99416..9a0dbe4 100644 --- a/src/bindings/swig/uscxml_ignores.i +++ b/src/bindings/swig/uscxml_ignores.i @@ -1,6 +1,7 @@ %ignore uscxml::NumAttr; %ignore uscxml::SCXMLParser; %ignore uscxml::InterpreterImpl; +%ignore uscxml::BlobImpl; #if 0 %ignore uscxml::EventHandlerImpl; #endif @@ -196,6 +197,7 @@ %ignore uscxml::Blob::Blob(size_t size); %ignore uscxml::Blob::Blob(const char* data, size_t size, const std::string& mimeType, bool adopt); +%ignore uscxml::Blob::Blob(const boost::shared_ptr<BlobImpl>); %ignore operator!=; diff --git a/src/uscxml/messages/Blob.cpp b/src/uscxml/messages/Blob.cpp index 2e68e98..b8a263e 100644 --- a/src/uscxml/messages/Blob.cpp +++ b/src/uscxml/messages/Blob.cpp @@ -24,27 +24,27 @@ namespace uscxml { -Blob::~Blob() { +BlobImpl::~BlobImpl() { free(data); } -std::string Blob::md5() { +std::string BlobImpl::md5() const { return uscxml::md5(data, size); } -Blob* Blob::fromBase64(const std::string base64) { +BlobImpl* BlobImpl::fromBase64(const std::string base64, const std::string& mimeType) { std::string decoded = base64Decode(base64); - return new Blob(decoded.c_str(), decoded.length(), mimeType); + return new BlobImpl(decoded.c_str(), decoded.length(), mimeType); } -Blob::Blob(size_t _size) { +BlobImpl::BlobImpl(size_t _size) { data = (char*)malloc(_size); memset(data, 0, _size); size = _size; mimeType = "application/octet-stream"; } -Blob::Blob(const char* _data, size_t _size, const std::string& _mimeType, bool adopt) { +BlobImpl::BlobImpl(const char* _data, size_t _size, const std::string& _mimeType, bool adopt) { if (adopt) { data = (char*)_data; } else { @@ -54,8 +54,8 @@ Blob::Blob(const char* _data, size_t _size, const std::string& _mimeType, bool a mimeType = _mimeType; size = _size; } - -std::string Blob::base64() { + +std::string BlobImpl::base64() const { return base64Encode((char* const)data, size); } diff --git a/src/uscxml/messages/Blob.h b/src/uscxml/messages/Blob.h index b805da1..0c20f95 100644 --- a/src/uscxml/messages/Blob.h +++ b/src/uscxml/messages/Blob.h @@ -21,33 +21,38 @@ #define BLOB_H_E1B6D2C3 #include <string> +#include <boost/shared_ptr.hpp> #include "uscxml/Common.h" namespace uscxml { -class USCXML_API Blob { +class USCXML_API BlobImpl { public: - ~Blob(); - Blob(size_t size); - Blob(const char* data, size_t size, const std::string& mimeType, bool adopt = false); - - std::string base64(); - std::string md5(); - Blob* fromBase64(const std::string base64); - + BlobImpl(size_t size); + BlobImpl(const char* data, size_t size, const std::string& mimeType, bool adopt = false); + virtual ~BlobImpl(); + + std::string base64() const; + std::string md5() const; + static BlobImpl* fromBase64(const std::string base64, const std::string& mimeType); + char* getData() const { return data; } - + size_t getSize() const { return size; } - + std::string getMimeType() const { return mimeType; } - + + void setMimeType(const std::string& mimeType) { + this->mimeType = mimeType; + } + #ifdef SWIGIMPORTED protected: #endif @@ -55,7 +60,71 @@ protected: char* data; size_t size; std::string mimeType; +}; + +class USCXML_API Blob { +public: + + Blob() : _impl() {} + Blob(const boost::shared_ptr<BlobImpl> impl) : _impl(impl) { } + Blob(const Blob& other) : _impl(other._impl) { } + Blob(size_t size) : _impl(boost::shared_ptr<BlobImpl>(new BlobImpl(size))) {} + Blob(const char* data, + size_t size, + const std::string& mimeType = "application/octet-stream", + bool adopt = false) : + _impl(boost::shared_ptr<BlobImpl>(new BlobImpl(data, size, mimeType, adopt))) {} + virtual ~Blob() {}; + + operator bool() const { + return _impl; + } + bool operator< (const Blob& other) const { + return _impl < other._impl; + } + bool operator==(const Blob& other) const { + return _impl == other._impl; + } + bool operator!=(const Blob& other) const { + return _impl != other._impl; + } + Blob& operator= (const Blob& other) { + _impl = other._impl; + return *this; + } + static Blob fromBase64(const std::string base64, const std::string& mimeType = "application/octet-stream") { + return Blob(boost::shared_ptr<BlobImpl>(BlobImpl::fromBase64(base64, mimeType))); + } + + std::string base64() const { + return _impl->base64(); + } + + std::string md5() const { + return _impl->md5(); + } + + char* getData() const { + return _impl->getData(); + } + + size_t getSize() const { + return _impl->getSize(); + } + + std::string getMimeType() const { + return _impl->getMimeType(); + } + + void setMimeType(const std::string& mimeType) { + _impl->setMimeType(mimeType); + } + +#ifdef SWIGIMPORTED +protected: +#endif + boost::shared_ptr<BlobImpl> _impl; }; diff --git a/src/uscxml/messages/Data.cpp b/src/uscxml/messages/Data.cpp index 1ee946a..911730a 100644 --- a/src/uscxml/messages/Data.cpp +++ b/src/uscxml/messages/Data.cpp @@ -35,9 +35,7 @@ extern "C" { namespace uscxml { -Data::Data(const char* data, size_t size, const std::string& mimeType, bool adopt) { - binary = boost::shared_ptr<Blob>(new Blob(data, size, mimeType, adopt)); -} +Data::Data(const char* data, size_t size, const std::string& mimeType, bool adopt) : binary(data, size, mimeType, adopt) {} void Data::merge(const Data& other) { if (other.compound.size() > 0) { diff --git a/src/uscxml/messages/Data.h b/src/uscxml/messages/Data.h index 44ce1d7..11b46fb 100644 --- a/src/uscxml/messages/Data.h +++ b/src/uscxml/messages/Data.h @@ -27,12 +27,11 @@ #include "uscxml/Common.h" #include "uscxml/Convenience.h" +#include "uscxml/messages/Blob.h" #include <DOM/Document.hpp> namespace uscxml { -class Blob; - static int _dataIndentation = 1; class USCXML_API Data { @@ -220,6 +219,13 @@ public: this->atom = atom; } + Blob getBinary() { + return this->binary; + } + void setBinary(const Blob& binary) { + this->binary = binary; + } + Type getType() { return type; } @@ -227,7 +233,6 @@ public: this->type = type; } - #ifdef SWIGIMPORTED protected: #endif @@ -236,7 +241,7 @@ protected: std::map<std::string, Data> compound; std::list<Data> array; std::string atom; - boost::shared_ptr<Blob> binary; + Blob binary; Type type; protected: 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; diff --git a/src/uscxml/server/InterpreterServlet.cpp b/src/uscxml/server/InterpreterServlet.cpp index f90d111..285add9 100644 --- a/src/uscxml/server/InterpreterServlet.cpp +++ b/src/uscxml/server/InterpreterServlet.cpp @@ -163,8 +163,8 @@ void InterpreterWebSocketServlet::send(const SendRequest& req) { } else if (req.data.binary) { HTTPServer::wsSend(_requests[req.target], EVWS_BINARY_FRAME, - req.data.binary->data, - req.data.binary->size); + req.data.binary.getData(), + req.data.binary.getSize()); } else if (req.data.node) { std::stringstream ssXML; ssXML << req.data.node; @@ -188,8 +188,8 @@ void InterpreterWebSocketServlet::send(const SendRequest& req) { } else if (req.data.binary) { HTTPServer::wsBroadcast(req.target.c_str(), EVWS_BINARY_FRAME, - req.data.binary->data, - req.data.binary->size); + req.data.binary.getData(), + req.data.binary.getSize()); } else if (req.data.node) { std::stringstream ssXML; ssXML << req.data.node; |