summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2012-09-24 17:01:05 -0400
committerBernard Normier <bernard@zeroc.com>2012-09-24 17:01:05 -0400
commitcc15ebed97ad43d9f2b04e73c8555ac4b2a3a0a3 (patch)
treeccf84d02fe6defae4995259028d4bacd4a403ee4 /cpp
parentPartial fix for ICE-3393: (diff)
downloadice-cc15ebed97ad43d9f2b04e73c8555ac4b2a3a0a3.tar.bz2
ice-cc15ebed97ad43d9f2b04e73c8555ac4b2a3a0a3.tar.xz
ice-cc15ebed97ad43d9f2b04e73c8555ac4b2a3a0a3.zip
Replaced optionalType in StreamTrait<> by a bool fixedLength member
and updated slice2cpp accordingly No longer rely on assert / static_assert to detect incorrect use of base StreamOptionalHelper: now, the code no longer compiles vector<bool> is now handled like a built-in type: InputStream and OutputStream have now read / write vector<bool>& functions. The default implementation (StreamI) simply delegates to the same functions on BasicStream.
Diffstat (limited to 'cpp')
-rw-r--r--cpp/include/Ice/BasicStream.h8
-rw-r--r--cpp/include/Ice/Stream.h59
-rw-r--r--cpp/include/Ice/StreamTraits.h243
-rw-r--r--cpp/src/Ice/StreamI.cpp12
-rw-r--r--cpp/src/Ice/StreamI.h29
-rw-r--r--cpp/src/Slice/CPlusPlusUtil.cpp7
-rw-r--r--cpp/src/slice2cpp/Gen.cpp12
7 files changed, 196 insertions, 174 deletions
diff --git a/cpp/include/Ice/BasicStream.h b/cpp/include/Ice/BasicStream.h
index 77b2d4dec56..5d817e0c3be 100644
--- a/cpp/include/Ice/BasicStream.h
+++ b/cpp/include/Ice/BasicStream.h
@@ -518,19 +518,19 @@ public:
if(writeOpt(tag, Ice::StreamOptionalHelper<T,
Ice::StreamTrait<T>::type,
- Ice::StreamTrait<T>::optionalType>::optionalType))
+ Ice::StreamTrait<T>::fixedLength>::optionalType))
{
- Ice::StreamOptionalHelper<T, Ice::StreamTrait<T>::type, Ice::StreamTrait<T>::optionalType>::write(this, *v);
+ Ice::StreamOptionalHelper<T, Ice::StreamTrait<T>::type, Ice::StreamTrait<T>::fixedLength>::write(this, *v);
}
}
template<typename T> void read(Ice::Int tag, IceUtil::Optional<T>& v)
{
if(readOpt(tag, Ice::StreamOptionalHelper<T,
Ice::StreamTrait<T>::type,
- Ice::StreamTrait<T>::optionalType>::optionalType))
+ Ice::StreamTrait<T>::fixedLength>::optionalType))
{
v.__setIsSet();
- Ice::StreamOptionalHelper<T, Ice::StreamTrait<T>::type, Ice::StreamTrait<T>::optionalType>::read(this, *v);
+ Ice::StreamOptionalHelper<T, Ice::StreamTrait<T>::type, Ice::StreamTrait<T>::fixedLength>::read(this, *v);
}
else
{
diff --git a/cpp/include/Ice/Stream.h b/cpp/include/Ice/Stream.h
index e5dc75b074c..9dda1497006 100644
--- a/cpp/include/Ice/Stream.h
+++ b/cpp/include/Ice/Stream.h
@@ -97,28 +97,6 @@ public:
virtual void sliceObjects(bool) = 0;
- //
- // Sequences of bool are handled specifically because C++
- // optimizations for vector<bool> prevent us from reading vector
- // of bools the same way as other sequences.
- //
- void
- read(std::vector<bool>& v)
- {
- Int sz = readAndCheckSeqSize(StreamTrait<bool>::minWireSize);
- v.resize(sz);
- for(std::vector<bool>::iterator p = v.begin(); p != v.end(); ++p)
- {
- //
- // We can't just call inS->read(*p) here because *p is
- // a compiler dependent bit reference.
- //
- bool b;
- read(b);
- *p = b;
- }
- }
-
virtual Int readSize() = 0;
virtual Int readAndCheckSeqSize(int) = 0;
@@ -209,7 +187,12 @@ public:
virtual void read(::std::string&, bool = true) = 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
+ //
+ virtual void read(::std::vector<bool>&) = 0;
+
virtual void read(::std::pair<const bool*, const bool*>&, ::IceUtil::ScopedArray<bool>&) = 0;
virtual void read(::std::pair<const Byte*, const Byte*>&) = 0;
virtual void read(::std::pair<const Short*, const Short*>&, ::IceUtil::ScopedArray<Short>&) = 0;
@@ -229,10 +212,10 @@ public:
{
if(readOptional(tag, StreamOptionalHelper<T,
Ice::StreamTrait<T>::type,
- Ice::StreamTrait<T>::optionalType>::optionalType))
+ Ice::StreamTrait<T>::fixedLength>::optionalType))
{
v.__setIsSet();
- StreamOptionalHelper<T, Ice::StreamTrait<T>::type, Ice::StreamTrait<T>::optionalType>::read(this, *v);
+ StreamOptionalHelper<T, Ice::StreamTrait<T>::type, Ice::StreamTrait<T>::fixedLength>::read(this, *v);
}
}
@@ -324,6 +307,11 @@ public:
virtual void write(const char*, bool = true) = 0;
virtual void write(const ::std::wstring&) = 0;
+ //
+ // std::vector<bool> is a special C++ type, so we give it its own write function
+ //
+ virtual void write(const ::std::vector<bool>&) = 0;
+
virtual void write(const bool*, const bool*) = 0;
virtual void write(const Byte*, const Byte*) = 0;
virtual void write(const Short*, const Short*) = 0;
@@ -337,23 +325,6 @@ public:
virtual void startSize() = 0;
virtual void endSize() = 0;
-//
-// COMPILER FIX: clang using libc++ cannot use the StreamHelper to write
-// vector<bool>, as vector<bool> get optimized to
-// __bit_const_reference that has not size member function.
-//
-#if defined(__clang__) && defined(_LIBCPP_VERSION)
- virtual void write(const ::std::vector<bool>& v)
- {
- writeSize(static_cast<Int>(v.size()));
- for(::std::vector<bool>::const_iterator p = v.begin(); p != v.end(); ++p)
- {
- bool v = (*p);
- write(v);
- }
- }
-#endif
-
template<typename T> inline void write(const T& v)
{
StreamHelper<T, StreamTrait<T>::type>::write(this, v);
@@ -365,8 +336,8 @@ public:
{
writeOptional(tag, StreamOptionalHelper<T,
Ice::StreamTrait<T>::type,
- Ice::StreamTrait<T>::optionalType>::optionalType);
- StreamOptionalHelper<T, Ice::StreamTrait<T>::type, Ice::StreamTrait<T>::optionalType>::write(this, *v);
+ Ice::StreamTrait<T>::fixedLength>::optionalType);
+ StreamOptionalHelper<T, Ice::StreamTrait<T>::type, Ice::StreamTrait<T>::fixedLength>::write(this, *v);
}
}
diff --git a/cpp/include/Ice/StreamTraits.h b/cpp/include/Ice/StreamTraits.h
index 16dfe6a3963..2316964d782 100644
--- a/cpp/include/Ice/StreamTraits.h
+++ b/cpp/include/Ice/StreamTraits.h
@@ -104,31 +104,18 @@ struct StreamTrait
//
// When extracting a sequence<T> from a stream, we can ensure the
- // stream as at least StreamTrait<T>::minWireSize * size bytes
- // For containers, the minWireSize is 1 - just 1 byte for an empty container.
+ // stream has at least StreamTrait<T>::minWireSize * size bytes
+ // For containers, the minWireSize is 1--just 1 byte for an empty container.
//
static const int minWireSize = 1;
//
- // The OptionalType, for reading/writing optional T from/to the stream
- // For containers, it can be either OptionalTypeVSize or OptionalTypeFSize
- // depending on whether the contained element is fixed size or not.
- // We can't easily compute it here, so we set optionalType to OptionalTypeEndMarker
- // and compute the correct optionalType for the container in the StreamOptionalHelpers
- // below.
+ // Is this type encoded on a fixed number of bytes?
+ // Used only for marshaling/unmarshaling optional data members and parameters.
//
- static const OptionalType optionalType = OptionalTypeEndMarker;
+ static const bool fixedLength = false;
};
-template<typename T>
-struct IsFixedLength
-{
- typedef StreamTrait<T> Traits;
-
- static const bool value = (Traits::optionalType <= OptionalTypeF8)
- || ((Traits::type == StreamTraitTypeStruct || Traits::type == StreamTraitTypeStructClass)
- && Traits::optionalType == OptionalTypeVSize);
-};
//
// StreamTrait specialization for array / range mapped sequences
@@ -140,7 +127,7 @@ struct StreamTrait< ::std::pair<T, U> >
{
static const StreamTraitType type = StreamTraitTypeSequence;
static const int minWireSize = 1;
- static const OptionalType optionalType = OptionalTypeEndMarker;
+ static const bool fixedLength = false;
};
//
@@ -153,21 +140,21 @@ struct StreamTrait<UserException>
//
// There is no sequence/dictionary of UserException (so no need for minWireSize)
- // and no optional UserException (so no need for optionalType)
+ // and no optional UserException (so no need for fixedLength)
//
};
//
// StreamTrait specialization for builtins (these are needed for sequence
-// marshalling to figure out the minWireSize of each built-in).
+// marshaling to figure out the minWireSize of each built-in).
//
template<>
struct StreamTrait<bool>
{
static const StreamTraitType type = StreamTraitTypeBuiltin;
static const int minWireSize = 1;
- static const OptionalType optionalType = OptionalTypeF1;
+ static const bool fixedLength = true;
};
template<>
@@ -175,7 +162,7 @@ struct StreamTrait<Byte>
{
static const StreamTraitType type = StreamTraitTypeBuiltin;
static const int minWireSize = 1;
- static const OptionalType optionalType = OptionalTypeF1;
+ static const bool fixedLength = true;
};
template<>
@@ -183,7 +170,7 @@ struct StreamTrait<Short>
{
static const StreamTraitType type = StreamTraitTypeBuiltin;
static const int minWireSize = 2;
- static const OptionalType optionalType = OptionalTypeF2;
+ static const bool fixedLength = true;
};
template<>
@@ -191,7 +178,7 @@ struct StreamTrait<Int>
{
static const StreamTraitType type = StreamTraitTypeBuiltin;
static const int minWireSize = 4;
- static const OptionalType optionalType = OptionalTypeF4;
+ static const bool fixedLength = true;
};
template<>
@@ -199,7 +186,7 @@ struct StreamTrait<Long>
{
static const StreamTraitType type = StreamTraitTypeBuiltin;
static const int minWireSize = 8;
- static const OptionalType optionalType = OptionalTypeF8;
+ static const bool fixedLength = true;
};
template<>
@@ -207,7 +194,7 @@ struct StreamTrait<Float>
{
static const StreamTraitType type = StreamTraitTypeBuiltin;
static const int minWireSize = 4;
- static const OptionalType optionalType = OptionalTypeF4;
+ static const bool fixedLength = true;
};
template<>
@@ -215,7 +202,7 @@ struct StreamTrait<Double>
{
static const StreamTraitType type = StreamTraitTypeBuiltin;
static const int minWireSize = 8;
- static const OptionalType optionalType = OptionalTypeF8;
+ static const bool fixedLength = true;
};
template<>
@@ -223,7 +210,7 @@ struct StreamTrait< ::std::string>
{
static const StreamTraitType type = StreamTraitTypeBuiltin;
static const int minWireSize = 1;
- static const OptionalType optionalType = OptionalTypeVSize;
+ static const bool fixedLength = false;
};
template<>
@@ -231,15 +218,28 @@ struct StreamTrait< ::std::wstring>
{
static const StreamTraitType type = StreamTraitTypeBuiltin;
static const int minWireSize = 1;
- static const OptionalType optionalType = OptionalTypeVSize;
+ static const bool fixedLength = false;
+};
+
+//
+// vector<bool> is a special type in C++: the streams are responsible
+// to handle it like a built-in type.
+//
+template<>
+struct StreamTrait< ::std::vector<bool> >
+{
+ static const StreamTraitType type = StreamTraitTypeBuiltin;
+ static const int minWireSize = 1;
+ static const bool fixedLength = false;
};
+
template<typename T>
struct StreamTrait< ::IceInternal::ProxyHandle<T> >
{
static const StreamTraitType type = StreamTraitTypeProxy;
static const int minWireSize = 2;
- static const OptionalType optionalType = OptionalTypeFSize;
+ static const bool fixedLength = false;
};
template<typename T>
@@ -247,10 +247,9 @@ struct StreamTrait< ::IceInternal::Handle<T> >
{
static const StreamTraitType type = StreamTraitTypeClass;
static const int minWireSize = 1;
- static const OptionalType optionalType = OptionalTypeSize;
+ static const bool fixedLength = false;
};
-
//
// StreamHelper templates used by streams to read and write data.
//
@@ -388,7 +387,7 @@ struct StreamHelper<std::pair<T, T>, StreamTraitTypeSequence>
template<class S> static inline void
write(S* stream, const std::pair<T, T>& v)
{
- stream->writeSize(static_cast< ::Ice::Int>(IceUtilInternal::distance(v.first, v.second)));
+ stream->writeSize(static_cast<Int>(IceUtilInternal::distance(v.first, v.second)));
for(T p = v.first; p != v.second; ++p)
{
stream->write(*p);
@@ -410,7 +409,7 @@ struct StreamHelper<std::pair< ::std::vector<bool>::const_iterator,
write(S* stream, const std::pair< ::std::vector<bool>::const_iterator,
::std::vector<bool>::const_iterator>& v)
{
- stream->writeSize(static_cast< ::Ice::Int>(IceUtilInternal::distance(v.first, v.second)));
+ stream->writeSize(static_cast<Int>(IceUtilInternal::distance(v.first, v.second)));
for(::std::vector<bool>::const_iterator p = v.first; p != v.second; ++p)
{
stream->write(static_cast<bool>(*p));
@@ -515,42 +514,87 @@ struct StreamHelper<T, StreamTraitTypeClass>
// Helpers to read/write optional attributes or members.
//
-// Base helper
-template<typename T, StreamTraitType st, OptionalType ot>
+//
+// Extract / compute the optionalType
+// 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 StreamHelper
+//
+template<StreamTraitType st, int minWireSize, bool fixedLength>
+struct GetOptionalType;
+
+template<>
+struct GetOptionalType<StreamTraitTypeBuiltin, 1, true>
+{
+ static const OptionalType value = OptionalTypeF1;
+};
+
+template<>
+struct GetOptionalType<StreamTraitTypeBuiltin, 2, true>
+{
+ static const OptionalType value = OptionalTypeF2;
+};
+
+template<>
+struct GetOptionalType<StreamTraitTypeBuiltin, 4, true>
+{
+ static const OptionalType value = OptionalTypeF4;
+};
+
+template<>
+struct GetOptionalType<StreamTraitTypeBuiltin, 8, true>
+{
+ static const OptionalType value = OptionalTypeF8;
+};
+
+template<>
+struct GetOptionalType<StreamTraitTypeBuiltin, 1, false>
+{
+ static const OptionalType value = OptionalTypeVSize;
+};
+
+template<>
+struct GetOptionalType<StreamTraitTypeClass, 1, false>
+{
+ static const OptionalType value = OptionalTypeSize;
+};
+
+template<int minWireSize>
+struct GetOptionalType<StreamTraitTypeEnum, minWireSize, false>
+{
+ static const OptionalType value = OptionalTypeSize;
+};
+
+
+// Base helper: simply read/write the data
+template<typename T, StreamTraitType st, bool fixedLength>
struct StreamOptionalHelper
{
- static const OptionalType optionalType = ot;
+ typedef StreamTrait<T> Traits;
+
+ // If this optionalType fails to compile, you must either define your specialization
+ // for GetOptionalType (in which case the optional data will be marshaled/unmarshaled
+ // with straight calls to write/read on the stream), or define your own
+ // StreamOptionalHelper specialization (which gives you more control over marshaling)
+ //
+ static const OptionalType optionalType = GetOptionalType<st, Traits::minWireSize, fixedLength>::value;
template<class S> static inline void
write(S* stream, const T& v)
{
-#ifdef ICE_CPP11
- static_assert((ot != OptionalTypeVSize && ot != OptionalTypeFSize && ot != OptionalTypeEndMarker)
- || st == StreamTraitTypeBuiltin, "Bad helper");
-#else
- assert((ot != OptionalTypeVSize && ot != OptionalTypeFSize && ot != OptionalTypeEndMarker)
- || st == StreamTraitTypeBuiltin);
-#endif
- StreamHelper<T, st>::write(stream, v);
+ stream->write(v);
}
template<class S> static inline void
read(S* stream, T& v)
{
-#ifdef ICE_CPP11
- static_assert((ot != OptionalTypeVSize && ot != OptionalTypeFSize && ot != OptionalTypeEndMarker)
- || st == StreamTraitTypeBuiltin, "Bad helper");
-#else
- assert((ot != OptionalTypeVSize && ot != OptionalTypeFSize && ot != OptionalTypeEndMarker)
- || st == StreamTraitTypeBuiltin);
-#endif
- StreamHelper<T, st>::read(stream, v);
+ stream->read(v);
}
};
// Helper to write fixed size structs
template<typename T>
-struct StreamOptionalHelper<T, StreamTraitTypeStruct, OptionalTypeVSize>
+struct StreamOptionalHelper<T, StreamTraitTypeStruct, true>
{
static const OptionalType optionalType = OptionalTypeVSize;
@@ -571,7 +615,7 @@ struct StreamOptionalHelper<T, StreamTraitTypeStruct, OptionalTypeVSize>
// Helper to write variable size structs
template<typename T>
-struct StreamOptionalHelper<T, StreamTraitTypeStruct, OptionalTypeFSize>
+struct StreamOptionalHelper<T, StreamTraitTypeStruct, false>
{
static const OptionalType optionalType = OptionalTypeFSize;
@@ -593,22 +637,22 @@ struct StreamOptionalHelper<T, StreamTraitTypeStruct, OptionalTypeFSize>
};
// Class structs are encoded like structs
-template<typename T, OptionalType ot>
-struct StreamOptionalHelper<T, StreamTraitTypeStructClass, ot> : StreamOptionalHelper<T, StreamTraitTypeStruct, ot>
+template<typename T, bool fixedLength>
+struct StreamOptionalHelper<T, StreamTraitTypeStructClass, fixedLength> : StreamOptionalHelper<T, StreamTraitTypeStruct, fixedLength>
{
};
// Optional proxies are encoded like variable size structs, using the FSize encoding
template<typename T>
-struct StreamOptionalHelper<T, StreamTraitTypeProxy, OptionalTypeFSize> :
- StreamOptionalHelper<T, StreamTraitTypeStruct, OptionalTypeFSize>
+struct StreamOptionalHelper<T, StreamTraitTypeProxy, false> : StreamOptionalHelper<T, StreamTraitTypeStruct, false>
{
};
+
//
// Helpers to read/write optional sequences or dictionaries
//
-template<typename T, bool isFixedLength, int sz>
+template<typename T, bool fixedLength, int sz>
struct StreamOptionalContainerHelper;
//
@@ -623,15 +667,15 @@ struct StreamOptionalContainerHelper<T, false, sz>
static const OptionalType optionalType = OptionalTypeFSize;
template<class S> static inline void
- write(S* stream, const T& v, Ice::Int n)
+ write(S* stream, const T& v, Int)
{
- StreamOptionalHelper<T, StreamTraitTypeStruct, OptionalTypeFSize>::write(stream, v);
+ StreamOptionalHelper<T, StreamTraitTypeStruct, false>::write(stream, v);
}
template<class S> static inline void
read(S* stream, T& v)
{
- StreamOptionalHelper<T, StreamTraitTypeStruct, OptionalTypeFSize>::read(stream, v);
+ StreamOptionalHelper<T, StreamTraitTypeStruct, false>::read(stream, v);
}
};
@@ -646,7 +690,7 @@ struct StreamOptionalContainerHelper<T, true, sz>
static const OptionalType optionalType = OptionalTypeVSize;
template<class S> static inline void
- write(S* stream, const T& v, Ice::Int n)
+ write(S* stream, const T& v, Int n)
{
//
// The container size is the number of elements * the size of
@@ -677,112 +721,113 @@ struct StreamOptionalContainerHelper<T, true, 1>
static const OptionalType optionalType = OptionalTypeVSize;
template<class S> static inline void
- write(S* stream, const T& v, Ice::Int n)
+ write(S* stream, const T& v, Int)
{
- StreamOptionalHelper<T, StreamTraitTypeBuiltin, OptionalTypeVSize>::write(stream, v);
+ stream->write(v);
}
template<class S> static inline void
read(S* stream, T& v)
{
- StreamOptionalHelper<T, StreamTraitTypeBuiltin, OptionalTypeVSize>::read(stream, v);
+ stream->read(v);
}
};
+
//
// Helper to write sequences, delegates to the optional container
// helper template partial specializations.
//
-template<typename T, OptionalType ot>
-struct StreamOptionalHelper<T, StreamTraitTypeSequence, ot>
+template<typename T>
+struct StreamOptionalHelper<T, StreamTraitTypeSequence, false>
{
typedef typename T::value_type E;
static const int size = StreamTrait<E>::minWireSize;
- static const bool isFixedLength = IsFixedLength<E>::value;
+ static const bool fixedLength = StreamTrait<E>::fixedLength;
// The optional type of a sequence depends on whether or not elements are fixed
// or variable size elements and their size.
- static const OptionalType optionalType = StreamOptionalContainerHelper<T, isFixedLength, size>::optionalType;
+ static const OptionalType optionalType = StreamOptionalContainerHelper<T, fixedLength, size>::optionalType;
template<class S> static inline void
write(S* stream, const T& v)
{
- StreamOptionalContainerHelper<T, isFixedLength, size>::write(stream, v, static_cast<Int>(v.size()));
+ StreamOptionalContainerHelper<T, fixedLength, size>::write(stream, v, static_cast<Int>(v.size()));
}
template<class S> static inline void
read(S* stream, T& v)
{
- StreamOptionalContainerHelper<T, isFixedLength, size>::read(stream, v);
+ StreamOptionalContainerHelper<T, fixedLength, size>::read(stream, v);
}
};
-template<typename T, OptionalType ot>
-struct StreamOptionalHelper<std::pair<const T*, const T*>, StreamTraitTypeSequence, ot>
+template<typename T>
+struct StreamOptionalHelper<std::pair<const T*, const T*>, StreamTraitTypeSequence, false>
{
typedef std::pair<const T*, const T*> P;
static const int size = StreamTrait<T>::minWireSize;
- static const bool isFixedLength = IsFixedLength<T>::value;
+ static const bool fixedLength = StreamTrait<T>::fixedLength;
// The optional type of a sequence depends on whether or not elements are fixed
// or variable size elements and their size.
- static const OptionalType optionalType = StreamOptionalContainerHelper<P, isFixedLength, size>::optionalType;
+ static const OptionalType optionalType = StreamOptionalContainerHelper<P, fixedLength, size>::optionalType;
template<class S> static inline void
write(S* stream, const P& v)
{
- Ice::Int n = static_cast<Ice::Int>(v.second - v.first);
- StreamOptionalContainerHelper<P, isFixedLength, size>::write(stream, v, n);
+ Int n = static_cast<Int>(v.second - v.first);
+ StreamOptionalContainerHelper<P, fixedLength, size>::write(stream, v, n);
}
template<class S> static inline void
read(S* stream, P& v)
{
- StreamOptionalContainerHelper<P, isFixedLength, size>::read(stream, v);
+ StreamOptionalContainerHelper<P, fixedLength, size>::read(stream, v);
}
};
-template<typename T, OptionalType ot>
-struct StreamOptionalHelper<std::pair<T, T>, StreamTraitTypeSequence, ot>
+template<typename T>
+struct StreamOptionalHelper<std::pair<T, T>, StreamTraitTypeSequence, false>
{
typedef std::pair<T, T> P;
static const int size = StreamTrait<typename T::value_type>::minWireSize;
- static const bool isFixedLength = IsFixedLength<typename T::value_type>::value;
+ static const bool fixedLength = StreamTrait<typename T::value_type>::fixedLength;
// The optional type of a sequence depends on whether or not elements are fixed
// or variable size elements and their size.
- static const OptionalType optionalType = StreamOptionalContainerHelper<P, isFixedLength, size>::optionalType;
+ static const OptionalType optionalType = StreamOptionalContainerHelper<P, fixedLength, size>::optionalType;
template<class S> static inline void
write(S* stream, const P& v)
{
- Ice::Int n = static_cast<Ice::Int>(v.second - v.first);
- StreamOptionalContainerHelper<P, isFixedLength, size>::write(stream, v, n);
+ Int n = static_cast<Int>(v.second - v.first);
+ StreamOptionalContainerHelper<P, fixedLength, size>::write(stream, v, n);
}
template<class S> static inline void
read(S* stream, P& v)
{
- StreamOptionalContainerHelper<P, isFixedLength, size>::read(stream, v);
+ StreamOptionalContainerHelper<P, fixedLength, size>::read(stream, v);
}
};
-template<typename T, OptionalType ot>
+template<typename T>
struct StreamOptionalHelper<std::pair<IceUtil::ScopedArray<T>, std::pair<const T*, const T*> >,
- StreamTraitTypeSequence, ot>
+ StreamTraitTypeSequence, false>
{
typedef std::pair<IceUtil::ScopedArray<T>, std::pair<const T*, const T*> > P;
static const int size = StreamTrait<T>::minWireSize;
- static const bool isFixedLength = IsFixedLength<T>::value;
+ static const bool fixedLength = StreamTrait<T>::fixedLength;
// The optional type of a sequence depends on whether or not elements are fixed
// or variable size elements and their size.
- static const OptionalType optionalType = StreamOptionalContainerHelper<P, isFixedLength, size>::optionalType;
+ static const OptionalType optionalType = StreamOptionalContainerHelper<P, fixedLength, size>::optionalType;
template<class S> static inline void
read(S* stream, P& v)
{
- StreamOptionalContainerHelper<P, isFixedLength, size>::read(stream, v);
+ StreamOptionalContainerHelper<P, fixedLength, size>::read(stream, v);
}
// no write: only used for unmarshaling
@@ -792,29 +837,29 @@ struct StreamOptionalHelper<std::pair<IceUtil::ScopedArray<T>, std::pair<const T
// Helper to write dictionaries, delegates to the optional container
// helper template partial specializations.
//
-template<typename T, OptionalType ot>
-struct StreamOptionalHelper<T, StreamTraitTypeDictionary, ot>
+template<typename T>
+struct StreamOptionalHelper<T, StreamTraitTypeDictionary, false>
{
typedef typename T::key_type K;
typedef typename T::mapped_type V;
static const int size = StreamTrait<K>::minWireSize + StreamTrait<V>::minWireSize;
- static const bool isFixedLength = IsFixedLength<K>::value && IsFixedLength<V>::value;
+ static const bool fixedLength = StreamTrait<K>::fixedLength && StreamTrait<V>::fixedLength;
// The optional type of a dictionary depends on whether or not elements are fixed
// or variable size elements.
- static const OptionalType optionalType = StreamOptionalContainerHelper<T, isFixedLength, size>::optionalType;
+ static const OptionalType optionalType = StreamOptionalContainerHelper<T, fixedLength, size>::optionalType;
template<class S> static inline void
write(S* stream, const T& v)
{
- StreamOptionalContainerHelper<T, isFixedLength, size>::write(stream, v, static_cast<Int>(v.size()));
+ StreamOptionalContainerHelper<T, fixedLength, size>::write(stream, v, static_cast<Int>(v.size()));
}
template<class S> static inline void
read(S* stream, T& v)
{
- StreamOptionalContainerHelper<T, isFixedLength, size>::read(stream, v);
+ StreamOptionalContainerHelper<T, fixedLength, size>::read(stream, v);
}
};
diff --git a/cpp/src/Ice/StreamI.cpp b/cpp/src/Ice/StreamI.cpp
index 431926d64b0..0cb438049c7 100644
--- a/cpp/src/Ice/StreamI.cpp
+++ b/cpp/src/Ice/StreamI.cpp
@@ -235,6 +235,12 @@ InputStreamI::read(wstring& v)
}
void
+InputStreamI::read(vector<bool>& v)
+{
+ _is->read(v);
+}
+
+void
InputStreamI::read(pair<const bool*, const bool*>& p, ::IceUtil::ScopedArray<bool>& result)
{
result.reset(_is->read(p));
@@ -528,6 +534,12 @@ OutputStreamI::write(const wstring& v)
_os->write(v);
}
+void
+OutputStreamI::write(const vector<bool>& v)
+{
+ _os->write(v);
+}
+
void
OutputStreamI::write(const bool* begin, const bool* end)
{
diff --git a/cpp/src/Ice/StreamI.h b/cpp/src/Ice/StreamI.h
index ba0d103a640..496b01aeb19 100644
--- a/cpp/src/Ice/StreamI.h
+++ b/cpp/src/Ice/StreamI.h
@@ -30,8 +30,8 @@ class InputStreamI : public InputStream
{
public:
- InputStreamI(const CommunicatorPtr&, const std::vector< Byte >&);
- InputStreamI(const CommunicatorPtr&, const std::pair< const Byte*, const Byte* >&);
+ InputStreamI(const CommunicatorPtr&, const std::vector<Byte>&);
+ InputStreamI(const CommunicatorPtr&, const std::pair<const Byte*, const Byte*>&);
virtual ~InputStreamI();
virtual CommunicatorPtr communicator() const;
@@ -70,16 +70,17 @@ public:
virtual void skip(Ice::Int);
virtual void skipSize();
- virtual void read(bool& v);
- virtual void read(Byte& v);
- virtual void read(Short& v);
- virtual void read(Int& v);
- virtual void read(Long& v);
- virtual void read(Float& v);
- virtual void read(Double& v);
- virtual void read(std::string& v, bool convert = true);
+ virtual void read(bool&);
+ virtual void read(Byte&);
+ virtual void read(Short&);
+ virtual void read(Int&);
+ virtual void read(Long&);
+ virtual void read(Float&);
+ virtual void read(Double&);
+ virtual void read(std::string&, bool = true);
virtual void read(std::vector<std::string>&, bool);
- virtual void read(std::wstring& v);
+ virtual void read(std::wstring&);
+ virtual void read(std::vector<bool>&);
virtual void read(std::pair<const bool*, const bool*>&, ::IceUtil::ScopedArray<bool>&);
virtual void read(std::pair<const Byte*, const Byte*>&);
virtual void read(std::pair<const Short*, const Short*>&, ::IceUtil::ScopedArray<Short>&);
@@ -132,9 +133,9 @@ public:
virtual void write(Double);
virtual void write(const std::string&, bool = true);
virtual void write(const std::vector<std::string>&, bool);
- virtual void write(const char* v, bool = true);
- virtual void write(const std::wstring& v);
-
+ virtual void write(const char*, bool = true);
+ virtual void write(const std::wstring&);
+ virtual void write(const std::vector<bool>&);
virtual void write(const bool*, const bool*);
virtual void write(const Byte*, const Byte*);
virtual void write(const Short*, const Short*);
diff --git a/cpp/src/Slice/CPlusPlusUtil.cpp b/cpp/src/Slice/CPlusPlusUtil.cpp
index 83fb812cd20..086e839b195 100644
--- a/cpp/src/Slice/CPlusPlusUtil.cpp
+++ b/cpp/src/Slice/CPlusPlusUtil.cpp
@@ -105,13 +105,6 @@ sequenceTypeToString(const SequencePtr& seq, const StringList& metaData, int typ
}
else
{
- // Get the metadata associated at the point of definition.
- seqType = findMetaData(seq->getMetaData(), typeCtx);
- if(!seqType.empty())
- {
- return seqType;
- }
-
return fixKwd(seq->scoped());
}
}
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index d67d8aa3256..e46b5aeae43 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -6096,20 +6096,20 @@ Slice::Gen::StreamVisitor::visitStructStart(const StructPtr& p)
H << sb;
if(classMetaData)
{
- H << nl << "static const ::Ice::StreamTraitType type = ::Ice::StreamTraitTypeStructClass;";
+ H << nl << "static const StreamTraitType type = StreamTraitTypeStructClass;";
}
else
{
- H << nl << "static const ::Ice::StreamTraitType type = ::Ice::StreamTraitTypeStruct;";
+ H << nl << "static const StreamTraitType type = StreamTraitTypeStruct;";
}
H << nl << "static const int minWireSize = " << p->minWireSize() << ";";
if(p->isVariableLength())
{
- H << nl << "static const ::Ice::OptionalType optionalType = ::Ice::OptionalTypeFSize;";
+ H << nl << "static const bool fixedLength = false;";
}
else
{
- H << nl << "static const ::Ice::OptionalType optionalType = ::Ice::OptionalTypeVSize;";
+ H << nl << "static const bool fixedLength = true;";
}
H << eb << ";" << nl;
}
@@ -6123,10 +6123,10 @@ Slice::Gen::StreamVisitor::visitEnum(const EnumPtr& p)
H << nl << "template<>";
H << nl << "struct StreamTrait< " << scoped << ">";
H << sb;
- H << nl << "static const ::Ice::StreamTraitType type = ::Ice::StreamTraitTypeEnum;";
+ H << nl << "static const StreamTraitType type = StreamTraitTypeEnum;";
H << nl << "static const int enumLimit = " << p->getEnumerators().size() << ";";
H << nl << "static const int minWireSize = " << p->minWireSize() << ";";
- H << nl << "static const ::Ice::OptionalType optionalType = ::Ice::OptionalTypeSize;";
+ H << nl << "static const bool fixedLength = false;";
H << eb << ";" << nl;
}