diff options
author | Jose <jose@zeroc.com> | 2016-01-11 22:44:55 +0100 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2016-01-11 22:44:55 +0100 |
commit | d159c9f1574a2e768c947ad697a1e1e2205d194c (patch) | |
tree | 86e784ac7347c1dfa92304be2a9355a7a535dbcc /cpp/src | |
parent | Add ICE_RESET_EXCEPTION macro to simplify C++ builds (diff) | |
download | ice-d159c9f1574a2e768c947ad697a1e1e2205d194c.tar.bz2 ice-d159c9f1574a2e768c947ad697a1e1e2205d194c.tar.xz ice-d159c9f1574a2e768c947ad697a1e1e2205d194c.zip |
C++11 Value::ice_clone improvements
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/AsyncResult.cpp | 2 | ||||
-rw-r--r-- | cpp/src/Ice/Value.cpp | 2 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 47 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Gen.h | 2 |
4 files changed, 21 insertions, 32 deletions
diff --git a/cpp/src/Ice/AsyncResult.cpp b/cpp/src/Ice/AsyncResult.cpp index 7387366cbed..68b0af9745e 100644 --- a/cpp/src/Ice/AsyncResult.cpp +++ b/cpp/src/Ice/AsyncResult.cpp @@ -441,7 +441,7 @@ AsyncResult::cancel(const Ice::LocalException& ex) } handler = _cancellationHandler; } - handler->asyncRequestCanceled(ICE_DYNAMIC_CAST(OutgoingAsyncBase, shared_from_this()), ex); + handler->asyncRequestCanceled(ICE_DYNAMIC_CAST(OutgoingAsyncBase, ICE_SHARED_FROM_THIS), ex); } void diff --git a/cpp/src/Ice/Value.cpp b/cpp/src/Ice/Value.cpp index 751794d1500..174a8a0857b 100644 --- a/cpp/src/Ice/Value.cpp +++ b/cpp/src/Ice/Value.cpp @@ -68,7 +68,7 @@ Ice::Value::ice_id() const ValuePtr Ice::Value::ice_clone() const { - return make_shared<Value>(*this); + return cloneImpl(); } #endif 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&); |