diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp index e48dbf40750..63342d3105c 100644 --- a/cpp/src/Slice/Parser.cpp +++ b/cpp/src/Slice/Parser.cpp @@ -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 -Slice::Comment::parameters() const +Slice::DocComment::parameters() const { return _parameters; } map -Slice::Comment::exceptions() const +Slice::DocComment::exceptions() const { return _exceptions; } @@ -617,9 +617,9 @@ Slice::Contained::line() const } string -Slice::Contained::comment() const +Slice::Contained::docComment() const { - return _comment; + return _docComment; } namespace @@ -749,17 +749,17 @@ namespace } } -CommentPtr -Slice::Contained::parseComment(function linkFormatter, bool stripMarkup) const +DocCommentPtr +Slice::Contained::parseDocComment(function 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(); + DocCommentPtr comment = make_shared(); // Parse the comment's text. StringList::const_iterator i; @@ -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(); } @@ -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) @@ -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; } @@ -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; @@ -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; } @@ -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: @@ -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()); diff --git a/cpp/src/Slice/Parser.h b/cpp/src/Slice/Parser.h index a7453636c36..bef1c384d2a 100644 --- a/cpp/src/Slice/Parser.h +++ b/cpp/src/Slice/Parser.h @@ -242,10 +242,10 @@ namespace Slice using DefinitionContextPtr = std::shared_ptr; // ---------------------------------------------------------------------- - // Comment + // DocComment // ---------------------------------------------------------------------- - class Comment final + class DocComment final { public: bool isDeprecated() const; @@ -275,7 +275,7 @@ namespace Slice std::map _parameters; std::map _exceptions; }; - using CommentPtr = std::shared_ptr; + using DocCommentPtr = std::shared_ptr; // ---------------------------------------------------------------------- // SyntaxTreeBase @@ -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 linkFormatter, bool stripMarkup = false) const; @@ -403,7 +403,7 @@ namespace Slice std::string _scoped; std::string _file; int _line; - std::string _comment; + std::string _docComment; int _includeLevel; MetadataList _metadata; }; @@ -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; @@ -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 _definitionContextStack; diff --git a/cpp/src/Slice/Scanner.cpp b/cpp/src/Slice/Scanner.cpp index 0bde7d88f00..83dcb27d629 100644 --- a/cpp/src/Slice/Scanner.cpp +++ b/cpp/src/Slice/Scanner.cpp @@ -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. */ @@ -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. */ @@ -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 ========== */ diff --git a/cpp/src/Slice/Scanner.l b/cpp/src/Slice/Scanner.l index 3f19cc96ad1..c6edc757c09 100644 --- a/cpp/src/Slice/Scanner.l +++ b/cpp/src/Slice/Scanner.l @@ -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. */ @@ -347,7 +347,7 @@ 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. */ @@ -355,7 +355,7 @@ floating_literal (({fractional_constant}{exponent_part}?)|((\+|-)?{dec}+{expo yy_pop_state(); currentUnit->error("encountered EOF while scanning a comment"); - currentUnit->setComment(yytext); + currentUnit->setDocComment(yytext); } /* ========== Preprocessor Statements ========== */ diff --git a/cpp/src/Slice/SliceUtil.cpp b/cpp/src/Slice/SliceUtil.cpp index 9f009075fa7..f3cb948fce3 100644 --- a/cpp/src/Slice/SliceUtil.cpp +++ b/cpp/src/Slice/SliceUtil.cpp @@ -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. @@ -333,16 +333,16 @@ Slice::printGeneratedHeader(IceInternal::Output& out, const string& path, const file = file.substr(pos + 1); } - out << comment << " \n"; - out << comment << "\n"; - out << comment << " Generated from file `" << file << "'" + out << commentStyle << " \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 << " \n"; - out << comment << "\n"; + out << commentStyle << "\n"; + out << commentStyle << " \n"; + out << commentStyle << "\n"; } void diff --git a/cpp/src/ice2slice/Gen.cpp b/cpp/src/ice2slice/Gen.cpp index 3df2889c690..0ca7b41d525 100644 --- a/cpp/src/ice2slice/Gen.cpp +++ b/cpp/src/ice2slice/Gen.cpp @@ -282,9 +282,9 @@ namespace return result += "}"; } - void writeComment(const ContainedPtr& contained, Output& out) + void writeDocComment(const ContainedPtr& contained, Output& out) { - CommentPtr comment = contained->parseComment(slice2LinkFormatter, true); + DocCommentPtr comment = contained->parseDocComment(slice2LinkFormatter, true); if (!comment) { return; @@ -328,7 +328,7 @@ namespace { for (const auto& member : dataMembers) { - writeComment(member, out); + writeDocComment(member, out); out << nl; if (member->optional()) { @@ -427,7 +427,7 @@ Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) Output& out = getOutput(p); out << sp; - writeComment(p, out); + writeDocComment(p, out); out << nl << "class " << p->name(); if (base) @@ -452,7 +452,7 @@ Gen::TypesVisitor::visitInterfaceDefStart(const InterfaceDefPtr& p) Output& out = getOutput(p); out << sp; - writeComment(p, out); + writeDocComment(p, out); out << nl << "interface " << p->name(); if (bases.size() > 0) { @@ -474,7 +474,7 @@ Gen::TypesVisitor::visitInterfaceDefStart(const InterfaceDefPtr& p) for (OperationList::const_iterator q = operations.begin(); q != operations.end();) { OperationPtr op = *q; - writeComment(op, out); + writeDocComment(op, out); if (op->hasMetadata("marshaled-result")) { out << nl << "[cs::encodedReturn]"; @@ -542,7 +542,7 @@ Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) Output& out = getOutput(p); out << sp; - writeComment(p, out); + writeDocComment(p, out); out << nl << "exception " << p->name(); if (ExceptionPtr base = p->base()) { @@ -565,7 +565,7 @@ Gen::TypesVisitor::visitStructStart(const StructPtr& p) Output& out = getOutput(p); out << sp; - writeComment(p, out); + writeDocComment(p, out); out << nl << "compact struct " << p->name() << " {"; out.inc(); @@ -583,7 +583,7 @@ Gen::TypesVisitor::visitSequence(const SequencePtr& p) Output& out = getOutput(p); out << sp; - writeComment(p, out); + writeDocComment(p, out); out << nl << "typealias " << p->name() << " = "; for (const auto& metadata : p->getMetadata()) @@ -622,7 +622,7 @@ Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p) Output& out = getOutput(p); out << sp; - writeComment(p, out); + writeDocComment(p, out); out << nl << "typealias " << p->name() << " = "; for (const auto& metadata : p->getMetadata()) @@ -647,7 +647,7 @@ Gen::TypesVisitor::visitEnum(const EnumPtr& p) Output& out = getOutput(p); out << sp; - writeComment(p, out); + writeDocComment(p, out); out << nl << "enum " << p->name() << " {"; out.inc(); diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index cfb2768917f..e1196c59807 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -384,12 +384,12 @@ namespace void writeDocSummary(Output& out, const ContainedPtr& p, GenerateDeprecated generateDeprecated = GenerateDeprecated::Yes) { - if (p->comment().empty()) + if (p->docComment().empty()) { return; } - CommentPtr doc = p->parseComment(cppLinkFormatter); + DocCommentPtr doc = p->parseDocComment(cppLinkFormatter); out << nl << "/**"; @@ -447,7 +447,7 @@ namespace void writeOpDocParams( Output& out, const OperationPtr& op, - const CommentPtr& doc, + const DocCommentPtr& doc, OpDocParamType type, const StringList& preParams = StringList(), const StringList& postParams = StringList()) @@ -488,7 +488,7 @@ namespace } } - void writeOpDocExceptions(Output& out, const OperationPtr& op, const CommentPtr& doc) + void writeOpDocExceptions(Output& out, const OperationPtr& op, const DocCommentPtr& doc) { for (const auto& [name, lines] : doc->exceptions()) { @@ -507,7 +507,7 @@ namespace void writeOpDocSummary( Output& out, const OperationPtr& op, - const CommentPtr& doc, + const DocCommentPtr& doc, OpDocParamType type, bool showExceptions, GenerateDeprecated generateDeprecated = GenerateDeprecated::Yes, @@ -1684,7 +1684,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) const string deprecatedAttribute = getDeprecatedAttribute(p); - CommentPtr comment = p->parseComment(cppLinkFormatter); + DocCommentPtr comment = p->parseDocComment(cppLinkFormatter); const string contextDoc = "@param " + contextParam + " The Context map to send with the invocation."; const string futureDoc = "The future object for the invocation."; @@ -2097,7 +2097,7 @@ Slice::Gen::DataDefVisitor::visitExceptionStart(const ExceptionPtr& p) vector params; vector allParamDecls; - map allComments; + map allDocComments; for (const auto& dataMember : dataMembers) { @@ -2110,9 +2110,9 @@ Slice::Gen::DataDefVisitor::visitExceptionStart(const ExceptionPtr& p) typeToString(dataMember->type(), dataMember->optional(), scope, dataMember->getMetadata(), _useWstring); allParamDecls.push_back(typeName + " " + fixKwd(dataMember->name())); - if (CommentPtr comment = dataMember->parseComment(cppLinkFormatter)) + if (DocCommentPtr comment = dataMember->parseDocComment(cppLinkFormatter)) { - allComments[dataMember->name()] = comment; + allDocComments[dataMember->name()] = comment; } } @@ -2153,8 +2153,8 @@ Slice::Gen::DataDefVisitor::visitExceptionStart(const ExceptionPtr& p) H << nl << " * One-shot constructor to initialize all data members."; for (const auto& dataMember : allDataMembers) { - map::iterator r = allComments.find(dataMember->name()); - if (r != allComments.end()) + map::iterator r = allDocComments.find(dataMember->name()); + if (r != allDocComments.end()) { H << nl << " * @param " << fixKwd(r->first) << " " << getDocSentence(r->second->overview()); } @@ -2578,7 +2578,7 @@ Slice::Gen::DataDefVisitor::emitOneShotConstructor(const ClassDefPtr& p) if (!allDataMembers.empty()) { vector allParamDecls; - map allComments; + map allDocComments; DataMemberList dataMembers = p->dataMembers(); for (const auto& dataMember : allDataMembers) @@ -2586,9 +2586,9 @@ Slice::Gen::DataDefVisitor::emitOneShotConstructor(const ClassDefPtr& p) string typeName = typeToString(dataMember->type(), dataMember->optional(), scope, dataMember->getMetadata(), _useWstring); allParamDecls.push_back(typeName + " " + fixKwd(dataMember->name())); - if (CommentPtr comment = dataMember->parseComment(cppLinkFormatter)) + if (DocCommentPtr comment = dataMember->parseDocComment(cppLinkFormatter)) { - allComments[dataMember->name()] = comment; + allDocComments[dataMember->name()] = comment; } } @@ -2597,8 +2597,8 @@ Slice::Gen::DataDefVisitor::emitOneShotConstructor(const ClassDefPtr& p) H << nl << " * One-shot constructor to initialize all data members."; for (const auto& dataMember : allDataMembers) { - map::iterator r = allComments.find(dataMember->name()); - if (r != allComments.end()) + map::iterator r = allDocComments.find(dataMember->name()); + if (r != allDocComments.end()) { H << nl << " * @param " << fixKwd(r->first) << " " << getDocSentence(r->second->overview()); } @@ -2941,7 +2941,7 @@ Slice::Gen::InterfaceVisitor::visitOperation(const OperationPtr& p) const string currentTypeDecl = "const " + getUnqualified("::Ice::Current&", interfaceScope); const string currentDecl = currentTypeDecl + " " + currentParam; - CommentPtr comment = p->parseComment(cppLinkFormatter); + DocCommentPtr comment = p->parseDocComment(cppLinkFormatter); if (ret) { diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp index 7155d0f0c8c..ef5da6971ed 100644 --- a/cpp/src/slice2cs/Gen.cpp +++ b/cpp/src/slice2cs/Gen.cpp @@ -891,9 +891,9 @@ Slice::CsVisitor::splitIntoLines(const string& comment) } void -Slice::CsVisitor::splitComment(const ContainedPtr& p, StringList& summaryLines, StringList& remarksLines) +Slice::CsVisitor::splitDocComment(const ContainedPtr& p, StringList& summaryLines, StringList& remarksLines) { - string s = p->comment(); + string s = p->docComment(); const string paramTag = "@param"; const string throwsTag = "@throws"; @@ -930,7 +930,7 @@ Slice::CsVisitor::writeDocComment(const ContainedPtr& p, const string& extraPara { StringList summaryLines; StringList remarksLines; - splitComment(p, summaryLines, remarksLines); + splitDocComment(p, summaryLines, remarksLines); if (summaryLines.empty()) { @@ -1002,7 +1002,7 @@ Slice::CsVisitor::writeDocCommentAMI( { StringList summaryLines; StringList remarksLines; - splitComment(p, summaryLines, remarksLines); + splitDocComment(p, summaryLines, remarksLines); if (summaryLines.empty()) { @@ -1132,7 +1132,7 @@ Slice::CsVisitor::writeDocCommentTaskAsyncAMI( { StringList summaryLines; StringList remarksLines; - splitComment(p, summaryLines, remarksLines); + splitDocComment(p, summaryLines, remarksLines); if (summaryLines.empty()) { @@ -1203,7 +1203,7 @@ Slice::CsVisitor::writeDocCommentAMD(const OperationPtr& p, const string& extraP { StringList summaryLines; StringList remarksLines; - splitComment(p, summaryLines, remarksLines); + splitDocComment(p, summaryLines, remarksLines); if (summaryLines.empty()) { @@ -1284,7 +1284,7 @@ Slice::CsVisitor::writeDocCommentParam(const OperationPtr& p, ParamDir paramType // StringList summaryLines; StringList remarksLines; - splitComment(p, summaryLines, remarksLines); + splitDocComment(p, summaryLines, remarksLines); const string paramTag = "name(); opName[0] = static_cast(toupper(static_cast(opName[0]))); @@ -560,7 +560,7 @@ Slice::JavaVisitor::writeMarshaledResultType( Output& out, const OperationPtr& op, const string& package, - const CommentPtr& dc) + const DocCommentPtr& dc) { string opName = op->name(); const TypePtr ret = op->returnType(); @@ -1295,7 +1295,7 @@ Slice::JavaVisitor::writeDispatch(Output& out, const InterfaceDefPtr& p) for (const auto& op : ops) { - CommentPtr dc = op->parseComment(javaLinkFormatter); + DocCommentPtr dc = op->parseDocComment(javaLinkFormatter); vector params = getParams(op, package); const string currentParam = "com.zeroc.Ice.Current " + getEscapedParamName(op, "current"); @@ -1846,7 +1846,7 @@ Slice::JavaVisitor::writeDocCommentLines(Output& out, const string& text) } void -Slice::JavaVisitor::writeDocComment(Output& out, const UnitPtr& unt, const CommentPtr& dc) +Slice::JavaVisitor::writeDocComment(Output& out, const UnitPtr& unt, const DocCommentPtr& dc) { if (!dc) { @@ -1901,7 +1901,7 @@ Slice::JavaVisitor::writeProxyDocComment( Output& out, const OperationPtr& p, const string& package, - const CommentPtr& dc, + const DocCommentPtr& dc, bool async, const string& contextParam) { @@ -2060,7 +2060,7 @@ Slice::JavaVisitor::writeServantDocComment( Output& out, const OperationPtr& p, const string& package, - const CommentPtr& dc, + const DocCommentPtr& dc, bool async) { if (!dc) @@ -2297,7 +2297,7 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) } } - CommentPtr dc = p->parseComment(javaLinkFormatter); + DocCommentPtr dc = p->parseDocComment(javaLinkFormatter); // // Slice interfaces map to Java interfaces. @@ -2535,7 +2535,7 @@ Slice::Gen::TypesVisitor::visitInterfaceDefStart(const InterfaceDefPtr& p) open(absolute, p->file()); Output& out = output(); - CommentPtr dc = p->parseComment(javaLinkFormatter); + DocCommentPtr dc = p->parseDocComment(javaLinkFormatter); bool hasOptionals = false; for (const auto& op : p->allOperations()) @@ -2607,7 +2607,7 @@ Slice::Gen::TypesVisitor::visitOperation(const OperationPtr& p) Output& out = output(); - CommentPtr dc = p->parseComment(javaLinkFormatter); + DocCommentPtr dc = p->parseDocComment(javaLinkFormatter); // // Generate the "Result" type needed by operations that return multiple values. @@ -2648,7 +2648,7 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) out << sp; - CommentPtr dc = p->parseComment(javaLinkFormatter); + DocCommentPtr dc = p->parseDocComment(javaLinkFormatter); writeDocComment(out, p->unit(), dc); if (dc && dc->isDeprecated()) { @@ -2914,7 +2914,7 @@ Slice::Gen::TypesVisitor::visitStructStart(const StructPtr& p) out << sp; - CommentPtr dc = p->parseComment(javaLinkFormatter); + DocCommentPtr dc = p->parseDocComment(javaLinkFormatter); writeDocComment(out, p->unit(), dc); if (dc && dc->isDeprecated()) { @@ -3232,7 +3232,7 @@ Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p) out << sp; - CommentPtr dc = p->parseComment(javaLinkFormatter); + DocCommentPtr dc = p->parseDocComment(javaLinkFormatter); writeDocComment(out, p->unit(), dc); if (dc && dc->isDeprecated()) { @@ -3514,7 +3514,7 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) out << sp; - CommentPtr dc = p->parseComment(javaLinkFormatter); + DocCommentPtr dc = p->parseDocComment(javaLinkFormatter); writeDocComment(out, p->unit(), dc); if (dc && dc->isDeprecated()) { @@ -3530,7 +3530,7 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) { out << ','; } - CommentPtr edc = (*en)->parseComment(javaLinkFormatter); + DocCommentPtr edc = (*en)->parseDocComment(javaLinkFormatter); writeDocComment(out, p->unit(), edc); if (edc && edc->isDeprecated()) { @@ -3653,7 +3653,7 @@ Slice::Gen::TypesVisitor::visitConst(const ConstPtr& p) out << sp; - CommentPtr dc = p->parseComment(javaLinkFormatter); + DocCommentPtr dc = p->parseDocComment(javaLinkFormatter); writeDocComment(out, p->unit(), dc); if (dc && dc->isDeprecated()) { @@ -4004,7 +4004,7 @@ Slice::Gen::ProxyVisitor::visitInterfaceDefStart(const InterfaceDefPtr& p) open(absolute, p->file()); Output& out = output(); - CommentPtr dc = p->parseComment(javaLinkFormatter); + DocCommentPtr dc = p->parseDocComment(javaLinkFormatter); // // Generate a Java interface as the user-visible type @@ -4044,7 +4044,7 @@ Slice::Gen::ProxyVisitor::visitInterfaceDefEnd(const InterfaceDefPtr& p) { Output& out = output(); - CommentPtr dc = p->parseComment(javaLinkFormatter); + DocCommentPtr dc = p->parseDocComment(javaLinkFormatter); const string package = getPackage(p); const string contextParam = "java.util.Map context"; @@ -4264,7 +4264,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) const string contextParam = "java.util.Map " + contextParamName; const string noExplicitContextArg = "com.zeroc.Ice.ObjectPrx.noExplicitContext"; - CommentPtr dc = p->parseComment(javaLinkFormatter); + DocCommentPtr dc = p->parseDocComment(javaLinkFormatter); // // Synchronous methods with required parameters. diff --git a/cpp/src/slice2java/Gen.h b/cpp/src/slice2java/Gen.h index 1811884a0d9..b9b6a4b68f4 100644 --- a/cpp/src/slice2java/Gen.h +++ b/cpp/src/slice2java/Gen.h @@ -25,9 +25,9 @@ namespace Slice }; std::string getResultType(const OperationPtr&, const std::string&, bool, bool); - void writeResultType(::IceInternal::Output&, const OperationPtr&, const std::string&, const CommentPtr&); + void writeResultType(::IceInternal::Output&, const OperationPtr&, const std::string&, const DocCommentPtr&); void - writeMarshaledResultType(::IceInternal::Output&, const OperationPtr&, const std::string&, const CommentPtr&); + writeMarshaledResultType(::IceInternal::Output&, const OperationPtr&, const std::string&, const DocCommentPtr&); void allocatePatcher(::IceInternal::Output&, const TypePtr&, const std::string&, const std::string&); std::string getPatcher(const TypePtr&, const std::string&, const std::string&); @@ -96,13 +96,13 @@ namespace Slice void writeHiddenDocComment(::IceInternal::Output&); void writeDocCommentLines(::IceInternal::Output&, const StringList&); void writeDocCommentLines(::IceInternal::Output&, const std::string&); - void writeDocComment(::IceInternal::Output&, const UnitPtr&, const CommentPtr&); + void writeDocComment(::IceInternal::Output&, const UnitPtr&, const DocCommentPtr&); void writeDocComment(::IceInternal::Output&, const std::string&); void writeProxyDocComment( ::IceInternal::Output&, const OperationPtr&, const std::string&, - const CommentPtr&, + const DocCommentPtr&, bool, const std::string&); void writeHiddenProxyDocComment(::IceInternal::Output&, const OperationPtr&); @@ -110,7 +110,7 @@ namespace Slice ::IceInternal::Output&, const OperationPtr&, const std::string&, - const CommentPtr&, + const DocCommentPtr&, bool); void writeSeeAlso(::IceInternal::Output&, const UnitPtr&, const std::string&); }; diff --git a/cpp/src/slice2js/Gen.cpp b/cpp/src/slice2js/Gen.cpp index 55bfc689d55..31cdf0c7cc8 100644 --- a/cpp/src/slice2js/Gen.cpp +++ b/cpp/src/slice2js/Gen.cpp @@ -163,7 +163,7 @@ namespace } } - void writeDeprecated(Output& out, const CommentPtr& comment, const ContainedPtr& contained) + void writeDeprecated(Output& out, const DocCommentPtr& comment, const ContainedPtr& contained) { // JavaScript doesn't provide a way to deprecate elements other than by using a comment, so we map both the // Slice @deprecated tag and the deprecated metadata argument to a `@deprecated` JSDoc tag. @@ -247,7 +247,7 @@ namespace OpDocAllParams }; - void writeOpDocExceptions(Output& out, const OperationPtr& op, const CommentPtr& doc) + void writeOpDocExceptions(Output& out, const OperationPtr& op, const DocCommentPtr& doc) { map exDoc = doc->exceptions(); for (map::iterator p = exDoc.begin(); p != exDoc.end(); ++p) @@ -479,7 +479,7 @@ void Slice::JsVisitor::writeDocCommentFor(const ContainedPtr& p, bool includeDeprecated) { assert(!dynamic_pointer_cast(p)); - CommentPtr comment = p->parseComment(jsLinkFormatter); + DocCommentPtr comment = p->parseDocComment(jsLinkFormatter); if (!comment && (!includeDeprecated || !p->isDeprecated())) { // There's nothing to write for this doc-comment. @@ -2376,7 +2376,7 @@ Slice::Gen::TypeScriptVisitor::visitClassDefStart(const ClassDefPtr& p) _out << nl << " * One-shot constructor to initialize all data members."; for (const auto& dataMember : allDataMembers) { - if (CommentPtr comment = dataMember->parseComment(jsLinkFormatter)) + if (DocCommentPtr comment = dataMember->parseDocComment(jsLinkFormatter)) { _out << nl << " * @param " << fixId(dataMember->name()) << " " << getDocSentence(comment->overview()); } @@ -2425,7 +2425,7 @@ void Slice::Gen::TypeScriptVisitor::writeOpDocSummary( Output& out, const OperationPtr& op, - const CommentPtr& comment, + const DocCommentPtr& comment, bool forDispatch) { out << nl << "/**"; @@ -2562,7 +2562,7 @@ Slice::Gen::TypeScriptVisitor::visitInterfaceDefStart(const InterfaceDefPtr& p) } _out << sp; - writeOpDocSummary(_out, op, op->parseComment(jsLinkFormatter), false); + writeOpDocSummary(_out, op, op->parseDocComment(jsLinkFormatter), false); _out << nl << fixId(op->name()) << spar; for (const auto& param : inParams) { @@ -2658,7 +2658,7 @@ Slice::Gen::TypeScriptVisitor::visitInterfaceDefStart(const InterfaceDefPtr& p) } _out << sp; - writeOpDocSummary(_out, op, op->parseComment(jsLinkFormatter), true); + writeOpDocSummary(_out, op, op->parseDocComment(jsLinkFormatter), true); _out << nl << "abstract " << fixId(op->name()) << spar; for (const auto& param : inParams) { @@ -2736,7 +2736,7 @@ Slice::Gen::TypeScriptVisitor::visitExceptionStart(const ExceptionPtr& p) _out << nl << " * One-shot constructor to initialize all data members."; for (const auto& dataMember : allDataMembers) { - if (CommentPtr comment = dataMember->parseComment(jsLinkFormatter)) + if (DocCommentPtr comment = dataMember->parseDocComment(jsLinkFormatter)) { _out << nl << " * @param " << fixId(dataMember->name()) << " " << getDocSentence(comment->overview()); } diff --git a/cpp/src/slice2js/Gen.h b/cpp/src/slice2js/Gen.h index 1b9d915300e..9f5d4aa7099 100644 --- a/cpp/src/slice2js/Gen.h +++ b/cpp/src/slice2js/Gen.h @@ -180,7 +180,7 @@ namespace Slice void writeOpDocSummary( ::IceInternal::Output& out, const OperationPtr& op, - const CommentPtr& doc, + const DocCommentPtr& doc, bool forDispatch); // The module name of the current unit. diff --git a/cpp/src/slice2matlab/Main.cpp b/cpp/src/slice2matlab/Main.cpp index 4c2c80127c1..44f9fb7dfdf 100644 --- a/cpp/src/slice2matlab/Main.cpp +++ b/cpp/src/slice2matlab/Main.cpp @@ -860,7 +860,7 @@ namespace void writeDocSummary(IceInternal::Output& out, const ContainedPtr& p) { - CommentPtr doc = p->parseComment(matlabLinkFormatter, true); + DocCommentPtr doc = p->parseDocComment(matlabLinkFormatter, true); if (!doc) { return; @@ -890,7 +890,7 @@ namespace for (const auto& enumerator : enumerators) { out << nl << "% " << fixEnumerator(enumerator->name()); - CommentPtr enumeratorDoc = enumerator->parseComment(matlabLinkFormatter, true); + DocCommentPtr enumeratorDoc = enumerator->parseDocComment(matlabLinkFormatter, true); if (enumeratorDoc) { StringList enumeratorOverview = enumeratorDoc->overview(); @@ -913,7 +913,7 @@ namespace for (const auto& member : members) { out << nl << "% " << fixIdent(member->name()); - if (CommentPtr memberDoc = member->parseComment(matlabLinkFormatter, true)) + if (DocCommentPtr memberDoc = member->parseDocComment(matlabLinkFormatter, true)) { StringList memberOverview = memberDoc->overview(); if (!memberOverview.empty()) @@ -935,7 +935,7 @@ namespace for (const auto& member : members) { out << nl << "% " << fixExceptionMember(member->name()); - if (CommentPtr memberDoc = member->parseComment(matlabLinkFormatter, true)) + if (DocCommentPtr memberDoc = member->parseDocComment(matlabLinkFormatter, true)) { StringList memberOverview = memberDoc->overview(); if (!memberOverview.empty()) @@ -957,7 +957,7 @@ namespace for (const auto& member : members) { out << nl << "% " << fixIdent(member->name()); - if (CommentPtr memberDoc = member->parseComment(matlabLinkFormatter, true)) + if (DocCommentPtr memberDoc = member->parseDocComment(matlabLinkFormatter, true)) { StringList memberOverview = memberDoc->overview(); if (!memberOverview.empty()) @@ -995,7 +995,7 @@ namespace void writeOpDocSummary(IceInternal::Output& out, const OperationPtr& p, bool async) { - CommentPtr doc = p->parseComment(matlabLinkFormatter, true); + DocCommentPtr doc = p->parseDocComment(matlabLinkFormatter, true); if (!doc) { return; @@ -1156,7 +1156,7 @@ namespace void writeProxyDocSummary(IceInternal::Output& out, const InterfaceDefPtr& p) { - CommentPtr doc = p->parseComment(matlabLinkFormatter, true); + DocCommentPtr doc = p->parseDocComment(matlabLinkFormatter, true); if (!doc) { return; @@ -1184,7 +1184,7 @@ namespace for (OperationList::const_iterator q = ops.begin(); q != ops.end(); ++q) { OperationPtr op = *q; - CommentPtr opdoc = op->parseComment(matlabLinkFormatter, true); + DocCommentPtr opdoc = op->parseDocComment(matlabLinkFormatter, true); out << nl << "% " << fixOp(op->name()); if (opdoc) { @@ -1235,7 +1235,7 @@ namespace void writeMemberDoc(IceInternal::Output& out, const DataMemberPtr& p) { - CommentPtr doc = p->parseComment(matlabLinkFormatter, true); + DocCommentPtr doc = p->parseDocComment(matlabLinkFormatter, true); if (!doc) { return; diff --git a/cpp/src/slice2py/Python.cpp b/cpp/src/slice2py/Python.cpp index c1773b5082e..b97ece1fbd8 100644 --- a/cpp/src/slice2py/Python.cpp +++ b/cpp/src/slice2py/Python.cpp @@ -536,8 +536,6 @@ Slice::Python::compile(const vector& argv) Ice::CtrlCHandler ctrlCHandler; ctrlCHandler.setCallback(interruptedCallback); - bool keepComments = true; - ostringstream os; if (dependxml) { @@ -592,7 +590,7 @@ Slice::Python::compile(const vector& argv) else { PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs); - FILE* cppHandle = icecpp->preprocess(keepComments, "-D__SLICE2PY__"); + FILE* cppHandle = icecpp->preprocess(true, "-D__SLICE2PY__"); if (cppHandle == 0) { diff --git a/cpp/src/slice2py/PythonUtil.cpp b/cpp/src/slice2py/PythonUtil.cpp index 40e8e441613..880de7a5836 100644 --- a/cpp/src/slice2py/PythonUtil.cpp +++ b/cpp/src/slice2py/PythonUtil.cpp @@ -275,14 +275,14 @@ namespace Slice void writeDocstring(const string&, const EnumeratorList&); typedef map StringMap; - struct OpComment + struct OpDocComment { vector description; map> params; vector returns; map> exceptions; }; - bool parseOpComment(const string&, OpComment&); + bool parseOpDocComment(const string&, OpDocComment&); enum DocstringMode { @@ -437,7 +437,7 @@ Slice::Python::CodeVisitor::visitModuleStart(const ModulePtr& p) } _out << nl << "__name__ = '" << abs << "'"; - writeDocstring(p->comment(), "_M_" + abs + ".__doc__ = "); + writeDocstring(p->docComment(), "_M_" + abs + ".__doc__ = "); _moduleStack.push_front(abs); return true; @@ -574,7 +574,7 @@ Slice::Python::CodeVisitor::visitClassDefStart(const ClassDefPtr& p) _out.inc(); - writeDocstring(p->comment(), p->dataMembers()); + writeDocstring(p->docComment(), p->dataMembers()); // // __init__ @@ -1151,7 +1151,7 @@ Slice::Python::CodeVisitor::visitExceptionStart(const ExceptionPtr& p) DataMemberList members = p->dataMembers(); - writeDocstring(p->comment(), members); + writeDocstring(p->docComment(), members); // // __init__ @@ -1291,7 +1291,7 @@ Slice::Python::CodeVisitor::visitStructStart(const StructPtr& p) _out << nl << "class " << name << "(object):"; _out.inc(); - writeDocstring(p->comment(), members); + writeDocstring(p->docComment(), members); _out << nl << "def __init__(self"; writeConstructorParams(memberList); @@ -1585,7 +1585,7 @@ Slice::Python::CodeVisitor::visitEnum(const EnumPtr& p) _out << nl << "class " << name << "(Ice.EnumBase):"; _out.inc(); - writeDocstring(p->comment(), enumerators); + writeDocstring(p->docComment(), enumerators); _out << sp << nl << "def __init__(self, _n, _v):"; _out.inc(); @@ -2248,7 +2248,7 @@ Slice::Python::CodeVisitor::writeDocstring(const string& comment, const DataMemb map> docs; for (const auto& member : members) { - vector doc = stripMarkup(member->comment()); + vector doc = stripMarkup(member->docComment()); if (!doc.empty()) { docs[member->name()] = doc; @@ -2304,7 +2304,7 @@ Slice::Python::CodeVisitor::writeDocstring(const string& comment, const Enumerat map> docs; for (const auto& enumerator : enumerators) { - vector doc = stripMarkup(enumerator->comment()); + vector doc = stripMarkup(enumerator->docComment()); if (!doc.empty()) { docs[enumerator->name()] = doc; @@ -2339,7 +2339,7 @@ Slice::Python::CodeVisitor::writeDocstring(const string& comment, const Enumerat } bool -Slice::Python::CodeVisitor::parseOpComment(const string& comment, OpComment& c) +Slice::Python::CodeVisitor::parseOpDocComment(const string& comment, OpDocComment& c) { // // Remove most javadoc & HTML markup. @@ -2507,8 +2507,8 @@ Slice::Python::CodeVisitor::parseOpComment(const string& comment, OpComment& c) void Slice::Python::CodeVisitor::writeDocstring(const OperationPtr& op, DocstringMode mode) { - OpComment comment; - if (!parseOpComment(op->comment(), comment)) + OpDocComment comment; + if (!parseOpDocComment(op->docComment(), comment)) { return; } diff --git a/cpp/src/slice2swift/SwiftUtil.cpp b/cpp/src/slice2swift/SwiftUtil.cpp index eafd7771195..50fe86996db 100644 --- a/cpp/src/slice2swift/SwiftUtil.cpp +++ b/cpp/src/slice2swift/SwiftUtil.cpp @@ -346,7 +346,7 @@ SwiftGenerator::writeDocSentence(IceInternal::Output& out, const StringList& lin void SwiftGenerator::writeDocSummary(IceInternal::Output& out, const ContainedPtr& p) { - CommentPtr doc = p->parseComment(swiftLinkFormatter, true); + DocCommentPtr doc = p->parseDocComment(swiftLinkFormatter, true); if (!doc) { return; @@ -382,7 +382,7 @@ SwiftGenerator::writeDocSummary(IceInternal::Output& out, const ContainedPtr& p) void SwiftGenerator::writeOpDocSummary(IceInternal::Output& out, const OperationPtr& p, bool dispatch) { - CommentPtr doc = p->parseComment(swiftLinkFormatter, true); + DocCommentPtr doc = p->parseDocComment(swiftLinkFormatter, true); if (!doc) { return; @@ -526,7 +526,7 @@ SwiftGenerator::writeOpDocSummary(IceInternal::Output& out, const OperationPtr& void SwiftGenerator::writeProxyDocSummary(IceInternal::Output& out, const InterfaceDefPtr& p, const string& swiftModule) { - CommentPtr doc = p->parseComment(swiftLinkFormatter, true); + DocCommentPtr doc = p->parseDocComment(swiftLinkFormatter, true); if (!doc) { return; @@ -552,7 +552,7 @@ SwiftGenerator::writeProxyDocSummary(IceInternal::Output& out, const InterfaceDe out << nl << "/// " << prx << " Methods:"; for (const auto& op : ops) { - CommentPtr opdoc = op->parseComment(swiftLinkFormatter, true); + DocCommentPtr opdoc = op->parseDocComment(swiftLinkFormatter, true); optional opDocOverview; if (opdoc) { @@ -583,7 +583,7 @@ SwiftGenerator::writeProxyDocSummary(IceInternal::Output& out, const InterfaceDe void SwiftGenerator::writeServantDocSummary(IceInternal::Output& out, const InterfaceDefPtr& p, const string& swiftModule) { - CommentPtr doc = p->parseComment(swiftLinkFormatter, true); + DocCommentPtr doc = p->parseDocComment(swiftLinkFormatter, true); if (!doc) { return; @@ -609,7 +609,7 @@ SwiftGenerator::writeServantDocSummary(IceInternal::Output& out, const Interface for (const auto& op : ops) { out << nl << "/// - " << fixIdent(op->name()); - CommentPtr opdoc = op->parseComment(swiftLinkFormatter, true); + DocCommentPtr opdoc = op->parseDocComment(swiftLinkFormatter, true); if (opdoc) { StringList opdocOverview = opdoc->overview(); diff --git a/python/modules/IcePy/Slice.cpp b/python/modules/IcePy/Slice.cpp index 121e99ca156..ed2590b1ed9 100644 --- a/python/modules/IcePy/Slice.cpp +++ b/python/modules/IcePy/Slice.cpp @@ -116,12 +116,10 @@ IcePy_loadSlice(PyObject* /*self*/, PyObject* args) debug = opts.isSet("d") || opts.isSet("debug"); all = opts.isSet("all"); - bool keepComments = true; - for (const auto& file : files) { Slice::PreprocessorPtr icecpp = Slice::Preprocessor::create("icecpp", file, cppArgs); - FILE* cppHandle = icecpp->preprocess(keepComments, "-D__SLICE2PY__"); + FILE* cppHandle = icecpp->preprocess(true, "-D__SLICE2PY__"); if (cppHandle == 0) {