summaryrefslogtreecommitdiff
path: root/cpp/src/slice2java/Gen.cpp
diff options
context:
space:
mode:
authorMichi Henning <michi@zeroc.com>2004-08-17 04:19:53 +0000
committerMichi Henning <michi@zeroc.com>2004-08-17 04:19:53 +0000
commitfc61da90073d890ec240e89d530fe08d113a427e (patch)
tree0b42e6966435001fe1567faea955d8c506022fac /cpp/src/slice2java/Gen.cpp
parentmore changes (diff)
downloadice-fc61da90073d890ec240e89d530fe08d113a427e.tar.bz2
ice-fc61da90073d890ec240e89d530fe08d113a427e.tar.xz
ice-fc61da90073d890ec240e89d530fe08d113a427e.zip
Fixed bug in code generation for "no current" operations.
Diffstat (limited to 'cpp/src/slice2java/Gen.cpp')
-rw-r--r--cpp/src/slice2java/Gen.cpp49
1 files changed, 48 insertions, 1 deletions
diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp
index 45445c572f7..a5cba9738d0 100644
--- a/cpp/src/slice2java/Gen.cpp
+++ b/cpp/src/slice2java/Gen.cpp
@@ -491,7 +491,54 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p)
throws.sort(Slice::DerivedToBaseCompare());
#endif
- if(cl == p || cl->isInterface())
+ //
+ // Only generate a "no current" version of the operation if it hasn't been done in a base
+ // class already, because the "no current" version is final.
+ //
+ bool generateOperation = cl == p; // Generate if the operation is defined in this class.
+ if(!generateOperation)
+ {
+ //
+ // The operation is not defined in this class.
+ //
+ ClassList bases = p->bases();
+ if(!bases.empty())
+ {
+ //
+ // Check if the operation is already implemented by a base class.
+ //
+ bool implementedByBase = false;
+ if(!bases.front()->isInterface())
+ {
+ OperationList baseOps = bases.front()->allOperations();
+ OperationList::const_iterator i;
+ for(i = baseOps.begin(); i != baseOps.end(); ++i)
+ {
+ if((*i)->name() == op->name())
+ {
+ implementedByBase = true;
+ break;
+ }
+ }
+ if(i == baseOps.end())
+ {
+ generateOperation = true;
+ }
+ }
+ if(!generateOperation && !implementedByBase)
+ {
+ //
+ // No base class defines the operation. Check if one of the
+ // interfaces defines it, in which case this class must provide it.
+ //
+ if(bases.front()->isInterface() || bases.size() > 1)
+ {
+ generateOperation = true;
+ }
+ }
+ }
+ }
+ if(generateOperation)
{
out << sp << nl << "public final " << typeToString(ret, TypeModeReturn, package)
<< nl << opName << spar << params << epar;