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

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

Issue 11438045: Make all allocation of external arrays used for IO use the IOBuffer class (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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
« no previous file with comments | « runtime/bin/dartutils.h ('k') | runtime/bin/file.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "include/dart_api.h" 11 #include "include/dart_api.h"
11 #include "platform/assert.h" 12 #include "platform/assert.h"
12 #include "platform/globals.h" 13 #include "platform/globals.h"
13 14
14 const char* DartUtils::original_working_directory = NULL; 15 const char* DartUtils::original_working_directory = NULL;
15 const char* DartUtils::kDartScheme = "dart:"; 16 const char* DartUtils::kDartScheme = "dart:";
16 const char* DartUtils::kDartExtensionScheme = "dart-ext:"; 17 const char* DartUtils::kDartExtensionScheme = "dart-ext:";
17 const char* DartUtils::kBuiltinLibURL = "dart:builtin"; 18 const char* DartUtils::kBuiltinLibURL = "dart:builtin";
18 const char* DartUtils::kCoreLibURL = "dart:core"; 19 const char* DartUtils::kCoreLibURL = "dart:core";
19 const char* DartUtils::kCryptoLibURL = "dart:crypto"; 20 const char* DartUtils::kCryptoLibURL = "dart:crypto";
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 Dart_PeerFinalizer callback) { 665 Dart_PeerFinalizer callback) {
665 Dart_CObject* cobject = New(Dart_CObject::kExternalUint8Array); 666 Dart_CObject* cobject = New(Dart_CObject::kExternalUint8Array);
666 cobject->value.as_external_byte_array.length = length; 667 cobject->value.as_external_byte_array.length = length;
667 cobject->value.as_external_byte_array.data = data; 668 cobject->value.as_external_byte_array.data = data;
668 cobject->value.as_external_byte_array.peer = peer; 669 cobject->value.as_external_byte_array.peer = peer;
669 cobject->value.as_external_byte_array.callback = callback; 670 cobject->value.as_external_byte_array.callback = callback;
670 return cobject; 671 return cobject;
671 } 672 }
672 673
673 674
675 Dart_CObject* CObject::NewIOBuffer(int64_t length) {
676 uint8_t* data = IOBuffer::Allocate(length);
677 return NewExternalUint8Array(length, data, data, IOBuffer::Free);
678 }
679
680
681 void CObject::FreeIOBufferData(Dart_CObject* cobject) {
682 ASSERT(cobject->type == Dart_CObject::kExternalUint8Array);
683 cobject->value.as_external_byte_array.callback(
684 cobject->value.as_external_byte_array.peer);
685 cobject->value.as_external_byte_array.data = NULL;
686 }
687
688
674 static int kArgumentError = 1; 689 static int kArgumentError = 1;
675 static int kOSError = 2; 690 static int kOSError = 2;
676 static int kFileClosedError = 3; 691 static int kFileClosedError = 3;
677 692
678 693
679 CObject* CObject::IllegalArgumentError() { 694 CObject* CObject::IllegalArgumentError() {
680 CObjectArray* result = new CObjectArray(CObject::NewArray(1)); 695 CObjectArray* result = new CObjectArray(CObject::NewArray(1));
681 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kArgumentError))); 696 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kArgumentError)));
682 return result; 697 return result;
683 } 698 }
(...skipping 13 matching lines...) Expand all
697 712
698 CObject* CObject::NewOSError(OSError* os_error) { 713 CObject* CObject::NewOSError(OSError* os_error) {
699 CObject* error_message = 714 CObject* error_message =
700 new CObjectString(CObject::NewString(os_error->message())); 715 new CObjectString(CObject::NewString(os_error->message()));
701 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); 716 CObjectArray* result = new CObjectArray(CObject::NewArray(3));
702 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); 717 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError)));
703 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); 718 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code())));
704 result->SetAt(2, error_message); 719 result->SetAt(2, error_message);
705 return result; 720 return result;
706 } 721 }
OLDNEW
« no previous file with comments | « runtime/bin/dartutils.h ('k') | runtime/bin/file.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698