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

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

Issue 10414021: Reland: Add more API fuzzing and fix the issues encountered. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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
« 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/file.h" 7 #include "bin/file.h"
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "platform/globals.h" 10 #include "platform/globals.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 int64_t DartUtils::GetIntegerValue(Dart_Handle value_obj) { 47 int64_t DartUtils::GetIntegerValue(Dart_Handle value_obj) {
48 ASSERT(Dart_IsInteger(value_obj)); 48 ASSERT(Dart_IsInteger(value_obj));
49 int64_t value = 0; 49 int64_t value = 0;
50 Dart_Handle result = Dart_IntegerToInt64(value_obj, &value); 50 Dart_Handle result = Dart_IntegerToInt64(value_obj, &value);
51 ASSERT(!Dart_IsError(result)); 51 ASSERT(!Dart_IsError(result));
52 return value; 52 return value;
53 } 53 }
54 54
55 55
56 bool DartUtils::GetInt64Value(Dart_Handle value_obj, int64_t* value) {
57 bool valid = Dart_IsInteger(value_obj);
58 if (valid) {
59 Dart_Handle result = Dart_IntegerFitsIntoInt64(value_obj, &valid);
60 ASSERT(!Dart_IsError(result));
61 }
62 if (!valid) return false;
63 Dart_Handle result = Dart_IntegerToInt64(value_obj, value);
64 ASSERT(!Dart_IsError(result));
65 return true;
66 }
67
68
56 const char* DartUtils::GetStringValue(Dart_Handle str_obj) { 69 const char* DartUtils::GetStringValue(Dart_Handle str_obj) {
57 const char* cstring = NULL; 70 const char* cstring = NULL;
58 Dart_Handle result = Dart_StringToCString(str_obj, &cstring); 71 Dart_Handle result = Dart_StringToCString(str_obj, &cstring);
59 ASSERT(!Dart_IsError(result)); 72 ASSERT(!Dart_IsError(result));
60 return cstring; 73 return cstring;
61 } 74 }
62 75
63 76
64 bool DartUtils::GetBooleanValue(Dart_Handle bool_obj) { 77 bool DartUtils::GetBooleanValue(Dart_Handle bool_obj) {
65 bool value = false; 78 bool value = false;
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 452
440 CObject* CObject::NewOSError(OSError* os_error) { 453 CObject* CObject::NewOSError(OSError* os_error) {
441 CObject* error_message = 454 CObject* error_message =
442 new CObjectString(CObject::NewString(os_error->message())); 455 new CObjectString(CObject::NewString(os_error->message()));
443 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); 456 CObjectArray* result = new CObjectArray(CObject::NewArray(3));
444 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); 457 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError)));
445 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); 458 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code())));
446 result->SetAt(2, error_message); 459 result->SetAt(2, error_message);
447 return result; 460 return result;
448 } 461 }
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