diff options
author | Cary Clark <caryclark@skia.org> | 2018-06-08 15:57:37 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-06-08 20:36:53 +0000 |
commit | 27dddae3130c8a6cfaa845195b2fb95cc691dd26 (patch) | |
tree | 248a7a0b76c427248b8aea1eb6ef203cefe15f33 /tools | |
parent | a05a31aef4a0dc1af797aa454a2864a36260956b (diff) |
rebase
This reverts commit 32a4910e57b1fdd3c8671de1ee85e05ca21d079f.
Reason for revert: SkMatrix::toString use has been removed from flutter
and has been picked up in fuchsia
Additionally some bookmaker changes take into account recent
additions of typedef comments and the generated header comment.
Original change's description:
> Revert "remove toString"
>
> This reverts commit 5191880cbf3ee4d122b0d11b4945fbab0784fda7.
>
> Reason for revert: broke flutter
>
> Original change's description:
> > remove toString
> >
> > toString may have been used by obsolete debugger only
> > find out if that is so
> >
> > R=​brianosman@google.com,bsalomon@google.com
> >
> > Docs-Preview: https://skia.org/?cl=119894
> > Bug:830651
> > Change-Id: I737f19b7d3fbc869bea2f443fa3b5ed7c1393ffd
> > Reviewed-on: https://skia-review.googlesource.com/119894
> > Commit-Queue: Cary Clark <caryclark@google.com>
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
>
> TBR=bsalomon@google.com,brianosman@google.com,caryclark@google.com,caryclark@skia.org
>
> Change-Id: I9f81de6c3615ee0608bcea9081b77239b4b8816c
TBR=bsalomon@google.com,brianosman@google.com
# Not skipping CQ checks because original CL landed > 1 day ago.
Reviewed-on: https://skia-review.googlesource.com/129623
Reviewed-by: Cary Clark <caryclark@skia.org>
Commit-Queue: Cary Clark <caryclark@google.com>
Docs-Preview: https://skia.org/?cl=133583
Bug: 830651
Change-Id: If8499e796be63580ad419e150e94d43e8b89de1b
Reviewed-on: https://skia-review.googlesource.com/133583
Commit-Queue: Cary Clark <caryclark@skia.org>
Auto-Submit: Cary Clark <caryclark@skia.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/bookmaker/bookmaker.h | 4 | ||||
-rw-r--r-- | tools/bookmaker/includeWriter.cpp | 14 | ||||
-rw-r--r-- | tools/bookmaker/parserCommon.cpp | 26 |
3 files changed, 39 insertions, 5 deletions
diff --git a/tools/bookmaker/bookmaker.h b/tools/bookmaker/bookmaker.h index a002621cd7..ecfbc99788 100644 --- a/tools/bookmaker/bookmaker.h +++ b/tools/bookmaker/bookmaker.h @@ -1150,6 +1150,8 @@ public: fParent = def; } + char* FindDateTime(char* buffer, int size); + void indentIn(IndentKind kind) { fIndent += 4; fIndentStack.emplace_back(kind, fIndent); @@ -1218,7 +1220,7 @@ public: fParent = fParent->fParent; } - const char* ReadToBuffer(string filename, int* size); + char* ReadToBuffer(string filename, int* size); virtual void reset() = 0; diff --git a/tools/bookmaker/includeWriter.cpp b/tools/bookmaker/includeWriter.cpp index 566cc7cc58..38cd2232ef 100644 --- a/tools/bookmaker/includeWriter.cpp +++ b/tools/bookmaker/includeWriter.cpp @@ -1342,6 +1342,7 @@ bool IncludeWriter::populate(Definition* def, ParentPair* prevPair, RootDefiniti bool sawConst = false; bool staticOnly = false; bool sawTypedef = false; + Definition* deferredTypedefComment = nullptr; const Definition* requireDense = nullptr; const Definition* startDef = nullptr; for (auto& child : def->fTokens) { @@ -1621,7 +1622,9 @@ bool IncludeWriter::populate(Definition* def, ParentPair* prevPair, RootDefiniti child.fContentStart; this->writeBlockTrim((int) (bodyEnd - fStart), fStart); if (fPendingMethod) { - this->indentOut(); + if (fIndent >= 4) { + this->indentOut(); + } fPendingMethod = false; } startDef = requireDense ? requireDense : &child; @@ -1784,6 +1787,7 @@ bool IncludeWriter::populate(Definition* def, ParentPair* prevPair, RootDefiniti case KeyWord::kTypedef: SkASSERT(!memberStart); memberStart = &child; + deferredTypedefComment = fDeferComment; sawTypedef = true; break; case KeyWord::kSK_BEGIN_REQUIRE_DENSE: @@ -2013,6 +2017,7 @@ bool IncludeWriter::populate(Definition* def, ParentPair* prevPair, RootDefiniti SkASSERT(fBmhParser->fTypedefMap.end() != typedefIter); bmhTypedef = &typedefIter->second; } + fDeferComment = deferredTypedefComment; this->constOut(memberStart, bmhTypedef); fDeferComment = nullptr; sawTypedef = false; @@ -2768,6 +2773,13 @@ bool IncludeWriter::writeHeader(std::pair<const string, Definition>& include) { this->writeString("*/"); this->lf(2); fIndent = 0; + if (this->startsWith("/* Generated by tools/bookmaker from")) { + this->skipToEndBracket("*/"); + if (!this->skipExact("*/\n\n")) { + return this->reportError<bool>("malformed generated comment"); + } + } fStart = fChar; + return true; } diff --git a/tools/bookmaker/parserCommon.cpp b/tools/bookmaker/parserCommon.cpp index 8a58b2642b..35769b6e4a 100644 --- a/tools/bookmaker/parserCommon.cpp +++ b/tools/bookmaker/parserCommon.cpp @@ -245,7 +245,7 @@ void ParserCommon::writeString(const char* str) { fMaxLF = 2; } -const char* ParserCommon::ReadToBuffer(string filename, int* size) { +char* ParserCommon::ReadToBuffer(string filename, int* size) { FILE* file = fopen(filename.c_str(), "rb"); if (!file) { return nullptr; @@ -261,13 +261,27 @@ const char* ParserCommon::ReadToBuffer(string filename, int* size) { return buffer; } +char* ParserCommon::FindDateTime(char* buffer, int size) { + int index = -1; + int lineCount = 8; + while (++index < size && ('\n' != buffer[index] || --lineCount)) + ; + if (lineCount) { + return nullptr; + } + if (strncmp("\n on 20", &buffer[index], 9)) { + return nullptr; + } + return &buffer[index]; +} + bool ParserCommon::writtenFileDiffers(string filename, string readname) { int writtenSize, readSize; - const char* written = ReadToBuffer(filename, &writtenSize); + char* written = ReadToBuffer(filename, &writtenSize); if (!written) { return true; } - const char* read = ReadToBuffer(readname, &readSize); + char* read = ReadToBuffer(readname, &readSize); if (!read) { delete[] written; return true; @@ -285,6 +299,12 @@ bool ParserCommon::writtenFileDiffers(string filename, string readname) { if (readSize != writtenSize) { return true; } + // force the date/time to be the same, if present in both + const char* newDateTime = FindDateTime(written, writtenSize); + char* oldDateTime = FindDateTime(read, readSize); + if (newDateTime && oldDateTime) { + memcpy(oldDateTime, newDateTime, 26); + } bool result = !!memcmp(written, read, writtenSize); delete[] written; delete[] read; |