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

Unified Diff: runtime/vm/object.h

Issue 23875015: - Base JSON stream printing on stack objects. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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
===================================================================
--- runtime/vm/object.h (revision 27342)
+++ runtime/vm/object.h (working copy)
@@ -126,6 +126,9 @@
/* with an object id is printed. If ref is false the object is fully */ \
/* printed. */ \
virtual void PrintToJSONStream(JSONStream* stream, bool ref = true) const; \
+ virtual const char* JSONType(bool ref) const { \
+ return ref ? "@"#object : ""#object; \
+ } \
static const ClassId kClassId = k##object##Cid; \
private: /* NOLINT */ \
/* Initialize the handle based on the raw_ptr in the presence of null. */ \
@@ -254,18 +257,14 @@
}
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();
+ JSONObject jsobj(stream);
+ jsobj.AddProperty("type", JSONType(ref));
}
+ virtual const char* JSONType(bool ref) const {
+ return IsNull() ? "null" : "Object";
+ }
+
// 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