summaryrefslogtreecommitdiff
path: root/cpp/src/slice2cpp
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2016-01-11 22:44:55 +0100
committerJose <jose@zeroc.com>2016-01-11 22:44:55 +0100
commitd159c9f1574a2e768c947ad697a1e1e2205d194c (patch)
tree86e784ac7347c1dfa92304be2a9355a7a535dbcc /cpp/src/slice2cpp
parentAdd ICE_RESET_EXCEPTION macro to simplify C++ builds (diff)
downloadice-d159c9f1574a2e768c947ad697a1e1e2205d194c.tar.bz2
ice-d159c9f1574a2e768c947ad697a1e1e2205d194c.tar.xz
ice-d159c9f1574a2e768c947ad697a1e1e2205d194c.zip
C++11 Value::ice_clone improvements
Diffstat (limited to 'cpp/src/slice2cpp')
-rw-r--r--cpp/src/slice2cpp/Gen.cpp47
-rw-r--r--cpp/src/slice2cpp/Gen.h2
2 files changed, 19 insertions, 30 deletions
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index 4ee33bada58..f390ce4ce13 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -7930,18 +7930,17 @@ Slice::Gen::Cpp11ValueVisitor::visitClassDefStart(const ClassDefPtr& p)
DataMemberList dataMembers = p->dataMembers();
DataMemberList allDataMembers = p->allDataMembers();
- H << sp << nl << "class " << _dllExport << name << " : ";
- H.useCurrentPosAsIndent();
+ H << sp << nl << "class " << _dllExport << name << " : public ::Ice::ValueHelper<" << name << ", ";
+
if(!base || (base && base->isInterface()))
{
- H << "public ::Ice::Value";
+ H << "Ice::Value";
}
else
{
- H << "public " << fixKwd(base->scoped());
+ H << fixKwd(base->scoped());
}
-
- H.restoreIndent();
+ H << ">";
H << sb;
H.dec();
H << nl << "public:" << sp;
@@ -7976,10 +7975,6 @@ Slice::Gen::Cpp11ValueVisitor::visitClassDefStart(const ClassDefPtr& p)
emitOneShotConstructor(p);
H << sp;
- H << nl << "virtual ::std::shared_ptr<::Ice::Value> ice_clone() const;";
- H << sp;
- H << nl << "const ::std::string& ice_id() const;";
- H << sp;
H << nl << "static const ::std::string& ice_staticId();";
return true;
}
@@ -7989,6 +7984,7 @@ Slice::Gen::Cpp11ValueVisitor::visitClassDefEnd(const ClassDefPtr& p)
{
string scoped = fixKwd(p->scoped());
string scope = fixKwd(p->scope());
+ string name = fixKwd(p->name());
ClassList bases = p->bases();
ClassDefPtr base;
if(!bases.empty() && !bases.front()->isInterface())
@@ -8058,26 +8054,12 @@ Slice::Gen::Cpp11ValueVisitor::visitClassDefEnd(const ClassDefPtr& p)
C << eb;
C << sp;
- C << nl << "::std::shared_ptr<::Ice::Value>";
- C << nl << scoped.substr(2) << "::ice_clone() const";
- C << sb;
- C << nl << "return ::std::make_shared<" << scoped << ">(*this);";
- C << eb;
-
- C << sp;
C << nl << "const ::std::string&" << nl << scoped.substr(2) << "::ice_staticId()";
C << sb;
C << nl << "static const ::std::string typeId = \"" << p->scoped() << "\";";
C << nl << "return typeId;";
C << eb;
- C << sp;
- C << nl << "const ::std::string&" << nl << scoped.substr(2) << "::ice_id() const";
- C << sb;
- C << nl << "static const ::std::string typeId = \"" << p->scoped() << "\";";
- C << nl << "return typeId;";
- C << eb;
-
C << sp << nl << "namespace";
C << nl << "{";
@@ -8172,9 +8154,9 @@ Slice::Gen::Cpp11ValueVisitor::visitOperation(const OperationPtr&)
bool
-Slice::Gen::Cpp11ObjectVisitor::emitVirtualBaseInitializers(const ClassDefPtr& p)
+Slice::Gen::Cpp11ObjectVisitor::emitVirtualBaseInitializers(const ClassDefPtr& derived, const ClassDefPtr& base)
{
- DataMemberList allDataMembers = p->allDataMembers();
+ DataMemberList allDataMembers = base->allDataMembers();
if(allDataMembers.empty())
{
return false;
@@ -8198,8 +8180,15 @@ Slice::Gen::Cpp11ObjectVisitor::emitVirtualBaseInitializers(const ClassDefPtr& p
}
upcall += ")";
- H << nl << fixKwd(p->scoped()) << upcall;
-
+ if(base->isLocal())
+ {
+ H << nl << fixKwd(base->scoped());
+ }
+ else
+ {
+ H << nl << "Ice::ValueHelper<" << fixKwd(derived->scoped()) << ", " << fixKwd(base->scoped()) << ">";
+ }
+ H << upcall;
return true;
}
@@ -8231,7 +8220,7 @@ Slice::Gen::Cpp11ObjectVisitor::emitOneShotConstructor(const ClassDefPtr& p)
if(!bases.empty() && !bases.front()->isInterface())
{
- if(emitVirtualBaseInitializers(bases.front()))
+ if(emitVirtualBaseInitializers(p, bases.front()))
{
if(!dataMembers.empty())
{
diff --git a/cpp/src/slice2cpp/Gen.h b/cpp/src/slice2cpp/Gen.h
index 3924ff61c19..1507f43fd77 100644
--- a/cpp/src/slice2cpp/Gen.h
+++ b/cpp/src/slice2cpp/Gen.h
@@ -446,7 +446,7 @@ private:
protected:
- bool emitVirtualBaseInitializers(const ClassDefPtr&);
+ bool emitVirtualBaseInitializers(const ClassDefPtr&, const ClassDefPtr&);
void emitOneShotConstructor(const ClassDefPtr&);
void emitDataMember(const DataMemberPtr&);