aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar Cary Clark <caryclark@skia.org>2018-07-12 16:24:53 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-07-12 23:47:49 +0000
commitab5c9af442382fd05215a09f1814686710108880 (patch)
tree4ae24dee1da7e80095da3c300db5f36b36150932 /tools
parentf839361feabc22a97108140e2f665cd4c947141a (diff)
fix include generation
Over zealous requirement to have periods at end of every sentence relaxed. Removed ancient comments from SkRRect.h. Add support for understanding " = default". TBR=caryclark@google.com Docs-Preview: https://skia.org/?cl=141120 Bug: skia:6818 Change-Id: I184533539803238ed386863f9029cb68a27e1d6a Reviewed-on: https://skia-review.googlesource.com/141120 Commit-Queue: Cary Clark <caryclark@skia.org> Reviewed-by: Cary Clark <caryclark@skia.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/bookmaker/bookmaker.h1
-rw-r--r--tools/bookmaker/definition.cpp23
-rw-r--r--tools/bookmaker/includeParser.cpp9
-rw-r--r--tools/bookmaker/includeWriter.cpp11
4 files changed, 40 insertions, 4 deletions
diff --git a/tools/bookmaker/bookmaker.h b/tools/bookmaker/bookmaker.h
index 24d56176aa..c695cff0e8 100644
--- a/tools/bookmaker/bookmaker.h
+++ b/tools/bookmaker/bookmaker.h
@@ -920,6 +920,7 @@ public:
return (int) (fContentEnd - fContentStart);
}
+ const char* methodEnd() const;
bool methodHasReturn(string name, TextParser* methodParser) const;
string methodName() const;
bool nextMethodParam(TextParser* methodParser, const char** nextEndPtr,
diff --git a/tools/bookmaker/definition.cpp b/tools/bookmaker/definition.cpp
index 056e4f7fe4..228f898fe1 100644
--- a/tools/bookmaker/definition.cpp
+++ b/tools/bookmaker/definition.cpp
@@ -533,11 +533,14 @@ bool Definition::checkMethod() const {
// check after end of #Line and before next child for description
const char* descStart = fContentStart;
const char* descEnd = nullptr;
+ const Definition* defEnd = nullptr;
+ const Definition* priorDef = nullptr;
for (auto& child : fChildren) {
if (MarkType::kAnchor == child->fMarkType) {
continue;
}
if (MarkType::kCode == child->fMarkType) {
+ priorDef = child;
continue;
}
if (MarkType::kDeprecated == child->fMarkType) {
@@ -550,6 +553,7 @@ bool Definition::checkMethod() const {
continue;
}
if (MarkType::kList == child->fMarkType) {
+ priorDef = child;
continue;
}
if (MarkType::kMarkChar == child->fMarkType) {
@@ -565,10 +569,12 @@ bool Definition::checkMethod() const {
if (!emptyCheck.eof() && emptyCheck.skipWhiteSpace()) {
descStart = emptyCheck.fChar;
emptyCheck.trimEnd();
+ defEnd = priorDef;
descEnd = emptyCheck.fEnd;
break;
}
descStart = child->fTerminator;
+ priorDef = nullptr;
}
if (!descEnd) {
return methodParser.reportError<bool>("missing description");
@@ -579,7 +585,9 @@ bool Definition::checkMethod() const {
if (!isupper(descStart[0])) {
description.reportWarning("expected capital");
} else if ('.' != descEnd[-1]) {
- description.reportWarning("expected period");
+ if (!defEnd || defEnd->fTerminator != descEnd) {
+ description.reportWarning("expected period");
+ }
} else {
if (!description.startsWith("For use by Android")) {
description.skipToSpace();
@@ -619,10 +627,21 @@ bool Definition::crossCheck(const Definition& includeToken) const {
return crossCheckInside(fContentStart, fContentEnd, includeToken);
}
+const char* Definition::methodEnd() const {
+ const char defaultTag[] = " = default";
+ size_t tagSize = sizeof(defaultTag) - 1;
+ const char* tokenEnd = fContentEnd - tagSize;
+ if (tokenEnd <= fContentStart || strncmp(tokenEnd, defaultTag, tagSize)) {
+ tokenEnd = fContentEnd;
+ }
+ return tokenEnd;
+}
+
bool Definition::crossCheckInside(const char* start, const char* end,
const Definition& includeToken) const {
TextParser def(fFileName, start, end, fLineCount);
- TextParser inc("", includeToken.fContentStart, includeToken.fContentEnd, 0);
+ const char* tokenEnd = includeToken.methodEnd();
+ TextParser inc("", includeToken.fContentStart, tokenEnd, 0);
if (inc.startsWith("SK_API")) {
inc.skipWord("SK_API");
}
diff --git a/tools/bookmaker/includeParser.cpp b/tools/bookmaker/includeParser.cpp
index 238fcf5109..fc378ddb45 100644
--- a/tools/bookmaker/includeParser.cpp
+++ b/tools/bookmaker/includeParser.cpp
@@ -305,9 +305,10 @@ bool IncludeParser::crossCheck(BmhParser& bmhParser) {
if (!def) {
int skip = !strncmp(token.fContentStart, "explicit ", 9) ? 9 : 0;
skip = !strncmp(token.fContentStart, "virtual ", 8) ? 8 : skip;
+ const char* tokenEnd = token.methodEnd();
string constructorName = className + "::";
constructorName += string(token.fContentStart + skip,
- token.fContentEnd - token.fContentStart - skip);
+ tokenEnd - token.fContentStart - skip);
def = root->find(constructorName, RootDefinition::AllowParens::kYes);
}
if (!def && 0 == token.fName.find("SK_")) {
@@ -1860,6 +1861,9 @@ bool IncludeParser::parseMethod(Definition* child, Definition* markupDef) {
tokenIter = operatorCheck;
}
string nameStr(tokenIter->fStart, nameEnd - tokenIter->fStart);
+ if (string::npos != nameStr.find("sizeof")) {
+ SkDebugf("");
+ }
if (addConst) {
nameStr += "_const";
}
@@ -2077,6 +2081,9 @@ bool IncludeParser::parseObject(Definition* child, Definition* markupDef) {
break;
}
}
+ if (previousToken.startsWith("sizeof") && 6 == previousToken.lineLength()) {
+ break;
+ }
}
if (fPriorObject && MarkType::kConst == fPriorObject->fMarkType) {
break;
diff --git a/tools/bookmaker/includeWriter.cpp b/tools/bookmaker/includeWriter.cpp
index e16da320eb..922f2200a9 100644
--- a/tools/bookmaker/includeWriter.cpp
+++ b/tools/bookmaker/includeWriter.cpp
@@ -436,6 +436,9 @@ void IncludeWriter::enumHeaderOut(RootDefinition* root, const Definition& child)
enumDef = &mapEntry->second;
}
}
+ if (!enumDef && enumName == root->fName) {
+ enumDef = root;
+ }
SkASSERT(enumDef);
// child[0] should be #Code comment starts at child[0].fTerminator
// though skip until #Code is found (in case there's a #ToDo, etc)
@@ -1464,7 +1467,13 @@ bool IncludeWriter::populate(Definition* def, ParentPair* prevPair, RootDefiniti
while (continueEnd > fContinuation && isspace(continueEnd[-1])) {
--continueEnd;
}
- methodName += string(fContinuation, continueEnd - fContinuation);
+ const char defaultTag[] = " = default";
+ size_t tagSize = sizeof(defaultTag) - 1;
+ const char* tokenEnd = continueEnd - tagSize;
+ if (tokenEnd <= fContinuation || strncmp(tokenEnd, defaultTag, tagSize)) {
+ tokenEnd = continueEnd;
+ }
+ methodName += string(fContinuation, tokenEnd - fContinuation);
if (string::npos != methodName.find('\n')) {
methodName.erase(std::remove(methodName.begin(), methodName.end(), '\n'),
methodName.end());