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

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

Issue 2251343003: [DevTools] Generate separate copies of inspector_protocol. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: win compile Created 4 years, 3 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 #ifndef ValueConversions_h 5 #ifndef {{"_".join(config.protocol.namespace)}}_ValueConversions_h
6 #define ValueConversions_h 6 #define {{"_".join(config.protocol.namespace)}}_ValueConversions_h
7 7
8 //#include "ErrorSupport.h" 8 //#include "ErrorSupport.h"
9 //#include "Platform.h" 9 //#include "Forward.h"
10 //#include "String16.h"
11 //#include "Values.h" 10 //#include "Values.h"
12 11
13 namespace blink { 12 {% for namespace in config.protocol.namespace %}
14 namespace protocol { 13 namespace {{namespace}} {
14 {% endfor %}
15 15
16 template<typename T> 16 template<typename T>
17 struct ValueConversions { 17 struct ValueConversions {
18 static std::unique_ptr<T> parse(protocol::Value* value, ErrorSupport* errors ) 18 static std::unique_ptr<T> parse(protocol::Value* value, ErrorSupport* errors )
19 { 19 {
20 return T::parse(value, errors); 20 return T::parse(value, errors);
21 } 21 }
22 22
23 static std::unique_ptr<protocol::Value> serialize(T* value) 23 static std::unique_ptr<protocol::Value> serialize(T* value)
24 { 24 {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 return result; 76 return result;
77 } 77 }
78 78
79 static std::unique_ptr<protocol::Value> serialize(double value) 79 static std::unique_ptr<protocol::Value> serialize(double value)
80 { 80 {
81 return FundamentalValue::create(value); 81 return FundamentalValue::create(value);
82 } 82 }
83 }; 83 };
84 84
85 template<> 85 template<>
86 struct ValueConversions<InspectorProtocolConvenienceStringType> { 86 struct ValueConversions<String> {
87 static InspectorProtocolConvenienceStringType parse(protocol::Value* value, ErrorSupport* errors) 87 static String parse(protocol::Value* value, ErrorSupport* errors)
88 { 88 {
89 String16 result; 89 String result;
90 bool success = value ? value->asString(&result) : false; 90 bool success = value ? value->asString(&result) : false;
91 if (!success) 91 if (!success)
92 errors->addError("string value expected"); 92 errors->addError("string value expected");
93 return result; 93 return result;
94 } 94 }
95 95
96 static std::unique_ptr<protocol::Value> serialize(const InspectorProtocolCon venienceStringType& value) 96 static std::unique_ptr<protocol::Value> serialize(const String& value)
97 { 97 {
98 return StringValue::create(value); 98 return StringValue::create(value);
99 } 99 }
100 };
101
102 template<>
103 struct ValueConversions<String16> {
104 static String16 parse(protocol::Value* value, ErrorSupport* errors)
105 {
106 String16 result;
107 bool success = value ? value->asString(&result) : false;
108 if (!success)
109 errors->addError("string value expected");
110 return result;
111 }
112
113 static std::unique_ptr<protocol::Value> serialize(const String16& value)
114 {
115 return StringValue::create(value);
116 }
117 }; 100 };
118 101
119 template<> 102 template<>
120 struct ValueConversions<Value> { 103 struct ValueConversions<Value> {
121 static std::unique_ptr<Value> parse(protocol::Value* value, ErrorSupport* er rors) 104 static std::unique_ptr<Value> parse(protocol::Value* value, ErrorSupport* er rors)
122 { 105 {
123 bool success = !!value; 106 bool success = !!value;
124 if (!success) { 107 if (!success) {
125 errors->addError("value expected"); 108 errors->addError("value expected");
126 return nullptr; 109 return nullptr;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 { 157 {
175 return value->clone(); 158 return value->clone();
176 } 159 }
177 160
178 static std::unique_ptr<protocol::Value> serialize(const std::unique_ptr<List Value>& value) 161 static std::unique_ptr<protocol::Value> serialize(const std::unique_ptr<List Value>& value)
179 { 162 {
180 return value->clone(); 163 return value->clone();
181 } 164 }
182 }; 165 };
183 166
184 } // namespace platform 167 {% for namespace in config.protocol.namespace %}
185 } // namespace blink 168 } // namespace {{namespace}}
169 {% endfor %}
186 170
187 #endif // !defined(ValueConversions_h) 171 #endif // !defined({{"_".join(config.protocol.namespace)}}_ValueConversions_h)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698