From 86d1e1192e81e9eb684d647238fff7a67ec45fcb Mon Sep 17 00:00:00 2001 From: Matthew Newhook Date: Mon, 12 Jan 2009 13:24:24 -0330 Subject: Squashed commit of the following: commit b73098371dca786520d9eab2731d1887a60685b1 Author: Matthew Newhook Date: Mon Jan 12 13:22:59 2009 -0330 http://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=3518 slice2XXX --depend exit status is bogus --- cpp/src/slice2cpp/Main.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'cpp/src/slice2cpp/Main.cpp') diff --git a/cpp/src/slice2cpp/Main.cpp b/cpp/src/slice2cpp/Main.cpp index 1cd6604766f..0f053917b0b 100644 --- a/cpp/src/slice2cpp/Main.cpp +++ b/cpp/src/slice2cpp/Main.cpp @@ -169,7 +169,10 @@ main(int argc, char* argv[]) if(depend) { Preprocessor icecpp(argv[0], *i, cppArgs); - icecpp.printMakefileDependencies(Preprocessor::CPlusPlus, includePaths); + if(!icecpp.printMakefileDependencies(Preprocessor::CPlusPlus, includePaths)) + { + return EXIT_FAILURE; + } } else { -- cgit v1.2.3 From efea74327637afce0a7f83b24d8c2f8b1d224f73 Mon Sep 17 00:00:00 2001 From: Matthew Newhook Date: Tue, 13 Jan 2009 17:58:32 -0330 Subject: http://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=3640 - If slice2java errors out generated files are left behind - Added file tracker - Added calls to file tracker when files or directories are created. - All translators cleanup created files if interrupted, or if they fail. - Normalized various error messages. - Fixed bug with slice2cs which would not correctly check if the impl files were created. Squashed commit of the following: commit 0fec143af219d59dcec5b91cb96a79179f73bd0d Author: Matthew Newhook Date: Tue Jan 13 17:57:25 2009 -0330 Fixed FileException for VC6. commit 38b22497c751ad9b2f86af2d44e87a23c0049d9c Merge: df29064... 4421a3d... Author: Matthew Newhook Date: Tue Jan 13 17:55:49 2009 -0330 Merged R3_3_branch. commit df290649637685bfff4f777ccf53f4f04fda71a0 Author: Matthew Newhook Date: Tue Jan 13 17:45:18 2009 -0330 move checksum writing outside loop commit a9bb2356167b1f9259ce2d1f1b43d40b7fd0ce82 Author: Matthew Newhook Date: Tue Jan 13 17:35:00 2009 -0330 added quotes commit a2f3d7a2414d08ebdc290222b8e97d8b203cc9ab Author: Matthew Newhook Date: Tue Jan 13 17:21:27 2009 -0330 can't -> cannot commit c3113e33a3687cae369bf7803e4f1d18c9141762 Author: Matthew Newhook Date: Tue Jan 13 17:10:12 2009 -0330 minor fixes to output. commit 2a17d6e1b6c0e5eed8be79b8353ca3c06572e19c Author: U-WIN-5WBK5GD0FYQ\matthew Date: Tue Jan 13 12:05:46 2009 -0800 windows fixes. commit d8d4f6dc35043fb71b599dac7171fee0c2bb87bf Author: Matthew Newhook Date: Tue Jan 13 15:58:21 2009 -0330 remove debugging. commit f1e4d7a55e13fea4c0b84244fb437bd391fbe538 Author: Matthew Newhook Date: Tue Jan 13 15:53:37 2009 -0330 Added FileTracker. Added file tracking, and cleanup to lots of translators. commit 33dbfb0124509779bd2d95bbac06a02ca9b907ac Author: Matthew Newhook Date: Tue Jan 13 09:42:16 2009 -0330 http://bugzilla/bugzilla/show_bug.cgi?id=3640 If slice2java errors out generated files are left behind --- cpp/include/Slice/FileTracker.h | 62 ++++++ cpp/include/Slice/JavaUtil.h | 19 -- cpp/src/Slice/FileTracker.cpp | 117 +++++++++++ cpp/src/Slice/JavaUtil.cpp | 47 +---- cpp/src/Slice/Makefile | 1 + cpp/src/Slice/Makefile.mak | 1 + cpp/src/Slice/Preprocessor.cpp | 2 +- cpp/src/slice2cpp/Gen.cpp | 54 +++-- cpp/src/slice2cpp/Gen.h | 3 - cpp/src/slice2cpp/Main.cpp | 17 +- cpp/src/slice2cs/Gen.cpp | 28 +-- cpp/src/slice2cs/Gen.h | 3 - cpp/src/slice2cs/Main.cpp | 52 +++-- cpp/src/slice2docbook/Gen.cpp | 15 +- cpp/src/slice2docbook/Gen.h | 4 +- cpp/src/slice2docbook/Main.cpp | 15 +- cpp/src/slice2freeze/Main.cpp | 428 +++++++++++++++++++++------------------- cpp/src/slice2freezej/Main.cpp | 129 +++++++----- cpp/src/slice2html/Gen.cpp | 37 +++- cpp/src/slice2html/Main.cpp | 13 ++ cpp/src/slice2java/Main.cpp | 24 ++- cpp/src/slice2py/Main.cpp | 208 +++++++++---------- cpp/src/slice2rb/Main.cpp | 43 ++-- 23 files changed, 788 insertions(+), 534 deletions(-) create mode 100644 cpp/include/Slice/FileTracker.h create mode 100644 cpp/src/Slice/FileTracker.cpp (limited to 'cpp/src/slice2cpp/Main.cpp') diff --git a/cpp/include/Slice/FileTracker.h b/cpp/include/Slice/FileTracker.h new file mode 100644 index 00000000000..944774d809b --- /dev/null +++ b/cpp/include/Slice/FileTracker.h @@ -0,0 +1,62 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#ifndef FILE_TRACKER_H +#define FILE_TRACKER_H + +#include +#include + +namespace Slice +{ + +class SLICE_API FileException : public ::IceUtil::Exception +{ +public: + + FileException(const char*, int, const std::string&); + ~FileException() throw(); + virtual std::string ice_name() const; + virtual void ice_print(std::ostream&) const; + virtual ::IceUtil::Exception* ice_clone() const; + virtual void ice_throw() const; + + std::string reason() const; + +private: + + static const char* _name; + const std::string _reason; +}; + +class FileTracker; +typedef IceUtil::Handle FileTrackerPtr; + +class SLICE_API FileTracker : public ::IceUtil::SimpleShared +{ +public: + + FileTracker(); + ~FileTracker(); + + static FileTrackerPtr instance(); + + void addFile(const std::string&); + void addDirectory(const std::string&); + + void cleanup(); + +private: + + std::list > _files; +}; + +} + +#endif diff --git a/cpp/include/Slice/JavaUtil.h b/cpp/include/Slice/JavaUtil.h index 1f00ad906fd..d85ae3cf2bb 100644 --- a/cpp/include/Slice/JavaUtil.h +++ b/cpp/include/Slice/JavaUtil.h @@ -16,25 +16,6 @@ namespace Slice { -class SLICE_API FileException : public ::IceUtil::Exception -{ -public: - - FileException(const char*, int, const std::string&); - ~FileException() throw(); - virtual std::string ice_name() const; - virtual void ice_print(std::ostream&) const; - virtual ::IceUtil::Exception* ice_clone() const; - virtual void ice_throw() const; - - std::string reason() const; - -private: - - static const char* _name; - const std::string _reason; -}; - class SLICE_API JavaOutput : public ::IceUtilInternal::Output { public: diff --git a/cpp/src/Slice/FileTracker.cpp b/cpp/src/Slice/FileTracker.cpp new file mode 100644 index 00000000000..438670cf2f8 --- /dev/null +++ b/cpp/src/Slice/FileTracker.cpp @@ -0,0 +1,117 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include + +#ifdef _WIN32 +# include +#endif + +using namespace std; + +Slice::FileException::FileException(const char* file, int line, const string& r) : + Exception(file, line), + _reason(r) +{ +} + +Slice::FileException::~FileException() throw() +{ +} + +const char* Slice::FileException::_name = "Slice::FileException"; + +string +Slice::FileException::ice_name() const +{ + return _name; +} + +void +Slice::FileException::ice_print(ostream& out) const +{ + Exception::ice_print(out); + out << ": " << _reason; +} + +IceUtil::Exception* +Slice::FileException::ice_clone() const +{ + return new FileException(*this); +} + +void +Slice::FileException::ice_throw() const +{ + throw *this; +} + +string +Slice::FileException::reason() const +{ + return _reason; +} + + +static Slice::FileTrackerPtr Instance; + +Slice::FileTracker::FileTracker() +{ +} + +Slice::FileTracker::~FileTracker() +{ +} + +// The file tracker is not supposed to be thread safe. +Slice::FileTrackerPtr +Slice::FileTracker::instance() +{ + if(!Instance) + { + Instance = new FileTracker(); + } + return Instance; +} + +void +Slice::FileTracker::addFile(const string& file) +{ + _files.push_front(make_pair(file, false)); +} + +void +Slice::FileTracker::addDirectory(const string& dir) +{ + _files.push_front(make_pair(dir, true)); +} + +void +Slice::FileTracker::cleanup() +{ + for(list >::const_iterator p = _files.begin(); p != _files.end(); ++p) + { + if(!p->second) + { +#ifdef _WIN32 + _unlink(p->first.c_str()); +#else + unlink(p->first.c_str()); +#endif + } + else + { +#ifdef _WIN32 + _rmdir(p->first.c_str()); +#else + rmdir(p->first.c_str()); +#endif + } + } +} diff --git a/cpp/src/Slice/JavaUtil.cpp b/cpp/src/Slice/JavaUtil.cpp index 2a1114aa064..7c73227bc55 100644 --- a/cpp/src/Slice/JavaUtil.cpp +++ b/cpp/src/Slice/JavaUtil.cpp @@ -7,7 +7,9 @@ // // ********************************************************************** +#include #include +#include #include #include @@ -28,49 +30,6 @@ using namespace Slice; using namespace IceUtil; using namespace IceUtilInternal; -Slice::FileException::FileException(const char* file, int line, const string& r) : - Exception(file, line), - _reason(r) -{ -} - -Slice::FileException::~FileException() throw() -{ -} - -const char* Slice::FileException::_name = "Slice::FileException"; - -string -Slice::FileException::ice_name() const -{ - return _name; -} - -void -Slice::FileException::ice_print(ostream& out) const -{ - Exception::ice_print(out); - out << ": " << _reason; -} - -IceUtil::Exception* -Slice::FileException::ice_clone() const -{ - return new FileException(*this); -} - -void -Slice::FileException::ice_throw() const -{ - throw *this; -} - -string -Slice::FileException::reason() const -{ - return _reason; -} - Slice::JavaOutput::JavaOutput() { } @@ -146,6 +105,7 @@ Slice::JavaOutput::openClass(const string& cls, const string& prefix) os << "cannot create directory `" << path << "': " << strerror(errno); throw FileException(__FILE__, __LINE__, os.str()); } + FileTracker::instance()->addDirectory(path); } while(pos != string::npos); } @@ -167,6 +127,7 @@ Slice::JavaOutput::openClass(const string& cls, const string& prefix) open(path.c_str()); if(isOpen()) { + FileTracker::instance()->addFile(path); printHeader(); if(!package.empty()) diff --git a/cpp/src/Slice/Makefile b/cpp/src/Slice/Makefile index fb5c0d5268d..7232e2fe64a 100644 --- a/cpp/src/Slice/Makefile +++ b/cpp/src/Slice/Makefile @@ -27,6 +27,7 @@ OBJS = Scanner.o \ DotNetNames.o \ RubyUtil.o \ Util.o \ + FileTracker.o \ MD5.o \ MD5I.o diff --git a/cpp/src/Slice/Makefile.mak b/cpp/src/Slice/Makefile.mak index e9312581b07..ad3e5a89611 100644 --- a/cpp/src/Slice/Makefile.mak +++ b/cpp/src/Slice/Makefile.mak @@ -26,6 +26,7 @@ OBJS = Scanner.obj \ DotNetNames.obj \ RubyUtil.obj \ Util.obj \ + FileTracker.obj \ MD5.obj \ MD5I.obj diff --git a/cpp/src/Slice/Preprocessor.cpp b/cpp/src/Slice/Preprocessor.cpp index b61d43cc5c0..dd1260f2fa0 100644 --- a/cpp/src/Slice/Preprocessor.cpp +++ b/cpp/src/Slice/Preprocessor.cpp @@ -517,7 +517,7 @@ Slice::Preprocessor::checkInputFile() ifstream test(_fileName.c_str()); if(!test) { - cerr << _path << ": can't open `" << _fileName << "' for reading" << endl; + cerr << _path << ": cannot open `" << _fileName << "' for reading" << endl; return false; } test.close(); diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index a577c67541f..c593e3dcd21 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -7,12 +7,14 @@ // // ********************************************************************** +#include #include #include #include #include #include #include +#include #include #include @@ -34,8 +36,8 @@ getDeprecateSymbol(const ContainedPtr& p1, const ContainedPtr& p2) return deprecateSymbol; } -Slice::Gen::Gen(const string& name, const string& base, const string& headerExtension, - const string& sourceExtension, const vector& extraHeaders, const string& include, +Slice::Gen::Gen(const string& base, const string& headerExtension, const string& sourceExtension, + const vector& extraHeaders, const string& include, const vector& includePaths, const string& dllExport, const string& dir, bool imp, bool checksum, bool stream, bool ice) : _base(base), @@ -74,28 +76,34 @@ Slice::Gen::Gen(const string& name, const string& base, const string& headerExte struct stat st; if(stat(fileImplH.c_str(), &st) == 0) { - cerr << name << ": `" << fileImplH << "' already exists - will not overwrite" << endl; - return; + ostringstream os; + os << fileImplH << "' already exists - will not overwrite"; + throw FileException(__FILE__, __LINE__, os.str()); } if(stat(fileImplC.c_str(), &st) == 0) { - cerr << name << ": `" << fileImplC << "' already exists - will not overwrite" << endl; - return; + ostringstream os; + os << fileImplC << "' already exists - will not overwrite"; + throw FileException(__FILE__, __LINE__, os.str()); } implH.open(fileImplH.c_str()); if(!implH) { - cerr << name << ": can't open `" << fileImplH << "' for writing" << endl; - return; + ostringstream os; + os << "cannot open `" << fileImplH << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); } + FileTracker::instance()->addFile(fileImplH); implC.open(fileImplC.c_str()); if(!implC) { - cerr << name << ": can't open `" << fileImplC << "' for writing" << endl; - return; + ostringstream os; + os << "cannot open `" << fileImplC << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); } + FileTracker::instance()->addFile(fileImplC); string s = fileImplH; if(_include.size()) @@ -119,16 +127,20 @@ Slice::Gen::Gen(const string& name, const string& base, const string& headerExte H.open(fileH.c_str()); if(!H) { - cerr << name << ": can't open `" << fileH << "' for writing" << endl; - return; + ostringstream os; + os << "cannot open `" << fileH << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); } + FileTracker::instance()->addFile(fileH); C.open(fileC.c_str()); if(!C) { - cerr << name << ": can't open `" << fileC << "' for writing" << endl; - return; + ostringstream os; + os << "cannot open `" << fileC << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); } + FileTracker::instance()->addFile(fileC); printHeader(H); printHeader(C); @@ -158,20 +170,6 @@ Slice::Gen::~Gen() } } -bool -Slice::Gen::operator!() const -{ - if(!H || !C) - { - return true; - } - if(_impl && (!implH || !implC)) - { - return true; - } - return false; -} - void Slice::Gen::generate(const UnitPtr& p) { diff --git a/cpp/src/slice2cpp/Gen.h b/cpp/src/slice2cpp/Gen.h index c91b3ed34c7..e3c1c9afc01 100644 --- a/cpp/src/slice2cpp/Gen.h +++ b/cpp/src/slice2cpp/Gen.h @@ -21,7 +21,6 @@ class Gen : private ::IceUtil::noncopyable public: Gen(const std::string&, - const std::string&, const std::string&, const std::string&, const std::vector&, @@ -35,8 +34,6 @@ public: bool); ~Gen(); - bool operator!() const; // Returns true if there was a constructor error - void generate(const UnitPtr&); void closeOutput(); diff --git a/cpp/src/slice2cpp/Main.cpp b/cpp/src/slice2cpp/Main.cpp index 0f053917b0b..4ca202872c7 100644 --- a/cpp/src/slice2cpp/Main.cpp +++ b/cpp/src/slice2cpp/Main.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include using namespace std; @@ -216,14 +217,21 @@ main(int argc, char* argv[]) } else { - Gen gen(argv[0], icecpp.getBaseName(), headerExtension, sourceExtension, extraHeaders, include, - includePaths, dllExport, output, impl, checksum, stream, ice); - if(!gen) + try { + Gen gen(icecpp.getBaseName(), headerExtension, sourceExtension, extraHeaders, include, + includePaths, dllExport, output, impl, checksum, stream, ice); + gen.generate(u); + } + catch(const Slice::FileException& ex) + { + // If a file could not be created, then + // cleanup any created files. + FileTracker::instance()->cleanup(); u->destroy(); + cerr << argv[0] << ": " << ex.reason() << endl; return EXIT_FAILURE; } - gen.generate(u); } u->destroy(); @@ -235,6 +243,7 @@ main(int argc, char* argv[]) if(_interrupted) { + FileTracker::instance()->cleanup(); return EXIT_FAILURE; } } diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp index def7ed38beb..633ba2d7ac9 100644 --- a/cpp/src/slice2cs/Gen.cpp +++ b/cpp/src/slice2cs/Gen.cpp @@ -21,6 +21,7 @@ #include #include #include +#include using namespace std; using namespace Slice; @@ -1053,7 +1054,7 @@ Slice::CsVisitor::writeValue(const TypePtr& type) } -Slice::Gen::Gen(const string& name, const string& base, const vector& includePaths, const string& dir, +Slice::Gen::Gen(const string& base, const vector& includePaths, const string& dir, bool impl, bool implTie, bool stream) : _includePaths(includePaths), _stream(stream) @@ -1076,9 +1077,11 @@ Slice::Gen::Gen(const string& name, const string& base, const vector& in _out.open(file.c_str()); if(!_out) { - cerr << name << ": can't open `" << file << "' for writing" << endl; - return; + ostringstream os; + os << "cannot open `" << file << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); } + FileTracker::instance()->addFile(file); printHeader(); _out << nl << "// Generated from file `" << fileBase << ".ice'"; @@ -1105,16 +1108,20 @@ Slice::Gen::Gen(const string& name, const string& base, const vector& in struct stat st; if(stat(fileImpl.c_str(), &st) == 0) { - cerr << name << ": `" << fileImpl << "' already exists--will not overwrite" << endl; - return; + ostringstream os; + os << fileImpl << "' already exists - will not overwrite"; + throw FileException(__FILE__, __LINE__, os.str()); } _impl.open(fileImpl.c_str()); if(!_impl) { - cerr << name << ": can't open `" << fileImpl << "' for writing" << endl; - return; + ostringstream os; + os << ": cannot open `" << fileImpl << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); } + + FileTracker::instance()->addFile(fileImpl); } } @@ -1130,16 +1137,9 @@ Slice::Gen::~Gen() } } -bool -Slice::Gen::operator!() const -{ - return !_out; -} - void Slice::Gen::generate(const UnitPtr& p) { - CsGenerator::validateMetaData(p); UnitVisitor unitVisitor(_out, _stream); diff --git a/cpp/src/slice2cs/Gen.h b/cpp/src/slice2cs/Gen.h index 265e1ab910d..dc9d655570e 100644 --- a/cpp/src/slice2cs/Gen.h +++ b/cpp/src/slice2cs/Gen.h @@ -47,7 +47,6 @@ class Gen : private ::IceUtil::noncopyable public: Gen(const std::string&, - const std::string&, const std::vector&, const std::string&, bool, @@ -55,8 +54,6 @@ public: bool); ~Gen(); - bool operator!() const; // Returns true if there was a constructor error - void generate(const UnitPtr&); void generateTie(const UnitPtr&); void generateImpl(const UnitPtr&); diff --git a/cpp/src/slice2cs/Main.cpp b/cpp/src/slice2cs/Main.cpp index 2ed3177a683..abdc24c23db 100644 --- a/cpp/src/slice2cs/Main.cpp +++ b/cpp/src/slice2cs/Main.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include using namespace std; @@ -164,7 +165,10 @@ main(int argc, char* argv[]) if(depend) { Preprocessor icecpp(argv[0], *i, cppArgs); - icecpp.printMakefileDependencies(Preprocessor::CSharp, includePaths); + if(!icecpp.printMakefileDependencies(Preprocessor::CSharp, includePaths)) + { + return EXIT_FAILURE; + } } else { @@ -207,28 +211,35 @@ main(int argc, char* argv[]) } else { - Gen gen(argv[0], icecpp.getBaseName(), includePaths, output, impl, implTie, stream); - if(!gen) - { - p->destroy(); - return EXIT_FAILURE; - } - gen.generate(p); - if(tie) + try { - gen.generateTie(p); + Gen gen(icecpp.getBaseName(), includePaths, output, impl, implTie, stream); + gen.generate(p); + if(tie) + { + gen.generateTie(p); + } + if(impl) + { + gen.generateImpl(p); + } + if(implTie) + { + gen.generateImplTie(p); + } + if(checksum) + { + gen.generateChecksums(p); + } } - if(impl) + catch(const Slice::FileException& ex) { - gen.generateImpl(p); - } - if(implTie) - { - gen.generateImplTie(p); - } - if(checksum) - { - gen.generateChecksums(p); + // If a file could not be created, then + // cleanup any created files. + FileTracker::instance()->cleanup(); + p->destroy(); + cerr << argv[0] << ": " << ex.reason() << endl; + return EXIT_FAILURE; } } @@ -241,6 +252,7 @@ main(int argc, char* argv[]) if(_interrupted) { + FileTracker::instance()->cleanup(); return EXIT_FAILURE; } } diff --git a/cpp/src/slice2docbook/Gen.cpp b/cpp/src/slice2docbook/Gen.cpp index d40b9e1ee75..322ca9a1147 100644 --- a/cpp/src/slice2docbook/Gen.cpp +++ b/cpp/src/slice2docbook/Gen.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -21,8 +22,7 @@ using namespace Slice; using namespace IceUtil; using namespace IceUtilInternal; -Slice::Gen::Gen(const string& name, const string& file, bool standAlone, bool chapter, - bool noIndex, bool sortFields) : +Slice::Gen::Gen(const string& file, bool standAlone, bool chapter, bool noIndex, bool sortFields) : _standAlone(standAlone), _noIndex(noIndex), _sortFields(sortFields) @@ -39,8 +39,9 @@ Slice::Gen::Gen(const string& name, const string& file, bool standAlone, bool ch O.open(file.c_str()); if(!O) { - cerr << name << ": can't open `" << file << "' for writing: " << strerror(errno) << endl; - return; + ostringstream os; + os << "cannot open `" << file << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); } } @@ -48,12 +49,6 @@ Slice::Gen::~Gen() { } -bool -Slice::Gen::operator!() const -{ - return !O; -} - void Slice::Gen::generate(const UnitPtr& p) { diff --git a/cpp/src/slice2docbook/Gen.h b/cpp/src/slice2docbook/Gen.h index 55222938370..97cbe3e1274 100644 --- a/cpp/src/slice2docbook/Gen.h +++ b/cpp/src/slice2docbook/Gen.h @@ -21,11 +21,9 @@ class Gen : private ::IceUtil::noncopyable, public ParserVisitor { public: - Gen(const std::string&, const std::string&, bool, bool, bool, bool); + Gen(const std::string&, bool, bool, bool, bool); virtual ~Gen(); - bool operator!() const; // Returns true if there was a constructor error - void generate(const UnitPtr&); void closeOutput(); diff --git a/cpp/src/slice2docbook/Main.cpp b/cpp/src/slice2docbook/Main.cpp index 9e7add9b40c..25bd52137ac 100644 --- a/cpp/src/slice2docbook/Main.cpp +++ b/cpp/src/slice2docbook/Main.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include using namespace std; @@ -210,13 +211,20 @@ main(int argc, char* argv[]) if(status == EXIT_SUCCESS && !preprocess) { - Gen gen(argv[0], docbook, standAlone, chapter, noIndex, sortFields); - if(!gen) + try { + Gen gen(docbook, standAlone, chapter, noIndex, sortFields); + gen.generate(p); + } + catch(const Slice::FileException& ex) + { + // If a file could not be created, then + // cleanup any created files. + FileTracker::instance()->cleanup(); p->destroy(); + cerr << argv[0] << ": " << ex.reason() << endl; return EXIT_FAILURE; } - gen.generate(p); } p->destroy(); @@ -226,6 +234,7 @@ main(int argc, char* argv[]) if(_interrupted) { + FileTracker::instance()->cleanup(); return EXIT_FAILURE; } } diff --git a/cpp/src/slice2freeze/Main.cpp b/cpp/src/slice2freeze/Main.cpp index 16e95c109eb..84f98ac7c27 100644 --- a/cpp/src/slice2freeze/Main.cpp +++ b/cpp/src/slice2freeze/Main.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -219,25 +220,25 @@ usage(const char* n) // Note: --case-sensitive is intentionally not shown here! } -bool -checkIdentifier(string n, string t, string s) +void +checkIdentifier(string t, string s) { if(s.empty() || (!isalpha(static_cast(s[0])) && s[0] != '_')) { - cerr << n << ": `" << t << "' is not a valid type name" << endl; - return false; + ostringstream os; + os << t << "' is not a valid type name"; + throw os.str(); } for(unsigned int i = 1; i < s.size(); ++i) { if(!isalnum(static_cast(s[i])) && s[i] != '_') { - cerr << n << ": `" << t << "' is not a valid type name" << endl; - return false; + ostringstream os; + os << t << "' is not a valid type name"; + throw os.str(); } } - - return true; } void @@ -924,9 +925,8 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di } } - -bool -writeDict(const string& n, UnitPtr& u, const Dict& dict, Output& H, Output& C, const string& dllExport) +void +writeDict(const string& n, const UnitPtr& u, const Dict& dict, Output& H, Output& C, const string& dllExport) { string absolute = dict.name; if(absolute.find("::") == 0) @@ -941,32 +941,28 @@ writeDict(const string& n, UnitPtr& u, const Dict& dict, Output& H, Output& C, c string s = name.substr(0, pos); name.erase(0, pos + 2); - if(!checkIdentifier(n, absolute, s)) - { - return false; - } + checkIdentifier(absolute, s); scope.push_back(s); } - if(!checkIdentifier(n, absolute, name)) - { - return false; - } + checkIdentifier(absolute, name); TypeList keyTypes = u->lookupType(dict.key, false); if(keyTypes.empty()) { - cerr << n << ": `" << dict.key << "' is not a valid type" << endl; - return false; + ostringstream os; + os << "`" << dict.key << "' is not a valid type"; + throw os.str(); } TypePtr keyType = keyTypes.front(); TypeList valueTypes = u->lookupType(dict.value, false); if(valueTypes.empty()) { - cerr << n << ": `" << dict.value << "' is not a valid type" << endl; - return false; + ostringstream os; + os << "`" << dict.value << "' is not a valid type"; + throw os.str(); } TypePtr valueType = valueTypes.front(); @@ -1002,19 +998,21 @@ writeDict(const string& n, UnitPtr& u, const Dict& dict, Output& H, Output& C, c { if(dict.indices.size() > 1) { - cerr << n << ": bad index for dictionary `" << dict.name << "'" << endl; - return false; + ostringstream os; + os << "bad index for dictionary `" << dict.name << "'"; + throw os.str(); } bool containsSequence = false; if(!Dictionary::legalKeyType(valueType, containsSequence)) { - cerr << n << ": `" << dict.value << "' is not a valid index type" << endl; - return false; + ostringstream os; + os << "`" << dict.value << "' is not a valid index type"; + throw os.str(); } if(containsSequence) { - cerr << n << ": warning: use of sequences in dictionary keys has been deprecated" << endl; + cerr << n << ": warning: use of sequences in dictionary keys has been deprecated"; } @@ -1028,8 +1026,9 @@ writeDict(const string& n, UnitPtr& u, const Dict& dict, Output& H, Output& C, c if(builtInType == 0 || builtInType->kind() != Builtin::KindString) { - cerr << n << ": VALUE is a `" << dict.value << "', not a string" << endl; - return false; + ostringstream os; + os << "VALUE is a `" << dict.value << "', not a string"; + throw os.str(); } } IndexType iType; @@ -1052,8 +1051,9 @@ writeDict(const string& n, UnitPtr& u, const Dict& dict, Output& H, Output& C, c StructPtr structDecl = StructPtr::dynamicCast(valueType); if(structDecl == 0) { - cerr << n << ": `" << dict.value << "' is neither a class nor a struct." << endl; - return false; + ostringstream os; + os << "`" << dict.value << "' is neither a class nor a struct."; + throw os.str(); } dataMembers = structDecl->dataMembers(); } @@ -1072,9 +1072,10 @@ writeDict(const string& n, UnitPtr& u, const Dict& dict, Output& H, Output& C, c if(dataMember == 0) { - cerr << n << ": The value of `" << dict.name - << "' has no data member named `" << index.member << "'" << endl; - return false; + ostringstream os; + os << "The value of `" << dict.name + << "' has no data member named `" << index.member << "'"; + throw os.str(); } TypePtr dataMemberType = dataMember->type(); @@ -1082,12 +1083,13 @@ writeDict(const string& n, UnitPtr& u, const Dict& dict, Output& H, Output& C, c bool containsSequence = false; if(!Dictionary::legalKeyType(dataMemberType, containsSequence)) { - cerr << n << ": `" << index.member << "' cannot be used as an index" << endl; - return false; + ostringstream os; + os << "`" << index.member << "' cannot be used as an index"; + throw os.str(); } if(containsSequence) { - cerr << n << ": warning: use of sequences in dictionary keys has been deprecated" << endl; + cerr << n << ": warning: use of sequences in dictionary keys has been deprecated"; } @@ -1099,8 +1101,9 @@ writeDict(const string& n, UnitPtr& u, const Dict& dict, Output& H, Output& C, c BuiltinPtr memberType = BuiltinPtr::dynamicCast(dataMemberType); if(memberType == 0 || memberType->kind() != Builtin::KindString) { - cerr << n << ": `" << index.member << "' is not a string " << endl; - return false; + ostringstream os; + os << "`" << index.member << "' is not a string "; + throw os.str(); } } IndexType iType; @@ -1128,11 +1131,8 @@ writeDict(const string& n, UnitPtr& u, const Dict& dict, Output& H, Output& C, c writeDictWithIndicesC(name, absolute, dict, indexTypes, keyType, dict.keyMetaData, valueType, dict.valueMetaData, C); } - - return true; } - void writeIndexH(const string& memberTypeString, const string& name, Output& H, const string& dllExport) { @@ -1251,8 +1251,8 @@ writeIndexC(const TypePtr& type, const TypePtr& memberType, const string& member C << eb; } -bool -writeIndex(const string& n, UnitPtr& u, const Index& index, Output& H, Output& C, const string& dllExport) +void +writeIndex(const string& n, const UnitPtr& u, const Index& index, Output& H, Output& C, const string& dllExport) { string absolute = index.name; if(absolute.find("::") == 0) @@ -1267,32 +1267,28 @@ writeIndex(const string& n, UnitPtr& u, const Index& index, Output& H, Output& C string s = name.substr(0, pos); name.erase(0, pos + 2); - if(!checkIdentifier(n, absolute, s)) - { - return false; - } + checkIdentifier(absolute, s); scope.push_back(s); } - if(!checkIdentifier(n, absolute, name)) - { - return false; - } + checkIdentifier(absolute, name); TypeList types = u->lookupType(index.type, false); if(types.empty()) { - cerr << n << ": `" << index.type << "' is not a valid type" << endl; - return false; + ostringstream os; + os << "`" << index.type << "' is not a valid type"; + throw os.str(); } TypePtr type = types.front(); ClassDeclPtr classDecl = ClassDeclPtr::dynamicCast(type); if(classDecl == 0) { - cerr << n << ": `" << index.type << "' is not a class" << endl; - return false; + ostringstream os; + os << "`" << index.type << "' is not a class"; + throw os.str(); } DataMemberList dataMembers = classDecl->definition()->allDataMembers(); @@ -1312,8 +1308,9 @@ writeIndex(const string& n, UnitPtr& u, const Index& index, Output& H, Output& C if(dataMember == 0) { - cerr << n << ": `" << index.type << "' has no data member named `" << index.member << "'" << endl; - return false; + ostringstream os; + os << "`" << index.type << "' has no data member named `" << index.member << "'"; + throw os.str(); } if(index.caseSensitive == false) @@ -1324,8 +1321,9 @@ writeIndex(const string& n, UnitPtr& u, const Index& index, Output& H, Output& C BuiltinPtr memberType = BuiltinPtr::dynamicCast(dataMember->type()); if(memberType == 0 || memberType->kind() != Builtin::KindString) { - cerr << n << ": `" << index.member << "'is not a string " << endl; - return false; + ostringstream os; + os << "`" << index.member << "'is not a string"; + throw os.str(); } } @@ -1346,7 +1344,140 @@ writeIndex(const string& n, UnitPtr& u, const Index& index, Output& H, Output& C } writeIndexC(type, dataMember->type(), index.member, index.caseSensitive, absolute, name, C); - return true; +} + +void +gen(const string& name, const UnitPtr& u, const vector& includePaths, const vector& extraHeaders, + const vector& dicts, const vector& indices, const string& include, const string& headerExtension, + const string& sourceExtension, string dllExport, const StringList& includes, const vector& args, + const string& output) +{ + string fileH = args[0]; + fileH += "." + headerExtension; + string includeH = fileH; + string fileC = args[0]; + fileC += "." + sourceExtension; + + if(!output.empty()) + { + fileH = output + '/' + fileH; + fileC = output + '/' + fileC; + } + + u->mergeModules(); + u->sort(); + + IceUtilInternal::Output H; + H.open(fileH.c_str()); + if(!H) + { + ostringstream os; + os << "cannot open `" << fileH << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); + } + + FileTracker::instance()->addFile(fileH); + + printHeader(H); + printFreezeTypes(H, dicts, indices); + + IceUtilInternal::Output CPP; + CPP.open(fileC.c_str()); + if(!CPP) + { + ostringstream os; + os << "cannot open `" << fileC << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); + } + FileTracker::instance()->addFile(fileC); + + printHeader(CPP); + printFreezeTypes(CPP, dicts, indices); + + 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()) + { + CPP << "\n#ifndef " << guard; + CPP << "\n#define " << guard; + } + CPP << "\n#include <"; + if(!include.empty()) + { + CPP << include << '/'; + } + CPP << hdr << '>'; + if(!guard.empty()) + { + CPP << "\n#endif"; + } + } + + string s = fileH; + transform(s.begin(), s.end(), s.begin(), ToIfdef()); + H << "\n#ifndef __" << s << "__"; + H << "\n#define __" << s << "__"; + H << '\n'; + + if(dicts.size() > 0) + { + H << "\n#include "; + } + + if(indices.size() > 0) + { + H << "\n#include "; + } + + { + for(StringList::const_iterator p = includes.begin(); p != includes.end(); ++p) + { + H << "\n#include <" << changeInclude(*p, includePaths) << "." + headerExtension + ">"; + } + } + + CPP << "\n#include "; + CPP << "\n#include <"; + if(include.size()) + { + CPP << include << '/'; + } + CPP << includeH << '>'; + + printVersionCheck(H); + printVersionCheck(CPP); + + printDllExportStuff(H, dllExport); + if(dllExport.size()) + { + dllExport += " "; + } + + { + for(vector::const_iterator p = dicts.begin(); p != dicts.end(); ++p) + { + writeDict(name, u, *p, H, CPP, dllExport); + } + + for(vector::const_iterator q = indices.begin(); q != indices.end(); ++q) + { + writeIndex(name, u, *q, H, CPP, dllExport); + } + } + + H << "\n\n#endif\n"; + CPP << '\n'; + + H.close(); + CPP.close(); } int @@ -1420,6 +1551,14 @@ main(int argc, char* argv[]) cppArgs.push_back("-I" + Preprocessor::normalizeIncludePath(*i)); } + // Convert include paths to full paths. + { + for(vector::iterator p = includePaths.begin(); p != includePaths.end(); ++p) + { + *p = fullPath(*p); + } + } + bool preprocess= opts.isSet("E"); string include = opts.optArg("include-dir"); @@ -1775,17 +1914,6 @@ main(int argc, char* argv[]) return EXIT_FAILURE; } - string fileH = args[0]; - fileH += "." + headerExtension; - string includeH = fileH; - string fileC = args[0]; - fileC += "." + sourceExtension; - if(!output.empty()) - { - fileH = output + '/' + fileH; - fileC = output + '/' + fileC; - } - UnitPtr u = Unit::createUnit(true, false, ice, caseSensitive); StringList includes; @@ -1849,153 +1977,39 @@ main(int argc, char* argv[]) } } + if(status == EXIT_SUCCESS && !preprocess) { - u->mergeModules(); - u->sort(); - + try { - for(vector::iterator p = includePaths.begin(); p != includePaths.end(); ++p) - { - *p = fullPath(*p); - } + gen(argv[0], u, includePaths, extraHeaders, dicts, indices, include, headerExtension, + sourceExtension, dllExport, includes, args, output); } - - IceUtilInternal::Output H; - H.open(fileH.c_str()); - if(!H) + catch(const string& ex) { - cerr << argv[0] << ": can't open `" << fileH << "' for writing: " << strerror(errno) << endl; + // If a file could not be created, then cleanup any + // created files. + FileTracker::instance()->cleanup(); u->destroy(); + cerr << argv[0] << ": " << ex << endl; return EXIT_FAILURE; } - printHeader(H); - printFreezeTypes(H, dicts, indices); - - IceUtilInternal::Output CPP; - CPP.open(fileC.c_str()); - if(!CPP) + catch(const Slice::FileException& ex) { - cerr << argv[0] << ": can't open `" << fileC << "' for writing: " << strerror(errno) << endl; + // If a file could not be created, then cleanup any + // created files. + FileTracker::instance()->cleanup(); u->destroy(); + cerr << argv[0] << ": " << ex.reason() << endl; return EXIT_FAILURE; } - printHeader(CPP); - printFreezeTypes(CPP, dicts, indices); - - 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()) - { - CPP << "\n#ifndef " << guard; - CPP << "\n#define " << guard; - } - CPP << "\n#include <"; - if(!include.empty()) - { - CPP << include << '/'; - } - CPP << hdr << '>'; - if(!guard.empty()) - { - CPP << "\n#endif"; - } - } - - string s = fileH; - transform(s.begin(), s.end(), s.begin(), ToIfdef()); - H << "\n#ifndef __" << s << "__"; - H << "\n#define __" << s << "__"; - H << '\n'; - - if(dicts.size() > 0) - { - H << "\n#include "; - } - - if(indices.size() > 0) - { - H << "\n#include "; - } - - + catch(...) { - for(StringList::const_iterator p = includes.begin(); p != includes.end(); ++p) - { - H << "\n#include <" << changeInclude(*p, includePaths) << "." + headerExtension + ">"; - } - } - - CPP << "\n#include "; - CPP << "\n#include <"; - if(include.size()) - { - CPP << include << '/'; - } - CPP << includeH << '>'; - - printVersionCheck(H); - printVersionCheck(CPP); - - printDllExportStuff(H, dllExport); - if(dllExport.size()) - { - dllExport += " "; - } - - { - for(vector::const_iterator p = dicts.begin(); p != dicts.end(); ++p) - { - try - { - if(!writeDict(argv[0], u, *p, H, CPP, dllExport)) - { - u->destroy(); - return EXIT_FAILURE; - } - } - catch(...) - { - cerr << argv[0] << ": unknown exception" << endl; - u->destroy(); - return EXIT_FAILURE; - } - } - - - for(vector::const_iterator q = indices.begin(); q != indices.end(); ++q) - { - try - { - if(!writeIndex(argv[0], u, *q, H, CPP, dllExport)) - { - u->destroy(); - return EXIT_FAILURE; - } - } - catch(...) - { - cerr << argv[0] << ": unknown exception" << endl; - u->destroy(); - return EXIT_FAILURE; - } - } - + cerr << argv[0] << ": unknown exception" << endl; + FileTracker::instance()->cleanup(); + u->destroy(); + return EXIT_FAILURE; } - - H << "\n\n#endif\n"; - CPP << '\n'; - - H.close(); - CPP.close(); } u->destroy(); @@ -2005,10 +2019,10 @@ main(int argc, char* argv[]) if(_interrupted) { + FileTracker::instance()->cleanup(); return EXIT_FAILURE; } } - return status; } diff --git a/cpp/src/slice2freezej/Main.cpp b/cpp/src/slice2freezej/Main.cpp index 9bae291e172..2b89feb5cfc 100644 --- a/cpp/src/slice2freezej/Main.cpp +++ b/cpp/src/slice2freezej/Main.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #ifdef __BCPLUSPLUS__ @@ -73,15 +74,15 @@ public: FreezeGenerator(const string&, const string&); virtual ~FreezeGenerator(); - bool generate(UnitPtr&, const Dict&); + void generate(UnitPtr&, const Dict&); - bool generate(UnitPtr&, const Index&); + void generate(UnitPtr&, const Index&); private: string varToObject(const TypePtr&, const string&); string objectToVar(const TypePtr&, const string&); - string _prog; + const string _prog; }; FreezeGenerator::FreezeGenerator(const string& prog, const string& dir) @@ -204,7 +205,7 @@ FreezeGenerator::objectToVar(const TypePtr& type, const string& param) return result; } -bool +void FreezeGenerator::generate(UnitPtr& u, const Dict& dict) { static const char* builtinTable[] = @@ -236,16 +237,18 @@ FreezeGenerator::generate(UnitPtr& u, const Dict& dict) TypeList keyTypes = u->lookupType(dict.key, false); if(keyTypes.empty()) { - cerr << _prog << ": `" << dict.key << "' is not a valid type" << endl; - return false; + ostringstream os; + os << "`" << dict.key << "' is not a valid type" << endl; + throw os.str(); } TypePtr keyType = keyTypes.front(); TypeList valueTypes = u->lookupType(dict.value, false); if(valueTypes.empty()) { - cerr << _prog << ": `" << dict.value << "' is not a valid type" << endl; - return false; + ostringstream os; + os << "`" << dict.value << "' is not a valid type" << endl; + throw os.str(); } TypePtr valueType = valueTypes.front(); @@ -263,15 +266,17 @@ FreezeGenerator::generate(UnitPtr& u, const Dict& dict) { if(dict.indices.size() > 1) { - cerr << _prog << ": bad index for dictionary `" << dict.name << "'" << endl; - return false; + ostringstream os; + os << "bad index for dictionary `" << dict.name << "'" << endl; + throw os.str(); } bool containsSequence = false; if(!Dictionary::legalKeyType(valueType, containsSequence)) { - cerr << _prog << ": `" << dict.value << "' is not a valid index type" << endl; - return false; + ostringstream os; + os << "`" << dict.value << "' is not a valid index type" << endl; + throw os.str(); } if(containsSequence) { @@ -288,8 +293,9 @@ FreezeGenerator::generate(UnitPtr& u, const Dict& dict) if(builtInType == 0 || builtInType->kind() != Builtin::KindString) { - cerr << _prog << ": VALUE is a `" << dict.value << "', not a string " << endl; - return false; + ostringstream os; + os << "VALUE is a `" << dict.value << "', not a string " << endl; + throw os.str(); } } indexTypes.push_back(valueType); @@ -311,8 +317,9 @@ FreezeGenerator::generate(UnitPtr& u, const Dict& dict) StructPtr structDecl = StructPtr::dynamicCast(valueType); if(structDecl == 0) { - cerr << _prog << ": `" << dict.value << "' is neither a class nor a struct." << endl; - return false; + ostringstream os; + os << "`" << dict.value << "' is neither a class nor a struct." << endl; + throw os.str(); } dataMembers = structDecl->dataMembers(); } @@ -331,9 +338,10 @@ FreezeGenerator::generate(UnitPtr& u, const Dict& dict) if(dataMember == 0) { - cerr << _prog << ": The value of `" << dict.name - << "' has no data member named `" << index.member << "'" << endl; - return false; + ostringstream os; + os << "The value of `" << dict.name + << "' has no data member named `" << index.member << "'" << endl; + throw os.str(); } TypePtr dataMemberType = dataMember->type(); @@ -341,8 +349,9 @@ FreezeGenerator::generate(UnitPtr& u, const Dict& dict) bool containsSequence = false; if(!Dictionary::legalKeyType(dataMemberType, containsSequence)) { - cerr << _prog << ": `" << index.member << "' cannot be used as an index" << endl; - return false; + ostringstream os; + os << "`" << index.member << "' cannot be used as an index" << endl; + throw os.str(); } if(containsSequence) { @@ -357,8 +366,9 @@ FreezeGenerator::generate(UnitPtr& u, const Dict& dict) BuiltinPtr memberType = BuiltinPtr::dynamicCast(dataMemberType); if(memberType == 0 || memberType->kind() != Builtin::KindString) { - cerr << _prog << ": `" << index.member << "' is not a string " << endl; - return false; + ostringstream os; + os << "`" << index.member << "' is not a string " << endl; + throw os.str(); } } indexTypes.push_back(dataMemberType); @@ -934,13 +944,10 @@ FreezeGenerator::generate(UnitPtr& u, const Dict& dict) out << eb; - close(); - - return true; } -bool +void FreezeGenerator::generate(UnitPtr& u, const Index& index) { string name; @@ -957,16 +964,18 @@ FreezeGenerator::generate(UnitPtr& u, const Index& index) TypeList types = u->lookupType(index.type, false); if(types.empty()) { - cerr << _prog << ": `" << index.type << "' is not a valid type" << endl; - return false; + ostringstream os; + os << "`" << index.type << "' is not a valid type" << endl; + throw os.str(); } TypePtr type = types.front(); ClassDeclPtr classDecl = ClassDeclPtr::dynamicCast(type); if(classDecl == 0) { - cerr << _prog << ": `" << index.type << "' is not a class" << endl; - return false; + ostringstream os; + os << "`" << index.type << "' is not a class" << endl; + throw os.str(); } DataMemberList dataMembers = classDecl->definition()->allDataMembers(); @@ -986,8 +995,9 @@ FreezeGenerator::generate(UnitPtr& u, const Index& index) if(dataMember == 0) { - cerr << _prog << ": `" << index.type << "' has no data member named `" << index.member << "'" << endl; - return false; + ostringstream os; + os << "`" << index.type << "' has no data member named `" << index.member << "'" << endl; + throw os.str(); } if(index.caseSensitive == false) @@ -998,8 +1008,9 @@ FreezeGenerator::generate(UnitPtr& u, const Index& index) BuiltinPtr memberType = BuiltinPtr::dynamicCast(dataMember->type()); if(memberType == 0 || memberType->kind() != Builtin::KindString) { - cerr << _prog << ": `" << index.member << "'is not a string " << endl; - return false; + ostringstream os; + os << "`" << index.member << "'is not a string " << endl; + throw os.str(); } } @@ -1087,11 +1098,8 @@ FreezeGenerator::generate(UnitPtr& u, const Index& index) out << eb; close(); - - return true; } - void usage(const char* n) { @@ -1501,20 +1509,29 @@ main(int argc, char* argv[]) { try { - if(!gen.generate(u, *p)) - { - u->destroy(); - return EXIT_FAILURE; - } + gen.generate(u, *p); + } + catch(const string& ex) + { + // If a file could not be created, then cleanup any + // created files. + FileTracker::instance()->cleanup(); + u->destroy(); + cerr << argv[0] << ": " << ex << endl; + return EXIT_FAILURE; } catch(const Slice::FileException& ex) { + // If a file could not be created, then cleanup any + // created files. + FileTracker::instance()->cleanup(); u->destroy(); cerr << ex.reason() << endl; return EXIT_FAILURE; } catch(...) { + FileTracker::instance()->cleanup(); cerr << argv[0] << ": unknown exception" << endl; u->destroy(); return EXIT_FAILURE; @@ -1525,15 +1542,30 @@ main(int argc, char* argv[]) { try { - if(!gen.generate(u, *q)) - { - u->destroy(); - return EXIT_FAILURE; - } + gen.generate(u, *q); + } + catch(const string& ex) + { + // If a file could not be created, then cleanup any + // created files. + FileTracker::instance()->cleanup(); + u->destroy(); + cerr << argv[0] << ": " << ex << endl; + return EXIT_FAILURE; + } + catch(const Slice::FileException& ex) + { + // If a file could not be created, then cleanup any + // created files. + FileTracker::instance()->cleanup(); + u->destroy(); + cerr << argv[0] << ": " << ex.reason() << endl; + return EXIT_FAILURE; } catch(...) { cerr << argv[0] << ": unknown exception" << endl; + FileTracker::instance()->cleanup(); u->destroy(); return EXIT_FAILURE; } @@ -1548,6 +1580,7 @@ main(int argc, char* argv[]) if(_interrupted) { + FileTracker::instance()->cleanup(); return EXIT_FAILURE; } } diff --git a/cpp/src/slice2html/Gen.cpp b/cpp/src/slice2html/Gen.cpp index d1a56b6ed32..f02ef04b75f 100644 --- a/cpp/src/slice2html/Gen.cpp +++ b/cpp/src/slice2html/Gen.cpp @@ -7,8 +7,13 @@ // // ********************************************************************** +#if defined(_MSC_VER) && _MSC_VER >= 1400 +# define _CRT_SECURE_NO_DEPRECATE 1 // C4996 '' was declared deprecated +#endif + #include #include +#include #include #include @@ -1244,9 +1249,11 @@ Slice::GeneratorBase::openStream(const string& path) _out.open(path.c_str()); if(!_out.isOpen()) { - string err = "cannot open `" + path + "' for writing"; - throw err; + ostringstream os; + os << "cannot open file `" << path << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); } + FileTracker::instance()->addFile(path); } void @@ -1447,18 +1454,28 @@ Slice::GeneratorBase::makeDir(const string& dir) int rc = stat(dir.c_str(), &st); if(rc == 0) { + if(!(st.st_mode & S_IFDIR)) + { + ostringstream os; + os << "failed to create package directory `" << dir + << "': file already exists and is not a directory"; + throw FileException(__FILE__, __LINE__, os.str()); + } return; } + #ifdef _WIN32 - rc = mkdir(dir.c_str()); + rc = _mkdir(dir.c_str()); #else rc = mkdir(dir.c_str(), S_IRWXU | S_IRWXG | S_IRWXO); #endif if(rc != 0) { - string err = "cannot create directory `" + dir + "'"; - throw err; + ostringstream os; + os << "cannot create directory `" << dir << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); } + FileTracker::instance()->addDirectory(dir); } string @@ -1467,8 +1484,9 @@ Slice::GeneratorBase::readFile(const string& file) ifstream in(file.c_str()); if(!in) { - string err = "cannot open `" + file + "' for reading"; - throw err; + ostringstream os; + os << "cannot open file `" << file << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); } ostringstream result; @@ -1540,8 +1558,9 @@ Slice::GeneratorBase::readFile(const string& file, string& part1, string& part2) ifstream in(file.c_str()); if(!in) { - string err = "cannot open `" + file + "' for reading"; - throw err; + ostringstream os; + os << "cannot open file `" << file << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); } string line; diff --git a/cpp/src/slice2html/Main.cpp b/cpp/src/slice2html/Main.cpp index f1e864b140f..068287ed632 100644 --- a/cpp/src/slice2html/Main.cpp +++ b/cpp/src/slice2html/Main.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -238,13 +239,24 @@ main(int argc, char* argv[]) Slice::generate(p, output, header, footer, indexHeader, indexFooter, imageDir, logoURL, searchAction, indexCount, summaryCount); } + catch(const Slice::FileException& ex) + { + // If a file could not be created, then cleanup any + // created files. + FileTracker::instance()->cleanup(); + p->destroy(); + cerr << argv[0] << ": " << ex.reason() << endl; + return EXIT_FAILURE; + } catch(const string& err) { + FileTracker::instance()->cleanup(); cerr << argv[0] << ": " << err << endl; status = EXIT_FAILURE; } catch(const char* err) { + FileTracker::instance()->cleanup(); cerr << argv[0] << ": " << err << endl; status = EXIT_FAILURE; } @@ -257,6 +269,7 @@ main(int argc, char* argv[]) if(_interrupted) { + FileTracker::instance()->cleanup(); return EXIT_FAILURE; } } diff --git a/cpp/src/slice2java/Main.cpp b/cpp/src/slice2java/Main.cpp index b2fff573e39..bc555d403bb 100644 --- a/cpp/src/slice2java/Main.cpp +++ b/cpp/src/slice2java/Main.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #ifdef __BCPLUSPLUS__ @@ -234,7 +235,7 @@ main(int argc, char* argv[]) p->destroy(); return EXIT_FAILURE; } - + if(parseStatus == EXIT_FAILURE) { status = EXIT_FAILURE; @@ -273,8 +274,11 @@ main(int argc, char* argv[]) } catch(const Slice::FileException& ex) { + // If a file could not be created, then + // cleanup any created files. + FileTracker::instance()->cleanup(); p->destroy(); - cerr << ex.reason() << endl; + cerr << argv[0] << ": " << ex.reason() << endl; return EXIT_FAILURE; } } @@ -287,6 +291,9 @@ main(int argc, char* argv[]) if(_interrupted) { + // If the translator was interrupted, then cleanup any + // created files. + FileTracker::instance()->cleanup(); return EXIT_FAILURE; } } @@ -294,7 +301,18 @@ main(int argc, char* argv[]) if(!checksumClass.empty()) { - Gen::writeChecksumClass(checksumClass, output, checksums, java2); + try + { + Gen::writeChecksumClass(checksumClass, output, checksums, java2); + } + catch(const Slice::FileException& ex) + { + // If a file could not be created, then + // cleanup any created files. + FileTracker::instance()->cleanup(); + cerr << argv[0] << ": " << ex.reason() << endl; + return EXIT_FAILURE; + } } return status; diff --git a/cpp/src/slice2py/Main.cpp b/cpp/src/slice2py/Main.cpp index 660914e715c..4b522bf9a98 100644 --- a/cpp/src/slice2py/Main.cpp +++ b/cpp/src/slice2py/Main.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -72,7 +73,7 @@ class PackageVisitor : public ParserVisitor { public: - PackageVisitor(const string&, const string&, const string&); + PackageVisitor(const string&, const string&); virtual bool visitModuleStart(const ModulePtr&); virtual void visitModuleEnd(const ModulePtr&); @@ -84,15 +85,14 @@ private: static const char* _moduleTag; static const char* _submoduleTag; - bool createDirectory(const string&); + void createDirectory(const string&); - bool addModule(const string&, const string&); - bool addSubmodule(const string&, const string&); + void addModule(const string&, const string&); + void addSubmodule(const string&, const string&); - bool readInit(const string&, StringList&, StringList&); - bool writeInit(const string&, const StringList&, const StringList&); + void readInit(const string&, StringList&, StringList&); + void writeInit(const string&, const StringList&, const StringList&); - string _name; string _module; StringList _pathStack; }; @@ -100,8 +100,8 @@ private: const char* PackageVisitor::_moduleTag = "# Modules:"; const char* PackageVisitor::_submoduleTag = "# Submodules:"; -PackageVisitor::PackageVisitor(const string& name, const string& module, const string& dir) : - _name(name), _module(module) +PackageVisitor::PackageVisitor(const string& module, const string& dir) : + _module(module) { if(dir.empty()) { @@ -138,27 +138,18 @@ PackageVisitor::visitModuleStart(const ModulePtr& p) } for(vector::iterator q = v.begin(); q != v.end(); ++q) { - if(q != v.begin() && !addSubmodule(path, fixIdent(*q))) + if(q != v.begin()) { - return false; + addSubmodule(path, fixIdent(*q)); } path += "/" + *q; - if(!createDirectory(path)) - { - return false; - } + createDirectory(path); - if(!addModule(path, _module)) - { - return false; - } + addModule(path, _module); } - if(!addSubmodule(path, name)) - { - return false; - } + addSubmodule(path, name); } path += "/" + name; @@ -171,26 +162,20 @@ PackageVisitor::visitModuleStart(const ModulePtr& p) string parentPath = _pathStack.front(); _pathStack.push_front(path); - if(!createDirectory(path)) - { - return false; - } + createDirectory(path); // // If necessary, add this module to the set of imported modules in __init__.py. // - if(!addModule(path, _module)) - { - return false; - } + addModule(path, _module); // // If this is a submodule, then modify the parent's __init__.py to import us. // ModulePtr mod = ModulePtr::dynamicCast(p->container()); - if(mod && !addSubmodule(parentPath, name)) + if(mod) { - return false; + addSubmodule(parentPath, name); } return true; @@ -203,75 +188,72 @@ PackageVisitor::visitModuleEnd(const ModulePtr& p) _pathStack.pop_front(); } -bool +void PackageVisitor::createDirectory(const string& dir) { struct stat st; int result; result = stat(dir.c_str(), &st); - if(result != 0) + if(result == 0) { + if(!(st.st_mode & S_IFDIR)) + { + ostringstream os; + os << "failed to create package directory `" << dir + << "': file already exists and is not a directory"; + throw FileException(__FILE__, __LINE__, os.str()); + } + return; + } #ifdef _WIN32 - result = _mkdir(dir.c_str()); + result = _mkdir(dir.c_str()); #else - result = mkdir(dir.c_str(), S_IRWXU | S_IRWXG | S_IRWXO); + result = mkdir(dir.c_str(), S_IRWXU | S_IRWXG | S_IRWXO); #endif - if(result != 0) - { - cerr << _name << ": unable to create `" << dir << "': " << strerror(errno) << endl; - return false; - } + if(result != 0) + { + ostringstream os; + os << "cannot create directory `" << dir << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); } - return true; + FileTracker::instance()->addDirectory(dir); } -bool +void PackageVisitor::addModule(const string& dir, const string& name) { // // Add a module to the set of imported modules in __init__.py. // StringList modules, submodules; - if(readInit(dir, modules, submodules)) + readInit(dir, modules, submodules); + StringList::iterator p = find(modules.begin(), modules.end(), name); + if(p == modules.end()) { - StringList::iterator p = find(modules.begin(), modules.end(), name); - if(p == modules.end()) - { - modules.push_back(name); - return writeInit(dir, modules, submodules); - } - - return true; + modules.push_back(name); + writeInit(dir, modules, submodules); } - - return false; } -bool +void PackageVisitor::addSubmodule(const string& dir, const string& name) { // // Add a submodule to the set of imported modules in __init__.py. // StringList modules, submodules; - if(readInit(dir, modules, submodules)) + readInit(dir, modules, submodules); + StringList::iterator p = find(submodules.begin(), submodules.end(), name); + if(p == submodules.end()) { - StringList::iterator p = find(submodules.begin(), submodules.end(), name); - if(p == submodules.end()) - { - submodules.push_back(name); - return writeInit(dir, modules, submodules); - } - - return true; + submodules.push_back(name); + writeInit(dir, modules, submodules); } - - return false; } -bool +void PackageVisitor::readInit(const string& dir, StringList& modules, StringList& submodules) { string initPath = dir + "/__init__.py"; @@ -282,8 +264,9 @@ PackageVisitor::readInit(const string& dir, StringList& modules, StringList& sub ifstream in(initPath.c_str()); if(!in) { - cerr << _name << ": unable to open `" << initPath << "': " << strerror(errno) << endl; - return false; + ostringstream os; + os << "cannot open file `" << initPath << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); } ReadState state = PreModules; @@ -316,8 +299,9 @@ PackageVisitor::readInit(const string& dir, StringList& modules, StringList& sub if(s.size() < 8) { - cerr << _name << ": invalid line `" << s << "' in `" << initPath << "'" << endl; - return false; + ostringstream os; + os << "invalid line `" << s << "' in `" << initPath << "'"; + throw os.str(); } string name = s.substr(7); @@ -334,15 +318,14 @@ PackageVisitor::readInit(const string& dir, StringList& modules, StringList& sub if(state != InSubmodules) { - cerr << _name << ": invalid format in `" << initPath << "'" << endl; - return false; + ostringstream os; + os << "invalid format in `" << initPath << "'" << endl; + throw os.str(); } } - - return true; } -bool +void PackageVisitor::writeInit(const string& dir, const StringList& modules, const StringList& submodules) { string initPath = dir + "/__init__.py"; @@ -350,8 +333,11 @@ PackageVisitor::writeInit(const string& dir, const StringList& modules, const St ofstream os(initPath.c_str()); if(!os) { - return false; + ostringstream os; + os << "cannot open file `" << initPath << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); } + FileTracker::instance()->addFile(initPath); StringList::const_iterator p; @@ -369,8 +355,6 @@ PackageVisitor::writeInit(const string& dir, const StringList& modules, const St { os << "import " << *p << endl; } - - return true; } void @@ -490,6 +474,7 @@ main(int argc, char* argv[]) IceUtil::CtrlCHandler ctrlCHandler; ctrlCHandler.setCallback(interruptedCallback); + for(i = args.begin(); i != args.end(); ++i) { Preprocessor icecpp(argv[0], *i, cppArgs); @@ -551,34 +536,52 @@ main(int argc, char* argv[]) file = output + '/' + file; } - IceUtilInternal::Output out; - out.open(file.c_str()); - if(!out) + try + { + IceUtilInternal::Output out; + out.open(file.c_str()); + if(!out) + { + ostringstream os; + os << "cannot open`" << file << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); + } + FileTracker::instance()->addFile(file); + + printHeader(out); + out << "\n# Generated from file `" << base << ".ice'\n"; + + // + // Generate the Python mapping. + // + generate(u, all, checksum, includePaths, out); + + out.close(); + + // + // Create or update the Python package hierarchy. + // + if(!noPackage) + { + PackageVisitor visitor(prefix + base + "_ice", output); + u->visit(&visitor, false); + } + } + catch(const Slice::FileException& ex) { - cerr << argv[0] << ": can't open `" << file << "' for writing" << endl; + // If a file could not be created, then cleanup any + // created files. + FileTracker::instance()->cleanup(); u->destroy(); + cerr << argv[0] << ": " << ex.reason() << endl; return EXIT_FAILURE; } - - printHeader(out); - out << "\n# Generated from file `" << base << ".ice'\n"; - - // - // Generate the Python mapping. - // - generate(u, all, checksum, includePaths, out); - - out.close(); - - // - // Create or update the Python package hierarchy. - // - if(!noPackage) + catch(const string& err) { - PackageVisitor visitor(argv[0], prefix + base + "_ice", output); - u->visit(&visitor, false); + FileTracker::instance()->cleanup(); + cerr << argv[0] << ": " << err << endl; + status = EXIT_FAILURE; } - } u->destroy(); @@ -589,6 +592,7 @@ main(int argc, char* argv[]) if(_interrupted) { + FileTracker::instance()->cleanup(); return EXIT_FAILURE; } } diff --git a/cpp/src/slice2rb/Main.cpp b/cpp/src/slice2rb/Main.cpp index 0d6856a2123..092c16f8a35 100644 --- a/cpp/src/slice2rb/Main.cpp +++ b/cpp/src/slice2rb/Main.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -207,24 +208,37 @@ main(int argc, char* argv[]) file = output + '/' + file; } - IceUtilInternal::Output out; - out.open(file.c_str()); - if(!out) + try { - cerr << argv[0] << ": can't open `" << file << "' for writing" << endl; + IceUtilInternal::Output out; + out.open(file.c_str()); + if(!out) + { + ostringstream os; + os << "cannot open`" << file << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); + } + FileTracker::instance()->addFile(file); + + printHeader(out); + out << "\n# Generated from file `" << base << ".ice'\n"; + + // + // Generate the Ruby mapping. + // + generate(u, all, checksum, includePaths, out); + + out.close(); + } + catch(const Slice::FileException& ex) + { + // If a file could not be created, then cleanup + // any created files. + FileTracker::instance()->cleanup(); u->destroy(); + cerr << argv[0] << ": " << ex.reason() << endl; return EXIT_FAILURE; } - - printHeader(out); - out << "\n# Generated from file `" << base << ".ice'\n"; - - // - // Generate the Ruby mapping. - // - generate(u, all, checksum, includePaths, out); - - out.close(); } u->destroy(); @@ -235,6 +249,7 @@ main(int argc, char* argv[]) if(_interrupted) { + FileTracker::instance()->cleanup(); return EXIT_FAILURE; } } -- cgit v1.2.3 From f8a2a5c47bcc31192d618de6833e9663c9feb5ac Mon Sep 17 00:00:00 2001 From: Matthew Newhook Date: Wed, 14 Jan 2009 09:59:23 -0330 Subject: http://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=3517 ; translator stdout/stderr. --- CHANGES | 2 ++ cpp/src/Slice/CsUtil.cpp | 8 ++++---- cpp/src/Slice/JavaUtil.cpp | 12 ++++++------ cpp/src/Slice/Parser.cpp | 14 +++++++------- cpp/src/Slice/PythonUtil.cpp | 6 +++--- cpp/src/slice2cpp/Gen.cpp | 8 ++++---- cpp/src/slice2cpp/Main.cpp | 2 +- cpp/src/slice2cs/Main.cpp | 2 +- cpp/src/slice2docbook/Main.cpp | 2 +- cpp/src/slice2freeze/Main.cpp | 2 +- cpp/src/slice2freezej/Main.cpp | 2 +- cpp/src/slice2html/Main.cpp | 2 +- cpp/src/slice2java/Main.cpp | 2 +- cpp/src/slice2py/Main.cpp | 2 +- cpp/src/slice2rb/Main.cpp | 2 +- 15 files changed, 35 insertions(+), 33 deletions(-) (limited to 'cpp/src/slice2cpp/Main.cpp') diff --git a/CHANGES b/CHANGES index 4b2dc57d40a..3d06162dab6 100644 --- a/CHANGES +++ b/CHANGES @@ -35,6 +35,8 @@ General Changes print an error message if the retry failed and if Ice.RetryIntervals was configured with non-zero time intervals. +- All error output from the slice compilers now goes to stderr. + C++ Changes =========== diff --git a/cpp/src/Slice/CsUtil.cpp b/cpp/src/Slice/CsUtil.cpp index a5d5c78a7e4..ae8c6e667cc 100644 --- a/cpp/src/Slice/CsUtil.cpp +++ b/cpp/src/Slice/CsUtil.cpp @@ -1528,7 +1528,7 @@ Slice::CsGenerator::MetaDataVisitor::visitModuleStart(const ModulePtr& p) static const string attributePrefix = "cs:attribute:"; if(s.find(attributePrefix) != 0 || s.size() == attributePrefix.size()) { - cout << file << ": warning: ignoring invalid global metadata `" << s << "'" << endl; + cerr << file << ": warning: ignoring invalid global metadata `" << s << "'" << endl; } } _history.insert(s); @@ -1595,7 +1595,7 @@ Slice::CsGenerator::MetaDataVisitor::visitOperation(const OperationPtr& p) ClassDefPtr cl = ClassDefPtr::dynamicCast(p->container()); if(!cl->isLocal()) { - cout << p->definitionContext()->filename() << ":" << p->line() + cerr << p->definitionContext()->filename() << ":" << p->line() << ": warning: metdata directive `UserException' applies only to local operations " << "but enclosing " << (cl->isInterface() ? "interface" : "class") << "`" << cl->name() << "' is not local" << endl; @@ -1720,7 +1720,7 @@ Slice::CsGenerator::MetaDataVisitor::validate(const ContainedPtr& cont) } } } - cout << file << ":" << cont->line() << ": warning: " << msg << " `" << s << "'" << endl; + cerr << file << ":" << cont->line() << ": warning: " << msg << " `" << s << "'" << endl; } _history.insert(s); } @@ -1734,7 +1734,7 @@ Slice::CsGenerator::MetaDataVisitor::validate(const ContainedPtr& cont) { continue; } - cout << file << ":" << cont->line() << ": warning: " << msg << " `" << s << "'" << endl; + cerr << file << ":" << cont->line() << ": warning: " << msg << " `" << s << "'" << endl; } _history.insert(s); } diff --git a/cpp/src/Slice/JavaUtil.cpp b/cpp/src/Slice/JavaUtil.cpp index 7c73227bc55..b67f36055a4 100644 --- a/cpp/src/Slice/JavaUtil.cpp +++ b/cpp/src/Slice/JavaUtil.cpp @@ -3426,7 +3426,7 @@ Slice::JavaGenerator::MetaDataVisitor::visitModuleStart(const ModulePtr& p) if(!ok) { - cout << file << ": warning: ignoring invalid global metadata `" << s << "'" << endl; + cerr << file << ": warning: ignoring invalid global metadata `" << s << "'" << endl; } } _history.insert(s); @@ -3482,7 +3482,7 @@ Slice::JavaGenerator::MetaDataVisitor::visitOperation(const OperationPtr& p) ClassDefPtr cl = ClassDefPtr::dynamicCast(p->container()); if(!cl->isLocal()) { - cout << p->definitionContext()->filename() << ":" << p->line() + cerr << p->definitionContext()->filename() << ":" << p->line() << ": warning: metadata directive `UserException' applies only to local operations " << "but enclosing " << (cl->isInterface() ? "interface" : "class") << "`" << cl->name() << "' is not local" << endl; @@ -3498,7 +3498,7 @@ Slice::JavaGenerator::MetaDataVisitor::visitOperation(const OperationPtr& p) { if(q->find("java:type:", 0) == 0) { - cout << p->definitionContext()->filename() << ":" << p->line() + cerr << p->definitionContext()->filename() << ":" << p->line() << ": warning: invalid metadata for operation" << endl; break; } @@ -3597,7 +3597,7 @@ Slice::JavaGenerator::MetaDataVisitor::getMetaData(const ContainedPtr& cont) continue; } - cout << file << ":" << cont->line() << ": warning: ignoring invalid metadata `" << s << "'" << endl; + cerr << file << ":" << cont->line() << ": warning: ignoring invalid metadata `" << s << "'" << endl; } _history.insert(s); @@ -3630,7 +3630,7 @@ Slice::JavaGenerator::MetaDataVisitor::validateType(const SyntaxTreeBasePtr& p, assert(b); str = b->typeId(); } - cout << file << ":" << line << ": warning: invalid metadata for " << str << endl; + cerr << file << ":" << line << ": warning: invalid metadata for " << str << endl; } } } @@ -3660,7 +3660,7 @@ Slice::JavaGenerator::MetaDataVisitor::validateGetSet(const SyntaxTreeBasePtr& p assert(b); str = b->typeId(); } - cout << file << ":" << line << ": warning: invalid metadata for " << str << endl; + cerr << file << ":" << line << ": warning: invalid metadata for " << str << endl; } } } diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp index 866a580373a..5d682503ec3 100644 --- a/cpp/src/Slice/Parser.cpp +++ b/cpp/src/Slice/Parser.cpp @@ -4714,7 +4714,7 @@ Slice::Operation::attributes() const } if(i == 2) { - cout << definitionContext()->filename() << ":" << line() + cerr << definitionContext()->filename() << ":" << line() << ": warning: invalid freeze metadata for operation" << endl; } else @@ -4736,7 +4736,7 @@ Slice::Operation::attributes() const { if(result != 0 && (i == int(Supports) || i == int(Never))) { - cout << definitionContext()->filename() << ":" << line() + cerr << definitionContext()->filename() << ":" << line() << ": warning: invalid freeze metadata for operation" << endl; } else @@ -4751,7 +4751,7 @@ Slice::Operation::attributes() const if(i == 4) { - cout << definitionContext()->filename() << ":" << line() + cerr << definitionContext()->filename() << ":" << line() << ": warning: invalid freeze metadata for operation" << endl; // @@ -5170,9 +5170,9 @@ Slice::Unit::error(const char* s) string file = currentFile(); if(!file.empty()) { - cout << file << ':' << _currentLine << ": "; + cerr << file << ':' << _currentLine << ": "; } - cout << s << endl; + cerr << s << endl; _errors++; } @@ -5188,9 +5188,9 @@ Slice::Unit::warning(const char* s) const string file = currentFile(); if(!file.empty()) { - cout << file << ':' << _currentLine << ": "; + cerr << file << ':' << _currentLine << ": "; } - cout << "warning: " << s << endl; + cerr << "warning: " << s << endl; } void diff --git a/cpp/src/Slice/PythonUtil.cpp b/cpp/src/Slice/PythonUtil.cpp index 648b7af94df..cb9e024717a 100644 --- a/cpp/src/Slice/PythonUtil.cpp +++ b/cpp/src/Slice/PythonUtil.cpp @@ -2035,7 +2035,7 @@ Slice::Python::MetaDataVisitor::validateGlobal(const DefinitionContextPtr& dc) static const string packagePrefix = "python:package:"; if(s.find(packagePrefix) != 0 || s.size() == packagePrefix.size()) { - cout << dc->filename() << ": warning: ignoring invalid global metadata `" << s << "'" << endl; + cerr << dc->filename() << ": warning: ignoring invalid global metadata `" << s << "'" << endl; } } _history.insert(s); @@ -2067,7 +2067,7 @@ Slice::Python::MetaDataVisitor::validateSequence(const DefinitionContextPtr& dc, } } } - cout << dc->filename() << ":" << line << ": warning: ignoring metadata `" << s << "'" << endl; + cerr << dc->filename() << ":" << line << ": warning: ignoring metadata `" << s << "'" << endl; } } } @@ -2085,7 +2085,7 @@ Slice::Python::MetaDataVisitor::reject(const ContainedPtr& cont) { DefinitionContextPtr dc = cont->definitionContext(); assert(dc); - cout << dc->filename() << ":" << cont->line() << ": warning: ignoring metadata `" << *p << "'" << endl; + cerr << dc->filename() << ":" << cont->line() << ": warning: ignoring metadata `" << *p << "'" << endl; } } } diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index c593e3dcd21..0c1731b684f 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -5651,7 +5651,7 @@ Slice::Gen::MetaDataVisitor::visitModuleStart(const ModulePtr& p) { continue; } - cout << file << ": warning: ignoring invalid global metadata `" << s << "'" << endl; + cerr << file << ": warning: ignoring invalid global metadata `" << s << "'" << endl; } _history.insert(s); } @@ -5722,7 +5722,7 @@ Slice::Gen::MetaDataVisitor::visitOperation(const OperationPtr& p) { if(!cl->isLocal()) { - cout << p->definitionContext()->filename() << ":" << p->line() + cerr << p->definitionContext()->filename() << ":" << p->line() << ": warning: metadata directive `UserException' applies only to local operations " << "but enclosing " << (cl->isInterface() ? "interface" : "class") << "`" << cl->name() << "' is not local" << endl; @@ -5741,7 +5741,7 @@ Slice::Gen::MetaDataVisitor::visitOperation(const OperationPtr& p) { if(q->find("cpp:type:", 0) == 0 || q->find("cpp:array", 0) == 0 || q->find("cpp:range", 0) == 0) { - cout << p->definitionContext()->filename() << ":" << p->line() + cerr << p->definitionContext()->filename() << ":" << p->line() << ": warning: invalid metadata for operation" << endl; break; } @@ -5834,7 +5834,7 @@ Slice::Gen::MetaDataVisitor::validate(const SyntaxTreeBasePtr& cont, const Strin continue; } - cout << file << ":" << line << ": warning: ignoring invalid metadata `" << s << "'" << endl; + cerr << file << ":" << line << ": warning: ignoring invalid metadata `" << s << "'" << endl; } _history.insert(s); } diff --git a/cpp/src/slice2cpp/Main.cpp b/cpp/src/slice2cpp/Main.cpp index 4ca202872c7..7e2ff8b58b1 100644 --- a/cpp/src/slice2cpp/Main.cpp +++ b/cpp/src/slice2cpp/Main.cpp @@ -101,7 +101,7 @@ main(int argc, char* argv[]) if(opts.isSet("version")) { - cout << ICE_STRING_VERSION << endl; + cerr << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; } diff --git a/cpp/src/slice2cs/Main.cpp b/cpp/src/slice2cs/Main.cpp index abdc24c23db..595dfe75dc9 100644 --- a/cpp/src/slice2cs/Main.cpp +++ b/cpp/src/slice2cs/Main.cpp @@ -95,7 +95,7 @@ main(int argc, char* argv[]) if(opts.isSet("version")) { - cout << ICE_STRING_VERSION << endl; + cerr << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; } diff --git a/cpp/src/slice2docbook/Main.cpp b/cpp/src/slice2docbook/Main.cpp index 25bd52137ac..b5616743174 100644 --- a/cpp/src/slice2docbook/Main.cpp +++ b/cpp/src/slice2docbook/Main.cpp @@ -92,7 +92,7 @@ main(int argc, char* argv[]) if(opts.isSet("version")) { - cout << ICE_STRING_VERSION << endl; + cerr << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; } diff --git a/cpp/src/slice2freeze/Main.cpp b/cpp/src/slice2freeze/Main.cpp index 84f98ac7c27..cbffb460a3f 100644 --- a/cpp/src/slice2freeze/Main.cpp +++ b/cpp/src/slice2freeze/Main.cpp @@ -1523,7 +1523,7 @@ main(int argc, char* argv[]) if(opts.isSet("version")) { - cout << ICE_STRING_VERSION << endl; + cerr << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; } diff --git a/cpp/src/slice2freezej/Main.cpp b/cpp/src/slice2freezej/Main.cpp index 2b89feb5cfc..2ab8c36f86f 100644 --- a/cpp/src/slice2freezej/Main.cpp +++ b/cpp/src/slice2freezej/Main.cpp @@ -1183,7 +1183,7 @@ main(int argc, char* argv[]) if(opts.isSet("version")) { - cout << ICE_STRING_VERSION << endl; + cerr << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; } diff --git a/cpp/src/slice2html/Main.cpp b/cpp/src/slice2html/Main.cpp index 068287ed632..dad5663fdba 100644 --- a/cpp/src/slice2html/Main.cpp +++ b/cpp/src/slice2html/Main.cpp @@ -101,7 +101,7 @@ main(int argc, char* argv[]) if(opts.isSet("version")) { - cout << ICE_STRING_VERSION << endl; + cerr << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; } diff --git a/cpp/src/slice2java/Main.cpp b/cpp/src/slice2java/Main.cpp index bc555d403bb..7439180b8f2 100644 --- a/cpp/src/slice2java/Main.cpp +++ b/cpp/src/slice2java/Main.cpp @@ -101,7 +101,7 @@ main(int argc, char* argv[]) if(opts.isSet("version")) { - cout << ICE_STRING_VERSION << endl; + cerr << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; } diff --git a/cpp/src/slice2py/Main.cpp b/cpp/src/slice2py/Main.cpp index 4b522bf9a98..7343ea9f812 100644 --- a/cpp/src/slice2py/Main.cpp +++ b/cpp/src/slice2py/Main.cpp @@ -420,7 +420,7 @@ main(int argc, char* argv[]) if(opts.isSet("version")) { - cout << ICE_STRING_VERSION << endl; + cerr << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; } diff --git a/cpp/src/slice2rb/Main.cpp b/cpp/src/slice2rb/Main.cpp index 092c16f8a35..d5f21dc3037 100644 --- a/cpp/src/slice2rb/Main.cpp +++ b/cpp/src/slice2rb/Main.cpp @@ -102,7 +102,7 @@ main(int argc, char* argv[]) if(opts.isSet("version")) { - cout << ICE_STRING_VERSION << endl; + cerr << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; } -- cgit v1.2.3 From 55f6e6863b8f17312e8ff58d05d6d035c822187b Mon Sep 17 00:00:00 2001 From: Jose Date: Tue, 27 Jan 2009 19:28:59 +0100 Subject: Squashed commit of the following: commit 9aa67a8862e402cb52276282b26a40422fae4adb Author: Jose Gutierrez Date: Tue Jan 27 19:25:22 2009 +0100 Fixed 3374 --header-ext not work as intended. --- cpp/include/Slice/Preprocessor.h | 3 +- cpp/src/Freeze/PingObject.ice | 2 + cpp/src/IceGrid/Internal.ice | 2 + cpp/src/IceStorm/Election.ice | 2 + cpp/src/IceStorm/IceStormInternal.ice | 2 + cpp/src/IceStorm/LinkRecord.ice | 2 + cpp/src/IceStorm/SubscriberRecord.ice | 2 + cpp/src/IceStorm/V31Format.ice | 2 + cpp/src/IceStorm/V32Format.ice | 2 + cpp/src/Slice/Preprocessor.cpp | 7 +- cpp/src/slice2cpp/Gen.cpp | 132 +++++++++++++++++++++++++------- cpp/src/slice2cpp/Gen.h | 16 ++++ cpp/src/slice2cpp/Main.cpp | 4 +- slice/Freeze/BackgroundSaveEvictor.ice | 2 + slice/Freeze/CatalogData.ice | 2 + slice/Freeze/Connection.ice | 2 + slice/Freeze/ConnectionF.ice | 2 + slice/Freeze/DB.ice | 2 + slice/Freeze/Evictor.ice | 2 + slice/Freeze/EvictorF.ice | 2 + slice/Freeze/EvictorStorage.ice | 2 + slice/Freeze/Exception.ice | 2 + slice/Freeze/Transaction.ice | 2 + slice/Freeze/TransactionalEvictor.ice | 2 + slice/Glacier2/PermissionsVerifier.ice | 2 + slice/Glacier2/PermissionsVerifierF.ice | 2 + slice/Glacier2/Router.ice | 2 + slice/Glacier2/RouterF.ice | 2 + slice/Glacier2/SSLInfo.ice | 2 + slice/Glacier2/Session.ice | 2 + slice/Glacier2/SessionF.ice | 2 + slice/Ice/BuiltinSequences.ice | 2 + slice/Ice/Communicator.ice | 2 + slice/Ice/CommunicatorF.ice | 2 + slice/Ice/Connection.ice | 2 + slice/Ice/ConnectionF.ice | 2 + slice/Ice/Current.ice | 2 + slice/Ice/Endpoint.ice | 2 + slice/Ice/FacetMap.ice | 2 + slice/Ice/Identity.ice | 2 + slice/Ice/ImplicitContext.ice | 2 + slice/Ice/ImplicitContextF.ice | 2 + slice/Ice/LocalException.ice | 2 + slice/Ice/Locator.ice | 2 + slice/Ice/LocatorF.ice | 2 + slice/Ice/Logger.ice | 2 + slice/Ice/LoggerF.ice | 2 + slice/Ice/ObjectAdapter.ice | 2 + slice/Ice/ObjectAdapterF.ice | 2 + slice/Ice/ObjectFactory.ice | 2 + slice/Ice/ObjectFactoryF.ice | 6 +- slice/Ice/Plugin.ice | 2 + slice/Ice/PluginF.ice | 2 + slice/Ice/Process.ice | 2 + slice/Ice/ProcessF.ice | 2 + slice/Ice/Properties.ice | 2 + slice/Ice/PropertiesF.ice | 2 + slice/Ice/Router.ice | 2 + slice/Ice/RouterF.ice | 2 + slice/Ice/ServantLocator.ice | 2 + slice/Ice/ServantLocatorF.ice | 2 + slice/Ice/SliceChecksumDict.ice | 2 + slice/Ice/Stats.ice | 2 + slice/Ice/StatsF.ice | 2 + slice/IceBox/IceBox.ice | 2 + slice/IceGrid/Admin.ice | 2 + slice/IceGrid/Descriptor.ice | 2 + slice/IceGrid/Exception.ice | 2 + slice/IceGrid/FileParser.ice | 2 + slice/IceGrid/Locator.ice | 2 + slice/IceGrid/Observer.ice | 2 + slice/IceGrid/Query.ice | 2 + slice/IceGrid/Registry.ice | 2 + slice/IceGrid/Session.ice | 2 + slice/IceGrid/UserAccountMapper.ice | 2 + slice/IcePatch2/FileInfo.ice | 2 + slice/IcePatch2/FileServer.ice | 2 + slice/IceStorm/IceStorm.ice | 2 + 78 files changed, 276 insertions(+), 36 deletions(-) (limited to 'cpp/src/slice2cpp/Main.cpp') diff --git a/cpp/include/Slice/Preprocessor.h b/cpp/include/Slice/Preprocessor.h index 98a018fbfbe..54535e28812 100644 --- a/cpp/include/Slice/Preprocessor.h +++ b/cpp/include/Slice/Preprocessor.h @@ -32,7 +32,7 @@ class SLICE_API Preprocessor { public: - Preprocessor(const std::string&, const std::string&, const std::vector&); + Preprocessor(const std::string&, const std::string&, const std::vector&, const std::string& = "cpp"); ~Preprocessor(); FILE* preprocess(bool); @@ -54,6 +54,7 @@ private: const std::string _path; const std::string _fileName; const std::vector _args; + const std::string _cppSourceExt; #ifdef _WIN32 std::wstring _cppFile; #else diff --git a/cpp/src/Freeze/PingObject.ice b/cpp/src/Freeze/PingObject.ice index 9ef1772eb57..ac0262e47d5 100644 --- a/cpp/src/Freeze/PingObject.ice +++ b/cpp/src/Freeze/PingObject.ice @@ -10,6 +10,8 @@ #ifndef FREEZE_PING_OBJECT_ICE #define FREEZE_PING_OBJECT_ICE +[["cpp:header-ext:h"]] + module Freeze { diff --git a/cpp/src/IceGrid/Internal.ice b/cpp/src/IceGrid/Internal.ice index 63d2bfb8f12..a1e510d8c38 100644 --- a/cpp/src/IceGrid/Internal.ice +++ b/cpp/src/IceGrid/Internal.ice @@ -10,6 +10,8 @@ #ifndef ICE_GRID_INTERNAL_ICE #define ICE_GRID_INTERNAL_ICE +[["cpp:header-ext:h"]] + #include #include #include diff --git a/cpp/src/IceStorm/Election.ice b/cpp/src/IceStorm/Election.ice index 2ba02e1035c..2a2fde7f0e9 100644 --- a/cpp/src/IceStorm/Election.ice +++ b/cpp/src/IceStorm/Election.ice @@ -10,6 +10,8 @@ #ifndef ELECTION_ICE #define ELECTION_ICE +[["cpp:header-ext:h"]] + #include #include #include diff --git a/cpp/src/IceStorm/IceStormInternal.ice b/cpp/src/IceStorm/IceStormInternal.ice index 744a5339eab..476dde4c346 100644 --- a/cpp/src/IceStorm/IceStormInternal.ice +++ b/cpp/src/IceStorm/IceStormInternal.ice @@ -10,6 +10,8 @@ #ifndef ICE_STORM_INTERNAL_ICE #define ICE_STORM_INTERNAL_ICE +[["cpp:header-ext:h"]] + #include #include #include diff --git a/cpp/src/IceStorm/LinkRecord.ice b/cpp/src/IceStorm/LinkRecord.ice index 6d30eb428c7..744755fedef 100644 --- a/cpp/src/IceStorm/LinkRecord.ice +++ b/cpp/src/IceStorm/LinkRecord.ice @@ -10,6 +10,8 @@ #ifndef LINK_RECORD_ICE #define LINK_RECORD_ICE +[["cpp:header-ext:h"]] + #include #include diff --git a/cpp/src/IceStorm/SubscriberRecord.ice b/cpp/src/IceStorm/SubscriberRecord.ice index 6a8c4133189..2c37010150d 100644 --- a/cpp/src/IceStorm/SubscriberRecord.ice +++ b/cpp/src/IceStorm/SubscriberRecord.ice @@ -10,6 +10,8 @@ #ifndef SUBSCRIBER_RECORD_ICE #define SUBSCRIBER_RECORD_ICE +[["cpp:header-ext:h"]] + #include #include diff --git a/cpp/src/IceStorm/V31Format.ice b/cpp/src/IceStorm/V31Format.ice index ca45b0a7f0c..9607990a156 100644 --- a/cpp/src/IceStorm/V31Format.ice +++ b/cpp/src/IceStorm/V31Format.ice @@ -10,6 +10,8 @@ #ifndef V31_FORMAT_ICE #define V31_FORMAT_ICE +[["cpp:header-ext:h"]] + #include module IceStorm diff --git a/cpp/src/IceStorm/V32Format.ice b/cpp/src/IceStorm/V32Format.ice index 248de06da41..860120756a2 100644 --- a/cpp/src/IceStorm/V32Format.ice +++ b/cpp/src/IceStorm/V32Format.ice @@ -10,6 +10,8 @@ #ifndef V32_FORMAT_ICE #define V32_FORMAT_ICE +[["cpp:header-ext:h"]] + #include module IceStorm diff --git a/cpp/src/Slice/Preprocessor.cpp b/cpp/src/Slice/Preprocessor.cpp index 6c226c2db72..636c772b94d 100644 --- a/cpp/src/Slice/Preprocessor.cpp +++ b/cpp/src/Slice/Preprocessor.cpp @@ -44,10 +44,11 @@ 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& args) : +Slice::Preprocessor::Preprocessor(const string& path, const string& fileName, const vector& args, const string& cppSourceExt) : _path(path), _fileName(fileName), _args(args), + _cppSourceExt(cppSourceExt), _cppHandle(0) { } @@ -390,12 +391,12 @@ Slice::Preprocessor::printMakefileDependencies(Language lang, const vector #include #include +#include #include #include -#include +#include + +#include //TODO using namespace std; using namespace Slice; @@ -44,11 +47,13 @@ Slice::Gen::Gen(const string& base, const string& headerExtension, const string& bool imp, bool checksum, bool stream, bool ice) : _base(base), _headerExtension(headerExtension), + _implHeaderExtension(headerExtension), _sourceExtension(sourceExtension), _extraHeaders(extraHeaders), _include(include), _includePaths(includePaths), _dllExport(dllExport), + _dir(dir), _impl(imp), _checksum(checksum), _stream(stream), @@ -64,15 +69,41 @@ Slice::Gen::Gen(const string& base, const string& headerExtension, const string& { _base.erase(0, pos + 1); } +} + +Slice::Gen::~Gen() +{ + H << "\n\n#endif\n"; + C << '\n'; + + if(_impl) + { + implH << "\n\n#endif\n"; + implC << '\n'; + } +} + +void +Slice::Gen::generate(const UnitPtr& p) +{ + + // + // Check the header-ext global meta data if is not empty we override _headerExtension + // + string headerExtension = getHeaderExt(p->modules()); + if(!headerExtension.empty()) + { + _headerExtension = headerExtension; + } if(_impl) { - string fileImplH = _base + "I." + _headerExtension; + string fileImplH = _base + "I." + _implHeaderExtension; string fileImplC = _base + "I." + _sourceExtension; - if(!dir.empty()) + if(!_dir.empty()) { - fileImplH = dir + '/' + fileImplH; - fileImplC = dir + '/' + fileImplC; + fileImplH = _dir + '/' + fileImplH; + fileImplC = _dir + '/' + fileImplC; } struct stat st; @@ -120,10 +151,10 @@ Slice::Gen::Gen(const string& base, const string& headerExtension, const string& string fileH = _base + "." + _headerExtension; string fileC = _base + "." + _sourceExtension; - if(!dir.empty()) + if(!_dir.empty()) { - fileH = dir + '/' + fileH; - fileC = dir + '/' + fileC; + fileH = _dir + '/' + fileH; + fileC = _dir + '/' + fileC; } H.open(fileH.c_str()); @@ -158,23 +189,7 @@ Slice::Gen::Gen(const string& base, const string& headerExtension, const string& H << "\n#ifndef __" << s << "__"; H << "\n#define __" << s << "__"; H << '\n'; -} - -Slice::Gen::~Gen() -{ - H << "\n\n#endif\n"; - C << '\n'; - - if(_impl) - { - implH << "\n\n#endif\n"; - implC << '\n'; - } -} -void -Slice::Gen::generate(const UnitPtr& p) -{ validateMetaData(p); writeExtraHeaders(C); @@ -193,6 +208,7 @@ Slice::Gen::generate(const UnitPtr& p) } C << _base << "." << _headerExtension << ">"; + H << "\n#include "; H << "\n#include "; H << "\n#include "; @@ -224,6 +240,7 @@ Slice::Gen::generate(const UnitPtr& p) } else if(p->hasNonLocalClassDecls()) { + H << "\n#include "; } @@ -274,7 +291,12 @@ Slice::Gen::generate(const UnitPtr& p) for(StringList::const_iterator q = includes.begin(); q != includes.end(); ++q) { - H << "\n#include <" << changeInclude(*q, _includePaths) << "." << _headerExtension << ">"; + string extension = getHeaderExt((*q), p->modules()); + if(extension.empty()) + { + extension = _headerExtension; + } + H << "\n#include <" << changeInclude(*q, _includePaths) << "." << extension << ">"; } H << "\n#include "; @@ -339,7 +361,7 @@ Slice::Gen::generate(const UnitPtr& p) { implH << _include << '/'; } - implH << _base << ".h>"; + implH << _base << "." << _headerExtension << ">"; writeExtraHeaders(implC); @@ -348,7 +370,7 @@ Slice::Gen::generate(const UnitPtr& p) { implC << _include << '/'; } - implC << _base << "I.h>"; + implC << _base << "I." << _implHeaderExtension << ">"; ImplVisitor implVisitor(implH, implC, _dllExport); p->visit(&implVisitor, false); @@ -5641,6 +5663,8 @@ Slice::Gen::MetaDataVisitor::visitModuleStart(const ModulePtr& p) StringList globalMetaData = dc->getMetaData(); string file = dc->filename(); static const string prefix = "cpp:"; + + int headerExtension = 0; for(StringList::const_iterator q = globalMetaData.begin(); q != globalMetaData.end(); ++q) { string s = *q; @@ -5653,7 +5677,15 @@ Slice::Gen::MetaDataVisitor::visitModuleStart(const ModulePtr& p) { continue; } - cerr << file << ": warning: ignoring invalid global metadata `" << s << "'" << endl; + else if(ss.find("header-ext:") == 0) + { + headerExtension++; + if(headerExtension == 1) + { + continue; + } + } + cerr << file << ": warning: ignoring invalid global metadata `" << s << "', the cpp:header-ext global metadata can only appear once per file." << endl; } _history.insert(s); } @@ -5866,3 +5898,47 @@ Slice::Gen::resetUseWstring(list& hist) hist.pop_back(); return use; } + +string +Slice::Gen::getHeaderExt(const string& file, const ModuleList& modules) +{ + string ext = ""; + if(!modules.empty()) // Just in case the Slice file has no definitions + { + for(ModuleList::const_iterator i = modules.begin(); i != modules.end(); ++i) + { + if((*i)->definitionContext()->filename() == file) + { + string meta = (*i)->definitionContext()->findMetaData("cpp:header-ext"); + string::size_type index = meta.find_last_of(":"); + if(index != string::npos && index + 1 < meta.size()) + { + ext = meta.substr(index + 1, meta.size() - index - 1); + } + } + } + } + return ext; +} + +string +Slice::Gen::getHeaderExt(const ModuleList& modules) +{ + string ext = ""; + if(!modules.empty()) // Just in case the Slice file has no definitions + { + for(ModuleList::const_iterator i = modules.begin(); i != modules.end(); ++i) + { + if((*i)->definitionContext()->includeLevel() == 0) + { + string meta = (*i)->definitionContext()->findMetaData("cpp:header-ext"); + string::size_type index = meta.find_last_of(":"); + if(index != string::npos && index + 1 < meta.size()) + { + ext = meta.substr(index + 1, meta.size() - index - 1); + } + } + } + } + return ext; +} diff --git a/cpp/src/slice2cpp/Gen.h b/cpp/src/slice2cpp/Gen.h index e3c1c9afc01..9cb699a205c 100644 --- a/cpp/src/slice2cpp/Gen.h +++ b/cpp/src/slice2cpp/Gen.h @@ -44,6 +44,20 @@ private: void writeExtraHeaders(::IceUtilInternal::Output&); + + // + // Get the header extension defined in the global metadata for a given file + // if there isn't defined returns a empty string + // + std::string getHeaderExt(const std::string& file, const ModuleList& modules); + + // + // Get the header extension defined in the global metadata for the current + // compiling file. + // if there isn't defined returns a empty string + // + std::string getHeaderExt(const ModuleList& modules); + ::IceUtilInternal::Output H; ::IceUtilInternal::Output C; @@ -52,11 +66,13 @@ private: std::string _base; std::string _headerExtension; + std::string _implHeaderExtension; std::string _sourceExtension; std::vector _extraHeaders; std::string _include; std::vector _includePaths; std::string _dllExport; + std::string _dir; bool _impl; bool _checksum; bool _stream; diff --git a/cpp/src/slice2cpp/Main.cpp b/cpp/src/slice2cpp/Main.cpp index 7e2ff8b58b1..86eafe9e64f 100644 --- a/cpp/src/slice2cpp/Main.cpp +++ b/cpp/src/slice2cpp/Main.cpp @@ -169,7 +169,7 @@ main(int argc, char* argv[]) { if(depend) { - Preprocessor icecpp(argv[0], *i, cppArgs); + Preprocessor icecpp(argv[0], *i, cppArgs, sourceExtension); if(!icecpp.printMakefileDependencies(Preprocessor::CPlusPlus, includePaths)) { return EXIT_FAILURE; @@ -177,7 +177,7 @@ main(int argc, char* argv[]) } else { - Preprocessor icecpp(argv[0], *i, cppArgs); + Preprocessor icecpp(argv[0], *i, cppArgs, sourceExtension); FILE* cppHandle = icecpp.preprocess(false); if(cppHandle == 0) diff --git a/slice/Freeze/BackgroundSaveEvictor.ice b/slice/Freeze/BackgroundSaveEvictor.ice index 381c0c6ce55..5dbdd4206a2 100644 --- a/slice/Freeze/BackgroundSaveEvictor.ice +++ b/slice/Freeze/BackgroundSaveEvictor.ice @@ -10,6 +10,8 @@ #ifndef FREEZE_BACKGROUND_SAVE_EVICTOR_ICE #define FREEZE_BACKGROUND_SAVE_EVICTOR_ICE +[["cpp:header-ext:h"]] + #include module Freeze diff --git a/slice/Freeze/CatalogData.ice b/slice/Freeze/CatalogData.ice index 8df77614183..ad4d9dbe53e 100644 --- a/slice/Freeze/CatalogData.ice +++ b/slice/Freeze/CatalogData.ice @@ -10,6 +10,8 @@ #ifndef FREEZE_CATALOG_DATA_ICE #define FREEZE_CATALOG_DATA_ICE +[["cpp:header-ext:h"]] + module Freeze { diff --git a/slice/Freeze/Connection.ice b/slice/Freeze/Connection.ice index 4fe590a50d7..834eff9c53c 100644 --- a/slice/Freeze/Connection.ice +++ b/slice/Freeze/Connection.ice @@ -13,6 +13,8 @@ #include #include +[["cpp:header-ext:h"]] + module Freeze { diff --git a/slice/Freeze/ConnectionF.ice b/slice/Freeze/ConnectionF.ice index 9a9b1e52ed0..b4d393b7049 100644 --- a/slice/Freeze/ConnectionF.ice +++ b/slice/Freeze/ConnectionF.ice @@ -10,6 +10,8 @@ #ifndef FREEZE_CONNECTION_F_ICE #define FREEZE_CONNECTION_F_ICE +[["cpp:header-ext:h"]] + module Freeze { diff --git a/slice/Freeze/DB.ice b/slice/Freeze/DB.ice index cd7d617ed56..a12feb001aa 100644 --- a/slice/Freeze/DB.ice +++ b/slice/Freeze/DB.ice @@ -10,6 +10,8 @@ #ifndef FREEZE_DB_ICE #define FREEZE_DB_ICE +[["cpp:header-ext:h"]] + /** * * Freeze provides automatic persistence for Ice servants. diff --git a/slice/Freeze/Evictor.ice b/slice/Freeze/Evictor.ice index 2022e795772..0f0979e6a9b 100644 --- a/slice/Freeze/Evictor.ice +++ b/slice/Freeze/Evictor.ice @@ -10,6 +10,8 @@ #ifndef FREEZE_EVICTOR_ICE #define FREEZE_EVICTOR_ICE +[["cpp:header-ext:h"]] + #include #include #include diff --git a/slice/Freeze/EvictorF.ice b/slice/Freeze/EvictorF.ice index a93f4d73c3c..8daa0b536fd 100644 --- a/slice/Freeze/EvictorF.ice +++ b/slice/Freeze/EvictorF.ice @@ -10,6 +10,8 @@ #ifndef FREEZE_EVICTOR_F_ICE #define FREEZE_EVICTOR_F_ICE +[["cpp:header-ext:h"]] + module Freeze { diff --git a/slice/Freeze/EvictorStorage.ice b/slice/Freeze/EvictorStorage.ice index cb4f27e0953..4a2304edc90 100644 --- a/slice/Freeze/EvictorStorage.ice +++ b/slice/Freeze/EvictorStorage.ice @@ -10,6 +10,8 @@ #ifndef FREEZE_EVICTOR_STORAGE_ICE #define FREEZE_EVICTOR_STORAGE_ICE +[["cpp:header-ext:h"]] + #include module Freeze diff --git a/slice/Freeze/Exception.ice b/slice/Freeze/Exception.ice index 53d9456cd37..31919486793 100644 --- a/slice/Freeze/Exception.ice +++ b/slice/Freeze/Exception.ice @@ -10,6 +10,8 @@ #ifndef FREEZE_EXCEPTION_ICE #define FREEZE_EXCEPTION_ICE +[["cpp:header-ext:h"]] + module Freeze { diff --git a/slice/Freeze/Transaction.ice b/slice/Freeze/Transaction.ice index 34eac416b5d..ab8179ec3ae 100644 --- a/slice/Freeze/Transaction.ice +++ b/slice/Freeze/Transaction.ice @@ -10,6 +10,8 @@ #ifndef FREEZE_TRANSACTION_ICE #define FREEZE_TRANSACTION_ICE +[["cpp:header-ext:h"]] + module Freeze { diff --git a/slice/Freeze/TransactionalEvictor.ice b/slice/Freeze/TransactionalEvictor.ice index dfdf7fd45ea..9acab43a232 100644 --- a/slice/Freeze/TransactionalEvictor.ice +++ b/slice/Freeze/TransactionalEvictor.ice @@ -10,6 +10,8 @@ #ifndef FREEZE_TRANSACTIONAL_EVICTOR_ICE #define FREEZE_TRANSACTIONAL_EVICTOR_ICE +[["cpp:header-ext:h"]] + #include module Freeze diff --git a/slice/Glacier2/PermissionsVerifier.ice b/slice/Glacier2/PermissionsVerifier.ice index 733d5b56f79..07cdda5a663 100644 --- a/slice/Glacier2/PermissionsVerifier.ice +++ b/slice/Glacier2/PermissionsVerifier.ice @@ -10,6 +10,8 @@ #ifndef GLACIER2_PERMISSIONS_VERIFIER_ICE #define GLACIER2_PERMISSIONS_VERIFIER_ICE +[["cpp:header-ext:h"]] + #include module Glacier2 diff --git a/slice/Glacier2/PermissionsVerifierF.ice b/slice/Glacier2/PermissionsVerifierF.ice index 1f20eb76b85..5620c94be55 100644 --- a/slice/Glacier2/PermissionsVerifierF.ice +++ b/slice/Glacier2/PermissionsVerifierF.ice @@ -10,6 +10,8 @@ #ifndef GLACIER2_PERMISSIONS_VERIFIER_F_ICE #define GLACIER2_PERMISSIONS_VERIFIER_F_ICE +[["cpp:header-ext:h"]] + module Glacier2 { diff --git a/slice/Glacier2/Router.ice b/slice/Glacier2/Router.ice index 2bc9a3ac317..cc8c090f1f4 100644 --- a/slice/Glacier2/Router.ice +++ b/slice/Glacier2/Router.ice @@ -10,6 +10,8 @@ #ifndef GLACIER2_ROUTER_ICE #define GLACIER2_ROUTER_ICE +[["cpp:header-ext:h"]] + #include #include diff --git a/slice/Glacier2/RouterF.ice b/slice/Glacier2/RouterF.ice index 70664f44801..ec420e71f63 100644 --- a/slice/Glacier2/RouterF.ice +++ b/slice/Glacier2/RouterF.ice @@ -10,6 +10,8 @@ #ifndef GLACIER2_ROUTER_F_ICE #define GLACIER2_ROUTER_F_ICE +[["cpp:header-ext:h"]] + module Glacier2 { diff --git a/slice/Glacier2/SSLInfo.ice b/slice/Glacier2/SSLInfo.ice index d1ae83b1433..94132ecf01b 100644 --- a/slice/Glacier2/SSLInfo.ice +++ b/slice/Glacier2/SSLInfo.ice @@ -10,6 +10,8 @@ #ifndef GLACIER2_SSL_INFO_ICE #define GLACIER2_SSL_INFO_ICE +[["cpp:header-ext:h"]] + #include module Glacier2 diff --git a/slice/Glacier2/Session.ice b/slice/Glacier2/Session.ice index ea687194350..02596804fc1 100644 --- a/slice/Glacier2/Session.ice +++ b/slice/Glacier2/Session.ice @@ -10,6 +10,8 @@ #ifndef GLACIER2_SESSION_ICE #define GLACIER2_SESSION_ICE +[["cpp:header-ext:h"]] + #include #include #include diff --git a/slice/Glacier2/SessionF.ice b/slice/Glacier2/SessionF.ice index 74a4faa5309..08386afc758 100644 --- a/slice/Glacier2/SessionF.ice +++ b/slice/Glacier2/SessionF.ice @@ -10,6 +10,8 @@ #ifndef GLACIER2_SESSION_F_ICE #define GLACIER2_SESSION_F_ICE +[["cpp:header-ext:h"]] + module Glacier2 { diff --git a/slice/Ice/BuiltinSequences.ice b/slice/Ice/BuiltinSequences.ice index 87e26022fce..306e6314a37 100644 --- a/slice/Ice/BuiltinSequences.ice +++ b/slice/Ice/BuiltinSequences.ice @@ -10,6 +10,8 @@ #ifndef ICE_BUILTIN_SEQUENCES_ICE #define ICE_BUILTIN_SEQUENCES_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/Communicator.ice b/slice/Ice/Communicator.ice index 4d464677612..aaffff1b0f3 100644 --- a/slice/Ice/Communicator.ice +++ b/slice/Ice/Communicator.ice @@ -10,6 +10,8 @@ #ifndef ICE_COMMUNICATOR_ICE #define ICE_COMMUNICATOR_ICE +[["cpp:header-ext:h"]] + #include #include #include diff --git a/slice/Ice/CommunicatorF.ice b/slice/Ice/CommunicatorF.ice index 2ea5062d412..ea8ae669fe9 100644 --- a/slice/Ice/CommunicatorF.ice +++ b/slice/Ice/CommunicatorF.ice @@ -10,6 +10,8 @@ #ifndef ICE_COMMUNICATOR_F_ICE #define ICE_COMMUNICATOR_F_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/Connection.ice b/slice/Ice/Connection.ice index 8603a697994..29d4c59562a 100644 --- a/slice/Ice/Connection.ice +++ b/slice/Ice/Connection.ice @@ -10,6 +10,8 @@ #ifndef ICE_CONNECTION_ICE #define ICE_CONNECTION_ICE +[["cpp:header-ext:h"]] + #include #include diff --git a/slice/Ice/ConnectionF.ice b/slice/Ice/ConnectionF.ice index f8602c60c90..b7c982d7537 100644 --- a/slice/Ice/ConnectionF.ice +++ b/slice/Ice/ConnectionF.ice @@ -10,6 +10,8 @@ #ifndef ICE_CONNECTION_F_ICE #define ICE_CONNECTION_F_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/Current.ice b/slice/Ice/Current.ice index a3af5456927..40d46264adf 100644 --- a/slice/Ice/Current.ice +++ b/slice/Ice/Current.ice @@ -10,6 +10,8 @@ #ifndef ICE_CURRENT_ICE #define ICE_CURRENT_ICE +[["cpp:header-ext:h"]] + #include #include #include diff --git a/slice/Ice/Endpoint.ice b/slice/Ice/Endpoint.ice index 84732f8b089..fafd424fc3b 100644 --- a/slice/Ice/Endpoint.ice +++ b/slice/Ice/Endpoint.ice @@ -10,6 +10,8 @@ #ifndef ICE_ENDPOINT_ICE #define ICE_ENDPOINT_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/FacetMap.ice b/slice/Ice/FacetMap.ice index 09aefe146f0..6299bf8e5f6 100644 --- a/slice/Ice/FacetMap.ice +++ b/slice/Ice/FacetMap.ice @@ -10,6 +10,8 @@ #ifndef ICE_FACET_MAP_ICE #define ICE_FACET_MAP_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/Identity.ice b/slice/Ice/Identity.ice index 736759de678..649fdcad838 100644 --- a/slice/Ice/Identity.ice +++ b/slice/Ice/Identity.ice @@ -10,6 +10,8 @@ #ifndef ICE_IDENTITY_ICE #define ICE_IDENTITY_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/ImplicitContext.ice b/slice/Ice/ImplicitContext.ice index 2b26687aa33..40c53d54257 100644 --- a/slice/Ice/ImplicitContext.ice +++ b/slice/Ice/ImplicitContext.ice @@ -10,6 +10,8 @@ #ifndef ICE_IMPLICIT_CONTEXT_ICE #define ICE_IMPLICIT_CONTEXT_ICE +[["cpp:header-ext:h"]] + #include #include diff --git a/slice/Ice/ImplicitContextF.ice b/slice/Ice/ImplicitContextF.ice index 4e4a552d522..8d91544e96f 100644 --- a/slice/Ice/ImplicitContextF.ice +++ b/slice/Ice/ImplicitContextF.ice @@ -10,6 +10,8 @@ #ifndef ICE_IMPLICIT_CONTEXT_F_ICE #define ICE_IMPLICIT_CONTEXT_F_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/LocalException.ice b/slice/Ice/LocalException.ice index b4cd5cba645..24923d87509 100644 --- a/slice/Ice/LocalException.ice +++ b/slice/Ice/LocalException.ice @@ -10,6 +10,8 @@ #ifndef ICE_LOCAL_EXCEPTION_ICE #define ICE_LOCAL_EXCEPTION_ICE +[["cpp:header-ext:h"]] + #include #include diff --git a/slice/Ice/Locator.ice b/slice/Ice/Locator.ice index 8b5c74ea437..3b5325b90f4 100644 --- a/slice/Ice/Locator.ice +++ b/slice/Ice/Locator.ice @@ -10,6 +10,8 @@ #ifndef ICE_LOCATOR_ICE #define ICE_LOCATOR_ICE +[["cpp:header-ext:h"]] + #include #include diff --git a/slice/Ice/LocatorF.ice b/slice/Ice/LocatorF.ice index 2490e4a31e7..401b6f5040c 100644 --- a/slice/Ice/LocatorF.ice +++ b/slice/Ice/LocatorF.ice @@ -10,6 +10,8 @@ #ifndef ICE_LOCATOR_F_ICE #define ICE_LOCATOR_F_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/Logger.ice b/slice/Ice/Logger.ice index 42d4bcf2407..3baa235b7dd 100644 --- a/slice/Ice/Logger.ice +++ b/slice/Ice/Logger.ice @@ -10,6 +10,8 @@ #ifndef ICE_LOGGER_ICE #define ICE_LOGGER_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/LoggerF.ice b/slice/Ice/LoggerF.ice index a162f3eecbc..567670b6bfb 100644 --- a/slice/Ice/LoggerF.ice +++ b/slice/Ice/LoggerF.ice @@ -10,6 +10,8 @@ #ifndef ICE_LOGGER_F_ICE #define ICE_LOGGER_F_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/ObjectAdapter.ice b/slice/Ice/ObjectAdapter.ice index 264aa046784..c1d48a151e2 100644 --- a/slice/Ice/ObjectAdapter.ice +++ b/slice/Ice/ObjectAdapter.ice @@ -10,6 +10,8 @@ #ifndef ICE_OBJECT_ADAPTER_ICE #define ICE_OBJECT_ADAPTER_ICE +[["cpp:header-ext:h"]] + #include #include #include diff --git a/slice/Ice/ObjectAdapterF.ice b/slice/Ice/ObjectAdapterF.ice index 47413a198d6..c124ba8f7fb 100644 --- a/slice/Ice/ObjectAdapterF.ice +++ b/slice/Ice/ObjectAdapterF.ice @@ -10,6 +10,8 @@ #ifndef ICE_OBJECT_ADAPTER_F_ICE #define ICE_OBJECT_ADAPTER_F_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/ObjectFactory.ice b/slice/Ice/ObjectFactory.ice index 06593a58c24..8e97300c874 100644 --- a/slice/Ice/ObjectFactory.ice +++ b/slice/Ice/ObjectFactory.ice @@ -10,6 +10,8 @@ #ifndef ICE_OBJECT_FACTORY_ICE #define ICE_OBJECT_FACTORY_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/ObjectFactoryF.ice b/slice/Ice/ObjectFactoryF.ice index 9b8f7fad0c5..fff74448aa0 100644 --- a/slice/Ice/ObjectFactoryF.ice +++ b/slice/Ice/ObjectFactoryF.ice @@ -7,8 +7,10 @@ // // ********************************************************************** -#ifndef ICE_SERVANT_FACTORY_F_ICE -#define ICE_SERVANT_FACTORY_F_ICE +#ifndef ICE_OBJECT_FACTORY_F_ICE +#define ICE_OBJECT_FACTORY_F_ICE + +[["cpp:header-ext:h"]] module Ice { diff --git a/slice/Ice/Plugin.ice b/slice/Ice/Plugin.ice index a872ed658aa..0d6e1515e9c 100644 --- a/slice/Ice/Plugin.ice +++ b/slice/Ice/Plugin.ice @@ -10,6 +10,8 @@ #ifndef ICE_PLUGIN_ICE #define ICE_PLUGIN_ICE +[["cpp:header-ext:h"]] + #include module Ice diff --git a/slice/Ice/PluginF.ice b/slice/Ice/PluginF.ice index 04aca2b7616..b30f0636adf 100644 --- a/slice/Ice/PluginF.ice +++ b/slice/Ice/PluginF.ice @@ -10,6 +10,8 @@ #ifndef ICE_PLUGIN_F_ICE #define ICE_PLUGIN_F_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/Process.ice b/slice/Ice/Process.ice index 162e13d3958..1662775c1e3 100644 --- a/slice/Ice/Process.ice +++ b/slice/Ice/Process.ice @@ -10,6 +10,8 @@ #ifndef ICE_PROCESS_ICE #define ICE_PROCESS_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/ProcessF.ice b/slice/Ice/ProcessF.ice index 86951dc6fee..c9cb8d2297d 100644 --- a/slice/Ice/ProcessF.ice +++ b/slice/Ice/ProcessF.ice @@ -10,6 +10,8 @@ #ifndef ICE_PROCESS_F_ICE #define ICE_PROCESS_F_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/Properties.ice b/slice/Ice/Properties.ice index c391403c711..f193c00caab 100644 --- a/slice/Ice/Properties.ice +++ b/slice/Ice/Properties.ice @@ -10,6 +10,8 @@ #ifndef ICE_PROPERTIES_ICE #define ICE_PROPERTIES_ICE +[["cpp:header-ext:h"]] + #include module Ice diff --git a/slice/Ice/PropertiesF.ice b/slice/Ice/PropertiesF.ice index cd93484aedb..8da07da5117 100644 --- a/slice/Ice/PropertiesF.ice +++ b/slice/Ice/PropertiesF.ice @@ -10,6 +10,8 @@ #ifndef ICE_PROPERTIES_F_ICE #define ICE_PROPERTIES_F_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/Router.ice b/slice/Ice/Router.ice index 70b90801c31..385e353fc41 100644 --- a/slice/Ice/Router.ice +++ b/slice/Ice/Router.ice @@ -10,6 +10,8 @@ #ifndef ICE_ROUTER_ICE #define ICE_ROUTER_ICE +[["cpp:header-ext:h"]] + #include module Ice diff --git a/slice/Ice/RouterF.ice b/slice/Ice/RouterF.ice index 0bf87bd732b..47093b80825 100644 --- a/slice/Ice/RouterF.ice +++ b/slice/Ice/RouterF.ice @@ -10,6 +10,8 @@ #ifndef ICE_ROUTER_F_ICE #define ICE_ROUTER_F_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/ServantLocator.ice b/slice/Ice/ServantLocator.ice index 310c9c90ba5..504ea58e411 100644 --- a/slice/Ice/ServantLocator.ice +++ b/slice/Ice/ServantLocator.ice @@ -10,6 +10,8 @@ #ifndef ICE_SERVANT_LOCATOR_ICE #define ICE_SERVANT_LOCATOR_ICE +[["cpp:header-ext:h"]] + #include #include diff --git a/slice/Ice/ServantLocatorF.ice b/slice/Ice/ServantLocatorF.ice index 458eff0d057..20e6398f4b0 100644 --- a/slice/Ice/ServantLocatorF.ice +++ b/slice/Ice/ServantLocatorF.ice @@ -10,6 +10,8 @@ #ifndef ICE_SERVANT_LOCATOR_F_ICE #define ICE_SERVANT_LOCATOR_F_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/SliceChecksumDict.ice b/slice/Ice/SliceChecksumDict.ice index 464081c54ea..87d2da1cd69 100644 --- a/slice/Ice/SliceChecksumDict.ice +++ b/slice/Ice/SliceChecksumDict.ice @@ -10,6 +10,8 @@ #ifndef ICE_SLICE_CHECKSUM_DICT_ICE #define ICE_SLICE_CHECKSUM_DICT_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/Stats.ice b/slice/Ice/Stats.ice index c6f57fb9ed6..45a58d25b31 100644 --- a/slice/Ice/Stats.ice +++ b/slice/Ice/Stats.ice @@ -10,6 +10,8 @@ #ifndef ICE_STATS_ICE #define ICE_STATS_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/StatsF.ice b/slice/Ice/StatsF.ice index 004858ab54c..540edd45712 100644 --- a/slice/Ice/StatsF.ice +++ b/slice/Ice/StatsF.ice @@ -10,6 +10,8 @@ #ifndef ICE_STATS_F_ICE #define ICE_STATS_F_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/IceBox/IceBox.ice b/slice/IceBox/IceBox.ice index b9c0c0cb118..e599a4323ef 100644 --- a/slice/IceBox/IceBox.ice +++ b/slice/IceBox/IceBox.ice @@ -10,6 +10,8 @@ #ifndef ICE_BOX_ICE_BOX_ICE #define ICE_BOX_ICE_BOX_ICE +[["cpp:header-ext:h"]] + #include #include #include diff --git a/slice/IceGrid/Admin.ice b/slice/IceGrid/Admin.ice index 8660878aca6..212392a148e 100644 --- a/slice/IceGrid/Admin.ice +++ b/slice/IceGrid/Admin.ice @@ -10,6 +10,8 @@ #ifndef ICE_GRID_ADMIN_ICE #define ICE_GRID_ADMIN_ICE +[["cpp:header-ext:h"]] + #include #include #include diff --git a/slice/IceGrid/Descriptor.ice b/slice/IceGrid/Descriptor.ice index 3ac6dad3e41..2d1de16743b 100644 --- a/slice/IceGrid/Descriptor.ice +++ b/slice/IceGrid/Descriptor.ice @@ -10,6 +10,8 @@ #ifndef ICE_GRID_DESCRIPTOR_ICE #define ICE_GRID_DESCRIPTOR_ICE +[["cpp:header-ext:h"]] + #include #include diff --git a/slice/IceGrid/Exception.ice b/slice/IceGrid/Exception.ice index cbccce90ac0..0a2a692eb7e 100644 --- a/slice/IceGrid/Exception.ice +++ b/slice/IceGrid/Exception.ice @@ -10,6 +10,8 @@ #ifndef ICE_GRID_EXCEPTION_ICE #define ICE_GRID_EXCEPTION_ICE +[["cpp:header-ext:h"]] + #include #include diff --git a/slice/IceGrid/FileParser.ice b/slice/IceGrid/FileParser.ice index d99633e116a..7b27455eeaa 100644 --- a/slice/IceGrid/FileParser.ice +++ b/slice/IceGrid/FileParser.ice @@ -10,6 +10,8 @@ #ifndef ICE_GRID_FILE_PARSER_ICE #define ICE_GRID_FILE_PARSER_ICE +[["cpp:header-ext:h"]] + #include module IceGrid diff --git a/slice/IceGrid/Locator.ice b/slice/IceGrid/Locator.ice index a236b37b6a9..91877f6a8b2 100644 --- a/slice/IceGrid/Locator.ice +++ b/slice/IceGrid/Locator.ice @@ -10,6 +10,8 @@ #ifndef ICE_GRID_LOCATOR_ICE #define ICE_GRID_LOCATOR_ICE +[["cpp:header-ext:h"]] + #include module IceGrid diff --git a/slice/IceGrid/Observer.ice b/slice/IceGrid/Observer.ice index abbd069664e..8b89278c2da 100644 --- a/slice/IceGrid/Observer.ice +++ b/slice/IceGrid/Observer.ice @@ -10,6 +10,8 @@ #ifndef ICE_GRID_OBSERVER_ICE #define ICE_GRID_OBSERVER_ICE +[["cpp:header-ext:h"]] + #include #include #include diff --git a/slice/IceGrid/Query.ice b/slice/IceGrid/Query.ice index 2304e7edc77..4ea597e852c 100644 --- a/slice/IceGrid/Query.ice +++ b/slice/IceGrid/Query.ice @@ -10,6 +10,8 @@ #ifndef ICE_GRID_QUERY_ICE #define ICE_GRID_QUERY_ICE +[["cpp:header-ext:h"]] + #include #include diff --git a/slice/IceGrid/Registry.ice b/slice/IceGrid/Registry.ice index 5ef47fae173..6dd91bf6dae 100644 --- a/slice/IceGrid/Registry.ice +++ b/slice/IceGrid/Registry.ice @@ -10,6 +10,8 @@ #ifndef ICE_GRID_REGISTRY_ICE #define ICE_GRID_REGISTRY_ICE +[["cpp:header-ext:h"]] + #include #include #include diff --git a/slice/IceGrid/Session.ice b/slice/IceGrid/Session.ice index ffd00c9f570..d071fc7ca6a 100644 --- a/slice/IceGrid/Session.ice +++ b/slice/IceGrid/Session.ice @@ -10,6 +10,8 @@ #ifndef ICE_GRID_SESSION_ICE #define ICE_GRID_SESSION_ICE +[["cpp:header-ext:h"]] + #include #include diff --git a/slice/IceGrid/UserAccountMapper.ice b/slice/IceGrid/UserAccountMapper.ice index d145b08af50..4befb4da59b 100644 --- a/slice/IceGrid/UserAccountMapper.ice +++ b/slice/IceGrid/UserAccountMapper.ice @@ -10,6 +10,8 @@ #ifndef ICE_GRID_USERACCOUNTMAPPER_ICE #define ICE_GRID_USERACCOUNTMAPPER_ICE +[["cpp:header-ext:h"]] + module IceGrid { diff --git a/slice/IcePatch2/FileInfo.ice b/slice/IcePatch2/FileInfo.ice index 194d1034851..e85a784982b 100644 --- a/slice/IcePatch2/FileInfo.ice +++ b/slice/IcePatch2/FileInfo.ice @@ -10,6 +10,8 @@ #ifndef ICE_PATCH2_FILE_INFO_ICE #define ICE_PATCH2_FILE_INFO_ICE +[["cpp:header-ext:h"]] + #include module IcePatch2 diff --git a/slice/IcePatch2/FileServer.ice b/slice/IcePatch2/FileServer.ice index e18fb043bc4..7e1317c5de9 100644 --- a/slice/IcePatch2/FileServer.ice +++ b/slice/IcePatch2/FileServer.ice @@ -10,6 +10,8 @@ #ifndef ICE_PATCH2_FILE_SERVER_ICE #define ICE_PATCH2_FILE_SERVER_ICE +[["cpp:header-ext:h"]] + #include /** diff --git a/slice/IceStorm/IceStorm.ice b/slice/IceStorm/IceStorm.ice index 013ea0e6c23..8a0e96bd4dc 100644 --- a/slice/IceStorm/IceStorm.ice +++ b/slice/IceStorm/IceStorm.ice @@ -10,6 +10,8 @@ #ifndef ICE_STORM_ICE #define ICE_STORM_ICE +[["cpp:header-ext:h"]] + #include #include -- cgit v1.2.3