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

Side by Side Diff: runtime/bin/dartutils.cc

Issue 14142008: Add support for more typed data types on native ports (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments Created 7 years, 8 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 "bin/dartutils.h" 5 #include "bin/dartutils.h"
6 6
7 #include "bin/extensions.h" 7 #include "bin/extensions.h"
8 #include "bin/directory.h" 8 #include "bin/directory.h"
9 #include "bin/file.h" 9 #include "bin/file.h"
10 #include "bin/io_buffer.h" 10 #include "bin/io_buffer.h"
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 Dart_CObject* cobject = 671 Dart_CObject* cobject =
672 New(Dart_CObject::kArray, length * sizeof(Dart_CObject*)); // NOLINT 672 New(Dart_CObject::kArray, length * sizeof(Dart_CObject*)); // NOLINT
673 cobject->value.as_array.length = length; 673 cobject->value.as_array.length = length;
674 cobject->value.as_array.values = 674 cobject->value.as_array.values =
675 reinterpret_cast<Dart_CObject**>(cobject + 1); 675 reinterpret_cast<Dart_CObject**>(cobject + 1);
676 return cobject; 676 return cobject;
677 } 677 }
678 678
679 679
680 Dart_CObject* CObject::NewUint8Array(int length) { 680 Dart_CObject* CObject::NewUint8Array(int length) {
681 Dart_CObject* cobject = New(Dart_CObject::kUint8Array, length); 681 Dart_CObject* cobject = New(Dart_CObject::kTypedData, length);
682 cobject->value.as_byte_array.length = length; 682 cobject->value.as_typed_data.type = Dart_CObject::kUint8Array;
683 cobject->value.as_byte_array.values = reinterpret_cast<uint8_t*>(cobject + 1); 683 cobject->value.as_typed_data.length = length;
684 cobject->value.as_typed_data.values = reinterpret_cast<uint8_t*>(cobject + 1);
684 return cobject; 685 return cobject;
685 } 686 }
686 687
687 688
688 Dart_CObject* CObject::NewExternalUint8Array( 689 Dart_CObject* CObject::NewExternalUint8Array(
689 int64_t length, uint8_t* data, void* peer, 690 int64_t length, uint8_t* data, void* peer,
690 Dart_WeakPersistentHandleFinalizer callback) { 691 Dart_WeakPersistentHandleFinalizer callback) {
691 Dart_CObject* cobject = New(Dart_CObject::kExternalUint8Array); 692 Dart_CObject* cobject = New(Dart_CObject::kExternalTypedData);
692 cobject->value.as_external_byte_array.length = length; 693 cobject->value.as_external_typed_data.type = Dart_CObject::kUint8Array;
693 cobject->value.as_external_byte_array.data = data; 694 cobject->value.as_external_typed_data.length = length;
694 cobject->value.as_external_byte_array.peer = peer; 695 cobject->value.as_external_typed_data.data = data;
695 cobject->value.as_external_byte_array.callback = callback; 696 cobject->value.as_external_typed_data.peer = peer;
697 cobject->value.as_external_typed_data.callback = callback;
696 return cobject; 698 return cobject;
697 } 699 }
698 700
699 701
700 Dart_CObject* CObject::NewIOBuffer(int64_t length) { 702 Dart_CObject* CObject::NewIOBuffer(int64_t length) {
701 uint8_t* data = IOBuffer::Allocate(length); 703 uint8_t* data = IOBuffer::Allocate(length);
702 return NewExternalUint8Array(length, data, data, IOBuffer::Finalizer); 704 return NewExternalUint8Array(length, data, data, IOBuffer::Finalizer);
703 } 705 }
704 706
705 707
706 void CObject::FreeIOBufferData(Dart_CObject* cobject) { 708 void CObject::FreeIOBufferData(Dart_CObject* cobject) {
707 ASSERT(cobject->type == Dart_CObject::kExternalUint8Array); 709 ASSERT(cobject->type == Dart_CObject::kExternalTypedData);
708 cobject->value.as_external_byte_array.callback( 710 cobject->value.as_external_typed_data.callback(
709 NULL, cobject->value.as_external_byte_array.peer); 711 NULL, cobject->value.as_external_typed_data.peer);
710 cobject->value.as_external_byte_array.data = NULL; 712 cobject->value.as_external_typed_data.data = NULL;
711 } 713 }
712 714
713 715
714 static int kArgumentError = 1; 716 static int kArgumentError = 1;
715 static int kOSError = 2; 717 static int kOSError = 2;
716 static int kFileClosedError = 3; 718 static int kFileClosedError = 3;
717 719
718 720
719 CObject* CObject::IllegalArgumentError() { 721 CObject* CObject::IllegalArgumentError() {
720 CObjectArray* result = new CObjectArray(CObject::NewArray(1)); 722 CObjectArray* result = new CObjectArray(CObject::NewArray(1));
(...skipping 16 matching lines...) Expand all
737 739
738 CObject* CObject::NewOSError(OSError* os_error) { 740 CObject* CObject::NewOSError(OSError* os_error) {
739 CObject* error_message = 741 CObject* error_message =
740 new CObjectString(CObject::NewString(os_error->message())); 742 new CObjectString(CObject::NewString(os_error->message()));
741 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); 743 CObjectArray* result = new CObjectArray(CObject::NewArray(3));
742 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); 744 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError)));
743 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); 745 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code())));
744 result->SetAt(2, error_message); 746 result->SetAt(2, error_message);
745 return result; 747 return result;
746 } 748 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698