summaryrefslogtreecommitdiff
path: root/cpp/src/Slice/Preprocessor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/Slice/Preprocessor.cpp')
-rw-r--r--cpp/src/Slice/Preprocessor.cpp86
1 files changed, 59 insertions, 27 deletions
diff --git a/cpp/src/Slice/Preprocessor.cpp b/cpp/src/Slice/Preprocessor.cpp
index 636c772b94d..29c968f9f93 100644
--- a/cpp/src/Slice/Preprocessor.cpp
+++ b/cpp/src/Slice/Preprocessor.cpp
@@ -44,11 +44,10 @@ extern "C" int mcpp_lib_main(int argc, char** argv);
extern "C" void mcpp_use_mem_buffers(int tf);
extern "C" char* mcpp_get_mem_buffer(Outdest od);
-Slice::Preprocessor::Preprocessor(const string& path, const string& fileName, const vector<string>& args, const string& cppSourceExt) :
+Slice::Preprocessor::Preprocessor(const string& path, const string& fileName, const vector<string>& args) :
_path(path),
_fileName(fileName),
_args(args),
- _cppSourceExt(cppSourceExt),
_cppHandle(0)
{
}
@@ -145,12 +144,16 @@ Slice::Preprocessor::preprocess(bool keepComments)
delete[] argv;
//
- // Print errors to stderr.
+ // Display any errors.
//
char* err = mcpp_get_mem_buffer(Err);
if(err)
{
- ::fputs(err, stderr);
+ vector<string> messages = filterMcppWarnings(err);
+ for(vector<string>::const_iterator i = messages.begin(); i != messages.end(); ++i)
+ {
+ emitRaw(i->c_str());
+ }
}
if(status == 0)
@@ -199,13 +202,14 @@ Slice::Preprocessor::preprocess(bool keepComments)
}
else
{
- cerr << "Could not open temporary file: ";
+ ostream& os = getErrorStream();
+ os << _path << ": error: could not open temporary file: ";
#ifdef _WIN32
- cerr << IceUtil::wstringToString(_cppFile);
+ os << IceUtil::wstringToString(_cppFile);
#else
- cerr << _cppFile;
+ os << _cppFile;
#endif
- cerr << endl;
+ os << endl;
}
}
@@ -218,7 +222,8 @@ Slice::Preprocessor::preprocess(bool keepComments)
}
bool
-Slice::Preprocessor::printMakefileDependencies(Language lang, const vector<string>& includePaths)
+Slice::Preprocessor::printMakefileDependencies(Language lang, const vector<string>& includePaths,
+ const string& cppSourceExt)
{
if(!checkInputFile())
{
@@ -253,7 +258,7 @@ Slice::Preprocessor::printMakefileDependencies(Language lang, const vector<strin
char* err = mcpp_get_mem_buffer(Err);
if(err)
{
- ::fputs(err, stderr);
+ emitRaw(err);
}
if(status != 0)
@@ -299,7 +304,11 @@ Slice::Preprocessor::printMakefileDependencies(Language lang, const vector<strin
string suffix = ".o:";
#endif
pos = unprocessed.find(suffix) + suffix.size();
- string result = unprocessed.substr(0, pos);
+ string result;
+ if(lang != JavaXML)
+ {
+ result = unprocessed.substr(0, pos);
+ }
vector<string> fullIncludePaths;
vector<string>::const_iterator p;
@@ -345,26 +354,47 @@ Slice::Preprocessor::printMakefileDependencies(Language lang, const vector<strin
}
}
- //
- // Escape spaces in the file name.
- //
- string::size_type space = 0;
- while((space = file.find(" ", space)) != string::npos)
+ if(lang == JavaXML)
{
- file.replace(space, 1, "\\ ");
- space += 2;
+ if(result.size() == 0)
+ {
+ result = " <source name=\"" + file + "\">";
+ }
+ else
+ {
+ result += "\n <dependsOn name=\"" + file + "\"/>";
+ }
}
+ else
+ {
+ //
+ // Escape spaces in the file name.
+ //
+ string::size_type space = 0;
+ while((space = file.find(" ", space)) != string::npos)
+ {
+ file.replace(space, 1, "\\ ");
+ space += 2;
+ }
- //
- // Add to result
- //
- result += " \\\n " + file;
+ //
+ // Add to result
+ //
+ result += " \\\n " + file;
+ }
pos = end;
}
- result += "\n";
+ if(lang == JavaXML)
+ {
+ result += "\n </source>\n";
+ }
+ else
+ {
+ result += "\n";
+ }
/*
- * icecpp emits dependencies in any of the following formats, depending on the
+ * Emit dependencies in any of the following formats, depending on the
* length of the filenames:
*
* x.o[bj]: /path/x.ice /path/y.ice
@@ -396,10 +426,12 @@ Slice::Preprocessor::printMakefileDependencies(Language lang, const vector<strin
string::size_type pos;
while((pos = result.find(suffix)) != string::npos)
{
- result.replace(pos, suffix.size() - 1, "." + _cppSourceExt);
+ result.replace(pos, suffix.size() - 1, "." + cppSourceExt);
}
break;
}
+ case JavaXML:
+ break;
case Java:
{
//
@@ -511,14 +543,14 @@ Slice::Preprocessor::checkInputFile()
}
if(suffix != ".ice")
{
- cerr << _path << ": input files must end with `.ice'" << endl;
+ getErrorStream() << _path << ": error: input files must end with `.ice'" << endl;
return false;
}
ifstream test(_fileName.c_str());
if(!test)
{
- cerr << _path << ": cannot open `" << _fileName << "' for reading" << endl;
+ getErrorStream() << _path << ": error: cannot open `" << _fileName << "' for reading" << endl;
return false;
}
test.close();