| 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 16 matching lines...) Expand all Loading... |
| 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 GrowableObjectArray& path, | 34 const GrowableObjectArray& path, |
| 35 const Array& option_keys, | 35 const Array& option_keys, |
| 36 const Array& option_values); | 36 const Array& option_values); |
| 37 |
| 38 void SetupNew(Zone* zone, |
| 39 Dart_Port reply_port, |
| 40 const String& method, |
| 41 const Array& param_keys, |
| 42 const Array& param_values); |
| 43 |
| 37 void PostReply(); | 44 void PostReply(); |
| 38 | 45 |
| 39 TextBuffer* buffer() { return &buffer_; } | 46 TextBuffer* buffer() { return &buffer_; } |
| 40 const char* ToCString() { return buffer_.buf(); } | 47 const char* ToCString() { return buffer_.buf(); } |
| 41 | 48 |
| 42 void set_reply_port(Dart_Port port); | 49 void set_reply_port(Dart_Port port); |
| 43 void SetArguments(const char** arguments, intptr_t num_arguments); | 50 void SetArguments(const char** arguments, intptr_t num_arguments); |
| 44 void SetOptions(const char** option_keys, const char** option_values, | 51 void SetOptions(const char** option_keys, const char** option_values, |
| 45 intptr_t num_options); | 52 intptr_t num_options); |
| 46 | 53 |
| 47 Dart_Port reply_port() const { return reply_port_; } | 54 Dart_Port reply_port() const { return reply_port_; } |
| 48 | 55 |
| 49 intptr_t num_arguments() const { return num_arguments_; } | 56 intptr_t num_arguments() const { return num_arguments_; } |
| 50 const char* GetArgument(intptr_t i) const { | 57 const char* GetArgument(intptr_t i) const { |
| 51 return arguments_[i]; | 58 return arguments_[i]; |
| 52 } | 59 } |
| 60 |
| 61 // TODO(turnidge): Rename "options" to "params". That is the more |
| 62 // appropriate name for json rpc. |
| 53 intptr_t num_options() const { return num_options_; } | 63 intptr_t num_options() const { return num_options_; } |
| 54 const char* GetOptionKey(intptr_t i) const { | 64 const char* GetOptionKey(intptr_t i) const { |
| 55 return option_keys_[i]; | 65 return option_keys_[i]; |
| 56 } | 66 } |
| 57 const char* GetOptionValue(intptr_t i) const { | 67 const char* GetOptionValue(intptr_t i) const { |
| 58 return option_values_[i]; | 68 return option_values_[i]; |
| 59 } | 69 } |
| 60 | 70 |
| 61 const char* LookupOption(const char* key) const; | 71 const char* LookupOption(const char* key) const; |
| 62 | 72 |
| 63 bool HasOption(const char* key) const; | 73 bool HasOption(const char* key) const; |
| 64 | 74 |
| 65 // Returns true if there is an option with key and value, false | 75 // Returns true if there is an option with key and value, false |
| 66 // otherwise. | 76 // otherwise. |
| 67 bool OptionIs(const char* key, const char* value) const; | 77 bool OptionIs(const char* key, const char* value) const; |
| 68 | 78 |
| 79 // TODO(turnidge): Rename "command" to "method". Better name for json rpc. |
| 69 const char* command() const { return command_; } | 80 const char* command() const { return command_; } |
| 70 const char** arguments() const { return arguments_; } | 81 const char** arguments() const { return arguments_; } |
| 71 const char** option_keys() const { return option_keys_; } | 82 const char** option_keys() const { return option_keys_; } |
| 72 const char** option_values() const { return option_values_; } | 83 const char** option_values() const { return option_values_; } |
| 73 | 84 |
| 74 private: | 85 private: |
| 75 void Clear(); | 86 void Clear(); |
| 76 | 87 |
| 77 void OpenObject(const char* property_name = NULL); | 88 void OpenObject(const char* property_name = NULL); |
| 78 void CloseObject(); | 89 void CloseObject(); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 | 254 |
| 244 friend class JSONObject; | 255 friend class JSONObject; |
| 245 | 256 |
| 246 DISALLOW_ALLOCATION(); | 257 DISALLOW_ALLOCATION(); |
| 247 DISALLOW_COPY_AND_ASSIGN(JSONArray); | 258 DISALLOW_COPY_AND_ASSIGN(JSONArray); |
| 248 }; | 259 }; |
| 249 | 260 |
| 250 } // namespace dart | 261 } // namespace dart |
| 251 | 262 |
| 252 #endif // VM_JSON_STREAM_H_ | 263 #endif // VM_JSON_STREAM_H_ |
| OLD | NEW |