summaryrefslogtreecommitdiff
path: root/cpp/src/slice2cpp/Gen.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/slice2cpp/Gen.cpp')
-rw-r--r--cpp/src/slice2cpp/Gen.cpp69
1 files changed, 35 insertions, 34 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)
{