| 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 6997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7008 EXPECT_NOTNULL(message); | 7008 EXPECT_NOTNULL(message); |
| 7009 EXPECT_EQ(Dart_CObject_kArray, message->type); | 7009 EXPECT_EQ(Dart_CObject_kArray, message->type); |
| 7010 EXPECT_EQ(Dart_CObject_kSendPort, message->value.as_array.values[0]->type); | 7010 EXPECT_EQ(Dart_CObject_kSendPort, message->value.as_array.values[0]->type); |
| 7011 | 7011 |
| 7012 // Post integer value. | 7012 // Post integer value. |
| 7013 Dart_CObject* response = | 7013 Dart_CObject* response = |
| 7014 reinterpret_cast<Dart_CObject*>(Dart_ScopeAllocate(sizeof(Dart_CObject))); | 7014 reinterpret_cast<Dart_CObject*>(Dart_ScopeAllocate(sizeof(Dart_CObject))); |
| 7015 response->type = Dart_CObject_kInt32; | 7015 response->type = Dart_CObject_kInt32; |
| 7016 response->value.as_int32 = 123; | 7016 response->value.as_int32 = 123; |
| 7017 Dart_PostCObject( | 7017 Dart_PostCObject( |
| 7018 message->value.as_array.values[0]->value.as_send_port, response); | 7018 message->value.as_array.values[0]->value.as_send_port.id, response); |
| 7019 } | 7019 } |
| 7020 | 7020 |
| 7021 | 7021 |
| 7022 void NewNativePort_send321(Dart_Port dest_port_id, | 7022 void NewNativePort_send321(Dart_Port dest_port_id, |
| 7023 Dart_CObject* message) { | 7023 Dart_CObject* message) { |
| 7024 // Gets a null message. | 7024 // Gets a null message. |
| 7025 EXPECT_NOTNULL(message); | 7025 EXPECT_NOTNULL(message); |
| 7026 EXPECT_EQ(Dart_CObject_kSendPort, message->value.as_array.values[0]->type); | 7026 EXPECT_EQ(Dart_CObject_kSendPort, message->value.as_array.values[0]->type); |
| 7027 | 7027 |
| 7028 // Post integer value. | 7028 // Post integer value. |
| 7029 Dart_CObject* response = | 7029 Dart_CObject* response = |
| 7030 reinterpret_cast<Dart_CObject*>(Dart_ScopeAllocate(sizeof(Dart_CObject))); | 7030 reinterpret_cast<Dart_CObject*>(Dart_ScopeAllocate(sizeof(Dart_CObject))); |
| 7031 response->type = Dart_CObject_kInt32; | 7031 response->type = Dart_CObject_kInt32; |
| 7032 response->value.as_int32 = 321; | 7032 response->value.as_int32 = 321; |
| 7033 Dart_PostCObject( | 7033 Dart_PostCObject( |
| 7034 message->value.as_array.values[0]->value.as_send_port, response); | 7034 message->value.as_array.values[0]->value.as_send_port.id, response); |
| 7035 } | 7035 } |
| 7036 | 7036 |
| 7037 | 7037 |
| 7038 UNIT_TEST_CASE(NewNativePort) { | 7038 UNIT_TEST_CASE(NewNativePort) { |
| 7039 // Create a port with a bogus handler. | 7039 // Create a port with a bogus handler. |
| 7040 Dart_Port error_port = Dart_NewNativePort("Foo", NULL, true); | 7040 Dart_Port error_port = Dart_NewNativePort("Foo", NULL, true); |
| 7041 EXPECT_EQ(ILLEGAL_PORT, error_port); | 7041 EXPECT_EQ(ILLEGAL_PORT, error_port); |
| 7042 | 7042 |
| 7043 // Create the port w/o a current isolate, just to make sure that works. | 7043 // Create the port w/o a current isolate, just to make sure that works. |
| 7044 Dart_Port port_id1 = | 7044 Dart_Port port_id1 = |
| (...skipping 1672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8717 NewString("main"), | 8717 NewString("main"), |
| 8718 1, | 8718 1, |
| 8719 dart_args); | 8719 dart_args); |
| 8720 int64_t value = 0; | 8720 int64_t value = 0; |
| 8721 result = Dart_IntegerToInt64(result, &value); | 8721 result = Dart_IntegerToInt64(result, &value); |
| 8722 EXPECT_VALID(result); | 8722 EXPECT_VALID(result); |
| 8723 EXPECT_EQ(6, value); | 8723 EXPECT_EQ(6, value); |
| 8724 } | 8724 } |
| 8725 | 8725 |
| 8726 } // namespace dart | 8726 } // namespace dart |
| OLD | NEW |