diff options
author | Benoit Foucher <benoit@zeroc.com> | 2012-08-06 15:02:15 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2012-08-06 15:02:15 +0200 |
commit | 4f9a13928253344c0191b3116c4408c1d83604d9 (patch) | |
tree | deca77fd2e69f0cb532c70de9adf14d6e3d628fe /cpp/src | |
parent | Rebuilt dependencies (diff) | |
download | ice-4f9a13928253344c0191b3116c4408c1d83604d9.tar.bz2 ice-4f9a13928253344c0191b3116c4408c1d83604d9.tar.xz ice-4f9a13928253344c0191b3116c4408c1d83604d9.zip |
Removed Stream::format method, replace with startWriteEncaps parameter
Diffstat (limited to 'cpp/src')
-rwxr-xr-x | cpp/src/Ice/BasicStream.cpp | 35 | ||||
-rw-r--r-- | cpp/src/Ice/Incoming.cpp | 16 | ||||
-rw-r--r-- | cpp/src/Ice/Object.cpp | 6 | ||||
-rw-r--r-- | cpp/src/Ice/OpaqueEndpointI.cpp | 2 | ||||
-rw-r--r-- | cpp/src/Ice/Proxy.cpp | 4 | ||||
-rw-r--r-- | cpp/src/Ice/StreamI.cpp | 10 | ||||
-rw-r--r-- | cpp/src/Ice/StreamI.h | 4 | ||||
-rw-r--r-- | cpp/src/Slice/CPlusPlusUtil.cpp | 4 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 48 | ||||
-rw-r--r-- | cpp/src/slice2java/Gen.cpp | 51 |
10 files changed, 55 insertions, 125 deletions
diff --git a/cpp/src/Ice/BasicStream.cpp b/cpp/src/Ice/BasicStream.cpp index 4636813d40a..ce7c37fa025 100755 --- a/cpp/src/Ice/BasicStream.cpp +++ b/cpp/src/Ice/BasicStream.cpp @@ -97,8 +97,7 @@ IceInternal::BasicStream::BasicStream(Instance* instance, const EncodingVersion& _unlimited(unlimited), _stringConverter(instance->initializationData().stringConverter), _wstringConverter(instance->initializationData().wstringConverter), - _startSeq(-1), - _format(_instance->defaultsAndOverrides()->defaultFormat) + _startSeq(-1) { // // Initialize the encoding members of our pre-allocated encapsulations, in case @@ -164,7 +163,6 @@ IceInternal::BasicStream::swap(BasicStream& other) std::swap(_unlimited, other._unlimited); std::swap(_startSeq, other._startSeq); std::swap(_minSeqSize, other._minSeqSize); - std::swap(_format, other._format); } void @@ -188,16 +186,6 @@ IceInternal::BasicStream::resetEncaps() _preAllocatedWriteEncaps.reset(); } - -void -IceInternal::BasicStream::format(Ice::FormatType format) -{ - if(format != DefaultFormat) - { - _format = format; - } -} - void IceInternal::BasicStream::startWriteEncaps() { @@ -209,11 +197,11 @@ IceInternal::BasicStream::startWriteEncaps() if(_currentWriteEncaps) { - startWriteEncaps(_currentWriteEncaps->encoding); + startWriteEncaps(_currentWriteEncaps->encoding, _currentWriteEncaps->format); } else { - startWriteEncaps(_encoding); + startWriteEncaps(_encoding, Ice::DefaultFormat); } } @@ -1768,9 +1756,14 @@ IceInternal::BasicStream::initWriteEncaps() _currentWriteEncaps->start = b.size(); } + if(_currentWriteEncaps->format == Ice::DefaultFormat) + { + _currentWriteEncaps->format = _instance->defaultsAndOverrides()->defaultFormat; + } + if(!_currentWriteEncaps->encoder) // Lazy initialization. { - _currentWriteEncaps->encoder = new EncapsEncoder(this, _currentWriteEncaps, _format); + _currentWriteEncaps->encoder = new EncapsEncoder(this, _currentWriteEncaps); } } @@ -1792,7 +1785,7 @@ IceInternal::BasicStream::EncapsEncoder::write(const ObjectPtr& v) _stream->write(-index); _usesClasses = true; } - else if(_sliceType != NoSlice && _format == SlicedFormat) + else if(_sliceType != NoSlice && _encaps->format == SlicedFormat) { // // An object reference that appears inside a slice of an @@ -1911,7 +1904,7 @@ IceInternal::BasicStream::EncapsEncoder::startSlice(const string& typeId, bool l // Encode the slice size for the old encoding and if using the // sliced format. // - if(_encaps->encoding == Encoding_1_0 || _format == SlicedFormat) + if(_encaps->encoding == Encoding_1_0 || _encaps->format == SlicedFormat) { _sliceFlags |= FLAG_HAS_SLICE_SIZE; } @@ -1937,7 +1930,7 @@ IceInternal::BasicStream::EncapsEncoder::startSlice(const string& typeId, bool l // Encode the type ID (only in the first slice for the compact // encoding). // - if(_format == SlicedFormat || _encaps->encoding == Encoding_1_0 || _firstSlice) + if(_encaps->format == SlicedFormat || _encaps->encoding == Encoding_1_0 || _firstSlice) { // // If the type ID has already been seen, write the index @@ -2006,7 +1999,7 @@ IceInternal::BasicStream::EncapsEncoder::endSlice() if(!_indirectionTable.empty()) { assert(_encaps->encoding != Encoding_1_0); - assert(_format == SlicedFormat); + assert(_encaps->format == SlicedFormat); _sliceFlags |= FLAG_HAS_INDIRECTION_TABLE; // @@ -2126,7 +2119,7 @@ IceInternal::BasicStream::EncapsEncoder::writeSlicedData(const SlicedDataPtr& sl // using the sliced format. Otherwise, we ignore the preserved slices, which // essentially "slices" the object into the most-derived type known by the sender. // - if(_encaps->encoding == Encoding_1_0 || _format != SlicedFormat) + if(_encaps->encoding == Encoding_1_0 || _encaps->format != SlicedFormat) { return; } diff --git a/cpp/src/Ice/Incoming.cpp b/cpp/src/Ice/Incoming.cpp index 15e49a61608..34f583bb1df 100644 --- a/cpp/src/Ice/Incoming.cpp +++ b/cpp/src/Ice/Incoming.cpp @@ -80,14 +80,14 @@ IceInternal::IncomingBase::__adopt(IncomingBase& other) } BasicStream* -IncomingBase::__startWriteParams() +IncomingBase::__startWriteParams(FormatType format) { if(_response) { assert(_os.b.size() == headerSize + 4); // Reply status position. assert(_current.encoding >= Ice::Encoding_1_0); // Encoding for reply is known. _os.write(static_cast<Ice::Byte>(0)); - _os.startWriteEncaps(_current.encoding); + _os.startWriteEncaps(_current.encoding, format); } // @@ -141,6 +141,14 @@ IncomingBase::__writeParamEncaps(const Byte* v, Ice::Int sz, bool ok) } } +void +IncomingBase::__writeUserException(const Ice::UserException& ex, Ice::FormatType format) +{ + ::IceInternal::BasicStream* __os = __startWriteParams(format); + __os->write(ex); + __endWriteParams(false); +} + void IceInternal::IncomingBase::__warning(const Exception& ex) const { @@ -203,7 +211,7 @@ IceInternal::IncomingBase::__servantLocatorFinished() { _os.b.resize(headerSize + 4); // Reply status position. _os.write(replyUserException); - _os.startWriteEncaps(_current.encoding); + _os.startWriteEncaps(_current.encoding, DefaultFormat); _os.write(ex); _os.endWriteEncaps(); _connection->sendResponse(&_os, _compress); @@ -567,7 +575,7 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager, BasicStre if(_response) { _os.write(replyUserException); - _os.startWriteEncaps(encoding); + _os.startWriteEncaps(encoding, DefaultFormat); _os.write(ex); _os.endWriteEncaps(); _connection->sendResponse(&_os, _compress); diff --git a/cpp/src/Ice/Object.cpp b/cpp/src/Ice/Object.cpp index 875c58ed78d..39ad9df18c2 100644 --- a/cpp/src/Ice/Object.cpp +++ b/cpp/src/Ice/Object.cpp @@ -111,7 +111,7 @@ Ice::Object::___ice_isA(Incoming& __inS, const Current& __current) __is->read(__id, false); __inS.endReadParams(); bool __ret = ice_isA(__id, __current); - BasicStream* __os = __inS.__startWriteParams(); + BasicStream* __os = __inS.__startWriteParams(DefaultFormat); __os->write(__ret); __inS.__endWriteParams(true); return DispatchOK; @@ -131,7 +131,7 @@ Ice::Object::___ice_ids(Incoming& __inS, const Current& __current) { __inS.readEmptyParams(); vector<string> __ret = ice_ids(__current); - BasicStream* __os = __inS.__startWriteParams(); + BasicStream* __os = __inS.__startWriteParams(DefaultFormat); __os->write(&__ret[0], &__ret[0] + __ret.size(), false); __inS.__endWriteParams(true); return DispatchOK; @@ -142,7 +142,7 @@ Ice::Object::___ice_id(Incoming& __inS, const Current& __current) { __inS.readEmptyParams(); string __ret = ice_id(__current); - BasicStream* __os = __inS.__startWriteParams(); + BasicStream* __os = __inS.__startWriteParams(DefaultFormat); __os->write(__ret, false); __inS.__endWriteParams(true); return DispatchOK; diff --git a/cpp/src/Ice/OpaqueEndpointI.cpp b/cpp/src/Ice/OpaqueEndpointI.cpp index 9b0eea19b0e..a3ed87efd85 100644 --- a/cpp/src/Ice/OpaqueEndpointI.cpp +++ b/cpp/src/Ice/OpaqueEndpointI.cpp @@ -196,7 +196,7 @@ void IceInternal::OpaqueEndpointI::streamWrite(BasicStream* s) const { s->write(_type); - s->startWriteEncaps(_rawEncoding); + s->startWriteEncaps(_rawEncoding, DefaultFormat); s->writeBlob(_rawBytes); s->endWriteEncaps(); } diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp index eead1433242..33081299113 100644 --- a/cpp/src/Ice/Proxy.cpp +++ b/cpp/src/Ice/Proxy.cpp @@ -155,7 +155,7 @@ IceProxy::Ice::Object::begin_ice_isA(const string& typeId, try { __result->__prepare(ice_isA_name, Nonmutating, ctx); - IceInternal::BasicStream* __os = __result->__startWriteParams(); + IceInternal::BasicStream* __os = __result->__startWriteParams(DefaultFormat); __os->write(typeId); __result->__endWriteParams(); __result->__send(true); @@ -1461,7 +1461,7 @@ IceDelegateM::Ice::Object::ice_isA(const string& __id, const Context* context) Outgoing __og(__handler.get(), ice_isA_name, ::Ice::Nonmutating, context); try { - BasicStream* __os = __og.startWriteParams(); + BasicStream* __os = __og.startWriteParams(DefaultFormat); __os->write(__id, false); __og.endWriteParams(); } diff --git a/cpp/src/Ice/StreamI.cpp b/cpp/src/Ice/StreamI.cpp index 91c658abcf2..e1e73f94617 100644 --- a/cpp/src/Ice/StreamI.cpp +++ b/cpp/src/Ice/StreamI.cpp @@ -577,12 +577,6 @@ OutputStreamI::writeOptional(Int tag, OptionalType type) } void -OutputStreamI::format(FormatType format) -{ - _os->format(format); -} - -void OutputStreamI::startObject(const SlicedDataPtr& slicedData) { _os->startWriteObject(slicedData); @@ -619,9 +613,9 @@ OutputStreamI::endSlice() } void -OutputStreamI::startEncapsulation(const EncodingVersion& version) +OutputStreamI::startEncapsulation(const EncodingVersion& version, FormatType format) { - _os->startWriteEncaps(version); + _os->startWriteEncaps(version, format); } void diff --git a/cpp/src/Ice/StreamI.h b/cpp/src/Ice/StreamI.h index 299e8a2bf02..0ccf35a8e6a 100644 --- a/cpp/src/Ice/StreamI.h +++ b/cpp/src/Ice/StreamI.h @@ -140,8 +140,6 @@ public: virtual void writeOptional(Int, OptionalType); - virtual void format(FormatType); - virtual void startObject(const SlicedDataPtr&); virtual void endObject(); @@ -151,7 +149,7 @@ public: virtual void startSlice(const std::string&, bool); virtual void endSlice(); - virtual void startEncapsulation(const Ice::EncodingVersion&); + virtual void startEncapsulation(const Ice::EncodingVersion&, FormatType); virtual void startEncapsulation(); virtual void endEncapsulation(); diff --git a/cpp/src/Slice/CPlusPlusUtil.cpp b/cpp/src/Slice/CPlusPlusUtil.cpp index aa35affc81b..a4ae0905b3f 100644 --- a/cpp/src/Slice/CPlusPlusUtil.cpp +++ b/cpp/src/Slice/CPlusPlusUtil.cpp @@ -712,9 +712,9 @@ Slice::operationModeToString(Operation::Mode mode) } string -Slice::formatTypeToString(FormatType type) +Slice::opFormatTypeToString(const OperationPtr& op) { - switch(type) + switch(op->format()) { case DefaultFormat: return "::Ice::DefaultFormat"; diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 44e4b501637..db0cbd559bd 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -2236,12 +2236,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) } else { - C << nl << "::IceInternal::BasicStream* __os = __result->__startWriteParams();"; - FormatType format = p->format(); - if(p->sendsClasses() && format != DefaultFormat) - { - C << nl << "__os->format(" << formatTypeToString(format) << ");"; - } + C << nl << "::IceInternal::BasicStream* __os = __result->__startWriteParams(" << opFormatTypeToString(p) <<");"; writeMarshalCode(C, inParams, 0, TypeContextInParam); C << nl << "__result->__endWriteParams();"; } @@ -2777,15 +2772,7 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p) { C << nl << "try"; C << sb; - C << nl<< "::IceInternal::BasicStream* __os = __og.startWriteParams();"; - if(p->sendsClasses()) - { - FormatType format = p->format(); - if(format != DefaultFormat) - { - C << nl << "__os->format(" << formatTypeToString(format) << ");"; - } - } + C << nl<< "::IceInternal::BasicStream* __os = __og.startWriteParams(" << opFormatTypeToString(p) << ");"; writeMarshalCode(C, inParams, 0, TypeContextInParam); C << nl << "__og.endWriteParams();"; C << eb; @@ -4344,14 +4331,10 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) C << retS << " __ret = "; } C << fixKwd(name) << args << ';'; - FormatType format = p->format(); if(ret || !outParams.empty()) { - C << nl << "::IceInternal::BasicStream* __os = __inS.__startWriteParams();"; - if(p->returnsClasses() && format != DefaultFormat) - { - C << nl << "__os->format(" << formatTypeToString(format) << ");"; - } + C << nl << "::IceInternal::BasicStream* __os = __inS.__startWriteParams(" + << opFormatTypeToString(p) << ");"; writeMarshalCode(C, outParams, p); C << nl << "__inS.__endWriteParams(true);"; } @@ -4368,13 +4351,7 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) { C << nl << "catch(const " << fixKwd((*r)->scoped()) << "& __ex)"; C << sb; - C << nl << "::IceInternal::BasicStream* __os = __inS.__startWriteParams();"; - if(format != DefaultFormat) - { - C << nl << "__os->format(" << formatTypeToString(format) << ");"; - } - C << nl << "__os->write(__ex);"; - C << nl << "__inS.__endWriteParams(false);"; + C << nl << "__inS.__writeUserException(__ex, " << opFormatTypeToString(p) << ");"; C << eb; } C << nl << "return ::Ice::DispatchUserException;"; @@ -6044,16 +6021,11 @@ Slice::Gen::AsyncImplVisitor::visitOperation(const OperationPtr& p) C << sb; C << nl << "if(__validateResponse(true))"; C << sb; - FormatType format = p->format(); if(ret || !outParams.empty()) { C << nl << "try"; C << sb; - C << nl << "::IceInternal::BasicStream* __os = __startWriteParams();"; - if(p->returnsClasses() && format != DefaultFormat) - { - C << nl << "__os->format(" << formatTypeToString(format) << ");"; - } + C << nl << "::IceInternal::BasicStream* __os = __startWriteParams(" << opFormatTypeToString(p) << ");"; writeMarshalCode(C, outParams, p, TypeContextInParam); C << nl << "__endWriteParams(true);"; C << eb; @@ -6089,13 +6061,7 @@ Slice::Gen::AsyncImplVisitor::visitOperation(const OperationPtr& p) C << sb; C << nl <<"if(__validateResponse(false))"; C << sb; - C << nl << "::IceInternal::BasicStream* __os = __startWriteParams();"; - if(format != DefaultFormat) - { - C << nl << "__os->format(" << formatTypeToString(format) << ");"; - } - C << nl << "__os->write(*__ex);"; - C << nl << "__endWriteParams(false);"; + C << nl << "__writeUserException(*__ex, " << opFormatTypeToString(p) << ");"; C << nl << "__response();"; C << eb; C << eb; diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp index 1327e24fb14..b15dc0d5f5a 100644 --- a/cpp/src/slice2java/Gen.cpp +++ b/cpp/src/slice2java/Gen.cpp @@ -66,9 +66,9 @@ sliceModeToIceMode(Operation::Mode opMode) } static string -formatTypeToString(FormatType type) +opFormatTypeToString(const OperationPtr& op) { - switch(type) + switch(op->format()) { case DefaultFormat: return "Ice.FormatType.DefaultFormat"; @@ -1171,14 +1171,10 @@ Slice::JavaVisitor::writeDispatchAndMarshalling(Output& out, const ClassDefPtr& // // Marshal 'out' parameters and return value. // - FormatType format = op->format(); if(!outParams.empty() || ret) { - out << nl << "IceInternal.BasicStream __os = __inS.__startWriteParams();"; - if(op->returnsClasses() && format != DefaultFormat) - { - out << nl << "__os.format(" << formatTypeToString(format) << ");"; - } + out << nl << "IceInternal.BasicStream __os = __inS.__startWriteParams(" + << opFormatTypeToString(op) << ");"; writeMarshalUnmarshalParams(out, package, outParams, op, iter, true, optionalMapping, true); out << nl << "__inS.__endWriteParams(true);"; } @@ -1200,13 +1196,7 @@ Slice::JavaVisitor::writeDispatchAndMarshalling(Output& out, const ClassDefPtr& string exS = getAbsolute(*t, package); out << nl << "catch(" << exS << " ex)"; out << sb; - out << nl << "IceInternal.BasicStream __os = __inS.__startWriteParams();"; - if(format != DefaultFormat) - { - out << nl << "__os.format(" << formatTypeToString(format) << ");"; - } - out << nl << "__os.writeUserException(ex);"; - out << nl << "__inS.__endWriteParams(false);"; + out << nl << "__inS.__writeUserException(ex, " << opFormatTypeToString(op) << ");"; out << nl << "return Ice.DispatchStatus.DispatchUserException;"; out << eb; } @@ -4652,12 +4642,8 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) iter = 0; if(!inArgs.empty()) { - out << nl << "IceInternal.BasicStream __os = __result.__startWriteParams();"; - FormatType format = op->format(); - if(op->sendsClasses() && format != DefaultFormat) - { - out << nl << "__os.format(" << formatTypeToString(format) << ");"; - } + out << nl << "IceInternal.BasicStream __os = __result.__startWriteParams(" + << opFormatTypeToString(op) << ");"; ParamDeclList pl; for(pli = paramList.begin(); pli != paramList.end(); ++pli) { @@ -5663,12 +5649,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p) { out << nl << "try"; out << sb; - out << nl << "IceInternal.BasicStream __os = __og.startWriteParams();"; - FormatType format = op->format(); - if(op->sendsClasses() && format != DefaultFormat) - { - out << nl << "__os.format(" << formatTypeToString(format) << ");"; - } + out << nl << "IceInternal.BasicStream __os = __og.startWriteParams(" << opFormatTypeToString(op) << ");"; writeMarshalUnmarshalParams(out, package, inParams, 0, iter, true, optionalMapping); out << nl << "__og.endWriteParams();"; out << eb; @@ -6780,16 +6761,12 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) iter = 0; out << nl << "if(__validateResponse(true))"; out << sb; - FormatType format = p->format(); if(ret || !outParams.empty()) { out << nl << "try"; out << sb; - out << nl << "IceInternal.BasicStream __os = this.__startWriteParams();"; - if(p->returnsClasses() && format != DefaultFormat) - { - out << nl << "__os.format(" << formatTypeToString(format) << ");"; - } + out << nl << "IceInternal.BasicStream __os = this.__startWriteParams(" + << opFormatTypeToString(p) << ");"; writeMarshalUnmarshalParams(out, classPkg, outParams, p, iter, true, optionalMapping, false); out << nl << "this.__endWriteParams(true);"; out << eb; @@ -6822,13 +6799,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) out << sb; out << nl << "if(__validateResponse(false))"; out << sb; - out << nl << "IceInternal.BasicStream __os = __startWriteParams();"; - if(format != DefaultFormat) - { - out << nl << "__os.format(" << formatTypeToString(format) << ");"; - } - out << nl << "__os.writeUserException(__ex);"; - out << nl << "__endWriteParams(false);"; + out << nl << "__writeUserException(__ex, " << opFormatTypeToString(p) << ");"; out << nl << "__response();"; out << eb; out << eb; |