summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/FreezeScript/DumpDB.cpp2
-rw-r--r--cpp/src/FreezeScript/Util.cpp4
-rw-r--r--cpp/src/FreezeScript/Util.h2
-rw-r--r--cpp/src/FreezeScript/transformdb.cpp6
-rw-r--r--cpp/src/Slice/Preprocessor.cpp59
-rw-r--r--cpp/src/slice2confluence/Gen.cpp4
-rw-r--r--cpp/src/slice2cpp/Main.cpp7
-rw-r--r--cpp/src/slice2cs/Main.cpp7
-rw-r--r--cpp/src/slice2freeze/Main.cpp2
-rw-r--r--cpp/src/slice2freezej/Main.cpp7
-rw-r--r--cpp/src/slice2html/Main.cpp2
-rw-r--r--cpp/src/slice2java/Main.cpp8
-rw-r--r--cpp/src/slice2php/Main.cpp6
-rw-r--r--cpp/src/slice2py/Main.cpp7
-rw-r--r--cpp/src/slice2rb/Main.cpp7
15 files changed, 82 insertions, 48 deletions
diff --git a/cpp/src/FreezeScript/DumpDB.cpp b/cpp/src/FreezeScript/DumpDB.cpp
index a31148abda5..ca011caedb0 100644
--- a/cpp/src/FreezeScript/DumpDB.cpp
+++ b/cpp/src/FreezeScript/DumpDB.cpp
@@ -343,7 +343,7 @@ run(const Ice::StringSeq& originalArgs, const Ice::CommunicatorPtr& communicator
Slice::UnitPtr unit = Slice::Unit::createUnit(true, true, ice, underscore);
FreezeScript::Destroyer<Slice::UnitPtr> unitD(unit);
- if(!FreezeScript::parseSlice(appName, unit, slice, cppArgs, debug))
+ if(!FreezeScript::parseSlice(appName, unit, slice, cppArgs, debug, "-DICE_COMPILER=ICE_DUMPDB"))
{
return EXIT_FAILURE;
}
diff --git a/cpp/src/FreezeScript/Util.cpp b/cpp/src/FreezeScript/Util.cpp
index 52e72b956a0..6ba2715713a 100644
--- a/cpp/src/FreezeScript/Util.cpp
+++ b/cpp/src/FreezeScript/Util.cpp
@@ -170,7 +170,7 @@ FreezeScript::createEvictorSliceTypes(const Slice::UnitPtr& u)
bool
FreezeScript::parseSlice(const string& n, const Slice::UnitPtr& u, const vector<string>& files,
- const vector<string>& cppArgs, bool debug)
+ const vector<string>& cppArgs, bool debug, const std::string& extraArgs)
{
//
// Parse the Slice files.
@@ -179,7 +179,7 @@ FreezeScript::parseSlice(const string& n, const Slice::UnitPtr& u, const vector<
{
PreprocessorPtr icecpp = Preprocessor::create(n, *p, cppArgs);
- FILE* cppHandle = icecpp->preprocess(false);
+ FILE* cppHandle = icecpp->preprocess(false, extraArgs);
if(cppHandle == 0)
{
diff --git a/cpp/src/FreezeScript/Util.h b/cpp/src/FreezeScript/Util.h
index 67986f18515..47d4dc751ba 100644
--- a/cpp/src/FreezeScript/Util.h
+++ b/cpp/src/FreezeScript/Util.h
@@ -56,7 +56,7 @@ std::string typeToString(const Slice::TypePtr&);
bool ignoreType(const std::string&);
void createEvictorSliceTypes(const Slice::UnitPtr&);
bool parseSlice(const std::string&, const Slice::UnitPtr&, const std::vector<std::string>&,
- const std::vector<std::string>&, bool);
+ const std::vector<std::string>&, bool, const std::string&);
typedef std::map<std::string, Freeze::CatalogData> CatalogDataMap;
diff --git a/cpp/src/FreezeScript/transformdb.cpp b/cpp/src/FreezeScript/transformdb.cpp
index 09c870b2c78..c4c3f1fe002 100644
--- a/cpp/src/FreezeScript/transformdb.cpp
+++ b/cpp/src/FreezeScript/transformdb.cpp
@@ -436,14 +436,16 @@ run(const Ice::StringSeq& originalArgs, const Ice::CommunicatorPtr& communicator
Slice::UnitPtr oldUnit = Slice::Unit::createUnit(true, true, ice, underscore);
FreezeScript::Destroyer<Slice::UnitPtr> oldD(oldUnit);
- if(!FreezeScript::parseSlice(appName, oldUnit, oldSlice, oldCppArgs, debug))
+ if(!FreezeScript::parseSlice(appName, oldUnit, oldSlice, oldCppArgs, debug,
+ "-DICE_COMPILER=ICE_TRANSFORMDB"))
{
return EXIT_FAILURE;
}
Slice::UnitPtr newUnit = Slice::Unit::createUnit(true, true, ice, underscore);
FreezeScript::Destroyer<Slice::UnitPtr> newD(newUnit);
- if(!FreezeScript::parseSlice(appName, newUnit, newSlice, newCppArgs, debug))
+ if(!FreezeScript::parseSlice(appName, newUnit, newSlice, newCppArgs, debug,
+ "-DICE_COMPILER=ICE_TRANSFORMDB"))
{
return EXIT_FAILURE;
}
diff --git a/cpp/src/Slice/Preprocessor.cpp b/cpp/src/Slice/Preprocessor.cpp
index 68072500ece..352cdf4147a 100644
--- a/cpp/src/Slice/Preprocessor.cpp
+++ b/cpp/src/Slice/Preprocessor.cpp
@@ -136,18 +136,12 @@ Slice::Preprocessor::normalizeIncludePath(const string& path)
return result;
}
-FILE*
-Slice::Preprocessor::preprocess(bool keepComments)
+namespace
{
- if(!checkInputFile())
- {
- return 0;
- }
- //
- // Build arguments list.
- //
- vector<string> args = _args;
+vector<string>
+baseArgs(vector<string> args, bool keepComments, const string& extraArgs, const string& fileName)
+{
if(keepComments)
{
args.push_back("-C");
@@ -157,7 +151,41 @@ Slice::Preprocessor::preprocess(bool keepComments)
ostringstream version;
version << "-DICE_VERSION=" << ICE_INT_VERSION;
args.push_back(version.str());
- args.push_back(_fileName);
+
+ args.push_back("-DICE_SLICE2CPP=1");
+ args.push_back("-DICE_SLICE2CS=2");
+ args.push_back("-DICE_SLICE2FREEZE=3");
+ args.push_back("-DICE_SLICE2FREEZEJ=4");
+ args.push_back("-DICE_SLICE2HTML=5");
+ args.push_back("-DICE_SLICE2JAVA=6");
+ args.push_back("-DICE_SLICE2PHP=7");
+ args.push_back("-DICE_SLICE2PY=8");
+ args.push_back("-DICE_SLICE2RB=9");
+ args.push_back("-DICE_TRANSFORMDB=10");
+ args.push_back("-DICE_DUMPDB=11");
+
+ if(!extraArgs.empty())
+ {
+ args.push_back(extraArgs);
+ }
+ args.push_back(fileName);
+ return args;
+}
+
+}
+
+FILE*
+Slice::Preprocessor::preprocess(bool keepComments, const string& extraArgs)
+{
+ if(!checkInputFile())
+ {
+ return 0;
+ }
+
+ //
+ // Build arguments list.
+ //
+ vector<string> args = baseArgs(_args, keepComments, extraArgs, _fileName);
const char** argv = new const char*[args.size() + 1];
argv[0] = "mcpp";
for(unsigned int i = 0; i < args.size(); ++i)
@@ -251,7 +279,8 @@ Slice::Preprocessor::preprocess(bool keepComments)
bool
Slice::Preprocessor::printMakefileDependencies(Language lang, const vector<string>& includePaths,
- const string& cppSourceExt, const string& optValue)
+ const std::string& extraArgs, const string& cppSourceExt,
+ const string& optValue)
{
if(!checkInputFile())
{
@@ -272,11 +301,7 @@ Slice::Preprocessor::printMakefileDependencies(Language lang, const vector<strin
//
// Build arguments list.
//
- vector<string> args = _args;
- args.push_back("-M");
- args.push_back("-e");
- args.push_back("en_us.utf8");
- args.push_back(_fileName);
+ vector<string> args = baseArgs(_args, false, extraArgs, _fileName);
const char** argv = new const char*[args.size() + 1];
for(unsigned int i = 0; i < args.size(); ++i)
diff --git a/cpp/src/slice2confluence/Gen.cpp b/cpp/src/slice2confluence/Gen.cpp
index 4b059667033..91ae7a4e99a 100644
--- a/cpp/src/slice2confluence/Gen.cpp
+++ b/cpp/src/slice2confluence/Gen.cpp
@@ -888,7 +888,7 @@ Slice::GeneratorBase::printHeaderFooter(const ContainedPtr& c)
bool isFirst = prev == _symbols.end();
bool isLast = next == _symbols.end();
- bool hasParent = false;
+ /*bool hasParent = false;
if(EnumPtr::dynamicCast(c))
{
hasParent = true;
@@ -904,7 +904,7 @@ Slice::GeneratorBase::printHeaderFooter(const ContainedPtr& c)
else if(ContainedPtr::dynamicCast(c))
{
hasParent = true;
- }
+ }*/
bool onEnumPage = EnumPtr::dynamicCast(c);
diff --git a/cpp/src/slice2cpp/Main.cpp b/cpp/src/slice2cpp/Main.cpp
index e90edc5d4fd..eb31d0414db 100644
--- a/cpp/src/slice2cpp/Main.cpp
+++ b/cpp/src/slice2cpp/Main.cpp
@@ -204,7 +204,7 @@ compile(int argc, char* argv[])
if(depend)
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
- FILE* cppHandle = icecpp->preprocess(false);
+ FILE* cppHandle = icecpp->preprocess(false, "-DICE_COMPILER=ICE_SLICE2CPP");
if(cppHandle == 0)
{
@@ -220,7 +220,8 @@ compile(int argc, char* argv[])
return EXIT_FAILURE;
}
- if(!icecpp->printMakefileDependencies(Preprocessor::CPlusPlus, includePaths, sourceExtension, headerExtension))
+ if(!icecpp->printMakefileDependencies(Preprocessor::CPlusPlus, includePaths,
+ "-DICE_COMPILER=ICE_SLICE2CPP", sourceExtension, headerExtension))
{
return EXIT_FAILURE;
}
@@ -233,7 +234,7 @@ compile(int argc, char* argv[])
else
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
- FILE* cppHandle = icecpp->preprocess(false);
+ FILE* cppHandle = icecpp->preprocess(false, "-DICE_COMPILER=ICE_SLICE2CPP");
if(cppHandle == 0)
{
diff --git a/cpp/src/slice2cs/Main.cpp b/cpp/src/slice2cs/Main.cpp
index 0129ecfbeba..0f91002bbf3 100644
--- a/cpp/src/slice2cs/Main.cpp
+++ b/cpp/src/slice2cs/Main.cpp
@@ -198,7 +198,7 @@ compile(int argc, char* argv[])
if(depend)
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
- FILE* cppHandle = icecpp->preprocess(false);
+ FILE* cppHandle = icecpp->preprocess(false, "-DICE_COMPILER=ICE_SLICE2CS");
if(cppHandle == 0)
{
@@ -214,7 +214,8 @@ compile(int argc, char* argv[])
return EXIT_FAILURE;
}
- if(!icecpp->printMakefileDependencies(Preprocessor::CSharp, includePaths))
+ if(!icecpp->printMakefileDependencies(Preprocessor::CSharp, includePaths,
+ "-DICE_COMPILER=ICE_SLICE2CS"))
{
return EXIT_FAILURE;
}
@@ -227,7 +228,7 @@ compile(int argc, char* argv[])
else
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
- FILE* cppHandle = icecpp->preprocess(true);
+ FILE* cppHandle = icecpp->preprocess(true, "-DICE_COMPILER=ICE_SLICE2CS");
if(cppHandle == 0)
{
diff --git a/cpp/src/slice2freeze/Main.cpp b/cpp/src/slice2freeze/Main.cpp
index ee807a38989..958e3438fab 100644
--- a/cpp/src/slice2freeze/Main.cpp
+++ b/cpp/src/slice2freeze/Main.cpp
@@ -1952,7 +1952,7 @@ compile(int argc, char* argv[])
//
includes.push_back(icecpp->getBaseName() + ".h");
- FILE* cppHandle = icecpp->preprocess(false);
+ FILE* cppHandle = icecpp->preprocess(false, "-DICE_COMPILER=ICE_SLICE2FREEZE");
if(cppHandle == 0)
{
diff --git a/cpp/src/slice2freezej/Main.cpp b/cpp/src/slice2freezej/Main.cpp
index 3b38ec8e667..6a80a241904 100644
--- a/cpp/src/slice2freezej/Main.cpp
+++ b/cpp/src/slice2freezej/Main.cpp
@@ -1771,7 +1771,7 @@ compile(int argc, char* argv[])
if(depend || dependxml)
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], args[idx], cppArgs);
- FILE* cppHandle = icecpp->preprocess(false);
+ FILE* cppHandle = icecpp->preprocess(false, "-DICE_COMPILER=ICE_SLICE2FREEZEJ");
if(cppHandle == 0)
{
@@ -1787,7 +1787,8 @@ compile(int argc, char* argv[])
return EXIT_FAILURE;
}
- if(!icecpp->printMakefileDependencies(depend ? Preprocessor::Java : Preprocessor::JavaXML, includePaths))
+ if(!icecpp->printMakefileDependencies(depend ? Preprocessor::Java : Preprocessor::JavaXML, includePaths,
+ "-DICE_COMPILER=ICE_SLICE2FREEZEJ"))
{
u->destroy();
return EXIT_FAILURE;
@@ -1802,7 +1803,7 @@ compile(int argc, char* argv[])
else
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], args[idx], cppArgs);
- FILE* cppHandle = icecpp->preprocess(false);
+ FILE* cppHandle = icecpp->preprocess(false, "-DICE_COMPILER=ICE_SLICE2FREEZEJ");
if(cppHandle == 0)
{
diff --git a/cpp/src/slice2html/Main.cpp b/cpp/src/slice2html/Main.cpp
index 43646495f9e..b58360de8ed 100644
--- a/cpp/src/slice2html/Main.cpp
+++ b/cpp/src/slice2html/Main.cpp
@@ -222,7 +222,7 @@ compile(int argc, char* argv[])
for(vector<string>::size_type idx = 0; idx < args.size(); ++idx)
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], args[idx], cppArgs);
- FILE* cppHandle = icecpp->preprocess(true);
+ FILE* cppHandle = icecpp->preprocess(true, "-DICE_COMPILER=ICE_SLICE2HTML");
if(cppHandle == 0)
{
diff --git a/cpp/src/slice2java/Main.cpp b/cpp/src/slice2java/Main.cpp
index 2d0f6cb06f1..d06b1477a66 100644
--- a/cpp/src/slice2java/Main.cpp
+++ b/cpp/src/slice2java/Main.cpp
@@ -219,7 +219,7 @@ compile(int argc, char* argv[])
if(depend || dependxml)
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
- FILE* cppHandle = icecpp->preprocess(false);
+ FILE* cppHandle = icecpp->preprocess(false, "-DICE_COMPILER=ICE_SLICE2JAVA");
if(cppHandle == 0)
{
@@ -235,7 +235,9 @@ compile(int argc, char* argv[])
return EXIT_FAILURE;
}
- if(!icecpp->printMakefileDependencies(depend ? Preprocessor::Java : Preprocessor::JavaXML, includePaths))
+ if(!icecpp->printMakefileDependencies(depend ? Preprocessor::Java : Preprocessor::JavaXML, includePaths,
+ "-DICE_COMPILER=ICE_SLICE2JAVA"
+ ))
{
return EXIT_FAILURE;
}
@@ -256,7 +258,7 @@ compile(int argc, char* argv[])
FileTracker::instance()->setSource(*i);
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
- FILE* cppHandle = icecpp->preprocess(true);
+ FILE* cppHandle = icecpp->preprocess(true, "-DICE_COMPILER=ICE_SLICE2JAVA");
if(cppHandle == 0)
{
diff --git a/cpp/src/slice2php/Main.cpp b/cpp/src/slice2php/Main.cpp
index 42eac38e19f..1be68d99238 100644
--- a/cpp/src/slice2php/Main.cpp
+++ b/cpp/src/slice2php/Main.cpp
@@ -1670,7 +1670,7 @@ compile(int argc, char* argv[])
if(depend)
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
- FILE* cppHandle = icecpp->preprocess(false);
+ FILE* cppHandle = icecpp->preprocess(false, "-DICE_COMPILER=ICE_SLICE2PHP");
if(cppHandle == 0)
{
@@ -1686,7 +1686,7 @@ compile(int argc, char* argv[])
return EXIT_FAILURE;
}
- if(!icecpp->printMakefileDependencies(Preprocessor::PHP, includePaths))
+ if(!icecpp->printMakefileDependencies(Preprocessor::PHP, includePaths, "-DICE_COMPILER=ICE_SLICE2PHP"))
{
return EXIT_FAILURE;
}
@@ -1699,7 +1699,7 @@ compile(int argc, char* argv[])
else
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
- FILE* cppHandle = icecpp->preprocess(false);
+ FILE* cppHandle = icecpp->preprocess(false, "-DICE_COMPILER=ICE_SLICE2PHP");
if(cppHandle == 0)
{
diff --git a/cpp/src/slice2py/Main.cpp b/cpp/src/slice2py/Main.cpp
index 15aec1b42b4..317f0d7c68f 100644
--- a/cpp/src/slice2py/Main.cpp
+++ b/cpp/src/slice2py/Main.cpp
@@ -490,7 +490,7 @@ compile(int argc, char* argv[])
if(depend)
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
- FILE* cppHandle = icecpp->preprocess(false);
+ FILE* cppHandle = icecpp->preprocess(false, "-DICE_COMPILER=ICE_SLICE2PY");
if(cppHandle == 0)
{
@@ -506,7 +506,8 @@ compile(int argc, char* argv[])
return EXIT_FAILURE;
}
- if(!icecpp->printMakefileDependencies(Preprocessor::Python, includePaths, "", prefix))
+ if(!icecpp->printMakefileDependencies(Preprocessor::Python, includePaths,
+ "-DICE_COMPILER=ICE_SLICE2PY", "", prefix))
{
return EXIT_FAILURE;
}
@@ -519,7 +520,7 @@ compile(int argc, char* argv[])
else
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
- FILE* cppHandle = icecpp->preprocess(keepComments);
+ FILE* cppHandle = icecpp->preprocess(keepComments, "-DICE_COMPILER=ICE_SLICE2PY");
if(cppHandle == 0)
{
diff --git a/cpp/src/slice2rb/Main.cpp b/cpp/src/slice2rb/Main.cpp
index c793f2b5b3b..a8d2764a2f5 100644
--- a/cpp/src/slice2rb/Main.cpp
+++ b/cpp/src/slice2rb/Main.cpp
@@ -194,7 +194,7 @@ compile(int argc, char* argv[])
if(depend)
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
- FILE* cppHandle = icecpp->preprocess(false);
+ FILE* cppHandle = icecpp->preprocess(false, "-DICE_COMPILER=ICE_SLICE2RB");
if(cppHandle == 0)
{
@@ -210,7 +210,8 @@ compile(int argc, char* argv[])
return EXIT_FAILURE;
}
- if(!icecpp->printMakefileDependencies(Preprocessor::Ruby, includePaths))
+ if(!icecpp->printMakefileDependencies(Preprocessor::Ruby, includePaths,
+ "-DICE_COMPILER=ICE_SLICE2RB"))
{
return EXIT_FAILURE;
}
@@ -223,7 +224,7 @@ compile(int argc, char* argv[])
else
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
- FILE* cppHandle = icecpp->preprocess(false);
+ FILE* cppHandle = icecpp->preprocess(false, "-DICE_COMPILER=ICE_SLICE2RB");
if(cppHandle == 0)
{