Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Side by Side Diff: runtime/vm/dart_api_impl.cc

Issue 9104041: Added API Dart_PostCMessage for posting a Dart_CMessage structure (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments from asiva@ Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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"
11 #include "vm/dart_api_impl.h" 11 #include "vm/dart_api_impl.h"
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_PostCObject(Dart_Port port_id, Dart_CObject* root) {
734 uint8_t* buffer = NULL;
735 MessageWriter writer(&buffer, allocator);
736
737 writer.WriteCMessage(root);
738
739 // Post the message at the given port.
740 return PortMap::PostMessage(new Message(
741 port_id, Message::kIllegalPort, buffer, Message::kNormalPriority));
742 }
743
744
733 DART_EXPORT bool Dart_Post(Dart_Port port_id, Dart_Handle handle) { 745 DART_EXPORT bool Dart_Post(Dart_Port port_id, Dart_Handle handle) {
734 Isolate* isolate = Isolate::Current(); 746 Isolate* isolate = Isolate::Current();
735 CHECK_ISOLATE(isolate); 747 CHECK_ISOLATE(isolate);
736 DARTSCOPE_NOCHECKS(isolate); 748 DARTSCOPE_NOCHECKS(isolate);
737 const Object& object = Object::Handle(Api::UnwrapHandle(handle)); 749 const Object& object = Object::Handle(Api::UnwrapHandle(handle));
738 uint8_t* data = NULL; 750 uint8_t* data = NULL;
739 SnapshotWriter writer(Snapshot::kMessage, &data, &allocator); 751 SnapshotWriter writer(Snapshot::kMessage, &data, &allocator);
740 writer.WriteObject(object.raw()); 752 writer.WriteObject(object.raw());
741 writer.FinalizeBuffer(); 753 writer.FinalizeBuffer();
742 return PortMap::PostMessage(new Message( 754 return PortMap::PostMessage(new Message(
(...skipping 1803 matching lines...) Expand 10 before | Expand all | Expand 10 after
2546 } 2558 }
2547 delete debug_region; 2559 delete debug_region;
2548 } else { 2560 } else {
2549 *buffer = NULL; 2561 *buffer = NULL;
2550 *buffer_size = 0; 2562 *buffer_size = 0;
2551 } 2563 }
2552 } 2564 }
2553 2565
2554 2566
2555 } // namespace dart 2567 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698