From 7f7978740f36b0c44abede9e799c4dc6d1a22cfd Mon Sep 17 00:00:00 2001 From: Michi Henning Date: Thu, 8 Sep 2005 03:39:54 +0000 Subject: Fixed for 355, updated version to 3.0.0. --- cpp/src/slice2cppe/Gen.cpp | 69 +++++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 34 deletions(-) (limited to 'cpp/src/slice2cppe/Gen.cpp') diff --git a/cpp/src/slice2cppe/Gen.cpp b/cpp/src/slice2cppe/Gen.cpp index 5808126ef91..0e160b0c096 100644 --- a/cpp/src/slice2cppe/Gen.cpp +++ b/cpp/src/slice2cppe/Gen.cpp @@ -187,40 +187,8 @@ Slice::Gen::generate(const UnitPtr& p) { validateMetaData(p); - // - // Output additional header includes first. - // - vector::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()) { @@ -325,7 +293,9 @@ Slice::Gen::generate(const UnitPtr& p) } implH << _base << ".h>"; - implC << "#include <"; + writeExtraHeaders(implC); + + implC << "\n#include <"; if(_include.size()) { implC << _include << '/'; @@ -337,6 +307,37 @@ Slice::Gen::generate(const UnitPtr& p) } } +void +Slice::Gen::writeExtraHeaders(Output& out) +{ + for(vector::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) : H(h), C(c), _dllExport(dllExport), _doneStaticSymbol(false) { -- cgit v1.2.3