diff options
author | Michi Henning <michi@zeroc.com> | 2005-07-20 00:59:46 +0000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2005-07-20 00:59:46 +0000 |
commit | 154d294f53e38f1efc716f579b05ace811b6fe3a (patch) | |
tree | d9f95db34692238b9e760cf1038f6d6d69e2bc6a /cpp/src/slice2cpp/Gen.cpp | |
parent | fix for signed -> unsigned conversion (diff) | |
download | ice-154d294f53e38f1efc716f579b05ace811b6fe3a.tar.bz2 ice-154d294f53e38f1efc716f579b05ace811b6fe3a.tar.xz ice-154d294f53e38f1efc716f579b05ace811b6fe3a.zip |
Fixed bug 369.
Diffstat (limited to 'cpp/src/slice2cpp/Gen.cpp')
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 1581902013b..c8546ca257c 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -340,7 +340,7 @@ Slice::Gen::generate(const UnitPtr& p) } Slice::Gen::TypesVisitor::TypesVisitor(Output& h, Output& c, const string& dllExport, bool stream) : - H(h), C(c), _dllExport(dllExport), _stream(stream) + H(h), C(c), _dllExport(dllExport), _stream(stream), _doneStaticSymbol(false) { } @@ -715,7 +715,16 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) if(!p->isLocal()) { - H << sp << nl << "static " << name << " __" << p->name() << "_init;"; + // + // We need an instance here to trigger initialization if the implementation is in a shared libarry. + // But we do this only once per source file, because a single instance is sufficient to initialize + // all of the globals in a shared library. + // + if(!_doneStaticSymbol) + { + _doneStaticSymbol = true; + H << sp << nl << "static " << name << " __" << p->name() << "_init;"; + } } } @@ -2191,7 +2200,7 @@ Slice::Gen::ObjectDeclVisitor::visitClassDecl(const ClassDeclPtr& p) } Slice::Gen::ObjectVisitor::ObjectVisitor(Output& h, Output& c, const string& dllExport, bool stream) : - H(h), C(c), _dllExport(dllExport), _stream(stream) + H(h), C(c), _dllExport(dllExport), _stream(stream), _doneStaticSymbol(false) { } @@ -2785,7 +2794,16 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p) if(!p->isAbstract() && !p->isLocal()) { - H << sp << nl << "static " << scoped << " __" << p->name() << "_init;"; + // + // We need an instance here to trigger initialization if the implementation is in a shared libarry. + // But we do this only once per source file, because a single instance is sufficient to initialize + // all of the globals in a shared library. + // + if(!_doneStaticSymbol) + { + _doneStaticSymbol = true; + H << sp << nl << "static " << scoped << " __" << p->name() << "_init;"; + } } if(p->isLocal()) |