| 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/dart_api_impl.h" | 8 #include "vm/dart_api_impl.h" |
| 9 #include "vm/dart_api_state.h" | 9 #include "vm/dart_api_state.h" |
| 10 #include "vm/thread.h" | 10 #include "vm/thread.h" |
| (...skipping 2872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2883 Dart_NewString(""), | 2883 Dart_NewString(""), |
| 2884 Dart_NewString("main"), | 2884 Dart_NewString("main"), |
| 2885 0, | 2885 0, |
| 2886 NULL); | 2886 NULL); |
| 2887 EXPECT_VALID(result); | 2887 EXPECT_VALID(result); |
| 2888 } | 2888 } |
| 2889 | 2889 |
| 2890 | 2890 |
| 2891 void NewNativePort_send123(Dart_Port dest_port_id, | 2891 void NewNativePort_send123(Dart_Port dest_port_id, |
| 2892 Dart_Port reply_port_id, | 2892 Dart_Port reply_port_id, |
| 2893 uint8_t* data) { | 2893 Dart_CObject *message) { |
| 2894 // Gets a null message. |
| 2895 EXPECT_NOTNULL(message); |
| 2896 EXPECT_EQ(Dart_CObject::kNull, message->type); |
| 2897 |
| 2894 // Post integer value. | 2898 // Post integer value. |
| 2895 Dart_CObject object; | 2899 Dart_CObject response; |
| 2896 object.type = Dart_CObject::kInt32; | 2900 response.type = Dart_CObject::kInt32; |
| 2897 object.value.as_int32 = 123; | 2901 response.value.as_int32 = 123; |
| 2898 Dart_PostCObject(reply_port_id, &object); | 2902 Dart_PostCObject(reply_port_id, &response); |
| 2899 } | 2903 } |
| 2900 | 2904 |
| 2901 | 2905 |
| 2902 void NewNativePort_send321(Dart_Port dest_port_id, | 2906 void NewNativePort_send321(Dart_Port dest_port_id, |
| 2903 Dart_Port reply_port_id, | 2907 Dart_Port reply_port_id, |
| 2904 uint8_t* data) { | 2908 Dart_CObject* message) { |
| 2909 // Gets a null message. |
| 2910 EXPECT_NOTNULL(message); |
| 2911 EXPECT_EQ(Dart_CObject::kNull, message->type); |
| 2912 |
| 2905 // Post integer value. | 2913 // Post integer value. |
| 2906 Dart_CObject object; | 2914 Dart_CObject response; |
| 2907 object.type = Dart_CObject::kInt32; | 2915 response.type = Dart_CObject::kInt32; |
| 2908 object.value.as_int32 = 321; | 2916 response.value.as_int32 = 321; |
| 2909 Dart_PostCObject(reply_port_id, &object); | 2917 Dart_PostCObject(reply_port_id, &response); |
| 2910 } | 2918 } |
| 2911 | 2919 |
| 2912 | 2920 |
| 2913 UNIT_TEST_CASE(NewNativePort) { | 2921 UNIT_TEST_CASE(NewNativePort) { |
| 2914 // Create a port with a bogus handler. | 2922 // Create a port with a bogus handler. |
| 2915 Dart_Port error_port = Dart_NewNativePort("Foo", NULL, true); | 2923 Dart_Port error_port = Dart_NewNativePort("Foo", NULL, true); |
| 2916 EXPECT_EQ(kIllegalPort, error_port); | 2924 EXPECT_EQ(kIllegalPort, error_port); |
| 2917 | 2925 |
| 2918 // Create the port w/o a current isolate, just to make sure that works. | 2926 // Create the port w/o a current isolate, just to make sure that works. |
| 2919 Dart_Port port_id1 = | 2927 Dart_Port port_id1 = |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3224 // We should have received the expected number of interrupts. | 3232 // We should have received the expected number of interrupts. |
| 3225 EXPECT_EQ(kInterruptCount, interrupt_count); | 3233 EXPECT_EQ(kInterruptCount, interrupt_count); |
| 3226 | 3234 |
| 3227 // Give the spawned thread enough time to properly exit. | 3235 // Give the spawned thread enough time to properly exit. |
| 3228 Isolate::SetInterruptCallback(saved); | 3236 Isolate::SetInterruptCallback(saved); |
| 3229 } | 3237 } |
| 3230 | 3238 |
| 3231 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 3239 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
| 3232 | 3240 |
| 3233 } // namespace dart | 3241 } // namespace dart |
| OLD | NEW |