OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 "include/dart_api.h" | 5 #include "include/dart_api.h" |
6 | 6 |
7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
10 #include "vm/dart.h" | 10 #include "vm/dart.h" |
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 MessageWriter writer(&buffer, &allocator); | 723 MessageWriter writer(&buffer, &allocator); |
724 | 724 |
725 writer.WriteMessage(len, data); | 725 writer.WriteMessage(len, data); |
726 | 726 |
727 // Post the message at the given port. | 727 // Post the message at the given port. |
728 return PortMap::PostMessage(new Message( | 728 return PortMap::PostMessage(new Message( |
729 port_id, Message::kIllegalPort, buffer, Message::kNormalPriority)); | 729 port_id, Message::kIllegalPort, buffer, Message::kNormalPriority)); |
730 } | 730 } |
731 | 731 |
732 | 732 |
| 733 DART_EXPORT bool Dart_PostCMessage(Dart_Port port_id, |
| 734 Dart_CMessage* message) { |
| 735 uint8_t* buffer = NULL; |
| 736 MessageWriter writer(&buffer, allocator); |
| 737 |
| 738 writer.WriteCMessage(message->root); |
| 739 |
| 740 // Post the message at the given port. |
| 741 return PortMap::PostMessage(new Message( |
| 742 port_id, Message::kIllegalPort, buffer, Message::kNormalPriority)); |
| 743 } |
| 744 |
| 745 |
733 DART_EXPORT bool Dart_Post(Dart_Port port_id, Dart_Handle handle) { | 746 DART_EXPORT bool Dart_Post(Dart_Port port_id, Dart_Handle handle) { |
734 Isolate* isolate = Isolate::Current(); | 747 Isolate* isolate = Isolate::Current(); |
735 CHECK_ISOLATE(isolate); | 748 CHECK_ISOLATE(isolate); |
736 DARTSCOPE_NOCHECKS(isolate); | 749 DARTSCOPE_NOCHECKS(isolate); |
737 const Object& object = Object::Handle(Api::UnwrapHandle(handle)); | 750 const Object& object = Object::Handle(Api::UnwrapHandle(handle)); |
738 uint8_t* data = NULL; | 751 uint8_t* data = NULL; |
739 SnapshotWriter writer(Snapshot::kMessage, &data, &allocator); | 752 SnapshotWriter writer(Snapshot::kMessage, &data, &allocator); |
740 writer.WriteObject(object.raw()); | 753 writer.WriteObject(object.raw()); |
741 writer.FinalizeBuffer(); | 754 writer.FinalizeBuffer(); |
742 return PortMap::PostMessage(new Message( | 755 return PortMap::PostMessage(new Message( |
(...skipping 1803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2546 } | 2559 } |
2547 delete debug_region; | 2560 delete debug_region; |
2548 } else { | 2561 } else { |
2549 *buffer = NULL; | 2562 *buffer = NULL; |
2550 *buffer_size = 0; | 2563 *buffer_size = 0; |
2551 } | 2564 } |
2552 } | 2565 } |
2553 | 2566 |
2554 | 2567 |
2555 } // namespace dart | 2568 } // namespace dart |
OLD | NEW |