OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef VM_JSON_STREAM_H_ | 5 #ifndef VM_JSON_STREAM_H_ |
6 #define VM_JSON_STREAM_H_ | 6 #define VM_JSON_STREAM_H_ |
7 | 7 |
8 #include "include/dart_api.h" // for Dart_Port | 8 #include "include/dart_api.h" // for Dart_Port |
9 #include "platform/json.h" | 9 #include "platform/json.h" |
10 #include "vm/allocation.h" | 10 #include "vm/allocation.h" |
11 | 11 |
12 namespace dart { | 12 namespace dart { |
13 | 13 |
14 class DebuggerEvent; | 14 class DebuggerEvent; |
15 class Field; | 15 class Field; |
16 class Array; | 16 class Array; |
17 class GrowableObjectArray; | 17 class GrowableObjectArray; |
18 class Instance; | 18 class Instance; |
19 class JSONArray; | 19 class JSONArray; |
20 class JSONObject; | 20 class JSONObject; |
21 class Object; | 21 class Object; |
22 class SourceBreakpoint; | 22 class SourceBreakpoint; |
| 23 class Metric; |
23 class Zone; | 24 class Zone; |
24 | 25 |
25 class JSONStream : ValueObject { | 26 class JSONStream : ValueObject { |
26 public: | 27 public: |
27 explicit JSONStream(intptr_t buf_size = 256); | 28 explicit JSONStream(intptr_t buf_size = 256); |
28 ~JSONStream(); | 29 ~JSONStream(); |
29 | 30 |
30 void Setup(Zone* zone, | 31 void Setup(Zone* zone, |
31 Dart_Port reply_port, | 32 Dart_Port reply_port, |
32 const GrowableObjectArray& path, | 33 const GrowableObjectArray& path, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 void PrintValueBool(bool b); | 82 void PrintValueBool(bool b); |
82 void PrintValue(intptr_t i); | 83 void PrintValue(intptr_t i); |
83 void PrintValue64(int64_t i); | 84 void PrintValue64(int64_t i); |
84 void PrintValue(double d); | 85 void PrintValue(double d); |
85 void PrintValue(const char* s); | 86 void PrintValue(const char* s); |
86 void PrintValueNoEscape(const char* s); | 87 void PrintValueNoEscape(const char* s); |
87 void PrintfValue(const char* format, ...) PRINTF_ATTRIBUTE(2, 3); | 88 void PrintfValue(const char* format, ...) PRINTF_ATTRIBUTE(2, 3); |
88 void PrintValue(const Object& o, bool ref = true); | 89 void PrintValue(const Object& o, bool ref = true); |
89 void PrintValue(SourceBreakpoint* bpt); | 90 void PrintValue(SourceBreakpoint* bpt); |
90 void PrintValue(const DebuggerEvent* event); | 91 void PrintValue(const DebuggerEvent* event); |
| 92 void PrintValue(Metric* metric); |
91 void PrintValue(Isolate* isolate, bool ref = true); | 93 void PrintValue(Isolate* isolate, bool ref = true); |
92 | 94 |
93 void PrintPropertyBool(const char* name, bool b); | 95 void PrintPropertyBool(const char* name, bool b); |
94 void PrintProperty(const char* name, intptr_t i); | 96 void PrintProperty(const char* name, intptr_t i); |
95 void PrintProperty64(const char* name, int64_t i); | 97 void PrintProperty64(const char* name, int64_t i); |
96 void PrintProperty(const char* name, double d); | 98 void PrintProperty(const char* name, double d); |
97 void PrintProperty(const char* name, const char* s); | 99 void PrintProperty(const char* name, const char* s); |
98 void PrintPropertyNoEscape(const char* name, const char* s); | 100 void PrintPropertyNoEscape(const char* name, const char* s); |
99 void PrintfProperty(const char* name, const char* format, ...) | 101 void PrintfProperty(const char* name, const char* format, ...) |
100 PRINTF_ATTRIBUTE(3, 4); | 102 PRINTF_ATTRIBUTE(3, 4); |
101 void PrintProperty(const char* name, const Object& o, bool ref = true); | 103 void PrintProperty(const char* name, const Object& o, bool ref = true); |
102 | 104 |
103 void PrintProperty(const char* name, const DebuggerEvent* event); | 105 void PrintProperty(const char* name, const DebuggerEvent* event); |
104 void PrintProperty(const char* name, SourceBreakpoint* bpt); | 106 void PrintProperty(const char* name, SourceBreakpoint* bpt); |
| 107 void PrintProperty(const char* name, Metric* metric); |
105 void PrintProperty(const char* name, Isolate* isolate); | 108 void PrintProperty(const char* name, Isolate* isolate); |
106 void PrintPropertyName(const char* name); | 109 void PrintPropertyName(const char* name); |
107 void PrintCommaIfNeeded(); | 110 void PrintCommaIfNeeded(); |
108 bool NeedComma(); | 111 bool NeedComma(); |
109 | 112 |
110 void AddEscapedUTF8String(const char* s); | 113 void AddEscapedUTF8String(const char* s); |
111 | 114 |
112 intptr_t nesting_level() const { return open_objects_; } | 115 intptr_t nesting_level() const { return open_objects_; } |
113 | 116 |
114 intptr_t open_objects_; | 117 intptr_t open_objects_; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 } | 164 } |
162 void AddProperty(const char* name, const Object& obj, bool ref = true) const { | 165 void AddProperty(const char* name, const Object& obj, bool ref = true) const { |
163 stream_->PrintProperty(name, obj, ref); | 166 stream_->PrintProperty(name, obj, ref); |
164 } | 167 } |
165 void AddProperty(const char* name, const DebuggerEvent* event) const { | 168 void AddProperty(const char* name, const DebuggerEvent* event) const { |
166 stream_->PrintProperty(name, event); | 169 stream_->PrintProperty(name, event); |
167 } | 170 } |
168 void AddProperty(const char* name, SourceBreakpoint* bpt) const { | 171 void AddProperty(const char* name, SourceBreakpoint* bpt) const { |
169 stream_->PrintProperty(name, bpt); | 172 stream_->PrintProperty(name, bpt); |
170 } | 173 } |
| 174 void AddProperty(const char* name, Metric* metric) const { |
| 175 stream_->PrintProperty(name, metric); |
| 176 } |
171 void AddProperty(const char* name, Isolate* isolate) const { | 177 void AddProperty(const char* name, Isolate* isolate) const { |
172 stream_->PrintProperty(name, isolate); | 178 stream_->PrintProperty(name, isolate); |
173 } | 179 } |
174 void AddPropertyF(const char* name, const char* format, ...) const | 180 void AddPropertyF(const char* name, const char* format, ...) const |
175 PRINTF_ATTRIBUTE(3, 4); | 181 PRINTF_ATTRIBUTE(3, 4); |
176 | 182 |
177 private: | 183 private: |
178 JSONStream* stream_; | 184 JSONStream* stream_; |
179 | 185 |
180 friend class JSONArray; | 186 friend class JSONArray; |
(...skipping 28 matching lines...) Expand all Loading... |
209 } | 215 } |
210 void AddValue(Isolate* isolate, bool ref = true) const { | 216 void AddValue(Isolate* isolate, bool ref = true) const { |
211 stream_->PrintValue(isolate, ref); | 217 stream_->PrintValue(isolate, ref); |
212 } | 218 } |
213 void AddValue(SourceBreakpoint* bpt) const { | 219 void AddValue(SourceBreakpoint* bpt) const { |
214 stream_->PrintValue(bpt); | 220 stream_->PrintValue(bpt); |
215 } | 221 } |
216 void AddValue(const DebuggerEvent* event) const { | 222 void AddValue(const DebuggerEvent* event) const { |
217 stream_->PrintValue(event); | 223 stream_->PrintValue(event); |
218 } | 224 } |
| 225 void AddValue(Metric* metric) const { |
| 226 stream_->PrintValue(metric); |
| 227 } |
219 void AddValueF(const char* format, ...) const PRINTF_ATTRIBUTE(2, 3); | 228 void AddValueF(const char* format, ...) const PRINTF_ATTRIBUTE(2, 3); |
220 | 229 |
221 private: | 230 private: |
222 JSONStream* stream_; | 231 JSONStream* stream_; |
223 | 232 |
224 friend class JSONObject; | 233 friend class JSONObject; |
225 | 234 |
226 DISALLOW_ALLOCATION(); | 235 DISALLOW_ALLOCATION(); |
227 DISALLOW_COPY_AND_ASSIGN(JSONArray); | 236 DISALLOW_COPY_AND_ASSIGN(JSONArray); |
228 }; | 237 }; |
229 | 238 |
230 } // namespace dart | 239 } // namespace dart |
231 | 240 |
232 #endif // VM_JSON_STREAM_H_ | 241 #endif // VM_JSON_STREAM_H_ |
OLD | NEW |