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 #include "platform/assert.h" | 5 #include "platform/assert.h" |
6 #include "vm/object.h" | 6 #include "vm/object.h" |
7 #include "vm/debugger.h" | 7 #include "vm/debugger.h" |
8 #include "vm/json_stream.h" | 8 #include "vm/json_stream.h" |
9 | 9 |
10 | 10 |
11 namespace dart { | 11 namespace dart { |
12 | 12 |
13 JSONStream::JSONStream(intptr_t buf_size) : buffer_(buf_size) { | 13 JSONStream::JSONStream(intptr_t buf_size) |
14 open_objects_ = 0; | 14 : open_objects_(0), |
15 arguments_ = NULL; | 15 buffer_(buf_size), |
16 num_arguments_ = 0; | 16 reply_port_(ILLEGAL_PORT), |
17 option_keys_ = NULL; | 17 arguments_(NULL), |
18 option_values_ = NULL; | 18 num_arguments_(0), |
19 num_options_ = 0; | 19 option_keys_(NULL), |
| 20 option_values_(NULL), |
| 21 num_options_(0) { |
20 } | 22 } |
21 | 23 |
22 | 24 |
23 JSONStream::~JSONStream() { | 25 JSONStream::~JSONStream() { |
24 } | 26 } |
25 | 27 |
26 | 28 |
27 const char* JSONStream::LookupOption(const char* key) const { | 29 const char* JSONStream::LookupOption(const char* key) const { |
28 for (int i = 0; i < num_options(); i++) { | 30 for (int i = 0; i < num_options(); i++) { |
29 if (!strcmp(key, option_keys_[i])) { | 31 if (!strcmp(key, option_keys_[i])) { |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 intptr_t len2 = OS::VSNPrint(p, len+1, format, args); | 176 intptr_t len2 = OS::VSNPrint(p, len+1, format, args); |
175 va_end(args); | 177 va_end(args); |
176 ASSERT(len == len2); | 178 ASSERT(len == len2); |
177 buffer_.AddChar('"'); | 179 buffer_.AddChar('"'); |
178 buffer_.AddEscapedString(p); | 180 buffer_.AddEscapedString(p); |
179 buffer_.AddChar('"'); | 181 buffer_.AddChar('"'); |
180 free(p); | 182 free(p); |
181 } | 183 } |
182 | 184 |
183 | 185 |
| 186 void JSONStream::set_reply_port(Dart_Port port) { |
| 187 reply_port_ = port; |
| 188 } |
| 189 |
| 190 |
184 void JSONStream::SetArguments(const char** arguments, intptr_t num_arguments) { | 191 void JSONStream::SetArguments(const char** arguments, intptr_t num_arguments) { |
185 arguments_ = arguments; | 192 arguments_ = arguments; |
186 num_arguments_ = num_arguments; | 193 num_arguments_ = num_arguments; |
187 } | 194 } |
188 | 195 |
189 | 196 |
190 void JSONStream::SetOptions(const char** option_keys, | 197 void JSONStream::SetOptions(const char** option_keys, |
191 const char** option_values, | 198 const char** option_values, |
192 intptr_t num_options) { | 199 intptr_t num_options) { |
193 option_keys_ = option_keys; | 200 option_keys_ = option_keys; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 intptr_t len2 = OS::VSNPrint(p, len+1, format, args); | 272 intptr_t len2 = OS::VSNPrint(p, len+1, format, args); |
266 va_end(args); | 273 va_end(args); |
267 ASSERT(len == len2); | 274 ASSERT(len == len2); |
268 stream_->buffer_.AddChar('"'); | 275 stream_->buffer_.AddChar('"'); |
269 stream_->buffer_.AddEscapedString(p); | 276 stream_->buffer_.AddEscapedString(p); |
270 stream_->buffer_.AddChar('"'); | 277 stream_->buffer_.AddChar('"'); |
271 free(p); | 278 free(p); |
272 } | 279 } |
273 | 280 |
274 } // namespace dart | 281 } // namespace dart |
OLD | NEW |