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/json.h" | 9 #include "platform/json.h" |
10 #include "vm/allocation.h" | 10 #include "vm/allocation.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 class String; | 24 class String; |
25 class Zone; | 25 class Zone; |
26 | 26 |
27 class JSONStream : ValueObject { | 27 class JSONStream : ValueObject { |
28 public: | 28 public: |
29 explicit JSONStream(intptr_t buf_size = 256); | 29 explicit JSONStream(intptr_t buf_size = 256); |
30 ~JSONStream(); | 30 ~JSONStream(); |
31 | 31 |
32 void Setup(Zone* zone, | 32 void Setup(Zone* zone, |
33 Dart_Port reply_port, | 33 Dart_Port reply_port, |
| 34 const String& seq, |
34 const String& method, | 35 const String& method, |
35 const Array& param_keys, | 36 const Array& param_keys, |
36 const Array& param_values); | 37 const Array& param_values); |
| 38 void SetupError(); |
37 | 39 |
38 void PostReply(); | 40 void PostReply(); |
39 | 41 |
40 TextBuffer* buffer() { return &buffer_; } | 42 TextBuffer* buffer() { return &buffer_; } |
41 const char* ToCString() { return buffer_.buf(); } | 43 const char* ToCString() { return buffer_.buf(); } |
42 | 44 |
43 void set_reply_port(Dart_Port port); | 45 void set_reply_port(Dart_Port port); |
44 | 46 |
45 void SetParams(const char** param_keys, const char** param_values, | 47 void SetParams(const char** param_keys, const char** param_values, |
46 intptr_t num_params); | 48 intptr_t num_params); |
47 | 49 |
48 Dart_Port reply_port() const { return reply_port_; } | 50 Dart_Port reply_port() const { return reply_port_; } |
49 | 51 |
50 intptr_t num_params() const { return num_params_; } | 52 intptr_t num_params() const { return num_params_; } |
51 const char* GetParamKey(intptr_t i) const { | 53 const char* GetParamKey(intptr_t i) const { |
52 return param_keys_[i]; | 54 return param_keys_[i]; |
53 } | 55 } |
54 const char* GetParamValue(intptr_t i) const { | 56 const char* GetParamValue(intptr_t i) const { |
55 return param_values_[i]; | 57 return param_values_[i]; |
56 } | 58 } |
57 | 59 |
58 const char* LookupParam(const char* key) const; | 60 const char* LookupParam(const char* key) const; |
59 | 61 |
60 bool HasParam(const char* key) const; | 62 bool HasParam(const char* key) const; |
61 | 63 |
62 // Returns true if there is an param with key and value, false | 64 // Returns true if there is an param with key and value, false |
63 // otherwise. | 65 // otherwise. |
64 bool ParamIs(const char* key, const char* value) const; | 66 bool ParamIs(const char* key, const char* value) const; |
65 | 67 |
| 68 const char* seq() const { return seq_; } |
66 const char* method() const { return method_; } | 69 const char* method() const { return method_; } |
67 const char** param_keys() const { return param_keys_; } | 70 const char** param_keys() const { return param_keys_; } |
68 const char** param_values() const { return param_values_; } | 71 const char** param_values() const { return param_values_; } |
69 | 72 |
70 private: | 73 private: |
71 void Clear(); | 74 void Clear(); |
72 | 75 |
73 void OpenObject(const char* property_name = NULL); | 76 void OpenObject(const char* property_name = NULL); |
74 void CloseObject(); | 77 void CloseObject(); |
75 | 78 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 115 |
113 bool AddDartString(const String& s, intptr_t limit); | 116 bool AddDartString(const String& s, intptr_t limit); |
114 void AddEscapedUTF8String(const char* s); | 117 void AddEscapedUTF8String(const char* s); |
115 void AddEscapedUTF8String(const char* s, intptr_t len); | 118 void AddEscapedUTF8String(const char* s, intptr_t len); |
116 | 119 |
117 intptr_t nesting_level() const { return open_objects_; } | 120 intptr_t nesting_level() const { return open_objects_; } |
118 | 121 |
119 intptr_t open_objects_; | 122 intptr_t open_objects_; |
120 TextBuffer buffer_; | 123 TextBuffer buffer_; |
121 Dart_Port reply_port_; | 124 Dart_Port reply_port_; |
| 125 const char* seq_; |
122 const char* method_; | 126 const char* method_; |
123 const char** param_keys_; | 127 const char** param_keys_; |
124 const char** param_values_; | 128 const char** param_values_; |
125 intptr_t num_params_; | 129 intptr_t num_params_; |
126 int64_t setup_time_micros_; | 130 int64_t setup_time_micros_; |
127 | 131 |
128 friend class JSONObject; | 132 friend class JSONObject; |
129 friend class JSONArray; | 133 friend class JSONArray; |
130 }; | 134 }; |
131 | 135 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 | 241 |
238 friend class JSONObject; | 242 friend class JSONObject; |
239 | 243 |
240 DISALLOW_ALLOCATION(); | 244 DISALLOW_ALLOCATION(); |
241 DISALLOW_COPY_AND_ASSIGN(JSONArray); | 245 DISALLOW_COPY_AND_ASSIGN(JSONArray); |
242 }; | 246 }; |
243 | 247 |
244 } // namespace dart | 248 } // namespace dart |
245 | 249 |
246 #endif // VM_JSON_STREAM_H_ | 250 #endif // VM_JSON_STREAM_H_ |
OLD | NEW |