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 #ifndef VM_JSON_STREAM_H_ | 5 #ifndef VM_JSON_STREAM_H_ |
6 #define VM_JSON_STREAM_H_ | 6 #define VM_JSON_STREAM_H_ |
7 | 7 |
8 #include "include/dart_api.h" // for Dart_Port | 8 #include "include/dart_api.h" // for Dart_Port |
9 #include "platform/text_buffer.h" | 9 #include "platform/text_buffer.h" |
10 #include "vm/allocation.h" | 10 #include "vm/allocation.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 kExtensionError = -32000, | 48 kExtensionError = -32000, |
49 | 49 |
50 kFeatureDisabled = 100, | 50 kFeatureDisabled = 100, |
51 kVMMustBePaused = 101, | 51 kVMMustBePaused = 101, |
52 kCannotAddBreakpoint = 102, | 52 kCannotAddBreakpoint = 102, |
53 kStreamAlreadySubscribed = 103, | 53 kStreamAlreadySubscribed = 103, |
54 kStreamNotSubscribed = 104, | 54 kStreamNotSubscribed = 104, |
55 kIsolateMustBeRunnable = 105, | 55 kIsolateMustBeRunnable = 105, |
56 }; | 56 }; |
57 | 57 |
| 58 // Expected that user_data is a JSONStream*. |
| 59 void AppendJSONStreamConsumer(Dart_StreamConsumer_State state, |
| 60 const char* stream_name, |
| 61 const uint8_t* buffer, |
| 62 intptr_t buffer_length, |
| 63 void* user_data); |
58 | 64 |
59 class JSONStream : ValueObject { | 65 class JSONStream : ValueObject { |
60 public: | 66 public: |
61 explicit JSONStream(intptr_t buf_size = 256); | 67 explicit JSONStream(intptr_t buf_size = 256); |
62 ~JSONStream(); | 68 ~JSONStream(); |
63 | 69 |
64 void Setup(Zone* zone, | 70 void Setup(Zone* zone, |
65 Dart_Port reply_port, | 71 Dart_Port reply_port, |
66 const Instance& seq, | 72 const Instance& seq, |
67 const String& method, | 73 const String& method, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 count_ = value; | 128 count_ = value; |
123 } | 129 } |
124 | 130 |
125 void ComputeOffsetAndCount(intptr_t length, | 131 void ComputeOffsetAndCount(intptr_t length, |
126 intptr_t* offset, | 132 intptr_t* offset, |
127 intptr_t* count); | 133 intptr_t* count); |
128 | 134 |
129 // Append |serialized_object| to the stream. | 135 // Append |serialized_object| to the stream. |
130 void AppendSerializedObject(const char* serialized_object); | 136 void AppendSerializedObject(const char* serialized_object); |
131 | 137 |
| 138 void PrintCommaIfNeeded(); |
| 139 |
| 140 // Append |buffer| to the stream. |
| 141 void AppendSerializedObject(const uint8_t* buffer, |
| 142 intptr_t buffer_length); |
| 143 |
132 // Append |serialized_object| to the stream with |property_name|. | 144 // Append |serialized_object| to the stream with |property_name|. |
133 void AppendSerializedObject(const char* property_name, | 145 void AppendSerializedObject(const char* property_name, |
134 const char* serialized_object); | 146 const char* serialized_object); |
135 | 147 |
136 private: | 148 private: |
137 void Clear(); | 149 void Clear(); |
138 void PostNullReply(Dart_Port port); | 150 void PostNullReply(Dart_Port port); |
139 | 151 |
140 void OpenObject(const char* property_name = NULL); | 152 void OpenObject(const char* property_name = NULL); |
141 void CloseObject(); | 153 void CloseObject(); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 void PrintProperty(const char* name, Breakpoint* bpt); | 201 void PrintProperty(const char* name, Breakpoint* bpt); |
190 void PrintProperty(const char* name, TokenPosition tp); | 202 void PrintProperty(const char* name, TokenPosition tp); |
191 void PrintProperty(const char* name, Metric* metric); | 203 void PrintProperty(const char* name, Metric* metric); |
192 void PrintProperty(const char* name, MessageQueue* queue); | 204 void PrintProperty(const char* name, MessageQueue* queue); |
193 void PrintProperty(const char* name, Isolate* isolate); | 205 void PrintProperty(const char* name, Isolate* isolate); |
194 void PrintProperty(const char* name, const TimelineEvent* timeline_event); | 206 void PrintProperty(const char* name, const TimelineEvent* timeline_event); |
195 void PrintProperty(const char* name, | 207 void PrintProperty(const char* name, |
196 const TimelineEventBlock* timeline_event_block); | 208 const TimelineEventBlock* timeline_event_block); |
197 void PrintPropertyVM(const char* name, bool ref = true); | 209 void PrintPropertyVM(const char* name, bool ref = true); |
198 void PrintPropertyName(const char* name); | 210 void PrintPropertyName(const char* name); |
199 void PrintCommaIfNeeded(); | |
200 bool NeedComma(); | 211 bool NeedComma(); |
201 | 212 |
202 bool AddDartString(const String& s, intptr_t offset, intptr_t count); | 213 bool AddDartString(const String& s, intptr_t offset, intptr_t count); |
203 void AddEscapedUTF8String(const char* s); | 214 void AddEscapedUTF8String(const char* s); |
204 void AddEscapedUTF8String(const char* s, intptr_t len); | 215 void AddEscapedUTF8String(const char* s, intptr_t len); |
205 | 216 |
206 intptr_t nesting_level() const { return open_objects_; } | 217 intptr_t nesting_level() const { return open_objects_; } |
207 | 218 |
208 // Debug only fatal assertion. | 219 // Debug only fatal assertion. |
209 static void EnsureIntegerIsRepresentableInJavaScript(int64_t i); | 220 static void EnsureIntegerIsRepresentableInJavaScript(int64_t i); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 | 412 |
402 friend class JSONObject; | 413 friend class JSONObject; |
403 | 414 |
404 DISALLOW_ALLOCATION(); | 415 DISALLOW_ALLOCATION(); |
405 DISALLOW_COPY_AND_ASSIGN(JSONArray); | 416 DISALLOW_COPY_AND_ASSIGN(JSONArray); |
406 }; | 417 }; |
407 | 418 |
408 } // namespace dart | 419 } // namespace dart |
409 | 420 |
410 #endif // VM_JSON_STREAM_H_ | 421 #endif // VM_JSON_STREAM_H_ |
OLD | NEW |