summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2019-06-06 19:24:20 +0200
committerJose <jose@zeroc.com>2019-06-06 19:24:20 +0200
commit2dc0a8799e913bb37db8c5895f00f4dda920df62 (patch)
tree6dd9fe720314d92fecedb703132c5cf73082ca3f /cpp/src
parentDo not set WindowsTargetPlatformVersion, use the default (diff)
downloadice-2dc0a8799e913bb37db8c5895f00f4dda920df62.tar.bz2
ice-2dc0a8799e913bb37db8c5895f00f4dda920df62.tar.xz
ice-2dc0a8799e913bb37db8c5895f00f4dda920df62.zip
Fix Incorrect generated code for class implements interface
Close #406
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/slice2cpp/Gen.cpp14
-rw-r--r--cpp/src/slice2matlab/Main.cpp24
2 files changed, 30 insertions, 8 deletions
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index 6315c900650..2b65602d59b 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -6740,12 +6740,17 @@ Slice::Gen::Cpp11ProxyVisitor::visitClassDefStart(const ClassDefPtr& p)
writeDocSummary(H, p);
H << nl << "class " << _dllClassExport << p->name() << "Prx : public virtual "
<< getUnqualified("::Ice::Proxy", scope) << "<" << fixKwd(p->name() + "Prx") << ", ";
- if(bases.empty() || (base && base->allOperations().empty()))
+ if(bases.empty() || (bases.size() == 1 && base && base->allOperations().empty()))
{
H << getUnqualified("::Ice::ObjectPrx", scope);
}
else
{
+ if(base && base->allOperations().empty())
+ {
+ bases.pop_front();
+ }
+
ClassList::const_iterator q = bases.begin();
while(q != bases.end())
{
@@ -7870,12 +7875,17 @@ Slice::Gen::Cpp11InterfaceVisitor::visitClassDefStart(const ClassDefPtr& p)
writeDocSummary(H, p);
H << nl << "class " << _dllExport << name << " : ";
H.useCurrentPosAsIndent();
- if(bases.empty() || (base && base->allOperations().empty()))
+ if(bases.empty() || (base && bases.size() == 1 && base->allOperations().empty()))
{
H << "public virtual " << getUnqualified("::Ice::Object", scope);
}
else
{
+ if(base && base->allOperations().empty())
+ {
+ bases.pop_front();
+ }
+
ClassList::const_iterator q = bases.begin();
while(q != bases.end())
{
diff --git a/cpp/src/slice2matlab/Main.cpp b/cpp/src/slice2matlab/Main.cpp
index 0b3de868384..353556bc814 100644
--- a/cpp/src/slice2matlab/Main.cpp
+++ b/cpp/src/slice2matlab/Main.cpp
@@ -1616,7 +1616,7 @@ CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
const string name = fixIdent(p->name());
const string scoped = p->scoped();
const string abs = getAbsolute(p);
- const ClassList bases = p->bases();
+ ClassList bases = p->bases();
const OperationList allOps = p->allOperations();
const string self = name == "obj" ? "this" : "obj";
@@ -2527,17 +2527,29 @@ CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
out.inc();
out << nl << "function obj = " << prxName << "(communicator, encoding, impl, bytes)";
out.inc();
- if(!bases.empty())
+
+ ClassDefPtr base;
+ if(!bases.empty() && !bases.front()->isInterface())
+ {
+ base = bases.front();
+ }
+
+ if(bases.empty() || (bases.size() == 1 && base && base->allOperations().empty()))
{
+ out << nl << "obj = obj@Ice.ObjectPrx(communicator, encoding, impl, bytes);";
+ }
+ else
+ {
+ if(base && base->allOperations().empty())
+ {
+ bases.pop_front();
+ }
+
for(ClassList::const_iterator q = bases.begin(); q != bases.end(); ++q)
{
out << nl << "obj = obj@" << getAbsolute(*q, "", "Prx") << "(communicator, encoding, impl, bytes);";
}
}
- else
- {
- out << nl << "obj = obj@Ice.ObjectPrx(communicator, encoding, impl, bytes);";
- }
out.dec();
out << nl << "end";
out.dec();