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 | |
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')
-rw-r--r-- | cpp/include/Ice/Buffer.h | 6 | ||||
-rw-r--r-- | cpp/include/Ice/Exception.h | 3 | ||||
-rw-r--r-- | cpp/include/Ice/InputStream.h | 5 | ||||
-rw-r--r-- | cpp/include/Ice/OutputStream.h | 3 | ||||
-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 |
8 files changed, 30 insertions, 47 deletions
diff --git a/cpp/include/Ice/Buffer.h b/cpp/include/Ice/Buffer.h index 56966089c06..95f599bb467 100644 --- a/cpp/include/Ice/Buffer.h +++ b/cpp/include/Ice/Buffer.h @@ -81,7 +81,7 @@ public: } void swap(Container&); - + void clear(); void resize(size_type n) // Inlined for performance reasons. @@ -98,7 +98,7 @@ public: } _size = n; } - + void reset() { assert(!_buf || _capacity > 0); @@ -141,7 +141,7 @@ public: assert(n < _size); return _buf[n]; } - + private: Container(const Container&); diff --git a/cpp/include/Ice/Exception.h b/cpp/include/Ice/Exception.h index c4477bb8000..003d1947cdc 100644 --- a/cpp/include/Ice/Exception.h +++ b/cpp/include/Ice/Exception.h @@ -47,7 +47,7 @@ public: virtual ~LocalException() ICE_NOEXCEPT; virtual std::string ice_id() const = 0; -#ifndef ICE_CPP11_MAPPING +#ifndef ICE_CPP11_MAPPING virtual LocalException* ice_clone() const = 0; #endif virtual void ice_throw() const = 0; @@ -57,7 +57,6 @@ class ICE_API UserException : public IceUtil::Exception { public: - virtual std::string ice_id() const = 0; #ifndef ICE_CPP11_MAPPING virtual UserException* ice_clone() const = 0; diff --git a/cpp/include/Ice/InputStream.h b/cpp/include/Ice/InputStream.h index b903f955b82..070d43e57a8 100644 --- a/cpp/include/Ice/InputStream.h +++ b/cpp/include/Ice/InputStream.h @@ -633,6 +633,11 @@ public: return i - b.begin(); } + void pos(size_type p) + { + i = b.begin() + p; + } + InputStream(IceInternal::Instance*, const EncodingVersion&); InputStream(IceInternal::Instance*, const EncodingVersion&, IceInternal::Buffer&, bool = false); diff --git a/cpp/include/Ice/OutputStream.h b/cpp/include/Ice/OutputStream.h index 5ba33bad8cc..0f0138e78f2 100644 --- a/cpp/include/Ice/OutputStream.h +++ b/cpp/include/Ice/OutputStream.h @@ -92,7 +92,6 @@ public: void resize(Container::size_type sz) { b.resize(sz); - i = b.end(); } void startObject(const SlicedDataPtr& data) @@ -468,7 +467,7 @@ public: size_type pos() { - return i - b.begin(); + return b.size(); } void rewrite(Int value, size_type p) 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) |