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

Side by Side Diff: runtime/vm/json_stream.h

Issue 542363003: Don't double-escape in strings in the VM Service, and don't use \u0000 to determine the string lengt (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: build Created 6 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 | Annotate | Revision Log
« no previous file with comments | « runtime/bin/vmservice/observatory/tests/ui/inspector.dart ('k') | runtime/vm/json_stream.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 String;
23 class Metric; 24 class Metric;
24 class Zone; 25 class Zone;
25 26
26 class JSONStream : ValueObject { 27 class JSONStream : ValueObject {
27 public: 28 public:
28 explicit JSONStream(intptr_t buf_size = 256); 29 explicit JSONStream(intptr_t buf_size = 256);
29 ~JSONStream(); 30 ~JSONStream();
30 31
31 void Setup(Zone* zone, 32 void Setup(Zone* zone,
32 Dart_Port reply_port, 33 Dart_Port reply_port,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 void CloseObject(); 78 void CloseObject();
78 79
79 void OpenArray(const char* property_name = NULL); 80 void OpenArray(const char* property_name = NULL);
80 void CloseArray(); 81 void CloseArray();
81 82
82 void PrintValueBool(bool b); 83 void PrintValueBool(bool b);
83 void PrintValue(intptr_t i); 84 void PrintValue(intptr_t i);
84 void PrintValue64(int64_t i); 85 void PrintValue64(int64_t i);
85 void PrintValue(double d); 86 void PrintValue(double d);
86 void PrintValue(const char* s); 87 void PrintValue(const char* s);
88 void PrintValue(const char* s, intptr_t len);
87 void PrintValueNoEscape(const char* s); 89 void PrintValueNoEscape(const char* s);
88 void PrintfValue(const char* format, ...) PRINTF_ATTRIBUTE(2, 3); 90 void PrintfValue(const char* format, ...) PRINTF_ATTRIBUTE(2, 3);
89 void PrintValue(const Object& o, bool ref = true); 91 void PrintValue(const Object& o, bool ref = true);
90 void PrintValue(SourceBreakpoint* bpt); 92 void PrintValue(SourceBreakpoint* bpt);
91 void PrintValue(const DebuggerEvent* event); 93 void PrintValue(const DebuggerEvent* event);
92 void PrintValue(Metric* metric); 94 void PrintValue(Metric* metric);
93 void PrintValue(Isolate* isolate, bool ref = true); 95 void PrintValue(Isolate* isolate, bool ref = true);
94 96
95 void PrintPropertyBool(const char* name, bool b); 97 void PrintPropertyBool(const char* name, bool b);
96 void PrintProperty(const char* name, intptr_t i); 98 void PrintProperty(const char* name, intptr_t i);
97 void PrintProperty64(const char* name, int64_t i); 99 void PrintProperty64(const char* name, int64_t i);
98 void PrintProperty(const char* name, double d); 100 void PrintProperty(const char* name, double d);
99 void PrintProperty(const char* name, const char* s); 101 void PrintProperty(const char* name, const char* s);
102 void PrintProperty(const char* name, const char* s, intptr_t len);
100 void PrintPropertyNoEscape(const char* name, const char* s); 103 void PrintPropertyNoEscape(const char* name, const char* s);
101 void PrintfProperty(const char* name, const char* format, ...) 104 void PrintfProperty(const char* name, const char* format, ...)
102 PRINTF_ATTRIBUTE(3, 4); 105 PRINTF_ATTRIBUTE(3, 4);
103 void PrintProperty(const char* name, const Object& o, bool ref = true); 106 void PrintProperty(const char* name, const Object& o, bool ref = true);
104 107
105 void PrintProperty(const char* name, const DebuggerEvent* event); 108 void PrintProperty(const char* name, const DebuggerEvent* event);
106 void PrintProperty(const char* name, SourceBreakpoint* bpt); 109 void PrintProperty(const char* name, SourceBreakpoint* bpt);
107 void PrintProperty(const char* name, Metric* metric); 110 void PrintProperty(const char* name, Metric* metric);
108 void PrintProperty(const char* name, Isolate* isolate); 111 void PrintProperty(const char* name, Isolate* isolate);
109 void PrintPropertyName(const char* name); 112 void PrintPropertyName(const char* name);
110 void PrintCommaIfNeeded(); 113 void PrintCommaIfNeeded();
111 bool NeedComma(); 114 bool NeedComma();
112 115
113 void AddEscapedUTF8String(const char* s); 116 void AddEscapedUTF8String(const char* s);
117 void AddEscapedUTF8String(const char* s, intptr_t len);
114 118
115 intptr_t nesting_level() const { return open_objects_; } 119 intptr_t nesting_level() const { return open_objects_; }
116 120
117 intptr_t open_objects_; 121 intptr_t open_objects_;
118 TextBuffer buffer_; 122 TextBuffer buffer_;
119 Dart_Port reply_port_; 123 Dart_Port reply_port_;
120 const char* command_; 124 const char* command_;
121 const char** arguments_; 125 const char** arguments_;
122 intptr_t num_arguments_; 126 intptr_t num_arguments_;
123 const char** option_keys_; 127 const char** option_keys_;
(...skipping 28 matching lines...) Expand all
152 } 156 }
153 void AddProperty64(const char* name, int64_t i) const { 157 void AddProperty64(const char* name, int64_t i) const {
154 stream_->PrintProperty64(name, i); 158 stream_->PrintProperty64(name, i);
155 } 159 }
156 void AddProperty(const char* name, double d) const { 160 void AddProperty(const char* name, double d) const {
157 stream_->PrintProperty(name, d); 161 stream_->PrintProperty(name, d);
158 } 162 }
159 void AddProperty(const char* name, const char* s) const { 163 void AddProperty(const char* name, const char* s) const {
160 stream_->PrintProperty(name, s); 164 stream_->PrintProperty(name, s);
161 } 165 }
166 void AddProperty(const char* name, const char* s, intptr_t len) const {
167 stream_->PrintProperty(name, s, len);
168 }
162 void AddPropertyNoEscape(const char* name, const char* s) const { 169 void AddPropertyNoEscape(const char* name, const char* s) const {
163 stream_->PrintPropertyNoEscape(name, s); 170 stream_->PrintPropertyNoEscape(name, s);
164 } 171 }
165 void AddProperty(const char* name, const Object& obj, bool ref = true) const { 172 void AddProperty(const char* name, const Object& obj, bool ref = true) const {
166 stream_->PrintProperty(name, obj, ref); 173 stream_->PrintProperty(name, obj, ref);
167 } 174 }
168 void AddProperty(const char* name, const DebuggerEvent* event) const { 175 void AddProperty(const char* name, const DebuggerEvent* event) const {
169 stream_->PrintProperty(name, event); 176 stream_->PrintProperty(name, event);
170 } 177 }
171 void AddProperty(const char* name, SourceBreakpoint* bpt) const { 178 void AddProperty(const char* name, SourceBreakpoint* bpt) const {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 239
233 friend class JSONObject; 240 friend class JSONObject;
234 241
235 DISALLOW_ALLOCATION(); 242 DISALLOW_ALLOCATION();
236 DISALLOW_COPY_AND_ASSIGN(JSONArray); 243 DISALLOW_COPY_AND_ASSIGN(JSONArray);
237 }; 244 };
238 245
239 } // namespace dart 246 } // namespace dart
240 247
241 #endif // VM_JSON_STREAM_H_ 248 #endif // VM_JSON_STREAM_H_
OLDNEW
« no previous file with comments | « runtime/bin/vmservice/observatory/tests/ui/inspector.dart ('k') | runtime/vm/json_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698