From 9cd6741e46f1c21b41f1b5ce8aae65d8a67458cb Mon Sep 17 00:00:00 2001 From: Michi Henning Date: Wed, 6 Aug 2003 02:32:09 +0000 Subject: Added ice_clone() for classes. --- cpp/src/slice2cpp/Gen.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'cpp/src/slice2cpp/Gen.cpp') diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index db026b60b0f..b93b6064cdf 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -2125,6 +2125,44 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p) H << nl << "public:"; H.inc(); + if(!p->isAbstract()) + { + H << nl << "void __copyMembers(" << scoped << "Ptr) const;"; + + C << sp; + C << nl << "void "; + C << nl << scoped.substr(2) << "::__copyMembers(" << scoped << "Ptr to) const"; + C << sb; + DataMemberList dataMembers = p->dataMembers(); + for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) + { + C << nl << "to->" << (*q)->name() << " = " << (*q)->name() << ";"; + } + C << eb; + + H << nl << "virtual ::Ice::ObjectPtr ice_clone() const;"; + + C << sp; + C << nl << "::Ice::ObjectPtr"; + C << nl << scoped.substr(2) << "::ice_clone() const"; + C << sb; + C << nl << scoped << "Ptr __p = new " << scoped << ";"; + if(!bases.empty() && !bases.front()->isInterface()) + { + C << nl << fixKwd(bases.front()->scoped()) << "::__copyMembers(__p);"; + } + else + { + C << nl << "::Ice::Object::__copyMembers(__p);"; + } + if(!dataMembers.empty()) + { + C << nl << scoped << "::__copyMembers(__p);"; + } + C << nl << "return __p;"; + C << eb; + } + if(!p->isLocal()) { ClassList allBases = p->allBases(); @@ -2163,6 +2201,7 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p) H.inc(); H << sp << nl << "static const ::Ice::ObjectFactoryPtr& ice_factory();"; } + C << sp; C << nl << "const ::std::string " << scoped.substr(2) << "::__ids[" << ids.size() << "] ="; C << sb; -- cgit v1.2.3