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

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

Issue 1157173005: Include 'fixedId' key when printing service ids (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « runtime/vm/json_stream.h ('k') | runtime/vm/json_test.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 #include "platform/assert.h" 5 #include "platform/assert.h"
6 6
7 #include "vm/dart_entry.h" 7 #include "vm/dart_entry.h"
8 #include "vm/debugger.h" 8 #include "vm/debugger.h"
9 #include "vm/json_stream.h" 9 #include "vm/json_stream.h"
10 #include "vm/message.h" 10 #include "vm/message.h"
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 queue->PrintJSON(this); 350 queue->PrintJSON(this);
351 } 351 }
352 352
353 353
354 void JSONStream::PrintValue(Isolate* isolate, bool ref) { 354 void JSONStream::PrintValue(Isolate* isolate, bool ref) {
355 PrintCommaIfNeeded(); 355 PrintCommaIfNeeded();
356 isolate->PrintJSON(this, ref); 356 isolate->PrintJSON(this, ref);
357 } 357 }
358 358
359 359
360 void JSONStream::PrintServiceId(const char* name, const Object& o) { 360 void JSONStream::PrintServiceId(const Object& o) {
361 ASSERT(id_zone_ != NULL); 361 ASSERT(id_zone_ != NULL);
362 PrintProperty(name, id_zone_->GetServiceId(o)); 362 PrintProperty("id", id_zone_->GetServiceId(o));
363 } 363 }
364 364
365 365
366 void JSONStream::PrintPropertyBool(const char* name, bool b) { 366 void JSONStream::PrintPropertyBool(const char* name, bool b) {
367 PrintPropertyName(name); 367 PrintPropertyName(name);
368 PrintValueBool(b); 368 PrintValueBool(b);
369 } 369 }
370 370
371 371
372 void JSONStream::PrintProperty(const char* name, intptr_t i) { 372 void JSONStream::PrintProperty(const char* name, intptr_t i) {
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 } 551 }
552 return did_truncate; 552 return did_truncate;
553 } 553 }
554 554
555 555
556 JSONObject::JSONObject(const JSONArray* arr) : stream_(arr->stream_) { 556 JSONObject::JSONObject(const JSONArray* arr) : stream_(arr->stream_) {
557 stream_->OpenObject(); 557 stream_->OpenObject();
558 } 558 }
559 559
560 560
561 void JSONObject::AddFixedServiceId(const char* format, ...) const {
562 // Mark that this id is fixed.
563 AddProperty("fixedId", true);
564 // Add the id property.
565 stream_->PrintPropertyName("id");
566 va_list args;
567 va_start(args, format);
568 intptr_t len = OS::VSNPrint(NULL, 0, format, args);
569 va_end(args);
570 char* p = reinterpret_cast<char*>(malloc(len+1));
571 va_start(args, format);
572 intptr_t len2 = OS::VSNPrint(p, len+1, format, args);
573 va_end(args);
574 ASSERT(len == len2);
575 stream_->buffer_.AddChar('"');
576 stream_->AddEscapedUTF8String(p);
577 stream_->buffer_.AddChar('"');
578 free(p);
579 }
580
581
561 void JSONObject::AddPropertyF(const char* name, 582 void JSONObject::AddPropertyF(const char* name,
562 const char* format, ...) const { 583 const char* format, ...) const {
563 stream_->PrintPropertyName(name); 584 stream_->PrintPropertyName(name);
564 va_list args; 585 va_list args;
565 va_start(args, format); 586 va_start(args, format);
566 intptr_t len = OS::VSNPrint(NULL, 0, format, args); 587 intptr_t len = OS::VSNPrint(NULL, 0, format, args);
567 va_end(args); 588 va_end(args);
568 char* p = reinterpret_cast<char*>(malloc(len+1)); 589 char* p = reinterpret_cast<char*>(malloc(len+1));
569 va_start(args, format); 590 va_start(args, format);
570 intptr_t len2 = OS::VSNPrint(p, len+1, format, args); 591 intptr_t len2 = OS::VSNPrint(p, len+1, format, args);
(...skipping 17 matching lines...) Expand all
588 intptr_t len2 = OS::VSNPrint(p, len+1, format, args); 609 intptr_t len2 = OS::VSNPrint(p, len+1, format, args);
589 va_end(args); 610 va_end(args);
590 ASSERT(len == len2); 611 ASSERT(len == len2);
591 stream_->buffer_.AddChar('"'); 612 stream_->buffer_.AddChar('"');
592 stream_->AddEscapedUTF8String(p); 613 stream_->AddEscapedUTF8String(p);
593 stream_->buffer_.AddChar('"'); 614 stream_->buffer_.AddChar('"');
594 free(p); 615 free(p);
595 } 616 }
596 617
597 } // namespace dart 618 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/json_stream.h ('k') | runtime/vm/json_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698