Skip to content

Commit

Permalink
Renamed 'Comment' to 'DocComment' in the Slice compilers.
Browse files Browse the repository at this point in the history
  • Loading branch information
InsertCreativityHere committed Nov 20, 2024
1 parent c9999ae commit fad9c08
Show file tree
Hide file tree
Showing 16 changed files with 148 additions and 148 deletions.
56 changes: 28 additions & 28 deletions cpp/src/Slice/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,47 +303,47 @@ Slice::DefinitionContext::initSuppressedWarnings()
}

// ----------------------------------------------------------------------
// Comment
// DocComment
// ----------------------------------------------------------------------

bool
Slice::Comment::isDeprecated() const
Slice::DocComment::isDeprecated() const
{
return _isDeprecated;
}

StringList
Slice::Comment::deprecated() const
Slice::DocComment::deprecated() const
{
return _deprecated;
}

StringList
Slice::Comment::overview() const
Slice::DocComment::overview() const
{
return _overview;
}

StringList
Slice::Comment::seeAlso() const
Slice::DocComment::seeAlso() const
{
return _seeAlso;
}

StringList
Slice::Comment::returns() const
Slice::DocComment::returns() const
{
return _returns;
}

map<string, StringList>
Slice::Comment::parameters() const
Slice::DocComment::parameters() const
{
return _parameters;
}

map<string, StringList>
Slice::Comment::exceptions() const
Slice::DocComment::exceptions() const
{
return _exceptions;
}
Expand Down Expand Up @@ -617,9 +617,9 @@ Slice::Contained::line() const
}

string
Slice::Contained::comment() const
Slice::Contained::docComment() const
{
return _comment;
return _docComment;
}

namespace
Expand Down Expand Up @@ -749,17 +749,17 @@ namespace
}
}

CommentPtr
Slice::Contained::parseComment(function<string(string, string)> linkFormatter, bool stripMarkup) const
DocCommentPtr
Slice::Contained::parseDocComment(function<string(string, string)> linkFormatter, bool stripMarkup) const
{
// Split the comment's raw text up into lines.
StringList lines = splitComment(_comment, std::move(linkFormatter), stripMarkup);
StringList lines = splitComment(_docComment, std::move(linkFormatter), stripMarkup);
if (lines.empty())
{
return nullptr;
}

CommentPtr comment = make_shared<Comment>();
DocCommentPtr comment = make_shared<DocComment>();

// Parse the comment's text.
StringList::const_iterator i;
Expand Down Expand Up @@ -1025,7 +1025,7 @@ Slice::Contained::Contained(const ContainerPtr& container, const string& name)
assert(_unit);
_file = _unit->currentFile();
_line = _unit->currentLine();
_comment = _unit->currentComment();
_docComment = _unit->currentDocComment();
_includeLevel = _unit->currentIncludeLevel();
}

Expand Down Expand Up @@ -4579,9 +4579,9 @@ Slice::Unit::createUnit(bool all, const StringList& defaultFileMetadata)
}

void
Slice::Unit::setComment(const string& comment)
Slice::Unit::setDocComment(const string& comment)
{
_currentComment = "";
_currentDocComment = "";

string::size_type end = 0;
while (true)
Expand All @@ -4608,7 +4608,7 @@ Slice::Unit::setComment(const string& comment)
{
if (end + 1 > begin)
{
_currentComment += comment.substr(begin, end + 1 - begin);
_currentDocComment += comment.substr(begin, end + 1 - begin);
}
++end;
}
Expand All @@ -4619,7 +4619,7 @@ Slice::Unit::setComment(const string& comment)
{
if (end + 1 > begin)
{
_currentComment += comment.substr(begin, end + 1 - begin);
_currentDocComment += comment.substr(begin, end + 1 - begin);
}
}
break;
Expand All @@ -4628,20 +4628,20 @@ Slice::Unit::setComment(const string& comment)
}

void
Slice::Unit::addToComment(const string& comment)
Slice::Unit::addToDocComment(const string& comment)
{
if (!_currentComment.empty())
if (!_currentDocComment.empty())
{
_currentComment += '\n';
_currentDocComment += '\n';
}
_currentComment += comment;
_currentDocComment += comment;
}

string
Slice::Unit::currentComment()
Slice::Unit::currentDocComment()
{
string comment;
comment.swap(_currentComment);
comment.swap(_currentDocComment);
return comment;
}

Expand Down Expand Up @@ -4713,14 +4713,14 @@ Slice::Unit::setCurrentFile(const std::string& currentFile, int lineNumber)
}
}
pushDefinitionContext();
_currentComment = "";
_currentDocComment = "";
break;
}
case Pop:
{
--_currentIncludeLevel;
popDefinitionContext();
_currentComment = "";
_currentDocComment = "";
break;
}
default:
Expand Down Expand Up @@ -4931,7 +4931,7 @@ Slice::Unit::parse(const string& filename, FILE* file, bool debugMode)
assert(!Slice::currentUnit);
Slice::currentUnit = this;

_currentComment = "";
_currentDocComment = "";
_currentIncludeLevel = 0;
_topLevelFile = fullPath(filename);
pushContainer(shared_from_this());
Expand Down
20 changes: 10 additions & 10 deletions cpp/src/Slice/Parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,10 @@ namespace Slice
using DefinitionContextPtr = std::shared_ptr<DefinitionContext>;

// ----------------------------------------------------------------------
// Comment
// DocComment
// ----------------------------------------------------------------------

