Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Unified Diff: experimental/docs/jsonReader.cpp

Issue 1342523002: json based animation toy (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: wip whats next? Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « experimental/docs/interpolatorFunctions.js ('k') | experimental/docs/jsonbaseddoc.htm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: experimental/docs/jsonReader.cpp
diff --git a/experimental/docs/jsonReader.cpp b/experimental/docs/jsonReader.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3c5fa2fdcdb0eb1c053f6d14c3982cb7ee34393a
--- /dev/null
+++ b/experimental/docs/jsonReader.cpp
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2006 The Android Open Source Project
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkTArray.h"
+#include "SkTDict.h"
+#include "SkString.h"
+
+enum ReadState {
+ kRoot_ReadState,
+
+};
+
+static bool isToken(const char* s, const char* e) {
+ SkASSERT(s < e);
+ while (s < e) {
+ char c = *s++;
+ char u = c & ~0x20;
+ if ((u < 'A' || u > 'Z') && (c < '0' || c > '9') && c != '_') {
+ return false;
+ }
+ }
+ return true;
+}
+
+static void skpWhiteSpace(const char** strPtr) {
+ const char* str = *strPtr;
+ while (*str && *str <= ' ') {
+ str++;
+ }
+ *strPtr = str;
+}
+
+static void ReadRoot(const char** strPtr) {
+ skipWhiteSpace(strPtr);
+ const char* str = *strPtr;
+ const char kVarStr[] = "var ";
+ SkASSERT(SkStrStartsWith(str, kVarStr));
+ const char* rootVar = str + sizeof(kVarStr) - 1;
+ const char* rootEnd = strchr(rootVar, ' ');
+ SkASSERT(rootEnd);
+ SkASSERT(isToken(rootVar, rootEnd));
+ const char* rootAssign = rootEnd;
+ skipWhiteSpace(rootAssign);
+ SkASSERT(rootAssign[0] == '=');
+ const char* rootData = rootAssign + 1;
+ SkASSERT(rootData[0]);
+ skipWhiteSpace(rootData);
+ if (rootData[0] == '{') {
+ addObject(rootVar, rootEnd);
+ } else if (rootData[0] == '[') {
+ addArray(rootVar, rootEnd);
+ } else {
+ SkASSERT(0);
+ }
+ *strPtr = str;
+}
+
+static void reader(const char* str) {
+ while (*str) {
+ ReadRoot(&str);
+ }
+}
« no previous file with comments | « experimental/docs/interpolatorFunctions.js ('k') | experimental/docs/jsonbaseddoc.htm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698