| 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 "include/dart_api.h" | 5 #include "include/dart_api.h" |
| 6 #include "platform/assert.h" | 6 #include "platform/assert.h" |
| 7 #include "platform/json.h" | 7 #include "platform/json.h" |
| 8 #include "platform/utils.h" | 8 #include "platform/utils.h" |
| 9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
| 10 #include "vm/dart_api_impl.h" | 10 #include "vm/dart_api_impl.h" |
| (...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 result = Dart_TypedDataReleaseData(array); | 951 result = Dart_TypedDataReleaseData(array); |
| 952 EXPECT_VALID(result); | 952 EXPECT_VALID(result); |
| 953 | 953 |
| 954 // Invoke the dart function in order to check the modified values. | 954 // Invoke the dart function in order to check the modified values. |
| 955 Dart_Invoke(lib, NewString("testMain"), 1, dart_args); | 955 Dart_Invoke(lib, NewString("testMain"), 1, dart_args); |
| 956 } | 956 } |
| 957 | 957 |
| 958 | 958 |
| 959 TEST_CASE(TypedDataDirectAccess1) { | 959 TEST_CASE(TypedDataDirectAccess1) { |
| 960 const char* kScriptChars = | 960 const char* kScriptChars = |
| 961 "import 'dart:scalarlist';\n" | 961 "import 'dart:typeddata';\n" |
| 962 "void setMain(var a) {" | 962 "void setMain(var a) {" |
| 963 " for (var i = 0; i < 10; i++) {" | 963 " for (var i = 0; i < 10; i++) {" |
| 964 " a[i] = i;" | 964 " a[i] = i;" |
| 965 " }" | 965 " }" |
| 966 "}\n" | 966 "}\n" |
| 967 "void testMain(var list) {" | 967 "void testMain(var list) {" |
| 968 " for (var i = 0; i < 10; i++) {" | 968 " for (var i = 0; i < 10; i++) {" |
| 969 " Expect.equals((10 + i), list[i]);" | 969 " Expect.equals((10 + i), list[i]);" |
| 970 " }\n" | 970 " }\n" |
| 971 "}\n" | 971 "}\n" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 993 EXPECT_VALID(ext_list_access_test_obj); | 993 EXPECT_VALID(ext_list_access_test_obj); |
| 994 TestDirectAccess(lib, ext_list_access_test_obj, kUint8); | 994 TestDirectAccess(lib, ext_list_access_test_obj, kUint8); |
| 995 } | 995 } |
| 996 | 996 |
| 997 | 997 |
| 998 static void ExternalTypedDataAccessTests(Dart_Handle obj, | 998 static void ExternalTypedDataAccessTests(Dart_Handle obj, |
| 999 Dart_TypedData_Type expected_type, | 999 Dart_TypedData_Type expected_type, |
| 1000 uint8_t data[], | 1000 uint8_t data[], |
| 1001 intptr_t data_length) { | 1001 intptr_t data_length) { |
| 1002 EXPECT_VALID(obj); | 1002 EXPECT_VALID(obj); |
| 1003 EXPECT_EQ(expected_type, Dart_GetTypeOfTypedData(obj)); | |
| 1004 EXPECT_EQ(expected_type, Dart_GetTypeOfExternalTypedData(obj)); | 1003 EXPECT_EQ(expected_type, Dart_GetTypeOfExternalTypedData(obj)); |
| 1005 EXPECT(Dart_IsList(obj)); | 1004 EXPECT(Dart_IsList(obj)); |
| 1006 | 1005 |
| 1007 void* raw_data = NULL; | 1006 void* raw_data = NULL; |
| 1008 intptr_t len; | 1007 intptr_t len; |
| 1009 Dart_TypedData_Type type; | 1008 Dart_TypedData_Type type; |
| 1010 EXPECT_VALID(Dart_TypedDataAcquireData(obj, &type, &raw_data, &len)); | 1009 EXPECT_VALID(Dart_TypedDataAcquireData(obj, &type, &raw_data, &len)); |
| 1011 EXPECT(raw_data == data); | 1010 EXPECT(raw_data == data); |
| 1012 EXPECT_EQ(data_length, len); | 1011 EXPECT_EQ(data_length, len); |
| 1013 EXPECT_EQ(expected_type, type); | 1012 EXPECT_EQ(expected_type, type); |
| (...skipping 6416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7430 NULL); | 7429 NULL); |
| 7431 int64_t value = 0; | 7430 int64_t value = 0; |
| 7432 result = Dart_IntegerToInt64(result, &value); | 7431 result = Dart_IntegerToInt64(result, &value); |
| 7433 EXPECT_VALID(result); | 7432 EXPECT_VALID(result); |
| 7434 EXPECT_EQ(260, value); | 7433 EXPECT_EQ(260, value); |
| 7435 } | 7434 } |
| 7436 | 7435 |
| 7437 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 7436 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
| 7438 | 7437 |
| 7439 } // namespace dart | 7438 } // namespace dart |
| OLD | NEW |