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

Unified 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, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/json_stream.h ('k') | runtime/vm/json_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/json_stream.cc
diff --git a/runtime/vm/json_stream.cc b/runtime/vm/json_stream.cc
index 2ed62efd8c1caf16ed1ab3bfaa4e79f129dc22e6..e1cf409b64961394802fc5e9f24cab7b12c9d8c5 100644
--- a/runtime/vm/json_stream.cc
+++ b/runtime/vm/json_stream.cc
@@ -357,9 +357,9 @@ void JSONStream::PrintValue(Isolate* isolate, bool ref) {
}
-void JSONStream::PrintServiceId(const char* name, const Object& o) {
+void JSONStream::PrintServiceId(const Object& o) {
ASSERT(id_zone_ != NULL);
- PrintProperty(name, id_zone_->GetServiceId(o));
+ PrintProperty("id", id_zone_->GetServiceId(o));
}
@@ -558,6 +558,27 @@ JSONObject::JSONObject(const JSONArray* arr) : stream_(arr->stream_) {
}
+void JSONObject::AddFixedServiceId(const char* format, ...) const {
+ // Mark that this id is fixed.
+ AddProperty("fixedId", true);
+ // Add the id property.
+ stream_->PrintPropertyName("id");
+ va_list args;
+ va_start(args, format);
+ intptr_t len = OS::VSNPrint(NULL, 0, format, args);
+ va_end(args);
+ char* p = reinterpret_cast<char*>(malloc(len+1));
+ va_start(args, format);
+ intptr_t len2 = OS::VSNPrint(p, len+1, format, args);
+ va_end(args);
+ ASSERT(len == len2);
+ stream_->buffer_.AddChar('"');
+ stream_->AddEscapedUTF8String(p);
+ stream_->buffer_.AddChar('"');
+ free(p);
+}
+
+
void JSONObject::AddPropertyF(const char* name,
const char* format, ...) const {
stream_->PrintPropertyName(name);
« 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