diff options
Diffstat (limited to 'cpp/src/slice2cpp/Gen.cpp')
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 7d5421e0e1f..6916846b1cb 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -520,6 +520,15 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) } } + H << sp << nl << "struct __" << p->name() << "_init"; + H << sb; + H << nl << "__" << p->name() << "_init();"; + H << eb << ';'; + + C << sp << nl << p->name() << "::__" << p->name() << "_init::__" << p->name() << "_init()"; + C << sb; + C << eb; + string factoryName = "__F" + flattenedScope + name; C << sp << nl << "class " << factoryName << " : public ::IceInternal::UserExceptionFactory"; @@ -570,6 +579,12 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) H << sp << nl << "static const ::std::string _name;"; H << eb << ';'; + + if(!p->isLocal()) + { + H << sp << nl << "static " << name << "::__" << p->name() << "_init __" + << p->name() << "_initializer; // Force initializers in .cpp file to run"; + } } bool @@ -2259,6 +2274,15 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p) C << nl << "extern \"C\" { void " << initfuncname << "() {} }"; C << nl << "#endif"; + H << sp << nl << "struct __" << p->name() << "_init"; + H << sb; + H << nl << "__" << p->name() << "_init();"; + H << eb << ';'; + + C << sp << nl << name << "::__" << p->name() << "_init::__" << name << "_init()"; + C << sb; + C << eb; + H.dec(); H << sp << nl << "private:"; H.inc(); @@ -2268,6 +2292,12 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p) H << eb << ';'; + if(!p->isAbstract() && !p->isLocal()) + { + H << sp << nl << "static " << fixKwd(p->name()) << "::__" << p->name() << "_init __" + << p->name() << "_initializer; // Force initializers in .cpp file to run"; + } + if(p->isLocal()) { C << sp; |