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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 | 52 |
53 | 53 |
54 DECLARE_FLAG(bool, print_class_table); | 54 DECLARE_FLAG(bool, print_class_table); |
55 DECLARE_FLAG(bool, verify_handles); | 55 DECLARE_FLAG(bool, verify_handles); |
56 #if defined(DART_NO_SNAPSHOT) | 56 #if defined(DART_NO_SNAPSHOT) |
57 DEFINE_FLAG(bool, check_function_fingerprints, true, | 57 DEFINE_FLAG(bool, check_function_fingerprints, true, |
58 "Check function fingerprints"); | 58 "Check function fingerprints"); |
59 #endif // defined(DART_NO_SNAPSHOT). | 59 #endif // defined(DART_NO_SNAPSHOT). |
60 DEFINE_FLAG(bool, verify_acquired_data, false, | 60 DEFINE_FLAG(bool, verify_acquired_data, false, |
61 "Verify correct API acquire/release of typed data."); | 61 "Verify correct API acquire/release of typed data."); |
| 62 DEFINE_FLAG(bool, support_externalizable_strings, true, |
| 63 "Support Dart_MakeExternalString."); |
| 64 |
62 | 65 |
63 ThreadLocalKey Api::api_native_key_ = kUnsetThreadLocalKey; | 66 ThreadLocalKey Api::api_native_key_ = kUnsetThreadLocalKey; |
64 Dart_Handle Api::true_handle_ = NULL; | 67 Dart_Handle Api::true_handle_ = NULL; |
65 Dart_Handle Api::false_handle_ = NULL; | 68 Dart_Handle Api::false_handle_ = NULL; |
66 Dart_Handle Api::null_handle_ = NULL; | 69 Dart_Handle Api::null_handle_ = NULL; |
67 Dart_Handle Api::empty_string_handle_ = NULL; | 70 Dart_Handle Api::empty_string_handle_ = NULL; |
68 | 71 |
69 | 72 |
70 const char* CanonicalFunction(const char* func) { | 73 const char* CanonicalFunction(const char* func) { |
71 if (strncmp(func, "dart::", 6) == 0) { | 74 if (strncmp(func, "dart::", 6) == 0) { |
(...skipping 2440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2512 return Api::Success(); | 2515 return Api::Success(); |
2513 } | 2516 } |
2514 | 2517 |
2515 | 2518 |
2516 DART_EXPORT Dart_Handle Dart_MakeExternalString(Dart_Handle str, | 2519 DART_EXPORT Dart_Handle Dart_MakeExternalString(Dart_Handle str, |
2517 void* array, | 2520 void* array, |
2518 intptr_t length, | 2521 intptr_t length, |
2519 void* peer, | 2522 void* peer, |
2520 Dart_PeerFinalizer cback) { | 2523 Dart_PeerFinalizer cback) { |
2521 DARTSCOPE(Thread::Current()); | 2524 DARTSCOPE(Thread::Current()); |
| 2525 if (!FLAG_support_externalizable_strings) { |
| 2526 return Api::NewError("Dart_MakeExternalString with " |
| 2527 "--support_externalizable_strings=false"); |
| 2528 } |
2522 const String& str_obj = Api::UnwrapStringHandle(Z, str); | 2529 const String& str_obj = Api::UnwrapStringHandle(Z, str); |
2523 if (str_obj.IsExternal()) { | 2530 if (str_obj.IsExternal()) { |
2524 return str; // String is already an external string. | 2531 return str; // String is already an external string. |
2525 } | 2532 } |
2526 if (str_obj.IsNull()) { | 2533 if (str_obj.IsNull()) { |
2527 RETURN_TYPE_ERROR(Z, str, String); | 2534 RETURN_TYPE_ERROR(Z, str, String); |
2528 } | 2535 } |
2529 if (array == NULL) { | 2536 if (array == NULL) { |
2530 RETURN_NULL_ERROR(array); | 2537 RETURN_NULL_ERROR(array); |
2531 } | 2538 } |
(...skipping 3581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6113 return Api::Success(); | 6120 return Api::Success(); |
6114 } | 6121 } |
6115 #endif // DART_PRECOMPILER | 6122 #endif // DART_PRECOMPILER |
6116 | 6123 |
6117 | 6124 |
6118 DART_EXPORT bool Dart_IsRunningPrecompiledCode() { | 6125 DART_EXPORT bool Dart_IsRunningPrecompiledCode() { |
6119 return Dart::IsRunningPrecompiledCode(); | 6126 return Dart::IsRunningPrecompiledCode(); |
6120 } | 6127 } |
6121 | 6128 |
6122 } // namespace dart | 6129 } // namespace dart |
OLD | NEW |