diff options
-rwxr-xr-x | cpp/src/slice2cs/Gen.cpp | 63 | ||||
-rw-r--r-- | cs/src/Ice/Proxy.cs | 148 |
2 files changed, 127 insertions, 84 deletions
diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp index 1d740161bb6..a43a89b1286 100755 --- a/cpp/src/slice2cs/Gen.cpp +++ b/cpp/src/slice2cs/Gen.cpp @@ -3759,40 +3759,32 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p) _out << nl << "__og.abort(__ex);"; _out << eb; } - if(!outParams.empty() || ret || !throws.empty()) - { - _out << nl << "IceInternal.BasicStream __is = __og.istr();"; - } - _out << nl << "if(!__og.invoke())"; + _out << nl << "bool __ok = __og.invoke();"; + _out << nl << "try"; _out << sb; - if(!throws.empty()) - { - // - // The try/catch block is necessary because throwException() - // can raise UserException. - // - _out << nl << "try"; - _out << sb; - _out << nl << "__is.throwException();"; - _out << eb; - for(ExceptionList::const_iterator t = throws.begin(); t != throws.end(); ++t) - { - _out << nl << "catch(" << fixId((*t)->scoped()) << ')'; - _out << sb; - _out << nl << "throw;"; - _out << eb; - } - _out << nl << "catch(Ice.UserException)"; - _out << sb; - _out << eb; - } - _out << nl << "throw new Ice.UnknownUserException();"; + _out << nl << "IceInternal.BasicStream __is = __og.istr();"; + _out << nl << "if(!__ok)"; + _out << sb; + // + // The try/catch block is necessary because throwException() + // can raise UserException. + // + _out << nl << "try"; + _out << sb; + _out << nl << "__is.throwException();"; _out << eb; - if(!outParams.empty() || ret) + for(ExceptionList::const_iterator t = throws.begin(); t != throws.end(); ++t) { - _out << nl << "try"; + _out << nl << "catch(" << fixId((*t)->scoped()) << ')'; _out << sb; + _out << nl << "throw;"; + _out << eb; } + _out << nl << "catch(Ice.UserException)"; + _out << sb; + _out << nl << "throw new Ice.UnknownUserException();"; + _out << eb; + _out << eb; for(q = outParams.begin(); q != outParams.end(); ++q) { writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), false, false, true, ""); @@ -3854,14 +3846,11 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p) } _out << nl << "return __ret;"; } - if(!outParams.empty() || ret) - { - _out << eb; - _out << nl << "catch(Ice.LocalException __ex)"; - _out << sb; - _out << nl << "throw new IceInternal.NonRepeatable(__ex);"; - _out << eb; - } + _out << eb; + _out << nl << "catch(Ice.LocalException __ex)"; + _out << sb; + _out << nl << "throw new IceInternal.NonRepeatable(__ex);"; + _out << eb; _out << eb; _out << nl << "finally"; _out << sb; diff --git a/cs/src/Ice/Proxy.cs b/cs/src/Ice/Proxy.cs index cd296613a30..45f185e6361 100644 --- a/cs/src/Ice/Proxy.cs +++ b/cs/src/Ice/Proxy.cs @@ -977,21 +977,36 @@ namespace Ice IceInternal.Outgoing __og = getOutgoing("ice_isA", OperationMode.Nonmutating, __context); try { - IceInternal.BasicStream __is = __og.istr(); - IceInternal.BasicStream __os = __og.ostr(); - __os.writeString(__id); - if(!__og.invoke()) - { - throw new UnknownUserException(); - } - try - { - return __is.readBool(); - } - catch(LocalException __ex) - { - throw new IceInternal.NonRepeatable(__ex); - } + try + { + IceInternal.BasicStream __os = __og.ostr(); + __os.writeString(__id); + } + catch(LocalException __ex) + { + __og.abort(__ex); + } + bool __ok = __og.invoke(); + try + { + IceInternal.BasicStream __is = __og.istr(); + if(!__ok) + { + try + { + __is.throwException(); + } + catch(UserException __ex) + { + throw new UnknownUserException(); + } + } + return __is.readBool(); + } + catch(LocalException __ex) + { + throw new IceInternal.NonRepeatable(__ex); + } } finally { @@ -1004,10 +1019,26 @@ namespace Ice IceInternal.Outgoing __og = getOutgoing("ice_ping", OperationMode.Nonmutating, __context); try { - if(!__og.invoke()) - { - throw new UnknownUserException(); - } + bool __ok = __og.invoke(); + try + { + IceInternal.BasicStream __is = __og.istr(); + if(!__ok) + { + try + { + __is.throwException(); + } + catch(UserException __ex) + { + throw new UnknownUserException(); + } + } + } + catch(LocalException __ex) + { + throw new IceInternal.NonRepeatable(__ex); + } } finally { @@ -1020,19 +1051,27 @@ namespace Ice IceInternal.Outgoing __og = getOutgoing("ice_ids", OperationMode.Nonmutating, __context); try { - IceInternal.BasicStream __is = __og.istr(); - if(!__og.invoke()) - { - throw new UnknownUserException(); - } - try - { - return __is.readStringSeq(); - } - catch(LocalException __ex) - { - throw new IceInternal.NonRepeatable(__ex); - } + bool __ok = __og.invoke(); + try + { + IceInternal.BasicStream __is = __og.istr(); + if(!__ok) + { + try + { + __is.throwException(); + } + catch(UserException __ex) + { + throw new UnknownUserException(); + } + } + return __is.readStringSeq(); + } + catch(LocalException __ex) + { + throw new IceInternal.NonRepeatable(__ex); + } } finally { @@ -1045,19 +1084,27 @@ namespace Ice IceInternal.Outgoing __og = getOutgoing("ice_id", OperationMode.Nonmutating, __context); try { - IceInternal.BasicStream __is = __og.istr(); - if(!__og.invoke()) - { - throw new UnknownUserException(); - } - try - { - return __is.readString(); - } - catch(LocalException __ex) - { - throw new IceInternal.NonRepeatable(__ex); - } + bool __ok = __og.invoke(); + try + { + IceInternal.BasicStream __is = __og.istr(); + if(!__ok) + { + try + { + __is.throwException(); + } + catch(UserException __ex) + { + throw new UnknownUserException(); + } + } + return __is.readString(); + } + catch(LocalException __ex) + { + throw new IceInternal.NonRepeatable(__ex); + } } finally { @@ -1071,8 +1118,15 @@ namespace Ice IceInternal.Outgoing __og = getOutgoing(operation, mode, __context); try { - IceInternal.BasicStream __os = __og.ostr(); - __os.writeBlob(inParams); + try + { + IceInternal.BasicStream __os = __og.ostr(); + __os.writeBlob(inParams); + } + catch(LocalException __ex) + { + __og.abort(__ex); + } bool ok = __og.invoke(); outParams = null; if(__reference.getMode() == IceInternal.Reference.Mode.ModeTwoway) |