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