summaryrefslogtreecommitdiff
path: root/cpp/src/slice2cs/Gen.cpp
diff options
context:
space:
mode:
authorMichi Henning <michi@zeroc.com>2004-09-09 04:04:08 +0000
committerMichi Henning <michi@zeroc.com>2004-09-09 04:04:08 +0000
commitd21eace6c9ca5387747d1ec2f1a4c076d758d411 (patch)
tree91b78b711994ce2c4d6a7de3d27823c8f0a83cf9 /cpp/src/slice2cs/Gen.cpp
parentFixed exception catch handler ordering problem. (diff)
downloadice-d21eace6c9ca5387747d1ec2f1a4c076d758d411.tar.bz2
ice-d21eace6c9ca5387747d1ec2f1a4c076d758d411.tar.xz
ice-d21eace6c9ca5387747d1ec2f1a4c076d758d411.zip
Fixed exception handler ordering problem in slice2java and slice2cs.
Removed redundant code to omit local exceptions when generating exception- handling code: local exceptions can no longer appear in the exception specification of a non-local operation, so the code was superfluous.
Diffstat (limited to 'cpp/src/slice2cs/Gen.cpp')
-rwxr-xr-xcpp/src/slice2cs/Gen.cpp43
1 files changed, 36 insertions, 7 deletions
diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp
index 68dc7e94259..7c8eb1a42e6 100755
--- a/cpp/src/slice2cs/Gen.cpp
+++ b/cpp/src/slice2cs/Gen.cpp
@@ -289,7 +289,18 @@ Slice::CsVisitor::writeDispatch(const ClassDefPtr& p)
ExceptionList throws = op->throws();
throws.sort();
throws.unique();
- remove_if(throws.begin(), throws.end(), IceUtil::constMemFun(&Exception::isLocal));
+
+ //
+ // 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 and resulting in the base exception
+ // being marshaled instead of the derived exception.
+ //
+#if defined(__SUNPRO_CC)
+ throws.sort(Slice::derivedToBaseCompare);
+#else
+ throws.sort(Slice::DerivedToBaseCompare());
+#endif
TypeStringList::const_iterator q;
@@ -3155,7 +3166,6 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p)
ExceptionList throws = op->throws();
throws.sort();
throws.unique();
- throws.erase(remove_if(throws.begin(), throws.end(), IceUtil::constMemFun(&Exception::isLocal)), throws.end());
//
// Arrange exceptions into most-derived to least-derived order. If we don't
@@ -3359,11 +3369,6 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p)
string retS = typeToString(ret);
ClassDefPtr containingClass = ClassDefPtr::dynamicCast(op->container());
- ExceptionList throws = op->throws();
- throws.sort();
- throws.unique();
- throws.erase(remove_if(throws.begin(), throws.end(), IceUtil::constMemFun(&Exception::isLocal)), throws.end());
-
vector<string> params = getParams(op);
vector<string> args = getArgs(op);
@@ -3599,6 +3604,18 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
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 and resulting in the base exception
+ // being marshaled instead of the derived exception.
+ //
+#if defined(__SUNPRO_CC)
+ throws.sort(Slice::derivedToBaseCompare);
+#else
+ throws.sort(Slice::DerivedToBaseCompare());
+#endif
+
TypeStringList::const_iterator q;
vector<string> params = getParamsAsyncCB(p);
@@ -3764,6 +3781,18 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
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 and resulting in the base exception
+ // being marshaled instead of the derived exception.
+ //
+#if defined(__SUNPRO_CC)
+ throws.sort(Slice::derivedToBaseCompare);
+#else
+ throws.sort(Slice::DerivedToBaseCompare());
+#endif
+
TypeStringList::const_iterator q;
_out << sp << nl << "class " << classNameAMDI << '_' << name
<< " : IceInternal.IncomingAsync, " << classNameAMD << '_' << name;