Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: include/dart_api.h

Issue 8673002: - Refactor the isolate callback mechanism to also include creation of the (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: '' Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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;
236
237 /**
238 * An isolate create and initialization callback function.
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).
242 * isolates spawned from the isolate currently being initialized.
243 */ 252 */
244 typedef void* (*Dart_IsolateInitCallback)(void* embedder_data); 253 typedef bool (*Dart_IsolateCreateAndInitCallback)(void* callback_data,
245 // TODO(iposva): Pass a specification of the app file being spawned. 254 Dart_IsolateError 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 255
249 /** 256 /**
250 * Initializes the VM with the given commmand line flags. 257 * Initializes the VM with the given commmand line flags.
251 * 258 *
252 * \param argc The length of the arguments array. 259 * \param argc The length of the arguments array.
253 * \param argv An array of arguments. 260 * \param argv An array of arguments.
254 * \param callback A function to be called during isolate creation. 261 * \param callback A function to be called during isolate creation.
255 * See Dart_IsolateInitCallback. 262 * See Dart_IsolateCreateAndInitCallback.
256 * 263 *
257 * \return True if initialization is successful. 264 * \return True if initialization is successful.
258 */ 265 */
259 DART_EXPORT bool Dart_Initialize(int argc, const char** argv, 266 DART_EXPORT bool Dart_Initialize(int argc, const char** argv,
260 Dart_IsolateInitCallback callback); 267 Dart_IsolateCreateAndInitCallback callback);
261 268
262 /** 269 /**
263 * Returns true if the named VM flag is set. 270 * Returns true if the named VM flag is set.
264 */ 271 */
265 DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name); 272 DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name);
266 273
267 // --- Isolates --- 274 // --- Isolates ---
268 275
269 /** 276 /**
270 * An isolate is the unit of concurrency in Dart. Each isolate has 277 * An isolate is the unit of concurrency in Dart. Each isolate has
(...skipping 18 matching lines...) Expand all
289 296
290 /** 297 /**
291 * Creates a new isolate. If snapshot data is provided, the isolate 298 * Creates a new isolate. If snapshot data is provided, the isolate
292 * will be started using that snapshot data. The new isolate becomes 299 * will be started using that snapshot data. The new isolate becomes
293 * the current isolate. 300 * the current isolate.
294 * 301 *
295 * Requires there to be no current isolate. 302 * Requires there to be no current isolate.
296 * 303 *
297 * \param snapshot A buffer containing a VM snapshot or NULL if no 304 * \param snapshot A buffer containing a VM snapshot or NULL if no
298 * snapshot is provided. 305 * snapshot is provided.
299 * \param data Embedder-specific data. See Dart_IsolateInitCallback.
300 * 306 *
301 * \return The new isolate is returned. May be NULL if an error 307 * \return The new isolate is returned. May be NULL if an error
302 * occurs duing isolate initialization. 308 * occurs duing isolate initialization.
303 */ 309 */
304 DART_EXPORT Dart_Isolate Dart_CreateIsolate(const Dart_Snapshot* snapshot, 310 DART_EXPORT Dart_Isolate Dart_CreateIsolate(const Dart_Snapshot* snapshot,
305 void* data); 311 void* callback_data);
306 // TODO(turnidge): Document behavior when there is already a current 312 // TODO(turnidge): Document behavior when there is already a current
307 // isolate. 313 // isolate.
308 314
309 /** 315 /**
310 * Shuts down the current isolate. After this call, the current 316 * Shuts down the current isolate. After this call, the current
311 * isolate is NULL. 317 * isolate is NULL.
312 * 318 *
313 * Requires there to be a current isolate. 319 * Requires there to be a current isolate.
314 */ 320 */
315 DART_EXPORT void Dart_ShutdownIsolate(); 321 DART_EXPORT void Dart_ShutdownIsolate();
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 1210
1205 // --- Profiling support ---- 1211 // --- Profiling support ----
1206 1212
1207 // External pprof support for gathering and dumping symbolic 1213 // External pprof support for gathering and dumping symbolic
1208 // information that can be used for better profile reports for 1214 // information that can be used for better profile reports for
1209 // dynamically generated code. 1215 // dynamically generated code.
1210 DART_EXPORT void Dart_InitPprofSupport(); 1216 DART_EXPORT void Dart_InitPprofSupport();
1211 DART_EXPORT void Dart_GetPprofSymbolInfo(void** buffer, int* buffer_size); 1217 DART_EXPORT void Dart_GetPprofSymbolInfo(void** buffer, int* buffer_size);
1212 1218
1213 #endif // INCLUDE_DART_API_H_ 1219 #endif // INCLUDE_DART_API_H_
OLDNEW
« bin/builtin.cc ('K') | « dart-runtime.gyp ('k') | lib/isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698