summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2014-07-17 12:36:00 -0230
committerDwayne Boone <dwayne@zeroc.com>2014-07-17 12:36:00 -0230
commit93fdab6fa782511ef569acb17352853646aa66b5 (patch)
tree1e73a243303f1d9564499f0b7a036b4484cc1671 /cpp
parentC# transceiver fixes (diff)
downloadice-93fdab6fa782511ef569acb17352853646aa66b5.tar.bz2
ice-93fdab6fa782511ef569acb17352853646aa66b5.tar.xz
ice-93fdab6fa782511ef569acb17352853646aa66b5.zip
ICE-5481 startSize/endSize methods aren't designed to be "reentrant"
Diffstat (limited to 'cpp')
-rw-r--r--cpp/include/Ice/BasicStream.h62
-rw-r--r--cpp/include/Ice/Stream.h20
-rw-r--r--cpp/include/Ice/StreamHelpers.h125
-rw-r--r--cpp/src/Ice/BasicStream.cpp112
-rw-r--r--cpp/src/Ice/StreamI.cpp20
-rw-r--r--cpp/src/Ice/StreamI.h10
-rw-r--r--cpp/src/Slice/CsUtil.cpp30
-rw-r--r--cpp/src/Slice/JavaUtil.cpp68
-rw-r--r--cpp/src/slice2cs/Gen.cpp40
9 files changed, 240 insertions, 247 deletions
diff --git a/cpp/include/Ice/BasicStream.h b/cpp/include/Ice/BasicStream.h
index c34e10d1d45..cf9268b8d84 100644
--- a/cpp/include/Ice/BasicStream.h
+++ b/cpp/include/Ice/BasicStream.h
@@ -33,7 +33,7 @@ class UserException;
namespace IceInternal
{
-template<typename T> inline void
+template<typename T> inline void
patchHandle(void* addr, const Ice::ObjectPtr& v)
{
IceInternal::Handle<T>* p = static_cast<IceInternal::Handle<T>*>(addr);
@@ -253,7 +253,7 @@ public:
{
throwEncapsulationException(__FILE__, __LINE__);
}
-
+
//
// Ice version < 3.3 had a bug where user exceptions with
// class members could be encoded with a trailing byte
@@ -399,17 +399,17 @@ public:
Ice::Int readAndCheckSeqSize(int);
- void startSize()
+ int startSize()
{
- _sizePos = static_cast<Ice::Int>(b.size());
+ int pos = static_cast<Ice::Int>(b.size());
write(Ice::Int(0));
+ return pos;
}
- void endSize()
+ void endSize(int pos)
{
- assert(_sizePos >= 0);
- rewrite(static_cast<Ice::Int>(b.size()) - _sizePos - 4, _sizePos);
- _sizePos = -1;
+ assert(pos >= 0);
+ rewrite(static_cast<Ice::Int>(b.size()) - pos - 4, pos);
}
void writeBlob(const std::vector<Ice::Byte>&);
@@ -459,22 +459,22 @@ public:
}
if(writeOpt(tag, Ice::StreamOptionalHelper<T,
- Ice::StreamableTraits<T>::helper,
+ Ice::StreamableTraits<T>::helper,
Ice::StreamableTraits<T>::fixedLength>::optionalFormat))
{
- Ice::StreamOptionalHelper<T,
- Ice::StreamableTraits<T>::helper,
+ Ice::StreamOptionalHelper<T,
+ Ice::StreamableTraits<T>::helper,
Ice::StreamableTraits<T>::fixedLength>::write(this, *v);
}
}
template<typename T> void read(Ice::Int tag, IceUtil::Optional<T>& v)
{
- if(readOpt(tag, Ice::StreamOptionalHelper<T,
- Ice::StreamableTraits<T>::helper,
+ if(readOpt(tag, Ice::StreamOptionalHelper<T,
+ Ice::StreamableTraits<T>::helper,
Ice::StreamableTraits<T>::fixedLength>::optionalFormat))
{
v.__setIsSet();
- Ice::StreamOptionalHelper<T,
+ Ice::StreamOptionalHelper<T,
Ice::StreamableTraits<T>::helper,
Ice::StreamableTraits<T>::fixedLength>::read(this, *v);
}
@@ -486,7 +486,7 @@ public:
//
// Template functions for sequences and custom sequences
- //
+ //
template<typename T> void write(const std::vector<T>& v)
{
if(v.empty())
@@ -726,7 +726,7 @@ public:
v.clear();
}
}
-
+
// For custom strings, convert = false
void read(const char*& vdata, size_t& vsize)
{
@@ -737,7 +737,7 @@ public:
{
throwUnmarshalOutOfBoundsException(__FILE__, __LINE__);
}
-
+
vdata = reinterpret_cast<const char*>(&*i);
vsize = static_cast<size_t>(sz);
i += sz;
@@ -766,7 +766,7 @@ public:
{
throwUnmarshalOutOfBoundsException(__FILE__, __LINE__);
}
-
+
readConverted(holder, sz);
vdata = holder.data();
vsize = holder.size();
@@ -834,7 +834,7 @@ public:
bool writeOptImpl(Ice::Int, Ice::OptionalFormat);
void skipOpt(Ice::OptionalFormat);
void skipOpts();
-
+
// Skip bytes from the stream
void skip(size_type size)
{
@@ -843,7 +843,7 @@ public:
throwUnmarshalOutOfBoundsException(__FILE__, __LINE__);
}
i += size;
- }
+ }
void skipSize()
{
Ice::Byte b;
@@ -926,7 +926,7 @@ private:
EncapsDecoder(BasicStream* stream, ReadEncaps* encaps, bool sliceObjects, const ObjectFactoryManagerPtr& f) :
_stream(stream), _encaps(encaps), _sliceObjects(sliceObjects), _servantFactoryManager(f), _typeIdIndex(0)
{
- }
+ }
std::string readTypeId(bool);
Ice::ObjectPtr newInstance(const std::string&);
@@ -966,10 +966,10 @@ private:
{
public:
- EncapsDecoder10(BasicStream* stream, ReadEncaps* encaps, bool sliceObjects, const ObjectFactoryManagerPtr& f) :
+ EncapsDecoder10(BasicStream* stream, ReadEncaps* encaps, bool sliceObjects, const ObjectFactoryManagerPtr& f) :
EncapsDecoder(stream, encaps, sliceObjects, f), _sliceType(NoSlice)
{
- }
+ }
virtual void read(PatchFunc, void*);
virtual void throwException(const UserExceptionFactoryPtr&);
@@ -1002,7 +1002,7 @@ private:
EncapsDecoder11(BasicStream* stream, ReadEncaps* encaps, bool sliceObjects, const ObjectFactoryManagerPtr& f) :
EncapsDecoder(stream, encaps, sliceObjects, f), _preAllocatedInstanceData(0), _current(0), _objectIdIndex(1)
{
- }
+ }
virtual void read(PatchFunc, void*);
virtual void throwException(const UserExceptionFactoryPtr&);
@@ -1093,7 +1093,7 @@ private:
virtual void write(const Ice::ObjectPtr&) = 0;
virtual void write(const Ice::UserException&) = 0;
-
+
virtual void startInstance(SliceType, const Ice::SlicedDataPtr&) = 0;
virtual void endInstance() = 0;
virtual void startSlice(const std::string&, int, bool) = 0;
@@ -1136,14 +1136,14 @@ private:
{
public:
- EncapsEncoder10(BasicStream* stream, WriteEncaps* encaps) :
+ EncapsEncoder10(BasicStream* stream, WriteEncaps* encaps) :
EncapsEncoder(stream, encaps), _sliceType(NoSlice), _objectIdIndex(0)
{
}
virtual void write(const Ice::ObjectPtr&);
virtual void write(const Ice::UserException&);
-
+
virtual void startInstance(SliceType, const Ice::SlicedDataPtr&);
virtual void endInstance();
virtual void startSlice(const std::string&, int, bool);
@@ -1170,7 +1170,7 @@ private:
{
public:
- EncapsEncoder11(BasicStream* stream, WriteEncaps* encaps) :
+ EncapsEncoder11(BasicStream* stream, WriteEncaps* encaps) :
EncapsEncoder(stream, encaps), _preAllocatedInstanceData(0), _current(0), _objectIdIndex(1)
{
}
@@ -1199,7 +1199,7 @@ private:
previous->next = this;
}
}
-
+
~InstanceData()
{
if(next)
@@ -1207,7 +1207,7 @@ private:
delete next;
}
}
-
+
// Instance attributes
SliceType sliceType;
bool firstSlice;
@@ -1318,8 +1318,6 @@ private:
int _startSeq;
int _minSeqSize;
-
- int _sizePos;
};
} // End namespace IceInternal
diff --git a/cpp/include/Ice/Stream.h b/cpp/include/Ice/Stream.h
index 9fab19d44c9..367f94fe3d4 100644
--- a/cpp/include/Ice/Stream.h
+++ b/cpp/include/Ice/Stream.h
@@ -149,7 +149,7 @@ public:
read(value);
return value;
}
- else
+ else
{
Int value;
read(value);
@@ -200,7 +200,7 @@ public:
virtual void read(const char*&, size_t&, std::string&) = 0;
virtual void read(::std::vector< ::std::string>&, bool) = 0; // Overload required for additional bool argument.
virtual void read(::std::wstring&) = 0;
-
+
//
// std::vector<bool> is a special C++ type, so we give it its own read function
//
@@ -221,7 +221,7 @@ public:
read(p);
}
- virtual bool readOptional(Int, OptionalFormat) = 0;
+ virtual bool readOptional(Int, OptionalFormat) = 0;
template<typename T> inline void read(T& v)
{
@@ -230,8 +230,8 @@ public:
template<typename T> inline void read(Int tag, IceUtil::Optional<T>& v)
{
- if(readOptional(tag, StreamOptionalHelper<T,
- StreamableTraits<T>::helper,
+ if(readOptional(tag, StreamOptionalHelper<T,
+ StreamableTraits<T>::helper,
StreamableTraits<T>::fixedLength>::optionalFormat))
{
v.__setIsSet();
@@ -282,7 +282,7 @@ public:
{
write(static_cast<Short>(v));
}
- else
+ else
{
write(v);
}
@@ -348,8 +348,8 @@ public:
virtual bool writeOptional(Int, OptionalFormat) = 0;
- virtual void startSize() = 0;
- virtual void endSize() = 0;
+ virtual int startSize() = 0;
+ virtual void endSize(int pos) = 0;
template<typename T> inline void write(const T& v)
{
@@ -361,7 +361,7 @@ public:
if(v)
{
writeOptional(tag, StreamOptionalHelper<T,
- StreamableTraits<T>::helper,
+ StreamableTraits<T>::helper,
StreamableTraits<T>::fixedLength>::optionalFormat);
StreamOptionalHelper<T, StreamableTraits<T>::helper, StreamableTraits<T>::fixedLength>::write(this, *v);
}
@@ -369,7 +369,7 @@ public:
//
// Template functions for sequences and custom sequences
- //
+ //
template<typename T> void write(const T* begin, const T* end)
{
writeSize(static_cast<Int>(end - begin));
diff --git a/cpp/include/Ice/StreamHelpers.h b/cpp/include/Ice/StreamHelpers.h
index e7692d43297..18943b2a4c6 100644
--- a/cpp/include/Ice/StreamHelpers.h
+++ b/cpp/include/Ice/StreamHelpers.h
@@ -51,10 +51,10 @@ enum OptionalFormat
OptionalFormatF4 = 2, // Fixed 4 bytes encoding
OptionalFormatF8 = 3, // Fixed 8 bytes encoding
OptionalFormatSize = 4, // "Size encoding" on 1 to 5 bytes, e.g. enum, class identifier
- OptionalFormatVSize = 5, // "Size encoding" on 1 to 5 bytes followed by data, e.g. string, fixed size
+ OptionalFormatVSize = 5, // "Size encoding" on 1 to 5 bytes followed by data, e.g. string, fixed size
// struct, or containers whose size can be computed prior to marshaling
OptionalFormatFSize = 6, // Fixed size on 4 bytes followed by data, e.g. variable-size struct, container.
- OptionalFormatClass = 7
+ OptionalFormatClass = 7
};
@@ -68,10 +68,10 @@ struct IsContainer
{
template<typename C>
static char test(typename C::iterator*);
-
+
template<typename C>
static long test(...);
-
+
static const bool value = sizeof(test<T>(0)) == sizeof(char);
};
@@ -85,7 +85,7 @@ struct IsMap
{
template<typename C>
static char test(typename C::mapped_type*);
-
+
template<typename C>
static long test(...);
@@ -103,12 +103,12 @@ struct StreamableTraits
(IsContainer<T>::value ? StreamHelperCategorySequence : StreamHelperCategoryUnknown);
//
- // When extracting a sequence<T> from a stream, we can ensure the
+ // When extracting a sequence<T> from a stream, we can ensure the
// stream has at least StreamableTraits<T>::minWireSize * size bytes
// For containers, the minWireSize is 1 (just 1 byte for an empty container).
//
static const int minWireSize = 1;
-
+
//
// Is this type encoded on a fixed number of bytes?
// Used only for marshaling/unmarshaling optional data members and parameters.
@@ -118,7 +118,7 @@ struct StreamableTraits
//
// StreamableTraits specialization for array / range mapped sequences
-// The type can be a std::pair<T, T> or a
+// The type can be a std::pair<T, T> or a
// std::pair<IceUtil::ScopedArray<T>, std::pair<const T*, const T*> >
//
template<typename T, typename U>
@@ -254,7 +254,7 @@ struct StreamableTraits< ::IceInternal::Handle<T> >
//
// Base StreamHelper template; it must be specialized for each type
-template<typename T, StreamHelperCategory st>
+template<typename T, StreamHelperCategory st>
struct StreamHelper;
@@ -262,7 +262,7 @@ struct StreamHelper;
template<typename T>
struct StreamHelper<T, StreamHelperCategoryBuiltin>
{
- template<class S> static inline void
+ template<class S> static inline void
write(S* stream, const T& v)
{
stream->write(v);
@@ -277,25 +277,25 @@ struct StreamHelper<T, StreamHelperCategoryBuiltin>
// "helpers" for the StreamHelper<T, StreamHelperCategoryStruct[Class]> below
// We generate specializations, which can be instantiated explicitly and exported from DLLs
-//
+//
-template<typename T, typename S>
+template<typename T, typename S>
struct StreamWriter;
-template<typename T, typename S>
+template<typename T, typename S>
struct StreamReader;
// Helper for structs
template<typename T>
struct StreamHelper<T, StreamHelperCategoryStruct>
{
- template<class S> static inline void
+ template<class S> static inline void
write(S* stream, const T& v)
{
StreamWriter<T, S>::write(stream, v);
}
- template<class S> static inline void
+ template<class S> static inline void
read(S* stream, T& v)
{
StreamReader<T, S>::read(stream, v);
@@ -307,13 +307,13 @@ struct StreamHelper<T, StreamHelperCategoryStruct>
template<typename T>
struct StreamHelper<T, StreamHelperCategoryStructClass>
{
- template<class S> static inline void
+ template<class S> static inline void
write(S* stream, const T& v)
{
StreamWriter<T, S>::write(stream, v);
}
- template<class S> static inline void
+ template<class S> static inline void
read(S* stream, T& v)
{
v = new typename T::element_type;
@@ -335,7 +335,7 @@ struct StreamHelper<T, StreamHelperCategoryEnum>
stream->writeEnum(static_cast<Int>(v), StreamableTraits<T>::maxValue);
}
- template<class S> static inline void
+ template<class S> static inline void
read(S* stream, T& v)
{
Int value = stream->readEnum(StreamableTraits<T>::maxValue);
@@ -351,7 +351,7 @@ struct StreamHelper<T, StreamHelperCategoryEnum>
template<typename T>
struct StreamHelper<T, StreamHelperCategorySequence>
{
- template<class S> static inline void
+ template<class S> static inline void
write(S* stream, const T& v)
{
stream->writeSize(static_cast<Int>(v.size()));
@@ -361,7 +361,7 @@ struct StreamHelper<T, StreamHelperCategorySequence>
}
}
- template<class S> static inline void
+ template<class S> static inline void
read(S* stream, T& v)
{
Int sz = stream->readAndCheckSeqSize(StreamableTraits<typename T::value_type>::minWireSize);
@@ -377,13 +377,13 @@ struct StreamHelper<T, StreamHelperCategorySequence>
template<typename T>
struct StreamHelper<std::pair<const T*, const T*>, StreamHelperCategorySequence>
{
- template<class S> static inline void
+ template<class S> static inline void
write(S* stream, const std::pair<const T*, const T*>& v)
{
stream->write(v.first, v.second);
}
- template<class S> static inline void
+ template<class S> static inline void
read(S* stream, std::pair<const T*, const T*>& v)
{
stream->read(v);
@@ -394,7 +394,7 @@ struct StreamHelper<std::pair<const T*, const T*>, StreamHelperCategorySequence>
template<typename T>
struct StreamHelper<std::pair<T, T>, StreamHelperCategorySequence>
{
- template<class S> static inline void
+ template<class S> static inline void
write(S* stream, const std::pair<T, T>& v)
{
stream->writeSize(static_cast<Int>(IceUtilInternal::distance(v.first, v.second)));
@@ -404,7 +404,7 @@ struct StreamHelper<std::pair<T, T>, StreamHelperCategorySequence>
}
}
- template<class S> static inline void
+ template<class S> static inline void
read(S* stream, std::pair<T, T>& v)
{
stream->read(v);
@@ -415,7 +415,7 @@ template<>
struct StreamHelper<std::pair< ::std::vector<bool>::const_iterator,
::std::vector<bool>::const_iterator>, StreamHelperCategorySequence>
{
- template<class S> static inline void
+ template<class S> static inline void
write(S* stream, const std::pair< ::std::vector<bool>::const_iterator,
::std::vector<bool>::const_iterator>& v)
{
@@ -433,7 +433,7 @@ struct StreamHelper<std::pair< ::std::vector<bool>::const_iterator,
template<typename T>
struct StreamHelper<std::pair<IceUtil::ScopedArray<T>, std::pair<const T*, const T*> >, StreamHelperCategorySequence>
{
- template<class S> static inline void
+ template<class S> static inline void
read(S* stream, std::pair<IceUtil::ScopedArray<T>, std::pair<const T*, const T*> >& v)
{
stream->read(v.second, v.first);
@@ -446,7 +446,7 @@ struct StreamHelper<std::pair<IceUtil::ScopedArray<T>, std::pair<const T*, const
template<typename T>
struct StreamHelper<T, StreamHelperCategoryDictionary>
{
- template<class S> static inline void
+ template<class S> static inline void
write(S* stream, const T& v)
{
stream->writeSize(static_cast<Int>(v.size()));
@@ -457,7 +457,7 @@ struct StreamHelper<T, StreamHelperCategoryDictionary>
}
}
- template<class S> static inline void
+ template<class S> static inline void
read(S* stream, T& v)
{
Int sz = stream->readSize();
@@ -476,7 +476,7 @@ struct StreamHelper<T, StreamHelperCategoryDictionary>
template<typename T>
struct StreamHelper<T, StreamHelperCategoryUserException>
{
- template<class S> static inline void
+ template<class S> static inline void
write(S* stream, const T& v)
{
stream->writeException(v);
@@ -525,7 +525,7 @@ struct StreamHelper<T, StreamHelperCategoryClass>
//
//
-// Extract / compute the optionalFormat
+// Extract / compute the optionalFormat
// This is used _only_ for the base StreamOptionalHelper below
// /!\ Do not use in StreamOptionalHelper specializations, and do
// not provide specialization not handled by the base StreamOptionalHelper
@@ -578,24 +578,24 @@ struct GetOptionalFormat<StreamHelperCategoryEnum, minWireSize, false>
// Base helper: simply read/write the data
template<typename T, StreamHelperCategory st, bool fixedLength>
-struct StreamOptionalHelper
+struct StreamOptionalHelper
{
typedef StreamableTraits<T> Traits;
// If this optionalFormat fails to compile, you must either define your specialization
// for GetOptionalFormat (in which case the optional data will be marshaled/unmarshaled
- // with straight calls to write/read on the stream), or define your own
+ // with straight calls to write/read on the stream), or define your own
// StreamOptionalHelper specialization (which gives you more control over marshaling)
- //
+ //
static const OptionalFormat optionalFormat = GetOptionalFormat<st, Traits::minWireSize, fixedLength>::value;
- template<class S> static inline void
+ template<class S> static inline void
write(S* stream, const T& v)
{
stream->write(v);
}
- template<class S> static inline void
+ template<class S> static inline void
read(S* stream, T& v)
{
stream->read(v);
@@ -608,14 +608,14 @@ struct StreamOptionalHelper<T, StreamHelperCategoryStruct, true>
{
static const OptionalFormat optionalFormat = OptionalFormatVSize;
- template<class S> static inline void
+ template<class S> static inline void
write(S* stream, const T& v)
{
stream->writeSize(StreamableTraits<T>::minWireSize);
stream->write(v);
}
- template<class S> static inline void
+ template<class S> static inline void
read(S* stream, T& v)
{
stream->skipSize();
@@ -629,13 +629,12 @@ struct StreamOptionalHelper<T, StreamHelperCategoryStruct, false>
{
static const OptionalFormat optionalFormat = OptionalFormatFSize;
- template<class S> static inline void
+ template<class S> static inline void
write(S* stream, const T& v)
{
- stream->write(static_cast<Int>(0));
- typename S::size_type p = stream->pos();
+ int pos = stream->startSize();
stream->write(v);
- stream->rewrite(static_cast<Int>(stream->pos() - p), p - 4);
+ stream->endSize(pos);
}
template<class S> static inline void
@@ -646,7 +645,7 @@ struct StreamOptionalHelper<T, StreamHelperCategoryStruct, false>
}
};
-// Class structs are encoded like structs
+// Class structs are encoded like structs
template<typename T, bool fixedLength>
struct StreamOptionalHelper<T, StreamHelperCategoryStructClass, fixedLength> : StreamOptionalHelper<T, StreamHelperCategoryStruct, fixedLength>
{
@@ -676,14 +675,14 @@ struct StreamOptionalContainerHelper<T, false, sz>
{
static const OptionalFormat optionalFormat = OptionalFormatFSize;
- template<class S> static inline void
- write(S* stream, const T& v, Int)
+ template<class S> static inline void
+ write(S* stream, const T& v, Int)
{
StreamOptionalHelper<T, StreamHelperCategoryStruct, false>::write(stream, v);
}
- template<class S> static inline void
- read(S* stream, T& v)
+ template<class S> static inline void
+ read(S* stream, T& v)
{
StreamOptionalHelper<T, StreamHelperCategoryStruct, false>::read(stream, v);
}
@@ -692,14 +691,14 @@ struct StreamOptionalContainerHelper<T, false, sz>
//
// Encode containers of fixed size elements with the VSize optional
// type since we can figure out the size of the container before
-// encoding.
+// encoding.
//
template<typename T, int sz>
struct StreamOptionalContainerHelper<T, true, sz>
-{
+{
static const OptionalFormat optionalFormat = OptionalFormatVSize;
- template<class S> static inline void
+ template<class S> static inline void
write(S* stream, const T& v, Int n)
{
//
@@ -711,7 +710,7 @@ struct StreamOptionalContainerHelper<T, true, sz>
stream->write(v);
}
- template<class S> static inline void
+ template<class S> static inline void
read(S* stream, T& v)
{
stream->skipSize();
@@ -727,16 +726,16 @@ struct StreamOptionalContainerHelper<T, true, sz>
//
template<typename T>
struct StreamOptionalContainerHelper<T, true, 1>
-{
+{
static const OptionalFormat optionalFormat = OptionalFormatVSize;
- template<class S> static inline void
- write(S* stream, const T& v, Int)
+ template<class S> static inline void
+ write(S* stream, const T& v, Int)
{
stream->write(v);
}
- template<class S> static inline void
+ template<class S> static inline void
read(S* stream, T& v)
{
stream->read(v);
@@ -759,13 +758,13 @@ struct StreamOptionalHelper<T, StreamHelperCategorySequence, false>
// or variable size elements and their size.
static const OptionalFormat optionalFormat = StreamOptionalContainerHelper<T, fixedLength, size>::optionalFormat;
- template<class S> static inline void
+ template<class S> static inline void
write(S* stream, const T& v)
{
StreamOptionalContainerHelper<T, fixedLength, size>::write(stream, v, static_cast<Int>(v.size()));
}
- template<class S> static inline void
+ template<class S> static inline void
read(S* stream, T& v)
{
StreamOptionalContainerHelper<T, fixedLength, size>::read(stream, v);
@@ -783,14 +782,14 @@ struct StreamOptionalHelper<std::pair<const T*, const T*>, StreamHelperCategoryS
// or variable size elements and their size.
static const OptionalFormat optionalFormat = StreamOptionalContainerHelper<P, fixedLength, size>::optionalFormat;
- template<class S> static inline void
+ template<class S> static inline void
write(S* stream, const P& v)
{
Int n = static_cast<Int>(v.second - v.first);
StreamOptionalContainerHelper<P, fixedLength, size>::write(stream, v, n);
}
- template<class S> static inline void
+ template<class S> static inline void
read(S* stream, P& v)
{
StreamOptionalContainerHelper<P, fixedLength, size>::read(stream, v);
@@ -808,14 +807,14 @@ struct StreamOptionalHelper<std::pair<T, T>, StreamHelperCategorySequence, false
// or variable size elements and their size.
static const OptionalFormat optionalFormat = StreamOptionalContainerHelper<P, fixedLength, size>::optionalFormat;
- template<class S> static inline void
+ template<class S> static inline void
write(S* stream, const P& v)
{
Int n = static_cast<Int>(v.second - v.first);
StreamOptionalContainerHelper<P, fixedLength, size>::write(stream, v, n);
}
- template<class S> static inline void
+ template<class S> static inline void
read(S* stream, P& v)
{
StreamOptionalContainerHelper<P, fixedLength, size>::read(stream, v);
@@ -834,7 +833,7 @@ struct StreamOptionalHelper<std::pair<IceUtil::ScopedArray<T>, std::pair<const T
// or variable size elements and their size.
static const OptionalFormat optionalFormat = StreamOptionalContainerHelper<P, fixedLength, size>::optionalFormat;
- template<class S> static inline void
+ template<class S> static inline void
read(S* stream, P& v)
{
StreamOptionalContainerHelper<P, fixedLength, size>::read(stream, v);
@@ -860,13 +859,13 @@ struct StreamOptionalHelper<T, StreamHelperCategoryDictionary, false>
// or variable size elements.
static const OptionalFormat optionalFormat = StreamOptionalContainerHelper<T, fixedLength, size>::optionalFormat;
- template<class S> static inline void
+ template<class S> static inline void
write(S* stream, const T& v)
{
StreamOptionalContainerHelper<T, fixedLength, size>::write(stream, v, static_cast<Int>(v.size()));
}
- template<class S> static inline void
+ template<class S> static inline void
read(S* stream, T& v)
{
StreamOptionalContainerHelper<T, fixedLength, size>::read(stream, v);
diff --git a/cpp/src/Ice/BasicStream.cpp b/cpp/src/Ice/BasicStream.cpp
index 2d19bd83d38..18192e118e9 100644
--- a/cpp/src/Ice/BasicStream.cpp
+++ b/cpp/src/Ice/BasicStream.cpp
@@ -37,12 +37,12 @@ namespace
class StreamUTF8BufferI : public IceUtil::UTF8Buffer
{
public:
-
- StreamUTF8BufferI(BasicStream& stream) :
+
+ StreamUTF8BufferI(BasicStream& stream) :
_stream(stream)
{
}
-
+
Ice::Byte*
getMoreBytes(size_t howMany, Ice::Byte* firstUnused)
{
@@ -100,8 +100,7 @@ IceInternal::BasicStream::BasicStream(Instance* instance, const EncodingVersion&
_unlimited(unlimited),
_stringConverter(instance->getStringConverter()),
_wstringConverter(instance->getWstringConverter()),
- _startSeq(-1),
- _sizePos(-1)
+ _startSeq(-1)
{
//
// Initialize the encoding members of our pre-allocated encapsulations, in case
@@ -111,7 +110,7 @@ IceInternal::BasicStream::BasicStream(Instance* instance, const EncodingVersion&
_preAllocatedWriteEncaps.encoding = encoding;
}
-IceInternal::BasicStream::BasicStream(Instance* instance, const EncodingVersion& encoding, const Byte* begin,
+IceInternal::BasicStream::BasicStream(Instance* instance, const EncodingVersion& encoding, const Byte* begin,
const Byte* end) :
IceInternal::Buffer(begin, end),
_instance(instance),
@@ -124,8 +123,7 @@ IceInternal::BasicStream::BasicStream(Instance* instance, const EncodingVersion&
_unlimited(false),
_stringConverter(instance->getStringConverter()),
_wstringConverter(instance->getWstringConverter()),
- _startSeq(-1),
- _sizePos(-1)
+ _startSeq(-1)
{
//
// Initialize the encoding members of our pre-allocated encapsulations, in case
@@ -153,7 +151,6 @@ IceInternal::BasicStream::clear()
}
_startSeq = -1;
- _sizePos = -1;
_sliceObjects = true;
}
@@ -191,7 +188,6 @@ IceInternal::BasicStream::swap(BasicStream& other)
std::swap(_unlimited, other._unlimited);
std::swap(_startSeq, other._startSeq);
std::swap(_minSeqSize, other._minSeqSize);
- std::swap(_sizePos, other._sizePos);
}
void
@@ -316,7 +312,7 @@ IceInternal::BasicStream::writePendingObjects()
// If using the 1.0 encoding and no objects were written, we
// still write an empty sequence for pending objects if
// requested (i.e.: if this is called).
- //
+ //
// This is required by the 1.0 encoding, even if no objects
// are written we do marshal an empty sequence if marshaled
// data types use classes.
@@ -339,8 +335,8 @@ IceInternal::BasicStream::readAndCheckSeqSize(int minSize)
// The _startSeq variable points to the start of the sequence for which
// we expect to read at least _minSeqSize bytes from the stream.
//
- // If not initialized or if we already read more data than _minSeqSize,
- // we reset _startSeq and _minSeqSize for this sequence (possibly a
+ // If not initialized or if we already read more data than _minSeqSize,
+ // we reset _startSeq and _minSeqSize for this sequence (possibly a
// top-level sequence or enclosed sequence it doesn't really matter).
//
// Otherwise, we are reading an enclosed sequence and we have to bump
@@ -349,7 +345,7 @@ IceInternal::BasicStream::readAndCheckSeqSize(int minSize)
//
// The goal of this check is to ensure that when we start un-marshalling
// a new sequence, we check the minimal size of this new sequence against
- // the estimated remaining buffer size. This estimatation is based on
+ // the estimated remaining buffer size. This estimatation is based on
// the minimum size of the enclosing sequences, it's _minSeqSize.
//
if(_startSeq == -1 || i > (b.begin() + _startSeq + _minSeqSize))
@@ -364,14 +360,14 @@ IceInternal::BasicStream::readAndCheckSeqSize(int minSize)
//
// If there isn't enough data to read on the stream for the sequence (and
- // possibly enclosed sequences), something is wrong with the marshalled
+ // possibly enclosed sequences), something is wrong with the marshalled
// data: it's claiming having more data that what is possible to read.
//
if(_startSeq + _minSeqSize > static_cast<int>(b.size()))
{
throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
}
-
+
return sz;
}
@@ -1361,19 +1357,19 @@ IceInternal::BasicStream::writeConverted(const char* vdata, size_t vsize)
{
Int guessedSize = static_cast<Int>(vsize);
writeSize(guessedSize); // writeSize() only writes the size; it does not reserve any buffer space.
-
+
size_t firstIndex = b.size();
StreamUTF8BufferI buffer(*this);
-
+
Byte* lastByte = _stringConverter->toUTF8(vdata, vdata + vsize, buffer);
if(lastByte != b.end())
{
b.resize(lastByte - b.begin());
}
size_t lastIndex = b.size();
-
+
Int actualSize = static_cast<Int>(lastIndex - firstIndex);
-
+
//
// Check against the guess
//
@@ -1396,7 +1392,7 @@ IceInternal::BasicStream::writeConverted(const char* vdata, size_t vsize)
memmove(b.begin() + firstIndex - 4, b.begin() + firstIndex, actualSize);
resize(b.size() - 4);
}
-
+
if(guessedSize <= 254)
{
rewriteSize(actualSize, b.begin() + firstIndex - 1);
@@ -1476,19 +1472,19 @@ IceInternal::BasicStream::write(const wstring& v)
{
Int guessedSize = static_cast<Int>(v.size());
writeSize(guessedSize); // writeSize() only writes the size; it does not reserve any buffer space.
-
+
size_t firstIndex = b.size();
StreamUTF8BufferI buffer(*this);
-
+
Byte* lastByte = _wstringConverter->toUTF8(v.data(), v.data() + v.size(), buffer);
if(lastByte != b.end())
{
b.resize(lastByte - b.begin());
}
size_t lastIndex = b.size();
-
+
Int actualSize = static_cast<Int>(lastIndex - firstIndex);
-
+
//
// Check against the guess
//
@@ -1511,7 +1507,7 @@ IceInternal::BasicStream::write(const wstring& v)
memmove(b.begin() + firstIndex - 4, b.begin() + firstIndex, actualSize);
resize(b.size() - 4);
}
-
+
if(guessedSize <= 254)
{
rewriteSize(actualSize, b.begin() + firstIndex - 1);
@@ -1616,7 +1612,7 @@ IceInternal::BasicStream::readEnum(Int maxValue)
read(value);
return value;
}
- else
+ else
{
Int value;
read(value);
@@ -1629,7 +1625,7 @@ IceInternal::BasicStream::readEnum(Int maxValue)
}
}
-void
+void
IceInternal::BasicStream::writeEnum(Int v, Int maxValue)
{
if(getWriteEncoding() == Encoding_1_0)
@@ -1642,7 +1638,7 @@ IceInternal::BasicStream::writeEnum(Int v, Int maxValue)
{
write(static_cast<Short>(v));
}
- else
+ else
{
write(v);
}
@@ -1695,7 +1691,7 @@ IceInternal::BasicStream::readOptImpl(Int readTag, OptionalFormat expectedFormat
--i; // Rewind
return false;
}
-
+
OptionalFormat format = static_cast<OptionalFormat>(v & 0x07); // First 3 bits.
Int tag = static_cast<Int>(v >> 3);
if(tag == 30)
@@ -1804,7 +1800,7 @@ BasicStream::skipOpts()
{
//
// Skip remaining un-read optional members.
- //
+ //
while(true)
{
if(i >= b.begin() + _currentReadEncaps->start + _currentReadEncaps->sz)
@@ -2003,7 +1999,7 @@ IceInternal::BasicStream::EncapsDecoder::unmarshal(Int index, const Ice::ObjectP
//
// Add the object to the map of un-marshalled objects, this must
// be done before reading the objects (for circular references).
- //
+ //
_unmarshaledMap.insert(make_pair(index, v));
//
@@ -2018,7 +2014,7 @@ IceInternal::BasicStream::EncapsDecoder::unmarshal(Int index, const Ice::ObjectP
if(patchPos != _patchMap.end())
{
assert(patchPos->second.size() > 0);
-
+
//
// Patch all pointers that refer to the instance.
//
@@ -2026,7 +2022,7 @@ IceInternal::BasicStream::EncapsDecoder::unmarshal(Int index, const Ice::ObjectP
{
(*k->patchFunc)(k->patchAddr, v);
}
-
+
//
// Clear out the patch map for that index -- there is nothing left
// to patch for that index for the time being.
@@ -2180,7 +2176,7 @@ IceInternal::BasicStream::EncapsDecoder10::throwException(const UserExceptionFac
readPendingObjects();
}
throw;
-
+
// Never reached.
}
}
@@ -2188,7 +2184,7 @@ IceInternal::BasicStream::EncapsDecoder10::throwException(const UserExceptionFac
//
// Slice off what we don't understand.
//
- skipSlice();
+ skipSlice();
try
{
startSlice();
@@ -2256,7 +2252,7 @@ IceInternal::BasicStream::EncapsDecoder10::startSlice()
//
// For objects, first read the type ID boolean which indicates
// whether or not the type ID is encoded as a string or as an
- // index. For exceptions, the type ID is always encoded as a
+ // index. For exceptions, the type ID is always encoded as a
// string.
//
if(_sliceType == ObjectSlice)
@@ -2264,7 +2260,7 @@ IceInternal::BasicStream::EncapsDecoder10::startSlice()
bool isIndex;
_stream->read(isIndex);
_typeId = readTypeId(isIndex);
- }
+ }
else
{
_stream->read(_typeId, false);
@@ -2281,7 +2277,7 @@ IceInternal::BasicStream::EncapsDecoder10::startSlice()
void
IceInternal::BasicStream::EncapsDecoder10::endSlice()
{
-}
+}
void
IceInternal::BasicStream::EncapsDecoder10::skipSlice()
@@ -2356,7 +2352,7 @@ IceInternal::BasicStream::EncapsDecoder10::readInstance()
{
throw NoObjectFactoryException(__FILE__, __LINE__, "", mostDerivedId);
}
-
+
v = newInstance(_typeId);
//
@@ -2477,7 +2473,7 @@ IceInternal::BasicStream::EncapsDecoder11::throwException(const UserExceptionFac
{
ex.__read(_stream);
throw;
-
+
// Never reached.
}
}
@@ -2485,7 +2481,7 @@ IceInternal::BasicStream::EncapsDecoder11::throwException(const UserExceptionFac
//
// Slice off what we don't understand.
//
- skipSlice();
+ skipSlice();
//
// If this is the last slice, raise an exception and stop un-marshalling.
@@ -2569,7 +2565,7 @@ IceInternal::BasicStream::EncapsDecoder11::startSlice()
_current->typeId.clear();
_current->compactId = -1;
}
- }
+ }
else
{
_stream->read(_current->typeId, false);
@@ -2611,7 +2607,7 @@ IceInternal::BasicStream::EncapsDecoder11::endSlice()
for(IndexList::iterator p = indirectionTable.begin(); p != indirectionTable.end(); ++p)
{
*p = readInstance(_stream->readSize(), 0, 0);
- }
+ }
//
// Sanity checks. If there are optional members, it's possible
@@ -2642,7 +2638,7 @@ IceInternal::BasicStream::EncapsDecoder11::endSlice()
}
_current->indirectPatchList.clear();
}
-}
+}
void
IceInternal::BasicStream::EncapsDecoder11::skipSlice()
@@ -2672,8 +2668,8 @@ IceInternal::BasicStream::EncapsDecoder11::skipSlice()
if(_current->sliceType == ObjectSlice)
{
throw NoObjectFactoryException(
- __FILE__, __LINE__,
- "compact format prevents slicing (the sender should use the sliced format instead)",
+ __FILE__, __LINE__,
+ "compact format prevents slicing (the sender should use the sliced format instead)",
_current->typeId);
}
else
@@ -2751,7 +2747,7 @@ Int
IceInternal::BasicStream::EncapsDecoder11::readInstance(Int index, PatchFunc patchFunc, void* patchAddr)
{
assert(index > 0);
-
+
if(index > 1)
{
if(patchFunc)
@@ -2864,7 +2860,7 @@ IceInternal::BasicStream::EncapsDecoder11::readInstance(Int index, PatchFunc pat
break;
}
-
+
startSlice(); // Read next Slice header for next iteration.
}
@@ -2889,7 +2885,7 @@ IceInternal::BasicStream::EncapsDecoder11::readInstance(Int index, PatchFunc pat
return index;
}
-SlicedDataPtr
+SlicedDataPtr
IceInternal::BasicStream::EncapsDecoder11::readSlicedData()
{
if(_current->slices.empty()) // No preserved slices.
@@ -2959,7 +2955,7 @@ IceInternal::BasicStream::EncapsEncoder10::write(const UserException& v)
//
// User exception with the 1.0 encoding start with a boolean
// flag that indicates whether or not the exception uses
- // classes.
+ // classes.
//
// This allows reading the pending objects even if some part of
// the exception was sliced.
@@ -3083,7 +3079,7 @@ IceInternal::BasicStream::EncapsEncoder10::writePendingObjects()
_stream->writeSize(0); // Zero marker indicates end of sequence of sequences of instances.
}
-Int
+Int
IceInternal::BasicStream::EncapsEncoder10::registerObject(const ObjectPtr& v)
{
assert(v);
@@ -3129,14 +3125,14 @@ IceInternal::BasicStream::EncapsEncoder11::write(const ObjectPtr& v)
// table. The indirect object table is encoded at the end of
// each slice and is always read (even if the Slice is
// unknown).
- //
+ //
PtrToIndexMap::const_iterator p = _current->indirectionMap.find(v);
if(p == _current->indirectionMap.end())
{
_current->indirectionTable.push_back(v);
Int idx = static_cast<Int>(_current->indirectionTable.size()); // Position + 1 (0 is reserved for nil)
_current->indirectionMap.insert(make_pair(v, idx));
- _stream->writeSize(idx);
+ _stream->writeSize(idx);
}
else
{
@@ -3210,7 +3206,7 @@ IceInternal::BasicStream::EncapsEncoder11::startSlice(const string& typeId, int
//
// Encode the type ID (only in the first slice for the compact
// encoding).
- //
+ //
if(_encaps->format == SlicedFormat || _current->firstSlice)
{
if(compactId >= 0)
@@ -3299,7 +3295,7 @@ IceInternal::BasicStream::EncapsEncoder11::endSlice()
*dest = _current->sliceFlags;
}
-bool
+bool
IceInternal::BasicStream::EncapsEncoder11::writeOpt(Ice::Int tag, Ice::OptionalFormat format)
{
if(!_current)
@@ -3339,12 +3335,12 @@ IceInternal::BasicStream::EncapsEncoder11::writeSlicedData(const SlicedDataPtr&
for(SliceInfoSeq::const_iterator p = slicedData->slices.begin(); p != slicedData->slices.end(); ++p)
{
startSlice((*p)->typeId, (*p)->compactId, (*p)->isLastSlice);
-
+
//
// Write the bytes associated with this slice.
//
_stream->writeBlob((*p)->bytes);
-
+
if((*p)->hasOptionalMembers)
{
_current->sliceFlags |= FLAG_HAS_OPTIONAL_MEMBERS;
diff --git a/cpp/src/Ice/StreamI.cpp b/cpp/src/Ice/StreamI.cpp
index 7537425a21c..6e65a752120 100644
--- a/cpp/src/Ice/StreamI.cpp
+++ b/cpp/src/Ice/StreamI.cpp
@@ -75,7 +75,7 @@ UserExceptionReader::__read(BasicStream* is)
//
// InputStreamI
//
-InputStreamI::InputStreamI(const CommunicatorPtr& communicator, const pair<const Byte*, const Byte*>& data,
+InputStreamI::InputStreamI(const CommunicatorPtr& communicator, const pair<const Byte*, const Byte*>& data,
bool copyData) :
_communicator(communicator),
_closure(0)
@@ -129,7 +129,7 @@ InputStreamI::readProxy()
return v;
}
-namespace
+namespace
{
void
@@ -391,7 +391,7 @@ InputStreamI::closure() const
}
void
-InputStreamI::initialize(Instance* instance, const pair<const Byte*, const Byte*>& buf, const EncodingVersion& v,
+InputStreamI::initialize(Instance* instance, const pair<const Byte*, const Byte*>& buf, const EncodingVersion& v,
bool copyData)
{
if(copyData)
@@ -555,7 +555,7 @@ OutputStreamI::write(const wstring& v)
_os->write(v);
}
-void
+void
OutputStreamI::write(const vector<bool>& v)
{
_os->write(v);
@@ -698,7 +698,7 @@ void
OutputStreamI::reset(bool clearBuffer)
{
_os->clear();
-
+
if(clearBuffer)
{
_os->b.clear();
@@ -707,7 +707,7 @@ OutputStreamI::reset(bool clearBuffer)
{
_os->b.reset();
}
-
+
_os->i = _os->b.begin();
}
@@ -723,16 +723,16 @@ OutputStreamI::rewrite(Int sz, size_type p)
_os->rewrite(sz, p);
}
-void
+int
OutputStreamI::startSize()
{
- _os->startSize();
+ return _os->startSize();
}
void
-OutputStreamI::endSize()
+OutputStreamI::endSize(int pos)
{
- _os->endSize();
+ _os->endSize(pos);
}
//
diff --git a/cpp/src/Ice/StreamI.h b/cpp/src/Ice/StreamI.h
index 4ea957be74d..a31dc213346 100644
--- a/cpp/src/Ice/StreamI.h
+++ b/cpp/src/Ice/StreamI.h
@@ -69,7 +69,7 @@ public:
virtual void skip(Int);
virtual void skipSize();
-
+
virtual void read(bool&);
virtual void read(Byte&);
virtual void read(Short&);
@@ -103,7 +103,7 @@ public:
private:
void initialize(IceInternal::Instance*, const std::pair<const Byte*, const Byte*>&, const EncodingVersion&, bool);
-
+
const CommunicatorPtr _communicator;
IceInternal::BasicStream* _is;
std::vector< ReadObjectCallbackPtr > _callbacks;
@@ -127,7 +127,7 @@ public:
virtual void writeObject(const ObjectPtr&);
virtual void writeException(const UserException&);
virtual void writeProxy(const ObjectPrx&);
-
+
virtual void writeSize(Int);
virtual void write(bool);
@@ -182,8 +182,8 @@ public:
virtual size_type pos();
virtual void rewrite(Int, size_type);
- virtual void startSize();
- virtual void endSize();
+ virtual int startSize();
+ virtual void endSize(int pos);
private:
diff --git a/cpp/src/Slice/CsUtil.cpp b/cpp/src/Slice/CsUtil.cpp
index 51bd6acec63..6c064e5a6c0 100644
--- a/cpp/src/Slice/CsUtil.cpp
+++ b/cpp/src/Slice/CsUtil.cpp
@@ -870,9 +870,9 @@ Slice::CsGenerator::writeOptionalMarshalUnmarshalCode(Output &out,
out << nl << "if(" << param << ".HasValue && " << stream << ".writeOpt(" << tag
<< ", Ice.OptionalFormat.FSize))";
out << sb;
- out << nl << stream << ".startSize();";
+ out << nl << "int pos__ = " << stream << ".startSize();";
writeMarshalUnmarshalCode(out, type, param + ".Value", marshal, streamingAPI);
- out << nl << stream << ".endSize();";
+ out << nl << stream << ".endSize(pos__);";
out << eb;
}
else
@@ -918,7 +918,7 @@ Slice::CsGenerator::writeOptionalMarshalUnmarshalCode(Output &out,
out << sb;
if(st->isVariableLength())
{
- out << nl << stream << ".startSize();";
+ out << nl << "int pos__ = " << stream << ".startSize();";
}
else
{
@@ -927,7 +927,7 @@ Slice::CsGenerator::writeOptionalMarshalUnmarshalCode(Output &out,
writeMarshalUnmarshalCode(out, type, param + ".Value", marshal, streamingAPI);
if(st->isVariableLength())
{
- out << nl << stream << ".endSize();";
+ out << nl << stream << ".endSize(pos__);";
}
out << eb;
}
@@ -1011,7 +1011,7 @@ Slice::CsGenerator::writeOptionalMarshalUnmarshalCode(Output &out,
out << sb;
if(keyType->isVariableLength() || valueType->isVariableLength())
{
- out << nl << stream << ".startSize();";
+ out << nl << "int pos__ = " << stream << ".startSize();";
}
else
{
@@ -1022,7 +1022,7 @@ Slice::CsGenerator::writeOptionalMarshalUnmarshalCode(Output &out,
writeMarshalUnmarshalCode(out, type, param + ".Value", marshal, streamingAPI);
if(keyType->isVariableLength() || valueType->isVariableLength())
{
- out << nl << stream << ".endSize();";
+ out << nl << stream << ".endSize(pos__);";
}
out << eb;
}
@@ -1432,7 +1432,7 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
else
{
out << sb;
- out << nl << "int szx__ = " << stream << ".readAndCheckSeqSize("
+ out << nl << "int szx__ = " << stream << ".readAndCheckSeqSize("
<< static_cast<unsigned>(type->minWireSize()) << ");";
out << nl << param << " = new ";
if(isArray)
@@ -1575,7 +1575,7 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
else
{
out << sb;
- out << nl << "int szx__ = " << stream << ".readAndCheckSeqSize("
+ out << nl << "int szx__ = " << stream << ".readAndCheckSeqSize("
<< static_cast<unsigned>(type->minWireSize()) << ");";
if(isArray)
{
@@ -1692,7 +1692,7 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
else
{
out << sb;
- out << nl << "int szx__ = " << stream << ".readAndCheckSeqSize(" <<
+ out << nl << "int szx__ = " << stream << ".readAndCheckSeqSize(" <<
static_cast<unsigned>(type->minWireSize()) << ");";
if(isArray)
{
@@ -1954,9 +1954,9 @@ Slice::CsGenerator::writeOptionalSequenceMarshalUnmarshalCode(Output& out,
out << nl << "if(" << param << ".HasValue && " << stream << ".writeOpt(" << tag << ", "
<< getOptionalFormat(seq) << "))";
out << sb;
- out << nl << stream << ".startSize();";
+ out << nl << "int pos__ = " << stream << ".startSize();";
writeSequenceMarshalUnmarshalCode(out, seq, param + ".Value", marshal, streamingAPI, true);
- out << nl << stream << ".endSize();";
+ out << nl << stream << ".endSize(pos__);";
out << eb;
}
else
@@ -1994,7 +1994,7 @@ Slice::CsGenerator::writeOptionalSequenceMarshalUnmarshalCode(Output& out,
out << sb;
if(st->isVariableLength())
{
- out << nl << stream << ".startSize();";
+ out << nl << "int pos__ = " << stream << ".startSize();";
}
else if(st->minWireSize() > 1)
{
@@ -2004,7 +2004,7 @@ Slice::CsGenerator::writeOptionalSequenceMarshalUnmarshalCode(Output& out,
writeSequenceMarshalUnmarshalCode(out, seq, param + ".Value", marshal, streamingAPI, true);
if(st->isVariableLength())
{
- out << nl << stream << ".endSize();";
+ out << nl << stream << ".endSize(pos__);";
}
out << eb;
}
@@ -2041,9 +2041,9 @@ Slice::CsGenerator::writeOptionalSequenceMarshalUnmarshalCode(Output& out,
out << nl << "if(" << param << ".HasValue && " << stream << ".writeOpt(" << tag << ", "
<< getOptionalFormat(seq) << "))";
out << sb;
- out << nl << stream << ".startSize();";
+ out << nl << "int pos__ = " << stream << ".startSize();";
writeSequenceMarshalUnmarshalCode(out, seq, param + ".Value", marshal, streamingAPI, true);
- out << nl << stream << ".endSize();";
+ out << nl << stream << ".endSize(pos__);";
out << eb;
}
else
diff --git a/cpp/src/Slice/JavaUtil.cpp b/cpp/src/Slice/JavaUtil.cpp
index cba34e6d2e8..273feb76251 100644
--- a/cpp/src/Slice/JavaUtil.cpp
+++ b/cpp/src/Slice/JavaUtil.cpp
@@ -31,7 +31,7 @@ using namespace std;
using namespace Slice;
using namespace IceUtil;
using namespace IceUtilInternal;
-
+
namespace
{
@@ -41,7 +41,7 @@ hashAdd(long& hashCode, const std::string& value)
for(std::string::const_iterator p = value.begin(); p != value.end(); ++p)
{
hashCode = ((hashCode << 5) + hashCode) ^ *p;
- }
+ }
}
}
@@ -65,7 +65,7 @@ Slice::computeSerialVersionUUID(const ClassDefPtr& p)
}
}
os << "]";
-
+
os << " Members: [";
DataMemberList members = p->dataMembers();
for(DataMemberList::const_iterator i = members.begin(); i != members.end();)
@@ -78,7 +78,7 @@ Slice::computeSerialVersionUUID(const ClassDefPtr& p)
}
}
os << "]";
-
+
const string data = os.str();
long hashCode = 5381;
hashAdd(hashCode, data);
@@ -103,7 +103,7 @@ Slice::computeSerialVersionUUID(const StructPtr& p)
}
}
os << "]";
-
+
const string data = os.str();
long hashCode = 5381;
hashAdd(hashCode, data);
@@ -128,7 +128,7 @@ Slice::computeSerialVersionUUID(const ExceptionPtr& p)
}
}
os << "]";
-
+
const string data = os.str();
long hashCode = 5381;
hashAdd(hashCode, data);
@@ -203,7 +203,7 @@ Slice::JavaOutput::openClass(const string& cls, const string& prefix, const stri
}
#ifdef _WIN32
result = _mkdir(path.c_str());
-#else
+#else
result = mkdir(path.c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
#endif
if(result != 0)
@@ -338,7 +338,7 @@ lookupKwd(const string& name)
//
// NOTE: Any changes made to this list must also be made in BasicStream.java.
//
- static const string keywordList[] =
+ static const string keywordList[] =
{
"abstract", "assert", "boolean", "break", "byte", "case", "catch",
"char", "checkedCast", "class", "clone", "const", "continue", "default", "do",
@@ -1205,9 +1205,9 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out,
}
else if(mode == OptionalMember)
{
- out << nl << stream << ".startSize();";
+ out << nl << "int __pos = " << stream << ".startSize();";
out << nl << stream << ".writeProxy(" << v << ");";
- out << nl << stream << ".endSize();";
+ out << nl << stream << ".endSize(__pos);";
}
else
{
@@ -1254,26 +1254,26 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out,
out << nl << "if(" << v << " != null && " << v << ".isSet() && " << stream << ".writeOpt(" << tag
<< ", " << getOptionalFormat(type) << "))";
out << sb;
- out << nl << stream << ".startSize();";
+ out << nl << "int __pos = " << stream << ".startSize();";
out << nl << typeS << "Helper.__write(" << stream << ", " << v << ".get());";
- out << nl << stream << ".endSize();";
+ out << nl << stream << ".endSize(__pos);";
out << eb;
}
else
{
out << nl << "if(" << stream << ".writeOpt(" << tag << ", " << getOptionalFormat(type) << "))";
out << sb;
- out << nl << stream << ".startSize();";
+ out << nl << "int __pos = " << stream << ".startSize();";
out << nl << typeS << "Helper.__write(" << stream << ", " << v << ");";
- out << nl << stream << ".endSize();";
+ out << nl << stream << ".endSize(__pos);";
out << eb;
}
}
else if(mode == OptionalMember)
{
- out << nl << stream << ".startSize();";
+ out << nl << "int __pos = " << stream << ".startSize();";
out << nl << typeS << "Helper.__write(" << stream << ", " << v << ");";
- out << nl << stream << ".endSize();";
+ out << nl << stream << ".endSize(__pos);";
}
else
{
@@ -1396,9 +1396,9 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out,
if(st->isVariableLength())
{
- out << nl << stream << ".startSize();";
+ out << nl << "int __pos = " << stream << ".startSize();";
out << nl << val << ".__write(" << stream << ");";
- out << nl << stream << ".endSize();";
+ out << nl << stream << ".endSize(__pos);";
}
else
{
@@ -1553,9 +1553,9 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out,
if(keyType->isVariableLength() || valueType->isVariableLength())
{
string d = optionalParam && optionalMapping ? v + ".get()" : v;
- out << nl << stream << ".startSize();";
+ out << nl << "int __pos = " << stream << ".startSize();";
writeDictionaryMarshalUnmarshalCode(out, package, dict, d, marshal, iter, true, metaData);
- out << nl << stream << ".endSize();";
+ out << nl << stream << ".endSize(__pos);";
}
else
{
@@ -1712,9 +1712,9 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out,
if(elemType->isVariableLength())
{
string s = optionalParam && optionalMapping ? v + ".get()" : v;
- out << nl << stream << ".startSize();";
+ out << nl << "int __pos = " << stream << ".startSize();";
writeSequenceMarshalUnmarshalCode(out, package, seq, s, marshal, iter, true, metaData);
- out << nl << stream << ".endSize();";
+ out << nl << stream << ".endSize(__pos);";
}
else if(findMetaData("java:type:", metaData, ignore) ||
findMetaData("java:type:", seq->getMetaData(), ignore))
@@ -2364,7 +2364,7 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
{
isObject = true;
}
- out << nl << "final int __len" << iter << " = " << stream << ".readAndCheckSeqSize("
+ out << nl << "final int __len" << iter << " = " << stream << ".readAndCheckSeqSize("
<< type->minWireSize() << ");";
if(isObject)
{
@@ -2608,9 +2608,9 @@ Slice::JavaGenerator::writeStreamMarshalUnmarshalCode(Output& out,
{
if(optional)
{
- out << nl << stream << ".startSize();";
+ out << nl << "int __pos = " << stream << ".startSize();";
out << nl << stream << ".writeProxy(" << v << ");";
- out << nl << stream << ".endSize();";
+ out << nl << stream << ".endSize(__pos);";
}
else
{
@@ -2644,9 +2644,9 @@ Slice::JavaGenerator::writeStreamMarshalUnmarshalCode(Output& out,
{
if(optional)
{
- out << nl << stream << ".startSize();";
+ out << nl << "int __pos = " << stream << ".startSize();";
out << nl << typeS << "Helper.write(" << stream << ", " << v << ");";
- out << nl << stream << ".endSize();";
+ out << nl << stream << ".endSize(__pos);";
}
else
{
@@ -2701,9 +2701,9 @@ Slice::JavaGenerator::writeStreamMarshalUnmarshalCode(Output& out,
{
if(st->isVariableLength())
{
- out << nl << stream << ".startSize();";
+ out << nl << "int __pos = " << stream << ".startSize();";
out << nl << v << ".ice_write(" << stream << ");";
- out << nl << stream << ".endSize();";
+ out << nl << stream << ".endSize(__pos);";
}
else
{
@@ -2769,9 +2769,9 @@ Slice::JavaGenerator::writeStreamMarshalUnmarshalCode(Output& out,
{
if(keyType->isVariableLength() || valueType->isVariableLength())
{
- out << nl << stream << ".startSize();";
+ out << nl << "int __pos = " << stream << ".startSize();";
writeStreamDictionaryMarshalUnmarshalCode(out, package, dict, v, marshal, iter, true, metaData);
- out << nl << stream << ".endSize();";
+ out << nl << stream << ".endSize(__pos);";
}
else
{
@@ -2818,9 +2818,9 @@ Slice::JavaGenerator::writeStreamMarshalUnmarshalCode(Output& out,
{
if(elemType->isVariableLength())
{
- out << nl << stream << ".startSize();";
+ out << nl << "int __pos = " << stream << ".startSize();";
writeStreamSequenceMarshalUnmarshalCode(out, package, seq, v, marshal, iter, true, metaData);
- out << nl << stream << ".endSize();";
+ out << nl << stream << ".endSize(__pos);";
}
else if(findMetaData("java:type:", metaData, ignore) ||
findMetaData("java:type:", seq->getMetaData(), ignore))
@@ -3446,7 +3446,7 @@ Slice::JavaGenerator::writeStreamSequenceMarshalUnmarshalCode(Output& out,
{
isObject = true;
}
- out << nl << "final int __len" << iter << " = " << stream << ".readAndCheckSeqSize("
+ out << nl << "final int __len" << iter << " = " << stream << ".readAndCheckSeqSize("
<< type->minWireSize() << ");";
if(isObject)
{
diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp
index 5681d37eb52..adaeb38b502 100644
--- a/cpp/src/slice2cs/Gen.cpp
+++ b/cpp/src/slice2cs/Gen.cpp
@@ -316,12 +316,12 @@ Slice::CsVisitor::writeStreamMarshalDataMember(const DataMemberPtr& member, cons
_out << sb;
if(builtin->kind() == Builtin::KindObjectProxy)
{
- _out << nl << "outS__.startSize();";
+ _out << nl << "int pos__ = outS__.startSize();";
}
writeMarshalUnmarshalCode(_out, member->type(), value, true, true);
if(builtin->kind() == Builtin::KindObjectProxy)
{
- _out << nl << "outS__.endSize();";
+ _out << nl << "outS__.endSize(pos__);";
}
_out << eb;
return;
@@ -366,9 +366,9 @@ Slice::CsVisitor::writeStreamMarshalDataMember(const DataMemberPtr& member, cons
case Builtin::KindObject:
case Builtin::KindObjectProxy:
{
- _out << nl << "outS__.startSize();";
+ _out << nl << "int pos__ = outS__.startSize();";
writeMarshalUnmarshalCode(_out, member->type(), value, true, true);
- _out << nl << "outS__.endSize();";
+ _out << nl << "outS__.endSize(pos__);";
break;
}
case Builtin::KindLocalObject:
@@ -389,9 +389,9 @@ Slice::CsVisitor::writeStreamMarshalDataMember(const DataMemberPtr& member, cons
}
else
{
- _out << nl << "outS__.startSize();";
+ _out << nl << "int pos__ = outS__.startSize();";
writeMarshalUnmarshalCode(_out, member->type(), value, true, true);
- _out << nl << "outS__.endSize();";
+ _out << nl << "outS__.endSize(pos__);";
}
}
@@ -408,7 +408,7 @@ Slice::CsVisitor::writeStreamMarshalDataMember(const DataMemberPtr& member, cons
if(d->keyType()->isVariableLength() || d->valueType()->isVariableLength())
{
- _out << nl << "outS__.startSize();";
+ _out << nl << "int pos__ = outS__.startSize();";
}
else
{
@@ -420,7 +420,7 @@ Slice::CsVisitor::writeStreamMarshalDataMember(const DataMemberPtr& member, cons
writeMarshalUnmarshalCode(_out, member->type(), value, true, true);
if(d->keyType()->isVariableLength() || d->valueType()->isVariableLength())
{
- _out << nl << "outS__.endSize();";
+ _out << nl << "outS__.endSize(pos__);";
}
_out << eb;
return;
@@ -435,7 +435,7 @@ Slice::CsVisitor::writeStreamMarshalDataMember(const DataMemberPtr& member, cons
if(st->isVariableLength())
{
- _out << nl << "outS__.startSize();";
+ _out << nl << "int pos__ = outS__.startSize();";
}
else
{
@@ -445,7 +445,7 @@ Slice::CsVisitor::writeStreamMarshalDataMember(const DataMemberPtr& member, cons
writeMarshalUnmarshalCode(_out, member->type(), value, true, true);
if(st->isVariableLength())
{
- _out << nl << "outS__.endSize();";
+ _out << nl << "outS__.endSize(pos__);";
}
_out << eb;
return;
@@ -468,9 +468,9 @@ Slice::CsVisitor::writeStreamMarshalDataMember(const DataMemberPtr& member, cons
_out << nl << "if(" << flag << " && outS__.writeOptional(" << member->tag() << ", "
<< getOptionalFormat(member->type()) << "))";
_out << sb;
- _out << nl << "outS__.startSize();";
+ _out << nl << "int pos__ = outS__.startSize();";
writeMarshalUnmarshalCode(_out, member->type(), value, true, true);
- _out << nl << "outS__.endSize();";
+ _out << nl << "outS__.endSize(pos__);";
_out << eb;
return;
}
@@ -1314,9 +1314,9 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p, bool stream)
emitGeneratedCodeAttribute();
_out << nl << "public virtual void ice_postUnmarshal()";
_out << sb;
- _out << eb;
+ _out << eb;
}
-
+
if(preserved && !basePreserved)
{
_out << sp;
@@ -1476,7 +1476,7 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p, bool stream)
}
else
{
- _out << sp << nl << "internal Patcher__(string type, Ice.Object instance";
+ _out << sp << nl << "internal Patcher__(string type, Ice.Object instance";
}
if(allClassMembers.size() > 1)
@@ -1560,7 +1560,7 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p, bool stream)
_out << eb;
}
-
+
_out << sp;
if(!p->isInterface())
{
@@ -3902,7 +3902,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
}
_out << eb;
}
-
+
if((!base || (base && !base->usesClasses(false))) && p->usesClasses(false))
{
_out << sp;
@@ -5153,7 +5153,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
for(ParamDeclList::const_iterator pli = outParams.begin(); pli != outParams.end(); ++pli)
{
const bool isClass = isClassType((*pli)->type());
-
+
if(!(*pli)->optional() && !isClass)
{
StructPtr st = StructPtr::dynamicCast((*pli)->type());
@@ -5176,9 +5176,9 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
{
string typeS = typeToString(ret, op->returnIsOptional());
const bool isClass = isClassType(ret);
-
+
_out << nl << typeS << " ret__;";
-
+
if(op->returnIsOptional())
{
BuiltinPtr b = BuiltinPtr::dynamicCast(ret);