summaryrefslogtreecommitdiff
path: root/cpp/src/slice2cppe
diff options
context:
space:
mode:
authorMichi Henning <michi@zeroc.com>2005-06-20 12:48:38 +0000
committerMichi Henning <michi@zeroc.com>2005-06-20 12:48:38 +0000
commitec7622852746c5f8f73b26ecf4c42fb5baeffca1 (patch)
tree88704bf921222d742e6327073b69e06828d8bc97 /cpp/src/slice2cppe
parentAnother fix for bug 377 -- the string wrapper was incorrect as well. (diff)
downloadice-ec7622852746c5f8f73b26ecf4c42fb5baeffca1.tar.bz2
ice-ec7622852746c5f8f73b26ecf4c42fb5baeffca1.tar.xz
ice-ec7622852746c5f8f73b26ecf4c42fb5baeffca1.zip
Removed copy constructor and assignment operator for exceptions and
classes. Removed #undef scheme and add UndefSysMacros.h instead.
Diffstat (limited to 'cpp/src/slice2cppe')
-rw-r--r--cpp/src/slice2cppe/Gen.cpp131
1 files changed, 56 insertions, 75 deletions
diff --git a/cpp/src/slice2cppe/Gen.cpp b/cpp/src/slice2cppe/Gen.cpp
index 68bb90f9a24..30dd9bbbcd4 100644
--- a/cpp/src/slice2cppe/Gen.cpp
+++ b/cpp/src/slice2cppe/Gen.cpp
@@ -218,6 +218,8 @@ Slice::Gen::generate(const UnitPtr& p)
H << "\n#include <" << changeInclude(*q, _includePaths) << "." << _headerExtension << ">";
}
+ H << "\n#include <Ice/UndefSysMacros.h>";
+
printVersionCheck(H);
printVersionCheck(C);
@@ -337,10 +339,6 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
}
}
- H.zeroIndent();
- H << sp << "#undef " << name;
- H.restoreIndent();
-
H << sp << nl << "class " << _dllExport << name << " : ";
H.useCurrentPosAsIndent();
H << "public ";
@@ -388,9 +386,9 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
if(p->isLocal())
{
- C << sp << nl << scoped << "::" << name << spar << "const char* __file" << "int __line" << epar << " :";
+ C << sp << nl << scoped.substr(2) << "::" << name << spar << "const char* __file" << "int __line" << epar
+ << " :";
C.inc();
- C << nl;
emitUpcall(base, "(__file, __line)", true);
C.dec();
C << sb;
@@ -399,10 +397,8 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
if(!allTypes.empty())
{
- writeUndefines(C, params);
-
C << sp << nl;
- C << scoped << "::" << name << spar;
+ C << scoped.substr(2) << "::" << name << spar;
if(p->isLocal())
{
C << "const char* __file" << "int __line";
@@ -412,34 +408,37 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
{
C << " :";
C.inc();
- C << nl;
- }
- if(p->isLocal() || !baseParams.empty())
- {
- if(p->isLocal())
+ string upcall;
+ if(!allParamDecls.empty())
{
- C << (base ? fixKwd(base->scoped()) : "::Ice::LocalException") << spar << "__file" << "__line";
+ upcall = "(";
+ if(p->isLocal())
+ {
+ upcall += "__file, __line";
+ }
+ for(pi = baseParams.begin(); pi != baseParams.end(); ++pi)
+ {
+ if(p->isLocal() || pi != baseParams.begin())
+ {
+ upcall += ", ";
+ }
+ upcall += *pi;
+ }
+ upcall += ")";
}
- else
+ if(!params.empty())
{
- C << fixKwd(base->scoped()) << spar;
+ upcall += ",";
}
- C << baseParams << epar;
+ emitUpcall(base, upcall, p->isLocal());
}
- if(!params.empty())
+ for(pi = params.begin(); pi != params.end(); ++pi)
{
- if(p->isLocal() || !baseParams.empty())
+ if(pi != params.begin())
{
- C << ',' << nl;
- }
- for(pi = params.begin(); pi != params.end(); ++pi)
- {
- if(pi != params.begin())
- {
- C << ',' << nl;
- }
- C << *pi << "(__" << *pi << ')';
+ C << ",";
}
+ C << nl << *pi << "(__" << *pi << ')';
}
if(p->isLocal() || !baseParams.empty() || !params.empty())
{
@@ -461,7 +460,7 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
if(p->isLocal())
{
- H << nl << "virtual ::std::string toString() const;";
+ H << nl << "virtual void ice_print(::std::ostream&) const;";
}
H << nl << "virtual ::Ice::Exception* ice_clone() const;";
@@ -973,11 +972,11 @@ Slice::Gen::TypesVisitor::emitUpcall(const ExceptionPtr& base, const string& cal
C.zeroIndent();
C << nl << "#if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug"; // COMPILERBUG
C.restoreIndent();
- C << nl << (base ? fixKwd(base->name()) : (isLocal ? "LocalException" : "Exception")) << call;
+ C << nl << (base ? fixKwd(base->name()) : (isLocal ? "LocalException" : "UserException")) << call;
C.zeroIndent();
C << nl << "#else";
C.restoreIndent();
- C << nl << (base ? fixKwd(base->scoped()) : (isLocal ? "::Ice::LocalException" : "::Ice::Exception")) << call;
+ C << nl << (base ? fixKwd(base->scoped()) : (isLocal ? "::Ice::LocalException" : "::Ice::UserException")) << call;
C.zeroIndent();
C << nl << "#endif";
C.restoreIndent();
@@ -1561,15 +1560,15 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p)
string name = fixKwd(p->name());
string scoped = fixKwd(p->scoped());
ClassList bases = p->bases();
- bool hasBaseClass = !bases.empty() && !bases.front()->isInterface();
+ ClassDefPtr base;
+ if(!bases.empty() && !bases.front()->isInterface())
+ {
+ base = bases.front();
+ }
DataMemberList dataMembers = p->dataMembers();
DataMemberList allDataMembers = p->allDataMembers();
DataMemberList::const_iterator q;
- H.zeroIndent();
- H << sp << nl << "#undef " << name;
- H.restoreIndent();
-
H << sp << nl << "class " << _dllExport << name << " : ";
H.useCurrentPosAsIndent();
if(bases.empty())
@@ -1631,11 +1630,14 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p)
}
H << name << spar << allTypes << epar << ';';
}
- H << nl << name << "(const " << name << "&)";
- if(allDataMembers.empty())
- {
- H << " {}";
- }
+
+ /*
+ * Strong guarantee: commented-out code marked "String guarantee" generates
+ * a copy-assignment operator that provides the strong exception guarantee.
+ * For now, this is commented out, and we use the compiler-generated
+ * copy-assignment operator. However, that one does not provide the strong
+ * guarantee.
+
H << ';';
if(!p->isAbstract())
{
@@ -1666,15 +1668,17 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p)
}
H << eb;
+ * Strong guarantee
+ */
+
if(!allParamDecls.empty())
{
- writeUndefines(C, params);
C << sp << nl << scoped.substr(2) << "::" << name << spar << allParamDecls << epar << " :";
C.inc();
- if(hasBaseClass)
+ if(base)
{
string upcall;
- if(!allParamDecls.empty() && hasBaseClass)
+ if(!allParamDecls.empty() && base)
{
upcall = "(";
DataMemberList baseDataMembers = bases.front()->allDataMembers();
@@ -1692,7 +1696,7 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p)
{
upcall += ",";
}
- emitUpcall(bases.front(), upcall);
+ emitUpcall(base, upcall);
}
C << nl;
for(pi = params.begin(); pi != params.end(); ++pi)
@@ -1708,33 +1712,8 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p)
C << eb;
}
- if(!allParamDecls.empty())
- {
- C << sp << nl << scoped.substr(2) << "::" << name << "(const " << name << "& __rhs)";
- C << " :";
- C.inc();
- if(hasBaseClass)
- {
- string upcall = "(__rhs)";
- if(!params.empty())
- {
- upcall += ",";
- }
- emitUpcall(bases.front(), upcall);
- }
- C << nl;
- for(pi = params.begin(); pi != params.end(); ++pi)
- {
- if(pi != params.begin())
- {
- C << ',' << nl;
- }
- C << *pi << '(' << "__rhs." << *pi << ')';
- }
- C.dec();
- C << sb;
- C << eb;
- }
+ /*
+ * Strong guarantee
if(!allDataMembers.empty())
{
@@ -1742,9 +1721,9 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p)
C << nl << scoped.substr(2) << "::__swap(" << name << "& __lhs, " << name << "& __rhs) throw()";
C << sb;
- if(hasBaseClass)
+ if(base)
{
- emitUpcall(bases.front(), "::__swap(__lhs, __rhs);");
+ emitUpcall(base, "::__swap(__lhs, __rhs);");
}
//
@@ -1806,6 +1785,8 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p)
}
}
+ * Strong guarantee
+ */
}
if(!p->isLocal())