diff options
author | Marc Laukien <marc@zeroc.com> | 2002-03-10 20:50:32 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2002-03-10 20:50:32 +0000 |
commit | 797a108bfab0f4acf8e07f22ef7e945eb44dd4fd (patch) | |
tree | bde138f7ec635ccff99b0e0a5586e1d5fad59692 /cpp/src | |
parent | fixes (diff) | |
download | ice-797a108bfab0f4acf8e07f22ef7e945eb44dd4fd.tar.bz2 ice-797a108bfab0f4acf8e07f22ef7e945eb44dd4fd.tar.xz ice-797a108bfab0f4acf8e07f22ef7e945eb44dd4fd.zip |
Ice protocol optimizations
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/BasicStream.cpp | 153 | ||||
-rw-r--r-- | cpp/src/Ice/Incoming.cpp | 2 | ||||
-rw-r--r-- | cpp/src/Ice/Object.cpp | 4 | ||||
-rw-r--r-- | cpp/src/Ice/Outgoing.cpp | 2 | ||||
-rw-r--r-- | cpp/src/Ice/Reference.cpp | 4 | ||||
-rw-r--r-- | cpp/src/Ice/ReferenceFactory.cpp | 4 | ||||
-rw-r--r-- | cpp/src/Ice/TraceUtil.cpp | 2 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 37 | ||||
-rw-r--r-- | cpp/src/slice2java/Gen.cpp | 12 |
9 files changed, 115 insertions, 105 deletions
diff --git a/cpp/src/Ice/BasicStream.cpp b/cpp/src/Ice/BasicStream.cpp index 1f5851902c8..f8c8226b5e7 100644 --- a/cpp/src/Ice/BasicStream.cpp +++ b/cpp/src/Ice/BasicStream.cpp @@ -72,7 +72,7 @@ IceInternal::BasicStream::reserve(int total) void IceInternal::BasicStream::startWriteEncaps() { - write(Int(0)); // Encoding + write(Byte(0)); // Encoding write(Int(0)); // Placeholder for the encapsulation length _writeEncapsStack.resize(_writeEncapsStack.size() + 1); _currentWriteEncaps = &_writeEncapsStack.back(); @@ -105,7 +105,7 @@ IceInternal::BasicStream::endWriteEncaps() void IceInternal::BasicStream::startReadEncaps() { - Int encoding; + Byte encoding; read(encoding); if (encoding != 0) { @@ -175,7 +175,7 @@ IceInternal::BasicStream::getReadEncapsSize() void IceInternal::BasicStream::skipEncaps() { - Int encoding; + Byte encoding; read(encoding); if (encoding != 0) { @@ -191,6 +191,35 @@ IceInternal::BasicStream::skipEncaps() } void +IceInternal::BasicStream::writeSize(Int v) +{ + if (v >= 0xff) + { + write(Byte(0xff)); + write(v); + } + else + { + write(static_cast<Byte>(v)); + } +} + +void +IceInternal::BasicStream::readSize(Ice::Int& v) +{ + Byte b; + read(b); + if (b == Byte(0xff)) + { + read(v); + } + else + { + v = static_cast<Int>(b); + } +} + +void IceInternal::BasicStream::writeBlob(const vector<Byte>& v) { int pos = b.size(); @@ -214,16 +243,11 @@ IceInternal::BasicStream::readBlob(vector<Byte>& v, Int sz) void IceInternal::BasicStream::write(const vector<Byte>& v) { - int pos = b.size(); Int sz = v.size(); - resize(pos + sizeof(Int) + sz); - const Byte* p = reinterpret_cast<const Byte*>(&sz); -#ifdef ICE_UTIL_BIGENDIAN - reverse_copy(p, p + sizeof(Int), b.begin() + pos); -#else - copy(p, p + sizeof(Int), b.begin() + pos); -#endif - copy(v.begin(), v.end(), b.begin() + pos + sizeof(Int)); + writeSize(sz); + int pos = b.size(); + resize(pos + sz); + copy(v.begin(), v.end(), b.begin() + pos); } void @@ -240,7 +264,7 @@ void IceInternal::BasicStream::read(vector<Byte>& v) { Int sz; - read(sz); + readSize(sz); Container::iterator begin = i; i += sz; if (i > b.end()) @@ -254,16 +278,11 @@ IceInternal::BasicStream::read(vector<Byte>& v) void IceInternal::BasicStream::write(const vector<bool>& v) { - int pos = b.size(); Int sz = v.size(); - resize(pos + sizeof(Int) + sz); - const Byte* p = reinterpret_cast<const Byte*>(&sz); -#ifdef ICE_UTIL_BIGENDIAN - reverse_copy(p, p + sizeof(Int), b.begin() + pos); -#else - copy(p, p + sizeof(Int), b.begin() + pos); -#endif - copy(v.begin(), v.end(), b.begin() + pos + sizeof(Int)); + writeSize(sz); + int pos = b.size(); + resize(pos + sz); + copy(v.begin(), v.end(), b.begin() + pos); } void @@ -280,7 +299,7 @@ void IceInternal::BasicStream::read(vector<bool>& v) { Int sz; - read(sz); + readSize(sz); Container::iterator begin = i; i += sz; if (i > b.end()) @@ -307,14 +326,12 @@ IceInternal::BasicStream::write(Short v) void IceInternal::BasicStream::write(const vector<Short>& v) { - int pos = b.size(); Int sz = v.size(); - resize(pos + sizeof(Int) + sz * sizeof(Short)); - const Byte* p = reinterpret_cast<const Byte*>(&sz); + writeSize(sz); + int pos = b.size(); + resize(pos + sz * sizeof(Short)); + const Byte* p = reinterpret_cast<const Byte*>(v.begin()); #ifdef ICE_UTIL_BIGENDIAN - reverse_copy(p, p + sizeof(Int), b.begin() + pos); - pos += sizeof(Int); - p = reinterpret_cast<const Byte*>(v.begin()); for (int j = 0 ; j < sz ; ++j) { reverse_copy(p, p + sizeof(Short), b.begin() + pos); @@ -322,9 +339,7 @@ IceInternal::BasicStream::write(const vector<Short>& v) pos += sizeof(Short); } #else - copy(p, p + sizeof(Int), b.begin() + pos); - p = reinterpret_cast<const Byte*>(v.begin()); - copy(p, p + sz * sizeof(Short), b.begin() + pos + sizeof(Int)); + copy(p, p + sz * sizeof(Short), b.begin() + pos); #endif } @@ -348,7 +363,7 @@ void IceInternal::BasicStream::read(vector<Short>& v) { Int sz; - read(sz); + readSize(sz); Container::iterator begin = i; i += sz * sizeof(Short); if (i > b.end()) @@ -383,14 +398,12 @@ IceInternal::BasicStream::write(Int v) void IceInternal::BasicStream::write(const vector<Int>& v) { - int pos = b.size(); Int sz = v.size(); - resize(pos + sizeof(Int) + sz * sizeof(Int)); - const Byte* p = reinterpret_cast<const Byte*>(&sz); + writeSize(sz); + int pos = b.size(); + resize(pos + sz * sizeof(Int)); + const Byte* p = reinterpret_cast<const Byte*>(v.begin()); #ifdef ICE_UTIL_BIGENDIAN - reverse_copy(p, p + sizeof(Int), b.begin() + pos); - pos += sizeof(Int); - p = reinterpret_cast<const Byte*>(v.begin()); for (int j = 0 ; j < sz ; ++j) { reverse_copy(p, p + sizeof(Int), b.begin() + pos); @@ -398,9 +411,7 @@ IceInternal::BasicStream::write(const vector<Int>& v) pos += sizeof(Int); } #else - copy(p, p + sizeof(Int), b.begin() + pos); - p = reinterpret_cast<const Byte*>(v.begin()); - copy(p, p + sz * sizeof(Int), b.begin() + pos + sizeof(Int)); + copy(p, p + sz * sizeof(Int), b.begin() + pos); #endif } @@ -424,7 +435,7 @@ void IceInternal::BasicStream::read(vector<Int>& v) { Int sz; - read(sz); + readSize(sz); Container::iterator begin = i; i += sz * sizeof(Int); if (i > b.end()) @@ -459,14 +470,12 @@ IceInternal::BasicStream::write(Long v) void IceInternal::BasicStream::write(const vector<Long>& v) { - int pos = b.size(); Int sz = v.size(); - resize(pos + sizeof(Int) + sz * sizeof(Long)); - const Byte* p = reinterpret_cast<const Byte*>(&sz); + writeSize(sz); + int pos = b.size(); + resize(pos + sz * sizeof(Long)); + const Byte* p = reinterpret_cast<const Byte*>(v.begin()); #ifdef ICE_UTIL_BIGENDIAN - reverse_copy(p, p + sizeof(Int), b.begin() + pos); - pos += sizeof(Int); - p = reinterpret_cast<const Byte*>(v.begin()); for (int j = 0 ; j < sz ; ++j) { reverse_copy(p, p + sizeof(Long), b.begin() + pos); @@ -474,9 +483,7 @@ IceInternal::BasicStream::write(const vector<Long>& v) pos += sizeof(Long); } #else - copy(p, p + sizeof(Int), b.begin() + pos); - p = reinterpret_cast<const Byte*>(v.begin()); - copy(p, p + sz * sizeof(Long), b.begin() + pos + sizeof(Int)); + copy(p, p + sz * sizeof(Long), b.begin() + pos); #endif } @@ -500,7 +507,7 @@ void IceInternal::BasicStream::read(vector<Long>& v) { Int sz; - read(sz); + readSize(sz); Container::iterator begin = i; i += sz * sizeof(Long); if (i > b.end()) @@ -535,14 +542,12 @@ IceInternal::BasicStream::write(Float v) void IceInternal::BasicStream::write(const vector<Float>& v) { - int pos = b.size(); Int sz = v.size(); - resize(pos + sizeof(Int) + sz * sizeof(Float)); - const Byte* p = reinterpret_cast<const Byte*>(&sz); + writeSize(sz); + int pos = b.size(); + resize(pos + sz * sizeof(Float)); + const Byte* p = reinterpret_cast<const Byte*>(v.begin()); #ifdef ICE_UTIL_BIGENDIAN - reverse_copy(p, p + sizeof(Int), b.begin() + pos); - pos += sizeof(Int); - p = reinterpret_cast<const Byte*>(v.begin()); for (int j = 0 ; j < sz ; ++j) { reverse_copy(p, p + sizeof(Float), b.begin() + pos); @@ -550,9 +555,7 @@ IceInternal::BasicStream::write(const vector<Float>& v) pos += sizeof(Float); } #else - copy(p, p + sizeof(Int), b.begin() + pos); - p = reinterpret_cast<const Byte*>(v.begin()); - copy(p, p + sz * sizeof(Float), b.begin() + pos + sizeof(Int)); + copy(p, p + sz * sizeof(Float), b.begin() + pos); #endif } @@ -576,7 +579,7 @@ void IceInternal::BasicStream::read(vector<Float>& v) { Int sz; - read(sz); + readSize(sz); Container::iterator begin = i; i += sz * sizeof(Float); if (i > b.end()) @@ -611,14 +614,12 @@ IceInternal::BasicStream::write(Double v) void IceInternal::BasicStream::write(const vector<Double>& v) { - int pos = b.size(); Int sz = v.size(); - resize(pos + sizeof(Int) + sz * sizeof(Double)); - const Byte* p = reinterpret_cast<const Byte*>(&sz); + writeSize(sz); + int pos = b.size(); + resize(pos + sz * sizeof(Double)); + const Byte* p = reinterpret_cast<const Byte*>(v.begin()); #ifdef ICE_UTIL_BIGENDIAN - reverse_copy(p, p + sizeof(Int), b.begin() + pos); - pos += sizeof(Int); - p = reinterpret_cast<const Byte*>(v.begin()); for (int j = 0 ; j < sz ; ++j) { reverse_copy(p, p + sizeof(Double), b.begin() + pos); @@ -626,9 +627,7 @@ IceInternal::BasicStream::write(const vector<Double>& v) pos += sizeof(Double); } #else - copy(p, p + sizeof(Int), b.begin() + pos); - p = reinterpret_cast<const Byte*>(v.begin()); - copy(p, p + sz * sizeof(Double), b.begin() + pos + sizeof(Int)); + copy(p, p + sz * sizeof(Double), b.begin() + pos); #endif } @@ -652,7 +651,7 @@ void IceInternal::BasicStream::read(vector<Double>& v) { Int sz; - read(sz); + readSize(sz); Container::iterator begin = i; i += sz * sizeof(Double); if (i > b.end()) @@ -675,7 +674,7 @@ void IceInternal::BasicStream::write(const string& v) { Int len = v.size(); - write(len); + writeSize(len); if (len > 0) { int pos = b.size(); @@ -687,7 +686,7 @@ IceInternal::BasicStream::write(const string& v) void IceInternal::BasicStream::write(const vector<string>& v) { - write(Int(v.size())); + writeSize(Int(v.size())); vector<string>::const_iterator p; for (p = v.begin(); p != v.end(); ++p) { @@ -699,7 +698,7 @@ void IceInternal::BasicStream::read(string& v) { Int len; - read(len); + readSize(len); if (len <= 0) { @@ -722,7 +721,7 @@ void IceInternal::BasicStream::read(vector<string>& v) { Int sz; - read(sz); + readSize(sz); // Don't use v.resize(sz) or v.reserve(sz) here, as it cannot be // checked whether sz is a reasonable value while (sz--) diff --git a/cpp/src/Ice/Incoming.cpp b/cpp/src/Ice/Incoming.cpp index 5a17ff70b9f..ecc97102942 100644 --- a/cpp/src/Ice/Incoming.cpp +++ b/cpp/src/Ice/Incoming.cpp @@ -34,7 +34,7 @@ IceInternal::Incoming::invoke(bool response) _is.read(current.operation); _is.read(current.nonmutating); Int sz; - _is.read(sz); + _is.readSize(sz); while (sz--) { pair<string, string> pair; diff --git a/cpp/src/Ice/Object.cpp b/cpp/src/Ice/Object.cpp index a77e0ac552b..7a64a727b5c 100644 --- a/cpp/src/Ice/Object.cpp +++ b/cpp/src/Ice/Object.cpp @@ -216,7 +216,7 @@ Ice::Object::__write(::IceInternal::BasicStream* __os) const { IceUtil::Mutex::Lock sync(_activeFacetMapMutex); - __os->write(Int(_activeFacetMap.size())); + __os->writeSize(Int(_activeFacetMap.size())); for (map<string, ObjectPtr>::const_iterator p = _activeFacetMap.begin(); p != _activeFacetMap.end(); ++p) { __os->write(p->first); @@ -230,7 +230,7 @@ Ice::Object::__read(::IceInternal::BasicStream* __is) IceUtil::Mutex::Lock sync(_activeFacetMapMutex); Int sz; - __is->read(sz); + __is->readSize(sz); _activeFacetMap.clear(); _activeFacetMapHint = _activeFacetMap.end(); diff --git a/cpp/src/Ice/Outgoing.cpp b/cpp/src/Ice/Outgoing.cpp index 647dab515dc..6daf8ae2c16 100644 --- a/cpp/src/Ice/Outgoing.cpp +++ b/cpp/src/Ice/Outgoing.cpp @@ -66,7 +66,7 @@ IceInternal::Outgoing::Outgoing(const ConnectionPtr& connection, const Reference _os.write(_reference->facet); _os.write(operation); _os.write(nonmutating); - _os.write(Int(context.size())); + _os.writeSize(Int(context.size())); Context::const_iterator p; for (p = context.begin(); p != context.end(); ++p) { diff --git a/cpp/src/Ice/Reference.cpp b/cpp/src/Ice/Reference.cpp index c40c30567a7..38140686a52 100644 --- a/cpp/src/Ice/Reference.cpp +++ b/cpp/src/Ice/Reference.cpp @@ -180,7 +180,7 @@ IceInternal::Reference::streamWrite(BasicStream* s) const vector<EndpointPtr>::const_iterator p; - s->write(Ice::Int(origEndpoints.size())); + s->writeSize(Ice::Int(origEndpoints.size())); for (p = origEndpoints.begin(); p != origEndpoints.end(); ++p) { (*p)->streamWrite(s); @@ -193,7 +193,7 @@ IceInternal::Reference::streamWrite(BasicStream* s) const else { s->write(false); - s->write(Ice::Int(endpoints.size())); + s->writeSize(Ice::Int(endpoints.size())); for (p = endpoints.begin(); p != endpoints.end(); ++p) { (*p)->streamWrite(s); diff --git a/cpp/src/Ice/ReferenceFactory.cpp b/cpp/src/Ice/ReferenceFactory.cpp index 386466d41ca..3e2f4cd2af1 100644 --- a/cpp/src/Ice/ReferenceFactory.cpp +++ b/cpp/src/Ice/ReferenceFactory.cpp @@ -335,7 +335,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident, BasicStream* s) vector<EndpointPtr> endpoints; Ice::Int sz; - s->read(sz); + s->readSize(sz); origEndpoints.reserve(sz); while (sz--) { @@ -352,7 +352,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident, BasicStream* s) } else { - s->read(sz); + s->readSize(sz); endpoints.reserve(sz); while (sz--) { diff --git a/cpp/src/Ice/TraceUtil.cpp b/cpp/src/Ice/TraceUtil.cpp index a42371cd86e..537e9903d83 100644 --- a/cpp/src/Ice/TraceUtil.cpp +++ b/cpp/src/Ice/TraceUtil.cpp @@ -83,7 +83,7 @@ printRequestHeader(ostream& s, BasicStream& stream) stream.read(nonmutating); s << "\nnonmutating = " << (nonmutating ? "true" : "false"); Int sz; - stream.read(sz); + stream.readSize(sz); s << "\ncontext = "; while (sz--) { diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 8bb1a65692e..33568564448 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -414,9 +414,11 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) H << sp << nl << _dllExport << "virtual void __write(::IceInternal::BasicStream*) const;"; H << nl << _dllExport << "virtual void __read(::IceInternal::BasicStream*);"; + H << sp << nl << _dllExport << "virtual void __marshal(const ::Ice::StreamPtr&) const;"; H << nl << _dllExport << "virtual void __unmarshal(const ::Ice::StreamPtr&);"; H << nl << _dllExport << "void ice_unmarshal(const ::std::string&, const ::Ice::StreamPtr&);"; + TypeStringList memberList; DataMemberList dataMembers = p->dataMembers(); for (DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) @@ -428,6 +430,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) writeMarshalCode(C, memberList, 0); emitExceptionBase(base, "__write(__os)"); C << eb; + C << sp << nl << "void" << nl << scoped.substr(2) << "::__read(::IceInternal::BasicStream* __is)"; C << sb; writeUnmarshalCode(C, memberList, 0); @@ -529,6 +532,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) // H << sp << nl << _dllExport << "void __write(::IceInternal::BasicStream*) const;"; H << nl << _dllExport << "void __read(::IceInternal::BasicStream*);"; + H << sp << nl << _dllExport << "void ice_marshal(const ::std::string&, const ::Ice::StreamPtr&) const;"; H << nl << _dllExport << "void ice_unmarshal(const ::std::string&, const ::Ice::StreamPtr&);"; @@ -541,6 +545,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) C << sb; writeMarshalCode(C, memberList, 0); C << eb; + C << sp << nl << "void" << nl << scoped.substr(2) << "::__read(::IceInternal::BasicStream* __is)"; C << sb; writeUnmarshalCode(C, memberList, 0); @@ -553,6 +558,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) writeGenericMarshalCode(C, memberList, 0); C << nl << "__os->endWriteStruct();"; C << eb; + C << sp << nl << "void" << nl << scoped.substr(2) << "::ice_unmarshal(const ::std::string& __name, const ::Ice::StreamPtr& __is)"; C << sb; @@ -600,7 +606,7 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p) << ");"; H << nl << _dllExport << "void __read(::IceInternal::BasicStream*, " << name << "&, __U__" << name << ");"; - H << nl << _dllExport << "void ice_marshal(const ::std::string&, const ::Ice::StreamPtr&, const " + H << sp << nl << _dllExport << "void ice_marshal(const ::std::string&, const ::Ice::StreamPtr&, const " << name << "&, __U__" << name << ");"; H << nl << _dllExport << "void ice_unmarshal(const ::std::string&, const ::Ice::StreamPtr&, " @@ -620,18 +626,19 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p) C << sp << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, const " << scoped << "& v, " << scope << "__U__" << name << ")"; C << sb; - C << nl << "__os->write(::Ice::Int(v.size()));"; + C << nl << "__os->writeSize(::Ice::Int(v.size()));"; C << nl << scoped << "::const_iterator p;"; C << nl << "for (p = v.begin(); p != v.end(); ++p)"; C << sb; writeMarshalUnmarshalCode(C, type, "(*p)", true); C << eb; C << eb; + C << sp << nl << "void" << nl << scope.substr(2) << "__read(::IceInternal::BasicStream* __is, " << scoped << "& v, " << scope << "__U__" << name << ')'; C << sb; C << nl << "::Ice::Int sz;"; - C << nl << "__is->read(sz);"; + C << nl << "__is->readSize(sz);"; // // Don't use v.resize(sz) or v.reserve(sz) here, as it cannot // be checked whether sz is a reasonable value. @@ -670,10 +677,6 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p) << "const ::Ice::StreamPtr& __is, " << scoped << "& v, " << scope << "__U__" << name << ')'; C << sb; 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. - // C << nl << "while (sz--)"; C << sb; C.zeroIndent(); @@ -699,7 +702,7 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p) C << nl << scope << "ice_marshal(__name, __os, v, " << scope << "__U__" << name << "());"; C << eb; - C << nl << "void" << nl << scope.substr(2) << name << "Helper::" + C << sp << nl << "void" << nl << scope.substr(2) << name << "Helper::" << "ice_unmarshal(const ::std::string& __name, const ::Ice::StreamPtr& __is, " << name << "& v)"; C << sb; @@ -735,6 +738,7 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p) H << nl << _dllExport << "void __write(::IceInternal::BasicStream*, const " << name << "&, __U__" << name << ");"; H << nl << _dllExport << "void __read(::IceInternal::BasicStream*, " << name << "&, __U__" << name << ");"; + H << sp << nl << _dllExport << "void ice_marshal(const ::std::string&, const ::Ice::StreamPtr&, const " << name << "&, __U__" << name << ");"; @@ -755,7 +759,7 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p) C << sp << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, const " << scoped << "& v, " << scope << "__U__" << name << ")"; C << sb; - C << nl << "__os->write(::Ice::Int(v.size()));"; + C << nl << "__os->writeSize(::Ice::Int(v.size()));"; C << nl << scoped << "::const_iterator p;"; C << nl << "for (p = v.begin(); p != v.end(); ++p)"; C << sb; @@ -763,11 +767,12 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p) writeMarshalUnmarshalCode(C, valueType, "p->second", true); C << eb; C << eb; + C << sp << nl << "void" << nl << scope.substr(2) << "__read(::IceInternal::BasicStream* __is, " << scoped << "& v, " << scope << "__U__" << name << ')'; C << sb; C << nl << "::Ice::Int sz;"; - C << nl << "__is->read(sz);"; + C << nl << "__is->readSize(sz);"; C << nl << "while (sz--)"; C << sb; C << nl << "::std::pair<" << ks << ", " << vs << "> pair;"; @@ -816,7 +821,7 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p) C << nl << scope << "ice_marshal(__name, __os, v, " << scope << "__U__" << name << "());"; C << eb; - C << nl << "void" << nl << scope.substr(2) << name << "Helper::" + C << sp << nl << "void" << nl << scope.substr(2) << name << "Helper::" << "ice_unmarshal(const ::std::string& __name, const ::Ice::StreamPtr& __is, " << name << "& v)"; C << sb; @@ -853,6 +858,7 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) H << sp << nl << _dllExport << "void __write(::IceInternal::BasicStream*, " << name << ");"; H << nl << _dllExport << "void __read(::IceInternal::BasicStream*, " << name << "&);"; + H << sp << nl << _dllExport << "void ice_marshal(const ::std::string&, const ::Ice::StreamPtr&, " << name << ");"; H << nl << _dllExport << "void ice_unmarshal(const ::std::string&, const ::Ice::StreamPtr&, " @@ -861,7 +867,7 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) C << sp << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, " << scoped << " v)"; C << sb; - if (sz <= 0x7f) + if (sz <= 0xff) { C << nl << "__os->write(static_cast< ::Ice::Byte>(v));"; } @@ -874,10 +880,11 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) C << nl << "__os->write(static_cast< ::Ice::Int>(v));"; } C << eb; + C << sp << nl << "void" << nl << scope.substr(2) << "__read(::IceInternal::BasicStream* __is, " << scoped << "& v)"; C << sb; - if (sz <= 0x7f) + if (sz <= 0xff) { C << nl << "::Ice::Byte val;"; C << nl << "__is->read(val);"; @@ -2580,6 +2587,7 @@ Slice::Gen::HandleVisitor::visitClassDecl(const ClassDeclPtr& p) if (!p->isLocal()) { H << nl << "typedef ::IceInternal::ProxyHandle< ::IceProxy" << scoped << "> " << name << "Prx;"; + H << sp; H << nl << _dllExport << "void __write(::IceInternal::BasicStream*, const " << name << "Prx&);"; H << nl << _dllExport << "void __read(::IceInternal::BasicStream*, " << name << "Prx&);"; @@ -2606,6 +2614,7 @@ Slice::Gen::HandleVisitor::visitClassDefStart(const ClassDefPtr& p) C << sb; C << nl << "__os->write(::Ice::ObjectPrx(v));"; C << eb; + C << sp; C << nl << "void" << nl << scope.substr(2) << "__read(::IceInternal::BasicStream* __is, " << scoped << "Prx& v)"; @@ -2629,6 +2638,8 @@ Slice::Gen::HandleVisitor::visitClassDefStart(const ClassDefPtr& p) C << sb; C << nl << "__os->writeProxy(__name, v);"; C << eb; + + C << sp; C << nl << "void" << nl << scope.substr(2) << "ice_unmarshal(const ::std::string& __name, " << "const ::Ice::StreamPtr& __is, " << scoped << "Prx& v)"; C << sb; diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp index 36b617e0b13..0c4b7484067 100644 --- a/cpp/src/slice2java/Gen.cpp +++ b/cpp/src/slice2java/Gen.cpp @@ -1416,7 +1416,7 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) out << sp << nl << "public final void" << nl << "__write(IceInternal.BasicStream __os)"; out << sb; - if (sz <= 0x7f) + if (sz <= 0xff) { out << nl << "__os.writeByte((byte)__value);"; } @@ -1436,7 +1436,7 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) out << sp << nl << "public static " << name << nl << "__read(IceInternal.BasicStream __is)"; out << sb; - if (sz <= 0x7f) + if (sz <= 0xff) { out << nl << "int __v = __is.readByte();"; } @@ -1953,7 +1953,7 @@ Slice::Gen::HelperVisitor::visitSequence(const SequencePtr& p) } else { - out << nl << "__os.writeInt(__v.length);"; + out << nl << "__os.writeSize(__v.length);"; out << nl << "for (int __i = 0; __i < __v.length; __i++)"; out << sb; iter = 0; @@ -1974,7 +1974,7 @@ Slice::Gen::HelperVisitor::visitSequence(const SequencePtr& p) } else { - out << nl << "int __len = __is.readInt();"; + out << nl << "int __len = __is.readSize();"; out << nl << typeS << " __v = new " << origContentS << "[__len]"; d = depth; while (d--) @@ -2085,7 +2085,7 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p) // out << nl << "public static void" << nl << "write(IceInternal.BasicStream __os, " << "java.util.Map __v)"; out << sb; - out << nl << "__os.writeInt(__v.size());"; + out << nl << "__os.writeSize(__v.size());"; out << nl << "java.util.Iterator __i = __v.entrySet().iterator();"; out << nl << "while (__i.hasNext())"; out << sb; @@ -2176,7 +2176,7 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p) out << sp << nl << "public static java.util.Map" << nl << "read(IceInternal.BasicStream __is)"; out << sb; - out << nl << "int __sz = __is.readInt();"; + out << nl << "int __sz = __is.readSize();"; out << nl << "java.util.Map __r = new java.util.HashMap(__sz);"; out << nl << "for (int __i = 0; __i < __sz; __i++)"; out << sb; |