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

Side by Side Diff: runtime/include/dart_api.h

Issue 10386107: Implement spawnUri from dart:isolate. This function allows us to (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 months 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 * error handle. 386 * error handle.
387 */ 387 */
388 DART_EXPORT Dart_Handle Dart_RemoveGcEpilogueCallback( 388 DART_EXPORT Dart_Handle Dart_RemoveGcEpilogueCallback(
389 Dart_GcEpilogueCallback callback); 389 Dart_GcEpilogueCallback callback);
390 390
391 // --- Initialization and Globals --- 391 // --- Initialization and Globals ---
392 392
393 /** 393 /**
394 * An isolate creation and initialization callback function. 394 * An isolate creation and initialization callback function.
395 * 395 *
396 * This callback, provided by the embedder, is called when an isolate needs 396 * This callback, provided by the embedder, is called when the vm
397 * to be created. The callback should create an isolate and load the 397 * needs to create an isolate. The callback should create an isolate
398 * required scripts for execution. 398 * by calling Dart_CreateIsolate and load any scripts required for
399 * execution.
399 * 400 *
401 * When the function returns false, it is the responsibility of this
402 * function to ensure that Dart_ShutdownIsolate has been called if
403 * required (for example, if the isolate was created successfully by
404 * Dart_CreateIsolate() but the root library fails to load
405 * successfully, then the function should call Dart_ShutdownIsolate
406 * before returning).
407 *
408 * When the function returns false, the function should set *error to
409 * a malloc-allocated buffer containing a useful error message. The
410 * caller of this function (the vm) will make sure that the buffer is
411 * freed.
412 *
413 * \param script_uri The uri of the script to load. This uri has been
414 * canonicalized by the library tag handler from the parent isolate.
415 * The callback is responsible for loading this script by a call to
416 * Dart_LoadScript or Dart_LoadScriptFromSnapshot.
417 * \param main The name of the main entry point this isolate will
418 * eventually run. This is provided for advisory purposes only to
419 * improve debugging messages. The main function is not invoked by
420 * this function.
421 * \param callback_data The callback data which was passed to the
422 * parent isolate when it was created by calling Dart_CreateIsolate().
400 * \param error A structure into which the embedder can place a 423 * \param error A structure into which the embedder can place a
401 * C string containing an error message in the case of failures. 424 * C string containing an error message in the case of failures.
402 * 425 *
403 * \return The embedder returns false if the creation and initialization was not 426 * \return The embedder returns false if the creation and
404 * successful and true if successful. The embedder is responsible for 427 * initialization was not successful and true if successful.
405 * maintaining consistency in the case of errors (e.g: isolate is created,
406 * but loading of scripts fails then the embedder should ensure that
407 * Dart_ShutdownIsolate is called on the isolate).
408 * In the case of errors the caller is responsible for freeing the buffer
409 * returned in error containing an error string.
410 */ 428 */
411 typedef bool (*Dart_IsolateCreateCallback)(const char* name_prefix, 429 typedef bool (*Dart_IsolateCreateCallback)(const char* script_uri,
430 const char* main,
412 void* callback_data, 431 void* callback_data,
413 char** error); 432 char** error);
414 433
415 /** 434 /**
416 * An isolate interrupt callback function. 435 * An isolate interrupt callback function.
417 * 436 *
418 * This callback, provided by the embedder, is called when an isolate 437 * This callback, provided by the embedder, is called when an isolate
419 * is interrupted as a result of a call to Dart_InterruptIsolate(). 438 * is interrupted as a result of a call to Dart_InterruptIsolate().
420 * When the callback is called, Dart_CurrentIsolate can be used to 439 * When the callback is called, Dart_CurrentIsolate can be used to
421 * figure out which isolate is being interrupted. 440 * figure out which isolate is being interrupted.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 494
476 /** 495 /**
477 * Creates a new isolate. The new isolate becomes the current isolate. 496 * Creates a new isolate. The new isolate becomes the current isolate.
478 * 497 *
479 * A snapshot can be used to restore the VM quickly to a saved state 498 * A snapshot can be used to restore the VM quickly to a saved state
480 * and is useful for fast startup. If snapshot data is provided, the 499 * and is useful for fast startup. If snapshot data is provided, the
481 * isolate will be started using that snapshot data. 500 * isolate will be started using that snapshot data.
482 * 501 *
483 * Requires there to be no current isolate. 502 * Requires there to be no current isolate.
484 * 503 *
504 * \param script_uri The name of the script this isolate will load.
505 * Provided only for advisory purposes to improve debugging messages.
506 * \param main The name of the main entry point this isolate will run.
507 * Provided only for advisory purposes to improve debugging messages.
485 * \param snapshot A buffer containing a VM snapshot or NULL if no 508 * \param snapshot A buffer containing a VM snapshot or NULL if no
486 * snapshot is provided. 509 * snapshot is provided.
510 * \param callback_data Embedder data. This data will be passed to
511 * the Dart_IsolateCreateCallback when new isolates are spawned from
512 * this parent isolate.
513 * \param error DOCUMENT
487 * 514 *
488 * \return The new isolate is returned. May be NULL if an error 515 * \return The new isolate is returned. May be NULL if an error
489 * occurs duing isolate initialization. 516 * occurs duing isolate initialization.
490 */ 517 */
491 DART_EXPORT Dart_Isolate Dart_CreateIsolate(const char* name_prefix, 518 DART_EXPORT Dart_Isolate Dart_CreateIsolate(const char* script_uri,
519 const char* main,
492 const uint8_t* snapshot, 520 const uint8_t* snapshot,
493 void* callback_data, 521 void* callback_data,
494 char** error); 522 char** error);
495 // TODO(turnidge): Document behavior when there is already a current 523 // TODO(turnidge): Document behavior when there is already a current
496 // isolate. 524 // isolate.
497 525
498 /** 526 /**
499 * Shuts down the current isolate. After this call, the current 527 * Shuts down the current isolate. After this call, the current
500 * isolate is NULL. 528 * isolate is NULL.
501 * 529 *
(...skipping 1418 matching lines...) Expand 10 before | Expand all | Expand 10 after
1920 typedef enum { 1948 typedef enum {
1921 kLibraryTag = 0, 1949 kLibraryTag = 0,
1922 kImportTag, 1950 kImportTag,
1923 kSourceTag, 1951 kSourceTag,
1924 kCanonicalizeUrl 1952 kCanonicalizeUrl
1925 } Dart_LibraryTag; 1953 } Dart_LibraryTag;
1926 1954
1927 // TODO(turnidge): Document. 1955 // TODO(turnidge): Document.
1928 typedef Dart_Handle (*Dart_LibraryTagHandler)(Dart_LibraryTag tag, 1956 typedef Dart_Handle (*Dart_LibraryTagHandler)(Dart_LibraryTag tag,
1929 Dart_Handle library, 1957 Dart_Handle library,
1930 Dart_Handle url, 1958 Dart_Handle url);
1931 Dart_Handle import_map);
1932 1959
1933 /** 1960 /**
1934 * Set library tag handler for the current isolate. This handler is used to 1961 * Sets library tag handler for the current isolate. This handler is
1935 * handle the various tags encountered while loading libraries or scripts in 1962 * used to handle the various tags encountered while loading libraries
1936 * the isolate. 1963 * or scripts in the isolate.
1937 * 1964 *
1938 * \param handler Handler code to be used for handling the various tags 1965 * \param handler Handler code to be used for handling the various tags
1939 * encountered while loading libraries or scripts in the isolate. 1966 * encountered while loading libraries or scripts in the isolate.
1940 * 1967 *
1941 * \return If no error occurs, the handler is set for the isolate. 1968 * \return If no error occurs, the handler is set for the isolate.
1942 * Otherwise an error handle is returned. 1969 * Otherwise an error handle is returned.
1943 * 1970 *
1944 * TODO(turnidge): Document. 1971 * TODO(turnidge): Document.
1945 */ 1972 */
1946 DART_EXPORT Dart_Handle Dart_SetLibraryTagHandler( 1973 DART_EXPORT Dart_Handle Dart_SetLibraryTagHandler(
1947 Dart_LibraryTagHandler handler); 1974 Dart_LibraryTagHandler handler);
1948 1975
1949 /** 1976 /**
1977 * Sets the import map for the current isolate.
1978 *
1979 * The import map is a List of Strings, representing a set of (name,
1980 * value) pairs. The import map is used during the resolution of #
1981 * directives in source files to implement string interpolation.
1982 *
1983 * For example, if a source file imports:
1984 *
1985 * #import('${foo}/dart.html');
1986 *
1987 * And the import map is:
1988 *
1989 * [ "foo", "/home/user" ]
1990 *
1991 * Then the import would resolve to:
1992 *
1993 * #import('/home/user/dart.html');
1994 *
1995 * \param import_map A List of Strings interpreted as a String to
1996 * String mapping.
1997 * \return If no error occurs, the import map is set for the isolate.
1998 * Otherwise an error handle is returned.
1999 */
2000 DART_EXPORT Dart_Handle Dart_SetImportMap(Dart_Handle import_map);
2001
2002 /**
1950 * Loads the root script for the current isolate. 2003 * Loads the root script for the current isolate.
1951 * 2004 *
1952 * TODO(turnidge): Document. 2005 * TODO(turnidge): Document.
1953 */ 2006 */
1954 DART_EXPORT Dart_Handle Dart_LoadScript(Dart_Handle url, 2007 DART_EXPORT Dart_Handle Dart_LoadScript(Dart_Handle url,
1955 Dart_Handle source, 2008 Dart_Handle source);
1956 Dart_Handle import_map);
1957 2009
1958 /** 2010 /**
1959 * Loads the root script for current isolate from a snapshot. 2011 * Loads the root script for current isolate from a snapshot.
1960 * 2012 *
1961 * \param buffer A buffer which contains a snapshot of the script. 2013 * \param buffer A buffer which contains a snapshot of the script.
1962 * 2014 *
1963 * \return If no error occurs, the Library object corresponding to the root 2015 * \return If no error occurs, the Library object corresponding to the root
1964 * script is returned. Otherwise an error handle is returned. 2016 * script is returned. Otherwise an error handle is returned.
1965 **/ 2017 */
1966 DART_EXPORT Dart_Handle Dart_LoadScriptFromSnapshot(const uint8_t* buffer); 2018 DART_EXPORT Dart_Handle Dart_LoadScriptFromSnapshot(const uint8_t* buffer);
1967 2019
1968 /** 2020 /**
2021 * Gets the library for the root script for the current isolate.
2022 *
2023 * \return Returns the Library object corresponding to the root script
2024 * if it has been set by a successful call to Dart_LoadScript or
2025 * Dart_LoadScriptFromSnapshot. Otherwise returns Dart_Null().
2026 */
2027 DART_EXPORT Dart_Handle Dart_RootLibrary();
2028
2029 /**
1969 * Forces all loaded classes and functions to be compiled eagerly in 2030 * Forces all loaded classes and functions to be compiled eagerly in
1970 * the current isolate.. 2031 * the current isolate..
1971 * 2032 *
1972 * TODO(turnidge): Document. 2033 * TODO(turnidge): Document.
1973 */ 2034 */
1974 DART_EXPORT Dart_Handle Dart_CompileAll(); 2035 DART_EXPORT Dart_Handle Dart_CompileAll();
1975 2036
1976 /** 2037 /**
1977 * Is this object a Library? 2038 * Is this object a Library?
1978 */ 2039 */
1979 DART_EXPORT bool Dart_IsLibrary(Dart_Handle object); 2040 DART_EXPORT bool Dart_IsLibrary(Dart_Handle object);
1980 2041
1981 /** 2042 /**
1982 * Lookup a class by name from a Library. 2043 * Lookup a class by name from a Library.
1983 * 2044 *
1984 * \return If no error occurs, the Library is returned. Otherwise an 2045 * \return If no error occurs, the Library is returned. Otherwise an
1985 * error handle is returned. 2046 * error handle is returned.
1986 */ 2047 */
1987 DART_EXPORT Dart_Handle Dart_GetClass(Dart_Handle library, Dart_Handle name); 2048 DART_EXPORT Dart_Handle Dart_GetClass(Dart_Handle library, Dart_Handle name);
1988 // TODO(turnidge): Consider returning Dart_Null() when the class is 2049 // TODO(turnidge): Consider returning Dart_Null() when the class is
1989 // not found to distinguish that from a true error case. 2050 // not found to distinguish that from a true error case.
1990 2051
1991 DART_EXPORT Dart_Handle Dart_LibraryUrl(Dart_Handle library); 2052 DART_EXPORT Dart_Handle Dart_LibraryUrl(Dart_Handle library);
1992 2053
1993 DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url); 2054 DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url);
1994 // TODO(turnidge): Consider returning Dart_Null() when the library is 2055 // TODO(turnidge): Consider returning Dart_Null() when the library is
1995 // not found to distinguish that from a true error case. 2056 // not found to distinguish that from a true error case.
1996 2057
1997 DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url, 2058 DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url,
1998 Dart_Handle source, 2059 Dart_Handle source);
1999 Dart_Handle import_map);
2000 2060
2001 2061
2002 DART_EXPORT Dart_Handle Dart_LibraryImportLibrary(Dart_Handle library, 2062 DART_EXPORT Dart_Handle Dart_LibraryImportLibrary(Dart_Handle library,
2003 Dart_Handle import); 2063 Dart_Handle import);
2004 2064
2005 DART_EXPORT Dart_Handle Dart_LoadSource(Dart_Handle library, 2065 DART_EXPORT Dart_Handle Dart_LoadSource(Dart_Handle library,
2006 Dart_Handle url, 2066 Dart_Handle url,
2007 Dart_Handle source); 2067 Dart_Handle source);
2008 // TODO(turnidge): Rename to Dart_LibraryLoadSource? 2068 // TODO(turnidge): Rename to Dart_LibraryLoadSource?
2009 2069
(...skipping 12 matching lines...) Expand all
2022 2082
2023 // --- Profiling support ---- 2083 // --- Profiling support ----
2024 2084
2025 // External pprof support for gathering and dumping symbolic 2085 // External pprof support for gathering and dumping symbolic
2026 // information that can be used for better profile reports for 2086 // information that can be used for better profile reports for
2027 // dynamically generated code. 2087 // dynamically generated code.
2028 DART_EXPORT void Dart_InitPprofSupport(); 2088 DART_EXPORT void Dart_InitPprofSupport();
2029 DART_EXPORT void Dart_GetPprofSymbolInfo(void** buffer, int* buffer_size); 2089 DART_EXPORT void Dart_GetPprofSymbolInfo(void** buffer, int* buffer_size);
2030 2090
2031 #endif // INCLUDE_DART_API_H_ 2091 #endif // INCLUDE_DART_API_H_
OLDNEW
« no previous file with comments | « runtime/bin/main.cc ('k') | runtime/lib/isolate.cc » ('j') | runtime/lib/isolate.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698