| 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/utils.h" | 7 #include "platform/utils.h" |
| 8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
| 9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
| 10 #include "vm/dart_api_state.h" | 10 #include "vm/dart_api_state.h" |
| (...skipping 3368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3379 | 3379 |
| 3380 | 3380 |
| 3381 void NewNativePort_send123(Dart_Port dest_port_id, | 3381 void NewNativePort_send123(Dart_Port dest_port_id, |
| 3382 Dart_Port reply_port_id, | 3382 Dart_Port reply_port_id, |
| 3383 Dart_CObject *message) { | 3383 Dart_CObject *message) { |
| 3384 // Gets a null message. | 3384 // Gets a null message. |
| 3385 EXPECT_NOTNULL(message); | 3385 EXPECT_NOTNULL(message); |
| 3386 EXPECT_EQ(Dart_CObject::kNull, message->type); | 3386 EXPECT_EQ(Dart_CObject::kNull, message->type); |
| 3387 | 3387 |
| 3388 // Post integer value. | 3388 // Post integer value. |
| 3389 Dart_CObject response; | 3389 Dart_CObject* response = |
| 3390 response.type = Dart_CObject::kInt32; | 3390 reinterpret_cast<Dart_CObject*>(Dart_ZoneAllocate(sizeof(Dart_CObject))); |
| 3391 response.value.as_int32 = 123; | 3391 response->type = Dart_CObject::kInt32; |
| 3392 Dart_PostCObject(reply_port_id, &response); | 3392 response->value.as_int32 = 123; |
| 3393 Dart_PostCObject(reply_port_id, response); |
| 3393 } | 3394 } |
| 3394 | 3395 |
| 3395 | 3396 |
| 3396 void NewNativePort_send321(Dart_Port dest_port_id, | 3397 void NewNativePort_send321(Dart_Port dest_port_id, |
| 3397 Dart_Port reply_port_id, | 3398 Dart_Port reply_port_id, |
| 3398 Dart_CObject* message) { | 3399 Dart_CObject* message) { |
| 3399 // Gets a null message. | 3400 // Gets a null message. |
| 3400 EXPECT_NOTNULL(message); | 3401 EXPECT_NOTNULL(message); |
| 3401 EXPECT_EQ(Dart_CObject::kNull, message->type); | 3402 EXPECT_EQ(Dart_CObject::kNull, message->type); |
| 3402 | 3403 |
| 3403 // Post integer value. | 3404 // Post integer value. |
| 3404 Dart_CObject response; | 3405 Dart_CObject* response = |
| 3405 response.type = Dart_CObject::kInt32; | 3406 reinterpret_cast<Dart_CObject*>(Dart_ZoneAllocate(sizeof(Dart_CObject))); |
| 3406 response.value.as_int32 = 321; | 3407 response->type = Dart_CObject::kInt32; |
| 3407 Dart_PostCObject(reply_port_id, &response); | 3408 response->value.as_int32 = 321; |
| 3409 Dart_PostCObject(reply_port_id, response); |
| 3408 } | 3410 } |
| 3409 | 3411 |
| 3410 | 3412 |
| 3411 UNIT_TEST_CASE(NewNativePort) { | 3413 UNIT_TEST_CASE(NewNativePort) { |
| 3412 // Create a port with a bogus handler. | 3414 // Create a port with a bogus handler. |
| 3413 Dart_Port error_port = Dart_NewNativePort("Foo", NULL, true); | 3415 Dart_Port error_port = Dart_NewNativePort("Foo", NULL, true); |
| 3414 EXPECT_EQ(kIllegalPort, error_port); | 3416 EXPECT_EQ(kIllegalPort, error_port); |
| 3415 | 3417 |
| 3416 // Create the port w/o a current isolate, just to make sure that works. | 3418 // Create the port w/o a current isolate, just to make sure that works. |
| 3417 Dart_Port port_id1 = | 3419 Dart_Port port_id1 = |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3727 // We should have received the expected number of interrupts. | 3729 // We should have received the expected number of interrupts. |
| 3728 EXPECT_EQ(kInterruptCount, interrupt_count); | 3730 EXPECT_EQ(kInterruptCount, interrupt_count); |
| 3729 | 3731 |
| 3730 // Give the spawned thread enough time to properly exit. | 3732 // Give the spawned thread enough time to properly exit. |
| 3731 Isolate::SetInterruptCallback(saved); | 3733 Isolate::SetInterruptCallback(saved); |
| 3732 } | 3734 } |
| 3733 | 3735 |
| 3734 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 3736 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
| 3735 | 3737 |
| 3736 } // namespace dart | 3738 } // namespace dart |
| OLD | NEW |