OLD | NEW |
---|---|
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 #ifndef INCLUDE_DART_API_H_ | 5 #ifndef INCLUDE_DART_API_H_ |
6 #define INCLUDE_DART_API_H_ | 6 #define INCLUDE_DART_API_H_ |
7 | 7 |
8 /** \mainpage Dart Embedding API Reference | 8 /** \mainpage Dart Embedding API Reference |
9 * | 9 * |
10 * Dart is a class-based programming language for creating structured | 10 * Dart is a class-based programming language for creating structured |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
219 * | 219 * |
220 * UNIMPLEMENTED. | 220 * UNIMPLEMENTED. |
221 * | 221 * |
222 * Requires there to be a current isolate. | 222 * Requires there to be a current isolate. |
223 */ | 223 */ |
224 DART_EXPORT Dart_Handle Dart_MakePersistentHandle(Dart_Handle object); | 224 DART_EXPORT Dart_Handle Dart_MakePersistentHandle(Dart_Handle object); |
225 | 225 |
226 // --- Initialization and Globals --- | 226 // --- Initialization and Globals --- |
227 | 227 |
228 /** | 228 /** |
229 * An isolate initialization callback function. | 229 * A type for passing error messages back when creation and initialization |
230 * of isolate fails. | |
231 * The caller must ensure that 'buffer' points to a buffer whose length is | |
232 * 'length' and it must also manage the lifetime of this buffer. | |
turnidge
2011/11/28 18:39:58
Since the caller is usually the VM itself instead
siva
2011/11/29 00:54:25
We are passing Dart_ErrorBuffer in Dart_CreateIsol
| |
233 */ | |
234 typedef struct { | |
235 char* buffer; | |
236 int length; | |
237 } Dart_ErrorBuffer; | |
238 | |
239 /** | |
240 * An isolate creation and initialization callback function. | |
230 * | 241 * |
231 * This callback, provided by the embedder, is called during isolate | 242 * This callback, provided by the embedder, is called when an isolate needs |
232 * creation. It is called for all isolates, regardless of whether they | 243 * to be created. The callback should create an isolate and load up the |
turnidge
2011/11/28 18:39:58
Maybe we can say "load" instead of "load up".
siva
2011/11/29 00:54:25
Done.
| |
233 * are created via Dart_CreateIsolate or directly from Dart code. | 244 * required scripts for execution. |
234 * | 245 * |
235 * \param data Embedder-specific data used during isolate initialization. | 246 * \param error A structure into which the embedder can place a |
247 * C string containing an error message in the case of failures. | |
236 * | 248 * |
237 * \return If the embedder returns NULL, then the isolate being | 249 * \return the embedder returns false if the creation and initialization was not |
238 * initialized will be shut down without executing any Dart code. | 250 * successful and true if successful. The embedder is responsible for |
239 * Otherwise, the embedder should return a pointer to | 251 * maintaining consistency in the case of errors (e.g: isolate is created, |
240 * embedder-specific data created during the initialization of this | 252 * but loading of scripts fails then the embedder should ensure that |
241 * isolate. This data will, in turn, be passed by the VM to all | 253 * Dart_ShutdownIsolate is called on the isolate). |
242 * isolates spawned from the isolate currently being initialized. | |
243 */ | 254 */ |
244 typedef void* (*Dart_IsolateInitCallback)(void* embedder_data); | 255 typedef bool (*Dart_IsolateCreateCallback)(void* callback_data, |
245 // TODO(iposva): Pass a specification of the app file being spawned. | 256 Dart_ErrorBuffer error); |
246 // TODO(turnidge): We don't actually shut down the isolate on NULL yet. | |
247 // TODO(turnidge): Should we separate the two return values? | |
248 | 257 |
249 /** | 258 /** |
250 * Initializes the VM with the given commmand line flags. | 259 * Initializes the VM with the given commmand line flags. |
251 * | 260 * |
252 * \param argc The length of the arguments array. | 261 * \param argc The length of the arguments array. |
253 * \param argv An array of arguments. | 262 * \param argv An array of arguments. |
254 * \param callback A function to be called during isolate creation. | 263 * \param callback A function to be called during isolate creation. |
255 * See Dart_IsolateInitCallback. | 264 * See Dart_IsolateCreateCallback. |
256 * | 265 * |
257 * \return True if initialization is successful. | 266 * \return True if initialization is successful. |
258 */ | 267 */ |
259 DART_EXPORT bool Dart_Initialize(int argc, const char** argv, | 268 DART_EXPORT bool Dart_Initialize(int argc, const char** argv, |
260 Dart_IsolateInitCallback callback); | 269 Dart_IsolateCreateCallback callback); |
261 | 270 |
262 /** | 271 /** |
263 * Returns true if the named VM flag is set. | 272 * Returns true if the named VM flag is set. |
264 */ | 273 */ |
265 DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name); | 274 DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name); |
266 | 275 |
267 // --- Isolates --- | 276 // --- Isolates --- |
268 | 277 |
269 /** | 278 /** |
270 * An isolate is the unit of concurrency in Dart. Each isolate has | 279 * An isolate is the unit of concurrency in Dart. Each isolate has |
(...skipping 18 matching lines...) Expand all Loading... | |
289 | 298 |
290 /** | 299 /** |
291 * Creates a new isolate. If snapshot data is provided, the isolate | 300 * Creates a new isolate. If snapshot data is provided, the isolate |
292 * will be started using that snapshot data. The new isolate becomes | 301 * will be started using that snapshot data. The new isolate becomes |
293 * the current isolate. | 302 * the current isolate. |
294 * | 303 * |
295 * Requires there to be no current isolate. | 304 * Requires there to be no current isolate. |
296 * | 305 * |
297 * \param snapshot A buffer containing a VM snapshot or NULL if no | 306 * \param snapshot A buffer containing a VM snapshot or NULL if no |
298 * snapshot is provided. | 307 * snapshot is provided. |
299 * \param data Embedder-specific data. See Dart_IsolateInitCallback. | |
300 * | 308 * |
301 * \return The new isolate is returned. May be NULL if an error | 309 * \return The new isolate is returned. May be NULL if an error |
302 * occurs duing isolate initialization. | 310 * occurs duing isolate initialization. |
303 */ | 311 */ |
304 DART_EXPORT Dart_Isolate Dart_CreateIsolate(const Dart_Snapshot* snapshot, | 312 DART_EXPORT Dart_Isolate Dart_CreateIsolate(const Dart_Snapshot* snapshot, |
305 void* data); | 313 void* callback_data, |
314 Dart_ErrorBuffer error); | |
306 // TODO(turnidge): Document behavior when there is already a current | 315 // TODO(turnidge): Document behavior when there is already a current |
307 // isolate. | 316 // isolate. |
308 | 317 |
309 /** | 318 /** |
310 * Shuts down the current isolate. After this call, the current | 319 * Shuts down the current isolate. After this call, the current |
311 * isolate is NULL. | 320 * isolate is NULL. |
312 * | 321 * |
313 * Requires there to be a current isolate. | 322 * Requires there to be a current isolate. |
314 */ | 323 */ |
315 DART_EXPORT void Dart_ShutdownIsolate(); | 324 DART_EXPORT void Dart_ShutdownIsolate(); |
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1204 | 1213 |
1205 // --- Profiling support ---- | 1214 // --- Profiling support ---- |
1206 | 1215 |
1207 // External pprof support for gathering and dumping symbolic | 1216 // External pprof support for gathering and dumping symbolic |
1208 // information that can be used for better profile reports for | 1217 // information that can be used for better profile reports for |
1209 // dynamically generated code. | 1218 // dynamically generated code. |
1210 DART_EXPORT void Dart_InitPprofSupport(); | 1219 DART_EXPORT void Dart_InitPprofSupport(); |
1211 DART_EXPORT void Dart_GetPprofSymbolInfo(void** buffer, int* buffer_size); | 1220 DART_EXPORT void Dart_GetPprofSymbolInfo(void** buffer, int* buffer_size); |
1212 | 1221 |
1213 #endif // INCLUDE_DART_API_H_ | 1222 #endif // INCLUDE_DART_API_H_ |
OLD | NEW |