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

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

Powered by Google App Engine
This is Rietveld 408576698