| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 "include/dart_api.h" | 5 #include "include/dart_api.h" |
| 6 #include "include/dart_mirrors_api.h" | 6 #include "include/dart_mirrors_api.h" |
| 7 #include "include/dart_native_api.h" | 7 #include "include/dart_native_api.h" |
| 8 | 8 |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 #include "lib/stacktrace.h" | 10 #include "lib/stacktrace.h" |
| (...skipping 2284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2295 if (bigint.FitsIntoUint64()) { | 2295 if (bigint.FitsIntoUint64()) { |
| 2296 *value = bigint.AsUint64Value(); | 2296 *value = bigint.AsUint64Value(); |
| 2297 return Api::Success(); | 2297 return Api::Success(); |
| 2298 } | 2298 } |
| 2299 } | 2299 } |
| 2300 return Api::NewError("%s: Integer %s cannot be represented as a uint64_t.", | 2300 return Api::NewError("%s: Integer %s cannot be represented as a uint64_t.", |
| 2301 CURRENT_FUNC, int_obj.ToCString()); | 2301 CURRENT_FUNC, int_obj.ToCString()); |
| 2302 } | 2302 } |
| 2303 | 2303 |
| 2304 | 2304 |
| 2305 static uword BigintAllocate(intptr_t size) { | |
| 2306 return Api::TopScope(Thread::Current())->zone()->AllocUnsafe(size); | |
| 2307 } | |
| 2308 | |
| 2309 | |
| 2310 DART_EXPORT Dart_Handle Dart_IntegerToHexCString(Dart_Handle integer, | 2305 DART_EXPORT Dart_Handle Dart_IntegerToHexCString(Dart_Handle integer, |
| 2311 const char** value) { | 2306 const char** value) { |
| 2312 API_TIMELINE_DURATION; | 2307 API_TIMELINE_DURATION; |
| 2313 DARTSCOPE(Thread::Current()); | 2308 DARTSCOPE(Thread::Current()); |
| 2314 const Integer& int_obj = Api::UnwrapIntegerHandle(Z, integer); | 2309 const Integer& int_obj = Api::UnwrapIntegerHandle(Z, integer); |
| 2315 if (int_obj.IsNull()) { | 2310 if (int_obj.IsNull()) { |
| 2316 RETURN_TYPE_ERROR(Z, integer, Integer); | 2311 RETURN_TYPE_ERROR(Z, integer, Integer); |
| 2317 } | 2312 } |
| 2313 Zone* scope_zone = Api::TopScope(Thread::Current())->zone(); |
| 2318 if (int_obj.IsSmi() || int_obj.IsMint()) { | 2314 if (int_obj.IsSmi() || int_obj.IsMint()) { |
| 2319 const Bigint& bigint = Bigint::Handle(Z, | 2315 const Bigint& bigint = Bigint::Handle(Z, |
| 2320 Bigint::NewFromInt64(int_obj.AsInt64Value())); | 2316 Bigint::NewFromInt64(int_obj.AsInt64Value())); |
| 2321 *value = bigint.ToHexCString(BigintAllocate); | 2317 *value = bigint.ToHexCString(scope_zone); |
| 2322 } else { | 2318 } else { |
| 2323 *value = Bigint::Cast(int_obj).ToHexCString(BigintAllocate); | 2319 *value = Bigint::Cast(int_obj).ToHexCString(scope_zone); |
| 2324 } | 2320 } |
| 2325 return Api::Success(); | 2321 return Api::Success(); |
| 2326 } | 2322 } |
| 2327 | 2323 |
| 2328 | 2324 |
| 2329 DART_EXPORT Dart_Handle Dart_NewDouble(double value) { | 2325 DART_EXPORT Dart_Handle Dart_NewDouble(double value) { |
| 2330 DARTSCOPE(Thread::Current()); | 2326 DARTSCOPE(Thread::Current()); |
| 2331 CHECK_CALLBACK_STATE(T); | 2327 CHECK_CALLBACK_STATE(T); |
| 2332 return Api::NewHandle(T, Double::New(value)); | 2328 return Api::NewHandle(T, Double::New(value)); |
| 2333 } | 2329 } |
| (...skipping 4310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6644 | 6640 |
| 6645 DART_EXPORT bool Dart_IsPrecompiledRuntime() { | 6641 DART_EXPORT bool Dart_IsPrecompiledRuntime() { |
| 6646 #if defined(DART_PRECOMPILED_RUNTIME) | 6642 #if defined(DART_PRECOMPILED_RUNTIME) |
| 6647 return true; | 6643 return true; |
| 6648 #else | 6644 #else |
| 6649 return false; | 6645 return false; |
| 6650 #endif | 6646 #endif |
| 6651 } | 6647 } |
| 6652 | 6648 |
| 6653 } // namespace dart | 6649 } // namespace dart |
| OLD | NEW |