| 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/json_stream.h" | 7 #include "vm/json_stream.h" |
| 8 | 8 |
| 9 | 9 |
| 10 namespace dart { | 10 namespace dart { |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 const char* buffer = buffer_.buf(); | 198 const char* buffer = buffer_.buf(); |
| 199 intptr_t length = buffer_.length(); | 199 intptr_t length = buffer_.length(); |
| 200 if (length == 0) { | 200 if (length == 0) { |
| 201 return false; | 201 return false; |
| 202 } | 202 } |
| 203 char ch = buffer[length-1]; | 203 char ch = buffer[length-1]; |
| 204 return (ch != '[') && (ch != '{') && (ch != ':') && (ch != ','); | 204 return (ch != '[') && (ch != '{') && (ch != ':') && (ch != ','); |
| 205 } | 205 } |
| 206 | 206 |
| 207 | 207 |
| 208 JSONObject::JSONObject(const JSONArray& arr) : stream_(arr.stream_) { | 208 JSONObject::JSONObject(const JSONArray* arr) : stream_(arr->stream_) { |
| 209 stream_->OpenObject(); | 209 stream_->OpenObject(); |
| 210 } | 210 } |
| 211 | 211 |
| 212 | 212 |
| 213 void JSONObject::AddPropertyF(const char* name, | 213 void JSONObject::AddPropertyF(const char* name, |
| 214 const char* format, ...) const { | 214 const char* format, ...) const { |
| 215 stream_->PrintPropertyName(name); | 215 stream_->PrintPropertyName(name); |
| 216 va_list args; | 216 va_list args; |
| 217 va_start(args, format); | 217 va_start(args, format); |
| 218 intptr_t len = OS::VSNPrint(NULL, 0, format, args); | 218 intptr_t len = OS::VSNPrint(NULL, 0, format, args); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 241 va_end(args); | 241 va_end(args); |
| 242 ASSERT(len == len2); | 242 ASSERT(len == len2); |
| 243 stream_->buffer_.AddChar('"'); | 243 stream_->buffer_.AddChar('"'); |
| 244 stream_->buffer_.AddEscapedString(p); | 244 stream_->buffer_.AddEscapedString(p); |
| 245 stream_->buffer_.AddChar('"'); | 245 stream_->buffer_.AddChar('"'); |
| 246 free(p); | 246 free(p); |
| 247 } | 247 } |
| 248 | 248 |
| 249 } // namespace dart | 249 } // namespace dart |
| 250 | 250 |
| OLD | NEW |