summaryrefslogtreecommitdiff
path: root/cpp/src/slice2java/Main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/slice2java/Main.cpp')
-rw-r--r--cpp/src/slice2java/Main.cpp107
1 files changed, 75 insertions, 32 deletions
diff --git a/cpp/src/slice2java/Main.cpp b/cpp/src/slice2java/Main.cpp
index 6fe2b12a9b5..d864279a544 100644
--- a/cpp/src/slice2java/Main.cpp
+++ b/cpp/src/slice2java/Main.cpp
@@ -15,6 +15,7 @@
#include <Slice/FileTracker.h>
#include <Slice/Util.h>
#include <Gen.h>
+#include <GenCompat.h>
#include <iterator>
using namespace std;
@@ -80,8 +81,8 @@ usage(const string& n)
"--ice Allow reserved Ice prefix in Slice identifiers.\n"
"--underscore Allow underscores in Slice identifiers.\n"
"--checksum CLASS Generate checksums for Slice definitions into CLASS.\n"
- "--stream Generate marshaling support for public stream API.\n"
"--meta META Define global metadata directive META.\n"
+ "--compat Use the backward-compatible language mapping.\n"
;
}
@@ -108,8 +109,8 @@ compile(const vector<string>& argv)
opts.addOpt("", "ice");
opts.addOpt("", "underscore");
opts.addOpt("", "checksum", IceUtilInternal::Options::NeedArg);
- opts.addOpt("", "stream");
opts.addOpt("", "meta", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat);
+ opts.addOpt("", "compat");
bool validate = find(argv.begin(), argv.end(), "--validate") != argv.end();
vector<string>args;
@@ -180,14 +181,14 @@ compile(const vector<string>& argv)
string checksumClass = opts.optArg("checksum");
- bool stream = opts.isSet("stream");
-
bool listGenerated = opts.isSet("list-generated");
StringList globalMetadata;
vector<string> v = opts.argVec("meta");
copy(v.begin(), v.end(), back_inserter(globalMetadata));
+ bool compat = opts.isSet("compat");
+
if(args.empty())
{
getErrorStream() << argv[0] << ": error: no input file" << endl;
@@ -208,6 +209,16 @@ compile(const vector<string>& argv)
return EXIT_FAILURE;
}
+ if(!compat && (tie || implTie))
+ {
+ getErrorStream() << argv[0] << ": error: TIE classes are only supported with the Java-Compat mapping" << endl;
+ if(!validate)
+ {
+ usage(argv[0]);
+ }
+ return EXIT_FAILURE;
+ }
+
if(depend && dependxml)
{
getErrorStream() << argv[0] << ": error: cannot specify both --depend and --depend-xml" << endl;
@@ -236,6 +247,13 @@ compile(const vector<string>& argv)
out.os() << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dependencies>" << endl;
}
+ vector<string> cppOpts;
+ cppOpts.push_back("-D__SLICE2JAVA__");
+ if(compat)
+ {
+ cppOpts.push_back("-D__SLICE2JAVA_COMPAT__");
+ }
+
for(vector<string>::const_iterator i = args.begin(); i != args.end(); ++i)
{
//
@@ -250,7 +268,7 @@ compile(const vector<string>& argv)
if(depend || dependxml)
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
- FILE* cppHandle = icecpp->preprocess(false, "-D__SLICE2JAVA__");
+ FILE* cppHandle = icecpp->preprocess(false, cppOpts);
if(cppHandle == 0)
{
@@ -268,8 +286,8 @@ compile(const vector<string>& argv)
return EXIT_FAILURE;
}
- if(!icecpp->printMakefileDependencies(out.os(), depend ? Preprocessor::Java : Preprocessor::SliceXML, includePaths,
- "-D__SLICE2JAVA__"))
+ if(!icecpp->printMakefileDependencies(out.os(), depend ? Preprocessor::Java : Preprocessor::SliceXML,
+ includePaths, cppOpts))
{
out.cleanup();
return EXIT_FAILURE;
@@ -292,7 +310,7 @@ compile(const vector<string>& argv)
FileTracker::instance()->setSource(*i);
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
- FILE* cppHandle = icecpp->preprocess(true, "-D__SLICE2JAVA__");
+ FILE* cppHandle = icecpp->preprocess(true, cppOpts);
if(cppHandle == 0)
{
@@ -343,31 +361,55 @@ compile(const vector<string>& argv)
{
try
{
- Gen gen(argv[0], icecpp->getBaseName(), includePaths, output);
- gen.generate(p, stream);
- if(tie)
- {
- gen.generateTie(p);
- }
- if(impl)
+ if(compat)
{
- gen.generateImpl(p);
+ GenCompat gen(argv[0], icecpp->getBaseName(), includePaths, output);
+ gen.generate(p);
+ 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(listGenerated)
+ {
+ FileTracker::instance()->setOutput(os.str(), false);
+ }
}
- 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(listGenerated)
+ else
{
- FileTracker::instance()->setOutput(os.str(), false);
+ Gen gen(argv[0], icecpp->getBaseName(), includePaths, output);
+ gen.generate(p);
+ if(impl)
+ {
+ gen.generateImpl(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(listGenerated)
+ {
+ FileTracker::instance()->setOutput(os.str(), false);
+ }
}
}
catch(const Slice::FileException& ex)
@@ -418,8 +460,9 @@ compile(const vector<string>& argv)
}
catch(const Slice::FileException& ex)
{
- // If a file could not be created, then
- // cleanup any created files.
+ //
+ // If a file could not be created, then cleanup any created files.
+ //
FileTracker::instance()->cleanup();
getErrorStream() << argv[0] << ": error: " << ex.reason() << endl;
return EXIT_FAILURE;