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

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

Issue 10698011: Support posting of external data into dart as external uint8 arrays through the Dart API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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) 2012, 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 "vm/dart_api_message.h" 5 #include "vm/dart_api_message.h"
6 #include "vm/object.h" 6 #include "vm/object.h"
7 #include "vm/object_store.h" 7 #include "vm/object_store.h"
8 8
9 namespace dart { 9 namespace dart {
10 10
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 // Write out the class and tags information. 708 // Write out the class and tags information.
709 WriteObjectHeader(ObjectStore::kUint8ArrayClass, 0); 709 WriteObjectHeader(ObjectStore::kUint8ArrayClass, 0);
710 uint8_t* bytes = object->value.as_byte_array.values; 710 uint8_t* bytes = object->value.as_byte_array.values;
711 intptr_t len = object->value.as_byte_array.length; 711 intptr_t len = object->value.as_byte_array.length;
712 WriteSmi(len); 712 WriteSmi(len);
713 for (intptr_t i = 0; i < len; i++) { 713 for (intptr_t i = 0; i < len; i++) {
714 Write<uint8_t>(bytes[i]); 714 Write<uint8_t>(bytes[i]);
715 } 715 }
716 break; 716 break;
717 } 717 }
718 case Dart_CObject::kExternalUint8Array: {
719 // Write out serialization header value for this object.
720 WriteInlinedHeader(object);
721 // Write out the class and tag information.
722 WriteObjectHeader(ObjectStore::kExternalUint8ArrayClass, 0);
723 int length = object->value.as_external_byte_array.length;
724 uint8_t* data = object->value.as_external_byte_array.data;
725 void* peer = object->value.as_external_byte_array.peer;
726 Dart_PeerFinalizer callback =
727 object->value.as_external_byte_array.callback;
728 WriteSmi(length);
729 WriteIntptrValue(reinterpret_cast<intptr_t>(data));
730 WriteIntptrValue(reinterpret_cast<intptr_t>(peer));
731 WriteIntptrValue(reinterpret_cast<intptr_t>(callback));
siva 2012/06/28 16:44:05 As discussed offline we need some mechanism to ens
Mads Ager (google) 2012/06/28 18:06:51 Done.
732 break;
733 }
718 default: 734 default:
719 UNREACHABLE(); 735 UNREACHABLE();
720 } 736 }
721 } 737 }
722 738
723 739
724 void ApiMessageWriter::WriteCMessage(Dart_CObject* object) { 740 void ApiMessageWriter::WriteCMessage(Dart_CObject* object) {
725 WriteCObject(object); 741 WriteCObject(object);
726 // Write out all objects that were added to the forward list and have 742 // Write out all objects that were added to the forward list and have
727 // not been serialized yet. These would typically be fields of arrays. 743 // not been serialized yet. These would typically be fields of arrays.
728 // NOTE: The forward list might grow as we process the list. 744 // NOTE: The forward list might grow as we process the list.
729 for (intptr_t i = 0; i < forward_id_; i++) { 745 for (intptr_t i = 0; i < forward_id_; i++) {
730 WriteForwardedCObject(forward_list_[i]); 746 WriteForwardedCObject(forward_list_[i]);
731 } 747 }
732 UnmarkAllCObjects(object); 748 UnmarkAllCObjects(object);
733 FinalizeBuffer(); 749 FinalizeBuffer();
734 } 750 }
735 751
736 } // namespace dart 752 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698