summaryrefslogtreecommitdiff
path: root/cpp/src/slice2swift/Gen.cpp
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2019-04-29 13:15:24 -0400
committerBernard Normier <bernard@zeroc.com>2019-04-29 13:15:24 -0400
commitef0511eda3faa162cfbf0f8fb715eea877d0b961 (patch)
tree8c550c896f9d088f2b2f3d82a04d05d14f887869 /cpp/src/slice2swift/Gen.cpp
parentFix minor style warnings (diff)
downloadice-ef0511eda3faa162cfbf0f8fb715eea877d0b961.tar.bz2
ice-ef0511eda3faa162cfbf0f8fb715eea877d0b961.tar.xz
ice-ef0511eda3faa162cfbf0f8fb715eea877d0b961.zip
Fixed code generation for class that implements interface
Diffstat (limited to 'cpp/src/slice2swift/Gen.cpp')
-rw-r--r--cpp/src/slice2swift/Gen.cpp34
1 files changed, 26 insertions, 8 deletions
diff --git a/cpp/src/slice2swift/Gen.cpp b/cpp/src/slice2swift/Gen.cpp
index 56f69def016..4a66cd48c9f 100644
--- a/cpp/src/slice2swift/Gen.cpp
+++ b/cpp/src/slice2swift/Gen.cpp
@@ -949,10 +949,19 @@ Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p)
}
ClassList bases = p->bases();
- ClassDefPtr baseClass;
- if(!bases.empty() && !bases.front()->isInterface())
+ bool hasBase = false;
+ while(!bases.empty() && !hasBase)
{
- baseClass = bases.front();
+ ClassDefPtr baseClass = bases.front();
+ if(!baseClass->isInterface() && baseClass->allOperations().empty())
+ {
+ // does not count
+ bases.pop_front();
+ }
+ else
+ {
+ hasBase = true;
+ }
}
const string swiftModule = getSwiftModule(getTopLevelModule(ContainedPtr::dynamicCast(p)));
@@ -962,7 +971,7 @@ Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p)
out << sp;
out << nl << "public protocol " << prx << ":";
- if(bases.empty() || (baseClass && baseClass->allOperations().empty()))
+ if(!hasBase)
{
out << " " << getUnqualified("Ice.ObjectPrx", swiftModule);
}
@@ -1294,10 +1303,19 @@ Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p)
}
ClassList bases = p->bases();
- ClassDefPtr baseClass;
- if(!bases.empty() && !bases.front()->isInterface())
+ bool hasBase = false;
+ while(!bases.empty() && !hasBase)
{
- baseClass = bases.front();
+ ClassDefPtr baseClass = bases.front();
+ if(!baseClass->isInterface() && baseClass->allOperations().empty())
+ {
+ // does not count
+ bases.pop_front();
+ }
+ else
+ {
+ hasBase = true;
+ }
}
const string swiftModule = getSwiftModule(getTopLevelModule(ContainedPtr::dynamicCast(p)));
@@ -1306,7 +1324,7 @@ Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p)
out << sp;
out << nl << "public protocol " << name << ":";
- if(bases.empty() || (baseClass && baseClass->allOperations().empty()))
+ if(!hasBase)
{
out << " " << getUnqualified("Ice.Object", swiftModule);
}