| OLD | NEW |
| 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 Loading... |
| 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 | |
| 69 const char* DartUtils::GetStringValue(Dart_Handle str_obj) { | 56 const char* DartUtils::GetStringValue(Dart_Handle str_obj) { |
| 70 const char* cstring = NULL; | 57 const char* cstring = NULL; |
| 71 Dart_Handle result = Dart_StringToCString(str_obj, &cstring); | 58 Dart_Handle result = Dart_StringToCString(str_obj, &cstring); |
| 72 ASSERT(!Dart_IsError(result)); | 59 ASSERT(!Dart_IsError(result)); |
| 73 return cstring; | 60 return cstring; |
| 74 } | 61 } |
| 75 | 62 |
| 76 | 63 |
| 77 bool DartUtils::GetBooleanValue(Dart_Handle bool_obj) { | 64 bool DartUtils::GetBooleanValue(Dart_Handle bool_obj) { |
| 78 bool value = false; | 65 bool value = false; |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 | 439 |
| 453 CObject* CObject::NewOSError(OSError* os_error) { | 440 CObject* CObject::NewOSError(OSError* os_error) { |
| 454 CObject* error_message = | 441 CObject* error_message = |
| 455 new CObjectString(CObject::NewString(os_error->message())); | 442 new CObjectString(CObject::NewString(os_error->message())); |
| 456 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); | 443 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); |
| 457 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); | 444 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); |
| 458 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); | 445 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); |
| 459 result->SetAt(2, error_message); | 446 result->SetAt(2, error_message); |
| 460 return result; | 447 return result; |
| 461 } | 448 } |
| OLD | NEW |