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 #include "platform/assert.h" | 5 #include "platform/assert.h" |
6 | 6 |
7 #include "vm/dart_entry.h" | 7 #include "vm/dart_entry.h" |
8 #include "vm/debugger.h" | 8 #include "vm/debugger.h" |
9 #include "vm/json_stream.h" | 9 #include "vm/json_stream.h" |
10 #include "vm/message.h" | 10 #include "vm/message.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 option_values_(NULL), | 27 option_values_(NULL), |
28 num_options_(0) { | 28 num_options_(0) { |
29 } | 29 } |
30 | 30 |
31 | 31 |
32 JSONStream::~JSONStream() { | 32 JSONStream::~JSONStream() { |
33 } | 33 } |
34 | 34 |
35 | 35 |
36 void JSONStream::Setup(Zone* zone, | 36 void JSONStream::Setup(Zone* zone, |
37 const Instance& reply_port, | 37 Dart_Port reply_port, |
38 const GrowableObjectArray& path, | 38 const GrowableObjectArray& path, |
39 const GrowableObjectArray& option_keys, | 39 const GrowableObjectArray& option_keys, |
40 const GrowableObjectArray& option_values) { | 40 const GrowableObjectArray& option_values) { |
41 // Setup the reply port. | 41 set_reply_port(reply_port); |
42 const Object& id_obj = Object::Handle( | |
43 DartLibraryCalls::PortGetId(reply_port)); | |
44 if (id_obj.IsError()) { | |
45 Exceptions::PropagateError(Error::Cast(id_obj)); | |
46 } | |
47 const Integer& id = Integer::Cast(id_obj); | |
48 Dart_Port port = static_cast<Dart_Port>(id.AsInt64Value()); | |
49 ASSERT(port != ILLEGAL_PORT); | |
50 set_reply_port(port); | |
51 | 42 |
52 // Setup JSONStream arguments and options. The arguments and options | 43 // Setup JSONStream arguments and options. The arguments and options |
53 // are zone allocated and will be freed immediately after handling the | 44 // are zone allocated and will be freed immediately after handling the |
54 // message. | 45 // message. |
55 const char** arguments = zone->Alloc<const char*>(path.Length()); | 46 const char** arguments = zone->Alloc<const char*>(path.Length()); |
56 String& string_iterator = String::Handle(); | 47 String& string_iterator = String::Handle(); |
57 for (intptr_t i = 0; i < path.Length(); i++) { | 48 for (intptr_t i = 0; i < path.Length(); i++) { |
58 string_iterator ^= path.At(i); | 49 string_iterator ^= path.At(i); |
59 arguments[i] = zone->MakeCopyOfString(string_iterator.ToCString()); | 50 arguments[i] = zone->MakeCopyOfString(string_iterator.ToCString()); |
60 if (i == 0) { | 51 if (i == 0) { |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 intptr_t len2 = OS::VSNPrint(p, len+1, format, args); | 411 intptr_t len2 = OS::VSNPrint(p, len+1, format, args); |
421 va_end(args); | 412 va_end(args); |
422 ASSERT(len == len2); | 413 ASSERT(len == len2); |
423 stream_->buffer_.AddChar('"'); | 414 stream_->buffer_.AddChar('"'); |
424 stream_->AddEscapedUTF8String(p); | 415 stream_->AddEscapedUTF8String(p); |
425 stream_->buffer_.AddChar('"'); | 416 stream_->buffer_.AddChar('"'); |
426 free(p); | 417 free(p); |
427 } | 418 } |
428 | 419 |
429 } // namespace dart | 420 } // namespace dart |
OLD | NEW |