diff options
author | Cary Clark <caryclark@skia.org> | 2018-02-09 16:49:09 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-02-11 18:30:05 +0000 |
commit | 78c110e2f0faefeecc8c8c19f6dcb00e738bffc7 (patch) | |
tree | bb4b3e964da1ff59c7cd79b176d342d6785d7123 /tools | |
parent | c5cecdcaf8ab3ad66abc2f88a82bb14279fe3d48 (diff) |
resolve bookmaker refs fixes
Getting ready to update include/core generated bookmaker
files. Fixing errors when resolving references in
bmh files.
Docs-Preview: https://skia.org/?cl=106281
Bug: skia:6898
Change-Id: Ic1cbe5b7b9b9f09346e460802b8f21d2ec14329d
Reviewed-on: https://skia-review.googlesource.com/106281
Commit-Queue: Cary Clark <caryclark@google.com>
Reviewed-by: Cary Clark <caryclark@skia.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/bookmaker/bookmaker.cpp | 7 | ||||
-rw-r--r-- | tools/bookmaker/bookmaker.h | 11 | ||||
-rw-r--r-- | tools/bookmaker/definition.cpp | 3 | ||||
-rw-r--r-- | tools/bookmaker/includeWriter.cpp | 109 | ||||
-rw-r--r-- | tools/bookmaker/mdOut.cpp | 9 | ||||
-rw-r--r-- | tools/bookmaker/spellCheck.cpp | 3 |
6 files changed, 93 insertions, 49 deletions
diff --git a/tools/bookmaker/bookmaker.cpp b/tools/bookmaker/bookmaker.cpp index 9d5a2782f3..6f7c698ca5 100644 --- a/tools/bookmaker/bookmaker.cpp +++ b/tools/bookmaker/bookmaker.cpp @@ -981,9 +981,6 @@ void HackParser::topicIter(const Definition* topic) { } switch (child->fMarkType) { case MarkType::kMethod: { - if (Definition::MethodType::kOperator == child->fMethodType) { - SkDebugf(""); - } hasIn |= MarkType::kTopic != topic->fMarkType && MarkType::kSubtopic != topic->fMarkType; // don't write #In if parent is class hasLine |= child->fClone; @@ -1008,10 +1005,6 @@ void HackParser::topicIter(const Definition* topic) { } } if ("" == oneLiner) { - const Definition* csParent = child->csParent(); - if (!csParent || !csParent->csParent()) { - SkDebugf(""); - } #ifdef SK_DEBUG const Definition* rootParent = topic; while (rootParent->fParent && MarkType::kClass != rootParent->fMarkType diff --git a/tools/bookmaker/bookmaker.h b/tools/bookmaker/bookmaker.h index 0264f50ac9..6bd4e1e5fa 100644 --- a/tools/bookmaker/bookmaker.h +++ b/tools/bookmaker/bookmaker.h @@ -902,6 +902,17 @@ public: void setWrapper(); + const Definition* topicParent() const { + Definition* test = fParent; + while (test) { + if (MarkType::kTopic == test->fMarkType) { + return test; + } + test = test->fParent; + } + return nullptr; + } + string fText; // if text is constructed instead of in a file, it's put here const char* fStart = nullptr; // .. in original text file, or the start of fText const char* fContentStart; // start past optional markup name diff --git a/tools/bookmaker/definition.cpp b/tools/bookmaker/definition.cpp index 25d154386d..68e001aebb 100644 --- a/tools/bookmaker/definition.cpp +++ b/tools/bookmaker/definition.cpp @@ -1285,9 +1285,6 @@ static string unpreformat(const string& orig) { } bool Definition::paramsMatch(const string& matchFormatted, const string& name) const { - if (string::npos != matchFormatted.find("readPixels")) { - SkDebugf(""); - } string match = unpreformat(matchFormatted); TextParser def(fFileName, fStart, fContentStart, fLineCount); const char* dName = def.strnstr(name.c_str(), fContentStart); diff --git a/tools/bookmaker/includeWriter.cpp b/tools/bookmaker/includeWriter.cpp index dd5df8f75f..716194066c 100644 --- a/tools/bookmaker/includeWriter.cpp +++ b/tools/bookmaker/includeWriter.cpp @@ -640,6 +640,9 @@ void IncludeWriter::enumSizeItems(const Definition& child) { // walk children and output complete method doxygen description void IncludeWriter::methodOut(const Definition* method, const Definition& child) { + if (string::npos != method->fName.find("scalePixels")) { + SkDebugf(""); + } if (fPendingMethod) { fIndent -= 4; fPendingMethod = false; @@ -705,6 +708,7 @@ void IncludeWriter::methodOut(const Definition* method, const Definition& child) this->writeCommentTrailer(); fBmhMethod = nullptr; fMethodDef = nullptr; + fEnumDef = nullptr; fWroteMethod = true; } @@ -1317,19 +1321,14 @@ bool IncludeWriter::populate(Definition* def, ParentPair* prevPair, RootDefiniti } } // FIXME: trigger error earlier if inner #Struct or #Class is missing #Code - const char* commentStart; - const char* commentEnd; if (!fBmhStructDef->fDeprecated) { SkASSERT(codeBlock); SkASSERT(nextBlock); // FIXME: check enum for correct order earlier - commentStart = codeBlock->fTerminator; - commentEnd = nextBlock->fStart; - } - if (fIndentNext) { -// fIndent += 4; + const char* commentStart = codeBlock->fTerminator; + const char* commentEnd = nextBlock->fStart; + fIndentNext = true; + this->structOut(root, *fBmhStructDef, commentStart, commentEnd); } - fIndentNext = true; - this->structOut(root, *fBmhStructDef, commentStart, commentEnd); } fDeferComment = nullptr; } else { @@ -1488,9 +1487,7 @@ bool IncludeWriter::populate(Definition* def, ParentPair* prevPair, RootDefiniti } } SkASSERT(fBmhStructDef); - if (fBmhStructDef->fDeprecated) { - SkDebugf(""); - } else { + if (!fBmhStructDef->fDeprecated) { memberEnd = this->structMemberOut(memberStart, child); startDef = &child; fStart = child.fContentEnd + 1; @@ -1676,6 +1673,7 @@ string IncludeWriter::resolveRef(const char* start, const char* end, bool first, *refType = RefType::kNormal; SkASSERT(string::npos == undername.find(' ')); const Definition* rootDef = nullptr; + string substitute; { auto rootDefIter = fBmhParser->fTopicMap.find(undername); if (fBmhParser->fTopicMap.end() != rootDefIter) { @@ -1691,10 +1689,18 @@ string IncludeWriter::resolveRef(const char* start, const char* end, bool first, if (fBmhParser->fTopicMap.end() != rootDefIter) { rootDef = rootDefIter->second; } - } else { + if (!rootDef) { + size_t doubleColon = fBmhStructDef->fName.rfind("::"); + if (string::npos != doubleColon && undername + == fBmhStructDef->fName.substr(doubleColon + 2)) { + substitute = fBmhStructDef->fName; + } + } + } + if (!rootDef && !substitute.length()) { auto aliasIter = fBmhParser->fAliasMap.find(undername); if (fBmhParser->fAliasMap.end() != aliasIter) { - rootDef = aliasIter->second->fParent; + rootDef = aliasIter->second; } else if (!first) { SkDebugf("unfound: %s\n", undername.c_str()); this->reportError("reference unfound"); @@ -1703,33 +1709,71 @@ string IncludeWriter::resolveRef(const char* start, const char* end, bool first, } } } - string substitute; if (rootDef) { - for (auto child : rootDef->fChildren) { - if (MarkType::kSubstitute == child->fMarkType) { - substitute = string(child->fContentStart, - (int) (child->fContentEnd - child->fContentStart)); - break; + MarkType rootType = rootDef->fMarkType; + bool isTopic = MarkType::kSubtopic == rootType || MarkType::kTopic == rootType; + auto substituteParent = MarkType::kAlias == rootType ? rootDef->fParent : + isTopic ? rootDef : nullptr; + if (substituteParent) { + for (auto child : substituteParent->fChildren) { + if (MarkType::kSubstitute == child->fMarkType) { + substitute = string(child->fContentStart, + (int) (child->fContentEnd - child->fContentStart)); + break; + } + } + } + if (!substitute.length()) { + string match = rootDef->fName; + size_t index; + while (string::npos != (index = match.find('_'))) { + match.erase(index, 1); + } + string skmatch = "Sk" + match; + auto parent = substituteParent ? substituteParent : rootDef; + for (auto child : parent->fChildren) { + // there may be more than one + // prefer the one mostly closely matching in text + if ((MarkType::kClass == child->fMarkType || + MarkType::kStruct == child->fMarkType || + (MarkType::kEnum == child->fMarkType && !child->fAnonymous) || + MarkType::kEnumClass == child->fMarkType) && (match == child->fName || + skmatch == child->fName)) { + substitute = child->fName; + break; + } } } if (!substitute.length()) { for (auto child : rootDef->fChildren) { + // there may be more than one + // if so, it's a bug since it's unknown which is the right one if (MarkType::kClass == child->fMarkType || MarkType::kStruct == child->fMarkType || (MarkType::kEnum == child->fMarkType && !child->fAnonymous) || MarkType::kEnumClass == child->fMarkType) { + SkASSERT("" == substitute); substitute = child->fName; - if (MarkType::kEnum == child->fMarkType && fInEnum) { + if (MarkType::kEnum == child->fMarkType) { size_t parentClassEnd = substitute.find("::"); SkASSERT(string::npos != parentClassEnd); - substitute = substitute.substr(parentClassEnd + 2); + string subEnd = substitute.substr(parentClassEnd + 2); + if (fInEnum) { + substitute = subEnd; + } + if (subEnd == undername) { + break; + } } - break; } } } if (!substitute.length()) { - auto parent = rootDef->fParent; + const Definition* parent = rootDef; + do { + parent = parent->fParent; + } while (parent && (MarkType::kSubtopic == parent->fMarkType + || MarkType::kTopic == parent->fMarkType)); if (parent) { if (MarkType::kClass == parent->fMarkType || MarkType::kStruct == parent->fMarkType || @@ -1738,9 +1782,14 @@ string IncludeWriter::resolveRef(const char* start, const char* end, bool first, if (parent->fParent != fRootTopic) { substitute = parent->fName; size_t under = undername.find('_'); - SkASSERT(string::npos != under); - string secondHalf(&undername[under], (size_t) (undername.length() - under)); - substitute += ConvertRef(secondHalf, false); + if (string::npos != under) { + string secondHalf(&undername[under], + (size_t) (undername.length() - under)); + substitute += ConvertRef(secondHalf, false); + } else { + substitute += ' '; + substitute += ConvertRef(undername, false); + } } else { substitute += ConvertRef(undername, first); } @@ -1752,6 +1801,9 @@ string IncludeWriter::resolveRef(const char* start, const char* end, bool first, if (first && isupper(start[0]) && substitute.length() > 0 && islower(substitute[0])) { substitute[0] = start[0]; } + if (undername == "Color_Type" && substitute == "") { + SkDebugf(""); + } return substitute; } @@ -1807,6 +1859,9 @@ int IncludeWriter::lookupReference(const PunctuationState punctuation, const Wor temp = ConvertRef(resolved, false); } } + if (resolved == "Color_Type" && temp == "color type") { + SkDebugf(""); + } if (temp.length()) { if (start > lastWrite) { SkASSERT(data[start - 1] >= ' '); diff --git a/tools/bookmaker/mdOut.cpp b/tools/bookmaker/mdOut.cpp index 31f8ef4f6f..77a370e156 100644 --- a/tools/bookmaker/mdOut.cpp +++ b/tools/bookmaker/mdOut.cpp @@ -973,9 +973,6 @@ void MdOut::markTypeOut(Definition* def) { case MarkType::kPopulate: { SkASSERT(MarkType::kSubtopic == def->fParent->fMarkType); string name = def->fParent->fName; - if ("Bitmap_Related_Function" == def->fParent->fFiddle) { - SkDebugf(""); - } if (kSubtopics == name) { this->subtopicsOut(); } else { @@ -1191,9 +1188,6 @@ void MdOut::populateTables(const Definition* def) { return; } for (auto child : def->fChildren) { - if (string::npos != child->fFiddle.find("Bitmap_Set")) { - SkDebugf(""); - } if (MarkType::kTopic == child->fMarkType || MarkType::kSubtopic == child->fMarkType) { string name = child->fName; bool builtInTopic = name == kClassesAndStructs || name == kConstants @@ -1381,9 +1375,6 @@ void MdOut::subtopicOut(const TableContents& tableContents) { items[name] = entry; } for (auto entry : items) { - if (string::npos != entry.second->fName.find("SkRect::set")) { - SkDebugf(""); - } if (entry.second->fDeprecated) { continue; } diff --git a/tools/bookmaker/spellCheck.cpp b/tools/bookmaker/spellCheck.cpp index bafc969ef4..3cb62be3ef 100644 --- a/tools/bookmaker/spellCheck.cpp +++ b/tools/bookmaker/spellCheck.cpp @@ -644,9 +644,6 @@ void SpellCheck::wordCheck(const string& str) { if (mappy.end() != iter) { iter->second.fCount += 1; } else { - if ("offscreen" == str) { - SkDebugf(""); - } CheckEntry* entry = &mappy[str]; entry->fFile = fFileName; entry->fLine = fLineCount + fLocalLine; |