diff options
author | Benoit Foucher <benoit@zeroc.com> | 2016-02-05 16:25:26 +0100 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2016-02-05 16:25:26 +0100 |
commit | 3cfb37df79a86ff279bee8e57bbe8105ec7edd5e (patch) | |
tree | de6e4384041940a162d2bf6711359186bc4240dd /cpp/src | |
parent | Fix for java8 compilation failure (diff) | |
download | ice-3cfb37df79a86ff279bee8e57bbe8105ec7edd5e.tar.bz2 ice-3cfb37df79a86ff279bee8e57bbe8105ec7edd5e.tar.xz ice-3cfb37df79a86ff279bee8e57bbe8105ec7edd5e.zip |
Updated Objective-C mapping to use new stream classes
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/Buffer.cpp | 10 | ||||
-rw-r--r-- | cpp/src/Ice/CollocatedRequestHandler.cpp | 7 | ||||
-rw-r--r-- | cpp/src/Ice/InputStream.cpp | 19 | ||||
-rw-r--r-- | cpp/src/Ice/OutputStream.cpp | 24 |
4 files changed, 20 insertions, 40 deletions
diff --git a/cpp/src/Ice/Buffer.cpp b/cpp/src/Ice/Buffer.cpp index b906c99ae74..382f852501f 100644 --- a/cpp/src/Ice/Buffer.cpp +++ b/cpp/src/Ice/Buffer.cpp @@ -87,10 +87,7 @@ IceInternal::Buffer::Container::~Container() void IceInternal::Buffer::Container::swap(Container& other) { - assert(!_buf || _capacity > 0); - std::swap(_buf, other._buf); - std::swap(_size, other._size); std::swap(_capacity, other._capacity); std::swap(_shrinkCounter, other._shrinkCounter); @@ -99,9 +96,10 @@ IceInternal::Buffer::Container::swap(Container& other) void IceInternal::Buffer::Container::clear() { - assert(!_buf || _capacity > 0); - - free(_buf); + if(_buf && _capacity > 0) + { + free(_buf); + } _buf = 0; _size = 0; _capacity = 0; diff --git a/cpp/src/Ice/CollocatedRequestHandler.cpp b/cpp/src/Ice/CollocatedRequestHandler.cpp index 4fbf0d0bc7b..377717018f6 100644 --- a/cpp/src/Ice/CollocatedRequestHandler.cpp +++ b/cpp/src/Ice/CollocatedRequestHandler.cpp @@ -335,8 +335,7 @@ CollocatedRequestHandler::sendResponse(Int requestId, OutputStream* os, Byte, bo } InputStream is(os->instance(), os->getEncoding(), *os, true); // Adopting the OutputStream's buffer. - - is.i = is.b.begin() + sizeof(replyHdr) + 4; + is.pos(sizeof(replyHdr) + 4); if(_traceLevels->protocol >= 1) { @@ -469,11 +468,11 @@ CollocatedRequestHandler::invokeAll(OutputStream* os, Int requestId, Int batchRe if(batchRequestNum > 0) { - is.i = is.b.begin() + sizeof(requestBatchHdr); + is.pos(sizeof(requestBatchHdr)); } else { - is.i = is.b.begin() + sizeof(requestHdr); + is.pos(sizeof(requestHdr)); } int invokeNum = batchRequestNum > 0 ? batchRequestNum : 1; diff --git a/cpp/src/Ice/InputStream.cpp b/cpp/src/Ice/InputStream.cpp index b89ce6e0177..5c73c51d6f1 100644 --- a/cpp/src/Ice/InputStream.cpp +++ b/cpp/src/Ice/InputStream.cpp @@ -179,12 +179,6 @@ Ice::InputStream::initialize(const EncodingVersion& encoding) _sliceObjects = true; _startSeq = -1; _minSeqSize = 0; - - // - // Initialize the encoding members of our pre-allocated encapsulation, in case - // this stream is used without an explicit encapsulation. - // - _preAllocatedEncaps.encoding = encoding; } void @@ -267,20 +261,15 @@ Ice::InputStream::setClosure(void* p) void Ice::InputStream::swap(InputStream& other) { - assert(_instance == other._instance); - swapBuffer(other); + std::swap(_instance, other._instance); std::swap(_encoding, other._encoding); - #ifndef ICE_CPP11_MAPPING std::swap(_collectObjects, other._collectObjects); #endif - std::swap(_traceSlicing, other._traceSlicing); - std::swap(_closure, other._closure); - std::swap(_sliceObjects, other._sliceObjects); // @@ -1278,6 +1267,10 @@ Ice::InputStream::skipOpt(OptionalFormat type) { Int sz; read(sz); + if(sz < 0) + { + throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); + } skip(sz); break; } @@ -1321,7 +1314,6 @@ Ice::InputStream::skipOpts() void Ice::InputStream::throwUnmarshalOutOfBoundsException(const char* file, int line) { - assert(false); throw UnmarshalOutOfBoundsException(file, line); } @@ -1487,6 +1479,7 @@ Ice::InputStream::initEncaps() if(!_currentEncaps) // Lazy initialization. { _currentEncaps = &_preAllocatedEncaps; + _currentEncaps->encoding = _encoding; _currentEncaps->sz = static_cast<Ice::Int>(b.size()); } diff --git a/cpp/src/Ice/OutputStream.cpp b/cpp/src/Ice/OutputStream.cpp index 1f784ad3675..318f411cc4a 100644 --- a/cpp/src/Ice/OutputStream.cpp +++ b/cpp/src/Ice/OutputStream.cpp @@ -79,11 +79,6 @@ Ice::OutputStream::OutputStream() : _format(CompactFormat), _currentEncaps(0) { - // - // Initialize the encoding member of our pre-allocated encapsulation, in case - // this stream is used without an explicit encapsulation. - // - _preAllocatedEncaps.encoding = _encoding; } Ice::OutputStream::OutputStream(const CommunicatorPtr& communicator) : @@ -111,16 +106,15 @@ void Ice::OutputStream::initialize(const CommunicatorPtr& communicator) { assert(communicator); - InstancePtr instance = getInstance(communicator); - initialize(instance.get(), instance->defaultsAndOverrides()->defaultEncoding); + Instance* instance = getInstance(communicator).get(); + initialize(instance, instance->defaultsAndOverrides()->defaultEncoding); } void Ice::OutputStream::initialize(const CommunicatorPtr& communicator, const EncodingVersion& encoding) { assert(communicator); - InstancePtr instance = getInstance(communicator); - initialize(instance.get(), encoding); + initialize(getInstance(communicator).get(), encoding); } void @@ -135,12 +129,6 @@ Ice::OutputStream::initialize(Instance* instance, const EncodingVersion& encodin _wstringConverter = _instance->getWstringConverter(); _format = _instance->defaultsAndOverrides()->defaultFormat; - - // - // Initialize the encoding member of our pre-allocated encapsulation, in case - // this stream is used without an explicit encapsulation. - // - _preAllocatedEncaps.encoding = encoding; } void @@ -184,11 +172,12 @@ Ice::OutputStream::setClosure(void* p) void Ice::OutputStream::swap(OutputStream& other) { - assert(_instance == other._instance); - swapBuffer(other); + std::swap(_instance, other._instance); std::swap(_closure, other._closure); + std::swap(_encoding, other._encoding); + std::swap(_format, other._format); // // Swap is never called for streams that have encapsulations being written. However, @@ -877,6 +866,7 @@ Ice::OutputStream::initEncaps() { _currentEncaps = &_preAllocatedEncaps; _currentEncaps->start = b.size(); + _currentEncaps->encoding = _encoding; } if(_currentEncaps->format == Ice::DefaultFormat) |