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 */ | |
232 typedef struct { | |
233 char* buffer; | |
234 int length; | |
235 } Dart_IsolateError; | |
turnidge
2011/11/23 18:05:12
We are always using snprintf to fill this error.
siva
2011/11/23 22:37:27
As discussed offline we will resolve the snprintf
| |
236 | |
237 /** | |
238 * An isolate create and initialization callback function. | |
turnidge
2011/11/23 18:05:12
s/create/creation/
siva
2011/11/23 22:37:27
Done.
| |
230 * | 239 * |
231 * This callback, provided by the embedder, is called during isolate | 240 * This callback, provided by the embedder, is called when an isolate needs |
232 * creation. It is called for all isolates, regardless of whether they | 241 * to be created. The callback should create an isolate and load up the |
233 * are created via Dart_CreateIsolate or directly from Dart code. | 242 * required scripts for execution. |
234 * | 243 * |
235 * \param data Embedder-specific data used during isolate initialization. | 244 * \param error A structure into which the embedder can place a |
245 * C string containing an error message in the case of failures. | |
236 * | 246 * |
237 * \return If the embedder returns NULL, then the isolate being | 247 * \return the embedder returns false if the creation and initialization was not |
238 * initialized will be shut down without executing any Dart code. | 248 * successful and true if successful. The embedder is responsible for |
239 * Otherwise, the embedder should return a pointer to | 249 * maintaining consistency in the case of errors (e.g: isolate is created, |
240 * embedder-specific data created during the initialization of this | 250 * but loading of scripts fails then the embedder should ensure that the |
241 * isolate. This data will, in turn, be passed by the VM to all | 251 * isolate is deleted). |
turnidge
2011/11/23 18:05:12
Instead of saying "deleted" maybe frame this in te
siva
2011/11/23 22:37:27
Done.
| |
242 * isolates spawned from the isolate currently being initialized. | |
243 */ | 252 */ |
244 typedef void* (*Dart_IsolateInitCallback)(void* embedder_data); | 253 typedef bool (*Dart_IsolateCreateAndInitCallback)(Dart_IsolateError error); |
turnidge
2011/11/23 18:05:12
Dart_IsolateCreateAndInitCallback is a bit long.
siva
2011/11/23 22:37:27
Done.
| |
245 // TODO(iposva): Pass a specification of the app file being spawned. | |
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 | 254 |
249 /** | 255 /** |
250 * Initializes the VM with the given commmand line flags. | 256 * Initializes the VM with the given commmand line flags. |
251 * | 257 * |
252 * \param argc The length of the arguments array. | 258 * \param argc The length of the arguments array. |
253 * \param argv An array of arguments. | 259 * \param argv An array of arguments. |
254 * \param callback A function to be called during isolate creation. | 260 * \param callback A function to be called during isolate creation. |
255 * See Dart_IsolateInitCallback. | 261 * See Dart_IsolateCreateAndInitCallback. |
256 * | 262 * |
257 * \return True if initialization is successful. | 263 * \return True if initialization is successful. |
258 */ | 264 */ |
259 DART_EXPORT bool Dart_Initialize(int argc, const char** argv, | 265 DART_EXPORT bool Dart_Initialize(int argc, const char** argv, |
260 Dart_IsolateInitCallback callback); | 266 Dart_IsolateCreateAndInitCallback callback); |
261 | 267 |
262 /** | 268 /** |
263 * Returns true if the named VM flag is set. | 269 * Returns true if the named VM flag is set. |
264 */ | 270 */ |
265 DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name); | 271 DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name); |
266 | 272 |
267 // --- Isolates --- | 273 // --- Isolates --- |
268 | 274 |
269 /** | 275 /** |
270 * An isolate is the unit of concurrency in Dart. Each isolate has | 276 * An isolate is the unit of concurrency in Dart. Each isolate has |
(...skipping 18 matching lines...) Expand all Loading... | |
289 | 295 |
290 /** | 296 /** |
291 * Creates a new isolate. If snapshot data is provided, the isolate | 297 * Creates a new isolate. If snapshot data is provided, the isolate |
292 * will be started using that snapshot data. The new isolate becomes | 298 * will be started using that snapshot data. The new isolate becomes |
293 * the current isolate. | 299 * the current isolate. |
294 * | 300 * |
295 * Requires there to be no current isolate. | 301 * Requires there to be no current isolate. |
296 * | 302 * |
297 * \param snapshot A buffer containing a VM snapshot or NULL if no | 303 * \param snapshot A buffer containing a VM snapshot or NULL if no |
298 * snapshot is provided. | 304 * snapshot is provided. |
299 * \param data Embedder-specific data. See Dart_IsolateInitCallback. | |
300 * | 305 * |
301 * \return The new isolate is returned. May be NULL if an error | 306 * \return The new isolate is returned. May be NULL if an error |
302 * occurs duing isolate initialization. | 307 * occurs duing isolate initialization. |
303 */ | 308 */ |
304 DART_EXPORT Dart_Isolate Dart_CreateIsolate(const Dart_Snapshot* snapshot, | 309 DART_EXPORT Dart_Isolate Dart_CreateIsolate(const Dart_Snapshot* snapshot); |
turnidge
2011/11/23 18:05:12
Consider taking a Dart_IsolateError parameter. I
siva
2011/11/23 22:37:27
Done.
| |
305 void* data); | |
306 // TODO(turnidge): Document behavior when there is already a current | 310 // TODO(turnidge): Document behavior when there is already a current |
307 // isolate. | 311 // isolate. |
308 | 312 |
309 /** | 313 /** |
310 * Shuts down the current isolate. After this call, the current | 314 * Shuts down the current isolate. After this call, the current |
311 * isolate is NULL. | 315 * isolate is NULL. |
312 * | 316 * |
313 * Requires there to be a current isolate. | 317 * Requires there to be a current isolate. |
314 */ | 318 */ |
315 DART_EXPORT void Dart_ShutdownIsolate(); | 319 DART_EXPORT void Dart_ShutdownIsolate(); |
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1204 | 1208 |
1205 // --- Profiling support ---- | 1209 // --- Profiling support ---- |
1206 | 1210 |
1207 // External pprof support for gathering and dumping symbolic | 1211 // External pprof support for gathering and dumping symbolic |
1208 // information that can be used for better profile reports for | 1212 // information that can be used for better profile reports for |
1209 // dynamically generated code. | 1213 // dynamically generated code. |
1210 DART_EXPORT void Dart_InitPprofSupport(); | 1214 DART_EXPORT void Dart_InitPprofSupport(); |
1211 DART_EXPORT void Dart_GetPprofSymbolInfo(void** buffer, int* buffer_size); | 1215 DART_EXPORT void Dart_GetPprofSymbolInfo(void** buffer, int* buffer_size); |
1212 | 1216 |
1213 #endif // INCLUDE_DART_API_H_ | 1217 #endif // INCLUDE_DART_API_H_ |
OLD | NEW |