summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/slice2html/Gen.cpp148
-rw-r--r--cpp/src/slice2html/Gen.h10
-rw-r--r--cpp/src/slice2java/Gen.cpp96
-rw-r--r--cpp/src/slice2java/Gen.h1
4 files changed, 151 insertions, 104 deletions
diff --git a/cpp/src/slice2html/Gen.cpp b/cpp/src/slice2html/Gen.cpp
index de131945303..bfbb4985e59 100644
--- a/cpp/src/slice2html/Gen.cpp
+++ b/cpp/src/slice2html/Gen.cpp
@@ -13,6 +13,7 @@
#include <IceUtil/DisableWarnings.h>
#include <IceUtil/Functional.h>
+#include <IceUtil/StringUtil.h>
#include <Slice/FileTracker.h>
#include <Gen.h>
@@ -400,7 +401,7 @@ Slice::GeneratorBase::printComment(const ContainedPtr& p, const ContainerPtr& co
}
start("dt", "Symbol");
- _out << toString(term, container, false, forIndex);
+ _out << toString(toSliceID(term, container->definitionContext()->filename()), container, false, forIndex);
end();
start("dd");
_out << nl << item;
@@ -531,7 +532,7 @@ Slice::GeneratorBase::printComment(const ContainedPtr& p, const ContainerPtr& co
for(StringList::const_iterator q = see.begin(); q != see.end(); ++q)
{
start("dt", "Symbol");
- _out << toString(*q, container, false, forIndex);
+ _out << toString(toSliceID(*q, container->definitionContext()->filename()), container, false, forIndex);
end();
}
end();
@@ -1052,15 +1053,14 @@ string
Slice::GeneratorBase::toString(const string& str, const ContainerPtr& container, bool asTarget, bool forIndex,
size_t* summarySize)
{
- string s = str;
- TypeList types = container->lookupType(s, false);
+ TypeList types = container->lookupType(str, false);
if(!types.empty())
{
return toString(types.front(), container, asTarget, forIndex, summarySize);
}
- ContainedList contList = container->lookupContained(s, false);
+ ContainedList contList = container->lookupContained(str, false);
if(!contList.empty())
{
return toString(contList.front(), container, asTarget, forIndex, summarySize);
@@ -1070,7 +1070,7 @@ Slice::GeneratorBase::toString(const string& str, const ContainerPtr& container,
// If we can't find the string, printing it in typewriter
// font is the best we can do.
//
- return "<tt>" + s + "</tt>";
+ return "<tt>" + str + "</tt>";
}
string
@@ -1082,6 +1082,9 @@ Slice::GeneratorBase::getComment(const ContainedPtr& contained, const ContainerP
string comment;
for(unsigned int i = 0; i < s.size(); ++i)
{
+ //
+ // TODO: Remove old-style link processing once we no longer support the [ident] syntax for links.
+ //
if(s[i] == '\\' && i + 1 < s.size() && s[i + 1] == '[')
{
comment += '[';
@@ -1103,6 +1106,37 @@ Slice::GeneratorBase::getComment(const ContainedPtr& contained, const ContainerP
size_t sz = 0;
comment += toString(literal, container, false, forIndex, summary ? &sz : 0);
summarySize += sz;
+
+ //
+ // TODO: Remove this warning once we no longer support the old javadoc syntax.
+ //
+ string fileName = contained->file();
+ if(_warnOldCommentFiles.find(fileName) == _warnOldCommentFiles.end())
+ {
+ _warnOldCommentFiles.insert(fileName);
+ cerr << fileName << ": warning: file contains old-style javadoc link syntax: `[" << literal << "]'";
+ }
+ }
+ else if(s[i] == '{')
+ {
+ static const string atLink = "{@link";
+ string::size_type pos = s.find(atLink, i);
+ if(pos != i)
+ {
+ comment += '{';
+ ++summarySize;
+ continue;
+ }
+ string::size_type endpos = s.find('}', pos);
+ if(endpos == string::npos)
+ {
+ continue;
+ }
+ string literal = s.substr(pos + atLink.size(), endpos - pos - atLink.size());
+ size_t sz = 0;
+ comment += toString(toSliceID(literal, contained->file()), container, false, forIndex, summary ? &sz : 0);
+ summarySize += sz;
+ i = endpos;
}
else if(summary && s[i] == '.' && (i + 1 >= s.size() || isspace(static_cast<unsigned char>(s[i + 1]))))
{
@@ -1119,7 +1153,7 @@ Slice::GeneratorBase::getComment(const ContainedPtr& contained, const ContainerP
if(summary && _warnSummary && summarySize > _warnSummary)
{
- cerr << contained->file() << ": summary size (" << summarySize << ") exceeds " << _warnSummary
+ cerr << contained->file() << ": warning: summary size (" << summarySize << ") exceeds " << _warnSummary
<< " characters: `" << comment << "'" << endl;
}
@@ -1423,6 +1457,106 @@ Slice::GeneratorBase::getContainer(const SyntaxTreeBasePtr& p)
return result;
}
+//
+// TODO: remove warnOldStyleIdent() function once we no longer support
+// old-style javadoc comments ([...] instead of {@link ...} and
+// X::Y::Z instead of X.Y#Z).
+//
+//
+void
+Slice::GeneratorBase::warnOldStyleIdent(const string& str, const string& fileName)
+{
+ string newName;
+
+ string::size_type next = 0;
+ if(str.size() > 2 && str[0] == ':' && str[1] == ':')
+ {
+ next = 2;
+ }
+
+ int numIdents = 0;
+ string::size_type endpos;
+ while((endpos = str.find("::", next)) != string::npos)
+ {
+ if(numIdents != 0)
+ {
+ newName += ".";
+ }
+ newName += str.substr(next, endpos - next);
+ ++numIdents;
+ next = endpos;
+ if(next != string::npos)
+ {
+ next += 2;
+ }
+ }
+
+ if(numIdents != 0)
+ {
+ newName += ".";
+ }
+ newName += str.substr(next);
+
+ if(_warnOldCommentFiles.find(fileName) == _warnOldCommentFiles.end())
+ {
+ _warnOldCommentFiles.insert(fileName);
+
+ string::size_type pos;
+ pos = newName.rfind('.');
+ string alternateName;
+ string lastName;
+ if(pos != string::npos)
+ {
+ alternateName = newName;
+ alternateName[pos] = '#';
+ lastName = newName.substr(pos + 1);
+ }
+
+ cerr << fileName << ": warning: file contains old-style javadoc identifier syntax: `" << str << "'."
+ << " Use `'" << newName << "'";
+ if(!alternateName.empty())
+ {
+ cerr << " or `" << alternateName << "' if `" << lastName << "' is a member";
+ }
+ cerr << endl;
+ }
+}
+
+//
+// Convert a string of the form X.Y#Z into X::Y::Z (#Z converts to Z).
+// TODO: Remove the filename parameter once we no longer support old-style javadoc comments.
+//
+string
+Slice::GeneratorBase::toSliceID(const string& str, const string& filename)
+{
+
+ const string s = IceUtilInternal::trim(str);
+ string result;
+ string::size_type pos;
+ string::size_type next = 0;
+ while((pos = s.find_first_of(".#", next)) != string::npos)
+ {
+ result += s.substr(next, pos - next);
+ if(s[pos] != '#' || pos != 0)
+ {
+ result += "::";
+ }
+ next = ++pos;
+ }
+ result += s.substr(next);
+
+ //
+ // TODO: Remove the warning once we no longer support the old-style
+ // javadoc syntax.
+ //
+ if(str.find("::") != string::npos)
+ {
+ warnOldStyleIdent(s, filename);
+ }
+
+ return result;
+}
+
StringList
Slice::GeneratorBase::toStringList(const ContainedPtr& c)
{
diff --git a/cpp/src/slice2html/Gen.h b/cpp/src/slice2html/Gen.h
index cacdd581a4b..cf44c726e92 100644
--- a/cpp/src/slice2html/Gen.h
+++ b/cpp/src/slice2html/Gen.h
@@ -103,6 +103,16 @@ private:
static ::std::string _logoURL;
static ::std::string _searchAction;
static ContainedList _symbols;
+
+ //
+ // TODO:
+ // Members below exist to emit warnings for old-style javadoc comments (using [...] instead of {@link ...}),
+ // and to emit warnings for old-style scoped names (X::Y::Z instead of X.Y#Z).
+ // Once we remove support for the old style comments, we also need to remove these members.
+ //
+ ::std::set< ::std::string> _warnOldCommentFiles;
+ ::std::string toSliceID(const ::std::string&, const ::std::string&);
+ void warnOldStyleIdent(const ::std::string&, const ::std::string&);
};
class StartPageGenerator : private GeneratorBase
diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp
index 40eca501be7..212e2e6a2cd 100644
--- a/cpp/src/slice2java/Gen.cpp
+++ b/cpp/src/slice2java/Gen.cpp
@@ -1201,39 +1201,6 @@ Slice::JavaVisitor::writeDispatchAndMarshalling(Output& out, const ClassDefPtr&
}
-//
-// Turn scoped identifiers such as "::A::B" and "B::C::D"
-// into "A.B" and "B.C.D", respectively.
-//
-string
-Slice::JavaVisitor::convertScoped(const string& s)
-{
- //
- // Strip surrounding white space.
- //
- string result = IceUtilInternal::trim(s);
-
- //
- // Delete leading "::", if any.
- //
- if(result.size() > 1 && result[0] == ':' && result[1] == ':')
- {
- result = result.substr(2);
- }
-
- //
- // Replace "::" with "."
- //
- string::size_type pos = result.find("::");
- while(pos != string::npos)
- {
- result = result.replace(pos, 2, ".");
- pos = result.find("::", pos);
- }
-
- return result;
-}
-
StringList
Slice::JavaVisitor::splitComment(const ContainedPtr& p)
{
@@ -1253,69 +1220,6 @@ Slice::JavaVisitor::splitComment(const ContainedPtr& p)
result.push_back(lastLine);
}
- //
- // Rewrite @see sections to replace "::" with "."
- //
- const string seeTag = "@see";
- StringList::iterator i = result.begin();
- while(i != result.end())
- {
- string::size_type pos = i->find(seeTag);
- if(pos != string::npos)
- {
- *i = seeTag + " " + convertScoped(i->substr(pos + seeTag.size()));
- }
- ++i;
- }
-
- //
- // Strip square brackets from comments with hyperlinks such as [ObjectAdapter].
- //
- StringList::iterator j;
- for(j = result.begin(); j != result.end(); ++j)
- {
- pos = j->find('[', 0);
- while(pos != string::npos)
- {
- //
- // Don't erase escaped opening bracket: \[, erase
- // the backslash instead.
- //
- if(pos != 0 && (*j)[pos - 1] == '\\')
- {
- *j = j->erase(pos - 1, 1);
- pos = j->find('[', pos);
- continue;
- }
-
- *j = j->erase(pos, 1); // Erase [
- pos = j->find(']', pos);
- if(pos != string::npos)
- {
- *j = j->erase(pos, 1); // Erase ]
- pos = j->find('[', pos);
- }
- }
- }
-
- //
- // Strip HTML tags.
- //
- for(j = result.begin(); j != result.end(); ++j)
- {
- pos = j->find('<', 0);
- while(pos != string::npos)
- {
- nextPos = j->find('>', pos + 1);
- if(pos != string::npos)
- {
- *j = j->erase(pos, nextPos - pos + 1);
- pos = j->find('<', pos);
- }
- }
- }
-
-
return result;
}
diff --git a/cpp/src/slice2java/Gen.h b/cpp/src/slice2java/Gen.h
index 54369b0c0b7..cb02fbeeb7a 100644
--- a/cpp/src/slice2java/Gen.h
+++ b/cpp/src/slice2java/Gen.h
@@ -66,7 +66,6 @@ protected:
//
// Write doc comments.
//
- static std::string convertScoped(const std::string&);
static StringList splitComment(const ContainedPtr&);
static void writeDocComment(::IceUtilInternal::Output&, const ContainedPtr&,
const std::string&, const std::string& = "");