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

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

Issue 2248783003: [DevTools] Refactor CodeGenerator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: up_to_date fix 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 #ifndef Values_h 5 #ifndef Values_h
6 #define Values_h 6 #define Values_h
7 7
8 //#include "Allocator.h" 8 //#include "Allocator.h"
9 //#include "Collections.h" 9 //#include "Collections.h"
10 //#include "Platform.h" 10 //#include "Platform.h"
11 //#include "String16.h" 11 //#include "String16.h"
12 #include "{{export_macro_include}}" 12 #include "{{config.class_export.header}}"
13 13
14 #include <vector> 14 #include <vector>
15 15
16 namespace blink { 16 namespace blink {
17 namespace protocol { 17 namespace protocol {
18 18
19 class ListValue; 19 class ListValue;
20 class DictionaryValue; 20 class DictionaryValue;
21 class Value; 21 class Value;
22 22
23 class {{export_macro}} Value { 23 class {{config.class_export.macro}} Value {
24 PROTOCOL_DISALLOW_COPY(Value); 24 PROTOCOL_DISALLOW_COPY(Value);
25 public: 25 public:
26 static const int maxDepth = 1000; 26 static const int maxDepth = 1000;
27 27
28 virtual ~Value() { } 28 virtual ~Value() { }
29 29
30 static std::unique_ptr<Value> null() 30 static std::unique_ptr<Value> null()
31 { 31 {
32 return wrapUnique(new Value()); 32 return wrapUnique(new Value());
33 } 33 }
(...skipping 27 matching lines...) Expand all
61 Value() : m_type(TypeNull) { } 61 Value() : m_type(TypeNull) { }
62 explicit Value(ValueType type) : m_type(type) { } 62 explicit Value(ValueType type) : m_type(type) { }
63 63
64 private: 64 private:
65 friend class DictionaryValue; 65 friend class DictionaryValue;
66 friend class ListValue; 66 friend class ListValue;
67 67
68 ValueType m_type; 68 ValueType m_type;
69 }; 69 };
70 70
71 class {{export_macro}} FundamentalValue : public Value { 71 class {{config.class_export.macro}} FundamentalValue : public Value {
72 public: 72 public:
73 static std::unique_ptr<FundamentalValue> create(bool value) 73 static std::unique_ptr<FundamentalValue> create(bool value)
74 { 74 {
75 return wrapUnique(new FundamentalValue(value)); 75 return wrapUnique(new FundamentalValue(value));
76 } 76 }
77 77
78 static std::unique_ptr<FundamentalValue> create(int value) 78 static std::unique_ptr<FundamentalValue> create(int value)
79 { 79 {
80 return wrapUnique(new FundamentalValue(value)); 80 return wrapUnique(new FundamentalValue(value));
81 } 81 }
(...skipping 14 matching lines...) Expand all
96 explicit FundamentalValue(int value) : Value(TypeInteger), m_integerValue(va lue) { } 96 explicit FundamentalValue(int value) : Value(TypeInteger), m_integerValue(va lue) { }
97 explicit FundamentalValue(double value) : Value(TypeDouble), m_doubleValue(v alue) { } 97 explicit FundamentalValue(double value) : Value(TypeDouble), m_doubleValue(v alue) { }
98 98
99 union { 99 union {
100 bool m_boolValue; 100 bool m_boolValue;
101 double m_doubleValue; 101 double m_doubleValue;
102 int m_integerValue; 102 int m_integerValue;
103 }; 103 };
104 }; 104 };
105 105
106 class {{export_macro}} StringValue : public Value { 106 class {{config.class_export.macro}} StringValue : public Value {
107 public: 107 public:
108 static std::unique_ptr<StringValue> create(const String16& value) 108 static std::unique_ptr<StringValue> create(const String16& value)
109 { 109 {
110 return wrapUnique(new StringValue(value)); 110 return wrapUnique(new StringValue(value));
111 } 111 }
112 112
113 static std::unique_ptr<StringValue> create(const char* value) 113 static std::unique_ptr<StringValue> create(const char* value)
114 { 114 {
115 return wrapUnique(new StringValue(value)); 115 return wrapUnique(new StringValue(value));
116 } 116 }
117 117
118 bool asString(String16* output) const override; 118 bool asString(String16* output) const override;
119 void writeJSON(String16Builder* output) const override; 119 void writeJSON(String16Builder* output) const override;
120 std::unique_ptr<Value> clone() const override; 120 std::unique_ptr<Value> clone() const override;
121 121
122 private: 122 private:
123 explicit StringValue(const String16& value) : Value(TypeString), m_stringVal ue(value) { } 123 explicit StringValue(const String16& value) : Value(TypeString), m_stringVal ue(value) { }
124 explicit StringValue(const char* value) : Value(TypeString), m_stringValue(v alue) { } 124 explicit StringValue(const char* value) : Value(TypeString), m_stringValue(v alue) { }
125 125
126 String16 m_stringValue; 126 String16 m_stringValue;
127 }; 127 };
128 128
129 class {{export_macro}} SerializedValue : public Value { 129 class {{config.class_export.macro}} SerializedValue : public Value {
130 public: 130 public:
131 static std::unique_ptr<SerializedValue> create(const String16& value) 131 static std::unique_ptr<SerializedValue> create(const String16& value)
132 { 132 {
133 return wrapUnique(new SerializedValue(value)); 133 return wrapUnique(new SerializedValue(value));
134 } 134 }
135 135
136 bool asSerialized(String16* output) const override; 136 bool asSerialized(String16* output) const override;
137 void writeJSON(String16Builder* output) const override; 137 void writeJSON(String16Builder* output) const override;
138 std::unique_ptr<Value> clone() const override; 138 std::unique_ptr<Value> clone() const override;
139 139
140 private: 140 private:
141 explicit SerializedValue(const String16& value) : Value(TypeSerialized), m_s erializedValue(value) { } 141 explicit SerializedValue(const String16& value) : Value(TypeSerialized), m_s erializedValue(value) { }
142 explicit SerializedValue(const char* value) : Value(TypeSerialized), m_seria lizedValue(value) { } 142 explicit SerializedValue(const char* value) : Value(TypeSerialized), m_seria lizedValue(value) { }
143 143
144 String16 m_serializedValue; 144 String16 m_serializedValue;
145 }; 145 };
146 146
147 class {{export_macro}} DictionaryValue : public Value { 147 class {{config.class_export.macro}} DictionaryValue : public Value {
148 public: 148 public:
149 using Entry = std::pair<String16, Value*>; 149 using Entry = std::pair<String16, Value*>;
150 static std::unique_ptr<DictionaryValue> create() 150 static std::unique_ptr<DictionaryValue> create()
151 { 151 {
152 return wrapUnique(new DictionaryValue()); 152 return wrapUnique(new DictionaryValue());
153 } 153 }
154 154
155 static DictionaryValue* cast(Value* value) 155 static DictionaryValue* cast(Value* value)
156 { 156 {
157 if (!value || value->type() != TypeObject) 157 if (!value || value->type() != TypeObject)
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 m_data[key] = std::move(value); 204 m_data[key] = std::move(value);
205 if (isNew) 205 if (isNew)
206 m_order.push_back(key); 206 m_order.push_back(key);
207 } 207 }
208 208
209 using Dictionary = protocol::HashMap<String16, std::unique_ptr<Value>>; 209 using Dictionary = protocol::HashMap<String16, std::unique_ptr<Value>>;
210 Dictionary m_data; 210 Dictionary m_data;
211 std::vector<String16> m_order; 211 std::vector<String16> m_order;
212 }; 212 };
213 213
214 class {{export_macro}} ListValue : public Value { 214 class {{config.class_export.macro}} ListValue : public Value {
215 public: 215 public:
216 static std::unique_ptr<ListValue> create() 216 static std::unique_ptr<ListValue> create()
217 { 217 {
218 return wrapUnique(new ListValue()); 218 return wrapUnique(new ListValue());
219 } 219 }
220 220
221 static ListValue* cast(Value* value) 221 static ListValue* cast(Value* value)
222 { 222 {
223 if (!value || value->type() != TypeArray) 223 if (!value || value->type() != TypeArray)
224 return nullptr; 224 return nullptr;
(...skipping 17 matching lines...) Expand all
242 242
243 private: 243 private:
244 ListValue(); 244 ListValue();
245 std::vector<std::unique_ptr<Value>> m_data; 245 std::vector<std::unique_ptr<Value>> m_data;
246 }; 246 };
247 247
248 } // namespace protocol 248 } // namespace protocol
249 } // namespace blink 249 } // namespace blink
250 250
251 #endif // Values_h 251 #endif // Values_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698