diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/Outgoing.cpp | 4 | ||||
-rwxr-xr-x | cpp/src/Slice/CsUtil.cpp | 11 | ||||
-rwxr-xr-x | cpp/src/slice2cpp/Gen.cpp | 8 | ||||
-rwxr-xr-x | cpp/src/slice2cs/Gen.cpp | 74 |
4 files changed, 81 insertions, 16 deletions
diff --git a/cpp/src/Ice/Outgoing.cpp b/cpp/src/Ice/Outgoing.cpp index 53c333ba5f8..a46a4e9b0bb 100644 --- a/cpp/src/Ice/Outgoing.cpp +++ b/cpp/src/Ice/Outgoing.cpp @@ -67,8 +67,12 @@ IceInternal::LocalExceptionWrapper::throwUnknownWrapper(const std::exception& ex throw LocalExceptionWrapper(*le, false); #endif } +#if 0 string msg = "std::exception: "; throw LocalExceptionWrapper(UnknownException(__FILE__, __LINE__, msg + ex.what()), false); +#else + throw ex; +#endif } const LocalException* diff --git a/cpp/src/Slice/CsUtil.cpp b/cpp/src/Slice/CsUtil.cpp index 2e392648a50..364f8f3e9aa 100755 --- a/cpp/src/Slice/CsUtil.cpp +++ b/cpp/src/Slice/CsUtil.cpp @@ -1540,6 +1540,17 @@ Slice::CsGenerator::MetaDataVisitor::visitStructEnd(const StructPtr&) void Slice::CsGenerator::MetaDataVisitor::visitOperation(const OperationPtr& p) { + if(p->hasMetaData("UserException")) + { + ClassDefPtr cl = ClassDefPtr::dynamicCast(p->container()); + if(!cl->isLocal()) + { + cout << p->definitionContext()->filename() << ":" << p->line() + << ": warning: metdata directive `UserException' applies only to local operations " + << "but enclosing " << (cl->isInterface() ? "interface" : "class") << "`" << cl->name() + << "' is not local" << endl; + } + } validate(p); } diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 7694559b5fd..a608a38648b 100755 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -2987,6 +2987,7 @@ Slice::Gen::DelegateDVisitor::visitOperation(const OperationPtr& p) C << sb; C << nl << "__direct.servant()->__collocDispatch(__direct);"; C << eb; +#if 0 C << nl << "catch(const ::std::exception& __ex)"; C << sb; C << nl << "__direct.destroy();"; @@ -2997,6 +2998,13 @@ Slice::Gen::DelegateDVisitor::visitOperation(const OperationPtr& p) C << nl << "__direct.destroy();"; C << nl << "throw ::Ice::UnknownException(__FILE__, __LINE__, \"unknown c++ exception\");"; C << eb; +#else + C << nl << "catch(...)"; + C << sb; + C << nl << "__direct.destroy();"; + C << nl << "throw;"; + C << eb; +#endif C << nl << "__direct.destroy();"; C << eb; for(ExceptionList::const_iterator k = throws.begin(); k != throws.end(); ++k) diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp index 107e5af57dc..a79a7f8333e 100755 --- a/cpp/src/slice2cs/Gen.cpp +++ b/cpp/src/slice2cs/Gen.cpp @@ -1855,6 +1855,11 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) _out << sp << nl << "#endregion"; // Constructors + _out << sp << nl << "public override string ice_name()"; + _out << sb; + _out << nl << "return \"" << p->scoped().substr(2) << "\";"; + _out << eb; + _out << sp << nl << "#region Object members"; _out << sp << nl << "public override int GetHashCode()"; @@ -3876,7 +3881,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p) } _out << nl << "catch(Ice.UserException ex)"; _out << sb; - _out << nl << "throw new Ice.UnknownUserException(ex);"; + _out << nl << "throw new Ice.UnknownUserException(ex.ice_name(), ex);"; _out << eb; _out << eb; for(q = outParams.begin(); q != outParams.end(); ++q) @@ -4038,6 +4043,19 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p) ClassDefPtr containingClass = ClassDefPtr::dynamicCast(op->container()); ExceptionList throws = op->throws(); + throws.sort(); + throws.unique(); + + // + // Arrange exceptions into most-derived to least-derived order. If we don't + // do this, a base exception handler can appear before a derived exception + // handler, causing compiler warnings. + // +#if defined(__SUNPRO_CC) + throws.sort(Slice::derivedToBaseCompare); +#else + throws.sort(Slice::DerivedToBaseCompare()); +#endif vector<string> params = getParams(op); vector<string> args = getArgs(op); @@ -4127,10 +4145,11 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p) _out << eb; _out << ";"; - _out << nl << "IceInternal.Direct direct__ = new IceInternal.Direct(current__, run__);"; - + _out << nl << "IceInternal.Direct direct__ = null;"; _out << nl << "try"; _out << sb; + _out << nl << "direct__ = new IceInternal.Direct(current__, run__);"; + _out << nl << "Ice.DispatchStatus status__ = direct__.servant().collocDispatch__(direct__);"; if(!throws.empty()) { @@ -4141,28 +4160,51 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p) } _out << nl << "_System.Diagnostics.Debug.Assert(status__ == Ice.DispatchStatus.DispatchOK);"; + _out << eb; + for(ExceptionList::const_iterator i = throws.begin(); i != throws.end(); ++i) + { + _out << nl << "catch(" << fixId((*i)->scoped()) << ')'; + _out << sb; + _out << nl << "throw;"; + _out << eb; + } + _out << nl << "catch(System.Exception ex__)"; + _out << sb; + _out << nl << "IceInternal.LocalExceptionWrapper.throwUnknownWrapper(ex__);"; + _out << eb; + _out << nl << "finally"; + _out << sb; + _out << nl << "if(direct__ != null)"; + _out << sb; + _out << nl << "try"; + _out << sb; + _out << nl << "direct__.destroy();"; + _out << eb; + for(ExceptionList::const_iterator i = throws.begin(); i != throws.end(); ++i) + { + _out << nl << "catch(" << fixId((*i)->scoped()) << " ex__)"; + _out << sb; + _out << nl << "throw ex__;"; + _out << eb; + } + _out << nl << "catch(System.Exception ex__)"; + _out << sb; + _out << nl << "IceInternal.LocalExceptionWrapper.throwUnknownWrapper(ex__);"; + _out << eb; + _out << eb; + _out << eb; + // // // Set out parameters // - for(vector<string>::iterator s = outHolders.begin(); s != outHolders.end(); ++s) { _out << nl << (*s) << " = " << (*s) << "Holder__;"; } - - if(ret) + if(ret && !containingClass->hasMetaData("amd") && !op->hasMetaData("amd")) { _out << nl << "return result__;"; } - _out << eb; - _out << nl << "catch(Ice.LocalException ex__)"; - _out << sb; - _out << nl << "throw new IceInternal.LocalExceptionWrapper(ex__, false);"; - _out << eb; - _out << nl << "finally"; - _out << sb; - _out << nl << "direct__.destroy();"; - _out << eb; } _out << eb; } @@ -4426,7 +4468,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) } _out << nl << "catch(Ice.UserException ex)"; _out << sb; - _out << nl << "throw new Ice.UnknownUserException(ex);"; + _out << nl << "throw new Ice.UnknownUserException(ex.ice_name(), ex);"; _out << eb; _out << eb; for(q = outParams.begin(); q != outParams.end(); ++q) |