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

Unified Diff: runtime/vm/object.h

Issue 18472009: JSONStream Print Dart Objects (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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_test.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.h
diff --git a/runtime/vm/object.h b/runtime/vm/object.h
index 840ec69d31f40c5d5951f8c9b0427be5bbe6ba60..6692c3f7d4a0b4ce820e2886208554f9256cb103 100644
--- a/runtime/vm/object.h
+++ b/runtime/vm/object.h
@@ -8,6 +8,7 @@
#include "include/dart_api.h"
#include "platform/assert.h"
#include "platform/utils.h"
+#include "vm/json_stream.h"
#include "vm/bitmap.h"
#include "vm/dart.h"
#include "vm/globals.h"
@@ -119,6 +120,10 @@ class Symbols;
return reinterpret_cast<Raw##object*>(Object::null()); \
} \
virtual const char* ToCString() const; \
+ /* Object is printed as JSON into stream. If ref is true only a header */ \
+ /* with an object id is printed. If ref is false the object is fully */ \
+ /* printed. */ \
+ virtual void PrintToJSONStream(JSONStream* stream, bool ref = true) const; \
static const ClassId kClassId = k##object##Cid; \
private: /* NOLINT */ \
/* Initialize the handle based on the raw_ptr in the presence of null. */ \
@@ -246,6 +251,19 @@ class Object {
}
}
+ virtual void PrintToJSONStream(JSONStream* stream, bool ref = true) const {
+ if (IsNull()) {
+ stream->OpenObject();
+ stream->PrintProperty("type", "null");
+ stream->CloseObject();
+ return;
+ }
+ ASSERT(!IsNull());
+ stream->OpenObject();
+ stream->PrintProperty("type", "Object");
+ stream->CloseObject();
+ }
+
// Returns the name that is used to identify an object in the
// namespace dictionary.
// Object::DictionaryName() returns String::null(). Only subclasses
« no previous file with comments | « runtime/vm/json_test.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698