diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2014-07-17 12:36:00 -0230 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2014-07-17 12:36:00 -0230 |
commit | 93fdab6fa782511ef569acb17352853646aa66b5 (patch) | |
tree | 1e73a243303f1d9564499f0b7a036b4484cc1671 /cpp/src | |
parent | C# transceiver fixes (diff) | |
download | ice-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/src')
-rw-r--r-- | cpp/src/Ice/BasicStream.cpp | 112 | ||||
-rw-r--r-- | cpp/src/Ice/StreamI.cpp | 20 | ||||
-rw-r--r-- | cpp/src/Ice/StreamI.h | 10 | ||||
-rw-r--r-- | cpp/src/Slice/CsUtil.cpp | 30 | ||||
-rw-r--r-- | cpp/src/Slice/JavaUtil.cpp | 68 | ||||
-rw-r--r-- | cpp/src/slice2cs/Gen.cpp | 40 |
6 files changed, 138 insertions, 142 deletions
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); |