summaryrefslogtreecommitdiff
path: root/cpp/src/slice2java
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/slice2java')
-rw-r--r--cpp/src/slice2java/.depend2
-rw-r--r--cpp/src/slice2java/Gen.cpp380
-rw-r--r--cpp/src/slice2java/Gen.h2
-rw-r--r--cpp/src/slice2java/Main.cpp114
-rw-r--r--cpp/src/slice2java/Makefile2
-rw-r--r--cpp/src/slice2java/Makefile.mak2
-rw-r--r--cpp/src/slice2java/Slice2Java.rc10
7 files changed, 243 insertions, 269 deletions
diff --git a/cpp/src/slice2java/.depend b/cpp/src/slice2java/.depend
index 07a9fd98908..e140be10882 100644
--- a/cpp/src/slice2java/.depend
+++ b/cpp/src/slice2java/.depend
@@ -1,2 +1,2 @@
Gen$(OBJEXT): Gen.cpp $(includedir)/IceUtil/DisableWarnings.h ./Gen.h $(includedir)/Slice/Parser.h $(includedir)/IceUtil/Shared.h $(includedir)/IceUtil/Config.h $(includedir)/IceUtil/Handle.h $(includedir)/IceUtil/Exception.h $(includedir)/Slice/JavaUtil.h $(includedir)/IceUtil/OutputUtil.h $(includedir)/Slice/Checksum.h $(includedir)/IceUtil/Functional.h $(includedir)/IceUtil/Iterator.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/Parser.h $(includedir)/Slice/JavaUtil.h $(includedir)/IceUtil/OutputUtil.h $(includedir)/Slice/Checksum.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/Parser.h $(includedir)/Slice/JavaUtil.h $(includedir)/IceUtil/OutputUtil.h $(includedir)/Slice/Checksum.h
diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp
index 974d0b6e647..ab9cc42aed4 100644
--- a/cpp/src/slice2java/Gen.cpp
+++ b/cpp/src/slice2java/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.
@@ -1279,11 +1279,7 @@ Slice::Gen::writeChecksumClass(const string& checksumClass, const string& dir, c
// Attempt to open the source file for the checksum class.
//
JavaOutput out;
- if(!out.openClass(checksumClass, dir))
- {
- cerr << "can't open class `" << checksumClass << "' for writing: " << strerror(errno) << endl;
- return;
- }
+ out.openClass(checksumClass, dir);
//
// Get the class name.
@@ -1383,10 +1379,7 @@ Slice::Gen::OpsVisitor::writeOperations(const ClassDefPtr& p, bool noCurrent)
}
string absolute = getAbsolute(p, "", "_", opIntfName);
- if(!open(absolute))
- {
- return;
- }
+ open(absolute);
Output& out = output();
@@ -1507,10 +1500,7 @@ Slice::Gen::TieVisitor::visitClassDefStart(const ClassDefPtr& p)
return false;
}
- if(!open(absolute))
- {
- return false;
- }
+ open(absolute);
Output& out = output();
@@ -1693,11 +1683,7 @@ Slice::Gen::PackageVisitor::visitModuleStart(const ModulePtr& p)
{
string markerClass = s.substr(packagePrefix.size()) + "." + fixKwd(p->name()) + "._Marker";
- if(!open(markerClass))
- {
- cerr << "can't open class `" << markerClass << "' for writing: " << strerror(errno) << endl;
- return false;
- }
+ open(markerClass);
Output& out = output();
out << sp << nl << "interface _Marker";
@@ -1733,10 +1719,7 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
DataMemberList allDataMembers = p->allDataMembers();
DataMemberList::const_iterator d;
- if(!open(absolute))
- {
- return false;
- }
+ open(absolute);
Output& out = output();
@@ -1951,10 +1934,7 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
DataMemberList members = p->dataMembers();
DataMemberList::const_iterator d;
- if(!open(absolute))
- {
- return false;
- }
+ open(absolute);
Output& out = output();
@@ -2285,10 +2265,7 @@ Slice::Gen::TypesVisitor::visitStructStart(const StructPtr& p)
string name = fixKwd(p->name());
string absolute = getAbsolute(p);
- if(!open(absolute))
- {
- return false;
- }
+ open(absolute);
Output& out = output();
@@ -2670,7 +2647,7 @@ Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p)
if(p->hasMetaData(_getSetMetaData) || contained->hasMetaData(_getSetMetaData))
{
string capName = p->name();
- capName[0] = toupper(capName[0]);
+ capName[0] = toupper(static_cast<unsigned char>(capName[0]));
//
// If container is a class, get all of its operations so that we can check for conflicts.
@@ -2809,10 +2786,7 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p)
EnumeratorList::const_iterator en;
size_t sz = enumerators.size();
- if(!open(absolute))
- {
- return;
- }
+ open(absolute);
Output& out = output();
@@ -3035,10 +3009,8 @@ Slice::Gen::TypesVisitor::visitConst(const ConstPtr& p)
string absolute = getAbsolute(p);
TypePtr type = p->type();
- if(!open(absolute))
- {
- return;
- }
+ open(absolute);
+
Output& out = output();
out << sp << nl << "public interface " << name;
out << sb;
@@ -3057,7 +3029,7 @@ Slice::Gen::TypesVisitor::visitConst(const ConstPtr& p)
const string val = p->value();
for(string::const_iterator c = val.begin(); c != val.end(); ++c)
{
- if(isascii(*c) && isprint(*c))
+ if(isascii(static_cast<unsigned char>(*c)) && isprint(static_cast<unsigned char>(*c)))
{
switch(*c)
{
@@ -3188,22 +3160,20 @@ Slice::Gen::HolderVisitor::visitClassDefStart(const ClassDefPtr& p)
string name = p->name();
string absolute = getAbsolute(p, "", "", "PrxHolder");
- if(open(absolute))
- {
- Output& out = output();
- out << sp << nl << "public final class " << name << "PrxHolder";
- out << sb;
- out << sp << nl << "public" << nl << name << "PrxHolder()";
- out << sb;
- out << eb;
- out << sp << nl << "public" << nl << name << "PrxHolder(" << name << "Prx value)";
- out << sb;
- out << nl << "this.value = value;";
- out << eb;
- out << sp << nl << "public " << name << "Prx value;";
- out << eb;
- close();
- }
+ open(absolute);
+ Output& out = output();
+ out << sp << nl << "public final class " << name << "PrxHolder";
+ out << sb;
+ out << sp << nl << "public" << nl << name << "PrxHolder()";
+ out << sb;
+ out << eb;
+ out << sp << nl << "public" << nl << name << "PrxHolder(" << name << "Prx value)";
+ out << sb;
+ out << nl << "this.value = value;";
+ out << eb;
+ out << sp << nl << "public " << name << "Prx value;";
+ out << eb;
+ close();
}
return false;
@@ -3242,68 +3212,66 @@ Slice::Gen::HolderVisitor::writeHolder(const TypePtr& p)
string name = contained->name();
string absolute = getAbsolute(contained, "", "", "Holder");
- if(open(absolute))
+ open(absolute);
+ Output& out = output();
+ string typeS = typeToString(p, TypeModeIn, getPackage(contained));
+ out << sp << nl << "public final class " << name << "Holder";
+ out << sb;
+ out << sp << nl << "public" << nl << name << "Holder()";
+ out << sb;
+ out << eb;
+ out << sp << nl << "public" << nl << name << "Holder(" << typeS << " value)";
+ out << sb;
+ out << nl << "this.value = value;";
+ out << eb;
+ if(!p->isLocal())
{
- Output& out = output();
- string typeS = typeToString(p, TypeModeIn, getPackage(contained));
- out << sp << nl << "public final class " << name << "Holder";
- out << sb;
- out << sp << nl << "public" << nl << name << "Holder()";
- out << sb;
- out << eb;
- out << sp << nl << "public" << nl << name << "Holder(" << typeS << " value)";
- out << sb;
- out << nl << "this.value = value;";
- out << eb;
- if(!p->isLocal())
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(p);
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(p))
{
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(p);
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(p))
+ out << sp << nl << "public class Patcher implements IceInternal.Patcher";
+ if(_stream)
{
- out << sp << nl << "public class Patcher implements IceInternal.Patcher";
- if(_stream)
- {
- out << ", Ice.ReadObjectCallback";
- }
- out << sb;
- out << nl << "public void";
- out << nl << "patch(Ice.Object v)";
- out << sb;
- out << nl << "try";
- out << sb;
- out << nl << "value = (" << typeS << ")v;";
- out << eb;
- out << nl << "catch(ClassCastException ex)";
- out << sb;
- out << nl << "IceInternal.Ex.throwUOE(type(), v.ice_id());";
- out << eb;
- out << eb;
-
- out << sp << nl << "public String" << nl << "type()";
- out << sb;
- out << nl << "return \"" << p->typeId() << "\";";
- out << eb;
+ out << ", Ice.ReadObjectCallback";
+ }
+ out << sb;
+ out << nl << "public void";
+ out << nl << "patch(Ice.Object v)";
+ out << sb;
+ out << nl << "try";
+ out << sb;
+ out << nl << "value = (" << typeS << ")v;";
+ out << eb;
+ out << nl << "catch(ClassCastException ex)";
+ out << sb;
+ out << nl << "IceInternal.Ex.throwUOE(type(), v.ice_id());";
+ out << eb;
+ out << eb;
- if(_stream)
- {
- out << sp << nl << "public void" << nl << "invoke(Ice.Object v)";
- out << sb;
- out << nl << "patch(v);";
- out << eb;
- }
- out << eb;
+ out << sp << nl << "public String" << nl << "type()";
+ out << sb;
+ out << nl << "return \"" << p->typeId() << "\";";
+ out << eb;
- out << sp << nl << "public Patcher";
- out << nl << "getPatcher()";
+ if(_stream)
+ {
+ out << sp << nl << "public void" << nl << "invoke(Ice.Object v)";
out << sb;
- out << nl << "return new Patcher();";
+ out << nl << "patch(v);";
out << eb;
}
+ out << eb;
+
+ out << sp << nl << "public Patcher";
+ out << nl << "getPatcher()";
+ out << sb;
+ out << nl << "return new Patcher();";
+ out << eb;
}
- out << sp << nl << "public " << typeS << " value;";
- out << eb;
- close();
}
+ out << sp << nl << "public " << typeS << " value;";
+ out << eb;
+ close();
}
Slice::Gen::HelperVisitor::HelperVisitor(const string& dir, bool stream) :
@@ -3328,10 +3296,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
string package = getPackage(p);
string absolute = getAbsolute(p);
- if(!open(getAbsolute(p, "", "", "PrxHelper")))
- {
- return false;
- }
+ open(getAbsolute(p, "", "", "PrxHelper"));
Output& out = output();
@@ -3698,10 +3663,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
//
// Class helper.
//
- if(!open(getAbsolute(p, "", "", "Helper")))
- {
- return false;
- }
+ open(getAbsolute(p, "", "", "Helper"));
Output& out2 = output();
@@ -3733,10 +3695,7 @@ Slice::Gen::HelperVisitor::visitStructStart(const StructPtr& p)
string name = p->name();
string fixedName = fixKwd(name);
- if(!open(getAbsolute(p, "", "", "Helper")))
- {
- return false;
- }
+ open(getAbsolute(p, "", "", "Helper"));
Output& out = output();
@@ -3779,48 +3738,46 @@ Slice::Gen::HelperVisitor::visitSequence(const SequencePtr& p)
string package = getPackage(p);
string typeS = typeToString(p, TypeModeIn, package);
- if(open(helper))
- {
- Output& out = output();
- int iter;
+ open(helper);
+ Output& out = output();
+ int iter;
- out << sp << nl << "public final class " << name << "Helper";
- out << sb;
+ out << sp << nl << "public final class " << name << "Helper";
+ out << sb;
- out << nl << "public static void" << nl << "write(IceInternal.BasicStream __os, " << typeS << " __v)";
+ out << nl << "public static void" << nl << "write(IceInternal.BasicStream __os, " << typeS << " __v)";
+ out << sb;
+ iter = 0;
+ writeSequenceMarshalUnmarshalCode(out, package, p, "__v", true, iter, false);
+ out << eb;
+
+ out << sp << nl << "public static " << typeS << nl << "read(IceInternal.BasicStream __is)";
+ out << sb;
+ out << nl << typeS << " __v;";
+ iter = 0;
+ writeSequenceMarshalUnmarshalCode(out, package, p, "__v", false, iter, false);
+ out << nl << "return __v;";
+ out << eb;
+
+ if(_stream)
+ {
+ out << sp << nl << "public static void" << nl << "write(Ice.OutputStream __outS, " << typeS << " __v)";
out << sb;
iter = 0;
- writeSequenceMarshalUnmarshalCode(out, package, p, "__v", true, iter, false);
+ writeStreamSequenceMarshalUnmarshalCode(out, package, p, "__v", true, iter, false);
out << eb;
- out << sp << nl << "public static " << typeS << nl << "read(IceInternal.BasicStream __is)";
+ out << sp << nl << "public static " << typeS << nl << "read(Ice.InputStream __inS)";
out << sb;
out << nl << typeS << " __v;";
iter = 0;
- writeSequenceMarshalUnmarshalCode(out, package, p, "__v", false, iter, false);
+ writeStreamSequenceMarshalUnmarshalCode(out, package, p, "__v", false, iter, false);
out << nl << "return __v;";
out << eb;
-
- if(_stream)
- {
- out << sp << nl << "public static void" << nl << "write(Ice.OutputStream __outS, " << typeS << " __v)";
- out << sb;
- iter = 0;
- writeStreamSequenceMarshalUnmarshalCode(out, package, p, "__v", true, iter, false);
- out << eb;
-
- out << sp << nl << "public static " << typeS << nl << "read(Ice.InputStream __inS)";
- out << sb;
- out << nl << typeS << " __v;";
- iter = 0;
- writeStreamSequenceMarshalUnmarshalCode(out, package, p, "__v", false, iter, false);
- out << nl << "return __v;";
- out << eb;
- }
-
- out << eb;
- close();
}
+
+ out << eb;
+ close();
}
void
@@ -3844,51 +3801,49 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p)
StringList metaData = p->getMetaData();
string formalType = typeToString(p, TypeModeIn, package, StringList(), true);
- if(open(helper))
- {
- Output& out = output();
- int iter;
+ open(helper);
+ Output& out = output();
+ int iter;
- out << sp << nl << "public final class " << name << "Helper";
- out << sb;
+ out << sp << nl << "public final class " << name << "Helper";
+ out << sb;
- out << nl << "public static void" << nl << "write(IceInternal.BasicStream __os, " << formalType << " __v)";
+ out << nl << "public static void" << nl << "write(IceInternal.BasicStream __os, " << formalType << " __v)";
+ out << sb;
+ iter = 0;
+ writeDictionaryMarshalUnmarshalCode(out, package, p, "__v", true, iter, false);
+ out << eb;
+
+ out << sp << nl << "public static " << formalType
+ << nl << "read(IceInternal.BasicStream __is)";
+ out << sb;
+ out << nl << formalType << " __v;";
+ iter = 0;
+ writeDictionaryMarshalUnmarshalCode(out, package, p, "__v", false, iter, false);
+ out << nl << "return __v;";
+ out << eb;
+
+ if(_stream)
+ {
+ out << sp << nl << "public static void" << nl << "write(Ice.OutputStream __outS, " << formalType
+ << " __v)";
out << sb;
iter = 0;
- writeDictionaryMarshalUnmarshalCode(out, package, p, "__v", true, iter, false);
+ writeStreamDictionaryMarshalUnmarshalCode(out, package, p, "__v", true, iter, false);
out << eb;
out << sp << nl << "public static " << formalType
- << nl << "read(IceInternal.BasicStream __is)";
+ << nl << "read(Ice.InputStream __inS)";
out << sb;
out << nl << formalType << " __v;";
iter = 0;
- writeDictionaryMarshalUnmarshalCode(out, package, p, "__v", false, iter, false);
+ writeStreamDictionaryMarshalUnmarshalCode(out, package, p, "__v", false, iter, false);
out << nl << "return __v;";
out << eb;
-
- if(_stream)
- {
- out << sp << nl << "public static void" << nl << "write(Ice.OutputStream __outS, " << formalType
- << " __v)";
- out << sb;
- iter = 0;
- writeStreamDictionaryMarshalUnmarshalCode(out, package, p, "__v", true, iter, false);
- out << eb;
-
- out << sp << nl << "public static " << formalType
- << nl << "read(Ice.InputStream __inS)";
- out << sb;
- out << nl << formalType << " __v;";
- iter = 0;
- writeStreamDictionaryMarshalUnmarshalCode(out, package, p, "__v", false, iter, false);
- out << nl << "return __v;";
- out << eb;
- }
-
- out << eb;
- close();
}
+
+ out << eb;
+ close();
}
void
@@ -3899,10 +3854,7 @@ Slice::Gen::HelperVisitor::visitEnum(const EnumPtr& p)
string name = p->name();
string fixedName = fixKwd(name);
- if(!open(getAbsolute(p, "", "", "Helper")))
- {
- return;
- }
+ open(getAbsolute(p, "", "", "Helper"));
Output& out = output();
@@ -3942,10 +3894,7 @@ Slice::Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p)
string package = getPackage(p);
string absolute = getAbsolute(p, "", "", "Prx");
- if(!open(absolute))
- {
- return false;
- }
+ open(absolute);
Output& out = output();
@@ -4076,10 +4025,7 @@ Slice::Gen::DelegateVisitor::visitClassDefStart(const ClassDefPtr& p)
string package = getPackage(p);
string absolute = getAbsolute(p, "", "_", "Del");
- if(!open(absolute))
- {
- return false;
- }
+ open(absolute);
Output& out = output();
@@ -4154,10 +4100,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p)
string package = getPackage(p);
string absolute = getAbsolute(p, "", "_", "DelM");
- if(!open(absolute))
- {
- return false;
- }
+ open(absolute);
Output& out = output();
@@ -4270,7 +4213,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p)
out << nl << "throw new Ice.UnknownUserException(__ex.ice_name());";
out << eb;
out << eb;
- if(op->returnsData())
+ if(ret || !outParams.empty())
{
out << nl << "IceInternal.BasicStream __is = __og.is();";
out << nl << "__is.startReadEncaps();";
@@ -4358,10 +4301,7 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p)
string package = getPackage(p);
string absolute = getAbsolute(p, "", "_", "DelD");
- if(!open(absolute))
- {
- return false;
- }
+ open(absolute);
Output& out = output();
@@ -4546,10 +4486,7 @@ Slice::Gen::DispatcherVisitor::visitClassDefStart(const ClassDefPtr& p)
ClassList bases = p->bases();
string absolute = getAbsolute(p, "", "_", "Disp");
- if(!open(absolute))
- {
- return false;
- }
+ open(absolute);
Output& out = output();
@@ -4844,10 +4781,7 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p)
string package = getPackage(p);
string absolute = getAbsolute(p, "", "", "I");
- if(!open(absolute))
- {
- return false;
- }
+ open(absolute);
Output& out = output();
@@ -4905,10 +4839,7 @@ Slice::Gen::ImplTieVisitor::visitClassDefStart(const ClassDefPtr& p)
string package = getPackage(p);
string absolute = getAbsolute(p, "", "", "I");
- if(!open(absolute))
- {
- return false;
- }
+ open(absolute);
Output& out = output();
@@ -5005,10 +4936,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
string classNameAMI = "AMI_" + cl->name();
string absoluteAMI = getAbsolute(cl, "", "AMI_", "_" + name);
- if(!open(absoluteAMI))
- {
- return;
- }
+ open(absoluteAMI);
Output& out = output();
@@ -5150,7 +5078,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
out << nl << "throw new Ice.UnknownUserException(__ex.ice_name());";
out << eb;
out << eb;
- if(p->returnsData())
+ if(ret || !outParams.empty())
{
out << nl << "__is.startReadEncaps();";
for(pli = outParams.begin(); pli != outParams.end(); ++pli)
@@ -5235,10 +5163,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
vector<string> paramsAMD = getParamsAsyncCB(p, classPkg);
{
- if(!open(absoluteAMD))
- {
- return;
- }
+ open(absoluteAMD);
Output& out = output();
@@ -5252,10 +5177,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
}
{
- if(!open(absoluteAMDI))
- {
- return;
- }
+ open(absoluteAMDI);
Output& out = output();
diff --git a/cpp/src/slice2java/Gen.h b/cpp/src/slice2java/Gen.h
index 82a2e9b1f1c..161a837872c 100644
--- a/cpp/src/slice2java/Gen.h
+++ b/cpp/src/slice2java/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.
diff --git a/cpp/src/slice2java/Main.cpp b/cpp/src/slice2java/Main.cpp
index 1b16f9ddb14..7439180b8f2 100644
--- a/cpp/src/slice2java/Main.cpp
+++ b/cpp/src/slice2java/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,8 +8,10 @@
// **********************************************************************
#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>
#ifdef __BCPLUSPLUS__
@@ -19,6 +21,17 @@
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)
{
@@ -88,7 +101,7 @@ main(int argc, char* argv[])
if(opts.isSet("version"))
{
- cout << ICE_STRING_VERSION << endl;
+ cerr << ICE_STRING_VERSION << endl;
return EXIT_SUCCESS;
}
@@ -174,14 +187,18 @@ main(int argc, char* argv[])
ChecksumMap checksums;
+ 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::Java, includePaths);
+ if(!icecpp.printMakefileDependencies(Preprocessor::Java, includePaths))
+ {
+ return EXIT_FAILURE;
+ }
}
else
{
@@ -218,49 +235,84 @@ main(int argc, char* argv[])
p->destroy();
return EXIT_FAILURE;
}
-
+
if(parseStatus == EXIT_FAILURE)
{
status = EXIT_FAILURE;
}
else
{
- Gen gen(argv[0], icecpp.getBaseName(), includePaths, output);
- if(!gen)
- {
- p->destroy();
- return EXIT_FAILURE;
- }
- gen.generate(p, stream);
- if(tie)
+ try
{
- gen.generateTie(p);
+ Gen gen(argv[0], icecpp.getBaseName(), includePaths, output);
+ if(!gen)
+ {
+ p->destroy();
+ return EXIT_FAILURE;
+ }
+ gen.generate(p, stream);
+ if(tie)
+ {
+ gen.generateTie(p);
+ }
+ if(impl)
+ {
+ gen.generateImpl(p);
+ }
+ if(implTie)
+ {
+ gen.generateImplTie(p);
+ }
+ if(!checksumClass.empty())
+ {
+ //
+ // Calculate checksums for the Slice definitions in the unit.
+ //
+ ChecksumMap m = createChecksums(p);
+ copy(m.begin(), m.end(), inserter(checksums, checksums.begin()));
+ }
}
- if(impl)
+ catch(const Slice::FileException& ex)
{
- gen.generateImpl(p);
- }
- if(implTie)
- {
- gen.generateImplTie(p);
- }
- if(!checksumClass.empty())
- {
- //
- // Calculate checksums for the Slice definitions in the unit.
- //
- ChecksumMap m = createChecksums(p);
- copy(m.begin(), m.end(), inserter(checksums, checksums.begin()));
+ // 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)
+ {
+ // If the translator was interrupted, then cleanup any
+ // created files.
+ FileTracker::instance()->cleanup();
+ return EXIT_FAILURE;
+ }
+ }
}
if(!checksumClass.empty())
{
- Gen::writeChecksumClass(checksumClass, output, checksums, java2);
+ try
+ {
+ Gen::writeChecksumClass(checksumClass, output, checksums, java2);
+ }
+ catch(const Slice::FileException& ex)
+ {
+ // If a file could not be created, then
+ // cleanup any created files.
+ FileTracker::instance()->cleanup();
+ cerr << argv[0] << ": " << ex.reason() << endl;
+ return EXIT_FAILURE;
+ }
}
return status;
diff --git a/cpp/src/slice2java/Makefile b/cpp/src/slice2java/Makefile
index 5708159b603..ede06823f73 100644
--- a/cpp/src/slice2java/Makefile
+++ b/cpp/src/slice2java/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/slice2java/Makefile.mak b/cpp/src/slice2java/Makefile.mak
index 89e6f17751c..4a16bbb3b56 100644
--- a/cpp/src/slice2java/Makefile.mak
+++ b/cpp/src/slice2java/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/slice2java/Slice2Java.rc b/cpp/src/slice2java/Slice2Java.rc
index 46104a0a7e8..5f454c00e63 100644
--- a/cpp/src/slice2java/Slice2Java.rc
+++ b/cpp/src/slice2java/Slice2Java.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 Java Translator\0"
- VALUE "FileVersion", "3.3.0\0"
+ VALUE "FileVersion", "3.3.1\0"
VALUE "InternalName", "slice2java\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", "slice2java.exe\0"
VALUE "ProductName", "Ice\0"
- VALUE "ProductVersion", "3.3.0\0"
+ VALUE "ProductVersion", "3.3.1\0"
END
END
BLOCK "VarFileInfo"