summaryrefslogtreecommitdiff
path: root/cpp/src/slice2cs
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/slice2cs')
-rw-r--r--cpp/src/slice2cs/.depend4
-rw-r--r--cpp/src/slice2cs/Gen.cpp66
-rw-r--r--cpp/src/slice2cs/Gen.h5
-rw-r--r--cpp/src/slice2cs/Main.cpp84
-rw-r--r--cpp/src/slice2cs/Makefile2
-rw-r--r--cpp/src/slice2cs/Makefile.mak2
-rw-r--r--cpp/src/slice2cs/Slice2Cs.rc10
7 files changed, 92 insertions, 81 deletions
diff --git a/cpp/src/slice2cs/.depend b/cpp/src/slice2cs/.depend
index 5e88d13cee9..3681dd8ef03 100644
--- a/cpp/src/slice2cs/.depend
+++ b/cpp/src/slice2cs/.depend
@@ -1,2 +1,2 @@
-Gen$(OBJEXT): Gen.cpp $(includedir)/IceUtil/DisableWarnings.h $(includedir)/IceUtil/Functional.h $(includedir)/IceUtil/Handle.h $(includedir)/IceUtil/Exception.h $(includedir)/IceUtil/Config.h ./Gen.h $(includedir)/Slice/CsUtil.h $(includedir)/Slice/Parser.h $(includedir)/IceUtil/Shared.h $(includedir)/IceUtil/OutputUtil.h $(includedir)/IceUtil/Iterator.h $(includedir)/IceUtil/UUID.h $(includedir)/Slice/Checksum.h $(includedir)/Slice/DotNetNames.h $(includedir)/Slice/SignalHandler.h
-Main$(OBJEXT): Main.cpp $(includedir)/IceUtil/Options.h $(includedir)/IceUtil/Config.h $(includedir)/IceUtil/RecMutex.h $(includedir)/IceUtil/Lock.h $(includedir)/IceUtil/ThreadException.h $(includedir)/IceUtil/Exception.h $(includedir)/IceUtil/Time.h $(includedir)/IceUtil/Shared.h $(includedir)/IceUtil/Handle.h $(includedir)/Slice/Preprocessor.h $(includedir)/Slice/SignalHandler.h ./Gen.h $(includedir)/Slice/CsUtil.h $(includedir)/Slice/Parser.h $(includedir)/IceUtil/OutputUtil.h
+Gen$(OBJEXT): Gen.cpp $(includedir)/IceUtil/DisableWarnings.h $(includedir)/IceUtil/Functional.h $(includedir)/IceUtil/Handle.h $(includedir)/IceUtil/Exception.h $(includedir)/IceUtil/Config.h ./Gen.h $(includedir)/Slice/CsUtil.h $(includedir)/Slice/Parser.h $(includedir)/IceUtil/Shared.h $(includedir)/IceUtil/OutputUtil.h $(includedir)/IceUtil/Iterator.h $(includedir)/IceUtil/UUID.h $(includedir)/Slice/Checksum.h $(includedir)/Slice/DotNetNames.h
+Main$(OBJEXT): Main.cpp $(includedir)/IceUtil/Options.h $(includedir)/IceUtil/Config.h $(includedir)/IceUtil/RecMutex.h $(includedir)/IceUtil/Lock.h $(includedir)/IceUtil/ThreadException.h $(includedir)/IceUtil/Exception.h $(includedir)/IceUtil/Time.h $(includedir)/IceUtil/Shared.h $(includedir)/IceUtil/Handle.h $(includedir)/IceUtil/CtrlCHandler.h $(includedir)/Slice/Preprocessor.h ./Gen.h $(includedir)/Slice/CsUtil.h $(includedir)/Slice/Parser.h $(includedir)/IceUtil/OutputUtil.h
diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp
index e16e3f67600..b3c236cfa1a 100644
--- a/cpp/src/slice2cs/Gen.cpp
+++ b/cpp/src/slice2cs/Gen.cpp
@@ -1,6 +1,6 @@
// **********************************************************************
//
-// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.
+// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
@@ -21,7 +21,8 @@
#include <IceUtil/UUID.h>
#include <Slice/Checksum.h>
#include <Slice/DotNetNames.h>
-#include <Slice/SignalHandler.h>
+#include <Slice/FileTracker.h>
+#include <string.h>
using namespace std;
using namespace Slice;
@@ -39,19 +40,6 @@ 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)
{
@@ -1067,14 +1055,11 @@ Slice::CsVisitor::writeValue(const TypePtr& type)
}
-Slice::Gen::Gen(const string& name, const string& base, const vector<string>& includePaths, const string& dir,
+Slice::Gen::Gen(const string& base, const vector<string>& includePaths, const string& dir,
bool impl, bool implTie, bool stream)
: _includePaths(includePaths),
_stream(stream)
{
- _gen = this;
- SignalHandler::setCallback(closeCallback);
-
string fileBase = base;
string::size_type pos = base.find_last_of("/\\");
if(pos != string::npos)
@@ -1089,15 +1074,15 @@ Slice::Gen::Gen(const string& name, const string& base, const vector<string>& in
file = dir + '/' + file;
fileImpl = dir + '/' + fileImpl;
}
- SignalHandler::addFile(file);
- SignalHandler::addFile(fileImpl);
_out.open(file.c_str());
if(!_out)
{
- cerr << name << ": can't open `" << file << "' for writing" << endl;
- return;
+ ostringstream os;
+ os << "cannot open `" << file << "': " << strerror(errno);
+ throw FileException(__FILE__, __LINE__, os.str());
}
+ FileTracker::instance()->addFile(file);
printHeader();
_out << nl << "// Generated from file `" << fileBase << ".ice'";
@@ -1124,15 +1109,20 @@ Slice::Gen::Gen(const string& name, const string& base, const vector<string>& in
struct stat st;
if(stat(fileImpl.c_str(), &st) == 0)
{
- cerr << name << ": `" << fileImpl << "' already exists--will not overwrite" << endl;
- return;
+ ostringstream os;
+ os << fileImpl << "' already exists - will not overwrite";
+ throw FileException(__FILE__, __LINE__, os.str());
}
+
_impl.open(fileImpl.c_str());
if(!_impl)
{
- cerr << name << ": can't open `" << fileImpl << "' for writing" << endl;
- return;
+ ostringstream os;
+ os << ": cannot open `" << fileImpl << "': " << strerror(errno);
+ throw FileException(__FILE__, __LINE__, os.str());
}
+
+ FileTracker::instance()->addFile(fileImpl);
}
}
@@ -1146,20 +1136,11 @@ Slice::Gen::~Gen()
{
_impl << '\n';
}
-
- SignalHandler::setCallback(0);
-}
-
-bool
-Slice::Gen::operator!() const
-{
- return !_out;
}
void
Slice::Gen::generate(const UnitPtr& p)
{
-
CsGenerator::validateMetaData(p);
UnitVisitor unitVisitor(_out, _stream);
@@ -1223,7 +1204,7 @@ Slice::Gen::generateChecksums(const UnitPtr& u)
string className = "X" + IceUtil::generateUUID();
for(string::size_type pos = 1; pos < className.size(); ++pos)
{
- if(!isalnum(className[pos]))
+ if(!isalnum(static_cast<unsigned char>(className[pos])))
{
className[pos] = '_';
}
@@ -1270,7 +1251,7 @@ Slice::Gen::printHeader()
static const char* header =
"// **********************************************************************\n"
"//\n"
-"// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.\n"
+"// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.\n"
"//\n"
"// This copy of Ice is licensed to you under the terms described in the\n"
"// ICE_LICENSE file included in this distribution.\n"
@@ -3655,7 +3636,6 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p)
bool hasClassValue = (builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(value);
if(hasClassValue)
{
- string expectedType = ContainedPtr::dynamicCast(value)->scoped();
_out << sp << nl << "public sealed class Patcher__ : IceInternal.Patcher<" << valueS << ">";
_out << sb;
_out << sp << nl << "internal Patcher__(string type, " << name << " m, " << keyS << " key) : base(type)";
@@ -3693,7 +3673,7 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p)
{
if(isValueType(key))
{
- _out << nl << "v__ = new " << typeToString(key) << "();";
+ _out << nl << "k__ = new " << typeToString(key) << "();";
}
else
{
@@ -3767,7 +3747,7 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p)
{
if(isValueType(key))
{
- _out << nl << "v__ = new " << typeToString(key) << "();";
+ _out << nl << "k__ = new " << typeToString(key) << "();";
}
else
{
@@ -4025,7 +4005,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p)
_out << nl << "throw new Ice.UnknownUserException(ex.ice_name(), ex);";
_out << eb;
_out << eb;
- if(op->returnsData())
+ if(ret || !outParams.empty())
{
_out << nl << "IceInternal.BasicStream is__ = og__.istr();";
_out << nl << "is__.startReadEncaps();";
@@ -4625,7 +4605,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
_out << eb;
_out << "return;";
_out << eb;
- if(p->returnsData())
+ if(ret || !outParams.empty())
{
_out << nl << "is__.startReadEncaps();";
for(q = outParams.begin(); q != outParams.end(); ++q)
diff --git a/cpp/src/slice2cs/Gen.h b/cpp/src/slice2cs/Gen.h
index c33257945ae..dc9d655570e 100644
--- a/cpp/src/slice2cs/Gen.h
+++ b/cpp/src/slice2cs/Gen.h
@@ -1,6 +1,6 @@
// **********************************************************************
//
-// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.
+// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
@@ -47,7 +47,6 @@ class Gen : private ::IceUtil::noncopyable
public:
Gen(const std::string&,
- const std::string&,
const std::vector<std::string>&,
const std::string&,
bool,
@@ -55,8 +54,6 @@ public:
bool);
~Gen();
- bool operator!() const; // Returns true if there was a constructor error
-
void generate(const UnitPtr&);
void generateTie(const UnitPtr&);
void generateImpl(const UnitPtr&);
diff --git a/cpp/src/slice2cs/Main.cpp b/cpp/src/slice2cs/Main.cpp
index 770ee8b5ea4..595dfe75dc9 100644
--- a/cpp/src/slice2cs/Main.cpp
+++ b/cpp/src/slice2cs/Main.cpp
@@ -1,6 +1,6 @@
// **********************************************************************
//
-// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.
+// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
@@ -8,13 +8,26 @@
// **********************************************************************
#include <IceUtil/Options.h>
+#include <IceUtil/CtrlCHandler.h>
+#include <IceUtil/StaticMutex.h>
#include <Slice/Preprocessor.h>
-#include <Slice/SignalHandler.h>
+#include <Slice/FileTracker.h>
#include <Gen.h>
using namespace std;
using namespace Slice;
+static IceUtil::StaticMutex _mutex = ICE_STATIC_MUTEX_INITIALIZER;
+static bool _interrupted = false;
+
+void
+interruptedCallback(int signal)
+{
+ IceUtil::StaticMutex::Lock lock(_mutex);
+
+ _interrupted = true;
+}
+
void
usage(const char* n)
{
@@ -82,7 +95,7 @@ main(int argc, char* argv[])
if(opts.isSet("version"))
{
- cout << ICE_STRING_VERSION << endl;
+ cerr << ICE_STRING_VERSION << endl;
return EXIT_SUCCESS;
}
@@ -144,14 +157,18 @@ main(int argc, char* argv[])
int status = EXIT_SUCCESS;
+ IceUtil::CtrlCHandler ctrlCHandler;
+ ctrlCHandler.setCallback(interruptedCallback);
+
for(i = args.begin(); i != args.end(); ++i)
{
- SignalHandler sigHandler;
-
if(depend)
{
Preprocessor icecpp(argv[0], *i, cppArgs);
- icecpp.printMakefileDependencies(Preprocessor::CSharp, includePaths);
+ if(!icecpp.printMakefileDependencies(Preprocessor::CSharp, includePaths))
+ {
+ return EXIT_FAILURE;
+ }
}
else
{
@@ -194,34 +211,51 @@ main(int argc, char* argv[])
}
else
{
- Gen gen(argv[0], icecpp.getBaseName(), includePaths, output, impl, implTie, stream);
- if(!gen)
- {
- p->destroy();
- return EXIT_FAILURE;
- }
- gen.generate(p);
- if(tie)
- {
- gen.generateTie(p);
- }
- if(impl)
+ try
{
- gen.generateImpl(p);
+ Gen gen(icecpp.getBaseName(), includePaths, output, impl, implTie, stream);
+ gen.generate(p);
+ if(tie)
+ {
+ gen.generateTie(p);
+ }
+ if(impl)
+ {
+ gen.generateImpl(p);
+ }
+ if(implTie)
+ {
+ gen.generateImplTie(p);
+ }
+ if(checksum)
+ {
+ gen.generateChecksums(p);
+ }
}
- if(implTie)
+ catch(const Slice::FileException& ex)
{
- gen.generateImplTie(p);
- }
- if(checksum)
- {
- gen.generateChecksums(p);
+ // If a file could not be created, then
+ // cleanup any created files.
+ FileTracker::instance()->cleanup();
+ p->destroy();
+ cerr << argv[0] << ": " << ex.reason() << endl;
+ return EXIT_FAILURE;
}
}
p->destroy();
}
}
+
+ {
+ IceUtil::StaticMutex::Lock lock(_mutex);
+
+ if(_interrupted)
+ {
+ FileTracker::instance()->cleanup();
+ return EXIT_FAILURE;
+ }
+ }
}
return status;
diff --git a/cpp/src/slice2cs/Makefile b/cpp/src/slice2cs/Makefile
index ad3d034882a..161b2bb6458 100644
--- a/cpp/src/slice2cs/Makefile
+++ b/cpp/src/slice2cs/Makefile
@@ -1,6 +1,6 @@
# **********************************************************************
#
-# Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.
+# Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
#
# This copy of Ice is licensed to you under the terms described in the
# ICE_LICENSE file included in this distribution.
diff --git a/cpp/src/slice2cs/Makefile.mak b/cpp/src/slice2cs/Makefile.mak
index f9f72b8e5e2..263fc9a09d4 100644
--- a/cpp/src/slice2cs/Makefile.mak
+++ b/cpp/src/slice2cs/Makefile.mak
@@ -1,6 +1,6 @@
# **********************************************************************
#
-# Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.
+# Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
#
# This copy of Ice is licensed to you under the terms described in the
# ICE_LICENSE file included in this distribution.
diff --git a/cpp/src/slice2cs/Slice2Cs.rc b/cpp/src/slice2cs/Slice2Cs.rc
index 0bc6cbf755c..5d9b7390e83 100644
--- a/cpp/src/slice2cs/Slice2Cs.rc
+++ b/cpp/src/slice2cs/Slice2Cs.rc
@@ -1,8 +1,8 @@
#include "winver.h"
VS_VERSION_INFO VERSIONINFO
- FILEVERSION 3,3,0,0
- PRODUCTVERSION 3,3,0,0
+ FILEVERSION 3,3,1,0
+ PRODUCTVERSION 3,3,1,0
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
#ifdef _DEBUG
FILEFLAGS VS_FF_DEBUG
@@ -19,12 +19,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "ZeroC, Inc.\0"
VALUE "FileDescription", "Slice To C# Translator\0"
- VALUE "FileVersion", "3.3.0\0"
+ VALUE "FileVersion", "3.3.1\0"
VALUE "InternalName", "slice2cs\0"
- VALUE "LegalCopyright", "Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.\0"
+ VALUE "LegalCopyright", "Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.\0"
VALUE "OriginalFilename", "slice2cs.exe\0"
VALUE "ProductName", "Ice\0"
- VALUE "ProductVersion", "3.3.0\0"
+ VALUE "ProductVersion", "3.3.1\0"
END
END
BLOCK "VarFileInfo"