diff options
Diffstat (limited to 'cpp/src/slice2sl/Gen.cpp')
-rwxr-xr-x | cpp/src/slice2sl/Gen.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/cpp/src/slice2sl/Gen.cpp b/cpp/src/slice2sl/Gen.cpp index 604c6e0e5d3..63f13486e9b 100755 --- a/cpp/src/slice2sl/Gen.cpp +++ b/cpp/src/slice2sl/Gen.cpp @@ -38,6 +38,19 @@ using IceUtilInternal::eb; using IceUtilInternal::spar; using IceUtilInternal::epar; +// +// Callback for Crtl-C signal handling +// +static Gen* _gen = 0; + +static void closeCallback() +{ + if(_gen != 0) + { + _gen->closeOutput(); + } +} + static string // Should be an anonymous namespace, but VC++ 6 can't handle that. sliceModeToIceMode(Operation::Mode opMode) { @@ -488,6 +501,9 @@ Slice::CsVisitor::emitAttributes(const ContainedPtr& p) Slice::Gen::Gen(const string& name, const string& base, const vector<string>& includePaths, const string& dir) : _includePaths(includePaths) { + _gen = this; + SignalHandler::setCallback(closeCallback); + string fileBase = base; string::size_type pos = base.find_last_of("/\\"); if(pos != string::npos) @@ -529,6 +545,8 @@ Slice::Gen::~Gen() { _impl << '\n'; } + + SignalHandler::setCallback(0); } bool @@ -566,6 +584,13 @@ Slice::Gen::generate(const UnitPtr& p) } void +Slice::Gen::closeOutput() +{ + _out.close(); + _impl.close(); +} + +void Slice::Gen::printHeader() { static const char* header = |