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/lib/Values_h.template

Issue 2296043004: [DevTools] Various tweaks to inspector_protocol. (Closed)
Patch Set: optional exports 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 {{"_".join(config.protocol.namespace)}}_Values_h 5 #ifndef {{"_".join(config.protocol.namespace)}}_Values_h
6 #define {{"_".join(config.protocol.namespace)}}_Values_h 6 #define {{"_".join(config.protocol.namespace)}}_Values_h
7 7
8 //#include "Allocator.h" 8 //#include "Allocator.h"
9 //#include "Collections.h" 9 //#include "Collections.h"
10 //#include "Forward.h" 10 //#include "Forward.h"
11 11
12 {% for namespace in config.protocol.namespace %} 12 {% for namespace in config.protocol.namespace %}
13 namespace {{namespace}} { 13 namespace {{namespace}} {
14 {% endfor %} 14 {% endfor %}
15 15
16 class ListValue; 16 class ListValue;
17 class DictionaryValue; 17 class DictionaryValue;
18 class Value; 18 class Value;
19 19
20 class {{config.class_export.macro}} Value { 20 class {{config.lib.export_macro}} Value {
21 PROTOCOL_DISALLOW_COPY(Value); 21 PROTOCOL_DISALLOW_COPY(Value);
22 public: 22 public:
23 virtual ~Value() { } 23 virtual ~Value() { }
24 24
25 static std::unique_ptr<Value> null() 25 static std::unique_ptr<Value> null()
26 { 26 {
27 return wrapUnique(new Value()); 27 return wrapUnique(new Value());
28 } 28 }
29 29
30 enum ValueType { 30 enum ValueType {
(...skipping 25 matching lines...) Expand all
56 Value() : m_type(TypeNull) { } 56 Value() : m_type(TypeNull) { }
57 explicit Value(ValueType type) : m_type(type) { } 57 explicit Value(ValueType type) : m_type(type) { }
58 58
59 private: 59 private:
60 friend class DictionaryValue; 60 friend class DictionaryValue;
61 friend class ListValue; 61 friend class ListValue;
62 62
63 ValueType m_type; 63 ValueType m_type;
64 }; 64 };
65 65
66 class {{config.class_export.macro}} FundamentalValue : public Value { 66 class {{config.lib.export_macro}} FundamentalValue : public Value {
67 public: 67 public:
68 static std::unique_ptr<FundamentalValue> create(bool value) 68 static std::unique_ptr<FundamentalValue> create(bool value)
69 { 69 {
70 return wrapUnique(new FundamentalValue(value)); 70 return wrapUnique(new FundamentalValue(value));
71 } 71 }
72 72
73 static std::unique_ptr<FundamentalValue> create(int value) 73 static std::unique_ptr<FundamentalValue> create(int value)
74 { 74 {
75 return wrapUnique(new FundamentalValue(value)); 75 return wrapUnique(new FundamentalValue(value));
76 } 76 }
(...skipping 14 matching lines...) Expand all
91 explicit FundamentalValue(int value) : Value(TypeInteger), m_integerValue(va lue) { } 91 explicit FundamentalValue(int value) : Value(TypeInteger), m_integerValue(va lue) { }
92 explicit FundamentalValue(double value) : Value(TypeDouble), m_doubleValue(v alue) { } 92 explicit FundamentalValue(double value) : Value(TypeDouble), m_doubleValue(v alue) { }
93 93
94 union { 94 union {
95 bool m_boolValue; 95 bool m_boolValue;
96 double m_doubleValue; 96 double m_doubleValue;
97 int m_integerValue; 97 int m_integerValue;
98 }; 98 };
99 }; 99 };
100 100
101 class {{config.class_export.macro}} StringValue : public Value { 101 class {{config.lib.export_macro}} StringValue : public Value {
102 public: 102 public:
103 static std::unique_ptr<StringValue> create(const String& value) 103 static std::unique_ptr<StringValue> create(const String& value)
104 { 104 {
105 return wrapUnique(new StringValue(value)); 105 return wrapUnique(new StringValue(value));
106 } 106 }
107 107
108 static std::unique_ptr<StringValue> create(const char* value) 108 static std::unique_ptr<StringValue> create(const char* value)
109 { 109 {
110 return wrapUnique(new StringValue(value)); 110 return wrapUnique(new StringValue(value));
111 } 111 }
112 112
113 bool asString(String* output) const override; 113 bool asString(String* output) const override;
114 void writeJSON(StringBuilder* output) const override; 114 void writeJSON(StringBuilder* output) const override;
115 std::unique_ptr<Value> clone() const override; 115 std::unique_ptr<Value> clone() const override;
116 116
117 private: 117 private:
118 explicit StringValue(const String& value) : Value(TypeString), m_stringValue (value) { } 118 explicit StringValue(const String& value) : Value(TypeString), m_stringValue (value) { }
119 explicit StringValue(const char* value) : Value(TypeString), m_stringValue(v alue) { } 119 explicit StringValue(const char* value) : Value(TypeString), m_stringValue(v alue) { }
120 120
121 String m_stringValue; 121 String m_stringValue;
122 }; 122 };
123 123
124 class {{config.class_export.macro}} SerializedValue : public Value { 124 class {{config.lib.export_macro}} SerializedValue : public Value {
125 public: 125 public:
126 static std::unique_ptr<SerializedValue> create(const String& value) 126 static std::unique_ptr<SerializedValue> create(const String& value)
127 { 127 {
128 return wrapUnique(new SerializedValue(value)); 128 return wrapUnique(new SerializedValue(value));
129 } 129 }
130 130
131 bool asSerialized(String* output) const override; 131 bool asSerialized(String* output) const override;
132 void writeJSON(StringBuilder* output) const override; 132 void writeJSON(StringBuilder* output) const override;
133 std::unique_ptr<Value> clone() const override; 133 std::unique_ptr<Value> clone() const override;
134 134
135 private: 135 private:
136 explicit SerializedValue(const String& value) : Value(TypeSerialized), m_ser ializedValue(value) { } 136 explicit SerializedValue(const String& value) : Value(TypeSerialized), m_ser ializedValue(value) { }
137 137
138 String m_serializedValue; 138 String m_serializedValue;
139 }; 139 };
140 140
141 class {{config.class_export.macro}} DictionaryValue : public Value { 141 class {{config.lib.export_macro}} DictionaryValue : public Value {
142 public: 142 public:
143 using Entry = std::pair<String, Value*>; 143 using Entry = std::pair<String, Value*>;
144 static std::unique_ptr<DictionaryValue> create() 144 static std::unique_ptr<DictionaryValue> create()
145 { 145 {
146 return wrapUnique(new DictionaryValue()); 146 return wrapUnique(new DictionaryValue());
147 } 147 }
148 148
149 static DictionaryValue* cast(Value* value) 149 static DictionaryValue* cast(Value* value)
150 { 150 {
151 if (!value || value->type() != TypeObject) 151 if (!value || value->type() != TypeObject)
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 m_data[key] = std::move(value); 198 m_data[key] = std::move(value);
199 if (isNew) 199 if (isNew)
200 m_order.push_back(key); 200 m_order.push_back(key);
201 } 201 }
202 202
203 using Dictionary = protocol::HashMap<String, std::unique_ptr<Value>>; 203 using Dictionary = protocol::HashMap<String, std::unique_ptr<Value>>;
204 Dictionary m_data; 204 Dictionary m_data;
205 std::vector<String> m_order; 205 std::vector<String> m_order;
206 }; 206 };
207 207
208 class {{config.class_export.macro}} ListValue : public Value { 208 class {{config.lib.export_macro}} ListValue : public Value {
209 public: 209 public:
210 static std::unique_ptr<ListValue> create() 210 static std::unique_ptr<ListValue> create()
211 { 211 {
212 return wrapUnique(new ListValue()); 212 return wrapUnique(new ListValue());
213 } 213 }
214 214
215 static ListValue* cast(Value* value) 215 static ListValue* cast(Value* value)
216 { 216 {
217 if (!value || value->type() != TypeArray) 217 if (!value || value->type() != TypeArray)
218 return nullptr; 218 return nullptr;
(...skipping 18 matching lines...) Expand all
237 private: 237 private:
238 ListValue(); 238 ListValue();
239 std::vector<std::unique_ptr<Value>> m_data; 239 std::vector<std::unique_ptr<Value>> m_data;
240 }; 240 };
241 241
242 {% for namespace in config.protocol.namespace %} 242 {% for namespace in config.protocol.namespace %}
243 } // namespace {{namespace}} 243 } // namespace {{namespace}}
244 {% endfor %} 244 {% endfor %}
245 245
246 #endif // {{"_".join(config.protocol.namespace)}}_Values_h 246 #endif // {{"_".join(config.protocol.namespace)}}_Values_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698