aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/bookmaker/definition.cpp
diff options
context:
space:
mode:
authorGravatar Cary Clark <caryclark@skia.org>2018-01-11 10:35:44 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-01-11 19:37:49 +0000
commitac47b88d3c4b6232ea8664cea99fbd8394f2dc38 (patch)
tree39c001433e3677d688cc472292295a8062edee80 /tools/bookmaker/definition.cpp
parent5f9102f2912ef702e013c48466b5461f2a0b9eb9 (diff)
update bookmaker to ToT
more image docs, still not done add ability to comment out non-working examples easily start work on additional self-checks clean up use of this-> in docs TBR=reed@google.com Docs-Preview: https://skia.org/?cl=91720 Bug: skia:6898 Change-Id: I706ab8145290e53ab67d3f509ccf4e1225adb3c3 Reviewed-on: https://skia-review.googlesource.com/91720 Commit-Queue: Cary Clark <caryclark@skia.org> Reviewed-by: Cary Clark <caryclark@skia.org>
Diffstat (limited to 'tools/bookmaker/definition.cpp')
-rw-r--r--tools/bookmaker/definition.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/tools/bookmaker/definition.cpp b/tools/bookmaker/definition.cpp
index 82b0a33a81..74f4d5a7fb 100644
--- a/tools/bookmaker/definition.cpp
+++ b/tools/bookmaker/definition.cpp
@@ -527,8 +527,12 @@ bool Definition::exampleToScript(string* result, ExampleOptions exampleOptions)
string code;
string imageStr = "0";
string srgbStr = "false";
+ string durationStr = "0";
for (auto const& iter : fChildren) {
switch (iter->fMarkType) {
+ case MarkType::kDuration:
+ durationStr = string(iter->fContentStart, iter->fContentEnd - iter->fContentStart);
+ break;
case MarkType::kError:
result->clear();
return true;
@@ -579,6 +583,7 @@ bool Definition::exampleToScript(string* result, ExampleOptions exampleOptions)
SkASSERT(0); // more coding to do
}
}
+ string animatedStr = "0" != durationStr ? "true" : "false";
string textOutStr = textOut ? "true" : "false";
size_t pos = 0;
while (pos < text.length() && ' ' > text[pos]) {
@@ -622,8 +627,8 @@ bool Definition::exampleToScript(string* result, ExampleOptions exampleOptions)
example += " \"srgb\": " + srgbStr + ",\n";
example += " \"f16\": false,\n";
example += " \"textOnly\": " + textOutStr + ",\n";
- example += " \"animated\": false,\n";
- example += " \"duration\": 0\n";
+ example += " \"animated\": " + animatedStr + ",\n";
+ example += " \"duration\": " + durationStr + "\n";
example += " },\n";
example += " \"fast\": true";
}
@@ -1035,6 +1040,18 @@ const Definition* Definition::hasParam(const string& ref) const {
return nullptr;
}
+bool Definition::hasMatch(const string& name) const {
+ for (auto child : fChildren) {
+ if (name == child->fName) {
+ return true;
+ }
+ if (child->hasMatch(name)) {
+ return true;
+ }
+ }
+ return false;
+}
+
bool Definition::methodHasReturn(const string& name, TextParser* methodParser) const {
if (methodParser->skipExact("static")) {
methodParser->skipWhiteSpace();