diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 69 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Gen.h | 2 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Main.cpp | 3 |
3 files changed, 38 insertions, 36 deletions
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 953714d572f..0691a80505c 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -169,40 +169,8 @@ Slice::Gen::generate(const UnitPtr& p) { validateMetaData(p); - // - // Output additional header includes first. - // - vector<string>::const_iterator i; - for(i = _extraHeaders.begin(); i != _extraHeaders.end(); ++i) - { - string hdr = *i; - string guard; - string::size_type pos = hdr.rfind(','); - if(pos != string::npos) - { - hdr = i->substr(0, pos); - guard = i->substr(pos + 1); - } - if(!guard.empty()) - { - C << "\n#ifndef " << guard; - C << "\n#define " << guard; - } - C << "\n#include <"; - if(!_include.empty()) - { - C << _include << '/'; - } - C << hdr << '>'; - if(!guard.empty()) - { - C << "\n#endif"; - } - } + writeExtraHeaders(C); - // - // Output remaining includes. - // C << "\n#include <"; if(_include.size()) { @@ -338,7 +306,9 @@ Slice::Gen::generate(const UnitPtr& p) } implH << _base << ".h>"; - implC << "#include <"; + writeExtraHeaders(implC); + + implC << "\n#include <"; if(_include.size()) { implC << _include << '/'; @@ -375,6 +345,37 @@ Slice::Gen::generate(const UnitPtr& p) } } +void +Slice::Gen::writeExtraHeaders(IceUtil::Output& out) +{ + for(vector<string>::const_iterator i = _extraHeaders.begin(); i != _extraHeaders.end(); ++i) + { + string hdr = *i; + string guard; + string::size_type pos = hdr.rfind(','); + if(pos != string::npos) + { + hdr = i->substr(0, pos); + guard = i->substr(pos + 1); + } + if(!guard.empty()) + { + out << "\n#ifndef " << guard; + out << "\n#define " << guard; + } + out << "\n#include <"; + if(!_include.empty()) + { + out << _include << '/'; + } + out << hdr << '>'; + if(!guard.empty()) + { + out << "\n#endif"; + } + } +} + Slice::Gen::TypesVisitor::TypesVisitor(Output& h, Output& c, const string& dllExport, bool stream) : H(h), C(c), _dllExport(dllExport), _stream(stream), _doneStaticSymbol(false) { diff --git a/cpp/src/slice2cpp/Gen.h b/cpp/src/slice2cpp/Gen.h index 4d4d2c55531..e419b82a508 100644 --- a/cpp/src/slice2cpp/Gen.h +++ b/cpp/src/slice2cpp/Gen.h @@ -40,6 +40,8 @@ public: private: + void writeExtraHeaders(::IceUtil::Output&); + ::IceUtil::Output H; ::IceUtil::Output C; diff --git a/cpp/src/slice2cpp/Main.cpp b/cpp/src/slice2cpp/Main.cpp index 50c91735d5f..8a1aa5d712f 100644 --- a/cpp/src/slice2cpp/Main.cpp +++ b/cpp/src/slice2cpp/Main.cpp @@ -107,8 +107,7 @@ main(int argc, char* argv[]) string headerExtension = opts.optArg("header-ext"); string sourceExtension = opts.optArg("source-ext"); - vector<string> extraHeaders; - extraHeaders = opts.argVec("add-header"); + vector<string> extraHeaders = opts.argVec("add-header"); if(opts.isSet("D")) { |