class Comment final
class DocComment final
{
public:
bool isDeprecated() const;
Expand Down Expand Up @@ -275,7 +275,7 @@ namespace Slice
std::map<std::string, StringList> _parameters;
std::map<std::string, StringList> _exceptions;
};
using CommentPtr = std::shared_ptr<Comment>;
using DocCommentPtr = std::shared_ptr<DocComment>;

// ----------------------------------------------------------------------
// SyntaxTreeBase
Expand Down Expand Up @@ -370,8 +370,8 @@ namespace Slice
std::string file() const;
int line() const;

std::string comment() const;
CommentPtr parseComment(
std::string docComment() const;
DocCommentPtr parseDocComment(
std::function<std::string(std::string, std::string)> linkFormatter,
bool stripMarkup = false) const;

Expand Down Expand Up @@ -403,7 +403,7 @@ namespace Slice
std::string _scoped;
std::string _file;
int _line;
std::string _comment;
std::string _docComment;
int _includeLevel;
MetadataList _metadata;
};
Expand Down Expand Up @@ -983,9 +983,9 @@ namespace Slice
public:
static UnitPtr createUnit(bool all, const StringList& defaultFileMetadata = StringList());

void setComment(const std::string& comment);
void addToComment(const std::string& comment);
std::string currentComment(); // Not const, as this function removes the current comment.
void setDocComment(const std::string& comment);
void addToDocComment(const std::string& comment);
std::string currentDocComment(); // Not const, as this function removes the current doc-comment.
std::string currentFile() const;
std::string topLevelFile() const;
int currentLine() const;
Expand Down Expand Up @@ -1041,7 +1041,7 @@ namespace Slice
bool _all;
MetadataList _defaultFileMetadata;
int _errors;
std::string _currentComment;
std::string _currentDocComment;
int _currentIncludeLevel;
std::string _topLevelFile;
std::stack<DefinitionContextPtr> _definitionContextStack;
Expand Down
6 changes: 3 additions & 3 deletions cpp/src/Slice/Scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1824,7 +1824,7 @@ case 21:
YY_RULE_SETUP
#line 320 "src/Slice/Scanner.l"
{
currentUnit->addToComment(yytext + 3);
currentUnit->addToDocComment(yytext + 3);
}
YY_BREAK
/* Matches and consumes a C++ style comment. */
Expand Down Expand Up @@ -1871,7 +1871,7 @@ YY_RULE_SETUP

string comment(yytext);
// The last 2 characters are the '*/' matched by this rule.
currentUnit->setComment(comment.substr(0, yyleng - 2));
currentUnit->setDocComment(comment.substr(0, yyleng - 2));
}
YY_BREAK
/* Handles reaching EOF while scanning a C style comment by issuing a warning but continuing normally. */
Expand All @@ -1881,7 +1881,7 @@ case YY_STATE_EOF(C_COMMENT):
yy_pop_state();

currentUnit->error("encountered EOF while scanning a comment");
currentUnit->setComment(yytext);
currentUnit->setDocComment(yytext);
}
YY_BREAK
/* ========== Preprocessor Statements ========== */
Expand Down
6 changes: 3 additions & 3 deletions cpp/src/Slice/Scanner.l
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ floating_literal (({fractional_constant}{exponent_part}?)|((\+|-)?{dec}+{expo

/* Matches and records a triple-slash style doc comment. */
<*>"///".* {
currentUnit->addToComment(yytext + 3);
currentUnit->addToDocComment(yytext + 3);
}

/* Matches and consumes a C++ style comment. */
Expand Down Expand Up @@ -347,15 +347,15 @@ floating_literal (({fractional_constant}{exponent_part}?)|((\+|-)?{dec}+{expo

string comment(yytext);
// The last 2 characters are the '*/' matched by this rule.
currentUnit->setComment(comment.substr(0, yyleng - 2));
currentUnit->setDocComment(comment.substr(0, yyleng - 2));
}

/* Handles reaching EOF while scanning a C style comment by issuing a warning but continuing normally. */
<C_COMMENT><<EOF>> {
yy_pop_state();

currentUnit->error("encountered EOF while scanning a comment");
currentUnit->setComment(yytext);
currentUnit->setDocComment(yytext);
}

/* ========== Preprocessor Statements ========== */
Expand Down
18 changes: 9 additions & 9 deletions cpp/src/Slice/SliceUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ Slice::filterMcppWarnings(const string& message)
}

void
Slice::printGeneratedHeader(IceInternal::Output& out, const string& path, const string& comment)
Slice::printGeneratedHeader(IceInternal::Output& out, const string& path, const string& commentStyle)
{
//
// Get only the file name part of the given path.
Expand All @@ -333,16 +333,16 @@ Slice::printGeneratedHeader(IceInternal::Output& out, const string& path, const
file = file.substr(pos + 1);
}

out << comment << " <auto-generated>\n";
out << comment << "\n";
out << comment << " Generated from file `" << file << "'"
out << commentStyle << " <auto-generated>\n";
out << commentStyle << "\n";
out << commentStyle << " Generated from file `" << file << "'"
<< "\n";
out << comment << "\n";
out << comment << " Warning: do not edit this file."
out << commentStyle << "\n";
out << commentStyle << " Warning: do not edit this file."
<< "\n";
out << comment << "\n";
out << comment << " </auto-generated>\n";
out << comment << "\n";
out << commentStyle << "\n";
out << commentStyle << " </auto-generated>\n";
out << commentStyle << "\n";
}

void
Expand Down
Loading

0 comments on commit fad9c08

Please sign in to comment.