summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2002-02-13 00:47:50 +0000
committerMark Spruiell <mes@zeroc.com>2002-02-13 00:47:50 +0000
commit8df1c85f81b1586570c47060a6d8ae7eaf6d33b9 (patch)
tree77768fb509cf428dc90a34872970eeddedd4122e /cpp
parentminor fixes (diff)
downloadice-8df1c85f81b1586570c47060a6d8ae7eaf6d33b9.tar.bz2
ice-8df1c85f81b1586570c47060a6d8ae7eaf6d33b9.tar.xz
ice-8df1c85f81b1586570c47060a6d8ae7eaf6d33b9.zip
revising Stream.ice to remove out params
Diffstat (limited to 'cpp')
-rw-r--r--cpp/include/IceXML/StreamI.h43
-rw-r--r--cpp/slice/Ice/Stream.ice84
-rw-r--r--cpp/src/Ice/Object.cpp9
-rw-r--r--cpp/src/IceXML/StreamI.cpp179
-rw-r--r--cpp/src/Slice/CPlusPlusUtil.cpp34
-rw-r--r--cpp/src/slice2cpp/Gen.cpp12
-rw-r--r--cpp/test/Freeze/dbmap/Client.cpp4
-rw-r--r--cpp/test/IceXML/encoding/Client.cpp3
8 files changed, 212 insertions, 156 deletions
diff --git a/cpp/include/IceXML/StreamI.h b/cpp/include/IceXML/StreamI.h
index 1be6fa546d1..b17dfe51c46 100644
--- a/cpp/include/IceXML/StreamI.h
+++ b/cpp/include/IceXML/StreamI.h
@@ -57,7 +57,7 @@ public:
virtual void endWriteDictionaryElement();
- virtual void startReadDictionary(const ::std::string&, ::Ice::Int&);
+ virtual ::Ice::Int startReadDictionary(const ::std::string&);
virtual void endReadDictionary();
@@ -73,7 +73,7 @@ public:
virtual void endWriteSequenceElement();
- virtual void startReadSequence(const ::std::string&, ::Ice::Int&);
+ virtual ::Ice::Int startReadSequence(const ::std::string&);
virtual void endReadSequence();
@@ -99,80 +99,79 @@ public:
virtual void writeEnum(const ::std::string&, const ::Ice::StringSeq&, ::Ice::Int);
- virtual void readEnum(const ::std::string&, const ::Ice::StringSeq&, ::Ice::Int&);
+ virtual ::Ice::Int readEnum(const ::std::string&, const ::Ice::StringSeq&);
virtual void writeByte(const ::std::string&, ::Ice::Byte);
virtual void writeByteSeq(const ::std::string&, const ::Ice::ByteSeq&);
- virtual void readByte(const ::std::string&, ::Ice::Byte&);
+ virtual ::Ice::Byte readByte(const ::std::string&);
- virtual void readByteSeq(const ::std::string&, ::Ice::ByteSeq&);
+ virtual ::Ice::ByteSeq readByteSeq(const ::std::string&);
virtual void writeBool(const ::std::string&, bool);
virtual void writeBoolSeq(const ::std::string&, const ::Ice::BoolSeq&);
- virtual void readBool(const ::std::string&, bool&);
+ virtual bool readBool(const ::std::string&);
- virtual void readBoolSeq(const ::std::string&, ::Ice::BoolSeq&);
+ virtual ::Ice::BoolSeq readBoolSeq(const ::std::string&);
virtual void writeShort(const ::std::string&, ::Ice::Short);
virtual void writeShortSeq(const ::std::string&, const ::Ice::ShortSeq&);
- virtual void readShort(const ::std::string&, ::Ice::Short&);
+ virtual ::Ice::Short readShort(const ::std::string&);
- virtual void readShortSeq(const ::std::string&, ::Ice::ShortSeq&);
+ virtual ::Ice::ShortSeq readShortSeq(const ::std::string&);
virtual void writeInt(const ::std::string&, ::Ice::Int);
virtual void writeIntSeq(const ::std::string&, const ::Ice::IntSeq&);
- virtual void readInt(const ::std::string&, ::Ice::Int&);
+ virtual ::Ice::Int readInt(const ::std::string&);
- virtual void readIntSeq(const ::std::string&, ::Ice::IntSeq&);
+ virtual ::Ice::IntSeq readIntSeq(const ::std::string&);
virtual void writeLong(const ::std::string&, ::Ice::Long);
virtual void writeLongSeq(const ::std::string&, const ::Ice::LongSeq&);
- virtual void readLong(const ::std::string&, ::Ice::Long&);
+ virtual ::Ice::Long readLong(const ::std::string&);
- virtual void readLongSeq(const ::std::string&, ::Ice::LongSeq&);
+ virtual ::Ice::LongSeq readLongSeq(const ::std::string&);
virtual void writeFloat(const ::std::string&, ::Ice::Float);
virtual void writeFloatSeq(const ::std::string&, const ::Ice::FloatSeq&);
- virtual void readFloat(const ::std::string&, ::Ice::Float&);
+ virtual ::Ice::Float readFloat(const ::std::string&);
- virtual void readFloatSeq(const ::std::string&, ::Ice::FloatSeq&);
+ virtual ::Ice::FloatSeq readFloatSeq(const ::std::string&);
virtual void writeDouble(const ::std::string&, ::Ice::Double);
virtual void writeDoubleSeq(const ::std::string&, const ::Ice::DoubleSeq&);
- virtual void readDouble(const ::std::string&, ::Ice::Double&);
+ virtual ::Ice::Double readDouble(const ::std::string&);
- virtual void readDoubleSeq(const ::std::string&, ::Ice::DoubleSeq&);
+ virtual ::Ice::DoubleSeq readDoubleSeq(const ::std::string&);
virtual void writeString(const ::std::string&, const ::std::string&);
virtual void writeStringSeq(const ::std::string&, const ::Ice::StringSeq&);
- virtual void readString(const ::std::string&, ::std::string&);
+ virtual ::std::string readString(const ::std::string&);
- virtual void readStringSeq(const ::std::string&, ::Ice::StringSeq&);
+ virtual ::Ice::StringSeq readStringSeq(const ::std::string&);
virtual void writeProxy(const ::std::string&, const ::Ice::ObjectPrx&);
- virtual void readProxy(const ::std::string&, ::Ice::ObjectPrx&);
+ virtual ::Ice::ObjectPrx readProxy(const ::std::string&);
virtual void writeObject(const ::std::string&, const ::Ice::ObjectPtr&);
- virtual void readObject(const ::std::string&, const ::std::string&, const ::Ice::ObjectFactoryPtr&,
- ::Ice::ObjectPtr&);
+ virtual ::Ice::ObjectPtr readObject(const ::std::string&, const ::std::string&, const ::Ice::ObjectFactoryPtr&);
private:
diff --git a/cpp/slice/Ice/Stream.ice b/cpp/slice/Ice/Stream.ice
index b699cc8e520..a85fe2d74f1 100644
--- a/cpp/slice/Ice/Stream.ice
+++ b/cpp/slice/Ice/Stream.ice
@@ -70,12 +70,12 @@ local interface Stream
*
* @param name The name of the parameter.
*
- * @param size The number of elements in the dictionary.
+ * @return The number of elements in the dictionary.
*
* @see endReadDictionary
*
**/
- void startReadDictionary(string name ; int size);
+ int startReadDictionary(string name);
/**
*
@@ -150,12 +150,12 @@ local interface Stream
*
* @param name The name of the parameter.
*
- * @param size The number of elements in the sequence.
+ * @return The number of elements in the sequence.
*
* @see endReadSequence
*
**/
- void startReadSequence(string name ; int size);
+ int startReadSequence(string name);
/**
*
@@ -287,12 +287,12 @@ local interface Stream
*
* @param table The enumeration elements.
*
- * @param ordinal The index of the enumeration value.
+ * @return The index of the enumeration value.
*
* @see writeEnum
*
**/
- void readEnum(string name, StringSeq table ; int ordinal);
+ int readEnum(string name, StringSeq table);
/**
*
@@ -326,12 +326,12 @@ local interface Stream
*
* @param name The name of the parameter that has been read..
*
- * @param value The byte that has been read.
+ * @return The byte that has been read.
*
* @see writeByte
*
**/
- void readByte(string name ; byte value);
+ byte readByte(string name);
/**
*
@@ -339,12 +339,12 @@ local interface Stream
*
* @param name The name of the parameter that has been read..
*
- * @param value The bytes that have been read.
+ * @return The bytes that have been read.
*
* @see writeByteSeq
*
**/
- void readByteSeq(string name ; ByteSeq value);
+ ByteSeq readByteSeq(string name);
/**
*
@@ -378,12 +378,12 @@ local interface Stream
*
* @param name The name of the parameter that has been read..
*
- * @param value The bool that has been read.
+ * @return The bool that has been read.
*
* @see writeBool
*
**/
- void readBool(string name ; bool value);
+ bool readBool(string name);
/**
*
@@ -391,12 +391,12 @@ local interface Stream
*
* @param name The name of the parameter that has been read..
*
- * @param value The bools that have been read.
+ * @return The bools that have been read.
*
* @see writeBoolSeq
*
**/
- void readBoolSeq(string name ; BoolSeq value);
+ BoolSeq readBoolSeq(string name);
/**
*
@@ -430,12 +430,12 @@ local interface Stream
*
* @param name The name of the parameter that has been read..
*
- * @param value The short that has been read.
+ * @return The short that has been read.
*
* @see writeShort
*
**/
- void readShort(string name ; short value);
+ short readShort(string name);
/**
*
@@ -443,12 +443,12 @@ local interface Stream
*
* @param name The name of the parameter that has been read..
*
- * @param value The shorts that have been read.
+ * @return The shorts that have been read.
*
* @see writeShortSeq
*
**/
- void readShortSeq(string name ; ShortSeq value);
+ ShortSeq readShortSeq(string name);
/**
*
@@ -482,12 +482,12 @@ local interface Stream
*
* @param name The name of the parameter that has been read..
*
- * @param value The int that has been read.
+ * @return The int that has been read.
*
* @see writeInt
*
**/
- void readInt(string name ; int value);
+ int readInt(string name);
/**
*
@@ -495,12 +495,12 @@ local interface Stream
*
* @param name The name of the parameter that has been read..
*
- * @param value The ints that have been read.
+ * @return The ints that have been read.
*
* @see writeIntSeq
*
**/
- void readIntSeq(string name ; IntSeq value);
+ IntSeq readIntSeq(string name);
/**
*
@@ -534,12 +534,12 @@ local interface Stream
*
* @param name The name of the parameter.
*
- * @param value The long that has been read.
+ * @return The long that has been read.
*
* @see readLong
*
**/
- void readLong(string name ; long value);
+ long readLong(string name);
/**
*
@@ -547,12 +547,12 @@ local interface Stream
*
* @param name The name of the parameter.
*
- * @param value The longs that have been read.
+ * @return The longs that have been read.
*
* @see readLongSeq
*
**/
- void readLongSeq(string name ; LongSeq value);
+ LongSeq readLongSeq(string name);
/**
*
@@ -586,12 +586,12 @@ local interface Stream
*
* @param name The name of the parameter that has been read.
*
- * @param value The float that has been read.
+ * @return The float that has been read.
*
* @see writeFloat
*
**/
- void readFloat(string name ; float value);
+ float readFloat(string name);
/**
*
@@ -599,12 +599,12 @@ local interface Stream
*
* @param name The name of the parameter that has been read.
*
- * @param value The floats that have been read.
+ * @return The floats that have been read.
*
* @see writeFloatSeq
*
**/
- void readFloatSeq(string name ; FloatSeq value);
+ FloatSeq readFloatSeq(string name);
/**
*
@@ -638,12 +638,12 @@ local interface Stream
*
* @param name The name of the parameter that has been read.
*
- * @param value The double that has been read.
+ * @return The double that has been read.
*
* @see writeDouble
*
**/
- void readDouble(string name ; double value);
+ double readDouble(string name);
/**
*
@@ -651,12 +651,12 @@ local interface Stream
*
* @param name The name of the parameter that has been read.
*
- * @param value The doubles that have been read.
+ * @return The doubles that have been read.
*
* @see writeDoubleSeq
*
**/
- void readDoubleSeq(string name ; DoubleSeq value);
+ DoubleSeq readDoubleSeq(string name);
/**
*
@@ -690,12 +690,12 @@ local interface Stream
*
* @param name The name of the parameter that has been read.
*
- * @param value The string that has been read.
+ * @return The string that has been read.
*
* @see writeString
*
**/
- void readString(string name ; string value);
+ string readString(string name);
/**
*
@@ -703,12 +703,12 @@ local interface Stream
*
* @param name The name of the parameter that has been read.
*
- * @param value The strings that have been read.
+ * @return The strings that have been read.
*
* @see writeStringSeq
*
**/
- void readStringSeq(string name ; StringSeq value);
+ StringSeq readStringSeq(string name);
/**
*
@@ -729,12 +729,12 @@ local interface Stream
*
* @param name The name of the parameter that has been read.
*
- * @param value The proxy that has been read.
+ * @return The proxy that has been read.
*
* @see writeProxy
*
**/
- void readProxy(string name ; Object* value);
+ Object* readProxy(string name);
/**
*
@@ -764,12 +764,12 @@ local interface Stream
*
* @param factory The object factory to use as desribed above.
*
- * @param value The object that has been read.
+ * @return The object that has been read.
*
* @see ObjectFactory, readObject
*
**/
- void readObject(string name, string signatureType, ObjectFactory factory; Object value);
+ Object readObject(string name, string signatureType, ObjectFactory factory);
};
};
diff --git a/cpp/src/Ice/Object.cpp b/cpp/src/Ice/Object.cpp
index ee7a479abb0..a77e0ac552b 100644
--- a/cpp/src/Ice/Object.cpp
+++ b/cpp/src/Ice/Object.cpp
@@ -270,8 +270,7 @@ Ice::Object::__unmarshal(const ::Ice::StreamPtr& __is)
static const string keyName = "key";
static const string valueName = "value";
- Int sz;
- __is->startReadDictionary(facetsName, sz);
+ Int sz = __is->startReadDictionary(facetsName);
_activeFacetMap.clear();
_activeFacetMapHint = _activeFacetMap.end();
@@ -280,8 +279,8 @@ Ice::Object::__unmarshal(const ::Ice::StreamPtr& __is)
{
__is->startReadDictionaryElement();
pair<string, ObjectPtr> v;
- __is->readString(keyName, v.first);
- __is->readObject(valueName, "", 0, v.second);
+ v.first = __is->readString(keyName);
+ v.second = __is->readObject(valueName, "", 0);
_activeFacetMapHint = _activeFacetMap.insert(_activeFacetMapHint, v);
__is->endReadDictionaryElement();
}
@@ -297,7 +296,7 @@ Ice::Object::ice_marshal(const string& name, const ::Ice::StreamPtr& stream)
void
Ice::Object::ice_unmarshal(const string& name, const ::Ice::StreamPtr& stream, ObjectPtr& value)
{
- stream->readObject(name, "", 0, value);
+ value = stream->readObject(name, "", 0);
}
void
diff --git a/cpp/src/IceXML/StreamI.cpp b/cpp/src/IceXML/StreamI.cpp
index cfbcab5b062..4bfcb272159 100644
--- a/cpp/src/IceXML/StreamI.cpp
+++ b/cpp/src/IceXML/StreamI.cpp
@@ -331,12 +331,13 @@ IceXML::StreamI::endWriteDictionaryElement()
endWrite();
}
-void
-IceXML::StreamI::startReadDictionary(const string& name, ::Ice::Int& size)
+::Ice::Int
+IceXML::StreamI::startReadDictionary(const string& name)
{
startRead(name);
- size = readLength();
+ ::Ice::Int size = readLength();
_input->current = _input->current.getFirstChild();
+ return size;
}
void
@@ -384,12 +385,13 @@ IceXML::StreamI::endWriteSequenceElement()
endWrite();
}
-void
-IceXML::StreamI::startReadSequence(const string& name, ::Ice::Int& size)
+::Ice::Int
+IceXML::StreamI::startReadSequence(const string& name)
{
startRead(name);
- size = readLength();
+ ::Ice::Int size = readLength();
_input->current = _input->current.getFirstChild();
+ return size;
}
void
@@ -468,8 +470,8 @@ IceXML::StreamI::writeEnum(const string& name, const ::Ice::StringSeq& table, ::
_os << nl << "<" << name << ">" << table[ordinal] << "</" << name << ">";
}
-void
-IceXML::StreamI::readEnum(const string& name, const ::Ice::StringSeq& table, ::Ice::Int& ordinal)
+::Ice::Int
+IceXML::StreamI::readEnum(const string& name, const ::Ice::StringSeq& table)
{
startRead(name);
@@ -485,9 +487,10 @@ IceXML::StreamI::readEnum(const string& name, const ::Ice::StringSeq& table, ::I
{
throw ::Ice::UnmarshalException(__FILE__, __LINE__);
}
- ordinal = p - table.begin();
endRead();
+
+ return p - table.begin();
}
void
@@ -511,8 +514,8 @@ IceXML::StreamI::writeByteSeq(const string& name, const ::Ice::ByteSeq& seq)
endWrite();
}
-void
-IceXML::StreamI::readByte(const string& name, ::Ice::Byte& value)
+::Ice::Byte
+IceXML::StreamI::readByte(const string& name)
{
startRead(name);
@@ -528,9 +531,10 @@ IceXML::StreamI::readByte(const string& name, ::Ice::Byte& value)
{
throw ::Ice::UnmarshalException(__FILE__, __LINE__);
}
- value = (::Ice::Byte)i;
endRead();
+
+ return (::Ice::Byte)i;
}
//
@@ -573,9 +577,11 @@ IceXML::StreamI::readByte(const string& name, ::Ice::Byte& value)
//
//
-void
-IceXML::StreamI::readByteSeq(const string& name, ::Ice::ByteSeq& value)
+::Ice::ByteSeq
+IceXML::StreamI::readByteSeq(const string& name)
{
+ ::Ice::ByteSeq value;
+
startRead(name);
::Ice::Int size = readLength();
@@ -585,11 +591,13 @@ IceXML::StreamI::readByteSeq(const string& name, ::Ice::ByteSeq& value)
_input->current = _input->current.getFirstChild();
for (int i = 0; i < size; ++i)
{
- readByte(seqElementName, value[i]);
+ value[i] = readByte(seqElementName);
}
}
endRead();
+
+ return value;
}
void
@@ -611,8 +619,8 @@ IceXML::StreamI::writeBoolSeq(const string& name, const ::Ice::BoolSeq& seq)
endWrite();
}
-void
-IceXML::StreamI::readBool(const string& name, bool& value)
+bool
+IceXML::StreamI::readBool(const string& name)
{
startRead(name);
@@ -623,14 +631,17 @@ IceXML::StreamI::readBool(const string& name, bool& value)
}
string s = toString(child.getNodeValue());
- value = (s == "true") ? true : false;
endRead();
+
+ return (s == "true") ? true : false;
}
-void
-IceXML::StreamI::readBoolSeq(const string& name, ::Ice::BoolSeq& value)
+::Ice::BoolSeq
+IceXML::StreamI::readBoolSeq(const string& name)
{
+ ::Ice::BoolSeq value;
+
startRead(name);
::Ice::Int size = readLength();
@@ -640,13 +651,13 @@ IceXML::StreamI::readBoolSeq(const string& name, ::Ice::BoolSeq& value)
_input->current = _input->current.getFirstChild();
for (int i = 0; i < size; ++i)
{
- bool v;
- readBool(seqElementName, v);
- value[i] = v;
+ value[i] = readBool(seqElementName);
}
}
endRead();
+
+ return value;
}
void
@@ -668,8 +679,8 @@ IceXML::StreamI::writeShortSeq(const string& name, const ::Ice::ShortSeq& seq)
endWrite();
}
-void
-IceXML::StreamI::readShort(const string& name, ::Ice::Short& value)
+::Ice::Short
+IceXML::StreamI::readShort(const string& name)
{
startRead(name);
@@ -685,14 +696,17 @@ IceXML::StreamI::readShort(const string& name, ::Ice::Short& value)
{
throw ::Ice::UnmarshalException(__FILE__, __LINE__);
}
- value = (::Ice::Short)i;
endRead();
+
+ return (::Ice::Short)i;
}
-void
-IceXML::StreamI::readShortSeq(const string& name, ::Ice::ShortSeq& value)
+::Ice::ShortSeq
+IceXML::StreamI::readShortSeq(const string& name)
{
+ ::Ice::ShortSeq value;
+
startRead(name);
::Ice::Int size = readLength();
@@ -702,11 +716,13 @@ IceXML::StreamI::readShortSeq(const string& name, ::Ice::ShortSeq& value)
_input->current = _input->current.getFirstChild();
for (int i = 0; i < size; ++i)
{
- readShort(seqElementName, value[i]);
+ value[i] = readShort(seqElementName);
}
}
endRead();
+
+ return value;
}
void
@@ -728,8 +744,8 @@ IceXML::StreamI::writeIntSeq(const string& name, const ::Ice::IntSeq& seq)
endWrite();
}
-void
-IceXML::StreamI::readInt(const string& name, ::Ice::Int& value)
+::Ice::Int
+IceXML::StreamI::readInt(const string& name)
{
startRead(name);
@@ -740,14 +756,17 @@ IceXML::StreamI::readInt(const string& name, ::Ice::Int& value)
}
string s = toString(child.getNodeValue());
- value = atoi(s.c_str());
endRead();
+
+ return atoi(s.c_str());
}
-void
-IceXML::StreamI::readIntSeq(const string& name, ::Ice::IntSeq& value)
+::Ice::IntSeq
+IceXML::StreamI::readIntSeq(const string& name)
{
+ ::Ice::IntSeq value;
+
startRead(name);
::Ice::Int size = readLength();
@@ -757,11 +776,13 @@ IceXML::StreamI::readIntSeq(const string& name, ::Ice::IntSeq& value)
_input->current = _input->current.getFirstChild();
for (int i = 0; i < size; ++i)
{
- readInt(seqElementName, value[i]);
+ value[i] = readInt(seqElementName);
}
}
endRead();
+
+ return value;
}
void
@@ -783,8 +804,8 @@ IceXML::StreamI::writeLongSeq(const string& name, const ::Ice::LongSeq& seq)
endWrite();
}
-void
-IceXML::StreamI::readLong(const string& name, ::Ice::Long& value)
+::Ice::Long
+IceXML::StreamI::readLong(const string& name)
{
startRead(name);
@@ -795,14 +816,17 @@ IceXML::StreamI::readLong(const string& name, ::Ice::Long& value)
}
string s = toString(child.getNodeValue());
- value = atol(s.c_str());
endRead();
+
+ return atol(s.c_str());
}
-void
-IceXML::StreamI::readLongSeq(const string& name, ::Ice::LongSeq& value)
+::Ice::LongSeq
+IceXML::StreamI::readLongSeq(const string& name)
{
+ ::Ice::LongSeq value;
+
startRead(name);
::Ice::Int size = readLength();
@@ -812,11 +836,13 @@ IceXML::StreamI::readLongSeq(const string& name, ::Ice::LongSeq& value)
_input->current = _input->current.getFirstChild();
for (int i = 0; i < size; ++i)
{
- readLong(seqElementName, value[i]);
+ value[i] = readLong(seqElementName);
}
}
endRead();
+
+ return value;
}
void
@@ -838,8 +864,8 @@ IceXML::StreamI::writeFloatSeq(const string& name, const ::Ice::FloatSeq& seq)
endWrite();
}
-void
-IceXML::StreamI::readFloat(const string& name, ::Ice::Float& value)
+::Ice::Float
+IceXML::StreamI::readFloat(const string& name)
{
startRead(name);
@@ -850,14 +876,17 @@ IceXML::StreamI::readFloat(const string& name, ::Ice::Float& value)
}
string s = toString(child.getNodeValue());
- value = (::Ice::Float)atof(s.c_str());
endRead();
+
+ return (::Ice::Float)atof(s.c_str());
}
-void
-IceXML::StreamI::readFloatSeq(const string& name, ::Ice::FloatSeq& value)
+::Ice::FloatSeq
+IceXML::StreamI::readFloatSeq(const string& name)
{
+ ::Ice::FloatSeq value;
+
startRead(name);
::Ice::Int size = readLength();
@@ -867,11 +896,13 @@ IceXML::StreamI::readFloatSeq(const string& name, ::Ice::FloatSeq& value)
_input->current = _input->current.getFirstChild();
for (int i = 0; i < size; ++i)
{
- readFloat(seqElementName, value[i]);
+ value[i] = readFloat(seqElementName);
}
}
endRead();
+
+ return value;
}
void
@@ -893,8 +924,8 @@ IceXML::StreamI::writeDoubleSeq(const string& name, const ::Ice::DoubleSeq& seq)
endWrite();
}
-void
-IceXML::StreamI::readDouble(const string& name, ::Ice::Double& value)
+::Ice::Double
+IceXML::StreamI::readDouble(const string& name)
{
startRead(name);
@@ -905,14 +936,17 @@ IceXML::StreamI::readDouble(const string& name, ::Ice::Double& value)
}
string s = toString(child.getNodeValue());
- value = atof(s.c_str());
endRead();
+
+ return atof(s.c_str());
}
-void
-IceXML::StreamI::readDoubleSeq(const string& name, ::Ice::DoubleSeq& value)
+::Ice::DoubleSeq
+IceXML::StreamI::readDoubleSeq(const string& name)
{
+ ::Ice::DoubleSeq value;
+
startRead(name);
::Ice::Int size = readLength();
@@ -922,11 +956,13 @@ IceXML::StreamI::readDoubleSeq(const string& name, ::Ice::DoubleSeq& value)
_input->current = _input->current.getFirstChild();
for (int i = 0; i < size; ++i)
{
- readDouble(seqElementName, value[i]);
+ value[i] = readDouble(seqElementName);
}
}
endRead();
+
+ return value;
}
void
@@ -1002,9 +1038,11 @@ IceXML::StreamI::writeStringSeq(const string& name, const ::Ice::StringSeq& seq)
endWrite();
}
-void
-IceXML::StreamI::readString(const string& name, string& value)
+string
+IceXML::StreamI::readString(const string& name)
{
+ string value;
+
startRead(name);
DOM_Node child = _input->current.getFirstChild();
@@ -1023,11 +1061,15 @@ IceXML::StreamI::readString(const string& name, string& value)
}
endRead();
+
+ return value;
}
-void
-IceXML::StreamI::readStringSeq(const string& name, ::Ice::StringSeq& value)
+::Ice::StringSeq
+IceXML::StreamI::readStringSeq(const string& name)
{
+ ::Ice::StringSeq value;
+
startRead(name);
::Ice::Int size = readLength();
@@ -1037,11 +1079,13 @@ IceXML::StreamI::readStringSeq(const string& name, ::Ice::StringSeq& value)
_input->current = _input->current.getFirstChild();
for (int i = 0; i < size; ++i)
{
- readString(seqElementName, value[i]);
+ value[i] = readString(seqElementName);
}
}
endRead();
+
+ return value;
}
void
@@ -1053,8 +1097,8 @@ IceXML::StreamI::writeProxy(const string& name, const ::Ice::ObjectPrx& proxy)
_os << nl << "<" << name << ">" << s << "</" << name << ">";
}
-void
-IceXML::StreamI::readProxy(const string& name, ::Ice::ObjectPrx& value)
+::Ice::ObjectPrx
+IceXML::StreamI::readProxy(const string& name)
{
startRead(name);
@@ -1069,9 +1113,9 @@ IceXML::StreamI::readProxy(const string& name, ::Ice::ObjectPrx& value)
s = toString(child.getNodeValue());
}
- value = _communicator->stringToProxy(s);
-
endRead();
+
+ return _communicator->stringToProxy(s);
}
void
@@ -1110,10 +1154,11 @@ IceXML::StreamI::writeObject(const string& name, const ::Ice::ObjectPtr& obj)
}
}
-void
-IceXML::StreamI::readObject(const string& name, const string& signatureType, const ::Ice::ObjectFactoryPtr& factory,
- ::Ice::ObjectPtr& value)
+::Ice::ObjectPtr
+IceXML::StreamI::readObject(const string& name, const string& signatureType, const ::Ice::ObjectFactoryPtr& factory)
{
+ ::Ice::ObjectPtr value;
+
startRead(name);
//
@@ -1137,7 +1182,7 @@ IceXML::StreamI::readObject(const string& name, const string& signatureType, con
{
value = p->second;
endRead();
- return;
+ return value;
}
//
@@ -1221,6 +1266,8 @@ IceXML::StreamI::readObject(const string& name, const string& signatureType, con
}
endRead();
+
+ return value;
}
void
diff --git a/cpp/src/Slice/CPlusPlusUtil.cpp b/cpp/src/Slice/CPlusPlusUtil.cpp
index 12b7b354958..363ad1ca391 100644
--- a/cpp/src/Slice/CPlusPlusUtil.cpp
+++ b/cpp/src/Slice/CPlusPlusUtil.cpp
@@ -496,22 +496,30 @@ Slice::writeGenericMarshalUnmarshalCode(Output& out, const TypePtr& type, const
{
if (builtin->kind() == Builtin::KindObject)
{
- streamFunc += outputBuiltinTable[builtin->kind()];
+ streamFunc += outputBuiltinTable[builtin->kind()];
if (marshal)
{
out << nl << stream << deref << streamFunc << "(" << tagName << ", " << param << ");";
}
else
{
- out << nl << stream << deref << streamFunc << "(" << tagName << ", ::Ice::Object::__classIds[0], 0, "
- << param << ");";
+ out << nl << param << " = " << stream << deref << streamFunc << "(" << tagName
+ << ", ::Ice::Object::__classIds[0], 0);";
}
return;
}
else
{
- out << nl << stream << deref << streamFunc << outputBuiltinTable[builtin->kind()]
- << "(" << tagName << ", " << param << ");";
+ if (marshal)
+ {
+ out << nl << stream << deref << streamFunc << outputBuiltinTable[builtin->kind()]
+ << "(" << tagName << ", " << param << ");";
+ }
+ else
+ {
+ out << nl << param << " = " << stream << deref << streamFunc << outputBuiltinTable[builtin->kind()]
+ << "(" << tagName << ");";
+ }
return;
}
}
@@ -543,8 +551,8 @@ Slice::writeGenericMarshalUnmarshalCode(Output& out, const TypePtr& type, const
factory = "0";
type = "\"\"";
}
- out << nl << stream << deref << streamFunc << "Object(" << tagName << ", "
- << type << ", " << factory << ", " << obj << ");";
+ out << nl << obj << " = " << stream << deref << streamFunc << "Object(" << tagName << ", "
+ << type << ", " << factory << ");";
out << nl << param << " = " << cl->scoped() << "Ptr::dynamicCast(" << obj << ");";
}
out << eb;
@@ -565,8 +573,16 @@ Slice::writeGenericMarshalUnmarshalCode(Output& out, const TypePtr& type, const
BuiltinPtr builtin = BuiltinPtr::dynamicCast(seq->type());
if (builtin)
{
- out << nl << stream << deref << streamFunc << outputBuiltinTable[builtin->kind()] << "Seq("
- << tagName << ", " << param << ");";
+ if (marshal)
+ {
+ out << nl << stream << deref << streamFunc << outputBuiltinTable[builtin->kind()] << "Seq("
+ << tagName << ", " << param << ");";
+ }
+ else
+ {
+ out << nl << param << " = " << stream << deref << streamFunc << outputBuiltinTable[builtin->kind()]
+ << "Seq(" << tagName << ");";
+ }
}
else
{
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index d91658521fb..8bb1a65692e 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -669,8 +669,7 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p)
C << sp << nl << "void" << nl << scope.substr(2) << "ice_unmarshal(const ::std::string& __name, "
<< "const ::Ice::StreamPtr& __is, " << scoped << "& v, " << scope << "__U__" << name << ')';
C << sb;
- C << nl << "::Ice::Int sz;";
- C << nl << "__is->startReadSequence(__name, sz);";
+ C << nl << "::Ice::Int sz = __is->startReadSequence(__name);";
//
// Don't use v.resize(sz) or v.reserve(sz) here, as it cannot
// be checked whether sz is a reasonable value.
@@ -797,8 +796,7 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p)
C << sp << nl << "void" << nl << scope.substr(2) << "ice_unmarshal(const ::std::string& __name, "
<< "const ::Ice::StreamPtr& __is, " << scoped << "& v, " << scope << "__U__" << name << ')';
C << sb;
- C << nl << "::Ice::Int sz;";
- C << nl << "__is->startReadDictionary(__name, sz);";
+ C << nl << "::Ice::Int sz = __is->startReadDictionary(__name);";
C << nl << "while (sz--)";
C << sb;
C << nl << "::std::pair<" << ks << ", " << vs << "> pair;";
@@ -927,8 +925,7 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p)
C << sp << nl << "void" << nl << scope.substr(2) << "ice_unmarshal(const ::std::string& __name, "
<< "const ::Ice::StreamPtr& __is, " << scoped << "& v)";
C << sb;
- C << nl << "::Ice::Int ordinal;";
- C << nl << "__is->readEnum(__name, __T__" << name << ", ordinal);";
+ C << nl << "::Ice::Int ordinal = __is->readEnum(__name, __T__" << name << ");";
C << nl << "v = static_cast< " << scoped << ">(ordinal);";
C << eb;
}
@@ -2635,8 +2632,7 @@ Slice::Gen::HandleVisitor::visitClassDefStart(const ClassDefPtr& p)
C << nl << "void" << nl << scope.substr(2) << "ice_unmarshal(const ::std::string& __name, "
<< "const ::Ice::StreamPtr& __is, " << scoped << "Prx& v)";
C << sb;
- C << nl << "::Ice::ObjectPrx proxy;";
- C << nl << "__is->readProxy(__name, proxy);";
+ C << nl << "::Ice::ObjectPrx proxy = __is->readProxy(__name);";
C << nl << "if (!proxy)";
C << sb;
C << nl << "v = 0;";
diff --git a/cpp/test/Freeze/dbmap/Client.cpp b/cpp/test/Freeze/dbmap/Client.cpp
index 79b522fbcc4..f249c6cc237 100644
--- a/cpp/test/Freeze/dbmap/Client.cpp
+++ b/cpp/test/Freeze/dbmap/Client.cpp
@@ -42,7 +42,7 @@ public:
string data(bytes.begin(), bytes.end());
istringstream is(data);
Ice::StreamPtr stream = new ::IceXML::StreamI(communicator, is, false);
- stream->readByte("Key", key);
+ key = stream->readByte("Key");
}
};
@@ -70,7 +70,7 @@ public:
string data(bytes.begin(), bytes.end());
istringstream is(data);
Ice::StreamPtr stream = new ::IceXML::StreamI(communicator, is, false);
- stream->readInt("Value", value);
+ value = stream->readInt("Value");
}
};
diff --git a/cpp/test/IceXML/encoding/Client.cpp b/cpp/test/IceXML/encoding/Client.cpp
index c05ce31e8d8..86444e72593 100644
--- a/cpp/test/IceXML/encoding/Client.cpp
+++ b/cpp/test/IceXML/encoding/Client.cpp
@@ -49,8 +49,7 @@ TestString(const Ice::CommunicatorPtr& communicator)
istringstream is(os.str());
Ice::StreamPtr istream = new IceXML::StreamI(communicator, is);
- string result;
- istream->readString(element, result);
+ string result = istream->readString(element);
test(result == strings[i]);
}
}