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 13 matching lines...) Expand all Loading... |
24 | 24 |
25 DART_EXPORT bool Dart_PostCObject(Dart_Port port_id, Dart_CObject* message) { | 25 DART_EXPORT bool Dart_PostCObject(Dart_Port port_id, Dart_CObject* message) { |
26 uint8_t* buffer = NULL; | 26 uint8_t* buffer = NULL; |
27 ApiMessageWriter writer(&buffer, allocator); | 27 ApiMessageWriter writer(&buffer, allocator); |
28 bool success = writer.WriteCMessage(message); | 28 bool success = writer.WriteCMessage(message); |
29 | 29 |
30 if (!success) return success; | 30 if (!success) return success; |
31 | 31 |
32 // Post the message at the given port. | 32 // Post the message at the given port. |
33 return PortMap::PostMessage(new Message( | 33 return PortMap::PostMessage(new Message( |
34 port_id, Message::kIllegalPort, buffer, writer.BytesWritten(), | 34 port_id, buffer, writer.BytesWritten(), Message::kNormalPriority)); |
35 Message::kNormalPriority)); | |
36 } | 35 } |
37 | 36 |
38 | 37 |
39 DART_EXPORT Dart_Port Dart_NewNativePort(const char* name, | 38 DART_EXPORT Dart_Port Dart_NewNativePort(const char* name, |
40 Dart_NativeMessageHandler handler, | 39 Dart_NativeMessageHandler handler, |
41 bool handle_concurrently) { | 40 bool handle_concurrently) { |
42 if (name == NULL) { | 41 if (name == NULL) { |
43 name = "<UnnamedNativePort>"; | 42 name = "<UnnamedNativePort>"; |
44 } | 43 } |
45 if (handler == NULL) { | 44 if (handler == NULL) { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 Dart_Handle result = Api::CheckIsolateState(isolate); | 113 Dart_Handle result = Api::CheckIsolateState(isolate); |
115 if (::Dart_IsError(result)) { | 114 if (::Dart_IsError(result)) { |
116 return result; | 115 return result; |
117 } | 116 } |
118 CHECK_CALLBACK_STATE(isolate); | 117 CHECK_CALLBACK_STATE(isolate); |
119 CompileAll(isolate, &result); | 118 CompileAll(isolate, &result); |
120 return result; | 119 return result; |
121 } | 120 } |
122 | 121 |
123 } // namespace dart | 122 } // namespace dart |
OLD | NEW |