summaryrefslogtreecommitdiff
path: root/cpp/src/slice2html
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2009-01-23 17:07:21 -0500
committerBernard Normier <bernard@zeroc.com>2009-01-23 17:07:21 -0500
commit2380e089401d048490da23bc6d71e5687bafbe47 (patch)
tree6d97052d1f93bc2bafcd7fd1a9ebe103544b6cad /cpp/src/slice2html
parentFixed permissions (diff)
parent3.3.1 third-party updates (diff)
downloadice-2380e089401d048490da23bc6d71e5687bafbe47.tar.bz2
ice-2380e089401d048490da23bc6d71e5687bafbe47.tar.xz
ice-2380e089401d048490da23bc6d71e5687bafbe47.zip
Merge branch 'R3_3_branch' of cvs:/home/git/ice into R3_3_branch
Conflicts: java/resources/IceGridAdmin/icegridadmin_content_dyn.html java/resources/IceGridAdmin/icegridadmin_content_static.html
Diffstat (limited to 'cpp/src/slice2html')
-rw-r--r--cpp/src/slice2html/.depend4
-rw-r--r--cpp/src/slice2html/Gen.cpp155
-rw-r--r--cpp/src/slice2html/Gen.h8
-rw-r--r--cpp/src/slice2html/Main.cpp52
-rw-r--r--cpp/src/slice2html/Makefile2
-rw-r--r--cpp/src/slice2html/Makefile.mak2
-rw-r--r--cpp/src/slice2html/Slice2Html.rc10
7 files changed, 145 insertions, 88 deletions
diff --git a/cpp/src/slice2html/.depend b/cpp/src/slice2html/.depend
index 519a081f272..19c08cbf59a 100644
--- a/cpp/src/slice2html/.depend
+++ b/cpp/src/slice2html/.depend
@@ -1,2 +1,2 @@
-Gen$(OBJEXT): Gen.cpp $(includedir)/IceUtil/DisableWarnings.h $(includedir)/IceUtil/Functional.h $(includedir)/IceUtil/Handle.h $(includedir)/IceUtil/Exception.h $(includedir)/IceUtil/Config.h $(includedir)/Slice/SignalHandler.h ./Gen.h $(includedir)/Slice/Parser.h $(includedir)/IceUtil/Shared.h $(includedir)/IceUtil/OutputUtil.h
-Main$(OBJEXT): Main.cpp $(includedir)/IceUtil/Options.h $(includedir)/IceUtil/Config.h $(includedir)/IceUtil/RecMutex.h $(includedir)/IceUtil/Lock.h $(includedir)/IceUtil/ThreadException.h $(includedir)/IceUtil/Exception.h $(includedir)/IceUtil/Time.h $(includedir)/IceUtil/Shared.h $(includedir)/IceUtil/Handle.h $(includedir)/Slice/Preprocessor.h $(includedir)/Slice/SignalHandler.h ./Gen.h $(includedir)/Slice/Parser.h $(includedir)/IceUtil/OutputUtil.h
+Gen$(OBJEXT): Gen.cpp $(includedir)/IceUtil/DisableWarnings.h $(includedir)/IceUtil/Functional.h $(includedir)/IceUtil/Handle.h $(includedir)/IceUtil/Exception.h $(includedir)/IceUtil/Config.h ./Gen.h $(includedir)/Slice/Parser.h $(includedir)/IceUtil/Shared.h $(includedir)/IceUtil/OutputUtil.h
+Main$(OBJEXT): Main.cpp $(includedir)/IceUtil/Options.h $(includedir)/IceUtil/Config.h $(includedir)/IceUtil/RecMutex.h $(includedir)/IceUtil/Lock.h $(includedir)/IceUtil/ThreadException.h $(includedir)/IceUtil/Exception.h $(includedir)/IceUtil/Time.h $(includedir)/IceUtil/Shared.h $(includedir)/IceUtil/Handle.h $(includedir)/IceUtil/CtrlCHandler.h $(includedir)/Slice/Preprocessor.h ./Gen.h $(includedir)/Slice/Parser.h $(includedir)/IceUtil/OutputUtil.h
diff --git a/cpp/src/slice2html/Gen.cpp b/cpp/src/slice2html/Gen.cpp
index 49ae1cbd617..65149c2581c 100644
--- a/cpp/src/slice2html/Gen.cpp
+++ b/cpp/src/slice2html/Gen.cpp
@@ -1,15 +1,19 @@
// **********************************************************************
//
-// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.
+// 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.
//
// **********************************************************************
+#if defined(_MSC_VER) && _MSC_VER >= 1400
+# define _CRT_SECURE_NO_DEPRECATE 1 // C4996 '<C function>' was declared deprecated
+#endif
+
#include <IceUtil/DisableWarnings.h>
#include <IceUtil/Functional.h>
-#include <Slice/SignalHandler.h>
+#include <Slice/FileTracker.h>
#include <Gen.h>
#include <sys/types.h>
@@ -25,25 +29,13 @@
# include <iterator>
#endif
+#include <string.h>
+
using namespace std;
using namespace Slice;
using namespace IceUtil;
using namespace IceUtilInternal;
-//
-// Callback for Crtl-C signal handling
-//
-static GeneratorBase* _genBase = 0;
-
-static void closeCallback()
-{
- if(_genBase != 0)
- {
- _genBase->closeStream();
- }
-}
-
-
namespace Slice
{
@@ -52,8 +44,6 @@ generate(const UnitPtr& unit, const string& dir, const string& header, const str
const string& indexHeader, const string& indexFooter, const string& imageDir, const string& logoURL,
const string& searchAction, unsigned indexCount, unsigned warnSummary)
{
- SignalHandler::setCallback(closeCallback);
-
unit->mergeModules();
//
@@ -212,12 +202,10 @@ Slice::GeneratorBase::setSymbols(const ContainedList& symbols)
Slice::GeneratorBase::GeneratorBase(XMLOutput& o, const Files& files)
: _out(o), _files(files)
{
- _genBase = this;
}
Slice::GeneratorBase::~GeneratorBase()
{
- _genBase = 0;
}
//
@@ -250,7 +238,6 @@ Slice::GeneratorBase::openDoc(const string& file, const string& title, const str
{
_out << h2;
}
- _indexFooter = getFooter(footer);
_out.inc();
_out.inc();
}
@@ -291,11 +278,11 @@ Slice::GeneratorBase::openDoc(const ContainedPtr& c)
// Close an open HTML file after writing the footer.
//
void
-Slice::GeneratorBase::closeDoc()
+Slice::GeneratorBase::closeDoc(const string& footer)
{
_out.dec();
_out.dec();
- _out << nl << (!_indexFooter.empty() ? _indexFooter : _footer);
+ _out << nl << (!footer.empty() ? footer : _footer);
_out << nl;
}
@@ -738,23 +725,24 @@ Slice::GeneratorBase::printHeaderFooter(const ContainedPtr& c)
}
path += imageDir + "/";
- prevImage = "<img class=\"" + prevClass + "\" src=\"" + path + prevImage + "\" alt=\"Previous\"/>";
- nextImage = "<img class=\"" + nextClass + "\" src=\"" + path + nextImage + "\" alt=\"Next\"/>";
- upImage = "<img class=\"" + upClass + "\" src=\"" + path + upImage + "\" alt=\"Up\"/>";
- homeImage = "<img class=\"Button\" src=\"" + path + homeImage + "\" alt=\"Home\"/>";
- indexImage = "<img class=\"Button\" src=\"" + path + indexImage + "\" alt=\"Index\"/>";
+ prevImage = "<img class=\"" + prevClass + "\" src=\"" + path + prevImage + "\" alt=\"Previous\">";
+ nextImage = "<img class=\"" + nextClass + "\" src=\"" + path + nextImage + "\" alt=\"Next\">";
+ upImage = "<img class=\"" + upClass + "\" src=\"" + path + upImage + "\" alt=\"Up\">";
+ homeImage = "<img class=\"Button\" src=\"" + path + homeImage + "\" alt=\"Home\">";
+ indexImage = "<img class=\"Button\" src=\"" + path + indexImage + "\" alt=\"Index\">";
}
_out << nl << "<!-- SwishCommand noindex -->";
- start("div", "HeaderFooter");
-
- start("table", "ButtonTable");
+ start("table", "HeaderFooter");
start("tr");
+ start("td align=\"left\"");
+ start("table");
+ start("tr");
start("td");
_out << "<a href=\"" << homeLink << "\">" << homeImage << "</a>";
- end();
+ end(); // td
if(!imageDir.empty() || !isFirst)
{
@@ -805,16 +793,22 @@ Slice::GeneratorBase::printHeaderFooter(const ContainedPtr& c)
_out << "<a href=\"" << indexLink << "\">" << indexImage << "</a>";
end();
- end();
- end();
+ end(); // tr
+ end(); // table
+ end(); // td
+ start("td align=\"center\"");
printSearch();
+ end();
+ start("td align=\"right\"");
printLogo(c, container, onEnumPage);
+ end();
- _out << nl << "<!-- SwishCommand index -->";
+ end(); // tr
+ end(); // table
- end();
+ _out << nl << "<!-- SwishCommand index -->" << nl;
}
void
@@ -822,9 +816,7 @@ Slice::GeneratorBase::printSearch()
{
if(!_searchAction.empty())
{
- _out << nl << "<div style=\"text-align: center;\">";
- _out.inc();
- start("table", "SearchTable");
+ start("table");
start("tr");
start("td");
_out << nl << "<form method=\"get\" action=\"" << _searchAction << "\""
@@ -833,14 +825,12 @@ Slice::GeneratorBase::printSearch()
start("div");
_out << nl << "<input maxlength=\"100\" value=\"\" type=\"text\" name=\"query\">";
_out << nl << "<input type=\"submit\" value=\"Search\" name=\"submit\">";
- end();
_out.dec();
- _out << nl << "</form>";
end();
- end();
- end();
- _out.dec();
- _out << nl << "</div>";
+ _out << nl << "</form>";
+ end(); // td
+ end(); // tr
+ end(); // table
}
}
@@ -863,7 +853,7 @@ Slice::GeneratorBase::printLogo(const ContainedPtr& c, const ContainerPtr& conta
{
_out << "<a href=\"" + _logoURL + "\">";
}
- _out << "<img class=\"Logo\" src=\"" + path + "\" alt=\"Logo\"/>";
+ _out << "<img class=\"Logo\" src=\"" + path + "\" alt=\"Logo\">";
if(!_logoURL.empty())
{
_out << "</a>";
@@ -1114,7 +1104,7 @@ Slice::GeneratorBase::getComment(const ContainedPtr& contained, const ContainerP
comment += toString(literal, container, false, forIndex, summary ? &sz : 0);
summarySize += sz;
}
- else if(summary && s[i] == '.' && (i + 1 >= s.size() || isspace(s[i + 1])))
+ else if(summary && s[i] == '.' && (i + 1 >= s.size() || isspace(static_cast<unsigned char>(s[i + 1]))))
{
comment += '.';
++summarySize;
@@ -1258,14 +1248,14 @@ Slice::GeneratorBase::getLogoURL()
void
Slice::GeneratorBase::openStream(const string& path)
{
- SignalHandler::addFile(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
@@ -1466,18 +1456,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
@@ -1486,8 +1486,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;
@@ -1559,8 +1560,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;
@@ -1646,9 +1648,10 @@ Slice::StartPageGenerator::generate(const ModulePtr& m)
void
Slice::StartPageGenerator::printHeaderFooter()
{
- start("div", "HeaderFooter");
-
- start("table", "ButtonTable");
+ start("table", "HeaderFooter");
+ start("tr");
+ start("td align=\"left\"");
+ start("table");
start("tr");
start("td");
string imageDir = getImageDir();
@@ -1659,17 +1662,21 @@ Slice::StartPageGenerator::printHeaderFooter()
else
{
string src = imageDir + "/index.gif";
- _out << "<a href=\"_sindex.html\"><img class=\"Button\" src=\"" + src + "\" alt=\"Index Button\"/></a>";
+ _out << "<a href=\"_sindex.html\"><img class=\"Button\" src=\"" + src + "\" alt=\"Index Button\"></a>";
}
- end();
- end();
- end();
+ end(); // td
+ end(); // tr
+ end(); // table
+ end(); // td
+ start("td align=\"center\"");
printSearch();
+ end(); // td
if(!imageDir.empty())
{
- start("table", "LogoTable");
+ start("td align=\"right\"");
+ start("table");
start("tr");
start("td");
string logoURL = getLogoURL();
@@ -1677,17 +1684,19 @@ Slice::StartPageGenerator::printHeaderFooter()
{
_out << "<a href=\"" + logoURL + "\">";
}
- _out << "<img class=\"Logo\" src=\"" + imageDir + "/logo.gif\" alt=\"Logo\"/>";
+ _out << "<img class=\"Logo\" src=\"" + imageDir + "/logo.gif\" alt=\"Logo\">";
if(!logoURL.empty())
{
_out << "</a>";
}
- end();
- end();
- end();
+ end(); // td
+ end(); // tr
+ end(); // table
+ end(); // td
}
- end();
+ end(); // tr
+ end(); // table
}
Slice::FileVisitor::FileVisitor(Files& files)
@@ -1774,6 +1783,7 @@ Slice::StartPageVisitor::visitModuleStart(const ModulePtr& m)
TOCGenerator::TOCGenerator(const Files& files, const string& header, const string& footer)
: GeneratorBase(_out, files)
{
+ _footer = footer;
openDoc("_sindex.html", "Slice API Index", header, footer);
start("h1");
@@ -1820,7 +1830,8 @@ TOCGenerator::writeTOC()
_symbols.sort();
_symbols.unique();
- closeDoc();
+ string f = getFooter(_footer);
+ closeDoc(getFooter(_footer));
}
const ContainedList&
diff --git a/cpp/src/slice2html/Gen.h b/cpp/src/slice2html/Gen.h
index 3709c515495..776035b96bf 100644
--- a/cpp/src/slice2html/Gen.h
+++ b/cpp/src/slice2html/Gen.h
@@ -1,6 +1,6 @@
// **********************************************************************
//
-// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.
+// 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.
@@ -45,7 +45,7 @@ protected:
void openDoc(const ::std::string&, const std::string&, const std::string& = "", const std::string& = "");
void openDoc(const ContainedPtr&);
- void closeDoc();
+ void closeDoc(const std::string& = "");
void start(const ::std::string&, const ::std::string& = ::std::string());
void end();
@@ -70,6 +70,8 @@ protected:
static ::std::string getImageDir();
static ::std::string getLogoURL();
+ static ::std::string getFooter(const ::std::string&);
+
::IceUtilInternal::XMLOutput& _out;
static size_t _indexCount;
@@ -89,7 +91,6 @@ private:
static ::std::string readFile(const ::std::string&);
static void readFile(const ::std::string&, ::std::string&, ::std::string&);
static void getHeaders(const ::std::string&, ::std::string&, ::std::string&);
- static ::std::string getFooter(const ::std::string&);
::std::string _indexFooter;
const Files _files;
@@ -171,6 +172,7 @@ private:
void writeEntry(const ContainedPtr&);
+ ::std::string _footer;
ModuleList _modules;
ContainedList _symbols;
::IceUtilInternal::XMLOutput _out;
diff --git a/cpp/src/slice2html/Main.cpp b/cpp/src/slice2html/Main.cpp
index d7a3b1911bc..dad5663fdba 100644
--- a/cpp/src/slice2html/Main.cpp
+++ b/cpp/src/slice2html/Main.cpp
@@ -1,6 +1,6 @@
// **********************************************************************
//
-// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.
+// 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.
@@ -8,8 +8,10 @@
// **********************************************************************
#include <IceUtil/Options.h>
+#include <IceUtil/CtrlCHandler.h>
+#include <IceUtil/StaticMutex.h>
#include <Slice/Preprocessor.h>
-#include <Slice/SignalHandler.h>
+#include <Slice/FileTracker.h>
#include <Gen.h>
#include <stdlib.h>
@@ -17,6 +19,17 @@ using namespace std;
using namespace Slice;
using namespace IceUtil;
+static IceUtil::StaticMutex _mutex = ICE_STATIC_MUTEX_INITIALIZER;
+static bool _interrupted = false;
+
+void
+interruptedCallback(int signal)
+{
+ IceUtil::StaticMutex::Lock lock(_mutex);
+
+ _interrupted = true;
+}
+
void
usage(const char* n)
{
@@ -88,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;
}
@@ -173,7 +186,8 @@ main(int argc, char* argv[])
int status = EXIT_SUCCESS;
- SignalHandler sigHandler;
+ IceUtil::CtrlCHandler ctrlCHandler;
+ ctrlCHandler.setCallback(interruptedCallback);
for(vector<string>::size_type idx = 0; idx < args.size(); ++idx)
{
@@ -207,6 +221,15 @@ main(int argc, char* argv[])
p->destroy();
return EXIT_FAILURE;
}
+
+ {
+ IceUtil::StaticMutex::Lock lock(_mutex);
+
+ if(_interrupted)
+ {
+ return EXIT_FAILURE;
+ }
+ }
}
if(status == EXIT_SUCCESS && !preprocess)
@@ -216,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;
}
@@ -230,5 +264,15 @@ main(int argc, char* argv[])
p->destroy();
+ {
+ IceUtil::StaticMutex::Lock lock(_mutex);
+
+ if(_interrupted)
+ {
+ FileTracker::instance()->cleanup();
+ return EXIT_FAILURE;
+ }
+ }
+
return status;
}
diff --git a/cpp/src/slice2html/Makefile b/cpp/src/slice2html/Makefile
index 35a63746164..cb067765af3 100644
--- a/cpp/src/slice2html/Makefile
+++ b/cpp/src/slice2html/Makefile
@@ -1,6 +1,6 @@
# **********************************************************************
#
-# Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.
+# 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.
diff --git a/cpp/src/slice2html/Makefile.mak b/cpp/src/slice2html/Makefile.mak
index 9f1bd789fc1..4b5e9383392 100644
--- a/cpp/src/slice2html/Makefile.mak
+++ b/cpp/src/slice2html/Makefile.mak
@@ -1,6 +1,6 @@
# **********************************************************************
#
-# Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.
+# 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.
diff --git a/cpp/src/slice2html/Slice2Html.rc b/cpp/src/slice2html/Slice2Html.rc
index 3efd33351f4..bd2e770ce9b 100644
--- a/cpp/src/slice2html/Slice2Html.rc
+++ b/cpp/src/slice2html/Slice2Html.rc
@@ -1,8 +1,8 @@
#include "winver.h"
VS_VERSION_INFO VERSIONINFO
- FILEVERSION 3,3,0,0
- PRODUCTVERSION 3,3,0,0
+ FILEVERSION 3,3,1,0
+ PRODUCTVERSION 3,3,1,0
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
#ifdef _DEBUG
FILEFLAGS VS_FF_DEBUG
@@ -19,12 +19,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "ZeroC, Inc.\0"
VALUE "FileDescription", "Slice To HTML Translator\0"
- VALUE "FileVersion", "3.3.0\0"
+ VALUE "FileVersion", "3.3.1\0"
VALUE "InternalName", "slice2html\0"
- VALUE "LegalCopyright", "Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.\0"
+ VALUE "LegalCopyright", "Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.\0"
VALUE "OriginalFilename", "slice2html.exe\0"
VALUE "ProductName", "Ice\0"
- VALUE "ProductVersion", "3.3.0\0"
+ VALUE "ProductVersion", "3.3.1\0"
END
END
BLOCK "VarFileInfo"