OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 2 * Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
3 * for details. All rights reserved. Use of this source code is governed by a | 3 * for details. All rights reserved. Use of this source code is governed by a |
4 * BSD-style license that can be found in the LICENSE file. | 4 * BSD-style license that can be found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 #ifndef RUNTIME_INCLUDE_DART_NATIVE_API_H_ | 7 #ifndef RUNTIME_INCLUDE_DART_NATIVE_API_H_ |
8 #define RUNTIME_INCLUDE_DART_NATIVE_API_H_ | 8 #define RUNTIME_INCLUDE_DART_NATIVE_API_H_ |
9 | 9 |
10 #include "include/dart_api.h" | 10 #include "include/dart_api.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 * This handler is associated with a native port by calling | 117 * This handler is associated with a native port by calling |
118 * Dart_NewNativePort. | 118 * Dart_NewNativePort. |
119 * | 119 * |
120 * The message received is decoded into the message structure. The | 120 * The message received is decoded into the message structure. The |
121 * lifetime of the message data is controlled by the caller. All the | 121 * lifetime of the message data is controlled by the caller. All the |
122 * data references from the message are allocated by the caller and | 122 * data references from the message are allocated by the caller and |
123 * will be reclaimed when returning to it. | 123 * will be reclaimed when returning to it. |
124 */ | 124 */ |
125 | 125 |
126 typedef void (*Dart_NativeMessageHandler)(Dart_Port dest_port_id, | 126 typedef void (*Dart_NativeMessageHandler)(Dart_Port dest_port_id, |
127 Dart_CObject* message); | 127 Dart_CObject* message, |
| 128 void* peer); |
128 | 129 |
129 /** | 130 /** |
130 * Creates a new native port. When messages are received on this | 131 * Creates a new native port. When messages are received on this |
131 * native port, then they will be dispatched to the provided native | 132 * native port, then they will be dispatched to the provided native |
132 * message handler. | 133 * message handler. |
133 * | 134 * |
134 * \param name The name of this port in debugging messages. | 135 * \param name The name of this port in debugging messages. |
135 * \param handler The C handler to run when messages arrive on the port. | 136 * \param handler The C handler to run when messages arrive on the port. |
136 * \param handle_concurrently Is it okay to process requests on this | 137 * \param handle_concurrently Is it okay to process requests on this |
137 * native port concurrently? | 138 * native port concurrently? |
| 139 * \param peer Peer associated with this port. It will be passed down to the |
| 140 handler when new message arrives. |
138 * | 141 * |
139 * \return If successful, returns the port id for the native port. In | 142 * \return If successful, returns the port id for the native port. In |
140 * case of error, returns ILLEGAL_PORT. | 143 * case of error, returns ILLEGAL_PORT. |
141 */ | 144 */ |
142 DART_EXPORT Dart_Port Dart_NewNativePort(const char* name, | 145 DART_EXPORT Dart_Port Dart_NewNativePort(const char* name, |
143 Dart_NativeMessageHandler handler, | 146 Dart_NativeMessageHandler handler, |
144 bool handle_concurrently); | 147 bool handle_concurrently, |
| 148 void* peer); |
145 /* TODO(turnidge): Currently handle_concurrently is ignored. */ | 149 /* TODO(turnidge): Currently handle_concurrently is ignored. */ |
146 | 150 |
147 /** | 151 /** |
148 * Closes the native port with the given id. | 152 * Closes the native port with the given id. |
149 * | 153 * |
150 * The port must have been allocated by a call to Dart_NewNativePort. | 154 * The port must have been allocated by a call to Dart_NewNativePort. |
151 * | 155 * |
152 * \param native_port_id The id of the native port to close. | 156 * \param native_port_id The id of the native port to close. |
153 * | 157 * |
154 * \return Returns true if the port was closed successfully. | 158 * \return Returns true if the port was closed successfully. |
(...skipping 15 matching lines...) Expand all Loading... |
170 */ | 174 */ |
171 DART_EXPORT Dart_Handle Dart_CompileAll(); | 175 DART_EXPORT Dart_Handle Dart_CompileAll(); |
172 | 176 |
173 /** | 177 /** |
174 * Parses all loaded functions in the current isolate.. | 178 * Parses all loaded functions in the current isolate.. |
175 * | 179 * |
176 */ | 180 */ |
177 DART_EXPORT Dart_Handle Dart_ParseAll(); | 181 DART_EXPORT Dart_Handle Dart_ParseAll(); |
178 | 182 |
179 #endif /* INCLUDE_DART_NATIVE_API_H_ */ /* NOLINT */ | 183 #endif /* INCLUDE_DART_NATIVE_API_H_ */ /* NOLINT */ |
OLD | NEW |