diff options
Diffstat (limited to 'tools/bookmaker/definition.cpp')
-rw-r--r-- | tools/bookmaker/definition.cpp | 82 |
1 files changed, 78 insertions, 4 deletions
diff --git a/tools/bookmaker/definition.cpp b/tools/bookmaker/definition.cpp index 757169b1a9..25d154386d 100644 --- a/tools/bookmaker/definition.cpp +++ b/tools/bookmaker/definition.cpp @@ -897,7 +897,7 @@ bool Definition::crossCheckInside(const char* start, const char* end, return false; } -string Definition::formatFunction() const { +string Definition::formatFunction(Format format) const { const char* end = fContentStart; while (end > fStart && ' ' >= end[-1]) { --end; @@ -913,6 +913,9 @@ string Definition::formatFunction() const { const char* nameInParser = methodParser.strnstr(name.c_str(), methodParser.fEnd); methodParser.skipTo(nameInParser); const char* lastEnd = methodParser.fChar; + if (Format::kOmitReturn == format) { + lastStart = lastEnd; + } const char* paren = methodParser.strnchr('(', methodParser.fEnd); size_t indent; if (paren) { @@ -983,8 +986,10 @@ string Definition::formatFunction() const { if (delimiter) { if (nextEnd - nextStart >= (ptrdiff_t) (limit - written)) { written = indent; - methodStr += '\n'; - methodStr += string(indent, ' '); + if (Format::kIncludeReturn == format) { + methodStr += '\n'; + methodStr += string(indent, ' '); + } } methodParser.skipTo(delimiter); } @@ -1214,7 +1219,76 @@ string Definition::NormalizedName(string name) { return normalizedName; } -bool Definition::paramsMatch(const string& match, const string& name) const { +static string unpreformat(const string& orig) { + string result; + int amp = 0; + for (auto c : orig) { + switch (amp) { + case 0: + if ('&' == c) { + amp = 1; + } else { + amp = 0; + result += c; + } + break; + case 1: + if ('l' == c) { + amp = 2; + } else if ('g' == c) { + amp = 3; + } else { + amp = 0; + result += "&"; + result += c; + } + break; + case 2: + if ('t' == c) { + amp = 4; + } else { + amp = 0; + result += "&l"; + result += c; + } + break; + case 3: + if ('t' == c) { + amp = 5; + } else { + amp = 0; + result += "&g"; + result += c; + } + break; + case 4: + if (';' == c) { + result += '<'; + } else { + result += "<"; + result += c; + } + amp = 0; + break; + case 5: + if (';' == c) { + result += '>'; + } else { + result += ">"; + result += c; + } + amp = 0; + break; + } + } + return result; +} + +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); if (!dName) { |