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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « experimental/docs/interpolatorFunctions.js ('k') | experimental/docs/jsonbaseddoc.htm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2006 The Android Open Source Project
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "SkTArray.h"
9 #include "SkTDict.h"
10 #include "SkString.h"
11
12 enum ReadState {
13 kRoot_ReadState,
14
15 };
16
17 static bool isToken(const char* s, const char* e) {
18 SkASSERT(s < e);
19 while (s < e) {
20 char c = *s++;
21 char u = c & ~0x20;
22 if ((u < 'A' || u > 'Z') && (c < '0' || c > '9') && c != '_') {
23 return false;
24 }
25 }
26 return true;
27 }
28
29 static void skpWhiteSpace(const char** strPtr) {
30 const char* str = *strPtr;
31 while (*str && *str <= ' ') {
32 str++;
33 }
34 *strPtr = str;
35 }
36
37 static void ReadRoot(const char** strPtr) {
38 skipWhiteSpace(strPtr);
39 const char* str = *strPtr;
40 const char kVarStr[] = "var ";
41 SkASSERT(SkStrStartsWith(str, kVarStr));
42 const char* rootVar = str + sizeof(kVarStr) - 1;
43 const char* rootEnd = strchr(rootVar, ' ');
44 SkASSERT(rootEnd);
45 SkASSERT(isToken(rootVar, rootEnd));
46 const char* rootAssign = rootEnd;
47 skipWhiteSpace(rootAssign);
48 SkASSERT(rootAssign[0] == '=');
49 const char* rootData = rootAssign + 1;
50 SkASSERT(rootData[0]);
51 skipWhiteSpace(rootData);
52 if (rootData[0] == '{') {
53 addObject(rootVar, rootEnd);
54 } else if (rootData[0] == '[') {
55 addArray(rootVar, rootEnd);
56 } else {
57 SkASSERT(0);
58 }
59 *strPtr = str;
60 }
61
62 static void reader(const char* str) {
63 while (*str) {
64 ReadRoot(&str);
65 }
66 }
OLDNEW
« 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