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

Side by Side Diff: third_party/WebKit/Source/platform/inspector_protocol/Values_cpp.template

Issue 2238423002: [DevTools] Generate all files in inspector_protocol. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2240663003
Patch Set: Created 4 years, 4 months 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/inspector_protocol/Values.h"
6
7 #include "platform/inspector_protocol/Parser.h"
8 #include "platform/inspector_protocol/String16.h"
9
10 #include <algorithm> 5 #include <algorithm>
11 #include <cmath> 6 #include <cmath>
12 7
13 namespace blink { 8 namespace blink {
14 namespace protocol { 9 namespace protocol {
15 10
16 namespace { 11 namespace {
17 12
18 const char* const nullString = "null"; 13 const char* const nullValueString = "null";
19 const char* const trueString = "true"; 14 const char* const trueValueString = "true";
20 const char* const falseString = "false"; 15 const char* const falseValueString = "false";
21 16
22 inline bool escapeChar(UChar c, String16Builder* dst) 17 inline bool escapeChar(UChar c, String16Builder* dst)
23 { 18 {
24 switch (c) { 19 switch (c) {
25 case '\b': dst->append("\\b"); break; 20 case '\b': dst->append("\\b"); break;
26 case '\f': dst->append("\\f"); break; 21 case '\f': dst->append("\\f"); break;
27 case '\n': dst->append("\\n"); break; 22 case '\n': dst->append("\\n"); break;
28 case '\r': dst->append("\\r"); break; 23 case '\r': dst->append("\\r"); break;
29 case '\t': dst->append("\\t"); break; 24 case '\t': dst->append("\\t"); break;
30 case '\\': dst->append("\\\\"); break; 25 case '\\': dst->append("\\\\"); break;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 { 97 {
103 String16Builder result; 98 String16Builder result;
104 result.reserveCapacity(512); 99 result.reserveCapacity(512);
105 writeJSON(&result); 100 writeJSON(&result);
106 return result.toString(); 101 return result.toString();
107 } 102 }
108 103
109 void Value::writeJSON(String16Builder* output) const 104 void Value::writeJSON(String16Builder* output) const
110 { 105 {
111 DCHECK(m_type == TypeNull); 106 DCHECK(m_type == TypeNull);
112 output->append(nullString, 4); 107 output->append(nullValueString, 4);
113 } 108 }
114 109
115 std::unique_ptr<Value> Value::clone() const 110 std::unique_ptr<Value> Value::clone() const
116 { 111 {
117 return Value::null(); 112 return Value::null();
118 } 113 }
119 114
120 bool FundamentalValue::asBoolean(bool* output) const 115 bool FundamentalValue::asBoolean(bool* output) const
121 { 116 {
122 if (type() != TypeBoolean) 117 if (type() != TypeBoolean)
(...skipping 21 matching lines...) Expand all
144 return false; 139 return false;
145 *output = m_integerValue; 140 *output = m_integerValue;
146 return true; 141 return true;
147 } 142 }
148 143
149 void FundamentalValue::writeJSON(String16Builder* output) const 144 void FundamentalValue::writeJSON(String16Builder* output) const
150 { 145 {
151 DCHECK(type() == TypeBoolean || type() == TypeInteger || type() == TypeDoubl e); 146 DCHECK(type() == TypeBoolean || type() == TypeInteger || type() == TypeDoubl e);
152 if (type() == TypeBoolean) { 147 if (type() == TypeBoolean) {
153 if (m_boolValue) 148 if (m_boolValue)
154 output->append(trueString, 4); 149 output->append(trueValueString, 4);
155 else 150 else
156 output->append(falseString, 5); 151 output->append(falseValueString, 5);
157 } else if (type() == TypeDouble) { 152 } else if (type() == TypeDouble) {
158 if (!std::isfinite(m_doubleValue)) { 153 if (!std::isfinite(m_doubleValue)) {
159 output->append(nullString, 4); 154 output->append(nullValueString, 4);
160 return; 155 return;
161 } 156 }
162 output->append(String16::fromDouble(m_doubleValue)); 157 output->append(String16::fromDouble(m_doubleValue));
163 } else if (type() == TypeInteger) { 158 } else if (type() == TypeInteger) {
164 output->append(String16::fromInteger(m_integerValue)); 159 output->append(String16::fromInteger(m_integerValue));
165 } 160 }
166 } 161 }
167 162
168 std::unique_ptr<Value> FundamentalValue::clone() const 163 std::unique_ptr<Value> FundamentalValue::clone() const
169 { 164 {
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 } 397 }
403 398
404 protocol::Value* ListValue::at(size_t index) 399 protocol::Value* ListValue::at(size_t index)
405 { 400 {
406 DCHECK_LT(index, m_data.size()); 401 DCHECK_LT(index, m_data.size());
407 return m_data[index].get(); 402 return m_data[index].get();
408 } 403 }
409 404
410 } // namespace protocol 405 } // namespace protocol
411 } // namespace blink 406 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698