summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2004-03-01 20:13:14 +0000
committerBernard Normier <bernard@zeroc.com>2004-03-01 20:13:14 +0000
commit5d33b030f2c0961d5dcfeffa944ade8ea0921ad0 (patch)
tree1e093d83820ea127374b690c79f1af256067923c /cpp/src
parentchanging version to 1.3.0 (diff)
downloadice-5d33b030f2c0961d5dcfeffa944ade8ea0921ad0.tar.bz2
ice-5d33b030f2c0961d5dcfeffa944ade8ea0921ad0.tar.xz
ice-5d33b030f2c0961d5dcfeffa944ade8ea0921ad0.zip
Nested exception support + test
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/slice2cpp/Gen.cpp31
1 files changed, 18 insertions, 13 deletions
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index 1fa5e0ee206..87774fc7602 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -431,6 +431,13 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
if(!p->isLocal())
{
+ string flattenedScope;
+
+ for(string::const_iterator r = scope.begin(); r != scope.end(); ++r)
+ {
+ flattenedScope += ((*r) == ':') ? '_' : *r;
+ }
+
string scoped = fixKwd(p->scoped());
ExceptionPtr base = p->base();
@@ -478,7 +485,9 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
}
}
- C << sp << nl << "class __F__" << name << " : public ::IceInternal::UserExceptionFactory";
+ string factoryName = "__F" + flattenedScope + name;
+
+ C << sp << nl << "class " << factoryName << " : public ::IceInternal::UserExceptionFactory";
C << sb;
C.dec();
C << nl << "public:";
@@ -490,32 +499,28 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
C << eb;
C << eb << ';';
- C << sp << nl << "::IceInternal::UserExceptionFactoryPtr " << scoped.substr(2) << "::_factory = new __F__"
- << name << ';';
+ C << sp << nl << "::IceInternal::UserExceptionFactoryPtr " << scoped.substr(2) << "::_factory = new "
+ << factoryName << ';';
- C << sp << nl << "class __F__" << name << "__Init";
+ C << sp << nl << "class " << factoryName << "__Init";
C << sb;
C.dec();
C << nl << "public:";
C.inc();
- C << sp << nl << "__F__" << name << "__Init()";
+ C << sp << nl << factoryName << "__Init()";
C << sb;
C << nl << "::Ice::factoryTable->addExceptionFactory(\"" << p->scoped() << "\", " << scoped
<< "::ice_factory());";
C << eb;
- C << sp << nl << "~__F__" << name << "__Init()";
+ C << sp << nl << "~" << factoryName << "__Init()";
C << sb;
C << nl << "::Ice::factoryTable->removeExceptionFactory(\"" << p->scoped() << "\");";
C << eb;
C << eb << ';';
- C << sp << nl << "static __F__" << name << "__Init __F__" << name << "__i;";
+ C << sp << nl << "static " << factoryName << "__Init "<< factoryName << "__i;";
C << sp << nl << "#ifdef __APPLE__";
- std::string initfuncname = "__F";
- for(std::string::const_iterator p = scope.begin(); p != scope.end(); ++p)
- {
- initfuncname += ((*p) == ':') ? '_' : *p;
- }
- initfuncname += name + "__initializer";
+
+ string initfuncname = "__F" + flattenedScope + name + "__initializer";
C << nl << "extern \"C\" { void " << initfuncname << "() {} }";
C << nl << "#endif";
}