summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorMarc Laukien <marc@zeroc.com>2001-09-24 06:03:29 +0000
committerMarc Laukien <marc@zeroc.com>2001-09-24 06:03:29 +0000
commit651299177638bb4928c1ade683709f0f171f5e18 (patch)
tree6c283b41a55b7af8bb39c738ea5cceb046608763 /cpp/src
parentmany fixes (diff)
downloadice-651299177638bb4928c1ade683709f0f171f5e18.tar.bz2
ice-651299177638bb4928c1ade683709f0f171f5e18.tar.xz
ice-651299177638bb4928c1ade683709f0f171f5e18.zip
fixes
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Slice/Parser.cpp10
-rw-r--r--cpp/src/slice2docbook/Gen.cpp66
-rw-r--r--cpp/src/slice2docbook/Gen.h1
3 files changed, 58 insertions, 19 deletions
diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp
index a699ec2d73d..02340d845eb 100644
--- a/cpp/src/Slice/Parser.cpp
+++ b/cpp/src/Slice/Parser.cpp
@@ -554,8 +554,6 @@ Slice::Container::createNative(const string& name)
TypeList
Slice::Container::lookupType(const string& scoped, bool printError)
{
- assert(!scoped.empty());
-
static const char* builtinTable[] =
{
"byte",
@@ -588,9 +586,7 @@ Slice::Container::lookupType(const string& scoped, bool printError)
TypeList
Slice::Container::lookupTypeNoBuiltin(const string& scoped, bool printError)
{
- assert(!scoped.empty());
-
- if (scoped[0] == ':')
+ if (scoped.size() >= 2 && scoped[0] == ':')
{
return _unit->lookupTypeNoBuiltin(scoped.substr(2), printError);
}
@@ -644,9 +640,7 @@ Slice::Container::lookupTypeNoBuiltin(const string& scoped, bool printError)
ContainedList
Slice::Container::lookupContained(const string& scoped, bool printError)
{
- assert(!scoped.empty());
-
- if (scoped[0] == ':')
+ if (scoped.size() >= 2 && scoped[0] == ':')
{
return _unit->lookupContained(scoped.substr(2), printError);
}
diff --git a/cpp/src/slice2docbook/Gen.cpp b/cpp/src/slice2docbook/Gen.cpp
index aa870c786a5..c4ac8a2c987 100644
--- a/cpp/src/slice2docbook/Gen.cpp
+++ b/cpp/src/slice2docbook/Gen.cpp
@@ -683,6 +683,46 @@ Slice::Gen::printHeader()
O.restoreIndent();
}
+string
+Slice::Gen::getComment(const ContainedPtr& contained, const ContainerPtr& container, bool summary)
+{
+ string s = contained->comment();
+ string comment;
+ for (unsigned int i = 0; i < s.size(); ++i)
+ {
+ if (s[i] == '\\' && i + 1 < s.size() && s[i + 1] == '[')
+ {
+ comment += '[';
+ ++i;
+ }
+ else if (s[i] == '[')
+ {
+ ++i;
+ string literal;
+ while (s[i] != ']')
+ {
+ literal += s[i++];
+ if (i >= s.size())
+ {
+ break;
+ }
+ }
+ comment += toString(literal, container);
+ }
+ else if(summary && s[i] == '.' && (i + 1 >= s.size() || isspace(s[i + 1])))
+ {
+ comment += '.';
+ break;
+ }
+ else
+ {
+ comment += s[i];
+ }
+
+ }
+ return comment;
+}
+
StringList
Slice::Gen::getTagged(const string& tag, string& comment)
{
@@ -727,7 +767,7 @@ Slice::Gen::printComment(const ContainedPtr& p)
container = p->container();
}
- string comment = p->comment();
+ string comment = getComment(p, container, false);
StringList par = getTagged("param", comment);
StringList ret = getTagged("return", comment);
StringList throws = getTagged("throws", comment);
@@ -906,17 +946,17 @@ Slice::Gen::printComment(const ContainedPtr& p)
void
Slice::Gen::printSummary(const ContainedPtr& p)
{
- string comment = p->comment();
-
- start("para");
- string::size_type pos = comment.find('.');
- if (pos != string::npos)
+ ContainerPtr container = ContainerPtr::dynamicCast(p);
+ if (!container)
{
- comment.erase(pos + 1);
- O.zeroIndent();
- O << nl << comment;
- O.restoreIndent();
+ container = p->container();
}
+
+ string summary = getComment(p, container, true);
+ start("para");
+ O.zeroIndent();
+ O << nl << summary;
+ O.restoreIndent();
end();
}
@@ -1134,5 +1174,9 @@ Slice::Gen::toString(const string& str, const ContainerPtr& container)
return toString(contList.front(), container);
}
- return s;
+ //
+ // If we can't find the string, printing it as "literal" is the
+ // best we can do.
+ //
+ return "<literal>" + s + "</literal>";
}
diff --git a/cpp/src/slice2docbook/Gen.h b/cpp/src/slice2docbook/Gen.h
index 4f1be44be04..3bfdaaaac5d 100644
--- a/cpp/src/slice2docbook/Gen.h
+++ b/cpp/src/slice2docbook/Gen.h
@@ -40,6 +40,7 @@ public:
private:
void printHeader();
+ std::string getComment(const ContainedPtr&, const ContainerPtr&, bool);
StringList getTagged(const std::string&, std::string&);
void printComment(const ContainedPtr&);
void printSummary(const ContainedPtr&);