summaryrefslogtreecommitdiff
path: root/cpp/src/slice2py/Main.cpp
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2008-01-18 10:27:58 -0330
committerDwayne Boone <dwayne@zeroc.com>2008-01-18 10:27:58 -0330
commit40da4a3aecbc259c472d77f58d1d6466af42e5ef (patch)
tree3780215d0441c84682c9c281b3187b78973a6b9e /cpp/src/slice2py/Main.cpp
parentAdded Windows signal handling (diff)
downloadice-40da4a3aecbc259c472d77f58d1d6466af42e5ef.tar.bz2
ice-40da4a3aecbc259c472d77f58d1d6466af42e5ef.tar.xz
ice-40da4a3aecbc259c472d77f58d1d6466af42e5ef.zip
Windows fixes for translator interrupt cleanup
Diffstat (limited to 'cpp/src/slice2py/Main.cpp')
-rw-r--r--cpp/src/slice2py/Main.cpp26
1 files changed, 20 insertions, 6 deletions
diff --git a/cpp/src/slice2py/Main.cpp b/cpp/src/slice2py/Main.cpp
index 521786ac6ce..c0d7dd61be3 100644
--- a/cpp/src/slice2py/Main.cpp
+++ b/cpp/src/slice2py/Main.cpp
@@ -33,6 +33,16 @@ using namespace Slice;
using namespace Slice::Python;
//
+// Callback for Crtl-C signal handling
+//
+static IceUtilInternal::Output _out;
+
+static void closeCallback()
+{
+ _out.close();
+}
+
+//
// For each Slice file Foo.ice we generate Foo_ice.py containing the Python
// mappings. Furthermore, for each Slice module M in Foo.ice, we create a
// Python package of the same name. This package is simply a subdirectory
@@ -538,22 +548,26 @@ main(int argc, char* argv[])
}
SignalHandler::addFile(file);
- IceUtilInternal::Output out;
- out.open(file.c_str());
- if(!out)
+ SignalHandler::setCallback(closeCallback);
+
+ _out.open(file.c_str());
+ if(!_out)
{
cerr << argv[0] << ": can't open `" << file << "' for writing" << endl;
u->destroy();
return EXIT_FAILURE;
}
- printHeader(out);
- out << "\n# Generated from file `" << base << ".ice'\n";
+ printHeader(_out);
+ _out << "\n# Generated from file `" << base << ".ice'\n";
//
// Generate the Python mapping.
//
- generate(u, all, checksum, includePaths, out);
+ generate(u, all, checksum, includePaths, _out);
+
+ _out.close();
+ SignalHandler::setCallback(0);
//
// Create or update the Python package hierarchy.