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

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

Issue 11414293: Fix a number of int type issues in dart:io File implementation to avoid implicit conversions that c… (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 "include/dart_api.h" 10 #include "include/dart_api.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 int64_t DartUtils::GetIntegerValue(Dart_Handle value_obj) { 59 int64_t DartUtils::GetIntegerValue(Dart_Handle value_obj) {
60 ASSERT(Dart_IsInteger(value_obj)); 60 ASSERT(Dart_IsInteger(value_obj));
61 int64_t value = 0; 61 int64_t value = 0;
62 Dart_Handle result = Dart_IntegerToInt64(value_obj, &value); 62 Dart_Handle result = Dart_IntegerToInt64(value_obj, &value);
63 ASSERT(!Dart_IsError(result)); 63 ASSERT(!Dart_IsError(result));
64 return value; 64 return value;
65 } 65 }
66 66
67 67
68 intptr_t DartUtils::GetIntptrValue(Dart_Handle value_obj) {
69 ASSERT(Dart_IsInteger(value_obj));
70 int64_t value = 0;
71 Dart_Handle result = Dart_IntegerToInt64(value_obj, &value);
72 ASSERT(!Dart_IsError(result));
73 return static_cast<intptr_t>(value);
74 }
75
76
68 bool DartUtils::GetInt64Value(Dart_Handle value_obj, int64_t* value) { 77 bool DartUtils::GetInt64Value(Dart_Handle value_obj, int64_t* value) {
69 bool valid = Dart_IsInteger(value_obj); 78 bool valid = Dart_IsInteger(value_obj);
70 if (valid) { 79 if (valid) {
71 Dart_Handle result = Dart_IntegerFitsIntoInt64(value_obj, &valid); 80 Dart_Handle result = Dart_IntegerFitsIntoInt64(value_obj, &valid);
72 ASSERT(!Dart_IsError(result)); 81 ASSERT(!Dart_IsError(result));
73 } 82 }
74 if (!valid) return false; 83 if (!valid) return false;
75 Dart_Handle result = Dart_IntegerToInt64(value_obj, value); 84 Dart_Handle result = Dart_IntegerToInt64(value_obj, value);
76 ASSERT(!Dart_IsError(result)); 85 ASSERT(!Dart_IsError(result));
77 return true; 86 return true;
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 646
638 647
639 Dart_CObject* CObject::NewUint8Array(int length) { 648 Dart_CObject* CObject::NewUint8Array(int length) {
640 Dart_CObject* cobject = New(Dart_CObject::kUint8Array, length); 649 Dart_CObject* cobject = New(Dart_CObject::kUint8Array, length);
641 cobject->value.as_byte_array.length = length; 650 cobject->value.as_byte_array.length = length;
642 cobject->value.as_byte_array.values = reinterpret_cast<uint8_t*>(cobject + 1); 651 cobject->value.as_byte_array.values = reinterpret_cast<uint8_t*>(cobject + 1);
643 return cobject; 652 return cobject;
644 } 653 }
645 654
646 655
647 Dart_CObject* CObject::NewExternalUint8Array(int length, 656 Dart_CObject* CObject::NewExternalUint8Array(int64_t length,
648 uint8_t* data, 657 uint8_t* data,
649 void* peer, 658 void* peer,
650 Dart_PeerFinalizer callback) { 659 Dart_PeerFinalizer callback) {
651 Dart_CObject* cobject = New(Dart_CObject::kExternalUint8Array); 660 Dart_CObject* cobject = New(Dart_CObject::kExternalUint8Array);
652 cobject->value.as_external_byte_array.length = length; 661 cobject->value.as_external_byte_array.length = length;
653 cobject->value.as_external_byte_array.data = data; 662 cobject->value.as_external_byte_array.data = data;
654 cobject->value.as_external_byte_array.peer = peer; 663 cobject->value.as_external_byte_array.peer = peer;
655 cobject->value.as_external_byte_array.callback = callback; 664 cobject->value.as_external_byte_array.callback = callback;
656 return cobject; 665 return cobject;
657 } 666 }
(...skipping 25 matching lines...) Expand all
683 692
684 CObject* CObject::NewOSError(OSError* os_error) { 693 CObject* CObject::NewOSError(OSError* os_error) {
685 CObject* error_message = 694 CObject* error_message =
686 new CObjectString(CObject::NewString(os_error->message())); 695 new CObjectString(CObject::NewString(os_error->message()));
687 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); 696 CObjectArray* result = new CObjectArray(CObject::NewArray(3));
688 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); 697 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError)));
689 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); 698 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code())));
690 result->SetAt(2, error_message); 699 result->SetAt(2, error_message);
691 return result; 700 return result;
692 } 701 }
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