Flutter Engine
The Flutter Engine
|
Go to the source code of this file.
Classes | |
struct | Dart_IsolateFlags |
struct | Dart_CodeObserver |
struct | Dart_InitializeParams |
struct | Dart_PortEx |
struct | _Dart_NativeArgument_Descriptor |
union | _Dart_NativeArgument_Value |
struct | NativeAssetsApi |
struct | Dart_KernelCompilationResult |
struct | Dart_SourceFile |
Macros | |
#define | __STDC_FORMAT_MACROS |
#define | DART_EXTERN_C extern |
#define | DART_WARN_UNUSED_RESULT |
#define | DART_DEPRECATED(msg) |
#define | DART_FLAGS_CURRENT_VERSION (0x0000000d) |
#define | DART_INITIALIZE_PARAMS_CURRENT_VERSION (0x00000008) |
#define | ILLEGAL_PORT ((Dart_Port)0) |
#define | BITMASK(size) ((1 << size) - 1) |
#define | DART_NATIVE_ARG_DESCRIPTOR(type, position) |
#define | DART_KERNEL_ISOLATE_NAME "kernel-service" |
#define | DART_VM_SERVICE_ISOLATE_NAME "vm-service" |
#define | kSnapshotBuildIdCSymbol "_kDartSnapshotBuildId" |
#define | kVmSnapshotDataCSymbol "_kDartVmSnapshotData" |
#define | kVmSnapshotInstructionsCSymbol "_kDartVmSnapshotInstructions" |
#define | kVmSnapshotBssCSymbol "_kDartVmSnapshotBss" |
#define | kIsolateSnapshotDataCSymbol "_kDartIsolateSnapshotData" |
#define | kIsolateSnapshotInstructionsCSymbol "_kDartIsolateSnapshotInstructions" |
#define | kIsolateSnapshotBssCSymbol "_kDartIsolateSnapshotBss" |
#define | kSnapshotBuildIdAsmSymbol "_kDartSnapshotBuildId" |
#define | kVmSnapshotDataAsmSymbol "_kDartVmSnapshotData" |
#define | kVmSnapshotInstructionsAsmSymbol "_kDartVmSnapshotInstructions" |
#define | kVmSnapshotBssAsmSymbol "_kDartVmSnapshotBss" |
#define | kIsolateSnapshotDataAsmSymbol "_kDartIsolateSnapshotData" |
#define | kIsolateSnapshotInstructionsAsmSymbol "_kDartIsolateSnapshotInstructions" |
#define | kIsolateSnapshotBssAsmSymbol "_kDartIsolateSnapshotBss" |
Typedefs | |
typedef struct _Dart_Isolate * | Dart_Isolate |
typedef struct _Dart_IsolateGroup * | Dart_IsolateGroup |
typedef struct _Dart_Handle * | Dart_Handle |
typedef Dart_Handle | Dart_PersistentHandle |
typedef struct _Dart_WeakPersistentHandle * | Dart_WeakPersistentHandle |
typedef struct _Dart_FinalizableHandle * | Dart_FinalizableHandle |
typedef void(* | Dart_HandleFinalizer) (void *isolate_callback_data, void *peer) |
typedef Dart_Isolate(* | Dart_IsolateGroupCreateCallback) (const char *script_uri, const char *main, const char *package_root, const char *package_config, Dart_IsolateFlags *flags, void *isolate_data, char **error) |
typedef bool(* | Dart_InitializeIsolateCallback) (void **child_isolate_data, char **error) |
typedef void(* | Dart_IsolateShutdownCallback) (void *isolate_group_data, void *isolate_data) |
typedef void(* | Dart_IsolateCleanupCallback) (void *isolate_group_data, void *isolate_data) |
typedef void(* | Dart_IsolateGroupCleanupCallback) (void *isolate_group_data) |
typedef void(* | Dart_ThreadStartCallback) (void) |
typedef void(* | Dart_ThreadExitCallback) (void) |
typedef void *(* | Dart_FileOpenCallback) (const char *name, bool write) |
typedef void(* | Dart_FileReadCallback) (uint8_t **data, intptr_t *file_length, void *stream) |
typedef void(* | Dart_FileWriteCallback) (const void *data, intptr_t length, void *stream) |
typedef void(* | Dart_FileCloseCallback) (void *stream) |
typedef bool(* | Dart_EntropySource) (uint8_t *buffer, intptr_t length) |
typedef Dart_Handle(* | Dart_GetVMServiceAssetsArchive) (void) |
typedef void(* | Dart_OnNewCodeCallback) (struct Dart_CodeObserver *observer, const char *name, uintptr_t base, uintptr_t size) |
typedef struct Dart_CodeObserver | Dart_CodeObserver |
typedef const char *(* | Dart_RegisterKernelBlobCallback) (const uint8_t *kernel_buffer, intptr_t kernel_buffer_size) |
typedef void(* | Dart_UnregisterKernelBlobCallback) (const char *kernel_blob_uri) |
typedef int64_t | Dart_IsolateGroupId |
typedef void(* | Dart_HeapSamplingReportCallback) (void *context, void *data) |
typedef void *(* | Dart_HeapSamplingCreateCallback) (Dart_Isolate isolate, Dart_IsolateGroup isolate_group, const char *cls_name, intptr_t allocation_size) |
typedef void(* | Dart_HeapSamplingDeleteCallback) (void *data) |
typedef int64_t | Dart_Port |
typedef void(* | Dart_MessageNotifyCallback) (Dart_Isolate destination_isolate) |
typedef struct _Dart_NativeArguments * | Dart_NativeArguments |
typedef struct _Dart_NativeArgument_Descriptor | Dart_NativeArgument_Descriptor |
typedef union _Dart_NativeArgument_Value | Dart_NativeArgument_Value |
typedef void(* | Dart_NativeFunction) (Dart_NativeArguments arguments) |
typedef Dart_NativeFunction(* | Dart_NativeEntryResolver) (Dart_Handle name, int num_of_arguments, bool *auto_setup_scope) |
typedef const uint8_t *(* | Dart_NativeEntrySymbol) (Dart_NativeFunction nf) |
typedef void *(* | Dart_FfiNativeResolver) (const char *name, uintptr_t args_n) |
typedef Dart_Handle(* | Dart_EnvironmentCallback) (Dart_Handle name) |
typedef void *(* | Dart_NativeAssetsDlopenCallback) (const char *path, char **error) |
typedef void *(* | Dart_NativeAssetsDlopenCallbackNoPath) (char **error) |
typedef void *(* | Dart_NativeAssetsDlsymCallback) (void *handle, const char *symbol, char **error) |
typedef Dart_Handle(* | Dart_LibraryTagHandler) (Dart_LibraryTag tag, Dart_Handle library_or_package_map_url, Dart_Handle url) |
typedef Dart_Handle(* | Dart_DeferredLoadHandler) (intptr_t loading_unit_id) |
typedef void(* | Dart_CreateLoadingUnitCallback) (void *callback_data, intptr_t loading_unit_id, void **write_callback_data, void **write_debug_callback_data) |
typedef void(* | Dart_StreamingWriteCallback) (void *callback_data, const uint8_t *buffer, intptr_t size) |
typedef void(* | Dart_StreamingCloseCallback) (void *callback_data) |
typedef char *(* | Dart_DwarfStackTraceFootnoteCallback) (void *addresses[], intptr_t count) |
#define __STDC_FORMAT_MACROS |
Definition at line 21 of file dart_api.h.
#define BITMASK | ( | size | ) | ((1 << size) - 1) |
Definition at line 3068 of file dart_api.h.
#define DART_DEPRECATED | ( | msg | ) |
Definition at line 67 of file dart_api.h.
#define DART_EXTERN_C extern |
Definition at line 35 of file dart_api.h.
#define DART_FLAGS_CURRENT_VERSION (0x0000000d) |
Isolate specific flags are set when creating a new isolate using the Dart_IsolateFlags structure.
Current version of flags is encoded in a 32-bit integer with 16 bits used for each part.
Definition at line 582 of file dart_api.h.
#define DART_INITIALIZE_PARAMS_CURRENT_VERSION (0x00000008) |
The current version of the Dart_InitializeFlags. Should be incremented every time Dart_InitializeFlags changes in a binary incompatible way.
Definition at line 840 of file dart_api.h.
#define DART_KERNEL_ISOLATE_NAME "kernel-service" |
Definition at line 3880 of file dart_api.h.
#define DART_NATIVE_ARG_DESCRIPTOR | ( | type, | |
position | |||
) |
Definition at line 3069 of file dart_api.h.
#define DART_VM_SERVICE_ISOLATE_NAME "vm-service" |
Definition at line 3888 of file dart_api.h.
#define DART_WARN_UNUSED_RESULT |
Definition at line 66 of file dart_api.h.
#define ILLEGAL_PORT ((Dart_Port)0) |
ILLEGAL_PORT is a port number guaranteed never to be associated with a valid port.
Definition at line 1535 of file dart_api.h.
#define kIsolateSnapshotBssAsmSymbol "_kDartIsolateSnapshotBss" |
Definition at line 3970 of file dart_api.h.
#define kIsolateSnapshotBssCSymbol "_kDartIsolateSnapshotBss" |
Definition at line 3960 of file dart_api.h.
#define kIsolateSnapshotDataAsmSymbol "_kDartIsolateSnapshotData" |
Definition at line 3967 of file dart_api.h.
#define kIsolateSnapshotDataCSymbol "_kDartIsolateSnapshotData" |
Definition at line 3958 of file dart_api.h.
#define kIsolateSnapshotInstructionsAsmSymbol "_kDartIsolateSnapshotInstructions" |
Definition at line 3968 of file dart_api.h.
#define kIsolateSnapshotInstructionsCSymbol "_kDartIsolateSnapshotInstructions" |
Definition at line 3959 of file dart_api.h.
#define kSnapshotBuildIdAsmSymbol "_kDartSnapshotBuildId" |
Definition at line 3963 of file dart_api.h.
#define kSnapshotBuildIdCSymbol "_kDartSnapshotBuildId" |
Definition at line 3954 of file dart_api.h.
#define kVmSnapshotBssAsmSymbol "_kDartVmSnapshotBss" |
Definition at line 3966 of file dart_api.h.
#define kVmSnapshotBssCSymbol "_kDartVmSnapshotBss" |
Definition at line 3957 of file dart_api.h.
#define kVmSnapshotDataAsmSymbol "_kDartVmSnapshotData" |
Definition at line 3964 of file dart_api.h.
#define kVmSnapshotDataCSymbol "_kDartVmSnapshotData" |
Definition at line 3955 of file dart_api.h.
#define kVmSnapshotInstructionsAsmSymbol "_kDartVmSnapshotInstructions" |
Definition at line 3965 of file dart_api.h.
#define kVmSnapshotInstructionsCSymbol "_kDartVmSnapshotInstructions" |
Definition at line 3956 of file dart_api.h.
typedef struct Dart_CodeObserver Dart_CodeObserver |
typedef void(* Dart_CreateLoadingUnitCallback) (void *callback_data, intptr_t loading_unit_id, void **write_callback_data, void **write_debug_callback_data) |
Definition at line 3930 of file dart_api.h.
typedef Dart_Handle(* Dart_DeferredLoadHandler) (intptr_t loading_unit_id) |
Handles deferred loading requests. When this handler is invoked, it should eventually load the deferred loading unit with the given id and call Dart_DeferredLoadComplete or Dart_DeferredLoadCompleteError. It is recommended that the loading occur asynchronously, but it is permitted to call Dart_DeferredLoadComplete or Dart_DeferredLoadCompleteError before the handler returns.
If an error is returned, it will be propagated through prefix.loadLibrary()
. This is useful for synchronous implementations, which must propagate any unwind errors from Dart_DeferredLoadComplete or Dart_DeferredLoadComplete. Otherwise the handler should return a non-error such as Dart_Null()
.
Definition at line 3491 of file dart_api.h.
typedef char *(* Dart_DwarfStackTraceFootnoteCallback) (void *addresses[], intptr_t count) |
Callback provided by the embedder that is used by the VM to produce footnotes appended to DWARF stack traces.
Whenever VM formats a stack trace as a string it would call this callback passing raw program counters for each frame in the stack trace.
Embedder can then return a string which if not-null will be appended to the formatted stack trace.
Returned string is expected to be malloc()
allocated. VM takes ownership of the returned string and will free()
it.
addresses | raw program counter addresses for each frame |
count | number of elements in the addresses array |
Definition at line 4145 of file dart_api.h.
Definition at line 822 of file dart_api.h.
typedef Dart_Handle(* Dart_EnvironmentCallback) (Dart_Handle name) |
An environment lookup callback function.
name | The name of the value to lookup in the environment. |
Definition at line 3278 of file dart_api.h.
typedef void *(* Dart_FfiNativeResolver) (const char *name, uintptr_t args_n) |
FFI Native C function pointer resolver callback.
See Dart_SetFfiNativeResolver.
Definition at line 3262 of file dart_api.h.
typedef void(* Dart_FileCloseCallback) (void *stream) |
Closes the opened file.
Callback provided by the embedder for file operations. If the embedder does not allow file operations this callback can be NULL.
stream | Handle to the opened file. |
Definition at line 820 of file dart_api.h.
Opens a file for reading or writing.
Callback provided by the embedder for file operations. If the embedder does not allow file operations this callback can be NULL.
name | The name of the file to open. |
write | A boolean variable which indicates if the file is to opened for writing. If there is an existing file it needs to truncated. |
Definition at line 776 of file dart_api.h.
typedef void(* Dart_FileReadCallback) (uint8_t **data, intptr_t *file_length, void *stream) |
Read contents of file.
Callback provided by the embedder for file operations. If the embedder does not allow file operations this callback can be NULL.
data | Buffer allocated in the callback into which the contents of the file are read into. It is the responsibility of the caller to free this buffer. |
file_length | A variable into which the length of the file is returned. In the case of an error this value would be -1. |
stream | Handle to the opened file. |
Definition at line 792 of file dart_api.h.
Write data into file.
Callback provided by the embedder for file operations. If the embedder does not allow file operations this callback can be NULL.
data | Buffer which needs to be written into the file. |
length | Length of the buffer. |
stream | Handle to the opened file. |
Definition at line 807 of file dart_api.h.
typedef struct _Dart_FinalizableHandle* Dart_FinalizableHandle |
Definition at line 261 of file dart_api.h.
typedef Dart_Handle(* Dart_GetVMServiceAssetsArchive) (void) |
Callback provided by the embedder that is used by the vmservice isolate to request the asset archive. The asset archive must be an uncompressed tar archive that is stored in a Uint8List.
If the embedder has no vmservice isolate assets, the callback can be NULL.
Definition at line 834 of file dart_api.h.
typedef struct _Dart_Handle* Dart_Handle |
An object reference managed by the Dart VM garbage collector.
Because the garbage collector may move objects, it is unsafe to refer to objects directly. Instead, we refer to objects through handles, which are known to the garbage collector and updated automatically when the object is moved. Handles should be passed by value (except in cases like out-parameters) and should never be allocated on the heap.
Most functions in the Dart Embedding API return a handle. When a function completes normally, this will be a valid handle to an object in the Dart VM heap. This handle may represent the result of the operation or it may be a special valid handle used merely to indicate successful completion. Note that a valid handle may in some cases refer to the null object.
— Error handles —
When a function encounters a problem that prevents it from completing normally, it returns an error handle (See Dart_IsError). An error handle has an associated error message that gives more details about the problem (See Dart_GetError).
There are four kinds of error handles that can be produced, depending on what goes wrong:
Unhandled exception error handles are produced when, during the execution of Dart code, an exception is thrown but not caught. Prototypically this would occur during a call to Dart_Invoke, but it can occur in any function which triggers the execution of Dart code (for example, Dart_ToString).
An unhandled exception error provides access to an exception and stacktrace via the functions Dart_ErrorGetException and Dart_ErrorGetStackTrace.
— Propagating errors —
When an error handle is returned from the top level invocation of Dart code in a program, the embedder must handle the error as they see fit. Often, the embedder will print the error message produced by Dart_Error and exit the program.
When an error is returned while in the body of a native function, it can be propagated up the call stack by calling Dart_PropagateError, Dart_SetReturnValue, or Dart_ThrowException. Errors should be propagated unless there is a specific reason not to. If an error is not propagated then it is ignored. For example, if an unhandled exception error is ignored, that effectively "catches" the unhandled exception. Fatal errors must always be propagated.
When an error is propagated, any current scopes created by Dart_EnterScope will be exited.
Using Dart_SetReturnValue to propagate an exception is somewhat more convenient than using Dart_PropagateError, and should be preferred for reasons discussed below.
Dart_PropagateError and Dart_ThrowException do not return. Instead they transfer control non-locally using a setjmp-like mechanism. This can be inconvenient if you have resources that you need to clean up before propagating the error.
When relying on Dart_PropagateError, we often return error handles rather than propagating them from helper functions. Consider the following contrived example:
1 Dart_Handle isLongStringHelper(Dart_Handle arg) { 2 intptr_t* length = 0; 3 result = Dart_StringLength(arg, &length); 4 if (Dart_IsError(result)) { 5 return result; 6 } 7 return Dart_NewBoolean(length > 100); 8 } 9 10 void NativeFunction_isLongString(Dart_NativeArguments args) { 11 Dart_EnterScope(); 12 AllocateMyResource(); 13 Dart_Handle arg = Dart_GetNativeArgument(args, 0); 14 Dart_Handle result = isLongStringHelper(arg); 15 if (Dart_IsError(result)) { 16 FreeMyResource(); 17 Dart_PropagateError(result); 18 abort(); // will not reach here 19 } 20 Dart_SetReturnValue(result); 21 FreeMyResource(); 22 Dart_ExitScope(); 23 }
In this example, we have a native function which calls a helper function to do its work. On line 5, the helper function could call Dart_PropagateError, but that would not give the native function a chance to call FreeMyResource(), causing a leak. Instead, the helper function returns the error handle to the caller, giving the caller a chance to clean up before propagating the error handle.
When an error is propagated by calling Dart_SetReturnValue, the native function will be allowed to complete normally and then the exception will be propagated only once the native call returns. This can be convenient, as it allows the C code to clean up normally.
The example can be written more simply using Dart_SetReturnValue to propagate the error.
1 Dart_Handle isLongStringHelper(Dart_Handle arg) { 2 intptr_t* length = 0; 3 result = Dart_StringLength(arg, &length); 4 if (Dart_IsError(result)) { 5 return result 6 } 7 return Dart_NewBoolean(length > 100); 8 } 9 10 void NativeFunction_isLongString(Dart_NativeArguments args) { 11 Dart_EnterScope(); 12 AllocateMyResource(); 13 Dart_Handle arg = Dart_GetNativeArgument(args, 0); 14 Dart_SetReturnValue(isLongStringHelper(arg)); 15 FreeMyResource(); 16 Dart_ExitScope(); 17 }
In this example, the call to Dart_SetReturnValue on line 14 will either return the normal return value or the error (potentially generated on line 3). The call to FreeMyResource on line 15 will execute in either case.
— Local and persistent handles —
Local handles are allocated within the current scope (see Dart_EnterScope) and go away when the current scope exits. Unless otherwise indicated, callers should assume that all functions in the Dart embedding api return local handles.
Persistent handles are allocated within the current isolate. They can be used to store objects across scopes. Persistent handles have the lifetime of the current isolate unless they are explicitly deallocated (see Dart_DeletePersistentHandle). The type Dart_Handle represents a handle (both local and persistent). The type Dart_PersistentHandle is a Dart_Handle and it is used to document that a persistent handle is expected as a parameter to a call or the return value from a call is a persistent handle.
FinalizableHandles are persistent handles which are auto deleted when the object is garbage collected. It is never safe to use these handles unless you know the object is still reachable.
WeakPersistentHandles are persistent handles which are automatically set to point Dart_Null when the object is garbage collected. They are not auto deleted, so it is safe to use them after the object has become unreachable.
Definition at line 258 of file dart_api.h.
typedef void(* Dart_HandleFinalizer) (void *isolate_callback_data, void *peer) |
Definition at line 265 of file dart_api.h.
typedef void *(* Dart_HeapSamplingCreateCallback) (Dart_Isolate isolate, Dart_IsolateGroup isolate_group, const char *cls_name, intptr_t allocation_size) |
Definition at line 1283 of file dart_api.h.
typedef void(* Dart_HeapSamplingDeleteCallback) (void *data) |
Definition at line 1288 of file dart_api.h.
typedef void(* Dart_HeapSamplingReportCallback) (void *context, void *data) |
Definition at line 1281 of file dart_api.h.
typedef bool(* Dart_InitializeIsolateCallback) (void **child_isolate_data, char **error) |
An isolate initialization callback function.
This callback, provided by the embedder, is called when the VM has created an isolate within an existing isolate group (i.e. from the same source as an existing isolate).
The callback should setup native resolvers and might want to set a custom message handler via [Dart_SetMessageNotifyCallback] and mark the isolate as runnable.
This callback may be called on a different thread than the one running the parent isolate.
When the function returns false
, it is the responsibility of this function to ensure that Dart_ShutdownIsolate
has been called.
When the function returns false
, the function should set *error to a malloc-allocated buffer containing a useful error message. The caller of this function (the VM) will make sure that the buffer is freed.
child_isolate_data | The callback data to associate with the new child isolate. |
error | A structure into which the embedder can place a C string containing an error message in the case the initialization fails. |
Definition at line 693 of file dart_api.h.
typedef struct _Dart_Isolate* Dart_Isolate |
An isolate is the unit of concurrency in Dart. Each isolate has its own memory and thread of control. No state is shared between isolates. Instead, isolates communicate by message passing.
Each thread keeps track of its current isolate, which is the isolate which is ready to execute on the current thread. The current isolate may be NULL, in which case no isolate is ready to execute. Most of the Dart apis require there to be a current isolate in order to function without error. The current isolate is set by any call to Dart_CreateIsolateGroup or Dart_EnterIsolate.
Definition at line 88 of file dart_api.h.
typedef void(* Dart_IsolateCleanupCallback) (void *isolate_group_data, void *isolate_data) |
An isolate cleanup callback function.
This callback, provided by the embedder, is called after the vm shuts down an isolate. There will be no current isolate and it is not safe to run Dart code.
This function should be used to dispose of native resources that are allocated to an isolate in order to avoid leaks.
isolate_group_data | The same callback data which was passed to the isolate group when it was created. |
isolate_data | The same callback data which was passed to the isolate when it was created. |
Definition at line 729 of file dart_api.h.
typedef struct _Dart_IsolateGroup* Dart_IsolateGroup |
Definition at line 89 of file dart_api.h.
typedef void(* Dart_IsolateGroupCleanupCallback) (void *isolate_group_data) |
An isolate group cleanup callback function.
This callback, provided by the embedder, is called after the vm shuts down an isolate group.
This function should be used to dispose of native resources that are allocated to an isolate in order to avoid leaks.
isolate_group_data | The same callback data which was passed to the isolate group when it was created. |
Definition at line 745 of file dart_api.h.
typedef Dart_Isolate(* Dart_IsolateGroupCreateCallback) (const char *script_uri, const char *main, const char *package_root, const char *package_config, Dart_IsolateFlags *flags, void *isolate_data, char **error) |
An isolate creation and initialization callback function.
This callback, provided by the embedder, is called when the VM needs to create an isolate. The callback should create an isolate by calling Dart_CreateIsolateGroup and load any scripts required for execution.
This callback may be called on a different thread than the one running the parent isolate.
When the function returns NULL, it is the responsibility of this function to ensure that Dart_ShutdownIsolate has been called if required (for example, if the isolate was created successfully by Dart_CreateIsolateGroup() but the root library fails to load successfully, then the function should call Dart_ShutdownIsolate before returning).
When the function returns NULL, the function should set *error to a malloc-allocated buffer containing a useful error message. The caller of this function (the VM) will make sure that the buffer is freed.
script_uri | The uri of the main source file or snapshot to load. Either the URI of the parent isolate set in Dart_CreateIsolateGroup for Isolate.spawn, or the argument to Isolate.spawnUri canonicalized by the library tag handler of the parent isolate. The callback is responsible for loading the program by a call to Dart_LoadScriptFromKernel. |
main | The name of the main entry point this isolate will eventually run. This is provided for advisory purposes only to improve debugging messages. The main function is not invoked by this function. |
package_root | Ignored. |
package_config | Uri of the package configuration file (either in format of .packages or .dart_tool/package_config.json) for this isolate to resolve package imports against. If this parameter is not passed the package resolution of the parent isolate should be used. |
flags | Default flags for this isolate being spawned. Either inherited from the spawning isolate or passed as parameters when spawning the isolate from Dart code. |
isolate_data | The isolate data which was passed to the parent isolate when it was created by calling Dart_CreateIsolateGroup(). |
error | A structure into which the embedder can place a C string containing an error message in the case of failures. |
Definition at line 654 of file dart_api.h.
typedef int64_t Dart_IsolateGroupId |
Gets an id that uniquely identifies current isolate group.
It is the responsibility of the caller to free the returned ID.
Definition at line 1209 of file dart_api.h.
typedef void(* Dart_IsolateShutdownCallback) (void *isolate_group_data, void *isolate_data) |
An isolate shutdown callback function.
This callback, provided by the embedder, is called before the vm shuts down an isolate. The isolate being shutdown will be the current isolate. It is safe to run Dart code.
This function should be used to dispose of native resources that are allocated to an isolate in order to avoid leaks.
isolate_group_data | The same callback data which was passed to the isolate group when it was created. |
isolate_data | The same callback data which was passed to the isolate when it was created. |
Definition at line 711 of file dart_api.h.
typedef Dart_Handle(* Dart_LibraryTagHandler) (Dart_LibraryTag tag, Dart_Handle library_or_package_map_url, Dart_Handle url) |
The library tag handler is a multi-purpose callback provided by the embedder to the Dart VM. The embedder implements the tag handler to provide the ability to load Dart scripts and imports.
– TAGS –
Dart_kCanonicalizeUrl
This tag indicates that the embedder should canonicalize 'url' with respect to 'library'. For most embedders, this is resolving the url
relative to the library
s url (see Dart_LibraryUrl
).
Dart_kImportTag
This tag is used to load a library from IsolateMirror.loadUri. The embedder should call Dart_LoadLibraryFromKernel to provide the library to the VM. The return value should be an error or library (the result from Dart_LoadLibraryFromKernel).
Dart_kKernelTag
This tag is used to load the intermediate file (kernel) generated by the Dart front end. This tag is typically used when a 'hot-reload' of an application is needed and the VM is 'use dart front end' mode. The dart front end typically compiles all the scripts, imports and part files into one intermediate file hence we don't use the source/import or script tags. The return value should be an error or a TypedData containing the kernel bytes.
Definition at line 3456 of file dart_api.h.
typedef void(* Dart_MessageNotifyCallback) (Dart_Isolate destination_isolate) |
A message notification callback.
This callback allows the embedder to provide a custom wakeup mechanism for the delivery of inter-isolate messages. This function is called once per message on an arbitrary thread. It is the responsibility of the embedder to eventually call Dart_HandleMessage once per callback received with the destination isolate set as the current isolate to process the message.
Definition at line 1546 of file dart_api.h.
typedef struct _Dart_NativeArgument_Descriptor Dart_NativeArgument_Descriptor |
typedef union _Dart_NativeArgument_Value Dart_NativeArgument_Value |
typedef struct _Dart_NativeArguments* Dart_NativeArguments |
The arguments to a native function.
This object is passed to a native function to represent its arguments and return value. It allows access to the arguments to a native function by index. It also allows the return value of a native function to be set.
Definition at line 3019 of file dart_api.h.
typedef void *(* Dart_NativeAssetsDlopenCallback) (const char *path, char **error) |
Callback provided by the embedder that is used by the VM to resolve asset paths. If no callback is provided, using @Native
s with native_asset.yaml
s will fail.
The VM is responsible for looking up the asset path with the asset id in the kernel mapping. The embedder is responsible for providing the asset mapping during kernel compilation and using the asset path to return a library handle in this function.
path | The string in the asset path as passed in native_assets.yaml during kernel compilation. |
error | Returns NULL if creation is successful, an error message otherwise. The caller is responsible for calling free() on the error message. |
Definition at line 3364 of file dart_api.h.
typedef void *(* Dart_NativeAssetsDlopenCallbackNoPath) (char **error) |
Definition at line 3366 of file dart_api.h.
typedef void *(* Dart_NativeAssetsDlsymCallback) (void *handle, const char *symbol, char **error) |
Callback provided by the embedder that is used by the VM to lookup symbols in native code assets. If no callback is provided, using @Native
s with native_asset.yaml
s will fail.
handle | The library handle returned from a Dart_NativeAssetsDlopenCallback or Dart_NativeAssetsDlopenCallbackNoPath . |
symbol | The symbol to look up. Is a string. |
error | Returns NULL if creation is successful, an error message otherwise. The caller is responsible for calling free() on the error message. |
Definition at line 3387 of file dart_api.h.
typedef Dart_NativeFunction(* Dart_NativeEntryResolver) (Dart_Handle name, int num_of_arguments, bool *auto_setup_scope) |
Native entry resolution callback.
For libraries and scripts which have native functions, the embedder can provide a native entry resolver. This callback is used to map a name/arity to a Dart_NativeFunction. If no function is found, the callback should return NULL.
The parameters to the native resolver function are:
name | a Dart string which is the name of the native function. |
num_of_arguments | is the number of arguments expected by the native function. |
auto_setup_scope | is a boolean flag that can be set by the resolver to indicate if this function needs a Dart API scope (see Dart_EnterScope/ Dart_ExitScope) to be setup automatically by the VM before calling into the native function. By default most native functions would require this to be true but some light weight native functions which do not call back into the VM through the Dart API may not require a Dart scope to be setup automatically. |
See Dart_SetNativeResolver.
Definition at line 3234 of file dart_api.h.
typedef const uint8_t *(* Dart_NativeEntrySymbol) (Dart_NativeFunction nf) |
Native entry symbol lookup callback.
For libraries and scripts which have native functions, the embedder can provide a callback for mapping a native entry to a symbol. This callback maps a native function entry PC to the native function name. If no native entry symbol can be found, the callback should return NULL.
The parameters to the native reverse resolver function are:
nf | A Dart_NativeFunction. |
See Dart_SetNativeResolver.
Definition at line 3255 of file dart_api.h.
typedef void(* Dart_NativeFunction) (Dart_NativeArguments arguments) |
A native function.
Definition at line 3207 of file dart_api.h.
typedef void(* Dart_OnNewCodeCallback) (struct Dart_CodeObserver *observer, const char *name, uintptr_t base, uintptr_t size) |
Callback provided by the embedder that is used by the VM to notify on code object creation, before it is invoked the first time. This is useful for embedders wanting to e.g. keep track of PCs beyond the lifetime of the garbage collected code objects. Note that an address range may be used by more than one code object over the lifecycle of a process. Clients of this function should record timestamps for these compilation events and when collecting PCs to disambiguate reused address ranges.
Definition at line 855 of file dart_api.h.
typedef Dart_Handle Dart_PersistentHandle |
Definition at line 259 of file dart_api.h.
typedef int64_t Dart_Port |
A port is used to send or receive inter-isolate messages
Definition at line 1525 of file dart_api.h.
typedef const char *(* Dart_RegisterKernelBlobCallback) (const uint8_t *kernel_buffer, intptr_t kernel_buffer_size) |
Optional callback provided by the embedder that is used by the VM to implement registration of kernel blobs for the subsequent Isolate.spawnUri If no callback is provided, the registration of kernel blobs will throw an error.
kernel_buffer | A buffer which contains a kernel program. Callback should copy the contents of kernel_buffer as it may be freed immediately after registration. |
kernel_buffer_size | The size of kernel_buffer . |
Definition at line 882 of file dart_api.h.
typedef void(* Dart_StreamingCloseCallback) (void *callback_data) |
Definition at line 3938 of file dart_api.h.
typedef void(* Dart_StreamingWriteCallback) (void *callback_data, const uint8_t *buffer, intptr_t size) |
Definition at line 3935 of file dart_api.h.
typedef void(* Dart_ThreadExitCallback) (void) |
A thread death callback function. This callback, provided by the embedder, is called before a thread in the vm thread pool exits. This function could be used to dispose of native resources that are associated and attached to the thread, in order to avoid leaks.
Definition at line 763 of file dart_api.h.
typedef void(* Dart_ThreadStartCallback) (void) |
A thread start callback function. This callback, provided by the embedder, is called after a thread in the vm thread pool starts. This function could be used to adjust thread priority or attach native resources to the thread.
Definition at line 754 of file dart_api.h.
typedef void(* Dart_UnregisterKernelBlobCallback) (const char *kernel_blob_uri) |
Optional callback provided by the embedder that is used by the VM to unregister kernel blobs. If no callback is provided, the unregistration of kernel blobs will throw an error.
kernel_blob_uri | URI of the kernel blob to unregister. |
Definition at line 894 of file dart_api.h.
typedef struct _Dart_WeakPersistentHandle* Dart_WeakPersistentHandle |
Definition at line 260 of file dart_api.h.
anonymous enum |
Enumerator | |
---|---|
kNativeArgNumberPos | |
kNativeArgNumberSize | |
kNativeArgTypePos | |
kNativeArgTypeSize |
Definition at line 3061 of file dart_api.h.
Experimental support for Dart to Kernel parser isolate.
TODO(hausner): Document finalized interface.
Enumerator | |
---|---|
Dart_KernelCompilationStatus_Unknown | |
Dart_KernelCompilationStatus_Ok | |
Dart_KernelCompilationStatus_Error | |
Dart_KernelCompilationStatus_Crash | |
Dart_KernelCompilationStatus_MsgFailed |
Definition at line 3783 of file dart_api.h.
Enumerator | |
---|---|
Dart_KernelCompilationVerbosityLevel_Error | |
Dart_KernelCompilationVerbosityLevel_Warning | |
Dart_KernelCompilationVerbosityLevel_Info | |
Dart_KernelCompilationVerbosityLevel_All |
Definition at line 3798 of file dart_api.h.
enum Dart_LibraryTag |
Enumerator | |
---|---|
Dart_kCanonicalizeUrl | |
Dart_kImportTag | |
Dart_kKernelTag |
Definition at line 3419 of file dart_api.h.
Definition at line 3026 of file dart_api.h.
enum Dart_PerformanceMode |
Definition at line 1369 of file dart_api.h.
enum Dart_TypedData_Type |
Definition at line 2612 of file dart_api.h.
DART_EXPORT void Dart_AddSymbols | ( | const char * | dso_name, |
void * | buffer, | ||
intptr_t | buffer_size | ||
) |
Register symbol information for the Dart VM's profiler and crash dumps.
This consumes the output of //topaz/runtime/dart/profiler_symbols, which should be treated as opaque.
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_Allocate | ( | Dart_Handle | type | ) |
Allocate a new object without invoking a constructor.
type | The type of an object to be allocated. |
DART_EXPORT Dart_Handle Dart_AllocateWithNativeFields | ( | Dart_Handle | type, |
intptr_t | num_native_fields, | ||
const intptr_t * | native_fields | ||
) |
Allocate a new object without invoking a constructor, and sets specified native fields.
type | The type of an object to be allocated. |
num_native_fields | The number of native fields to set. |
native_fields | An array containing the value of native fields. |
DART_EXPORT Dart_Handle Dart_BooleanValue | ( | Dart_Handle | boolean_obj, |
bool * | value | ||
) |
DART_EXPORT Dart_Handle Dart_ClassLibrary | ( | Dart_Handle | cls_type | ) |
Returns a handle to the library which contains class.
DART_EXPORT Dart_Handle Dart_ClassName | ( | Dart_Handle | cls_type | ) |
Returns the name for the provided class type.
DART_EXPORT DART_WARN_UNUSED_RESULT char * Dart_Cleanup | ( | void | ) |
Cleanup state in the VM before process termination.
NOTE: This function must not be called on a thread that was created by the VM itself.
DART_EXPORT Dart_Handle Dart_ClosureFunction | ( | Dart_Handle | closure | ) |
Retrieves the function of a closure.
DART_EXPORT Dart_KernelCompilationResult Dart_CompileToKernel | ( | const char * | script_uri, |
const uint8_t * | platform_kernel, | ||
const intptr_t | platform_kernel_size, | ||
bool | incremental_compile, | ||
bool | snapshot_compile, | ||
bool | embed_sources, | ||
const char * | package_config, | ||
Dart_KernelCompilationVerbosityLevel | verbosity | ||
) |
Compiles the given script_uri
to a kernel file.
platform_kernel | A buffer containing the kernel of the platform (e.g. vm_platform_strong.dill ). The VM does not take ownership of this memory. |
platform_kernel_size | The length of the platform_kernel buffer. |
snapshot_compile | Set to true when the compilation is for a snapshot. This is used by the frontend to determine if compilation related information should be printed to console (e.g., null safety mode). |
embed_sources | Set to true when sources should be embedded in the kernel file. |
verbosity | Specifies the logging behavior of the kernel compilation service. |
On a successful compilation the returned [Dart_KernelCompilationResult] has a status of [Dart_KernelCompilationStatus_Ok] and the kernel
/kernel_size
fields are set. The caller takes ownership of the malloc()ed buffer.
On a failed compilation the error
might be set describing the reason for the failed compilation. The caller takes ownership of the malloc()ed error.
Requires there to be a current isolate.
DART_EXPORT Dart_Handle Dart_CopyUTF8EncodingOfString | ( | Dart_Handle | str, |
uint8_t * | utf8_array, | ||
intptr_t | length | ||
) |
Copies the UTF-8 encoded representation of a String into specified buffer.
Any unpaired surrogate code points in the string will be converted as replacement characters (U+FFFD, 0xEF 0xBF 0xBD in UTF-8).
str | A string. |
utf8_array | Buffer into which the UTF-8 encoded representation of the string is copied into. The buffer is allocated and managed by the caller. |
length | Specifies the length of the buffer passed in. |
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_CreateAppAOTSnapshotAsAssemblies | ( | Dart_CreateLoadingUnitCallback | next_callback, |
void * | next_callback_data, | ||
bool | stripped, | ||
Dart_StreamingWriteCallback | write_callback, | ||
Dart_StreamingCloseCallback | close_callback | ||
) |
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_CreateAppAOTSnapshotAsAssembly | ( | Dart_StreamingWriteCallback | callback, |
void * | callback_data, | ||
bool | stripped, | ||
void * | debug_callback_data | ||
) |
Creates a precompiled snapshot.
Outputs an assembly file defining the symbols listed in the definitions above.
The assembly should be compiled as a static or shared library and linked or loaded by the embedder. Running this snapshot requires a VM compiled with DART_PRECOMPILED_SNAPSHOT. The kDartVmSnapshotData and kDartVmSnapshotInstructions should be passed to Dart_Initialize. The kDartIsolateSnapshotData and kDartIsolateSnapshotInstructions should be passed to Dart_CreateIsolateGroup.
The callback will be invoked one or more times to provide the assembly code.
If stripped is true, then the assembly code will not include DWARF debugging sections.
If debug_callback_data is provided, debug_callback_data will be used with the callback to provide separate debugging information.
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_CreateAppAOTSnapshotAsElf | ( | Dart_StreamingWriteCallback | callback, |
void * | callback_data, | ||
bool | stripped, | ||
void * | debug_callback_data | ||
) |
Creates a precompiled snapshot.
Outputs an ELF shared library defining the symbols
The shared library should be dynamically loaded by the embedder. Running this snapshot requires a VM compiled with DART_PRECOMPILED_SNAPSHOT. The kDartVmSnapshotData and kDartVmSnapshotInstructions should be passed to Dart_Initialize. The kDartIsolateSnapshotData and kDartIsolateSnapshotInstructions should be passed to Dart_CreateIsolate.
The callback will be invoked one or more times to provide the binary output.
If stripped is true, then the binary output will not include DWARF debugging sections.
If debug_callback_data is provided, debug_callback_data will be used with the callback to provide separate debugging information.
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_CreateAppAOTSnapshotAsElfs | ( | Dart_CreateLoadingUnitCallback | next_callback, |
void * | next_callback_data, | ||
bool | stripped, | ||
Dart_StreamingWriteCallback | write_callback, | ||
Dart_StreamingCloseCallback | close_callback | ||
) |
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_CreateAppJITSnapshotAsBlobs | ( | uint8_t ** | isolate_snapshot_data_buffer, |
intptr_t * | isolate_snapshot_data_size, | ||
uint8_t ** | isolate_snapshot_instructions_buffer, | ||
intptr_t * | isolate_snapshot_instructions_size | ||
) |
Creates a snapshot that caches compiled code and type feedback for faster startup and quicker warmup in a subsequent process.
Outputs a snapshot in two pieces. The pieces should be passed to Dart_CreateIsolateGroup in a VM using the same VM snapshot pieces used in the current VM. The instructions piece must be loaded with read and execute permissions; the data piece may be loaded as read-only.
The buffers are scope allocated and are only valid until the next call to Dart_ExitScope.
DART_EXPORT Dart_Isolate Dart_CreateIsolateGroup | ( | const char * | script_uri, |
const char * | name, | ||
const uint8_t * | isolate_snapshot_data, | ||
const uint8_t * | isolate_snapshot_instructions, | ||
Dart_IsolateFlags * | flags, | ||
void * | isolate_group_data, | ||
void * | isolate_data, | ||
char ** | error | ||
) |
Creates a new isolate. The new isolate becomes the current isolate.
A snapshot can be used to restore the VM quickly to a saved state and is useful for fast startup. If snapshot data is provided, the isolate will be started using that snapshot data. Requires a core snapshot or an app snapshot created by Dart_CreateSnapshot or Dart_CreatePrecompiledSnapshot* from a VM with the same version.
Requires there to be no current isolate.
script_uri | The main source file or snapshot this isolate will load. The VM will provide this URI to the Dart_IsolateGroupCreateCallback when a child isolate is created by Isolate.spawn. The embedder should use a URI that allows it to load the same program into such a child isolate. |
name | A short name for the isolate to improve debugging messages. Typically of the format 'foo.dart:main()'. |
isolate_snapshot_data | Buffer containing the snapshot data of the isolate or NULL if no snapshot is provided. If provided, the buffer must remain valid until the isolate shuts down. |
isolate_snapshot_instructions | Buffer containing the snapshot instructions of the isolate or NULL if no snapshot is provided. If provided, the buffer must remain valid until the isolate shuts down. |
flags | Pointer to VM specific flags or NULL for default flags. |
isolate_group_data | Embedder group data. This data can be obtained by calling Dart_IsolateGroupData and will be passed to the Dart_IsolateShutdownCallback, Dart_IsolateCleanupCallback, and Dart_IsolateGroupCleanupCallback. |
isolate_data | Embedder data. This data will be passed to the Dart_IsolateGroupCreateCallback when new isolates are spawned from this parent isolate. |
error | Returns NULL if creation is successful, an error message otherwise. The caller is responsible for calling free() on the error message. |
DART_EXPORT Dart_Isolate Dart_CreateIsolateGroupFromKernel | ( | const char * | script_uri, |
const char * | name, | ||
const uint8_t * | kernel_buffer, | ||
intptr_t | kernel_buffer_size, | ||
Dart_IsolateFlags * | flags, | ||
void * | isolate_group_data, | ||
void * | isolate_data, | ||
char ** | error | ||
) |
Creates a new isolate from a Dart Kernel file. The new isolate becomes the current isolate.
Requires there to be no current isolate.
script_uri | The main source file or snapshot this isolate will load. The VM will provide this URI to the Dart_IsolateGroupCreateCallback when a child isolate is created by Isolate.spawn. The embedder should use a URI that allows it to load the same program into such a child isolate. |
name | A short name for the isolate to improve debugging messages. Typically of the format 'foo.dart:main()'. |
kernel_buffer | A buffer which contains a kernel/DIL program. Must remain valid until isolate shutdown. |
kernel_buffer_size | The size of kernel_buffer . |
flags | Pointer to VM specific flags or NULL for default flags. |
isolate_group_data | Embedder group data. This data can be obtained by calling Dart_IsolateGroupData and will be passed to the Dart_IsolateShutdownCallback, Dart_IsolateCleanupCallback, and Dart_IsolateGroupCleanupCallback. |
isolate_data | Embedder data. This data will be passed to the Dart_IsolateGroupCreateCallback when new isolates are spawned from this parent isolate. |
error | Returns NULL if creation is successful, an error message otherwise. The caller is responsible for calling free() on the error message. |
DART_EXPORT Dart_Isolate Dart_CreateIsolateInGroup | ( | Dart_Isolate | group_member, |
const char * | name, | ||
Dart_IsolateShutdownCallback | shutdown_callback, | ||
Dart_IsolateCleanupCallback | cleanup_callback, | ||
void * | child_isolate_data, | ||
char ** | error | ||
) |
Creates a new isolate inside the isolate group of [group_member].
Requires there to be no current isolate.
group_member | An isolate from the same group into which the newly created isolate should be born into. Other threads may not have entered / enter this member isolate. |
name | A short name for the isolate for debugging purposes. |
shutdown_callback | A callback to be called when the isolate is being shutdown (may be NULL). |
cleanup_callback | A callback to be called when the isolate is being cleaned up (may be NULL). |
child_isolate_data | The embedder-specific data associated with this isolate. |
error | Set to NULL if creation is successful, set to an error message otherwise. The caller is responsible for calling free() on the error message. |
If successful, the newly created isolate will become the current isolate.
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_CreateSnapshot | ( | uint8_t ** | vm_snapshot_data_buffer, |
intptr_t * | vm_snapshot_data_size, | ||
uint8_t ** | isolate_snapshot_data_buffer, | ||
intptr_t * | isolate_snapshot_data_size, | ||
bool | is_core | ||
) |
Creates a full snapshot of the current isolate heap.
A full snapshot is a compact representation of the dart vm isolate heap and dart isolate heap states. These snapshots are used to initialize the vm isolate on startup and fast initialization of an isolate. A Snapshot of the heap is created before any dart code has executed.
Requires there to be a current isolate. Not available in the precompiled runtime (check Dart_IsPrecompiledRuntime).
vm_snapshot_data_buffer | Returns a pointer to a buffer containing the vm snapshot. This buffer is scope allocated and is only valid until the next call to Dart_ExitScope. |
vm_snapshot_data_size | Returns the size of vm_snapshot_data_buffer. |
isolate_snapshot_data_buffer | Returns a pointer to a buffer containing the isolate snapshot. This buffer is scope allocated and is only valid until the next call to Dart_ExitScope. |
isolate_snapshot_data_size | Returns the size of isolate_snapshot_data_buffer. |
is_core | Create a snapshot containing core libraries. Such snapshot should be agnostic to null safety mode. |
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_CreateVMAOTSnapshotAsAssembly | ( | Dart_StreamingWriteCallback | callback, |
void * | callback_data | ||
) |
Like Dart_CreateAppAOTSnapshotAsAssembly, but only includes kDartVmSnapshotData and kDartVmSnapshotInstructions. It also does not strip DWARF information from the generated assembly or allow for separate debug information.
DART_EXPORT Dart_Isolate Dart_CurrentIsolate | ( | void | ) |
Returns the current isolate. Will return NULL if there is no current isolate.
DART_EXPORT void * Dart_CurrentIsolateData | ( | void | ) |
Returns the callback data associated with the current isolate. This data was set when the isolate got created or initialized.
DART_EXPORT Dart_IsolateGroup Dart_CurrentIsolateGroup | ( | void | ) |
Returns the current isolate group. Will return NULL if there is no current isolate group.
DART_EXPORT void * Dart_CurrentIsolateGroupData | ( | void | ) |
Returns the callback data associated with the current isolate group. This data was passed to the isolate group when it was created.
DART_EXPORT Dart_IsolateGroupId Dart_CurrentIsolateGroupId | ( | void | ) |
DART_EXPORT Dart_Handle Dart_DebugName | ( | void | ) |
Returns the debugging name for the current isolate.
This name is unique to each isolate and should only be used to make debugging messages more comprehensible.
DART_EXPORT const char * Dart_DebugNameToCString | ( | void | ) |
Returns the debugging name for the current isolate.
This name is unique to each isolate and should only be used to make debugging messages more comprehensible.
The returned string is scope allocated and is only valid until the next call to Dart_ExitScope.
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_DeferredLoadComplete | ( | intptr_t | loading_unit_id, |
const uint8_t * | snapshot_data, | ||
const uint8_t * | snapshot_instructions | ||
) |
Notifies the VM that a deferred load completed successfully. This function will eventually cause the corresponding prefix.loadLibrary()
futures to complete.
Requires the current isolate to be the same current isolate during the invocation of the Dart_DeferredLoadHandler.
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_DeferredLoadCompleteError | ( | intptr_t | loading_unit_id, |
const char * | error_message, | ||
bool | transient | ||
) |
Notifies the VM that a deferred load failed. This function will eventually cause the corresponding prefix.loadLibrary()
futures to complete with an error.
If transient
is true, future invocations of prefix.loadLibrary()
will trigger new load requests. If false, futures invocation will complete with the same error.
Requires the current isolate to be the same current isolate during the invocation of the Dart_DeferredLoadHandler.
DART_EXPORT void Dart_DeleteFinalizableHandle | ( | Dart_FinalizableHandle | object, |
Dart_Handle | strong_ref_to_object | ||
) |
Deletes the given finalizable [object] handle.
The caller has to provide the actual Dart object the handle was created from to prove the object (and therefore the finalizable handle) is still alive.
Requires there to be a current isolate.
DART_EXPORT void Dart_DeletePersistentHandle | ( | Dart_PersistentHandle | object | ) |
Deallocates a persistent handle.
Requires there to be a current isolate group.
DART_EXPORT void Dart_DeleteWeakPersistentHandle | ( | Dart_WeakPersistentHandle | object | ) |
Deletes the given weak persistent [object] handle.
Requires there to be a current isolate group.
DART_EXPORT bool Dart_DetectNullSafety | ( | const char * | script_uri, |
const char * | package_config, | ||
const char * | original_working_directory, | ||
const uint8_t * | snapshot_data, | ||
const uint8_t * | snapshot_instructions, | ||
const uint8_t * | kernel_buffer, | ||
intptr_t | kernel_buffer_size | ||
) |
Always return true as the VM only supports strong null safety.
DART_EXPORT void Dart_DisableHeapSampling | ( | void | ) |
DART_EXPORT Dart_Handle Dart_DoubleValue | ( | Dart_Handle | double_obj, |
double * | value | ||
) |
DART_EXPORT void Dart_DumpNativeStackTrace | ( | void * | context | ) |
Print a native stack trace. Used for crash handling.
If context is NULL, prints the current stack trace. Otherwise, context should be a CONTEXT* (Windows) or ucontext_t* (POSIX) from a signal handler running on the current thread.
DART_EXPORT Dart_Handle Dart_EmptyString | ( | void | ) |
Returns the empty string object.
DART_EXPORT void Dart_EnableHeapSampling | ( | void | ) |
Starts the heap sampling profiler for each thread in the VM.
DART_EXPORT void Dart_EnterIsolate | ( | Dart_Isolate | isolate | ) |
Enters an isolate. After calling this function, the current isolate will be set to the provided isolate.
Requires there to be no current isolate. Multiple threads may not be in the same isolate at once.
DART_EXPORT void Dart_EnterScope | ( | void | ) |
Enters a new scope.
All new local handles will be created in this scope. Additionally, some functions may return "scope allocated" memory which is only valid within this scope.
Requires there to be a current isolate.
DART_EXPORT Dart_Handle Dart_ErrorGetException | ( | Dart_Handle | handle | ) |
Gets the exception Object from an unhandled exception error handle.
DART_EXPORT Dart_Handle Dart_ErrorGetStackTrace | ( | Dart_Handle | handle | ) |
Gets the stack trace Object from an unhandled exception error handle.
DART_EXPORT bool Dart_ErrorHasException | ( | Dart_Handle | handle | ) |
Is this an error handle for an unhandled exception?
DART_EXPORT void Dart_ExitIsolate | ( | void | ) |
Exits an isolate. After this call, Dart_CurrentIsolate will return NULL.
Requires there to be a current isolate.
DART_EXPORT void Dart_ExitScope | ( | void | ) |
Exits a scope.
The previous scope (if any) becomes the current scope.
Requires there to be a current isolate.
DART_EXPORT Dart_Handle Dart_False | ( | void | ) |
Returns the False object.
Requires there to be a current isolate.
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_FinalizeLoading | ( | bool | complete_futures | ) |
Indicates that all outstanding load requests have been satisfied. This finalizes all the new classes loaded and optionally completes deferred library futures.
Requires there to be a current isolate.
complete_futures | Specify true if all deferred library futures should be completed, false otherwise. |
DART_EXPORT Dart_Handle Dart_FunctionIsStatic | ( | Dart_Handle | function, |
bool * | is_static | ||
) |
Determines whether a function handle refers to a static function of method.
For the purposes of the embedding API, a top-level function is implicitly declared static.
function | A handle to a function or method declaration. |
is_static | Returns whether the function or method is declared static. |
DART_EXPORT Dart_Handle Dart_FunctionName | ( | Dart_Handle | function | ) |
Returns the name for the provided function or method.
DART_EXPORT Dart_Handle Dart_FunctionOwner | ( | Dart_Handle | function | ) |
Returns a handle to the owner of a function.
The owner of an instance method or a static method is its defining class. The owner of a top-level function is its defining library. The owner of the function of a non-implicit closure is the function of the method or closure that defines the non-implicit closure.
DART_EXPORT Dart_Handle Dart_GetClass | ( | Dart_Handle | library, |
Dart_Handle | class_name | ||
) |
Lookup a class or interface by name from a Library.
library | The library containing the class or interface. |
class_name | The name of the class or interface. |
DART_EXPORT Dart_Handle Dart_GetDataFromByteBuffer | ( | Dart_Handle | byte_buffer | ) |
Returns the TypedData object associated with the ByteBuffer object.
byte_buffer | The ByteBuffer object. |
DART_EXPORT const char * Dart_GetError | ( | Dart_Handle | handle | ) |
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_GetField | ( | Dart_Handle | container, |
Dart_Handle | name | ||
) |
Gets the value of a field.
The 'container' parameter may be an object, type, or library. If 'container' is an object, then this function will access an instance field. If 'container' is a type, then this function will access a static field. If 'container' is a library, then this function will access a top-level variable. NOTE: This API call cannot be used to access fields of a type object.
This function ignores field visibility (leading underscores in names).
May generate an unhandled exception error.
container | An object, type, or library. |
name | A field name. |
DART_EXPORT Dart_Handle Dart_GetLoadedLibraries | ( | void | ) |
DART_EXPORT Dart_Port Dart_GetMainPortId | ( | void | ) |
Gets the main port id for the current isolate.
DART_EXPORT Dart_MessageNotifyCallback Dart_GetMessageNotifyCallback | ( | void | ) |
Query the current message notify callback for the isolate.
DART_EXPORT Dart_Handle Dart_GetNativeArgument | ( | Dart_NativeArguments | args, |
int | index | ||
) |
Gets the native argument at some index.
DART_EXPORT int Dart_GetNativeArgumentCount | ( | Dart_NativeArguments | args | ) |
Gets the number of native arguments.
DART_EXPORT Dart_Handle Dart_GetNativeArguments | ( | Dart_NativeArguments | args, |
int | num_arguments, | ||
const Dart_NativeArgument_Descriptor * | arg_descriptors, | ||
Dart_NativeArgument_Value * | arg_values | ||
) |
Gets the native arguments based on the types passed in and populates the passed arguments buffer with appropriate native values.
args | the Native arguments block passed into the native call. |
num_arguments | length of argument descriptor array and argument values array passed in. |
arg_descriptors | an array that describes the arguments that need to be retrieved. For each argument to be retrieved the descriptor contains the argument number (0, 1 etc.) and the argument type described using Dart_NativeArgument_Type, e.g: DART_NATIVE_ARG_DESCRIPTOR(Dart_NativeArgument_kBool, 1) indicates that the first argument is to be retrieved and it should be a boolean. |
arg_values | array into which the native arguments need to be extracted into, the array is allocated by the caller (it could be stack allocated to avoid the malloc/free performance overhead). |
DART_EXPORT Dart_Handle Dart_GetNativeBooleanArgument | ( | Dart_NativeArguments | args, |
int | index, | ||
bool * | value | ||
) |
Gets a boolean native argument at some index.
args | Native arguments structure. |
index | Index of the desired argument in the structure above. |
value | Returns the boolean value if the argument is a Boolean. |
DART_EXPORT Dart_Handle Dart_GetNativeDoubleArgument | ( | Dart_NativeArguments | args, |
int | index, | ||
double * | value | ||
) |
Gets a double native argument at some index.
args | Native arguments structure. |
index | Index of the desired argument in the structure above. |
value | Returns the double value if the argument is a double. |
DART_EXPORT Dart_Handle Dart_GetNativeFieldsOfArgument | ( | Dart_NativeArguments | args, |
int | arg_index, | ||
int | num_fields, | ||
intptr_t * | field_values | ||
) |
Gets all the native fields of the native argument at some index.
args | Native arguments structure. |
arg_index | Index of the desired argument in the structure above. |
num_fields | size of the intptr_t array 'field_values' passed in. |
field_values | intptr_t array in which native field values are returned. |
DART_EXPORT Dart_Handle Dart_GetNativeInstanceField | ( | Dart_Handle | obj, |
int | index, | ||
intptr_t * | value | ||
) |
Gets the value of a native field.
TODO(turnidge): Document.
DART_EXPORT Dart_Handle Dart_GetNativeInstanceFieldCount | ( | Dart_Handle | obj, |
int * | count | ||
) |
Gets the number of native instance fields in an object.
DART_EXPORT Dart_Handle Dart_GetNativeIntegerArgument | ( | Dart_NativeArguments | args, |
int | index, | ||
int64_t * | value | ||
) |
Gets an integer native argument at some index.
args | Native arguments structure. |
index | Index of the desired argument in the structure above. |
value | Returns the integer value if the argument is an Integer. |
DART_EXPORT void * Dart_GetNativeIsolateGroupData | ( | Dart_NativeArguments | args | ) |
Extracts current isolate group data from the native arguments structure.
DART_EXPORT Dart_Handle Dart_GetNativeReceiver | ( | Dart_NativeArguments | args, |
intptr_t * | value | ||
) |
Gets the native field of the receiver.
DART_EXPORT Dart_Handle Dart_GetNativeResolver | ( | Dart_Handle | library, |
Dart_NativeEntryResolver * | resolver | ||
) |
DART_EXPORT Dart_Handle Dart_GetNativeStringArgument | ( | Dart_NativeArguments | args, |
int | arg_index, | ||
void ** | peer | ||
) |
Gets a string native argument at some index.
args | Native arguments structure. |
arg_index | Index of the desired argument in the structure above. |
peer | Returns the peer pointer if the string argument has one. |
DART_EXPORT Dart_Handle Dart_GetNativeSymbol | ( | Dart_Handle | library, |
Dart_NativeEntrySymbol * | resolver | ||
) |
DART_EXPORT Dart_Handle Dart_GetNonNullableType | ( | Dart_Handle | library, |
Dart_Handle | class_name, | ||
intptr_t | number_of_type_arguments, | ||
Dart_Handle * | type_arguments | ||
) |
Lookup or instantiate a non-nullable type by name and type arguments from Library.
library | The library containing the class or interface. |
class_name | The class name for the type. |
number_of_type_arguments | Number of type arguments. For non parametric types the number of type arguments would be 0. |
type_arguments | Pointer to an array of type arguments. For non parametric types a NULL would be passed in for this argument. |
DART_EXPORT Dart_Handle Dart_GetNullableType | ( | Dart_Handle | library, |
Dart_Handle | class_name, | ||
intptr_t | number_of_type_arguments, | ||
Dart_Handle * | type_arguments | ||
) |
Lookup or instantiate a nullable type by name and type arguments from Library.
library | The library containing the class or interface. |
class_name | The class name for the type. |
number_of_type_arguments | Number of type arguments. For non parametric types the number of type arguments would be 0. |
type_arguments | Pointer to an array of type arguments. For non parametric types a NULL would be passed in for this argument. |
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_GetObfuscationMap | ( | uint8_t ** | buffer, |
intptr_t * | buffer_length | ||
) |
Get obfuscation map for precompiled code.
Obfuscation map is encoded as a JSON array of pairs (original name, obfuscated name).
DART_EXPORT Dart_Handle Dart_GetPeer | ( | Dart_Handle | object, |
void ** | peer | ||
) |
The peer field is a lazily allocated field intended for storage of an uncommonly used values. Most instances types can have a peer field allocated. The exceptions are subtypes of Null, num, and bool. Returns the value of peer field of 'object' in 'peer'.
object | An object. |
peer | An out parameter that returns the value of the peer field. |
DART_EXPORT Dart_Handle Dart_GetStaticMethodClosure | ( | Dart_Handle | library, |
Dart_Handle | cls_type, | ||
Dart_Handle | function_name | ||
) |
Returns a closure of static function 'function_name' in the class 'class_name' in the exported namespace of specified 'library'.
library | Library object |
cls_type | Type object representing a Class |
function_name | Name of the static function in the class |
DART_EXPORT Dart_Handle Dart_GetStickyError | ( | void | ) |
Gets the sticky error for the current isolate.
DART_EXPORT Dart_Handle Dart_GetType | ( | Dart_Handle | library, |
Dart_Handle | class_name, | ||
intptr_t | number_of_type_arguments, | ||
Dart_Handle * | type_arguments | ||
) |
Lookup or instantiate a legacy type by name and type arguments from a Library.
library | The library containing the class or interface. |
class_name | The class name for the type. |
number_of_type_arguments | Number of type arguments. For non parametric types the number of type arguments would be 0. |
type_arguments | Pointer to an array of type arguments. For non parametric types a NULL would be passed in for this argument. |
DART_EXPORT Dart_TypedData_Type Dart_GetTypeOfExternalTypedData | ( | Dart_Handle | object | ) |
Return type if this object is an external TypedData object.
DART_EXPORT Dart_TypedData_Type Dart_GetTypeOfTypedData | ( | Dart_Handle | object | ) |
Return type if this object is a TypedData object.
DART_EXPORT Dart_Handle Dart_HandleFromPersistent | ( | Dart_PersistentHandle | object | ) |
Allocates a handle in the current scope from a persistent handle.
DART_EXPORT Dart_Handle Dart_HandleFromWeakPersistent | ( | Dart_WeakPersistentHandle | object | ) |
Allocates a handle in the current scope from a weak persistent handle.
This will be a handle to Dart_Null if the object has been garbage collected.
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_HandleMessage | ( | void | ) |
Handles the next pending message for the current isolate.
May generate an unhandled exception error.
DART_EXPORT bool Dart_HandleServiceMessages | ( | void | ) |
Handles any pending messages for the vm service for the current isolate.
This function may be used by an embedder at a breakpoint to avoid pausing the vm service.
This function can indirectly cause the message notify callback to be called.
DART_EXPORT bool Dart_HasLivePorts | ( | void | ) |
Does the current isolate have live ReceivePorts?
A ReceivePort is live when it has not been closed.
DART_EXPORT bool Dart_HasServiceMessages | ( | void | ) |
Does the current isolate have pending service messages?
DART_EXPORT bool Dart_HasStickyError | ( | void | ) |
Does the current isolate have a sticky error?
DART_EXPORT bool Dart_IdentityEquals | ( | Dart_Handle | obj1, |
Dart_Handle | obj2 | ||
) |
Checks to see if two handles refer to identically equal objects.
If both handles refer to instances, this is equivalent to using the top-level function identical() from dart:core. Otherwise, returns whether the two argument handles refer to the same object.
obj1 | An object to be compared. |
obj2 | An object to be compared. |
DART_EXPORT DART_WARN_UNUSED_RESULT char * Dart_Initialize | ( | Dart_InitializeParams * | params | ) |
Initializes the VM.
params | A struct containing initialization information. The version field of the struct must be DART_INITIALIZE_PARAMS_CURRENT_VERSION. |
DART_EXPORT void Dart_InitializeNativeAssetsResolver | ( | NativeAssetsApi * | native_assets_api | ) |
Initializes native asset resolution for the current isolate group.
The caller is responsible for ensuring this is called right after isolate group creation, and before running any dart code (or spawning isolates).
native_assets_api | The callbacks used by native assets resolution. The VM does not take ownership of the parameter, it can be freed immediately after the call. |
DART_EXPORT Dart_Handle Dart_InstanceGetType | ( | Dart_Handle | instance | ) |
Gets the type of a Dart language object.
instance | Some Dart object. |
DART_EXPORT Dart_Handle Dart_IntegerFitsIntoInt64 | ( | Dart_Handle | integer, |
bool * | fits | ||
) |
Does this Integer fit into a 64-bit signed integer?
integer | An integer. |
fits | Returns true if the integer fits into a 64-bit signed integer. |
DART_EXPORT Dart_Handle Dart_IntegerFitsIntoUint64 | ( | Dart_Handle | integer, |
bool * | fits | ||
) |
Does this Integer fit into a 64-bit unsigned integer?
integer | An integer. |
fits | Returns true if the integer fits into a 64-bit unsigned integer. |
DART_EXPORT Dart_Handle Dart_IntegerToHexCString | ( | Dart_Handle | integer, |
const char ** | value | ||
) |
Gets the value of an integer as a hexadecimal C string.
integer | An Integer. |
value | Returns the value of the Integer as a hexadecimal C string. This C string is scope allocated and is only valid until the next call to Dart_ExitScope. |
DART_EXPORT Dart_Handle Dart_IntegerToInt64 | ( | Dart_Handle | integer, |
int64_t * | value | ||
) |
Gets the value of an Integer.
The integer must fit into a 64-bit signed integer, otherwise an error occurs.
integer | An Integer. |
value | Returns the value of the Integer. |
DART_EXPORT Dart_Handle Dart_IntegerToUint64 | ( | Dart_Handle | integer, |
uint64_t * | value | ||
) |
Gets the value of an Integer.
The integer must fit into a 64-bit unsigned integer, otherwise an error occurs.
integer | An Integer. |
value | Returns the value of the Integer. |
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_Invoke | ( | Dart_Handle | target, |
Dart_Handle | name, | ||
int | number_of_arguments, | ||
Dart_Handle * | arguments | ||
) |
Invokes a method or function.
The 'target' parameter may be an object, type, or library. If 'target' is an object, then this function will invoke an instance method. If 'target' is a type, then this function will invoke a static method. If 'target' is a library, then this function will invoke a top-level function from that library. NOTE: This API call cannot be used to invoke methods of a type object.
This function ignores visibility (leading underscores in names).
May generate an unhandled exception error.
target | An object, type, or library. |
name | The name of the function or method to invoke. |
number_of_arguments | Size of the arguments array. |
arguments | An array of arguments to the function. |
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_InvokeClosure | ( | Dart_Handle | closure, |
int | number_of_arguments, | ||
Dart_Handle * | arguments | ||
) |
Invokes a Closure with the given arguments.
May generate an unhandled exception error.
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_InvokeConstructor | ( | Dart_Handle | object, |
Dart_Handle | name, | ||
int | number_of_arguments, | ||
Dart_Handle * | arguments | ||
) |
Invokes a Generative Constructor on an object that was previously allocated using Dart_Allocate/Dart_AllocateWithNativeFields.
The 'object' parameter must be an object.
This function ignores visibility (leading underscores in names).
May generate an unhandled exception error.
object | An object. |
name | The name of the constructor to invoke. Use Dart_Null() or Dart_EmptyString() to invoke the unnamed constructor. |
number_of_arguments | Size of the arguments array. |
arguments | An array of arguments to the function. |
DART_EXPORT bool Dart_IsApiError | ( | Dart_Handle | handle | ) |
Is this an api error handle?
Api error handles are produced when an api function is misused. This happens when a Dart embedding api function is called with invalid arguments or in an invalid context.
Requires there to be a current isolate.
DART_EXPORT bool Dart_IsBoolean | ( | Dart_Handle | object | ) |
DART_EXPORT bool Dart_IsByteBuffer | ( | Dart_Handle | object | ) |
DART_EXPORT bool Dart_IsClosure | ( | Dart_Handle | object | ) |
DART_EXPORT bool Dart_IsCompilationError | ( | Dart_Handle | handle | ) |
Is this a compilation error handle?
Compilation error handles are produced when, during the execution of Dart code, a compile-time error occurs. This can occur in any function which triggers the execution of Dart code.
Requires there to be a current isolate.
DART_EXPORT bool Dart_IsDouble | ( | Dart_Handle | object | ) |
DART_EXPORT bool Dart_IsError | ( | Dart_Handle | handle | ) |
Is this an error handle?
Requires there to be a current isolate.
DART_EXPORT bool Dart_IsFatalError | ( | Dart_Handle | handle | ) |
Is this a fatal error handle?
Fatal error handles are produced when the system wants to shut down the current isolate.
Requires there to be a current isolate.
DART_EXPORT bool Dart_IsFunction | ( | Dart_Handle | handle | ) |
DART_EXPORT bool Dart_IsFuture | ( | Dart_Handle | object | ) |
DART_EXPORT bool Dart_IsInstance | ( | Dart_Handle | object | ) |
Query object type.
object | Some Object. |
DART_EXPORT bool Dart_IsInteger | ( | Dart_Handle | object | ) |
DART_EXPORT bool Dart_IsKernel | ( | const uint8_t * | buffer, |
intptr_t | buffer_size | ||
) |
Returns whether the buffer contains a kernel file.
buffer | Pointer to a buffer that might contain a kernel binary. |
buffer_size | Size of the buffer. |
DART_EXPORT bool Dart_IsKernelIsolate | ( | Dart_Isolate | isolate | ) |
DART_EXPORT bool Dart_IsLibrary | ( | Dart_Handle | object | ) |
DART_EXPORT bool Dart_IsList | ( | Dart_Handle | object | ) |
DART_EXPORT bool Dart_IsMap | ( | Dart_Handle | object | ) |
DART_EXPORT Dart_Handle Dart_IsNonNullableType | ( | Dart_Handle | type, |
bool * | result | ||
) |
DART_EXPORT bool Dart_IsNull | ( | Dart_Handle | object | ) |
Is this object null?
DART_EXPORT Dart_Handle Dart_IsNullableType | ( | Dart_Handle | type, |
bool * | result | ||
) |
DART_EXPORT bool Dart_IsNumber | ( | Dart_Handle | object | ) |
DART_EXPORT void * Dart_IsolateData | ( | Dart_Isolate | isolate | ) |
Returns the callback data associated with the given isolate. This data was set when the isolate got created or initialized.
DART_EXPORT void Dart_IsolateFlagsInitialize | ( | Dart_IsolateFlags * | flags | ) |
Initialize Dart_IsolateFlags with correct version and default values.
DART_EXPORT void * Dart_IsolateGroupData | ( | Dart_Isolate | isolate | ) |
Returns the callback data associated with the specified isolate group. This data was passed to the isolate when it was created. The embedder is responsible for ensuring the consistency of this data with respect to the lifecycle of an isolate group.
DART_EXPORT DART_WARN_UNUSED_RESULT char * Dart_IsolateMakeRunnable | ( | Dart_Isolate | isolate | ) |
Make isolate runnable.
When isolates are spawned, this function is used to indicate that the creation and initialization (including script loading) of the isolate is complete and the isolate can start. This function expects there to be no current isolate.
isolate | The isolate to be made runnable. |
DART_EXPORT const char * Dart_IsolateServiceId | ( | Dart_Isolate | isolate | ) |
Returns the ID for an isolate which is used to query the service protocol.
It is the responsibility of the caller to free the returned ID.
DART_EXPORT bool Dart_IsPausedOnExit | ( | void | ) |
Is the current isolate paused on exit?
DART_EXPORT bool Dart_IsPausedOnStart | ( | void | ) |
Is the current isolate paused on start?
DART_EXPORT bool Dart_IsPrecompiledRuntime | ( | void | ) |
Returns whether the VM only supports running from precompiled snapshots and not from any other kind of snapshot or from source (that is, the VM was compiled with DART_PRECOMPILED_RUNTIME).
DART_EXPORT bool Dart_IsServiceIsolate | ( | Dart_Isolate | isolate | ) |
Returns true if isolate is the service isolate.
isolate | An isolate |
DART_EXPORT bool Dart_IsString | ( | Dart_Handle | object | ) |
DART_EXPORT bool Dart_IsStringLatin1 | ( | Dart_Handle | object | ) |
DART_EXPORT bool Dart_IsTearOff | ( | Dart_Handle | object | ) |
Is this object a closure resulting from a tear-off (closurized method)?
Returns true for closures produced when an ordinary method is accessed through a getter call. Returns false otherwise, in particular for closures produced from local function declarations.
object | Some Object. |
DART_EXPORT bool Dart_IsType | ( | Dart_Handle | handle | ) |
DART_EXPORT bool Dart_IsTypedData | ( | Dart_Handle | object | ) |
DART_EXPORT bool Dart_IsTypeVariable | ( | Dart_Handle | handle | ) |
DART_EXPORT bool Dart_IsUnhandledExceptionError | ( | Dart_Handle | handle | ) |
Is this an unhandled exception error handle?
Unhandled exception error handles are produced when, during the execution of Dart code, an exception is thrown but not caught. This can occur in any function which triggers the execution of Dart code.
See Dart_ErrorGetException and Dart_ErrorGetStackTrace.
Requires there to be a current isolate.
DART_EXPORT bool Dart_IsVariable | ( | Dart_Handle | handle | ) |
DART_EXPORT bool Dart_IsVMFlagSet | ( | const char * | flag_name | ) |
Returns true if the named VM flag is of boolean type, specified, and set to true.
flag_name | The name of the flag without leading punctuation (example: "enable_asserts"). |
DART_EXPORT bool Dart_KernelIsolateIsRunning | ( | void | ) |
DART_EXPORT Dart_KernelCompilationResult Dart_KernelListDependencies | ( | void | ) |
DART_EXPORT Dart_Port Dart_KernelPort | ( | void | ) |
DART_EXPORT void Dart_KillIsolate | ( | Dart_Isolate | isolate | ) |
Kills the given isolate.
This function has the same effect as dart:isolate's Isolate.kill(priority:immediate). It can interrupt ordinary Dart code but not native code. If the isolate is in the middle of a long running native function, the isolate will not be killed until control returns to Dart.
Does not require a current isolate. It is safe to kill the current isolate if there is one.
DART_EXPORT Dart_Handle Dart_LibraryHandleError | ( | Dart_Handle | library, |
Dart_Handle | error | ||
) |
Report an loading error for the library.
library | The library that failed to load. |
error | The Dart error instance containing the load error. |
DART_EXPORT Dart_Handle Dart_LibraryResolvedUrl | ( | Dart_Handle | library | ) |
Returns a URL from which a Library was loaded.
DART_EXPORT Dart_Handle Dart_LibraryUrl | ( | Dart_Handle | library | ) |
Returns an import path to a Library, such as "file:///test.dart" or "dart:core".
DART_EXPORT Dart_Handle Dart_ListGetAsBytes | ( | Dart_Handle | list, |
intptr_t | offset, | ||
uint8_t * | native_array, | ||
intptr_t | length | ||
) |
May generate an unhandled exception error.
DART_EXPORT Dart_Handle Dart_ListGetAt | ( | Dart_Handle | list, |
intptr_t | index | ||
) |
DART_EXPORT Dart_Handle Dart_ListGetRange | ( | Dart_Handle | list, |
intptr_t | offset, | ||
intptr_t | length, | ||
Dart_Handle * | result | ||
) |
Gets a range of Objects from a List.
If any of the requested index values are out of bounds, an error occurs.
May generate an unhandled exception error.
list | A List. |
offset | The offset of the first item to get. |
length | The number of items to get. |
result | A pointer to fill with the objects. |
DART_EXPORT Dart_Handle Dart_ListLength | ( | Dart_Handle | list, |
intptr_t * | length | ||
) |
DART_EXPORT Dart_Handle Dart_ListSetAsBytes | ( | Dart_Handle | list, |
intptr_t | offset, | ||
const uint8_t * | native_array, | ||
intptr_t | length | ||
) |
May generate an unhandled exception error.
DART_EXPORT Dart_Handle Dart_ListSetAt | ( | Dart_Handle | list, |
intptr_t | index, | ||
Dart_Handle | value | ||
) |
DART_EXPORT Dart_Handle Dart_LoadingUnitLibraryUris | ( | intptr_t | loading_unit_id | ) |
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_LoadLibrary | ( | Dart_Handle | kernel_buffer | ) |
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_LoadLibraryFromKernel | ( | const uint8_t * | kernel_buffer, |
intptr_t | kernel_buffer_size | ||
) |
Called by the embedder to load a partial program. Does not set the root library.
kernel_buffer | A buffer which contains a kernel binary (see pkg/kernel/binary.md). Must remain valid until isolate shutdown. |
kernel_buffer_size | Length of the passed in buffer. |
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_LoadScriptFromKernel | ( | const uint8_t * | kernel_buffer, |
intptr_t | kernel_size | ||
) |
Loads the root library for the current isolate.
Requires there to be no current root library.
kernel_buffer | A buffer which contains a kernel binary (see pkg/kernel/binary.md). Must remain valid until isolate group shutdown. |
kernel_size | Length of the passed in buffer. |
DART_EXPORT Dart_Handle Dart_LookupLibrary | ( | Dart_Handle | url | ) |
DART_EXPORT Dart_Handle Dart_MapContainsKey | ( | Dart_Handle | map, |
Dart_Handle | key | ||
) |
DART_EXPORT Dart_Handle Dart_MapGetAt | ( | Dart_Handle | map, |
Dart_Handle | key | ||
) |
Gets the Object at some key of a Map.
May generate an unhandled exception error.
map | A Map. |
key | An Object. |
DART_EXPORT Dart_Handle Dart_MapKeys | ( | Dart_Handle | map | ) |
Gets the list of keys of a Map.
May generate an unhandled exception error.
map | A Map. |
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_New | ( | Dart_Handle | type, |
Dart_Handle | constructor_name, | ||
int | number_of_arguments, | ||
Dart_Handle * | arguments | ||
) |
Invokes a constructor, creating a new object.
This function allows hidden constructors (constructors with leading underscores) to be called.
type | Type of object to be constructed. |
constructor_name | The name of the constructor to invoke. Use Dart_Null() or Dart_EmptyString() to invoke the unnamed constructor. This name should not include the name of the class. |
number_of_arguments | Size of the arguments array. |
arguments | An array of arguments to the constructor. |
DART_EXPORT Dart_Handle Dart_NewApiError | ( | const char * | error | ) |
Produces an api error handle with the provided error message.
Requires there to be a current isolate.
error | the error message. |
DART_EXPORT Dart_Handle Dart_NewBoolean | ( | bool | value | ) |
Returns a Boolean with the provided value.
value | true or false. |
DART_EXPORT Dart_Handle Dart_NewByteBuffer | ( | Dart_Handle | typed_data | ) |
Returns a ByteBuffer object for the typed data.
typed_data | The TypedData object. |
DART_EXPORT Dart_Handle Dart_NewCompilationError | ( | const char * | error | ) |
DART_EXPORT Dart_Handle Dart_NewDouble | ( | double | value | ) |
Returns a Double with the provided value.
value | A double. |
DART_EXPORT Dart_Handle Dart_NewExternalTypedData | ( | Dart_TypedData_Type | type, |
void * | data, | ||
intptr_t | length | ||
) |
Returns a TypedData object which references an external data array.
type | The type of the data array. |
data | A data array. This array must not move. |
length | The length of the data array (length in type units). |
DART_EXPORT Dart_Handle Dart_NewExternalTypedDataWithFinalizer | ( | Dart_TypedData_Type | type, |
void * | data, | ||
intptr_t | length, | ||
void * | peer, | ||
intptr_t | external_allocation_size, | ||
Dart_HandleFinalizer | callback | ||
) |
Returns a TypedData object which references an external data array.
type | The type of the data array. |
data | A data array. This array must not move. |
length | The length of the data array (length in type units). |
peer | A pointer to a native object or NULL. This value is provided to callback when it is invoked. |
external_allocation_size | The number of externally allocated bytes for peer. Used to inform the garbage collector. |
callback | A function pointer that will be invoked sometime after the object is garbage collected, unless the handle has been deleted. A valid callback needs to be specified it cannot be NULL. |
DART_EXPORT Dart_FinalizableHandle Dart_NewFinalizableHandle | ( | Dart_Handle | object, |
void * | peer, | ||
intptr_t | external_allocation_size, | ||
Dart_HandleFinalizer | callback | ||
) |
Allocates a finalizable handle for an object.
This handle has the lifetime of the current isolate group unless the object pointed to by the handle is garbage collected, in this case the VM automatically deletes the handle after invoking the callback associated with the handle. The handle can also be explicitly deallocated by calling Dart_DeleteFinalizableHandle.
If the object becomes unreachable the callback is invoked with the the peer as argument. The callback can be executed on any thread, will have an isolate group, but will not have a current isolate. The callback can only call Dart_DeletePersistentHandle or Dart_DeleteWeakPersistentHandle. This gives the embedder the ability to cleanup data associated with the object and clear out any cached references to the handle. All references to this handle after the callback will be invalid. It is illegal to call into the VM with any other Dart_* functions from the callback. If the handle is deleted before the object becomes unreachable, the callback is never invoked.
Requires there to be a current isolate.
object | An object with identity. |
peer | A pointer to a native object or NULL. This value is provided to callback when it is invoked. |
external_allocation_size | The number of externally allocated bytes for peer. Used to inform the garbage collector. |
callback | A function pointer that will be invoked sometime after the object is garbage collected, unless the handle has been deleted. A valid callback needs to be specified it cannot be NULL. |
DART_EXPORT Dart_Handle Dart_NewInteger | ( | int64_t | value | ) |
Returns an Integer with the provided value.
value | The value of the integer. |
DART_EXPORT Dart_Handle Dart_NewIntegerFromHexCString | ( | const char * | value | ) |
Returns an Integer with the provided value.
value | The value of the integer represented as a C string containing a hexadecimal number. |
DART_EXPORT Dart_Handle Dart_NewIntegerFromUint64 | ( | uint64_t | value | ) |
Returns an Integer with the provided value.
value | The unsigned value of the integer. |
DART_EXPORT Dart_Handle Dart_NewList | ( | intptr_t | length | ) |
Returns a List<dynamic> of the desired length.
length | The length of the list. |
DART_EXPORT Dart_Handle Dart_NewListOfType | ( | Dart_Handle | element_type, |
intptr_t | length | ||
) |
Returns a List of the desired length with the desired element type.
element_type | Handle to a nullable type object. E.g., from Dart_GetType or Dart_GetNullableType. |
length | The length of the list. |
DART_EXPORT Dart_Handle Dart_NewListOfTypeFilled | ( | Dart_Handle | element_type, |
Dart_Handle | fill_object, | ||
intptr_t | length | ||
) |
Returns a List of the desired length with the desired element type, filled with the provided object.
element_type | Handle to a type object. E.g., from Dart_GetType. |
fill_object | Handle to an object of type 'element_type' that will be used to populate the list. This parameter can only be Dart_Null() if the length of the list is 0 or 'element_type' is a nullable type. |
length | The length of the list. |
DART_EXPORT Dart_PersistentHandle Dart_NewPersistentHandle | ( | Dart_Handle | object | ) |
Allocates a persistent handle for an object.
This handle has the lifetime of the current isolate unless it is explicitly deallocated by calling Dart_DeletePersistentHandle.
Requires there to be a current isolate.
DART_EXPORT Dart_Handle Dart_NewSendPort | ( | Dart_Port | port_id | ) |
Returns a new SendPort with the provided port id.
If there is a possibility of a port closing since port_id was acquired for a SendPort, one should use Dart_NewSendPortEx and Dart_SendPortGetIdEx.
port_id | The destination port. |
DART_EXPORT Dart_Handle Dart_NewSendPortEx | ( | Dart_PortEx | portex_id | ) |
Returns a new SendPort with the provided port id and origin id.
portex_id | The destination composte port id. |
DART_EXPORT Dart_Handle Dart_NewStringFromCString | ( | const char * | str | ) |
DART_EXPORT Dart_Handle Dart_NewStringFromUTF16 | ( | const uint16_t * | utf16_array, |
intptr_t | length | ||
) |
Returns a String built from an array of UTF-16 encoded characters.
utf16_array | An array of UTF-16 encoded characters. |
length | The length of the codepoints array. |
DART_EXPORT Dart_Handle Dart_NewStringFromUTF32 | ( | const int32_t * | utf32_array, |
intptr_t | length | ||
) |
Returns a String built from an array of UTF-32 encoded characters.
utf32_array | An array of UTF-32 encoded characters. |
length | The length of the codepoints array. |
DART_EXPORT Dart_Handle Dart_NewStringFromUTF8 | ( | const uint8_t * | utf8_array, |
intptr_t | length | ||
) |
Returns a String built from an array of UTF-8 encoded characters.
utf8_array | An array of UTF-8 encoded characters. |
length | The length of the codepoints array. |
DART_EXPORT Dart_Handle Dart_NewTypedData | ( | Dart_TypedData_Type | type, |
intptr_t | length | ||
) |
Returns a TypedData object of the desired length and type.
type | The type of the TypedData object. |
length | The length of the TypedData object (length in type units). |
DART_EXPORT Dart_Handle Dart_NewUnhandledExceptionError | ( | Dart_Handle | exception | ) |
Produces a new unhandled exception error handle.
Requires there to be a current isolate.
exception | An instance of a Dart object to be thrown or an ApiError or CompilationError handle. When an ApiError or CompilationError handle is passed in a string object of the error message is created and it becomes the Dart object to be thrown. |
DART_EXPORT Dart_Handle Dart_NewUnmodifiableExternalTypedDataWithFinalizer | ( | Dart_TypedData_Type | type, |
const void * | data, | ||
intptr_t | length, | ||
void * | peer, | ||
intptr_t | external_allocation_size, | ||
Dart_HandleFinalizer | callback | ||
) |
DART_EXPORT Dart_WeakPersistentHandle Dart_NewWeakPersistentHandle | ( | Dart_Handle | object, |
void * | peer, | ||
intptr_t | external_allocation_size, | ||
Dart_HandleFinalizer | callback | ||
) |
Allocates a weak persistent handle for an object.
This handle has the lifetime of the current isolate. The handle can also be explicitly deallocated by calling Dart_DeleteWeakPersistentHandle.
If the object becomes unreachable the callback is invoked with the peer as argument. The callback can be executed on any thread, will have a current isolate group, but will not have a current isolate. The callback can only call Dart_DeletePersistentHandle or Dart_DeleteWeakPersistentHandle. This gives the embedder the ability to cleanup data associated with the object. The handle will point to the Dart_Null object after the finalizer has been run. It is illegal to call into the VM with any other Dart_* functions from the callback. If the handle is deleted before the object becomes unreachable, the callback is never invoked.
Requires there to be a current isolate.
object | An object with identity. |
peer | A pointer to a native object or NULL. This value is provided to callback when it is invoked. |
external_allocation_size | The number of externally allocated bytes for peer. Used to inform the garbage collector. |
callback | A function pointer that will be invoked sometime after the object is garbage collected, unless the handle has been deleted. A valid callback needs to be specified it cannot be NULL. |
DART_EXPORT void Dart_NotifyDestroyed | ( | void | ) |
Notifies the VM that the embedder expects the application's working set has recently shrunk significantly and is not expected to rise in the near future. The VM may spend O(heap-size) time performing clean up work.
Requires there to be a current isolate.
DART_EXPORT void Dart_NotifyIdle | ( | int64_t | deadline | ) |
Notifies the VM that the embedder expects to be idle until |deadline|. The VM may use this time to perform garbage collection or other tasks to avoid delays during execution of Dart code in the future.
|deadline| is measured in microseconds against the system's monotonic time. This clock can be accessed via Dart_TimelineGetMicros().
Requires there to be a current isolate.
DART_EXPORT void Dart_NotifyLowMemory | ( | void | ) |
Notifies the VM that the system is running low on memory.
Does not require a current isolate. Only valid after calling Dart_Initialize.
DART_EXPORT Dart_Handle Dart_Null | ( | void | ) |
Returns the null object.
DART_EXPORT Dart_Handle Dart_ObjectEquals | ( | Dart_Handle | obj1, |
Dart_Handle | obj2, | ||
bool * | equal | ||
) |
Checks if the two objects are equal.
The result of the comparison is returned through the 'equal' parameter. The return value itself is used to indicate success or failure, not equality.
May generate an unhandled exception error.
obj1 | An object to be compared. |
obj2 | An object to be compared. |
equal | Returns the result of the equality comparison. |
DART_EXPORT Dart_Handle Dart_ObjectIsType | ( | Dart_Handle | object, |
Dart_Handle | type, | ||
bool * | instanceof | ||
) |
Is this object an instance of some type?
The result of the test is returned through the 'instanceof' parameter. The return value itself is used to indicate success or failure.
object | An object. |
type | A type. |
instanceof | Return true if 'object' is an instance of type 'type'. |
DART_EXPORT bool Dart_Post | ( | Dart_Port | port_id, |
Dart_Handle | object | ||
) |
Posts a message for some isolate. The message is a serialized object.
Requires there to be a current isolate.
For posting messages outside of an isolate see Dart_PostCObject.
port_id | The destination port. |
object | An object from the current isolate. |
DART_EXPORT Dart_Handle Dart_Precompile | ( | void | ) |
Compiles all functions reachable from entry points and marks the isolate to disallow future compilation.
Entry points should be specified using @pragma("vm:entry-point")
annotation.
DART_EXPORT void Dart_PrepareToAbort | ( | void | ) |
Indicate that the process is about to abort, and the Dart VM should not attempt to cleanup resources.
DART_EXPORT void Dart_PropagateError | ( | Dart_Handle | handle | ) |
Propagates an error.
If the provided handle is an unhandled exception error, this function will cause the unhandled exception to be rethrown. This will proceed in the standard way, walking up Dart frames until an appropriate 'catch' block is found, executing 'finally' blocks, etc.
If the error is not an unhandled exception error, we will unwind the stack to the next C frame. Intervening Dart frames will be discarded; specifically, 'finally' blocks will not execute. This is the standard way that compilation errors (and the like) are handled by the Dart runtime.
In either case, when an error is propagated any current scopes created by Dart_EnterScope will be exited.
See the additional discussion under "Propagating Errors" at the beginning of this file.
handle | An error handle (See Dart_IsError) |
On success, this function does not return. On failure, the process is terminated.
DART_EXPORT void Dart_RegisterHeapSamplingCallback | ( | Dart_HeapSamplingCreateCallback | create_callback, |
Dart_HeapSamplingDeleteCallback | delete_callback | ||
) |
DART_EXPORT void Dart_ReportSurvivingAllocations | ( | Dart_HeapSamplingReportCallback | callback, |
void * | context, | ||
bool | force_gc | ||
) |
DART_EXPORT Dart_Handle Dart_ReThrowException | ( | Dart_Handle | exception, |
Dart_Handle | stacktrace | ||
) |
Rethrows an exception.
Rethrows an exception, unwinding all dart frames on the stack. If successful, this function does not return. Note that this means that the destructors of any stack-allocated C++ objects will not be called. If there are no Dart frames on the stack, an error occurs.
DART_EXPORT Dart_Handle Dart_RootLibrary | ( | void | ) |
Gets the library for the root script for the current isolate.
If the root script has not yet been set for the current isolate, this function returns Dart_Null(). This function never returns an error handle.
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_RunLoop | ( | void | ) |
Processes any incoming messages for the current isolate.
This function may only be used when the embedder has not provided an alternate message delivery mechanism with Dart_SetMessageCallbacks. It is provided for convenience.
This function waits for incoming messages for the current isolate. As new messages arrive, they are handled using Dart_HandleMessage. The routine exits when all ports to the current isolate are closed.
DART_EXPORT DART_WARN_UNUSED_RESULT bool Dart_RunLoopAsync | ( | bool | errors_are_fatal, |
Dart_Port | on_error_port, | ||
Dart_Port | on_exit_port, | ||
char ** | error | ||
) |
Lets the VM run message processing for the isolate.
This function expects there to a current isolate and the current isolate must not have an active api scope. The VM will take care of making the isolate runnable (if not already), handles its message loop and will take care of shutting the isolate down once it's done.
errors_are_fatal | Whether uncaught errors should be fatal. |
on_error_port | A port to notify on uncaught errors (or ILLEGAL_PORT). |
on_exit_port | A port to notify on exit (or ILLEGAL_PORT). |
error | A non-NULL pointer which will hold an error message if the call fails. The error has to be free()ed by the caller. |
DART_EXPORT uint8_t * Dart_ScopeAllocate | ( | intptr_t | size | ) |
The Dart VM uses "zone allocation" for temporary structures. Zones support very fast allocation of small chunks of memory. The chunks cannot be deallocated individually, but instead zones support deallocating all chunks in one fast operation.
This function makes it possible for the embedder to allocate temporary data in the VMs zone allocator.
Zone allocation is possible:
All the memory allocated this way will be reclaimed either on the next call to Dart_ExitScope or when the native port handler exits.
size | Size of the memory to allocate. |
DART_EXPORT Dart_Handle Dart_SendPortGetId | ( | Dart_Handle | port, |
Dart_Port * | port_id | ||
) |
Gets the SendPort id for the provided SendPort.
port | A SendPort object whose id is desired. |
port_id | Returns the id of the SendPort. |
DART_EXPORT Dart_Handle Dart_SendPortGetIdEx | ( | Dart_Handle | port, |
Dart_PortEx * | portex_id | ||
) |
Gets the SendPort and Origin ids for the provided SendPort.
port | A SendPort object whose id is desired. |
portex_id | Returns composite id of the SendPort. |
DART_EXPORT void Dart_SetBooleanReturnValue | ( | Dart_NativeArguments | args, |
bool | retval | ||
) |
DART_EXPORT void Dart_SetDartLibrarySourcesKernel | ( | const uint8_t * | platform_kernel, |
const intptr_t | platform_kernel_size | ||
) |
Sets the kernel buffer which will be used to load Dart SDK sources dynamically at runtime.
platform_kernel | A buffer containing kernel which has sources for the Dart SDK populated. Note: The VM does not take ownership of this memory. |
platform_kernel_size | The length of the platform_kernel buffer. |
DART_EXPORT Dart_Handle Dart_SetDeferredLoadHandler | ( | Dart_DeferredLoadHandler | handler | ) |
Sets the deferred load handler for the current isolate. This handler is used to handle loading deferred imports in an AppJIT or AppAOT program.
DART_EXPORT void Dart_SetDoubleReturnValue | ( | Dart_NativeArguments | args, |
double | retval | ||
) |
DART_EXPORT void Dart_SetDwarfStackTraceFootnoteCallback | ( | Dart_DwarfStackTraceFootnoteCallback | callback | ) |
Configure DWARF stack trace footnote callback.
DART_EXPORT Dart_Handle Dart_SetEnvironmentCallback | ( | Dart_EnvironmentCallback | callback | ) |
Sets the environment callback for the current isolate. This callback is used to lookup environment values by name in the current environment. This enables the embedder to supply values for the const constructors bool.fromEnvironment, int.fromEnvironment and String.fromEnvironment.
DART_EXPORT Dart_Handle Dart_SetFfiNativeResolver | ( | Dart_Handle | library, |
Dart_FfiNativeResolver | resolver | ||
) |
Sets the callback used to resolve FFI native functions for a library. The resolved functions are expected to be a C function pointer of the correct signature (as specified in the @Native<NFT>()
function annotation in Dart code).
NOTE: This is an experimental feature and might change in the future.
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_SetField | ( | Dart_Handle | container, |
Dart_Handle | name, | ||
Dart_Handle | value | ||
) |
Sets the value of a field.
The 'container' parameter may actually be an object, type, or library. If 'container' is an object, then this function will access an instance field. If 'container' is a type, then this function will access a static field. If 'container' is a library, then this function will access a top-level variable. NOTE: This API call cannot be used to access fields of a type object.
This function ignores field visibility (leading underscores in names).
May generate an unhandled exception error.
container | An object, type, or library. |
name | A field name. |
value | The new field value. |
DART_EXPORT void Dart_SetHeapSamplingPeriod | ( | intptr_t | bytes | ) |
DART_EXPORT void Dart_SetIntegerReturnValue | ( | Dart_NativeArguments | args, |
int64_t | retval | ||
) |
DART_EXPORT Dart_Handle Dart_SetLibraryTagHandler | ( | Dart_LibraryTagHandler | handler | ) |
Sets library tag handler for the current isolate. This handler is used to handle the various tags encountered while loading libraries or scripts in the isolate.
handler | Handler code to be used for handling the various tags encountered while loading libraries or scripts in the isolate. |
TODO(turnidge): Document.
DART_EXPORT void Dart_SetMessageNotifyCallback | ( | Dart_MessageNotifyCallback | message_notify_callback | ) |
Allows embedders to provide a custom wakeup mechanism for the delivery of inter-isolate messages. This setting only applies to the current isolate.
This mechanism is optional: if not provided, the isolate will be scheduled on a VM-managed thread pool. An embedder should provide this callback if it wants to run an isolate on a specific thread or to interleave handling of inter-isolate messages with other event sources.
Most embedders will only call this function once, before isolate execution begins. If this function is called after isolate execution begins, the embedder is responsible for threading issues.
DART_EXPORT Dart_Handle Dart_SetNativeInstanceField | ( | Dart_Handle | obj, |
int | index, | ||
intptr_t | value | ||
) |
Sets the value of a native field.
TODO(turnidge): Document.
DART_EXPORT Dart_Handle Dart_SetNativeResolver | ( | Dart_Handle | library, |
Dart_NativeEntryResolver | resolver, | ||
Dart_NativeEntrySymbol | symbol | ||
) |
DART_EXPORT void Dart_SetPausedOnExit | ( | bool | paused | ) |
Called when the embedder has paused the current isolate on exit and when the embedder has resumed the isolate.
paused | Is the isolate paused on exit? |
DART_EXPORT void Dart_SetPausedOnStart | ( | bool | paused | ) |
Called when the embedder has paused the current isolate on start and when the embedder has resumed the isolate.
paused | Is the isolate paused on start? |
DART_EXPORT Dart_Handle Dart_SetPeer | ( | Dart_Handle | object, |
void * | peer | ||
) |
Sets the value of the peer field of 'object' to the value of 'peer'.
object | An object. |
peer | A value to store in the peer field. |
DART_EXPORT Dart_PerformanceMode Dart_SetPerformanceMode | ( | Dart_PerformanceMode | mode | ) |
Set the desired performance trade-off.
Requires a current isolate.
Returns the previous performance mode.
DART_EXPORT void Dart_SetPersistentHandle | ( | Dart_PersistentHandle | obj1, |
Dart_Handle | obj2 | ||
) |
Assign value of local handle to a persistent handle.
Requires there to be a current isolate.
obj1 | A persistent handle whose value needs to be set. |
obj2 | An object whose value needs to be set to the persistent handle. |
DART_EXPORT void Dart_SetReturnValue | ( | Dart_NativeArguments | args, |
Dart_Handle | retval | ||
) |
Sets the return value for a native function.
If retval is an Error handle, then error will be propagated once the native functions exits. See Dart_PropagateError for a discussion of how different types of errors are propagated.
DART_EXPORT Dart_Handle Dart_SetRootLibrary | ( | Dart_Handle | library | ) |
Sets the root library for the current isolate.
library
is not a library handle. DART_EXPORT void Dart_SetShouldPauseOnExit | ( | bool | should_pause | ) |
Override the VM flag --pause-isolates-on-exit
for the current isolate.
should_pause | Should the isolate be paused on exit? |
DART_EXPORT void Dart_SetShouldPauseOnStart | ( | bool | should_pause | ) |
Override the VM flag --pause-isolates-on-start
for the current isolate.
should_pause | Should the isolate be paused on start? |
NOTE: This must be called before Dart_IsolateMakeRunnable.
DART_EXPORT void Dart_SetStickyError | ( | Dart_Handle | error | ) |
Called when the embedder has caught a top level unhandled exception error in the current isolate.
NOTE: It is illegal to call this twice on the same isolate without first clearing the sticky error to null.
error | The unhandled exception error. |
DART_EXPORT DART_WARN_UNUSED_RESULT char * Dart_SetVMFlags | ( | int | argc, |
const char ** | argv | ||
) |
Sets command line flags. Should be called before Dart_Initialize.
argc | The length of the arguments array. |
argv | An array of arguments. |
NOTE: This call does not store references to the passed in c-strings.
DART_EXPORT void Dart_SetWeakHandleReturnValue | ( | Dart_NativeArguments | args, |
Dart_WeakPersistentHandle | rval | ||
) |
DART_EXPORT bool Dart_ShouldPauseOnExit | ( | void | ) |
If the VM flag --pause-isolates-on-exit
was passed this will be true.
DART_EXPORT bool Dart_ShouldPauseOnStart | ( | void | ) |
The VM's default message handler supports pausing an isolate before it processes the first message and right after the it processes the isolate's final message. This can be controlled for all isolates by two VM flags:
--pause-isolates-on-start
--pause-isolates-on-exit
Additionally, Dart_SetShouldPauseOnStart and Dart_SetShouldPauseOnExit can be used to control this behaviour on a per-isolate basis.
When an embedder is using a Dart_MessageNotifyCallback the embedder needs to cooperate with the VM so that the service protocol can report accurate information about isolates and so that tools such as debuggers work reliably.
The following functions can be used to implement pausing on start and exit. If the VM flag --pause-isolates-on-start
was passed this will be true.
DART_EXPORT void Dart_ShutdownIsolate | ( | void | ) |
Shuts down the current isolate. After this call, the current isolate is NULL. Any current scopes created by Dart_EnterScope will be exited. Invokes the shutdown callback and any callbacks of remaining weak persistent handles.
Requires there to be a current isolate.
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_SortClasses | ( | void | ) |
Sorts the class-ids in depth first traversal order of the inheritance tree. This is a costly operation, but it can make method dispatch more efficient and is done before writing snapshots.
DART_EXPORT void Dart_StartProfiling | ( | void | ) |
Starts the CPU sampling profiler.
DART_EXPORT void Dart_StopProfiling | ( | void | ) |
Stops the CPU sampling profiler.
Note that some profile samples might still be taken after this function returns due to the asynchronous nature of the implementation on some platforms.
DART_EXPORT Dart_Handle Dart_StringGetProperties | ( | Dart_Handle | str, |
intptr_t * | char_size, | ||
intptr_t * | str_len, | ||
void ** | peer | ||
) |
Retrieves some properties associated with a String. Properties retrieved are:
str | A String. |
char_size | Returns the character size of the String. |
str_len | Returns the length of the String. |
peer | Returns the peer pointer associated with the String or 0 if there is no peer pointer for it. |
DART_EXPORT Dart_Handle Dart_StringLength | ( | Dart_Handle | str, |
intptr_t * | length | ||
) |
DART_EXPORT Dart_Handle Dart_StringStorageSize | ( | Dart_Handle | str, |
intptr_t * | size | ||
) |
DART_EXPORT Dart_Handle Dart_StringToCString | ( | Dart_Handle | str, |
const char ** | cstr | ||
) |
Gets the C string representation of a String. (It is a sequence of UTF-8 encoded values with a '\0' termination.)
str | A string. |
cstr | Returns the String represented as a C string. This C string is scope allocated and is only valid until the next call to Dart_ExitScope. |
DART_EXPORT Dart_Handle Dart_StringToLatin1 | ( | Dart_Handle | str, |
uint8_t * | latin1_array, | ||
intptr_t * | length | ||
) |
Gets the data corresponding to the string object. This function returns the data only for Latin-1 (ISO-8859-1) string objects. For all other string objects it returns an error.
str | A string. |
latin1_array | An array allocated by the caller, used to return the string data. |
length | Used to pass in the length of the provided array. Used to return the length of the array which was actually used. |
DART_EXPORT Dart_Handle Dart_StringToUTF16 | ( | Dart_Handle | str, |
uint16_t * | utf16_array, | ||
intptr_t * | length | ||
) |
Gets the UTF-16 encoded representation of a string.
str | A string. |
utf16_array | An array allocated by the caller, used to return the array of UTF-16 encoded characters. |
length | Used to pass in the length of the provided array. Used to return the length of the array which was actually used. |
DART_EXPORT Dart_Handle Dart_StringToUTF8 | ( | Dart_Handle | str, |
uint8_t ** | utf8_array, | ||
intptr_t * | length | ||
) |
Gets a UTF-8 encoded representation of a String.
Any unpaired surrogate code points in the string will be converted as replacement characters (U+FFFD, 0xEF 0xBF 0xBD in UTF-8). If you need to preserve unpaired surrogates, use the Dart_StringToUTF16 function.
str | A string. |
utf8_array | Returns the String represented as UTF-8 code units. This UTF-8 array is scope allocated and is only valid until the next call to Dart_ExitScope. |
length | Used to return the length of the array which was actually used. |
DART_EXPORT Dart_Handle Dart_StringUTF8Length | ( | Dart_Handle | str, |
intptr_t * | length | ||
) |
DART_EXPORT void Dart_ThreadDisableProfiling | ( | void | ) |
Notifies the VM that the current thread should not be profiled until a matching call to Dart_ThreadEnableProfiling is made.
NOTE: By default, if a thread has entered an isolate it will be profiled. This function should be used when an embedder knows a thread is about to make a blocking call and wants to avoid unnecessary interrupts by the profiler.
DART_EXPORT void Dart_ThreadEnableProfiling | ( | void | ) |
Notifies the VM that the current thread should be profiled.
NOTE: It is only legal to call this function after calling Dart_ThreadDisableProfiling.
NOTE: By default, if a thread has entered an isolate it will be profiled.
DART_EXPORT Dart_Handle Dart_ThrowException | ( | Dart_Handle | exception | ) |
Throws an exception.
This function causes a Dart language exception to be thrown. This will proceed in the standard way, walking up Dart frames until an appropriate 'catch' block is found, executing 'finally' blocks, etc.
If an error handle is passed into this function, the error is propagated immediately. See Dart_PropagateError for a discussion of error propagation.
If successful, this function does not return. Note that this means that the destructors of any stack-allocated C++ objects will not be called. If there are no Dart frames on the stack, an error occurs.
DART_EXPORT Dart_Handle Dart_ToString | ( | Dart_Handle | object | ) |
Converts an object to a string.
May generate an unhandled exception error.
DART_EXPORT Dart_Handle Dart_True | ( | void | ) |
Returns the True object.
Requires there to be a current isolate.
DART_EXPORT Dart_Handle Dart_TypedDataAcquireData | ( | Dart_Handle | object, |
Dart_TypedData_Type * | type, | ||
void ** | data, | ||
intptr_t * | len | ||
) |
Acquires access to the internal data address of a TypedData object.
object | The typed data object whose internal data address is to be accessed. |
type | The type of the object is returned here. |
data | The internal data address is returned here. |
len | Size of the typed array is returned here. |
Notes: When the internal address of the object is acquired any calls to a Dart API function that could potentially allocate an object or run any Dart code will return an error.
Any Dart API functions for accessing the data should not be called before the corresponding release. In particular, the object should not be acquired again before its release. This leads to undefined behavior.
DART_EXPORT Dart_Handle Dart_TypedDataReleaseData | ( | Dart_Handle | object | ) |
Releases access to the internal data address that was acquired earlier using Dart_TypedDataAcquireData.
object | The typed data object whose internal data address is to be released. |
DART_EXPORT Dart_Handle Dart_TypeDynamic | ( | void | ) |
Returns types that are not classes, and which therefore cannot be looked up as library members by Dart_GetType.
DART_EXPORT Dart_Handle Dart_TypeNever | ( | void | ) |
DART_EXPORT Dart_Handle Dart_TypeToNonNullableType | ( | Dart_Handle | type | ) |
Creates a non-nullable version of the provided type.
type | The type to be converted to a non-nullable type. |
DART_EXPORT Dart_Handle Dart_TypeToNullableType | ( | Dart_Handle | type | ) |
Creates a nullable version of the provided type.
type | The type to be converted to a nullable type. |
DART_EXPORT Dart_Handle Dart_TypeVoid | ( | void | ) |
DART_EXPORT const char * Dart_VersionString | ( | void | ) |
Gets the version string for the Dart VM.
The version of the Dart VM can be accessed without initializing the VM.
DART_EXPORT bool Dart_WriteProfileToTimeline | ( | Dart_Port | main_port, |
char ** | error | ||
) |
Writes the CPU profile to the timeline as a series of 'instant' events.
Note that this is an expensive operation.
main_port | The main port of the Isolate whose profile samples to write. |
error | An optional error, must be free()ed by caller. |