| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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_native_api.h" | 5 #include "include/dart_native_api.h" |
| 6 | 6 |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "vm/dart_api_impl.h" | 8 #include "vm/dart_api_impl.h" |
| 9 #include "vm/dart_api_message.h" | 9 #include "vm/dart_api_message.h" |
| 10 #include "vm/dart_api_state.h" | 10 #include "vm/dart_api_state.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 } | 75 } |
| 76 Dart_CObject cobj; | 76 Dart_CObject cobj; |
| 77 cobj.type = Dart_CObject_kInt64; | 77 cobj.type = Dart_CObject_kInt64; |
| 78 cobj.value.as_int64 = message; | 78 cobj.value.as_int64 = message; |
| 79 return PostCObjectHelper(port_id, &cobj); | 79 return PostCObjectHelper(port_id, &cobj); |
| 80 } | 80 } |
| 81 | 81 |
| 82 | 82 |
| 83 DART_EXPORT Dart_Port Dart_NewNativePort(const char* name, | 83 DART_EXPORT Dart_Port Dart_NewNativePort(const char* name, |
| 84 Dart_NativeMessageHandler handler, | 84 Dart_NativeMessageHandler handler, |
| 85 bool handle_concurrently) { | 85 bool handle_concurrently, |
| 86 void* peer) { |
| 86 if (name == NULL) { | 87 if (name == NULL) { |
| 87 name = "<UnnamedNativePort>"; | 88 name = "<UnnamedNativePort>"; |
| 88 } | 89 } |
| 89 if (handler == NULL) { | 90 if (handler == NULL) { |
| 90 OS::PrintErr("%s expects argument 'handler' to be non-null.\n", | 91 OS::PrintErr("%s expects argument 'handler' to be non-null.\n", |
| 91 CURRENT_FUNC); | 92 CURRENT_FUNC); |
| 92 return ILLEGAL_PORT; | 93 return ILLEGAL_PORT; |
| 93 } | 94 } |
| 94 // Start the native port without a current isolate. | 95 // Start the native port without a current isolate. |
| 95 IsolateSaver saver(Isolate::Current()); | 96 IsolateSaver saver(Isolate::Current()); |
| 96 | 97 |
| 97 NativeMessageHandler* nmh = new NativeMessageHandler(name, handler); | 98 NativeMessageHandler* nmh = new NativeMessageHandler(name, handler, peer); |
| 98 Dart_Port port_id = PortMap::CreatePort(nmh); | 99 Dart_Port port_id = PortMap::CreatePort(nmh); |
| 99 PortMap::SetPortState(port_id, PortMap::kLivePort); | 100 PortMap::SetPortState(port_id, PortMap::kLivePort); |
| 100 nmh->Run(Dart::thread_pool(), NULL, NULL, 0); | 101 nmh->Run(Dart::thread_pool(), NULL, NULL, 0); |
| 101 return port_id; | 102 return port_id; |
| 102 } | 103 } |
| 103 | 104 |
| 104 | 105 |
| 105 DART_EXPORT bool Dart_CloseNativePort(Dart_Port native_port_id) { | 106 DART_EXPORT bool Dart_CloseNativePort(Dart_Port native_port_id) { |
| 106 // Close the native port without a current isolate. | 107 // Close the native port without a current isolate. |
| 107 IsolateSaver saver(Isolate::Current()); | 108 IsolateSaver saver(Isolate::Current()); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 Dart_Handle result = Api::CheckAndFinalizePendingClasses(T); | 153 Dart_Handle result = Api::CheckAndFinalizePendingClasses(T); |
| 153 if (::Dart_IsError(result)) { | 154 if (::Dart_IsError(result)) { |
| 154 return result; | 155 return result; |
| 155 } | 156 } |
| 156 CHECK_CALLBACK_STATE(T); | 157 CHECK_CALLBACK_STATE(T); |
| 157 ParseAll(T, &result); | 158 ParseAll(T, &result); |
| 158 return result; | 159 return result; |
| 159 } | 160 } |
| 160 | 161 |
| 161 } // namespace dart | 162 } // namespace dart |
| OLD | NEW |