| 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/builtin.h" | 5 #include "bin/builtin.h" |
| 6 #include "include/dart_api.h" | 6 #include "include/dart_api.h" |
| 7 #include "include/dart_debugger_api.h" | 7 #include "include/dart_debugger_api.h" |
| 8 #include "include/dart_mirrors_api.h" | 8 #include "include/dart_mirrors_api.h" |
| 9 #include "include/dart_native_api.h" | 9 #include "include/dart_native_api.h" |
| 10 #include "platform/assert.h" | 10 #include "platform/assert.h" |
| (...skipping 5298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5309 | 5309 |
| 5310 static intptr_t kNativeArgumentNativeField1Value = 30; | 5310 static intptr_t kNativeArgumentNativeField1Value = 30; |
| 5311 static intptr_t kNativeArgumentNativeField2Value = 40; | 5311 static intptr_t kNativeArgumentNativeField2Value = 40; |
| 5312 static intptr_t native_arg_str_peer = 100; | 5312 static intptr_t native_arg_str_peer = 100; |
| 5313 static void NativeArgumentCreate(Dart_NativeArguments args) { | 5313 static void NativeArgumentCreate(Dart_NativeArguments args) { |
| 5314 Dart_Handle lib = Dart_LookupLibrary(NewString(TestCase::url())); | 5314 Dart_Handle lib = Dart_LookupLibrary(NewString(TestCase::url())); |
| 5315 Dart_Handle type = Dart_GetType(lib, NewString("MyObject"), 0, NULL); | 5315 Dart_Handle type = Dart_GetType(lib, NewString("MyObject"), 0, NULL); |
| 5316 EXPECT_VALID(type); | 5316 EXPECT_VALID(type); |
| 5317 | 5317 |
| 5318 // Allocate without a constructor. | 5318 // Allocate without a constructor. |
| 5319 Dart_Handle obj = Dart_Allocate(type); | 5319 const int num_native_fields = 2; |
| 5320 const intptr_t native_fields[] = { |
| 5321 kNativeArgumentNativeField1Value, |
| 5322 kNativeArgumentNativeField2Value |
| 5323 }; |
| 5324 // Allocate and Setup native fields. |
| 5325 Dart_Handle obj = Dart_AllocateWithNativeFields(type, |
| 5326 num_native_fields, |
| 5327 native_fields); |
| 5320 EXPECT_VALID(obj); | 5328 EXPECT_VALID(obj); |
| 5321 | 5329 |
| 5322 // Setup native fields. | |
| 5323 Dart_SetNativeInstanceField(obj, 0, kNativeArgumentNativeField1Value); | |
| 5324 Dart_SetNativeInstanceField(obj, 1, kNativeArgumentNativeField2Value); | |
| 5325 kNativeArgumentNativeField1Value *= 2; | 5330 kNativeArgumentNativeField1Value *= 2; |
| 5326 kNativeArgumentNativeField2Value *= 2; | 5331 kNativeArgumentNativeField2Value *= 2; |
| 5327 Dart_SetReturnValue(args, obj); | 5332 Dart_SetReturnValue(args, obj); |
| 5328 } | 5333 } |
| 5329 | 5334 |
| 5330 | 5335 |
| 5331 static void NativeArgumentAccess(Dart_NativeArguments args) { | 5336 static void NativeArgumentAccess(Dart_NativeArguments args) { |
| 5332 const int kNumNativeFields = 2; | 5337 const int kNumNativeFields = 2; |
| 5333 | 5338 |
| 5334 // Test different argument types with a valid descriptor set. | 5339 // Test different argument types with a valid descriptor set. |
| (...skipping 3172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8507 NewString("main"), | 8512 NewString("main"), |
| 8508 1, | 8513 1, |
| 8509 dart_args); | 8514 dart_args); |
| 8510 int64_t value = 0; | 8515 int64_t value = 0; |
| 8511 result = Dart_IntegerToInt64(result, &value); | 8516 result = Dart_IntegerToInt64(result, &value); |
| 8512 EXPECT_VALID(result); | 8517 EXPECT_VALID(result); |
| 8513 EXPECT_EQ(6, value); | 8518 EXPECT_EQ(6, value); |
| 8514 } | 8519 } |
| 8515 | 8520 |
| 8516 } // namespace dart | 8521 } // namespace dart |
| OLD | NEW |