Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
dart_api.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
3 * for details. All rights reserved. Use of this source code is governed by a
4 * BSD-style license that can be found in the LICENSE file.
5 */
6
7#ifndef RUNTIME_INCLUDE_DART_API_H_
8#define RUNTIME_INCLUDE_DART_API_H_
9
10/** \mainpage Dart Embedding API Reference
11 *
12 * This reference describes the Dart Embedding API, which is used to embed the
13 * Dart Virtual Machine within C/C++ applications.
14 *
15 * This reference is generated from the header include/dart_api.h.
16 */
17
18/* __STDC_FORMAT_MACROS has to be defined before including <inttypes.h> to
19 * enable platform independent printf format specifiers. */
20#ifndef __STDC_FORMAT_MACROS
21#define __STDC_FORMAT_MACROS
22#endif
23
24#include <assert.h>
25#include <inttypes.h>
26#include <stdbool.h>
27
28#if defined(__Fuchsia__)
29#include <zircon/types.h>
30#endif
31
32#ifdef __cplusplus
33#define DART_EXTERN_C extern "C"
34#else
35#define DART_EXTERN_C extern
36#endif
37
38#if defined(__CYGWIN__)
39#error Tool chain and platform not supported.
40#elif defined(_WIN32)
41#if defined(DART_SHARED_LIB)
42#define DART_EXPORT DART_EXTERN_C __declspec(dllexport)
43#else
44#define DART_EXPORT DART_EXTERN_C
45#endif
46#else
47#if __GNUC__ >= 4
48#if defined(DART_SHARED_LIB)
49#define DART_EXPORT \
50 DART_EXTERN_C __attribute__((visibility("default"))) __attribute((used))
51#else
52#define DART_EXPORT DART_EXTERN_C
53#endif
54#else
55#error Tool chain not supported.
56#endif
57#endif
58
59#if __GNUC__
60#define DART_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
61#define DART_DEPRECATED(msg) __attribute__((deprecated(msg)))
62#elif _MSC_VER
63#define DART_WARN_UNUSED_RESULT _Check_return_
64#define DART_DEPRECATED(msg) __declspec(deprecated(msg))
65#else
66#define DART_WARN_UNUSED_RESULT
67#define DART_DEPRECATED(msg)
68#endif
69
70/*
71 * =======
72 * Handles
73 * =======
74 */
75
76/**
77 * An isolate is the unit of concurrency in Dart. Each isolate has
78 * its own memory and thread of control. No state is shared between
79 * isolates. Instead, isolates communicate by message passing.
80 *
81 * Each thread keeps track of its current isolate, which is the
82 * isolate which is ready to execute on the current thread. The
83 * current isolate may be NULL, in which case no isolate is ready to
84 * execute. Most of the Dart apis require there to be a current
85 * isolate in order to function without error. The current isolate is
86 * set by any call to Dart_CreateIsolateGroup or Dart_EnterIsolate.
87 */
88typedef struct _Dart_Isolate* Dart_Isolate;
89typedef struct _Dart_IsolateGroup* Dart_IsolateGroup;
90
91/**
92 * An object reference managed by the Dart VM garbage collector.
93 *
94 * Because the garbage collector may move objects, it is unsafe to
95 * refer to objects directly. Instead, we refer to objects through
96 * handles, which are known to the garbage collector and updated
97 * automatically when the object is moved. Handles should be passed
98 * by value (except in cases like out-parameters) and should never be
99 * allocated on the heap.
100 *
101 * Most functions in the Dart Embedding API return a handle. When a
102 * function completes normally, this will be a valid handle to an
103 * object in the Dart VM heap. This handle may represent the result of
104 * the operation or it may be a special valid handle used merely to
105 * indicate successful completion. Note that a valid handle may in
106 * some cases refer to the null object.
107 *
108 * --- Error handles ---
109 *
110 * When a function encounters a problem that prevents it from
111 * completing normally, it returns an error handle (See Dart_IsError).
112 * An error handle has an associated error message that gives more
113 * details about the problem (See Dart_GetError).
114 *
115 * There are four kinds of error handles that can be produced,
116 * depending on what goes wrong:
117 *
118 * - Api error handles are produced when an api function is misused.
119 * This happens when a Dart embedding api function is called with
120 * invalid arguments or in an invalid context.
121 *
122 * - Unhandled exception error handles are produced when, during the
123 * execution of Dart code, an exception is thrown but not caught.
124 * Prototypically this would occur during a call to Dart_Invoke, but
125 * it can occur in any function which triggers the execution of Dart
126 * code (for example, Dart_ToString).
127 *
128 * An unhandled exception error provides access to an exception and
129 * stacktrace via the functions Dart_ErrorGetException and
130 * Dart_ErrorGetStackTrace.
131 *
132 * - Compilation error handles are produced when, during the execution
133 * of Dart code, a compile-time error occurs. As above, this can
134 * occur in any function which triggers the execution of Dart code.
135 *
136 * - Fatal error handles are produced when the system wants to shut
137 * down the current isolate.
138 *
139 * --- Propagating errors ---
140 *
141 * When an error handle is returned from the top level invocation of
142 * Dart code in a program, the embedder must handle the error as they
143 * see fit. Often, the embedder will print the error message produced
144 * by Dart_Error and exit the program.
145 *
146 * When an error is returned while in the body of a native function,
147 * it can be propagated up the call stack by calling
148 * Dart_PropagateError, Dart_SetReturnValue, or Dart_ThrowException.
149 * Errors should be propagated unless there is a specific reason not
150 * to. If an error is not propagated then it is ignored. For
151 * example, if an unhandled exception error is ignored, that
152 * effectively "catches" the unhandled exception. Fatal errors must
153 * always be propagated.
154 *
155 * When an error is propagated, any current scopes created by
156 * Dart_EnterScope will be exited.
157 *
158 * Using Dart_SetReturnValue to propagate an exception is somewhat
159 * more convenient than using Dart_PropagateError, and should be
160 * preferred for reasons discussed below.
161 *
162 * Dart_PropagateError and Dart_ThrowException do not return. Instead
163 * they transfer control non-locally using a setjmp-like mechanism.
164 * This can be inconvenient if you have resources that you need to
165 * clean up before propagating the error.
166 *
167 * When relying on Dart_PropagateError, we often return error handles
168 * rather than propagating them from helper functions. Consider the
169 * following contrived example:
170 *
171 * 1 Dart_Handle isLongStringHelper(Dart_Handle arg) {
172 * 2 intptr_t* length = 0;
173 * 3 result = Dart_StringLength(arg, &length);
174 * 4 if (Dart_IsError(result)) {
175 * 5 return result;
176 * 6 }
177 * 7 return Dart_NewBoolean(length > 100);
178 * 8 }
179 * 9
180 * 10 void NativeFunction_isLongString(Dart_NativeArguments args) {
181 * 11 Dart_EnterScope();
182 * 12 AllocateMyResource();
183 * 13 Dart_Handle arg = Dart_GetNativeArgument(args, 0);
184 * 14 Dart_Handle result = isLongStringHelper(arg);
185 * 15 if (Dart_IsError(result)) {
186 * 16 FreeMyResource();
187 * 17 Dart_PropagateError(result);
188 * 18 abort(); // will not reach here
189 * 19 }
190 * 20 Dart_SetReturnValue(result);
191 * 21 FreeMyResource();
192 * 22 Dart_ExitScope();
193 * 23 }
194 *
195 * In this example, we have a native function which calls a helper
196 * function to do its work. On line 5, the helper function could call
197 * Dart_PropagateError, but that would not give the native function a
198 * chance to call FreeMyResource(), causing a leak. Instead, the
199 * helper function returns the error handle to the caller, giving the
200 * caller a chance to clean up before propagating the error handle.
201 *
202 * When an error is propagated by calling Dart_SetReturnValue, the
203 * native function will be allowed to complete normally and then the
204 * exception will be propagated only once the native call
205 * returns. This can be convenient, as it allows the C code to clean
206 * up normally.
207 *
208 * The example can be written more simply using Dart_SetReturnValue to
209 * propagate the error.
210 *
211 * 1 Dart_Handle isLongStringHelper(Dart_Handle arg) {
212 * 2 intptr_t* length = 0;
213 * 3 result = Dart_StringLength(arg, &length);
214 * 4 if (Dart_IsError(result)) {
215 * 5 return result
216 * 6 }
217 * 7 return Dart_NewBoolean(length > 100);
218 * 8 }
219 * 9
220 * 10 void NativeFunction_isLongString(Dart_NativeArguments args) {
221 * 11 Dart_EnterScope();
222 * 12 AllocateMyResource();
223 * 13 Dart_Handle arg = Dart_GetNativeArgument(args, 0);
224 * 14 Dart_SetReturnValue(isLongStringHelper(arg));
225 * 15 FreeMyResource();
226 * 16 Dart_ExitScope();
227 * 17 }
228 *
229 * In this example, the call to Dart_SetReturnValue on line 14 will
230 * either return the normal return value or the error (potentially
231 * generated on line 3). The call to FreeMyResource on line 15 will
232 * execute in either case.
233 *
234 * --- Local and persistent handles ---
235 *
236 * Local handles are allocated within the current scope (see
237 * Dart_EnterScope) and go away when the current scope exits. Unless
238 * otherwise indicated, callers should assume that all functions in
239 * the Dart embedding api return local handles.
240 *
241 * Persistent handles are allocated within the current isolate. They
242 * can be used to store objects across scopes. Persistent handles have
243 * the lifetime of the current isolate unless they are explicitly
244 * deallocated (see Dart_DeletePersistentHandle).
245 * The type Dart_Handle represents a handle (both local and persistent).
246 * The type Dart_PersistentHandle is a Dart_Handle and it is used to
247 * document that a persistent handle is expected as a parameter to a call
248 * or the return value from a call is a persistent handle.
249 *
250 * FinalizableHandles are persistent handles which are auto deleted when
251 * the object is garbage collected. It is never safe to use these handles
252 * unless you know the object is still reachable.
253 *
254 * WeakPersistentHandles are persistent handles which are automatically set
255 * to point Dart_Null when the object is garbage collected. They are not auto
256 * deleted, so it is safe to use them after the object has become unreachable.
257 */
258typedef struct _Dart_Handle* Dart_Handle;
260typedef struct _Dart_WeakPersistentHandle* Dart_WeakPersistentHandle;
261typedef struct _Dart_FinalizableHandle* Dart_FinalizableHandle;
262// These structs are versioned by DART_API_DL_MAJOR_VERSION, bump the
263// version when changing this struct.
264
265typedef void (*Dart_HandleFinalizer)(void* isolate_callback_data, void* peer);
266
267/**
268 * Is this an error handle?
269 *
270 * Requires there to be a current isolate.
271 */
273
274/**
275 * Is this an api error handle?
276 *
277 * Api error handles are produced when an api function is misused.
278 * This happens when a Dart embedding api function is called with
279 * invalid arguments or in an invalid context.
280 *
281 * Requires there to be a current isolate.
282 */
284
285/**
286 * Is this an unhandled exception error handle?
287 *
288 * Unhandled exception error handles are produced when, during the
289 * execution of Dart code, an exception is thrown but not caught.
290 * This can occur in any function which triggers the execution of Dart
291 * code.
292 *
293 * See Dart_ErrorGetException and Dart_ErrorGetStackTrace.
294 *
295 * Requires there to be a current isolate.
296 */
298
299/**
300 * Is this a compilation error handle?
301 *
302 * Compilation error handles are produced when, during the execution
303 * of Dart code, a compile-time error occurs. This can occur in any
304 * function which triggers the execution of Dart code.
305 *
306 * Requires there to be a current isolate.
307 */
309
310/**
311 * Is this a fatal error handle?
312 *
313 * Fatal error handles are produced when the system wants to shut down
314 * the current isolate.
315 *
316 * Requires there to be a current isolate.
317 */
319
320/**
321 * Gets the error message from an error handle.
322 *
323 * Requires there to be a current isolate.
324 *
325 * \return A C string containing an error message if the handle is
326 * error. An empty C string ("") if the handle is valid. This C
327 * String is scope allocated and is only valid until the next call
328 * to Dart_ExitScope.
329*/
331
332/**
333 * Is this an error handle for an unhandled exception?
334 */
336
337/**
338 * Gets the exception Object from an unhandled exception error handle.
339 */
341
342/**
343 * Gets the stack trace Object from an unhandled exception error handle.
344 */
346
347/**
348 * Produces an api error handle with the provided error message.
349 *
350 * Requires there to be a current isolate.
351 *
352 * \param error the error message.
353 */
356
357/**
358 * Produces a new unhandled exception error handle.
359 *
360 * Requires there to be a current isolate.
361 *
362 * \param exception An instance of a Dart object to be thrown or
363 * an ApiError or CompilationError handle.
364 * When an ApiError or CompilationError handle is passed in
365 * a string object of the error message is created and it becomes
366 * the Dart object to be thrown.
367 */
369
370/**
371 * Propagates an error.
372 *
373 * If the provided handle is an unhandled exception error, this
374 * function will cause the unhandled exception to be rethrown. This
375 * will proceed in the standard way, walking up Dart frames until an
376 * appropriate 'catch' block is found, executing 'finally' blocks,
377 * etc.
378 *
379 * If the error is not an unhandled exception error, we will unwind
380 * the stack to the next C frame. Intervening Dart frames will be
381 * discarded; specifically, 'finally' blocks will not execute. This
382 * is the standard way that compilation errors (and the like) are
383 * handled by the Dart runtime.
384 *
385 * In either case, when an error is propagated any current scopes
386 * created by Dart_EnterScope will be exited.
387 *
388 * See the additional discussion under "Propagating Errors" at the
389 * beginning of this file.
390 *
391 * \param handle An error handle (See Dart_IsError)
392 *
393 * On success, this function does not return. On failure, the
394 * process is terminated.
395 */
397
398/**
399 * Converts an object to a string.
400 *
401 * May generate an unhandled exception error.
402 *
403 * \return The converted string if no error occurs during
404 * the conversion. If an error does occur, an error handle is
405 * returned.
406 */
408
409/**
410 * Checks to see if two handles refer to identically equal objects.
411 *
412 * If both handles refer to instances, this is equivalent to using the top-level
413 * function identical() from dart:core. Otherwise, returns whether the two
414 * argument handles refer to the same object.
415 *
416 * \param obj1 An object to be compared.
417 * \param obj2 An object to be compared.
418 *
419 * \return True if the objects are identically equal. False otherwise.
420 */
422
423/**
424 * Allocates a handle in the current scope from a persistent handle.
425 */
427
428/**
429 * Allocates a handle in the current scope from a weak persistent handle.
430 *
431 * This will be a handle to Dart_Null if the object has been garbage collected.
432 */
435
436/**
437 * Allocates a persistent handle for an object.
438 *
439 * This handle has the lifetime of the current isolate unless it is
440 * explicitly deallocated by calling Dart_DeletePersistentHandle.
441 *
442 * Requires there to be a current isolate.
443 */
445
446/**
447 * Assign value of local handle to a persistent handle.
448 *
449 * Requires there to be a current isolate.
450 *
451 * \param obj1 A persistent handle whose value needs to be set.
452 * \param obj2 An object whose value needs to be set to the persistent handle.
453 */
455 Dart_Handle obj2);
456
457/**
458 * Deallocates a persistent handle.
459 *
460 * Requires there to be a current isolate group.
461 */
463
464/**
465 * Allocates a weak persistent handle for an object.
466 *
467 * This handle has the lifetime of the current isolate. The handle can also be
468 * explicitly deallocated by calling Dart_DeleteWeakPersistentHandle.
469 *
470 * If the object becomes unreachable the callback is invoked with the peer as
471 * argument. The callback can be executed on any thread, will have a current
472 * isolate group, but will not have a current isolate. The callback can only
473 * call Dart_DeletePersistentHandle or Dart_DeleteWeakPersistentHandle. This
474 * gives the embedder the ability to cleanup data associated with the object.
475 * The handle will point to the Dart_Null object after the finalizer has been
476 * run. It is illegal to call into the VM with any other Dart_* functions from
477 * the callback. If the handle is deleted before the object becomes
478 * unreachable, the callback is never invoked.
479 *
480 * Requires there to be a current isolate.
481 *
482 * \param object An object with identity.
483 * \param peer A pointer to a native object or NULL. This value is
484 * provided to callback when it is invoked.
485 * \param external_allocation_size The number of externally allocated
486 * bytes for peer. Used to inform the garbage collector.
487 * \param callback A function pointer that will be invoked sometime
488 * after the object is garbage collected, unless the handle has been deleted.
489 * A valid callback needs to be specified it cannot be NULL.
490 *
491 * \return The weak persistent handle or NULL. NULL is returned in case of bad
492 * parameters.
493 */
496 void* peer,
497 intptr_t external_allocation_size,
499
500/**
501 * Deletes the given weak persistent [object] handle.
502 *
503 * Requires there to be a current isolate group.
504 */
507
508/**
509 * Allocates a finalizable handle for an object.
510 *
511 * This handle has the lifetime of the current isolate group unless the object
512 * pointed to by the handle is garbage collected, in this case the VM
513 * automatically deletes the handle after invoking the callback associated
514 * with the handle. The handle can also be explicitly deallocated by
515 * calling Dart_DeleteFinalizableHandle.
516 *
517 * If the object becomes unreachable the callback is invoked with the
518 * the peer as argument. The callback can be executed on any thread, will have
519 * an isolate group, but will not have a current isolate. The callback can only
520 * call Dart_DeletePersistentHandle or Dart_DeleteWeakPersistentHandle.
521 * This gives the embedder the ability to cleanup data associated with the
522 * object and clear out any cached references to the handle. All references to
523 * this handle after the callback will be invalid. It is illegal to call into
524 * the VM with any other Dart_* functions from the callback. If the handle is
525 * deleted before the object becomes unreachable, the callback is never
526 * invoked.
527 *
528 * Requires there to be a current isolate.
529 *
530 * \param object An object with identity.
531 * \param peer A pointer to a native object or NULL. This value is
532 * provided to callback when it is invoked.
533 * \param external_allocation_size The number of externally allocated
534 * bytes for peer. Used to inform the garbage collector.
535 * \param callback A function pointer that will be invoked sometime
536 * after the object is garbage collected, unless the handle has been deleted.
537 * A valid callback needs to be specified it cannot be NULL.
538 *
539 * \return The finalizable handle or NULL. NULL is returned in case of bad
540 * parameters.
541 */
544 void* peer,
545 intptr_t external_allocation_size,
547
548/**
549 * Deletes the given finalizable [object] handle.
550 *
551 * The caller has to provide the actual Dart object the handle was created from
552 * to prove the object (and therefore the finalizable handle) is still alive.
553 *
554 * Requires there to be a current isolate.
555 */
557 Dart_Handle strong_ref_to_object);
558
559
560/*
561 * ==========================
562 * Initialization and Globals
563 * ==========================
564 */
565
566/**
567 * Gets the version string for the Dart VM.
568 *
569 * The version of the Dart VM can be accessed without initializing the VM.
570 *
571 * \return The version string for the embedded Dart VM.
572 */
574
575/**
576 * Isolate specific flags are set when creating a new isolate using the
577 * Dart_IsolateFlags structure.
578 *
579 * Current version of flags is encoded in a 32-bit integer with 16 bits used
580 * for each part.
581 */
582
583#define DART_FLAGS_CURRENT_VERSION (0x0000000c)
584
585typedef struct {
586 int32_t version;
598
599/**
600 * Initialize Dart_IsolateFlags with correct version and default values.
601 */
603
604/**
605 * An isolate creation and initialization callback function.
606 *
607 * This callback, provided by the embedder, is called when the VM
608 * needs to create an isolate. The callback should create an isolate
609 * by calling Dart_CreateIsolateGroup and load any scripts required for
610 * execution.
611 *
612 * This callback may be called on a different thread than the one
613 * running the parent isolate.
614 *
615 * When the function returns NULL, it is the responsibility of this
616 * function to ensure that Dart_ShutdownIsolate has been called if
617 * required (for example, if the isolate was created successfully by
618 * Dart_CreateIsolateGroup() but the root library fails to load
619 * successfully, then the function should call Dart_ShutdownIsolate
620 * before returning).
621 *
622 * When the function returns NULL, the function should set *error to
623 * a malloc-allocated buffer containing a useful error message. The
624 * caller of this function (the VM) will make sure that the buffer is
625 * freed.
626 *
627 * \param script_uri The uri of the main source file or snapshot to load.
628 * Either the URI of the parent isolate set in Dart_CreateIsolateGroup for
629 * Isolate.spawn, or the argument to Isolate.spawnUri canonicalized by the
630 * library tag handler of the parent isolate.
631 * The callback is responsible for loading the program by a call to
632 * Dart_LoadScriptFromKernel.
633 * \param main The name of the main entry point this isolate will
634 * eventually run. This is provided for advisory purposes only to
635 * improve debugging messages. The main function is not invoked by
636 * this function.
637 * \param package_root Ignored.
638 * \param package_config Uri of the package configuration file (either in format
639 * of .packages or .dart_tool/package_config.json) for this isolate
640 * to resolve package imports against. If this parameter is not passed the
641 * package resolution of the parent isolate should be used.
642 * \param flags Default flags for this isolate being spawned. Either inherited
643 * from the spawning isolate or passed as parameters when spawning the
644 * isolate from Dart code.
645 * \param isolate_data The isolate data which was passed to the
646 * parent isolate when it was created by calling Dart_CreateIsolateGroup().
647 * \param error A structure into which the embedder can place a
648 * C string containing an error message in the case of failures.
649 *
650 * \return The embedder returns NULL if the creation and
651 * initialization was not successful and the isolate if successful.
652 */
654 const char* script_uri,
655 const char* main,
656 const char* package_root,
657 const char* package_config,
659 void* isolate_data,
660 char** error);
661
662/**
663 * An isolate initialization callback function.
664 *
665 * This callback, provided by the embedder, is called when the VM has created an
666 * isolate within an existing isolate group (i.e. from the same source as an
667 * existing isolate).
668 *
669 * The callback should setup native resolvers and might want to set a custom
670 * message handler via [Dart_SetMessageNotifyCallback] and mark the isolate as
671 * runnable.
672 *
673 * This callback may be called on a different thread than the one
674 * running the parent isolate.
675 *
676 * When the function returns `false`, it is the responsibility of this
677 * function to ensure that `Dart_ShutdownIsolate` has been called.
678 *
679 * When the function returns `false`, the function should set *error to
680 * a malloc-allocated buffer containing a useful error message. The
681 * caller of this function (the VM) will make sure that the buffer is
682 * freed.
683 *
684 * \param child_isolate_data The callback data to associate with the new
685 * child isolate.
686 * \param error A structure into which the embedder can place a
687 * C string containing an error message in the case the initialization fails.
688 *
689 * \return The embedder returns true if the initialization was successful and
690 * false otherwise (in which case the VM will terminate the isolate).
691 */
692typedef bool (*Dart_InitializeIsolateCallback)(void** child_isolate_data,
693 char** error);
694
695/**
696 * An isolate shutdown callback function.
697 *
698 * This callback, provided by the embedder, is called before the vm
699 * shuts down an isolate. The isolate being shutdown will be the current
700 * isolate. It is safe to run Dart code.
701 *
702 * This function should be used to dispose of native resources that
703 * are allocated to an isolate in order to avoid leaks.
704 *
705 * \param isolate_group_data The same callback data which was passed to the
706 * isolate group when it was created.
707 * \param isolate_data The same callback data which was passed to the isolate
708 * when it was created.
709 */
710typedef void (*Dart_IsolateShutdownCallback)(void* isolate_group_data,
711 void* isolate_data);
712
713/**
714 * An isolate cleanup callback function.
715 *
716 * This callback, provided by the embedder, is called after the vm
717 * shuts down an isolate. There will be no current isolate and it is *not*
718 * safe to run Dart code.
719 *
720 * This function should be used to dispose of native resources that
721 * are allocated to an isolate in order to avoid leaks.
722 *
723 * \param isolate_group_data The same callback data which was passed to the
724 * isolate group when it was created.
725 * \param isolate_data The same callback data which was passed to the isolate
726 * when it was created.
727 */
728typedef void (*Dart_IsolateCleanupCallback)(void* isolate_group_data,
729 void* isolate_data);
730
731/**
732 * An isolate group cleanup callback function.
733 *
734 * This callback, provided by the embedder, is called after the vm
735 * shuts down an isolate group.
736 *
737 * This function should be used to dispose of native resources that
738 * are allocated to an isolate in order to avoid leaks.
739 *
740 * \param isolate_group_data The same callback data which was passed to the
741 * isolate group when it was created.
742 *
743 */
744typedef void (*Dart_IsolateGroupCleanupCallback)(void* isolate_group_data);
745
746/**
747 * A thread start callback function.
748 * This callback, provided by the embedder, is called after a thread in the
749 * vm thread pool starts.
750 * This function could be used to adjust thread priority or attach native
751 * resources to the thread.
752 */
753typedef void (*Dart_ThreadStartCallback)(void);
754
755/**
756 * A thread death callback function.
757 * This callback, provided by the embedder, is called before a thread in the
758 * vm thread pool exits.
759 * This function could be used to dispose of native resources that
760 * are associated and attached to the thread, in order to avoid leaks.
761 */
762typedef void (*Dart_ThreadExitCallback)(void);
763
764/**
765 * Opens a file for reading or writing.
766 *
767 * Callback provided by the embedder for file operations. If the
768 * embedder does not allow file operations this callback can be
769 * NULL.
770 *
771 * \param name The name of the file to open.
772 * \param write A boolean variable which indicates if the file is to
773 * opened for writing. If there is an existing file it needs to truncated.
774 */
775typedef void* (*Dart_FileOpenCallback)(const char* name, bool write);
776
777/**
778 * Read contents of file.
779 *
780 * Callback provided by the embedder for file operations. If the
781 * embedder does not allow file operations this callback can be
782 * NULL.
783 *
784 * \param data Buffer allocated in the callback into which the contents
785 * of the file are read into. It is the responsibility of the caller to
786 * free this buffer.
787 * \param file_length A variable into which the length of the file is returned.
788 * In the case of an error this value would be -1.
789 * \param stream Handle to the opened file.
790 */
791typedef void (*Dart_FileReadCallback)(uint8_t** data,
792 intptr_t* file_length,
793 void* stream);
794
795/**
796 * Write data into file.
797 *
798 * Callback provided by the embedder for file operations. If the
799 * embedder does not allow file operations this callback can be
800 * NULL.
801 *
802 * \param data Buffer which needs to be written into the file.
803 * \param length Length of the buffer.
804 * \param stream Handle to the opened file.
805 */
806typedef void (*Dart_FileWriteCallback)(const void* data,
807 intptr_t length,
808 void* stream);
809
810/**
811 * Closes the opened file.
812 *
813 * Callback provided by the embedder for file operations. If the
814 * embedder does not allow file operations this callback can be
815 * NULL.
816 *
817 * \param stream Handle to the opened file.
818 */
819typedef void (*Dart_FileCloseCallback)(void* stream);
820
821typedef bool (*Dart_EntropySource)(uint8_t* buffer, intptr_t length);
822
823/**
824 * Callback provided by the embedder that is used by the vmservice isolate
825 * to request the asset archive. The asset archive must be an uncompressed tar
826 * archive that is stored in a Uint8List.
827 *
828 * If the embedder has no vmservice isolate assets, the callback can be NULL.
829 *
830 * \return The embedder must return a handle to a Uint8List containing an
831 * uncompressed tar archive or null.
832 */
834
835/**
836 * The current version of the Dart_InitializeFlags. Should be incremented every
837 * time Dart_InitializeFlags changes in a binary incompatible way.
838 */
839#define DART_INITIALIZE_PARAMS_CURRENT_VERSION (0x00000008)
840
841/** Forward declaration */
842struct Dart_CodeObserver;
843
844/**
845 * Callback provided by the embedder that is used by the VM to notify on code
846 * object creation, *before* it is invoked the first time.
847 * This is useful for embedders wanting to e.g. keep track of PCs beyond
848 * the lifetime of the garbage collected code objects.
849 * Note that an address range may be used by more than one code object over the
850 * lifecycle of a process. Clients of this function should record timestamps for
851 * these compilation events and when collecting PCs to disambiguate reused
852 * address ranges.
853 */
854typedef void (*Dart_OnNewCodeCallback)(struct Dart_CodeObserver* observer,
855 const char* name,
856 uintptr_t base,
857 uintptr_t size);
858
859typedef struct Dart_CodeObserver {
860 void* data;
861
864
865/**
866 * Optional callback provided by the embedder that is used by the VM to
867 * implement registration of kernel blobs for the subsequent Isolate.spawnUri
868 * If no callback is provided, the registration of kernel blobs will throw
869 * an error.
870 *
871 * \param kernel_buffer A buffer which contains a kernel program. Callback
872 * should copy the contents of `kernel_buffer` as
873 * it may be freed immediately after registration.
874 * \param kernel_buffer_size The size of `kernel_buffer`.
875 *
876 * \return A C string representing URI which can be later used
877 * to spawn a new isolate. This C String should be scope allocated
878 * or owned by the embedder.
879 * Returns NULL if embedder runs out of memory.
880 */
881typedef const char* (*Dart_RegisterKernelBlobCallback)(
882 const uint8_t* kernel_buffer,
883 intptr_t kernel_buffer_size);
884
885/**
886 * Optional callback provided by the embedder that is used by the VM to
887 * unregister kernel blobs.
888 * If no callback is provided, the unregistration of kernel blobs will throw
889 * an error.
890 *
891 * \param kernel_blob_uri URI of the kernel blob to unregister.
892 */
893typedef void (*Dart_UnregisterKernelBlobCallback)(const char* kernel_blob_uri);
894
895/**
896 * Describes how to initialize the VM. Used with Dart_Initialize.
897 */
898typedef struct {
899 /**
900 * Identifies the version of the struct used by the client.
901 * should be initialized to DART_INITIALIZE_PARAMS_CURRENT_VERSION.
902 */
903 int32_t version;
904
905 /**
906 * A buffer containing snapshot data, or NULL if no snapshot is provided.
907 *
908 * If provided, the buffer must remain valid until Dart_Cleanup returns.
909 */
910 const uint8_t* vm_snapshot_data;
911
912 /**
913 * A buffer containing a snapshot of precompiled instructions, or NULL if
914 * no snapshot is provided.
915 *
916 * If provided, the buffer must remain valid until Dart_Cleanup returns.
917 */
919
920 /**
921 * A function to be called during isolate group creation.
922 * See Dart_IsolateGroupCreateCallback.
923 */
925
926 /**
927 * A function to be called during isolate
928 * initialization inside an existing isolate group.
929 * See Dart_InitializeIsolateCallback.
930 */
932
933 /**
934 * A function to be called right before an isolate is shutdown.
935 * See Dart_IsolateShutdownCallback.
936 */
938
939 /**
940 * A function to be called after an isolate was shutdown.
941 * See Dart_IsolateCleanupCallback.
942 */
944
945 /**
946 * A function to be called after an isolate group is
947 * shutdown. See Dart_IsolateGroupCleanupCallback.
948 */
950
958
959 /**
960 * A function to be called by the service isolate when it requires the
961 * vmservice assets archive. See Dart_GetVMServiceAssetsArchive.
962 */
964
966
967 /**
968 * An external code observer callback function. The observer can be invoked
969 * as early as during the Dart_Initialize() call.
970 */
972
973 /**
974 * Kernel blob registration callback function. See Dart_RegisterKernelBlobCallback.
975 */
977
978 /**
979 * Kernel blob unregistration callback function. See Dart_UnregisterKernelBlobCallback.
980 */
982
983#if defined(__Fuchsia__)
984 /**
985 * The resource needed to use zx_vmo_replace_as_executable. Can be
986 * ZX_HANDLE_INVALID if the process has ambient-replace-as-executable or if
987 * executable memory is not needed (e.g., this is an AOT runtime).
988 */
989 zx_handle_t vmex_resource;
990#endif
992
993/**
994 * Initializes the VM.
995 *
996 * \param params A struct containing initialization information. The version
997 * field of the struct must be DART_INITIALIZE_PARAMS_CURRENT_VERSION.
998 *
999 * \return NULL if initialization is successful. Returns an error message
1000 * otherwise. The caller is responsible for freeing the error message.
1001 */
1003 Dart_InitializeParams* params);
1004
1005/**
1006 * Cleanup state in the VM before process termination.
1007 *
1008 * \return NULL if cleanup is successful. Returns an error message otherwise.
1009 * The caller is responsible for freeing the error message.
1010 *
1011 * NOTE: This function must not be called on a thread that was created by the VM
1012 * itself.
1013 */
1015
1016/**
1017 * Sets command line flags. Should be called before Dart_Initialize.
1018 *
1019 * \param argc The length of the arguments array.
1020 * \param argv An array of arguments.
1021 *
1022 * \return NULL if successful. Returns an error message otherwise.
1023 * The caller is responsible for freeing the error message.
1024 *
1025 * NOTE: This call does not store references to the passed in c-strings.
1026 */
1028 const char** argv);
1029
1030/**
1031 * Returns true if the named VM flag is of boolean type, specified, and set to
1032 * true.
1033 *
1034 * \param flag_name The name of the flag without leading punctuation
1035 * (example: "enable_asserts").
1036 */
1037DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name);
1038
1039/*
1040 * ========
1041 * Isolates
1042 * ========
1043 */
1044
1045/**
1046 * Creates a new isolate. The new isolate becomes the current isolate.
1047 *
1048 * A snapshot can be used to restore the VM quickly to a saved state
1049 * and is useful for fast startup. If snapshot data is provided, the
1050 * isolate will be started using that snapshot data. Requires a core snapshot or
1051 * an app snapshot created by Dart_CreateSnapshot or
1052 * Dart_CreatePrecompiledSnapshot* from a VM with the same version.
1053 *
1054 * Requires there to be no current isolate.
1055 *
1056 * \param script_uri The main source file or snapshot this isolate will load.
1057 * The VM will provide this URI to the Dart_IsolateGroupCreateCallback when a
1058 * child isolate is created by Isolate.spawn. The embedder should use a URI
1059 * that allows it to load the same program into such a child isolate.
1060 * \param name A short name for the isolate to improve debugging messages.
1061 * Typically of the format 'foo.dart:main()'.
1062 * \param isolate_snapshot_data Buffer containing the snapshot data of the
1063 * isolate or NULL if no snapshot is provided. If provided, the buffer must
1064 * remain valid until the isolate shuts down.
1065 * \param isolate_snapshot_instructions Buffer containing the snapshot
1066 * instructions of the isolate or NULL if no snapshot is provided. If
1067 * provided, the buffer must remain valid until the isolate shuts down.
1068 * \param flags Pointer to VM specific flags or NULL for default flags.
1069 * \param isolate_group_data Embedder group data. This data can be obtained
1070 * by calling Dart_IsolateGroupData and will be passed to the
1071 * Dart_IsolateShutdownCallback, Dart_IsolateCleanupCallback, and
1072 * Dart_IsolateGroupCleanupCallback.
1073 * \param isolate_data Embedder data. This data will be passed to
1074 * the Dart_IsolateGroupCreateCallback when new isolates are spawned from
1075 * this parent isolate.
1076 * \param error Returns NULL if creation is successful, an error message
1077 * otherwise. The caller is responsible for calling free() on the error
1078 * message.
1079 *
1080 * \return The new isolate on success, or NULL if isolate creation failed.
1081 */
1083Dart_CreateIsolateGroup(const char* script_uri,
1084 const char* name,
1085 const uint8_t* isolate_snapshot_data,
1086 const uint8_t* isolate_snapshot_instructions,
1088 void* isolate_group_data,
1089 void* isolate_data,
1090 char** error);
1091/**
1092 * Creates a new isolate inside the isolate group of [group_member].
1093 *
1094 * Requires there to be no current isolate.
1095 *
1096 * \param group_member An isolate from the same group into which the newly created
1097 * isolate should be born into. Other threads may not have entered / enter this
1098 * member isolate.
1099 * \param name A short name for the isolate for debugging purposes.
1100 * \param shutdown_callback A callback to be called when the isolate is being
1101 * shutdown (may be NULL).
1102 * \param cleanup_callback A callback to be called when the isolate is being
1103 * cleaned up (may be NULL).
1104 * \param child_isolate_data The embedder-specific data associated with this isolate.
1105 * \param error Set to NULL if creation is successful, set to an error
1106 * message otherwise. The caller is responsible for calling free() on the
1107 * error message.
1108 *
1109 * \return The newly created isolate on success, or NULL if isolate creation
1110 * failed.
1111 *
1112 * If successful, the newly created isolate will become the current isolate.
1113 */
1116 const char* name,
1117 Dart_IsolateShutdownCallback shutdown_callback,
1118 Dart_IsolateCleanupCallback cleanup_callback,
1119 void* child_isolate_data,
1120 char** error);
1121
1122/* TODO(turnidge): Document behavior when there is already a current
1123 * isolate. */
1124
1125/**
1126 * Creates a new isolate from a Dart Kernel file. The new isolate
1127 * becomes the current isolate.
1128 *
1129 * Requires there to be no current isolate.
1130 *
1131 * \param script_uri The main source file or snapshot this isolate will load.
1132 * The VM will provide this URI to the Dart_IsolateGroupCreateCallback when a
1133 * child isolate is created by Isolate.spawn. The embedder should use a URI that
1134 * allows it to load the same program into such a child isolate.
1135 * \param name A short name for the isolate to improve debugging messages.
1136 * Typically of the format 'foo.dart:main()'.
1137 * \param kernel_buffer A buffer which contains a kernel/DIL program. Must
1138 * remain valid until isolate shutdown.
1139 * \param kernel_buffer_size The size of `kernel_buffer`.
1140 * \param flags Pointer to VM specific flags or NULL for default flags.
1141 * \param isolate_group_data Embedder group data. This data can be obtained
1142 * by calling Dart_IsolateGroupData and will be passed to the
1143 * Dart_IsolateShutdownCallback, Dart_IsolateCleanupCallback, and
1144 * Dart_IsolateGroupCleanupCallback.
1145 * \param isolate_data Embedder data. This data will be passed to
1146 * the Dart_IsolateGroupCreateCallback when new isolates are spawned from
1147 * this parent isolate.
1148 * \param error Returns NULL if creation is successful, an error message
1149 * otherwise. The caller is responsible for calling free() on the error
1150 * message.
1151 *
1152 * \return The new isolate on success, or NULL if isolate creation failed.
1153 */
1156 const char* name,
1157 const uint8_t* kernel_buffer,
1158 intptr_t kernel_buffer_size,
1160 void* isolate_group_data,
1161 void* isolate_data,
1162 char** error);
1163/**
1164 * Shuts down the current isolate. After this call, the current isolate is NULL.
1165 * Any current scopes created by Dart_EnterScope will be exited. Invokes the
1166 * shutdown callback and any callbacks of remaining weak persistent handles.
1167 *
1168 * Requires there to be a current isolate.
1169 */
1171/* TODO(turnidge): Document behavior when there is no current isolate. */
1172
1173/**
1174 * Returns the current isolate. Will return NULL if there is no
1175 * current isolate.
1176 */
1178
1179/**
1180 * Returns the callback data associated with the current isolate. This
1181 * data was set when the isolate got created or initialized.
1182 */
1184
1185/**
1186 * Returns the callback data associated with the given isolate. This
1187 * data was set when the isolate got created or initialized.
1188 */
1190
1191/**
1192 * Returns the current isolate group. Will return NULL if there is no
1193 * current isolate group.
1194 */
1196
1197/**
1198 * Returns the callback data associated with the current isolate group. This
1199 * data was passed to the isolate group when it was created.
1200 */
1202
1203/**
1204 * Gets an id that uniquely identifies current isolate group.
1205 *
1206 * It is the responsibility of the caller to free the returned ID.
1207 */
1208typedef int64_t Dart_IsolateGroupId;
1210
1211/**
1212 * Returns the callback data associated with the specified isolate group. This
1213 * data was passed to the isolate when it was created.
1214 * The embedder is responsible for ensuring the consistency of this data
1215 * with respect to the lifecycle of an isolate group.
1216 */
1218
1219/**
1220 * Returns the debugging name for the current isolate.
1221 *
1222 * This name is unique to each isolate and should only be used to make
1223 * debugging messages more comprehensible.
1224 */
1226
1227/**
1228 * Returns the debugging name for the current isolate.
1229 *
1230 * This name is unique to each isolate and should only be used to make
1231 * debugging messages more comprehensible.
1232 *
1233 * The returned string is scope allocated and is only valid until the next call
1234 * to Dart_ExitScope.
1235 */
1237
1238/**
1239 * Returns the ID for an isolate which is used to query the service protocol.
1240 *
1241 * It is the responsibility of the caller to free the returned ID.
1242 */
1244
1245/**
1246 * Enters an isolate. After calling this function,
1247 * the current isolate will be set to the provided isolate.
1248 *
1249 * Requires there to be no current isolate. Multiple threads may not be in
1250 * the same isolate at once.
1251 */
1253
1254/**
1255 * Kills the given isolate.
1256 *
1257 * This function has the same effect as dart:isolate's
1258 * Isolate.kill(priority:immediate).
1259 * It can interrupt ordinary Dart code but not native code. If the isolate is
1260 * in the middle of a long running native function, the isolate will not be
1261 * killed until control returns to Dart.
1262 *
1263 * Does not require a current isolate. It is safe to kill the current isolate if
1264 * there is one.
1265 */
1267
1268/**
1269 * Notifies the VM that the embedder expects to be idle until |deadline|. The VM
1270 * may use this time to perform garbage collection or other tasks to avoid
1271 * delays during execution of Dart code in the future.
1272 *
1273 * |deadline| is measured in microseconds against the system's monotonic time.
1274 * This clock can be accessed via Dart_TimelineGetMicros().
1275 *
1276 * Requires there to be a current isolate.
1277 */
1278DART_EXPORT void Dart_NotifyIdle(int64_t deadline);
1279
1280typedef void (*Dart_HeapSamplingReportCallback)(void* context,
1281 void* data);
1282
1283typedef void* (*Dart_HeapSamplingCreateCallback)(
1284 Dart_Isolate isolate,
1285 Dart_IsolateGroup isolate_group,
1286 const char* cls_name,
1287 intptr_t allocation_size);
1288typedef void (*Dart_HeapSamplingDeleteCallback)(void* data);
1289
1290/**
1291 * Starts the heap sampling profiler for each thread in the VM.
1292 */
1294
1295/*
1296 * Stops the heap sampling profiler for each thread in the VM.
1297 */
1299
1300/* Registers callbacks are invoked once per sampled allocation upon object
1301 * allocation and garbage collection.
1302 *
1303 * |create_callback| can be used to associate additional data with the sampled
1304 * allocation, such as a stack trace. This data pointer will be passed to
1305 * |delete_callback| to allow for proper disposal when the object associated
1306 * with the allocation sample is collected.
1307 *
1308 * The provided callbacks must not call into the VM and should do as little
1309 * work as possible to avoid performance penalities during object allocation and
1310 * garbage collection.
1311 *
1312 * NOTE: It is a fatal error to set either callback to null once they have been
1313 * initialized.
1314 */
1316 Dart_HeapSamplingCreateCallback create_callback,
1317 Dart_HeapSamplingDeleteCallback delete_callback);
1318
1319/*
1320 * Reports the surviving allocation samples for all live isolate groups in the
1321 * VM.
1322 *
1323 * When the callback is invoked:
1324 * - |context| will be the context object provided when invoking
1325 * |Dart_ReportSurvivingAllocations|. This can be safely set to null if not
1326 * required.
1327 * - |heap_size| will be equal to the size of the allocated object associated
1328 * with the sample.
1329 * - |cls_name| will be a C String representing
1330 * the class name of the allocated object. This string is valid for the
1331 * duration of the call to Dart_ReportSurvivingAllocations and can be
1332 * freed by the VM at any point after the method returns.
1333 * - |data| will be set to the data associated with the sample by
1334 * |Dart_HeapSamplingCreateCallback|.
1335 *
1336 * If |force_gc| is true, a full GC will be performed before reporting the
1337 * allocations.
1338 */
1341 void* context,
1342 bool force_gc);
1343
1344/*
1345 * Sets the average heap sampling rate based on a number of |bytes| for each
1346 * thread.
1347 *
1348 * In other words, approximately every |bytes| allocated will create a sample.
1349 * Defaults to 512 KiB.
1350 */
1352
1353/**
1354 * Notifies the VM that the embedder expects the application's working set has
1355 * recently shrunk significantly and is not expected to rise in the near future.
1356 * The VM may spend O(heap-size) time performing clean up work.
1357 *
1358 * Requires there to be a current isolate.
1359 */
1361
1362/**
1363 * Notifies the VM that the system is running low on memory.
1364 *
1365 * Does not require a current isolate. Only valid after calling Dart_Initialize.
1366 */
1368
1369typedef enum {
1370 /**
1371 * Balanced
1372 */
1374 /**
1375 * Optimize for low latency, at the expense of throughput and memory overhead
1376 * by performing work in smaller batches (requiring more overhead) or by
1377 * delaying work (requiring more memory). An embedder should not remain in
1378 * this mode indefinitely.
1379 */
1381 /**
1382 * Optimize for high throughput, at the expense of latency and memory overhead
1383 * by performing work in larger batches with more intervening growth.
1384 */
1386 /**
1387 * Optimize for low memory, at the expensive of throughput and latency by more
1388 * frequently performing work.
1389 */
1392
1393/**
1394 * Set the desired performance trade-off.
1395 *
1396 * Requires a current isolate.
1397 *
1398 * Returns the previous performance mode.
1399 */
1402
1403/**
1404 * Starts the CPU sampling profiler.
1405 */
1407
1408/**
1409 * Stops the CPU sampling profiler.
1410 *
1411 * Note that some profile samples might still be taken after this function
1412 * returns due to the asynchronous nature of the implementation on some
1413 * platforms.
1414 */
1416
1417/**
1418 * Notifies the VM that the current thread should not be profiled until a
1419 * matching call to Dart_ThreadEnableProfiling is made.
1420 *
1421 * NOTE: By default, if a thread has entered an isolate it will be profiled.
1422 * This function should be used when an embedder knows a thread is about
1423 * to make a blocking call and wants to avoid unnecessary interrupts by
1424 * the profiler.
1425 */
1427
1428/**
1429 * Notifies the VM that the current thread should be profiled.
1430 *
1431 * NOTE: It is only legal to call this function *after* calling
1432 * Dart_ThreadDisableProfiling.
1433 *
1434 * NOTE: By default, if a thread has entered an isolate it will be profiled.
1435 */
1437
1438/**
1439 * Register symbol information for the Dart VM's profiler and crash dumps.
1440 *
1441 * This consumes the output of //topaz/runtime/dart/profiler_symbols, which
1442 * should be treated as opaque.
1443 */
1444DART_EXPORT void Dart_AddSymbols(const char* dso_name,
1445 void* buffer,
1446 intptr_t buffer_size);
1447
1448/**
1449 * Exits an isolate. After this call, Dart_CurrentIsolate will
1450 * return NULL.
1451 *
1452 * Requires there to be a current isolate.
1453 */
1455/* TODO(turnidge): We don't want users of the api to be able to exit a
1456 * "pure" dart isolate. Implement and document. */
1457
1458/**
1459 * Creates a full snapshot of the current isolate heap.
1460 *
1461 * A full snapshot is a compact representation of the dart vm isolate heap
1462 * and dart isolate heap states. These snapshots are used to initialize
1463 * the vm isolate on startup and fast initialization of an isolate.
1464 * A Snapshot of the heap is created before any dart code has executed.
1465 *
1466 * Requires there to be a current isolate. Not available in the precompiled
1467 * runtime (check Dart_IsPrecompiledRuntime).
1468 *
1469 * \param vm_snapshot_data_buffer Returns a pointer to a buffer containing the
1470 * vm snapshot. This buffer is scope allocated and is only valid
1471 * until the next call to Dart_ExitScope.
1472 * \param vm_snapshot_data_size Returns the size of vm_snapshot_data_buffer.
1473 * \param isolate_snapshot_data_buffer Returns a pointer to a buffer containing
1474 * the isolate snapshot. This buffer is scope allocated and is only valid
1475 * until the next call to Dart_ExitScope.
1476 * \param isolate_snapshot_data_size Returns the size of
1477 * isolate_snapshot_data_buffer.
1478 * \param is_core Create a snapshot containing core libraries.
1479 * Such snapshot should be agnostic to null safety mode.
1480 *
1481 * \return A valid handle if no error occurs during the operation.
1482 */
1484Dart_CreateSnapshot(uint8_t** vm_snapshot_data_buffer,
1485 intptr_t* vm_snapshot_data_size,
1486 uint8_t** isolate_snapshot_data_buffer,
1487 intptr_t* isolate_snapshot_data_size,
1488 bool is_core);
1489
1490/**
1491 * Returns whether the buffer contains a kernel file.
1492 *
1493 * \param buffer Pointer to a buffer that might contain a kernel binary.
1494 * \param buffer_size Size of the buffer.
1495 *
1496 * \return Whether the buffer contains a kernel binary (full or partial).
1497 */
1498DART_EXPORT bool Dart_IsKernel(const uint8_t* buffer, intptr_t buffer_size);
1499
1500/**
1501 * Make isolate runnable.
1502 *
1503 * When isolates are spawned, this function is used to indicate that
1504 * the creation and initialization (including script loading) of the
1505 * isolate is complete and the isolate can start.
1506 * This function expects there to be no current isolate.
1507 *
1508 * \param isolate The isolate to be made runnable.
1509 *
1510 * \return NULL if successful. Returns an error message otherwise. The caller
1511 * is responsible for freeing the error message.
1512 */
1514 Dart_Isolate isolate);
1515
1516/*
1517 * ==================
1518 * Messages and Ports
1519 * ==================
1520 */
1521
1522/**
1523 * A port is used to send or receive inter-isolate messages
1524 */
1525typedef int64_t Dart_Port;
1526
1527/**
1528 * ILLEGAL_PORT is a port number guaranteed never to be associated with a valid
1529 * port.
1530 */
1531#define ILLEGAL_PORT ((Dart_Port)0)
1532
1533/**
1534 * A message notification callback.
1535 *
1536 * This callback allows the embedder to provide a custom wakeup mechanism for
1537 * the delivery of inter-isolate messages. This function is called once per
1538 * message on an arbitrary thread. It is the responsibility of the embedder to
1539 * eventually call Dart_HandleMessage once per callback received with the
1540 * destination isolate set as the current isolate to process the message.
1541 */
1542typedef void (*Dart_MessageNotifyCallback)(Dart_Isolate destination_isolate);
1543
1544/**
1545 * Allows embedders to provide a custom wakeup mechanism for the delivery of
1546 * inter-isolate messages. This setting only applies to the current isolate.
1547 *
1548 * This mechanism is optional: if not provided, the isolate will be scheduled on
1549 * a VM-managed thread pool. An embedder should provide this callback if it
1550 * wants to run an isolate on a specific thread or to interleave handling of
1551 * inter-isolate messages with other event sources.
1552 *
1553 * Most embedders will only call this function once, before isolate
1554 * execution begins. If this function is called after isolate
1555 * execution begins, the embedder is responsible for threading issues.
1556 */
1558 Dart_MessageNotifyCallback message_notify_callback);
1559/* TODO(turnidge): Consider moving this to isolate creation so that it
1560 * is impossible to mess up. */
1561
1562/**
1563 * Query the current message notify callback for the isolate.
1564 *
1565 * \return The current message notify callback for the isolate.
1566 */
1568
1569/**
1570 * The VM's default message handler supports pausing an isolate before it
1571 * processes the first message and right after the it processes the isolate's
1572 * final message. This can be controlled for all isolates by two VM flags:
1573 *
1574 * `--pause-isolates-on-start`
1575 * `--pause-isolates-on-exit`
1576 *
1577 * Additionally, Dart_SetShouldPauseOnStart and Dart_SetShouldPauseOnExit can be
1578 * used to control this behaviour on a per-isolate basis.
1579 *
1580 * When an embedder is using a Dart_MessageNotifyCallback the embedder
1581 * needs to cooperate with the VM so that the service protocol can report
1582 * accurate information about isolates and so that tools such as debuggers
1583 * work reliably.
1584 *
1585 * The following functions can be used to implement pausing on start and exit.
1586 */
1587
1588/**
1589 * If the VM flag `--pause-isolates-on-start` was passed this will be true.
1590 *
1591 * \return A boolean value indicating if pause on start was requested.
1592 */
1594
1595/**
1596 * Override the VM flag `--pause-isolates-on-start` for the current isolate.
1597 *
1598 * \param should_pause Should the isolate be paused on start?
1599 *
1600 * NOTE: This must be called before Dart_IsolateMakeRunnable.
1601 */
1603
1604/**
1605 * Is the current isolate paused on start?
1606 *
1607 * \return A boolean value indicating if the isolate is paused on start.
1608 */
1610
1611/**
1612 * Called when the embedder has paused the current isolate on start and when
1613 * the embedder has resumed the isolate.
1614 *
1615 * \param paused Is the isolate paused on start?
1616 */
1618
1619/**
1620 * If the VM flag `--pause-isolates-on-exit` was passed this will be true.
1621 *
1622 * \return A boolean value indicating if pause on exit was requested.
1623 */
1625
1626/**
1627 * Override the VM flag `--pause-isolates-on-exit` for the current isolate.
1628 *
1629 * \param should_pause Should the isolate be paused on exit?
1630 *
1631 */
1633
1634/**
1635 * Is the current isolate paused on exit?
1636 *
1637 * \return A boolean value indicating if the isolate is paused on exit.
1638 */
1640
1641/**
1642 * Called when the embedder has paused the current isolate on exit and when
1643 * the embedder has resumed the isolate.
1644 *
1645 * \param paused Is the isolate paused on exit?
1646 */
1648
1649/**
1650 * Called when the embedder has caught a top level unhandled exception error
1651 * in the current isolate.
1652 *
1653 * NOTE: It is illegal to call this twice on the same isolate without first
1654 * clearing the sticky error to null.
1655 *
1656 * \param error The unhandled exception error.
1657 */
1659
1660/**
1661 * Does the current isolate have a sticky error?
1662 */
1664
1665/**
1666 * Gets the sticky error for the current isolate.
1667 *
1668 * \return A handle to the sticky error object or null.
1669 */
1671
1672/**
1673 * Handles the next pending message for the current isolate.
1674 *
1675 * May generate an unhandled exception error.
1676 *
1677 * \return A valid handle if no error occurs during the operation.
1678 */
1680
1681/**
1682 * Drains the microtask queue, then blocks the calling thread until the current
1683 * isolate receives a message, then handles all messages.
1684 *
1685 * \param timeout_millis When non-zero, the call returns after the indicated
1686 number of milliseconds even if no message was received.
1687 * \return A valid handle if no error occurs, otherwise an error handle.
1688 */
1690Dart_WaitForEvent(int64_t timeout_millis);
1691
1692/**
1693 * Handles any pending messages for the vm service for the current
1694 * isolate.
1695 *
1696 * This function may be used by an embedder at a breakpoint to avoid
1697 * pausing the vm service.
1698 *
1699 * This function can indirectly cause the message notify callback to
1700 * be called.
1701 *
1702 * \return true if the vm service requests the program resume
1703 * execution, false otherwise
1704 */
1706
1707/**
1708 * Does the current isolate have pending service messages?
1709 *
1710 * \return true if the isolate has pending service messages, false otherwise.
1711 */
1713
1714/**
1715 * Processes any incoming messages for the current isolate.
1716 *
1717 * This function may only be used when the embedder has not provided
1718 * an alternate message delivery mechanism with
1719 * Dart_SetMessageCallbacks. It is provided for convenience.
1720 *
1721 * This function waits for incoming messages for the current
1722 * isolate. As new messages arrive, they are handled using
1723 * Dart_HandleMessage. The routine exits when all ports to the
1724 * current isolate are closed.
1725 *
1726 * \return A valid handle if the run loop exited successfully. If an
1727 * exception or other error occurs while processing messages, an
1728 * error handle is returned.
1729 */
1731
1732/**
1733 * Lets the VM run message processing for the isolate.
1734 *
1735 * This function expects there to a current isolate and the current isolate
1736 * must not have an active api scope. The VM will take care of making the
1737 * isolate runnable (if not already), handles its message loop and will take
1738 * care of shutting the isolate down once it's done.
1739 *
1740 * \param errors_are_fatal Whether uncaught errors should be fatal.
1741 * \param on_error_port A port to notify on uncaught errors (or ILLEGAL_PORT).
1742 * \param on_exit_port A port to notify on exit (or ILLEGAL_PORT).
1743 * \param error A non-NULL pointer which will hold an error message if the call
1744 * fails. The error has to be free()ed by the caller.
1745 *
1746 * \return If successful the VM takes ownership of the isolate and takes care
1747 * of its message loop. If not successful the caller retains ownership of the
1748 * isolate.
1749 */
1751 bool errors_are_fatal,
1752 Dart_Port on_error_port,
1753 Dart_Port on_exit_port,
1754 char** error);
1755
1756/* TODO(turnidge): Should this be removed from the public api? */
1757
1758/**
1759 * Gets the main port id for the current isolate.
1760 */
1762
1763/**
1764 * Does the current isolate have live ReceivePorts?
1765 *
1766 * A ReceivePort is live when it has not been closed.
1767 */
1769
1770/**
1771 * Posts a message for some isolate. The message is a serialized
1772 * object.
1773 *
1774 * Requires there to be a current isolate.
1775 *
1776 * For posting messages outside of an isolate see \ref Dart_PostCObject.
1777 *
1778 * \param port_id The destination port.
1779 * \param object An object from the current isolate.
1780 *
1781 * \return True if the message was posted.
1782 */
1784
1785/**
1786 * Returns a new SendPort with the provided port id.
1787 *
1788 * \param port_id The destination port.
1789 *
1790 * \return A new SendPort if no errors occurs. Otherwise returns
1791 * an error handle.
1792 */
1794
1795/**
1796 * Gets the SendPort id for the provided SendPort.
1797 * \param port A SendPort object whose id is desired.
1798 * \param port_id Returns the id of the SendPort.
1799 * \return Success if no error occurs. Otherwise returns
1800 * an error handle.
1801 */
1803 Dart_Port* port_id);
1804
1805/*
1806 * ======
1807 * Scopes
1808 * ======
1809 */
1810
1811/**
1812 * Enters a new scope.
1813 *
1814 * All new local handles will be created in this scope. Additionally,
1815 * some functions may return "scope allocated" memory which is only
1816 * valid within this scope.
1817 *
1818 * Requires there to be a current isolate.
1819 */
1821
1822/**
1823 * Exits a scope.
1824 *
1825 * The previous scope (if any) becomes the current scope.
1826 *
1827 * Requires there to be a current isolate.
1828 */
1830
1831/**
1832 * The Dart VM uses "zone allocation" for temporary structures. Zones
1833 * support very fast allocation of small chunks of memory. The chunks
1834 * cannot be deallocated individually, but instead zones support
1835 * deallocating all chunks in one fast operation.
1836 *
1837 * This function makes it possible for the embedder to allocate
1838 * temporary data in the VMs zone allocator.
1839 *
1840 * Zone allocation is possible:
1841 * 1. when inside a scope where local handles can be allocated
1842 * 2. when processing a message from a native port in a native port
1843 * handler
1844 *
1845 * All the memory allocated this way will be reclaimed either on the
1846 * next call to Dart_ExitScope or when the native port handler exits.
1847 *
1848 * \param size Size of the memory to allocate.
1849 *
1850 * \return A pointer to the allocated memory. NULL if allocation
1851 * failed. Failure might due to is no current VM zone.
1852 */
1853DART_EXPORT uint8_t* Dart_ScopeAllocate(intptr_t size);
1854
1855/*
1856 * =======
1857 * Objects
1858 * =======
1859 */
1860
1861/**
1862 * Returns the null object.
1863 *
1864 * \return A handle to the null object.
1865 */
1867
1868/**
1869 * Is this object null?
1870 */
1872
1873/**
1874 * Returns the empty string object.
1875 *
1876 * \return A handle to the empty string object.
1877 */
1879
1880/**
1881 * Returns types that are not classes, and which therefore cannot be looked up
1882 * as library members by Dart_GetType.
1883 *
1884 * \return A handle to the dynamic, void or Never type.
1885 */
1889
1890/**
1891 * Checks if the two objects are equal.
1892 *
1893 * The result of the comparison is returned through the 'equal'
1894 * parameter. The return value itself is used to indicate success or
1895 * failure, not equality.
1896 *
1897 * May generate an unhandled exception error.
1898 *
1899 * \param obj1 An object to be compared.
1900 * \param obj2 An object to be compared.
1901 * \param equal Returns the result of the equality comparison.
1902 *
1903 * \return A valid handle if no error occurs during the comparison.
1904 */
1906 Dart_Handle obj2,
1907 bool* equal);
1908
1909/**
1910 * Is this object an instance of some type?
1911 *
1912 * The result of the test is returned through the 'instanceof' parameter.
1913 * The return value itself is used to indicate success or failure.
1914 *
1915 * \param object An object.
1916 * \param type A type.
1917 * \param instanceof Return true if 'object' is an instance of type 'type'.
1918 *
1919 * \return A valid handle if no error occurs during the operation.
1920 */
1923 bool* instanceof);
1924
1925/**
1926 * Query object type.
1927 *
1928 * \param object Some Object.
1929 *
1930 * \return true if Object is of the specified type.
1931 */
1938DART_EXPORT bool Dart_IsStringLatin1(Dart_Handle object); /* (ISO-8859-1) */
1951
1952/*
1953 * =========
1954 * Instances
1955 * =========
1956 */
1957
1958/*
1959 * For the purposes of the embedding api, not all objects returned are
1960 * Dart language objects. Within the api, we use the term 'Instance'
1961 * to indicate handles which refer to true Dart language objects.
1962 *
1963 * TODO(turnidge): Reorganize the "Object" section above, pulling down
1964 * any functions that more properly belong here. */
1965
1966/**
1967 * Gets the type of a Dart language object.
1968 *
1969 * \param instance Some Dart object.
1970 *
1971 * \return If no error occurs, the type is returned. Otherwise an
1972 * error handle is returned.
1973 */
1975
1976/**
1977 * Returns the name for the provided class type.
1978 *
1979 * \return A valid string handle if no error occurs during the
1980 * operation.
1981 */
1983
1984/**
1985 * Returns the name for the provided function or method.
1986 *
1987 * \return A valid string handle if no error occurs during the
1988 * operation.
1989 */
1991
1992/**
1993 * Returns a handle to the owner of a function.
1994 *
1995 * The owner of an instance method or a static method is its defining
1996 * class. The owner of a top-level function is its defining
1997 * library. The owner of the function of a non-implicit closure is the
1998 * function of the method or closure that defines the non-implicit
1999 * closure.
2000 *
2001 * \return A valid handle to the owner of the function, or an error
2002 * handle if the argument is not a valid handle to a function.
2003 */
2005
2006/**
2007 * Determines whether a function handle refers to a static function
2008 * of method.
2009 *
2010 * For the purposes of the embedding API, a top-level function is
2011 * implicitly declared static.
2012 *
2013 * \param function A handle to a function or method declaration.
2014 * \param is_static Returns whether the function or method is declared static.
2015 *
2016 * \return A valid handle if no error occurs during the operation.
2017 */
2019 bool* is_static);
2020
2021/**
2022 * Is this object a closure resulting from a tear-off (closurized method)?
2023 *
2024 * Returns true for closures produced when an ordinary method is accessed
2025 * through a getter call. Returns false otherwise, in particular for closures
2026 * produced from local function declarations.
2027 *
2028 * \param object Some Object.
2029 *
2030 * \return true if Object is a tear-off.
2031 */
2033
2034/**
2035 * Retrieves the function of a closure.
2036 *
2037 * \return A handle to the function of the closure, or an error handle if the
2038 * argument is not a closure.
2039 */
2041
2042/**
2043 * Returns a handle to the library which contains class.
2044 *
2045 * \return A valid handle to the library with owns class, null if the class
2046 * has no library or an error handle if the argument is not a valid handle
2047 * to a class type.
2048 */
2050
2051/*
2052 * =============================
2053 * Numbers, Integers and Doubles
2054 * =============================
2055 */
2056
2057/**
2058 * Does this Integer fit into a 64-bit signed integer?
2059 *
2060 * \param integer An integer.
2061 * \param fits Returns true if the integer fits into a 64-bit signed integer.
2062 *
2063 * \return A valid handle if no error occurs during the operation.
2064 */
2066 bool* fits);
2067
2068/**
2069 * Does this Integer fit into a 64-bit unsigned integer?
2070 *
2071 * \param integer An integer.
2072 * \param fits Returns true if the integer fits into a 64-bit unsigned integer.
2073 *
2074 * \return A valid handle if no error occurs during the operation.
2075 */
2077 bool* fits);
2078
2079/**
2080 * Returns an Integer with the provided value.
2081 *
2082 * \param value The value of the integer.
2083 *
2084 * \return The Integer object if no error occurs. Otherwise returns
2085 * an error handle.
2086 */
2088
2089/**
2090 * Returns an Integer with the provided value.
2091 *
2092 * \param value The unsigned value of the integer.
2093 *
2094 * \return The Integer object if no error occurs. Otherwise returns
2095 * an error handle.
2096 */
2098
2099/**
2100 * Returns an Integer with the provided value.
2101 *
2102 * \param value The value of the integer represented as a C string
2103 * containing a hexadecimal number.
2104 *
2105 * \return The Integer object if no error occurs. Otherwise returns
2106 * an error handle.
2107 */
2109
2110/**
2111 * Gets the value of an Integer.
2112 *
2113 * The integer must fit into a 64-bit signed integer, otherwise an error occurs.
2114 *
2115 * \param integer An Integer.
2116 * \param value Returns the value of the Integer.
2117 *
2118 * \return A valid handle if no error occurs during the operation.
2119 */
2121 int64_t* value);
2122
2123/**
2124 * Gets the value of an Integer.
2125 *
2126 * The integer must fit into a 64-bit unsigned integer, otherwise an
2127 * error occurs.
2128 *
2129 * \param integer An Integer.
2130 * \param value Returns the value of the Integer.
2131 *
2132 * \return A valid handle if no error occurs during the operation.
2133 */
2135 uint64_t* value);
2136
2137/**
2138 * Gets the value of an integer as a hexadecimal C string.
2139 *
2140 * \param integer An Integer.
2141 * \param value Returns the value of the Integer as a hexadecimal C
2142 * string. This C string is scope allocated and is only valid until
2143 * the next call to Dart_ExitScope.
2144 *
2145 * \return A valid handle if no error occurs during the operation.
2146 */
2148 const char** value);
2149
2150/**
2151 * Returns a Double with the provided value.
2152 *
2153 * \param value A double.
2154 *
2155 * \return The Double object if no error occurs. Otherwise returns
2156 * an error handle.
2157 */
2159
2160/**
2161 * Gets the value of a Double
2162 *
2163 * \param double_obj A Double
2164 * \param value Returns the value of the Double.
2165 *
2166 * \return A valid handle if no error occurs during the operation.
2167 */
2169
2170/**
2171 * Returns a closure of static function 'function_name' in the class 'class_name'
2172 * in the exported namespace of specified 'library'.
2173 *
2174 * \param library Library object
2175 * \param cls_type Type object representing a Class
2176 * \param function_name Name of the static function in the class
2177 *
2178 * \return A valid Dart instance if no error occurs during the operation.
2179 */
2181 Dart_Handle cls_type,
2182 Dart_Handle function_name);
2183
2184/*
2185 * ========
2186 * Booleans
2187 * ========
2188 */
2189
2190/**
2191 * Returns the True object.
2192 *
2193 * Requires there to be a current isolate.
2194 *
2195 * \return A handle to the True object.
2196 */
2198
2199/**
2200 * Returns the False object.
2201 *
2202 * Requires there to be a current isolate.
2203 *
2204 * \return A handle to the False object.
2205 */
2207
2208/**
2209 * Returns a Boolean with the provided value.
2210 *
2211 * \param value true or false.
2212 *
2213 * \return The Boolean object if no error occurs. Otherwise returns
2214 * an error handle.
2215 */
2217
2218/**
2219 * Gets the value of a Boolean
2220 *
2221 * \param boolean_obj A Boolean
2222 * \param value Returns the value of the Boolean.
2223 *
2224 * \return A valid handle if no error occurs during the operation.
2225 */
2227
2228/*
2229 * =======
2230 * Strings
2231 * =======
2232 */
2233
2234/**
2235 * Gets the length of a String.
2236 *
2237 * \param str A String.
2238 * \param length Returns the length of the String.
2239 *
2240 * \return A valid handle if no error occurs during the operation.
2241 */
2243
2244/**
2245 * Returns a String built from the provided C string
2246 * (There is an implicit assumption that the C string passed in contains
2247 * UTF-8 encoded characters and '\0' is considered as a termination
2248 * character).
2249 *
2250 * \param str A C String
2251 *
2252 * \return The String object if no error occurs. Otherwise returns
2253 * an error handle.
2254 */
2256/* TODO(turnidge): Document what happens when we run out of memory
2257 * during this call. */
2258
2259/**
2260 * Returns a String built from an array of UTF-8 encoded characters.
2261 *
2262 * \param utf8_array An array of UTF-8 encoded characters.
2263 * \param length The length of the codepoints array.
2264 *
2265 * \return The String object if no error occurs. Otherwise returns
2266 * an error handle.
2267 */
2269 intptr_t length);
2270
2271/**
2272 * Returns a String built from an array of UTF-16 encoded characters.
2273 *
2274 * \param utf16_array An array of UTF-16 encoded characters.
2275 * \param length The length of the codepoints array.
2276 *
2277 * \return The String object if no error occurs. Otherwise returns
2278 * an error handle.
2279 */
2281 intptr_t length);
2282
2283/**
2284 * Returns a String built from an array of UTF-32 encoded characters.
2285 *
2286 * \param utf32_array An array of UTF-32 encoded characters.
2287 * \param length The length of the codepoints array.
2288 *
2289 * \return The String object if no error occurs. Otherwise returns
2290 * an error handle.
2291 */
2293 intptr_t length);
2294
2295/**
2296 * Returns a String which references an external array of
2297 * Latin-1 (ISO-8859-1) encoded characters.
2298 *
2299 * \param latin1_array Array of Latin-1 encoded characters. This must not move.
2300 * \param length The length of the characters array.
2301 * \param peer An external pointer to associate with this string.
2302 * \param external_allocation_size The number of externally allocated
2303 * bytes for peer. Used to inform the garbage collector.
2304 * \param callback A callback to be called when this string is finalized.
2305 *
2306 * \return The String object if no error occurs. Otherwise returns
2307 * an error handle.
2308 */
2310Dart_NewExternalLatin1String(const uint8_t* latin1_array,
2311 intptr_t length,
2312 void* peer,
2313 intptr_t external_allocation_size,
2315
2316/**
2317 * Returns a String which references an external array of UTF-16 encoded
2318 * characters.
2319 *
2320 * \param utf16_array An array of UTF-16 encoded characters. This must not move.
2321 * \param length The length of the characters array.
2322 * \param peer An external pointer to associate with this string.
2323 * \param external_allocation_size The number of externally allocated
2324 * bytes for peer. Used to inform the garbage collector.
2325 * \param callback A callback to be called when this string is finalized.
2326 *
2327 * \return The String object if no error occurs. Otherwise returns
2328 * an error handle.
2329 */
2331Dart_NewExternalUTF16String(const uint16_t* utf16_array,
2332 intptr_t length,
2333 void* peer,
2334 intptr_t external_allocation_size,
2336
2337/**
2338 * Gets the C string representation of a String.
2339 * (It is a sequence of UTF-8 encoded values with a '\0' termination.)
2340 *
2341 * \param str A string.
2342 * \param cstr Returns the String represented as a C string.
2343 * This C string is scope allocated and is only valid until
2344 * the next call to Dart_ExitScope.
2345 *
2346 * \return A valid handle if no error occurs during the operation.
2347 */
2349 const char** cstr);
2350
2351/**
2352 * Gets a UTF-8 encoded representation of a String.
2353 *
2354 * Any unpaired surrogate code points in the string will be converted as
2355 * replacement characters (U+FFFD, 0xEF 0xBF 0xBD in UTF-8). If you need
2356 * to preserve unpaired surrogates, use the Dart_StringToUTF16 function.
2357 *
2358 * \param str A string.
2359 * \param utf8_array Returns the String represented as UTF-8 code
2360 * units. This UTF-8 array is scope allocated and is only valid
2361 * until the next call to Dart_ExitScope.
2362 * \param length Used to return the length of the array which was
2363 * actually used.
2364 *
2365 * \return A valid handle if no error occurs during the operation.
2366 */
2368 uint8_t** utf8_array,
2369 intptr_t* length);
2370
2371/**
2372 * Gets the data corresponding to the string object. This function returns
2373 * the data only for Latin-1 (ISO-8859-1) string objects. For all other
2374 * string objects it returns an error.
2375 *
2376 * \param str A string.
2377 * \param latin1_array An array allocated by the caller, used to return
2378 * the string data.
2379 * \param length Used to pass in the length of the provided array.
2380 * Used to return the length of the array which was actually used.
2381 *
2382 * \return A valid handle if no error occurs during the operation.
2383 */
2385 uint8_t* latin1_array,
2386 intptr_t* length);
2387
2388/**
2389 * Gets the UTF-16 encoded representation of a string.
2390 *
2391 * \param str A string.
2392 * \param utf16_array An array allocated by the caller, used to return
2393 * the array of UTF-16 encoded characters.
2394 * \param length Used to pass in the length of the provided array.
2395 * Used to return the length of the array which was actually used.
2396 *
2397 * \return A valid handle if no error occurs during the operation.
2398 */
2400 uint16_t* utf16_array,
2401 intptr_t* length);
2402
2403/**
2404 * Gets the storage size in bytes of a String.
2405 *
2406 * \param str A String.
2407 * \param size Returns the storage size in bytes of the String.
2408 * This is the size in bytes needed to store the String.
2409 *
2410 * \return A valid handle if no error occurs during the operation.
2411 */
2413
2414/**
2415 * Retrieves some properties associated with a String.
2416 * Properties retrieved are:
2417 * - character size of the string (one or two byte)
2418 * - length of the string
2419 * - peer pointer of string if it is an external string.
2420 * \param str A String.
2421 * \param char_size Returns the character size of the String.
2422 * \param str_len Returns the length of the String.
2423 * \param peer Returns the peer pointer associated with the String or 0 if
2424 * there is no peer pointer for it.
2425 * \return Success if no error occurs. Otherwise returns
2426 * an error handle.
2427 */
2429 intptr_t* char_size,
2430 intptr_t* str_len,
2431 void** peer);
2432
2433/*
2434 * =====
2435 * Lists
2436 * =====
2437 */
2438
2439/**
2440 * Returns a List<dynamic> of the desired length.
2441 *
2442 * \param length The length of the list.
2443 *
2444 * \return The List object if no error occurs. Otherwise returns
2445 * an error handle.
2446 */
2448
2449typedef enum {
2454
2455// TODO(bkonyi): convert this to use nullable types once NNBD is enabled.
2456/**
2457 * Returns a List of the desired length with the desired legacy element type.
2458 *
2459 * \param element_type_id The type of elements of the list.
2460 * \param length The length of the list.
2461 *
2462 * \return The List object if no error occurs. Otherwise returns an error
2463 * handle.
2464 */
2466 intptr_t length);
2467
2468/**
2469 * Returns a List of the desired length with the desired element type.
2470 *
2471 * \param element_type Handle to a nullable type object. E.g., from
2472 * Dart_GetType or Dart_GetNullableType.
2473 *
2474 * \param length The length of the list.
2475 *
2476 * \return The List object if no error occurs. Otherwise returns
2477 * an error handle.
2478 */
2480 intptr_t length);
2481
2482/**
2483 * Returns a List of the desired length with the desired element type, filled
2484 * with the provided object.
2485 *
2486 * \param element_type Handle to a type object. E.g., from Dart_GetType.
2487 *
2488 * \param fill_object Handle to an object of type 'element_type' that will be
2489 * used to populate the list. This parameter can only be Dart_Null() if the
2490 * length of the list is 0 or 'element_type' is a nullable type.
2491 *
2492 * \param length The length of the list.
2493 *
2494 * \return The List object if no error occurs. Otherwise returns
2495 * an error handle.
2496 */
2498 Dart_Handle fill_object,
2499 intptr_t length);
2500
2501/**
2502 * Gets the length of a List.
2503 *
2504 * May generate an unhandled exception error.
2505 *
2506 * \param list A List.
2507 * \param length Returns the length of the List.
2508 *
2509 * \return A valid handle if no error occurs during the operation.
2510 */
2512
2513/**
2514 * Gets the Object at some index of a List.
2515 *
2516 * If the index is out of bounds, an error occurs.
2517 *
2518 * May generate an unhandled exception error.
2519 *
2520 * \param list A List.
2521 * \param index A valid index into the List.
2522 *
2523 * \return The Object in the List at the specified index if no error
2524 * occurs. Otherwise returns an error handle.
2525 */
2527
2528/**
2529* Gets a range of Objects from a List.
2530*
2531* If any of the requested index values are out of bounds, an error occurs.
2532*
2533* May generate an unhandled exception error.
2534*
2535* \param list A List.
2536* \param offset The offset of the first item to get.
2537* \param length The number of items to get.
2538* \param result A pointer to fill with the objects.
2539*
2540* \return Success if no error occurs during the operation.
2541*/
2543 intptr_t offset,
2544 intptr_t length,
2546
2547/**
2548 * Sets the Object at some index of a List.
2549 *
2550 * If the index is out of bounds, an error occurs.
2551 *
2552 * May generate an unhandled exception error.
2553 *
2554 * \param list A List.
2555 * \param index A valid index into the List.
2556 * \param value The Object to put in the List.
2557 *
2558 * \return A valid handle if no error occurs during the operation.
2559 */
2561 intptr_t index,
2563
2564/**
2565 * May generate an unhandled exception error.
2566 */
2568 intptr_t offset,
2569 uint8_t* native_array,
2570 intptr_t length);
2571
2572/**
2573 * May generate an unhandled exception error.
2574 */
2576 intptr_t offset,
2577 const uint8_t* native_array,
2578 intptr_t length);
2579
2580/*
2581 * ====
2582 * Maps
2583 * ====
2584 */
2585
2586/**
2587 * Gets the Object at some key of a Map.
2588 *
2589 * May generate an unhandled exception error.
2590 *
2591 * \param map A Map.
2592 * \param key An Object.
2593 *
2594 * \return The value in the map at the specified key, null if the map does not
2595 * contain the key, or an error handle.
2596 */
2598
2599/**
2600 * Returns whether the Map contains a given key.
2601 *
2602 * May generate an unhandled exception error.
2603 *
2604 * \param map A Map.
2605 *
2606 * \return A handle on a boolean indicating whether map contains the key.
2607 * Otherwise returns an error handle.
2608 */
2610
2611/**
2612 * Gets the list of keys of a Map.
2613 *
2614 * May generate an unhandled exception error.
2615 *
2616 * \param map A Map.
2617 *
2618 * \return The list of key Objects if no error occurs. Otherwise returns an
2619 * error handle.
2620 */
2622
2623/*
2624 * ==========
2625 * Typed Data
2626 * ==========
2627 */
2628
2629typedef enum {
2647
2648/**
2649 * Return type if this object is a TypedData object.
2650 *
2651 * \return kInvalid if the object is not a TypedData object or the appropriate
2652 * Dart_TypedData_Type.
2653 */
2655
2656/**
2657 * Return type if this object is an external TypedData object.
2658 *
2659 * \return kInvalid if the object is not an external TypedData object or
2660 * the appropriate Dart_TypedData_Type.
2661 */
2664
2665/**
2666 * Returns a TypedData object of the desired length and type.
2667 *
2668 * \param type The type of the TypedData object.
2669 * \param length The length of the TypedData object (length in type units).
2670 *
2671 * \return The TypedData object if no error occurs. Otherwise returns
2672 * an error handle.
2673 */
2675 intptr_t length);
2676
2677/**
2678 * Returns a TypedData object which references an external data array.
2679 *
2680 * \param type The type of the data array.
2681 * \param data A data array. This array must not move.
2682 * \param length The length of the data array (length in type units).
2683 *
2684 * \return The TypedData object if no error occurs. Otherwise returns
2685 * an error handle.
2686 */
2688 void* data,
2689 intptr_t length);
2690
2691/**
2692 * Returns a TypedData object which references an external data array.
2693 *
2694 * \param type The type of the data array.
2695 * \param data A data array. This array must not move.
2696 * \param length The length of the data array (length in type units).
2697 * \param peer A pointer to a native object or NULL. This value is
2698 * provided to callback when it is invoked.
2699 * \param external_allocation_size The number of externally allocated
2700 * bytes for peer. Used to inform the garbage collector.
2701 * \param callback A function pointer that will be invoked sometime
2702 * after the object is garbage collected, unless the handle has been deleted.
2703 * A valid callback needs to be specified it cannot be NULL.
2704 *
2705 * \return The TypedData object if no error occurs. Otherwise returns
2706 * an error handle.
2707 */
2710 void* data,
2711 intptr_t length,
2712 void* peer,
2713 intptr_t external_allocation_size,
2717 const void* data,
2718 intptr_t length,
2719 void* peer,
2720 intptr_t external_allocation_size,
2722
2723/**
2724 * Returns a ByteBuffer object for the typed data.
2725 *
2726 * \param typed_data The TypedData object.
2727 *
2728 * \return The ByteBuffer object if no error occurs. Otherwise returns
2729 * an error handle.
2730 */
2732
2733/**
2734 * Acquires access to the internal data address of a TypedData object.
2735 *
2736 * \param object The typed data object whose internal data address is to
2737 * be accessed.
2738 * \param type The type of the object is returned here.
2739 * \param data The internal data address is returned here.
2740 * \param len Size of the typed array is returned here.
2741 *
2742 * Notes:
2743 * When the internal address of the object is acquired any calls to a
2744 * Dart API function that could potentially allocate an object or run
2745 * any Dart code will return an error.
2746 *
2747 * Any Dart API functions for accessing the data should not be called
2748 * before the corresponding release. In particular, the object should
2749 * not be acquired again before its release. This leads to undefined
2750 * behavior.
2751 *
2752 * \return Success if the internal data address is acquired successfully.
2753 * Otherwise, returns an error handle.
2754 */
2757 void** data,
2758 intptr_t* len);
2759
2760/**
2761 * Releases access to the internal data address that was acquired earlier using
2762 * Dart_TypedDataAcquireData.
2763 *
2764 * \param object The typed data object whose internal data address is to be
2765 * released.
2766 *
2767 * \return Success if the internal data address is released successfully.
2768 * Otherwise, returns an error handle.
2769 */
2771
2772/**
2773 * Returns the TypedData object associated with the ByteBuffer object.
2774 *
2775 * \param byte_buffer The ByteBuffer object.
2776 *
2777 * \return The TypedData object if no error occurs. Otherwise returns
2778 * an error handle.
2779 */
2781
2782/*
2783 * ============================================================
2784 * Invoking Constructors, Methods, Closures and Field accessors
2785 * ============================================================
2786 */
2787
2788/**
2789 * Invokes a constructor, creating a new object.
2790 *
2791 * This function allows hidden constructors (constructors with leading
2792 * underscores) to be called.
2793 *
2794 * \param type Type of object to be constructed.
2795 * \param constructor_name The name of the constructor to invoke. Use
2796 * Dart_Null() or Dart_EmptyString() to invoke the unnamed constructor.
2797 * This name should not include the name of the class.
2798 * \param number_of_arguments Size of the arguments array.
2799 * \param arguments An array of arguments to the constructor.
2800 *
2801 * \return If the constructor is called and completes successfully,
2802 * then the new object. If an error occurs during execution, then an
2803 * error handle is returned.
2804 */
2807 Dart_Handle constructor_name,
2808 int number_of_arguments,
2809 Dart_Handle* arguments);
2810
2811/**
2812 * Allocate a new object without invoking a constructor.
2813 *
2814 * \param type The type of an object to be allocated.
2815 *
2816 * \return The new object. If an error occurs during execution, then an
2817 * error handle is returned.
2818 */
2820
2821/**
2822 * Allocate a new object without invoking a constructor, and sets specified
2823 * native fields.
2824 *
2825 * \param type The type of an object to be allocated.
2826 * \param num_native_fields The number of native fields to set.
2827 * \param native_fields An array containing the value of native fields.
2828 *
2829 * \return The new object. If an error occurs during execution, then an
2830 * error handle is returned.
2831 */
2834 intptr_t num_native_fields,
2835 const intptr_t* native_fields);
2836
2837/**
2838 * Invokes a method or function.
2839 *
2840 * The 'target' parameter may be an object, type, or library. If
2841 * 'target' is an object, then this function will invoke an instance
2842 * method. If 'target' is a type, then this function will invoke a
2843 * static method. If 'target' is a library, then this function will
2844 * invoke a top-level function from that library.
2845 * NOTE: This API call cannot be used to invoke methods of a type object.
2846 *
2847 * This function ignores visibility (leading underscores in names).
2848 *
2849 * May generate an unhandled exception error.
2850 *
2851 * \param target An object, type, or library.
2852 * \param name The name of the function or method to invoke.
2853 * \param number_of_arguments Size of the arguments array.
2854 * \param arguments An array of arguments to the function.
2855 *
2856 * \return If the function or method is called and completes
2857 * successfully, then the return value is returned. If an error
2858 * occurs during execution, then an error handle is returned.
2859 */
2863 int number_of_arguments,
2864 Dart_Handle* arguments);
2865/* TODO(turnidge): Document how to invoke operators. */
2866
2867/**
2868 * Invokes a Closure with the given arguments.
2869 *
2870 * May generate an unhandled exception error.
2871 *
2872 * \return If no error occurs during execution, then the result of
2873 * invoking the closure is returned. If an error occurs during
2874 * execution, then an error handle is returned.
2875 */
2878 int number_of_arguments,
2879 Dart_Handle* arguments);
2880
2881/**
2882 * Invokes a Generative Constructor on an object that was previously
2883 * allocated using Dart_Allocate/Dart_AllocateWithNativeFields.
2884 *
2885 * The 'object' parameter must be an object.
2886 *
2887 * This function ignores visibility (leading underscores in names).
2888 *
2889 * May generate an unhandled exception error.
2890 *
2891 * \param object An object.
2892 * \param name The name of the constructor to invoke.
2893 * Use Dart_Null() or Dart_EmptyString() to invoke the unnamed constructor.
2894 * \param number_of_arguments Size of the arguments array.
2895 * \param arguments An array of arguments to the function.
2896 *
2897 * \return If the constructor is called and completes
2898 * successfully, then the object is returned. If an error
2899 * occurs during execution, then an error handle is returned.
2900 */
2904 int number_of_arguments,
2905 Dart_Handle* arguments);
2906
2907/**
2908 * Gets the value of a field.
2909 *
2910 * The 'container' parameter may be an object, type, or library. If
2911 * 'container' is an object, then this function will access an
2912 * instance field. If 'container' is a type, then this function will
2913 * access a static field. If 'container' is a library, then this
2914 * function will access a top-level variable.
2915 * NOTE: This API call cannot be used to access fields of a type object.
2916 *
2917 * This function ignores field visibility (leading underscores in names).
2918 *
2919 * May generate an unhandled exception error.
2920 *
2921 * \param container An object, type, or library.
2922 * \param name A field name.
2923 *
2924 * \return If no error occurs, then the value of the field is
2925 * returned. Otherwise an error handle is returned.
2926 */
2929
2930/**
2931 * Sets the value of a field.
2932 *
2933 * The 'container' parameter may actually be an object, type, or
2934 * library. If 'container' is an object, then this function will
2935 * access an instance field. If 'container' is a type, then this
2936 * function will access a static field. If 'container' is a library,
2937 * then this function will access a top-level variable.
2938 * NOTE: This API call cannot be used to access fields of a type object.
2939 *
2940 * This function ignores field visibility (leading underscores in names).
2941 *
2942 * May generate an unhandled exception error.
2943 *
2944 * \param container An object, type, or library.
2945 * \param name A field name.
2946 * \param value The new field value.
2947 *
2948 * \return A valid handle if no error occurs.
2949 */
2952
2953/*
2954 * ==========
2955 * Exceptions
2956 * ==========
2957 */
2958
2959/*
2960 * TODO(turnidge): Remove these functions from the api and replace all
2961 * uses with Dart_NewUnhandledExceptionError. */
2962
2963/**
2964 * Throws an exception.
2965 *
2966 * This function causes a Dart language exception to be thrown. This
2967 * will proceed in the standard way, walking up Dart frames until an
2968 * appropriate 'catch' block is found, executing 'finally' blocks,
2969 * etc.
2970 *
2971 * If an error handle is passed into this function, the error is
2972 * propagated immediately. See Dart_PropagateError for a discussion
2973 * of error propagation.
2974 *
2975 * If successful, this function does not return. Note that this means
2976 * that the destructors of any stack-allocated C++ objects will not be
2977 * called. If there are no Dart frames on the stack, an error occurs.
2978 *
2979 * \return An error handle if the exception was not thrown.
2980 * Otherwise the function does not return.
2981 */
2983
2984/**
2985 * Rethrows an exception.
2986 *
2987 * Rethrows an exception, unwinding all dart frames on the stack. If
2988 * successful, this function does not return. Note that this means
2989 * that the destructors of any stack-allocated C++ objects will not be
2990 * called. If there are no Dart frames on the stack, an error occurs.
2991 *
2992 * \return An error handle if the exception was not thrown.
2993 * Otherwise the function does not return.
2994 */
2996 Dart_Handle stacktrace);
2997
2998/*
2999 * ===========================
3000 * Native fields and functions
3001 * ===========================
3002 */
3003
3004/**
3005 * Gets the number of native instance fields in an object.
3006 */
3008 int* count);
3009
3010/**
3011 * Gets the value of a native field.
3012 *
3013 * TODO(turnidge): Document.
3014 */
3016 int index,
3017 intptr_t* value);
3018
3019/**
3020 * Sets the value of a native field.
3021 *
3022 * TODO(turnidge): Document.
3023 */
3025 int index,
3026 intptr_t value);
3027
3028/**
3029 * The arguments to a native function.
3030 *
3031 * This object is passed to a native function to represent its
3032 * arguments and return value. It allows access to the arguments to a
3033 * native function by index. It also allows the return value of a
3034 * native function to be set.
3035 */
3036typedef struct _Dart_NativeArguments* Dart_NativeArguments;
3037
3038/**
3039 * Extracts current isolate group data from the native arguments structure.
3040 */
3042
3043typedef enum {
3054
3056 uint8_t type;
3057 uint8_t index;
3059
3062 int32_t as_int32;
3063 uint32_t as_uint32;
3064 int64_t as_int64;
3065 uint64_t as_uint64;
3067 struct {
3069 void* peer;
3071 struct {
3072 intptr_t num_fields;
3073 intptr_t* values;
3077
3078enum {
3083};
3084
3085#define BITMASK(size) ((1 << size) - 1)
3086#define DART_NATIVE_ARG_DESCRIPTOR(type, position) \
3087 (((type & BITMASK(kNativeArgTypeSize)) << kNativeArgTypePos) | \
3088 (position & BITMASK(kNativeArgNumberSize)))
3089
3090/**
3091 * Gets the native arguments based on the types passed in and populates
3092 * the passed arguments buffer with appropriate native values.
3093 *
3094 * \param args the Native arguments block passed into the native call.
3095 * \param num_arguments length of argument descriptor array and argument
3096 * values array passed in.
3097 * \param arg_descriptors an array that describes the arguments that
3098 * need to be retrieved. For each argument to be retrieved the descriptor
3099 * contains the argument number (0, 1 etc.) and the argument type
3100 * described using Dart_NativeArgument_Type, e.g:
3101 * DART_NATIVE_ARG_DESCRIPTOR(Dart_NativeArgument_kBool, 1) indicates
3102 * that the first argument is to be retrieved and it should be a boolean.
3103 * \param arg_values array into which the native arguments need to be
3104 * extracted into, the array is allocated by the caller (it could be
3105 * stack allocated to avoid the malloc/free performance overhead).
3106 *
3107 * \return Success if all the arguments could be extracted correctly,
3108 * returns an error handle if there were any errors while extracting the
3109 * arguments (mismatched number of arguments, incorrect types, etc.).
3110 */
3113 int num_arguments,
3114 const Dart_NativeArgument_Descriptor* arg_descriptors,
3115 Dart_NativeArgument_Value* arg_values);
3116
3117/**
3118 * Gets the native argument at some index.
3119 */
3121 int index);
3122/* TODO(turnidge): Specify the behavior of an out-of-bounds access. */
3123
3124/**
3125 * Gets the number of native arguments.
3126 */
3128
3129/**
3130 * Gets all the native fields of the native argument at some index.
3131 * \param args Native arguments structure.
3132 * \param arg_index Index of the desired argument in the structure above.
3133 * \param num_fields size of the intptr_t array 'field_values' passed in.
3134 * \param field_values intptr_t array in which native field values are returned.
3135 * \return Success if the native fields where copied in successfully. Otherwise
3136 * returns an error handle. On success the native field values are copied
3137 * into the 'field_values' array, if the argument at 'arg_index' is a
3138 * null object then 0 is copied as the native field values into the
3139 * 'field_values' array.
3140 */
3143 int arg_index,
3144 int num_fields,
3145 intptr_t* field_values);
3146
3147/**
3148 * Gets the native field of the receiver.
3149 */
3151 intptr_t* value);
3152
3153/**
3154 * Gets a string native argument at some index.
3155 * \param args Native arguments structure.
3156 * \param arg_index Index of the desired argument in the structure above.
3157 * \param peer Returns the peer pointer if the string argument has one.
3158 * \return Success if the string argument has a peer, if it does not
3159 * have a peer then the String object is returned. Otherwise returns
3160 * an error handle (argument is not a String object).
3161 */
3163 int arg_index,
3164 void** peer);
3165
3166/**
3167 * Gets an integer native argument at some index.
3168 * \param args Native arguments structure.
3169 * \param index Index of the desired argument in the structure above.
3170 * \param value Returns the integer value if the argument is an Integer.
3171 * \return Success if no error occurs. Otherwise returns an error handle.
3172 */
3174 int index,
3175 int64_t* value);
3176
3177/**
3178 * Gets a boolean native argument at some index.
3179 * \param args Native arguments structure.
3180 * \param index Index of the desired argument in the structure above.
3181 * \param value Returns the boolean value if the argument is a Boolean.
3182 * \return Success if no error occurs. Otherwise returns an error handle.
3183 */
3185 int index,
3186 bool* value);
3187
3188/**
3189 * Gets a double native argument at some index.
3190 * \param args Native arguments structure.
3191 * \param index Index of the desired argument in the structure above.
3192 * \param value Returns the double value if the argument is a double.
3193 * \return Success if no error occurs. Otherwise returns an error handle.
3194 */
3196 int index,
3197 double* value);
3198
3199/**
3200 * Sets the return value for a native function.
3201 *
3202 * If retval is an Error handle, then error will be propagated once
3203 * the native functions exits. See Dart_PropagateError for a
3204 * discussion of how different types of errors are propagated.
3205 */
3207 Dart_Handle retval);
3208
3211
3213 bool retval);
3214
3216 int64_t retval);
3217
3219 double retval);
3220
3221/**
3222 * A native function.
3223 */
3225
3226/**
3227 * Native entry resolution callback.
3228 *
3229 * For libraries and scripts which have native functions, the embedder
3230 * can provide a native entry resolver. This callback is used to map a
3231 * name/arity to a Dart_NativeFunction. If no function is found, the
3232 * callback should return NULL.
3233 *
3234 * The parameters to the native resolver function are:
3235 * \param name a Dart string which is the name of the native function.
3236 * \param num_of_arguments is the number of arguments expected by the
3237 * native function.
3238 * \param auto_setup_scope is a boolean flag that can be set by the resolver
3239 * to indicate if this function needs a Dart API scope (see Dart_EnterScope/
3240 * Dart_ExitScope) to be setup automatically by the VM before calling into
3241 * the native function. By default most native functions would require this
3242 * to be true but some light weight native functions which do not call back
3243 * into the VM through the Dart API may not require a Dart scope to be
3244 * setup automatically.
3245 *
3246 * \return A valid Dart_NativeFunction which resolves to a native entry point
3247 * for the native function.
3248 *
3249 * See Dart_SetNativeResolver.
3250 */
3252 int num_of_arguments,
3253 bool* auto_setup_scope);
3254/* TODO(turnidge): Consider renaming to NativeFunctionResolver or
3255 * NativeResolver. */
3256
3257/**
3258 * Native entry symbol lookup callback.
3259 *
3260 * For libraries and scripts which have native functions, the embedder
3261 * can provide a callback for mapping a native entry to a symbol. This callback
3262 * maps a native function entry PC to the native function name. If no native
3263 * entry symbol can be found, the callback should return NULL.
3264 *
3265 * The parameters to the native reverse resolver function are:
3266 * \param nf A Dart_NativeFunction.
3267 *
3268 * \return A const UTF-8 string containing the symbol name or NULL.
3269 *
3270 * See Dart_SetNativeResolver.
3271 */
3272typedef const uint8_t* (*Dart_NativeEntrySymbol)(Dart_NativeFunction nf);
3273
3274/**
3275 * FFI Native C function pointer resolver callback.
3276 *
3277 * See Dart_SetFfiNativeResolver.
3278 */
3279typedef void* (*Dart_FfiNativeResolver)(const char* name, uintptr_t args_n);
3280
3281/*
3282 * ===========
3283 * Environment
3284 * ===========
3285 */
3286
3287/**
3288 * An environment lookup callback function.
3289 *
3290 * \param name The name of the value to lookup in the environment.
3291 *
3292 * \return A valid handle to a string if the name exists in the
3293 * current environment or Dart_Null() if not.
3294 */
3296
3297/**
3298 * Sets the environment callback for the current isolate. This
3299 * callback is used to lookup environment values by name in the
3300 * current environment. This enables the embedder to supply values for
3301 * the const constructors bool.fromEnvironment, int.fromEnvironment
3302 * and String.fromEnvironment.
3303 */
3306
3307/**
3308 * Sets the callback used to resolve native functions for a library.
3309 *
3310 * \param library A library.
3311 * \param resolver A native entry resolver.
3312 *
3313 * \return A valid handle if the native resolver was set successfully.
3314 */
3317 Dart_NativeEntryResolver resolver,
3318 Dart_NativeEntrySymbol symbol);
3319/* TODO(turnidge): Rename to Dart_LibrarySetNativeResolver? */
3320
3321/**
3322 * Returns the callback used to resolve native functions for a library.
3323 *
3324 * \param library A library.
3325 * \param resolver a pointer to a Dart_NativeEntryResolver
3326 *
3327 * \return A valid handle if the library was found.
3328 */
3331
3332/**
3333 * Returns the callback used to resolve native function symbols for a library.
3334 *
3335 * \param library A library.
3336 * \param resolver a pointer to a Dart_NativeEntrySymbol.
3337 *
3338 * \return A valid handle if the library was found.
3339 */
3341 Dart_NativeEntrySymbol* resolver);
3342
3343/**
3344 * Sets the callback used to resolve FFI native functions for a library.
3345 * The resolved functions are expected to be a C function pointer of the
3346 * correct signature (as specified in the `@FfiNative<NFT>()` function
3347 * annotation in Dart code).
3348 *
3349 * NOTE: This is an experimental feature and might change in the future.
3350 *
3351 * \param library A library.
3352 * \param resolver A native function resolver.
3353 *
3354 * \return A valid handle if the native resolver was set successfully.
3355 */
3358
3359/*
3360 * =====================
3361 * Scripts and Libraries
3362 * =====================
3363 */
3364
3365typedef enum {
3370
3371/**
3372 * The library tag handler is a multi-purpose callback provided by the
3373 * embedder to the Dart VM. The embedder implements the tag handler to
3374 * provide the ability to load Dart scripts and imports.
3375 *
3376 * -- TAGS --
3377 *
3378 * Dart_kCanonicalizeUrl
3379 *
3380 * This tag indicates that the embedder should canonicalize 'url' with
3381 * respect to 'library'. For most embedders, the
3382 * Dart_DefaultCanonicalizeUrl function is a sufficient implementation
3383 * of this tag. The return value should be a string holding the
3384 * canonicalized url.
3385 *
3386 * Dart_kImportTag
3387 *
3388 * This tag is used to load a library from IsolateMirror.loadUri. The embedder
3389 * should call Dart_LoadLibraryFromKernel to provide the library to the VM. The
3390 * return value should be an error or library (the result from
3391 * Dart_LoadLibraryFromKernel).
3392 *
3393 * Dart_kKernelTag
3394 *
3395 * This tag is used to load the intermediate file (kernel) generated by
3396 * the Dart front end. This tag is typically used when a 'hot-reload'
3397 * of an application is needed and the VM is 'use dart front end' mode.
3398 * The dart front end typically compiles all the scripts, imports and part
3399 * files into one intermediate file hence we don't use the source/import or
3400 * script tags. The return value should be an error or a TypedData containing
3401 * the kernel bytes.
3402 *
3403 */
3405 Dart_LibraryTag tag,
3406 Dart_Handle library_or_package_map_url,
3407 Dart_Handle url);
3408
3409/**
3410 * Sets library tag handler for the current isolate. This handler is
3411 * used to handle the various tags encountered while loading libraries
3412 * or scripts in the isolate.
3413 *
3414 * \param handler Handler code to be used for handling the various tags
3415 * encountered while loading libraries or scripts in the isolate.
3416 *
3417 * \return If no error occurs, the handler is set for the isolate.
3418 * Otherwise an error handle is returned.
3419 *
3420 * TODO(turnidge): Document.
3421 */
3424
3425/**
3426 * Handles deferred loading requests. When this handler is invoked, it should
3427 * eventually load the deferred loading unit with the given id and call
3428 * Dart_DeferredLoadComplete or Dart_DeferredLoadCompleteError. It is
3429 * recommended that the loading occur asynchronously, but it is permitted to
3430 * call Dart_DeferredLoadComplete or Dart_DeferredLoadCompleteError before the
3431 * handler returns.
3432 *
3433 * If an error is returned, it will be propagated through
3434 * `prefix.loadLibrary()`. This is useful for synchronous
3435 * implementations, which must propagate any unwind errors from
3436 * Dart_DeferredLoadComplete or Dart_DeferredLoadComplete. Otherwise the handler
3437 * should return a non-error such as `Dart_Null()`.
3438 */
3439typedef Dart_Handle (*Dart_DeferredLoadHandler)(intptr_t loading_unit_id);
3440
3441/**
3442 * Sets the deferred load handler for the current isolate. This handler is
3443 * used to handle loading deferred imports in an AppJIT or AppAOT program.
3444 */
3447
3448/**
3449 * Notifies the VM that a deferred load completed successfully. This function
3450 * will eventually cause the corresponding `prefix.loadLibrary()` futures to
3451 * complete.
3452 *
3453 * Requires the current isolate to be the same current isolate during the
3454 * invocation of the Dart_DeferredLoadHandler.
3455 */
3457Dart_DeferredLoadComplete(intptr_t loading_unit_id,
3458 const uint8_t* snapshot_data,
3459 const uint8_t* snapshot_instructions);
3460
3461/**
3462 * Notifies the VM that a deferred load failed. This function
3463 * will eventually cause the corresponding `prefix.loadLibrary()` futures to
3464 * complete with an error.
3465 *
3466 * If `transient` is true, future invocations of `prefix.loadLibrary()` will
3467 * trigger new load requests. If false, futures invocation will complete with
3468 * the same error.
3469 *
3470 * Requires the current isolate to be the same current isolate during the
3471 * invocation of the Dart_DeferredLoadHandler.
3472 */
3474Dart_DeferredLoadCompleteError(intptr_t loading_unit_id,
3475 const char* error_message,
3476 bool transient);
3477
3478/**
3479 * Canonicalizes a url with respect to some library.
3480 *
3481 * The url is resolved with respect to the library's url and some url
3482 * normalizations are performed.
3483 *
3484 * This canonicalization function should be sufficient for most
3485 * embedders to implement the Dart_kCanonicalizeUrl tag.
3486 *
3487 * \param base_url The base url relative to which the url is
3488 * being resolved.
3489 * \param url The url being resolved and canonicalized. This
3490 * parameter is a string handle.
3491 *
3492 * \return If no error occurs, a String object is returned. Otherwise
3493 * an error handle is returned.
3494 */
3496 Dart_Handle url);
3497
3498/**
3499 * Loads the root library for the current isolate.
3500 *
3501 * Requires there to be no current root library.
3502 *
3503 * \param kernel_buffer A buffer which contains a kernel binary (see
3504 * pkg/kernel/binary.md). Must remain valid until isolate group shutdown.
3505 * \param kernel_size Length of the passed in buffer.
3506 *
3507 * \return A handle to the root library, or an error.
3508 */
3510Dart_LoadScriptFromKernel(const uint8_t* kernel_buffer, intptr_t kernel_size);
3511
3512/**
3513 * Gets the library for the root script for the current isolate.
3514 *
3515 * If the root script has not yet been set for the current isolate,
3516 * this function returns Dart_Null(). This function never returns an
3517 * error handle.
3518 *
3519 * \return Returns the root Library for the current isolate or Dart_Null().
3520 */
3522
3523/**
3524 * Sets the root library for the current isolate.
3525 *
3526 * \return Returns an error handle if `library` is not a library handle.
3527 */
3529
3530/**
3531 * Lookup or instantiate a legacy type by name and type arguments from a
3532 * Library.
3533 *
3534 * \param library The library containing the class or interface.
3535 * \param class_name The class name for the type.
3536 * \param number_of_type_arguments Number of type arguments.
3537 * For non parametric types the number of type arguments would be 0.
3538 * \param type_arguments Pointer to an array of type arguments.
3539 * For non parametric types a NULL would be passed in for this argument.
3540 *
3541 * \return If no error occurs, the type is returned.
3542 * Otherwise an error handle is returned.
3543 */
3545 Dart_Handle class_name,
3546 intptr_t number_of_type_arguments,
3547 Dart_Handle* type_arguments);
3548
3549/**
3550 * Lookup or instantiate a nullable type by name and type arguments from
3551 * Library.
3552 *
3553 * \param library The library containing the class or interface.
3554 * \param class_name The class name for the type.
3555 * \param number_of_type_arguments Number of type arguments.
3556 * For non parametric types the number of type arguments would be 0.
3557 * \param type_arguments Pointer to an array of type arguments.
3558 * For non parametric types a NULL would be passed in for this argument.
3559 *
3560 * \return If no error occurs, the type is returned.
3561 * Otherwise an error handle is returned.
3562 */
3564 Dart_Handle class_name,
3565 intptr_t number_of_type_arguments,
3566 Dart_Handle* type_arguments);
3567
3568/**
3569 * Lookup or instantiate a non-nullable type by name and type arguments from
3570 * Library.
3571 *
3572 * \param library The library containing the class or interface.
3573 * \param class_name The class name for the type.
3574 * \param number_of_type_arguments Number of type arguments.
3575 * For non parametric types the number of type arguments would be 0.
3576 * \param type_arguments Pointer to an array of type arguments.
3577 * For non parametric types a NULL would be passed in for this argument.
3578 *
3579 * \return If no error occurs, the type is returned.
3580 * Otherwise an error handle is returned.
3581 */
3584 Dart_Handle class_name,
3585 intptr_t number_of_type_arguments,
3586 Dart_Handle* type_arguments);
3587
3588/**
3589 * Creates a nullable version of the provided type.
3590 *
3591 * \param type The type to be converted to a nullable type.
3592 *
3593 * \return If no error occurs, a nullable type is returned.
3594 * Otherwise an error handle is returned.
3595 */
3597
3598/**
3599 * Creates a non-nullable version of the provided type.
3600 *
3601 * \param type The type to be converted to a non-nullable type.
3602 *
3603 * \return If no error occurs, a non-nullable type is returned.
3604 * Otherwise an error handle is returned.
3605 */
3607
3608/**
3609 * A type's nullability.
3610 *
3611 * \param type A Dart type.
3612 * \param result An out parameter containing the result of the check. True if
3613 * the type is of the specified nullability, false otherwise.
3614 *
3615 * \return Returns an error handle if type is not of type Type.
3616 */
3620
3621/**
3622 * Lookup a class or interface by name from a Library.
3623 *
3624 * \param library The library containing the class or interface.
3625 * \param class_name The name of the class or interface.
3626 *
3627 * \return If no error occurs, the class or interface is
3628 * returned. Otherwise an error handle is returned.
3629 */
3631 Dart_Handle class_name);
3632/* TODO(asiva): The above method needs to be removed once all uses
3633 * of it are removed from the embedder code. */
3634
3635/**
3636 * Returns an import path to a Library, such as "file:///test.dart" or
3637 * "dart:core".
3638 */
3640
3641/**
3642 * Returns a URL from which a Library was loaded.
3643 */
3645
3646/**
3647 * \return An array of libraries.
3648 */
3650
3652/* TODO(turnidge): Consider returning Dart_Null() when the library is
3653 * not found to distinguish that from a true error case. */
3654
3655/**
3656 * Report an loading error for the library.
3657 *
3658 * \param library The library that failed to load.
3659 * \param error The Dart error instance containing the load error.
3660 *
3661 * \return If the VM handles the error, the return value is
3662 * a null handle. If it doesn't handle the error, the error
3663 * object is returned.
3664 */
3667
3668/**
3669 * Called by the embedder to load a partial program. Does not set the root
3670 * library.
3671 *
3672 * \param kernel_buffer A buffer which contains a kernel binary (see
3673 * pkg/kernel/binary.md). Must remain valid until isolate shutdown.
3674 * \param kernel_buffer_size Length of the passed in buffer.
3675 *
3676 * \return A handle to the main library of the compilation unit, or an error.
3677 */
3679Dart_LoadLibraryFromKernel(const uint8_t* kernel_buffer,
3680 intptr_t kernel_buffer_size);
3683
3684/**
3685 * Indicates that all outstanding load requests have been satisfied.
3686 * This finalizes all the new classes loaded and optionally completes
3687 * deferred library futures.
3688 *
3689 * Requires there to be a current isolate.
3690 *
3691 * \param complete_futures Specify true if all deferred library
3692 * futures should be completed, false otherwise.
3693 *
3694 * \return Success if all classes have been finalized and deferred library
3695 * futures are completed. Otherwise, returns an error.
3696 */
3698Dart_FinalizeLoading(bool complete_futures);
3699
3700/*
3701 * =====
3702 * Peers
3703 * =====
3704 */
3705
3706/**
3707 * The peer field is a lazily allocated field intended for storage of
3708 * an uncommonly used values. Most instances types can have a peer
3709 * field allocated. The exceptions are subtypes of Null, num, and
3710 * bool.
3711 */
3712
3713/**
3714 * Returns the value of peer field of 'object' in 'peer'.
3715 *
3716 * \param object An object.
3717 * \param peer An out parameter that returns the value of the peer
3718 * field.
3719 *
3720 * \return Returns an error if 'object' is a subtype of Null, num, or
3721 * bool.
3722 */
3724
3725/**
3726 * Sets the value of the peer field of 'object' to the value of
3727 * 'peer'.
3728 *
3729 * \param object An object.
3730 * \param peer A value to store in the peer field.
3731 *
3732 * \return Returns an error if 'object' is a subtype of Null, num, or
3733 * bool.
3734 */
3736
3737/*
3738 * ======
3739 * Kernel
3740 * ======
3741 */
3742
3743/**
3744 * Experimental support for Dart to Kernel parser isolate.
3745 *
3746 * TODO(hausner): Document finalized interface.
3747 *
3748 */
3749
3750// TODO(33433): Remove kernel service from the embedding API.
3751
3752typedef enum {
3759
3760typedef struct {
3763 char* error;
3764 uint8_t* kernel;
3765 intptr_t kernel_size;
3767
3768typedef enum {
3774
3778
3779/**
3780 * Compiles the given `script_uri` to a kernel file.
3781 *
3782 * \param platform_kernel A buffer containing the kernel of the platform (e.g.
3783 * `vm_platform_strong.dill`). The VM does not take ownership of this memory.
3784 *
3785 * \param platform_kernel_size The length of the platform_kernel buffer.
3786 *
3787 * \param snapshot_compile Set to `true` when the compilation is for a snapshot.
3788 * This is used by the frontend to determine if compilation related information
3789 * should be printed to console (e.g., null safety mode).
3790 *
3791 * \param embed_sources Set to `true` when sources should be embedded in the
3792 * kernel file.
3793 *
3794 * \param verbosity Specifies the logging behavior of the kernel compilation
3795 * service.
3796 *
3797 * \return Returns the result of the compilation.
3798 *
3799 * On a successful compilation the returned [Dart_KernelCompilationResult] has
3800 * a status of [Dart_KernelCompilationStatus_Ok] and the `kernel`/`kernel_size`
3801 * fields are set. The caller takes ownership of the malloc()ed buffer.
3802 *
3803 * On a failed compilation the `error` might be set describing the reason for
3804 * the failed compilation. The caller takes ownership of the malloc()ed
3805 * error.
3806 *
3807 * Requires there to be a current isolate.
3808 */
3810Dart_CompileToKernel(const char* script_uri,
3811 const uint8_t* platform_kernel,
3812 const intptr_t platform_kernel_size,
3813 bool incremental_compile,
3814 bool snapshot_compile,
3815 bool embed_sources,
3816 const char* package_config,
3818
3819typedef struct {
3820 const char* uri;
3821 const char* source;
3823
3825
3826/**
3827 * Sets the kernel buffer which will be used to load Dart SDK sources
3828 * dynamically at runtime.
3829 *
3830 * \param platform_kernel A buffer containing kernel which has sources for the
3831 * Dart SDK populated. Note: The VM does not take ownership of this memory.
3832 *
3833 * \param platform_kernel_size The length of the platform_kernel buffer.
3834 */
3836 const uint8_t* platform_kernel,
3837 const intptr_t platform_kernel_size);
3838
3839/**
3840 * Detect the null safety opt-in status.
3841 *
3842 * When running from source, it is based on the opt-in status of `script_uri`.
3843 * When running from a kernel buffer, it is based on the mode used when
3844 * generating `kernel_buffer`.
3845 * When running from an appJIT or AOT snapshot, it is based on the mode used
3846 * when generating `snapshot_data`.
3847 *
3848 * \param script_uri Uri of the script that contains the source code
3849 *
3850 * \param package_config Uri of the package configuration file (either in format
3851 * of .packages or .dart_tool/package_config.json) for the null safety
3852 * detection to resolve package imports against. If this parameter is not
3853 * passed the package resolution of the parent isolate should be used.
3854 *
3855 * \param original_working_directory current working directory when the VM
3856 * process was launched, this is used to correctly resolve the path specified
3857 * for package_config.
3858 *
3859 * \param snapshot_data Buffer containing the snapshot data of the
3860 * isolate or NULL if no snapshot is provided. If provided, the buffers must
3861 * remain valid until the isolate shuts down.
3862 *
3863 * \param snapshot_instructions Buffer containing the snapshot instructions of
3864 * the isolate or NULL if no snapshot is provided. If provided, the buffers
3865 * must remain valid until the isolate shuts down.
3866 *
3867 * \param kernel_buffer A buffer which contains a kernel/DIL program. Must
3868 * remain valid until isolate shutdown.
3869 *
3870 * \param kernel_buffer_size The size of `kernel_buffer`.
3871 *
3872 * \return Returns true if the null safety is opted in by the input being
3873 * run `script_uri`, `snapshot_data` or `kernel_buffer`.
3874 *
3875 */
3876DART_EXPORT bool Dart_DetectNullSafety(const char* script_uri,
3877 const char* package_config,
3878 const char* original_working_directory,
3879 const uint8_t* snapshot_data,
3880 const uint8_t* snapshot_instructions,
3881 const uint8_t* kernel_buffer,
3882 intptr_t kernel_buffer_size);
3883
3884#define DART_KERNEL_ISOLATE_NAME "kernel-service"
3885
3886/*
3887 * =======
3888 * Service
3889 * =======
3890 */
3891
3892#define DART_VM_SERVICE_ISOLATE_NAME "vm-service"
3893
3894/**
3895 * Returns true if isolate is the service isolate.
3896 *
3897 * \param isolate An isolate
3898 *
3899 * \return Returns true if 'isolate' is the service isolate.
3900 */
3902
3903/**
3904 * Writes the CPU profile to the timeline as a series of 'instant' events.
3905 *
3906 * Note that this is an expensive operation.
3907 *
3908 * \param main_port The main port of the Isolate whose profile samples to write.
3909 * \param error An optional error, must be free()ed by caller.
3910 *
3911 * \return Returns true if the profile is successfully written and false
3912 * otherwise.
3913 */
3915
3916/*
3917 * ==============
3918 * Precompilation
3919 * ==============
3920 */
3921
3922/**
3923 * Compiles all functions reachable from entry points and marks
3924 * the isolate to disallow future compilation.
3925 *
3926 * Entry points should be specified using `@pragma("vm:entry-point")`
3927 * annotation.
3928 *
3929 * \return An error handle if a compilation error or runtime error running const
3930 * constructors was encountered.
3931 */
3933
3935 void* callback_data,
3936 intptr_t loading_unit_id,
3937 void** write_callback_data,
3938 void** write_debug_callback_data);
3939typedef void (*Dart_StreamingWriteCallback)(void* callback_data,
3940 const uint8_t* buffer,
3941 intptr_t size);
3942typedef void (*Dart_StreamingCloseCallback)(void* callback_data);
3943
3945
3946// On Darwin systems, 'dlsym' adds an '_' to the beginning of the symbol name.
3947// Use the '...CSymbol' definitions for resolving through 'dlsym'. The actual
3948// symbol names in the objects are given by the '...AsmSymbol' definitions.
3949#if defined(__APPLE__)
3950#define kSnapshotBuildIdCSymbol "kDartSnapshotBuildId"
3951#define kVmSnapshotDataCSymbol "kDartVmSnapshotData"
3952#define kVmSnapshotInstructionsCSymbol "kDartVmSnapshotInstructions"
3953#define kVmSnapshotBssCSymbol "kDartVmSnapshotBss"
3954#define kIsolateSnapshotDataCSymbol "kDartIsolateSnapshotData"
3955#define kIsolateSnapshotInstructionsCSymbol "kDartIsolateSnapshotInstructions"
3956#define kIsolateSnapshotBssCSymbol "kDartIsolateSnapshotBss"
3957#else
3958#define kSnapshotBuildIdCSymbol "_kDartSnapshotBuildId"
3959#define kVmSnapshotDataCSymbol "_kDartVmSnapshotData"
3960#define kVmSnapshotInstructionsCSymbol "_kDartVmSnapshotInstructions"
3961#define kVmSnapshotBssCSymbol "_kDartVmSnapshotBss"
3962#define kIsolateSnapshotDataCSymbol "_kDartIsolateSnapshotData"
3963#define kIsolateSnapshotInstructionsCSymbol "_kDartIsolateSnapshotInstructions"
3964#define kIsolateSnapshotBssCSymbol "_kDartIsolateSnapshotBss"
3965#endif
3966
3967#define kSnapshotBuildIdAsmSymbol "_kDartSnapshotBuildId"
3968#define kVmSnapshotDataAsmSymbol "_kDartVmSnapshotData"
3969#define kVmSnapshotInstructionsAsmSymbol "_kDartVmSnapshotInstructions"
3970#define kVmSnapshotBssAsmSymbol "_kDartVmSnapshotBss"
3971#define kIsolateSnapshotDataAsmSymbol "_kDartIsolateSnapshotData"
3972#define kIsolateSnapshotInstructionsAsmSymbol \
3973 "_kDartIsolateSnapshotInstructions"
3974#define kIsolateSnapshotBssAsmSymbol "_kDartIsolateSnapshotBss"
3975
3976/**
3977 * Creates a precompiled snapshot.
3978 * - A root library must have been loaded.
3979 * - Dart_Precompile must have been called.
3980 *
3981 * Outputs an assembly file defining the symbols listed in the definitions
3982 * above.
3983 *
3984 * The assembly should be compiled as a static or shared library and linked or
3985 * loaded by the embedder. Running this snapshot requires a VM compiled with
3986 * DART_PRECOMPILED_SNAPSHOT. The kDartVmSnapshotData and
3987 * kDartVmSnapshotInstructions should be passed to Dart_Initialize. The
3988 * kDartIsolateSnapshotData and kDartIsolateSnapshotInstructions should be
3989 * passed to Dart_CreateIsolateGroup.
3990 *
3991 * The callback will be invoked one or more times to provide the assembly code.
3992 *
3993 * If stripped is true, then the assembly code will not include DWARF
3994 * debugging sections.
3995 *
3996 * If debug_callback_data is provided, debug_callback_data will be used with
3997 * the callback to provide separate debugging information.
3998 *
3999 * \return A valid handle if no error occurs during the operation.
4000 */
4003 void* callback_data,
4004 bool stripped,
4005 void* debug_callback_data);
4008 Dart_CreateLoadingUnitCallback next_callback,
4009 void* next_callback_data,
4010 bool stripped,
4011 Dart_StreamingWriteCallback write_callback,
4012 Dart_StreamingCloseCallback close_callback);
4013
4014/**
4015 * Creates a precompiled snapshot.
4016 * - A root library must have been loaded.
4017 * - Dart_Precompile must have been called.
4018 *
4019 * Outputs an ELF shared library defining the symbols
4020 * - _kDartVmSnapshotData
4021 * - _kDartVmSnapshotInstructions
4022 * - _kDartIsolateSnapshotData
4023 * - _kDartIsolateSnapshotInstructions
4024 *
4025 * The shared library should be dynamically loaded by the embedder.
4026 * Running this snapshot requires a VM compiled with DART_PRECOMPILED_SNAPSHOT.
4027 * The kDartVmSnapshotData and kDartVmSnapshotInstructions should be passed to
4028 * Dart_Initialize. The kDartIsolateSnapshotData and
4029 * kDartIsolateSnapshotInstructions should be passed to Dart_CreateIsolate.
4030 *
4031 * The callback will be invoked one or more times to provide the binary output.
4032 *
4033 * If stripped is true, then the binary output will not include DWARF
4034 * debugging sections.
4035 *
4036 * If debug_callback_data is provided, debug_callback_data will be used with
4037 * the callback to provide separate debugging information.
4038 *
4039 * \return A valid handle if no error occurs during the operation.
4040 */
4043 void* callback_data,
4044 bool stripped,
4045 void* debug_callback_data);
4048 void* next_callback_data,
4049 bool stripped,
4050 Dart_StreamingWriteCallback write_callback,
4051 Dart_StreamingCloseCallback close_callback);
4052
4053/**
4054 * Like Dart_CreateAppAOTSnapshotAsAssembly, but only includes
4055 * kDartVmSnapshotData and kDartVmSnapshotInstructions. It also does
4056 * not strip DWARF information from the generated assembly or allow for
4057 * separate debug information.
4058 */
4061 void* callback_data);
4062
4063/**
4064 * Sorts the class-ids in depth first traversal order of the inheritance
4065 * tree. This is a costly operation, but it can make method dispatch
4066 * more efficient and is done before writing snapshots.
4067 *
4068 * \return A valid handle if no error occurs during the operation.
4069 */
4071
4072/**
4073 * Creates a snapshot that caches compiled code and type feedback for faster
4074 * startup and quicker warmup in a subsequent process.
4075 *
4076 * Outputs a snapshot in two pieces. The pieces should be passed to
4077 * Dart_CreateIsolateGroup in a VM using the same VM snapshot pieces used in the
4078 * current VM. The instructions piece must be loaded with read and execute
4079 * permissions; the data piece may be loaded as read-only.
4080 *
4081 * - Requires the VM to have not been started with --precompilation.
4082 * - Not supported when targeting IA32.
4083 * - The VM writing the snapshot and the VM reading the snapshot must be the
4084 * same version, must be built in the same DEBUG/RELEASE/PRODUCT mode, must
4085 * be targeting the same architecture, and must both be in checked mode or
4086 * both in unchecked mode.
4087 *
4088 * The buffers are scope allocated and are only valid until the next call to
4089 * Dart_ExitScope.
4090 *
4091 * \return A valid handle if no error occurs during the operation.
4092 */
4094Dart_CreateAppJITSnapshotAsBlobs(uint8_t** isolate_snapshot_data_buffer,
4095 intptr_t* isolate_snapshot_data_size,
4096 uint8_t** isolate_snapshot_instructions_buffer,
4097 intptr_t* isolate_snapshot_instructions_size);
4098
4099/**
4100 * Like Dart_CreateAppJITSnapshotAsBlobs, but also creates a new VM snapshot.
4101 */
4104 uint8_t** vm_snapshot_data_buffer,
4105 intptr_t* vm_snapshot_data_size,
4106 uint8_t** vm_snapshot_instructions_buffer,
4107 intptr_t* vm_snapshot_instructions_size,
4108 uint8_t** isolate_snapshot_data_buffer,
4109 intptr_t* isolate_snapshot_data_size,
4110 uint8_t** isolate_snapshot_instructions_buffer,
4111 intptr_t* isolate_snapshot_instructions_size);
4112
4113/**
4114 * Get obfuscation map for precompiled code.
4115 *
4116 * Obfuscation map is encoded as a JSON array of pairs (original name,
4117 * obfuscated name).
4118 *
4119 * \return Returns an error handler if the VM was built in a mode that does not
4120 * support obfuscation.
4121 */
4123Dart_GetObfuscationMap(uint8_t** buffer, intptr_t* buffer_length);
4124
4125/**
4126 * Returns whether the VM only supports running from precompiled snapshots and
4127 * not from any other kind of snapshot or from source (that is, the VM was
4128 * compiled with DART_PRECOMPILED_RUNTIME).
4129 */
4131
4132/**
4133 * Print a native stack trace. Used for crash handling.
4134 *
4135 * If context is NULL, prints the current stack trace. Otherwise, context
4136 * should be a CONTEXT* (Windows) or ucontext_t* (POSIX) from a signal handler
4137 * running on the current thread.
4138 */
4140
4141/**
4142 * Indicate that the process is about to abort, and the Dart VM should not
4143 * attempt to cleanup resources.
4144 */
4146
4147/**
4148 * Callback provided by the embedder that is used by the VM to
4149 * produce footnotes appended to DWARF stack traces.
4150 *
4151 * Whenever VM formats a stack trace as a string it would call this callback
4152 * passing raw program counters for each frame in the stack trace.
4153 *
4154 * Embedder can then return a string which if not-null will be appended to the
4155 * formatted stack trace.
4156 *
4157 * Returned string is expected to be `malloc()` allocated. VM takes ownership
4158 * of the returned string and will `free()` it.
4159 *
4160 * \param addresses raw program counter addresses for each frame
4161 * \param count number of elements in the addresses array
4162 */
4163typedef char* (*Dart_DwarfStackTraceFootnoteCallback)(void* addresses[],
4164 intptr_t count);
4165
4166/**
4167 * Configure DWARF stack trace footnote callback.
4168 */
4171
4172#endif /* INCLUDE_DART_API_H_ */ /* NOLINT */
int count
Definition: FontMgrTest.cpp:49
static uint32_t buffer_size(uint32_t offset, uint32_t maxAlignment)
static bool equal(const SkBitmap &a, const SkBitmap &b)
Definition: ImageTest.cpp:1386
DART_EXPORT void Dart_SetPausedOnExit(bool paused)
DART_EXPORT Dart_Handle Dart_ListSetAsBytes(Dart_Handle list, intptr_t offset, const uint8_t *native_array, intptr_t length)
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)
DART_EXPORT Dart_Handle Dart_HandleFromPersistent(Dart_PersistentHandle object)
DART_EXPORT Dart_Handle Dart_StringToUTF16(Dart_Handle str, uint16_t *utf16_array, intptr_t *length)
DART_EXPORT Dart_Handle Dart_StringLength(Dart_Handle str, intptr_t *length)
DART_EXPORT void Dart_IsolateFlagsInitialize(Dart_IsolateFlags *flags)
DART_EXPORT bool Dart_IsInteger(Dart_Handle object)
DART_EXPORT Dart_Handle Dart_TypeNever(void)
DART_EXPORT void * Dart_CurrentIsolateData(void)
DART_EXPORT Dart_Handle Dart_FunctionIsStatic(Dart_Handle function, bool *is_static)
DART_EXPORT Dart_TypedData_Type Dart_GetTypeOfExternalTypedData(Dart_Handle object)
Dart_CoreType_Id
Definition: dart_api.h:2449
@ Dart_CoreType_Dynamic
Definition: dart_api.h:2450
@ Dart_CoreType_Int
Definition: dart_api.h:2451
@ Dart_CoreType_String
Definition: dart_api.h:2452
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_CreateCoreJITSnapshotAsBlobs(uint8_t **vm_snapshot_data_buffer, intptr_t *vm_snapshot_data_size, uint8_t **vm_snapshot_instructions_buffer, intptr_t *vm_snapshot_instructions_size, uint8_t **isolate_snapshot_data_buffer, intptr_t *isolate_snapshot_data_size, uint8_t **isolate_snapshot_instructions_buffer, intptr_t *isolate_snapshot_instructions_size)
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_CreateAppAOTSnapshotAsElf(Dart_StreamingWriteCallback callback, void *callback_data, bool stripped, void *debug_callback_data)
void(* Dart_UnregisterKernelBlobCallback)(const char *kernel_blob_uri)
Definition: dart_api.h:893
DART_EXPORT Dart_Handle Dart_NewDouble(double value)
DART_EXPORT void Dart_SetIntegerReturnValue(Dart_NativeArguments args, int64_t retval)
DART_EXPORT Dart_Handle Dart_GetNonNullableType(Dart_Handle library, Dart_Handle class_name, intptr_t number_of_type_arguments, Dart_Handle *type_arguments)
DART_EXPORT Dart_Handle Dart_GetType(Dart_Handle library, Dart_Handle class_name, intptr_t number_of_type_arguments, Dart_Handle *type_arguments)
DART_EXPORT Dart_Port Dart_KernelPort(void)
DART_EXPORT void Dart_DisableHeapSampling(void)
DART_EXPORT void Dart_SetPausedOnStart(bool paused)
Dart_Handle(* Dart_EnvironmentCallback)(Dart_Handle name)
Definition: dart_api.h:3295
DART_EXPORT Dart_Handle Dart_SetFfiNativeResolver(Dart_Handle library, Dart_FfiNativeResolver resolver)
void(* Dart_StreamingWriteCallback)(void *callback_data, const uint8_t *buffer, intptr_t size)
Definition: dart_api.h:3939
DART_EXPORT void Dart_StartProfiling(void)
DART_EXPORT Dart_FinalizableHandle Dart_NewFinalizableHandle(Dart_Handle object, void *peer, intptr_t external_allocation_size, Dart_HandleFinalizer callback)
DART_EXPORT DART_WARN_UNUSED_RESULT char * Dart_IsolateMakeRunnable(Dart_Isolate isolate)
DART_EXPORT void Dart_PrepareToAbort(void)
void(* Dart_FileWriteCallback)(const void *data, intptr_t length, void *stream)
Definition: dart_api.h:806
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)
Definition: dart_api.h:653
DART_EXPORT Dart_Handle Dart_SetNativeResolver(Dart_Handle library, Dart_NativeEntryResolver resolver, Dart_NativeEntrySymbol symbol)
DART_EXPORT Dart_Handle Dart_IsNullableType(Dart_Handle type, bool *result)
Dart_KernelCompilationStatus
Definition: dart_api.h:3752
@ Dart_KernelCompilationStatus_MsgFailed
Definition: dart_api.h:3757
@ Dart_KernelCompilationStatus_Error
Definition: dart_api.h:3755
@ Dart_KernelCompilationStatus_Crash
Definition: dart_api.h:3756
@ Dart_KernelCompilationStatus_Unknown
Definition: dart_api.h:3753
@ Dart_KernelCompilationStatus_Ok
Definition: dart_api.h:3754
DART_EXPORT Dart_Handle Dart_ListGetRange(Dart_Handle list, intptr_t offset, intptr_t length, Dart_Handle *result)
DART_EXPORT Dart_Handle Dart_GetNativeResolver(Dart_Handle library, Dart_NativeEntryResolver *resolver)
DART_EXPORT Dart_Handle Dart_NewStringFromUTF8(const uint8_t *utf8_array, intptr_t length)
DART_EXPORT void Dart_ThreadDisableProfiling(void)
DART_EXPORT void Dart_StopProfiling(void)
DART_EXPORT bool Dart_IsBoolean(Dart_Handle object)
void(* Dart_IsolateCleanupCallback)(void *isolate_group_data, void *isolate_data)
Definition: dart_api.h:728
DART_EXPORT Dart_Handle Dart_FunctionOwner(Dart_Handle function)
DART_EXPORT bool Dart_WriteProfileToTimeline(Dart_Port main_port, char **error)
DART_EXPORT bool Dart_HandleServiceMessages(void)
DART_EXPORT void Dart_EnterScope(void)
void(* Dart_FileCloseCallback)(void *stream)
Definition: dart_api.h:819
DART_EXPORT void Dart_ExitScope(void)
DART_EXPORT Dart_Handle Dart_NewSendPort(Dart_Port port_id)
DART_EXPORT Dart_Handle Dart_TypeVoid(void)
DART_EXPORT bool Dart_IsInstance(Dart_Handle object)
DART_EXPORT Dart_Handle Dart_IntegerToInt64(Dart_Handle integer, int64_t *value)
DART_EXPORT bool Dart_IsStringLatin1(Dart_Handle object)
DART_EXPORT bool Dart_IsNumber(Dart_Handle object)
DART_EXPORT Dart_KernelCompilationResult Dart_KernelListDependencies(void)
DART_EXPORT Dart_Handle Dart_NewExternalTypedData(Dart_TypedData_Type type, void *data, intptr_t length)
Dart_PerformanceMode
Definition: dart_api.h:1369
@ Dart_PerformanceMode_Default
Definition: dart_api.h:1373
@ Dart_PerformanceMode_Latency
Definition: dart_api.h:1380
@ Dart_PerformanceMode_Memory
Definition: dart_api.h:1390
@ Dart_PerformanceMode_Throughput
Definition: dart_api.h:1385
DART_EXPORT void Dart_DumpNativeStackTrace(void *context)
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_Allocate(Dart_Handle type)
DART_EXPORT const char * Dart_VersionString(void)
DART_EXPORT bool Dart_HasServiceMessages(void)
DART_EXPORT Dart_Handle Dart_SetDeferredLoadHandler(Dart_DeferredLoadHandler handler)
DART_EXPORT const char * Dart_DebugNameToCString(void)
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)
int64_t Dart_Port
Definition: dart_api.h:1525
DART_EXPORT Dart_Handle Dart_GetStaticMethodClosure(Dart_Handle library, Dart_Handle cls_type, Dart_Handle function_name)
DART_EXPORT Dart_Handle Dart_NewExternalUTF16String(const uint16_t *utf16_array, intptr_t length, void *peer, intptr_t external_allocation_size, Dart_HandleFinalizer callback)
DART_EXPORT Dart_Handle Dart_ErrorGetStackTrace(Dart_Handle handle)
void(* Dart_MessageNotifyCallback)(Dart_Isolate destination_isolate)
Definition: dart_api.h:1542
DART_EXPORT Dart_Handle Dart_MapKeys(Dart_Handle map)
DART_EXPORT void Dart_ShutdownIsolate(void)
DART_EXPORT Dart_Handle Dart_NewListOfTypeFilled(Dart_Handle element_type, Dart_Handle fill_object, intptr_t length)
void(* Dart_FileReadCallback)(uint8_t **data, intptr_t *file_length, void *stream)
Definition: dart_api.h:791
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 void Dart_KillIsolate(Dart_Isolate isolate)
DART_EXPORT Dart_Handle Dart_StringStorageSize(Dart_Handle str, intptr_t *size)
DART_EXPORT bool Dart_ShouldPauseOnExit(void)
DART_EXPORT bool Dart_IsApiError(Dart_Handle handle)
struct _Dart_Handle * Dart_Handle
Definition: dart_api.h:258
DART_EXPORT bool Dart_IsPausedOnExit(void)
DART_EXPORT Dart_Handle Dart_TypeToNonNullableType(Dart_Handle type)
DART_EXPORT Dart_Handle Dart_TypedDataReleaseData(Dart_Handle object)
const char *(* Dart_RegisterKernelBlobCallback)(const uint8_t *kernel_buffer, intptr_t kernel_buffer_size)
Definition: dart_api.h:881
DART_EXPORT Dart_Handle Dart_ClassName(Dart_Handle cls_type)
bool(* Dart_EntropySource)(uint8_t *buffer, intptr_t length)
Definition: dart_api.h:821
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_CreateVMAOTSnapshotAsAssembly(Dart_StreamingWriteCallback callback, void *callback_data)
DART_EXPORT void Dart_ThreadEnableProfiling(void)
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_CreateAppAOTSnapshotAsAssembly(Dart_StreamingWriteCallback callback, void *callback_data, bool stripped, void *debug_callback_data)
#define DART_WARN_UNUSED_RESULT
Definition: dart_api.h:66
DART_EXPORT bool Dart_IsFunction(Dart_Handle handle)
DART_EXPORT bool Dart_IsTypeVariable(Dart_Handle handle)
DART_EXPORT void Dart_PropagateError(Dart_Handle handle)
DART_EXPORT bool Dart_IsByteBuffer(Dart_Handle object)
DART_EXPORT Dart_Handle Dart_True(void)
DART_EXPORT Dart_Handle Dart_NewStringFromUTF32(const int32_t *utf32_array, intptr_t length)
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_Invoke(Dart_Handle target, Dart_Handle name, int number_of_arguments, Dart_Handle *arguments)
DART_EXPORT bool Dart_IsPausedOnStart(void)
DART_EXPORT Dart_PersistentHandle Dart_NewPersistentHandle(Dart_Handle object)
DART_EXPORT void Dart_SetHeapSamplingPeriod(intptr_t bytes)
DART_EXPORT bool Dart_IsVMFlagSet(const char *flag_name)
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)
DART_EXPORT Dart_Handle Dart_GetDataFromByteBuffer(Dart_Handle byte_buffer)
struct _Dart_Isolate * Dart_Isolate
Definition: dart_api.h:88
DART_EXPORT Dart_Handle Dart_FunctionName(Dart_Handle function)
Dart_NativeFunction(* Dart_NativeEntryResolver)(Dart_Handle name, int num_of_arguments, bool *auto_setup_scope)
Definition: dart_api.h:3251
DART_EXPORT Dart_Handle Dart_DebugName(void)
DART_EXPORT Dart_Handle Dart_ReThrowException(Dart_Handle exception, Dart_Handle stacktrace)
DART_EXPORT void Dart_SetDoubleReturnValue(Dart_NativeArguments args, double retval)
DART_EXPORT bool Dart_IsPrecompiledRuntime(void)
void(* Dart_StreamingCloseCallback)(void *callback_data)
Definition: dart_api.h:3942
void(* Dart_HandleFinalizer)(void *isolate_callback_data, void *peer)
Definition: dart_api.h:265
void(* Dart_ThreadStartCallback)(void)
Definition: dart_api.h:753
DART_EXPORT Dart_Handle Dart_GetNativeArgument(Dart_NativeArguments args, int index)
DART_EXPORT bool Dart_IsFatalError(Dart_Handle handle)
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_InvokeClosure(Dart_Handle closure, int number_of_arguments, Dart_Handle *arguments)
DART_EXPORT Dart_Handle Dart_EmptyString(void)
DART_EXPORT Dart_Handle Dart_ListGetAsBytes(Dart_Handle list, intptr_t offset, uint8_t *native_array, intptr_t length)
struct _Dart_IsolateGroup * Dart_IsolateGroup
Definition: dart_api.h:89
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)
DART_EXPORT Dart_Handle Dart_NewListOf(Dart_CoreType_Id element_type_id, intptr_t length)
const uint8_t *(* Dart_NativeEntrySymbol)(Dart_NativeFunction nf)
Definition: dart_api.h:3272
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_LoadLibraryFromKernel(const uint8_t *kernel_buffer, intptr_t kernel_buffer_size)
DART_EXPORT Dart_Handle Dart_AllocateWithNativeFields(Dart_Handle type, intptr_t num_native_fields, const intptr_t *native_fields)
DART_EXPORT bool Dart_HasStickyError(void)
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)
DART_EXPORT Dart_Handle Dart_NewIntegerFromUint64(uint64_t value)
DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url)
DART_EXPORT Dart_Handle Dart_GetNativeInstanceField(Dart_Handle obj, int index, intptr_t *value)
void *(* Dart_FfiNativeResolver)(const char *name, uintptr_t args_n)
Definition: dart_api.h:3279
DART_EXPORT Dart_Handle Dart_TypedDataAcquireData(Dart_Handle object, Dart_TypedData_Type *type, void **data, intptr_t *len)
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_SortClasses(void)
DART_EXPORT Dart_Handle Dart_IsLegacyType(Dart_Handle type, bool *result)
DART_EXPORT Dart_Handle Dart_ThrowException(Dart_Handle exception)
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_FinalizeLoading(bool complete_futures)
DART_EXPORT Dart_Handle Dart_IntegerToHexCString(Dart_Handle integer, const char **value)
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_InvokeConstructor(Dart_Handle object, Dart_Handle name, int number_of_arguments, Dart_Handle *arguments)
DART_EXPORT Dart_Handle Dart_GetNativeInstanceFieldCount(Dart_Handle obj, int *count)
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)
DART_EXPORT DART_WARN_UNUSED_RESULT char * Dart_Initialize(Dart_InitializeParams *params)
struct _Dart_NativeArguments * Dart_NativeArguments
Definition: dart_api.h:3036
bool(* Dart_InitializeIsolateCallback)(void **child_isolate_data, char **error)
Definition: dart_api.h:692
DART_EXPORT void Dart_NotifyIdle(int64_t deadline)
DART_EXPORT Dart_Handle Dart_ClosureFunction(Dart_Handle closure)
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_New(Dart_Handle type, Dart_Handle constructor_name, int number_of_arguments, Dart_Handle *arguments)
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_SetField(Dart_Handle container, Dart_Handle name, Dart_Handle value)
Dart_TypedData_Type
Definition: dart_api.h:2629
@ Dart_TypedData_kFloat32x4
Definition: dart_api.h:2643
@ Dart_TypedData_kInt32x4
Definition: dart_api.h:2642
@ Dart_TypedData_kUint8
Definition: dart_api.h:2632
@ Dart_TypedData_kUint32
Definition: dart_api.h:2637
@ Dart_TypedData_kInt32
Definition: dart_api.h:2636
@ Dart_TypedData_kUint16
Definition: dart_api.h:2635
@ Dart_TypedData_kFloat64x2
Definition: dart_api.h:2644
@ Dart_TypedData_kUint64
Definition: dart_api.h:2639
@ Dart_TypedData_kFloat32
Definition: dart_api.h:2640
@ Dart_TypedData_kInt16
Definition: dart_api.h:2634
@ Dart_TypedData_kFloat64
Definition: dart_api.h:2641
@ Dart_TypedData_kUint8Clamped
Definition: dart_api.h:2633
@ Dart_TypedData_kByteData
Definition: dart_api.h:2630
@ Dart_TypedData_kInt8
Definition: dart_api.h:2631
@ Dart_TypedData_kInt64
Definition: dart_api.h:2638
@ Dart_TypedData_kInvalid
Definition: dart_api.h:2645
DART_EXPORT Dart_Handle Dart_SetNativeInstanceField(Dart_Handle obj, int index, intptr_t value)
DART_EXPORT Dart_Handle Dart_GetNativeIntegerArgument(Dart_NativeArguments args, int index, int64_t *value)
DART_EXPORT int Dart_GetNativeArgumentCount(Dart_NativeArguments args)
DART_EXPORT Dart_Isolate Dart_CurrentIsolate(void)
DART_EXPORT Dart_Handle Dart_NewTypedData(Dart_TypedData_Type type, intptr_t length)
DART_EXPORT bool Dart_IsKernel(const uint8_t *buffer, intptr_t buffer_size)
Dart_Handle Dart_PersistentHandle
Definition: dart_api.h:259
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_GetObfuscationMap(uint8_t **buffer, intptr_t *buffer_length)
DART_EXPORT Dart_Handle Dart_False(void)
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)
void(* Dart_IsolateGroupCleanupCallback)(void *isolate_group_data)
Definition: dart_api.h:744
DART_EXPORT Dart_Handle Dart_TypeToNullableType(Dart_Handle type)
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_LoadLibrary(Dart_Handle kernel_buffer)
DART_EXPORT Dart_Handle Dart_SetEnvironmentCallback(Dart_EnvironmentCallback callback)
DART_EXPORT bool Dart_IsUnhandledExceptionError(Dart_Handle handle)
DART_EXPORT Dart_Handle Dart_NewApiError(const char *error)
DART_EXPORT void Dart_DeleteWeakPersistentHandle(Dart_WeakPersistentHandle object)
DART_EXPORT Dart_Handle Dart_TypeDynamic(void)
DART_EXPORT Dart_Handle Dart_Null(void)
struct _Dart_FinalizableHandle * Dart_FinalizableHandle
Definition: dart_api.h:261
void(* Dart_OnNewCodeCallback)(struct Dart_CodeObserver *observer, const char *name, uintptr_t base, uintptr_t size)
Definition: dart_api.h:854
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)
Dart_LibraryTag
Definition: dart_api.h:3365
@ Dart_kImportTag
Definition: dart_api.h:3367
@ Dart_kCanonicalizeUrl
Definition: dart_api.h:3366
@ Dart_kKernelTag
Definition: dart_api.h:3368
DART_EXPORT Dart_Handle Dart_Precompile(void)
void(* Dart_CreateLoadingUnitCallback)(void *callback_data, intptr_t loading_unit_id, void **write_callback_data, void **write_debug_callback_data)
Definition: dart_api.h:3934
void *(* Dart_FileOpenCallback)(const char *name, bool write)
Definition: dart_api.h:775
DART_EXPORT Dart_Handle Dart_GetNativeSymbol(Dart_Handle library, Dart_NativeEntrySymbol *resolver)
void(* Dart_IsolateShutdownCallback)(void *isolate_group_data, void *isolate_data)
Definition: dart_api.h:710
DART_EXPORT DART_WARN_UNUSED_RESULT char * Dart_Cleanup(void)
DART_EXPORT Dart_WeakPersistentHandle Dart_NewWeakPersistentHandle(Dart_Handle object, void *peer, intptr_t external_allocation_size, Dart_HandleFinalizer callback)
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)
DART_EXPORT Dart_Handle Dart_GetNativeReceiver(Dart_NativeArguments args, intptr_t *value)
DART_EXPORT const char * Dart_IsolateServiceId(Dart_Isolate isolate)
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)
DART_EXPORT Dart_Handle Dart_GetPeer(Dart_Handle object, void **peer)
union _Dart_NativeArgument_Value Dart_NativeArgument_Value
DART_EXPORT Dart_Handle Dart_StringToLatin1(Dart_Handle str, uint8_t *latin1_array, intptr_t *length)
DART_EXPORT bool Dart_KernelIsolateIsRunning(void)
DART_EXPORT Dart_Handle Dart_ErrorGetException(Dart_Handle handle)
DART_EXPORT void Dart_SetDartLibrarySourcesKernel(const uint8_t *platform_kernel, const intptr_t platform_kernel_size)
DART_EXPORT void Dart_SetReturnValue(Dart_NativeArguments args, Dart_Handle retval)
DART_EXPORT void Dart_SetWeakHandleReturnValue(Dart_NativeArguments args, Dart_WeakPersistentHandle rval)
void(* Dart_ThreadExitCallback)(void)
Definition: dart_api.h:762
DART_EXPORT Dart_Handle Dart_StringToUTF8(Dart_Handle str, uint8_t **utf8_array, intptr_t *length)
DART_EXPORT Dart_Handle Dart_MapContainsKey(Dart_Handle map, Dart_Handle key)
DART_EXPORT Dart_Handle Dart_LibraryResolvedUrl(Dart_Handle library)
DART_EXPORT Dart_Handle Dart_GetClass(Dart_Handle library, Dart_Handle class_name)
DART_EXPORT Dart_Handle Dart_ListLength(Dart_Handle list, intptr_t *length)
DART_EXPORT Dart_Handle Dart_NewByteBuffer(Dart_Handle typed_data)
DART_EXPORT bool Dart_IsNull(Dart_Handle object)
DART_EXPORT void Dart_SetShouldPauseOnExit(bool should_pause)
DART_EXPORT void Dart_NotifyDestroyed(void)
DART_EXPORT Dart_Port Dart_GetMainPortId(void)
DART_EXPORT void Dart_SetDwarfStackTraceFootnoteCallback(Dart_DwarfStackTraceFootnoteCallback callback)
DART_EXPORT Dart_Handle Dart_NewExternalLatin1String(const uint8_t *latin1_array, intptr_t length, void *peer, intptr_t external_allocation_size, Dart_HandleFinalizer callback)
DART_EXPORT Dart_Handle Dart_IntegerFitsIntoInt64(Dart_Handle integer, bool *fits)
DART_EXPORT uint8_t * Dart_ScopeAllocate(intptr_t size)
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)
DART_EXPORT void * Dart_IsolateData(Dart_Isolate isolate)
DART_EXPORT void Dart_SetStickyError(Dart_Handle error)
DART_EXPORT void Dart_AddSymbols(const char *dso_name, void *buffer, intptr_t buffer_size)
DART_EXPORT bool Dart_ErrorHasException(Dart_Handle handle)
DART_EXPORT Dart_Handle Dart_StringToCString(Dart_Handle str, const char **cstr)
void *(* Dart_HeapSamplingCreateCallback)(Dart_Isolate isolate, Dart_IsolateGroup isolate_group, const char *cls_name, intptr_t allocation_size)
Definition: dart_api.h:1283
DART_EXPORT Dart_Handle Dart_ObjectIsType(Dart_Handle object, Dart_Handle type, bool *instanceof)
DART_EXPORT Dart_Handle Dart_NewStringFromCString(const char *str)
DART_EXPORT Dart_Handle Dart_SendPortGetId(Dart_Handle port, Dart_Port *port_id)
void(* Dart_NativeFunction)(Dart_NativeArguments arguments)
Definition: dart_api.h:3224
Dart_Handle(* Dart_GetVMServiceAssetsArchive)(void)
Definition: dart_api.h:833
DART_EXPORT bool Dart_IdentityEquals(Dart_Handle obj1, Dart_Handle obj2)
DART_EXPORT void * Dart_IsolateGroupData(Dart_Isolate isolate)
DART_EXPORT Dart_Handle Dart_GetStickyError(void)
@ kNativeArgNumberPos
Definition: dart_api.h:3079
@ kNativeArgNumberSize
Definition: dart_api.h:3080
@ kNativeArgTypePos
Definition: dart_api.h:3081
@ kNativeArgTypeSize
Definition: dart_api.h:3082
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_IsolateGroup Dart_CurrentIsolateGroup(void)
DART_EXPORT Dart_Handle Dart_NewInteger(int64_t value)
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_GetField(Dart_Handle container, Dart_Handle name)
DART_EXPORT void Dart_RegisterHeapSamplingCallback(Dart_HeapSamplingCreateCallback create_callback, Dart_HeapSamplingDeleteCallback delete_callback)
DART_EXPORT bool Dart_IsType(Dart_Handle handle)
DART_EXPORT Dart_Handle Dart_DoubleValue(Dart_Handle double_obj, double *value)
DART_EXPORT Dart_Handle Dart_GetNativeArguments(Dart_NativeArguments args, int num_arguments, const Dart_NativeArgument_Descriptor *arg_descriptors, Dart_NativeArgument_Value *arg_values)
Dart_Handle(* Dart_LibraryTagHandler)(Dart_LibraryTag tag, Dart_Handle library_or_package_map_url, Dart_Handle url)
Definition: dart_api.h:3404
DART_EXPORT Dart_Handle Dart_NewBoolean(bool value)
DART_EXPORT void Dart_EnterIsolate(Dart_Isolate isolate)
DART_EXPORT void Dart_NotifyLowMemory(void)
Dart_NativeArgument_Type
Definition: dart_api.h:3043
@ Dart_NativeArgument_kString
Definition: dart_api.h:3050
@ Dart_NativeArgument_kInt64
Definition: dart_api.h:3047
@ Dart_NativeArgument_kNativeFields
Definition: dart_api.h:3052
@ Dart_NativeArgument_kInstance
Definition: dart_api.h:3051
@ Dart_NativeArgument_kInt32
Definition: dart_api.h:3045
@ Dart_NativeArgument_kUint64
Definition: dart_api.h:3048
@ Dart_NativeArgument_kUint32
Definition: dart_api.h:3046
@ Dart_NativeArgument_kDouble
Definition: dart_api.h:3049
@ Dart_NativeArgument_kBool
Definition: dart_api.h:3044
DART_EXPORT Dart_Handle Dart_DefaultCanonicalizeUrl(Dart_Handle base_url, Dart_Handle url)
DART_EXPORT void Dart_SetBooleanReturnValue(Dart_NativeArguments args, bool retval)
DART_EXPORT Dart_Handle Dart_InstanceGetType(Dart_Handle instance)
DART_EXPORT bool Dart_IsVariable(Dart_Handle handle)
DART_EXPORT void Dart_SetShouldPauseOnStart(bool should_pause)
DART_EXPORT Dart_Handle Dart_GetNativeFieldsOfArgument(Dart_NativeArguments args, int arg_index, int num_fields, intptr_t *field_values)
DART_EXPORT Dart_MessageNotifyCallback Dart_GetMessageNotifyCallback(void)
int64_t Dart_IsolateGroupId
Definition: dart_api.h:1208
DART_EXPORT Dart_Handle Dart_LibraryUrl(Dart_Handle library)
DART_EXPORT void Dart_SetPersistentHandle(Dart_PersistentHandle obj1, Dart_Handle obj2)
char *(* Dart_DwarfStackTraceFootnoteCallback)(void *addresses[], intptr_t count)
Definition: dart_api.h:4163
DART_EXPORT Dart_Handle Dart_LibraryHandleError(Dart_Handle library, Dart_Handle error)
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_LoadScriptFromKernel(const uint8_t *kernel_buffer, intptr_t kernel_size)
DART_EXPORT Dart_PerformanceMode Dart_SetPerformanceMode(Dart_PerformanceMode mode)
DART_EXPORT Dart_Handle Dart_ObjectEquals(Dart_Handle obj1, Dart_Handle obj2, bool *equal)
DART_EXPORT DART_WARN_UNUSED_RESULT char * Dart_SetVMFlags(int argc, const char **argv)
DART_EXPORT void * Dart_GetNativeIsolateGroupData(Dart_NativeArguments args)
DART_EXPORT bool Dart_IsError(Dart_Handle handle)
DART_EXPORT Dart_Handle Dart_NewList(intptr_t length)
DART_EXPORT Dart_Handle Dart_NewStringFromUTF16(const uint16_t *utf16_array, intptr_t length)
DART_EXPORT Dart_Handle Dart_StringGetProperties(Dart_Handle str, intptr_t *char_size, intptr_t *str_len, void **peer)
struct _Dart_WeakPersistentHandle * Dart_WeakPersistentHandle
Definition: dart_api.h:260
Dart_KernelCompilationVerbosityLevel
Definition: dart_api.h:3768
@ Dart_KernelCompilationVerbosityLevel_Error
Definition: dart_api.h:3769
@ Dart_KernelCompilationVerbosityLevel_Warning
Definition: dart_api.h:3770
@ Dart_KernelCompilationVerbosityLevel_All
Definition: dart_api.h:3772
@ Dart_KernelCompilationVerbosityLevel_Info
Definition: dart_api.h:3771
DART_EXPORT bool Dart_Post(Dart_Port port_id, Dart_Handle object)
DART_EXPORT Dart_Handle Dart_GetNullableType(Dart_Handle library, Dart_Handle class_name, intptr_t number_of_type_arguments, Dart_Handle *type_arguments)
DART_EXPORT void Dart_DeleteFinalizableHandle(Dart_FinalizableHandle object, Dart_Handle strong_ref_to_object)
DART_EXPORT void Dart_EnableHeapSampling(void)
DART_EXPORT bool Dart_ShouldPauseOnStart(void)
DART_EXPORT bool Dart_IsDouble(Dart_Handle object)
DART_EXPORT void Dart_ExitIsolate(void)
DART_EXPORT bool Dart_IsServiceIsolate(Dart_Isolate isolate)
Dart_Handle(* Dart_DeferredLoadHandler)(intptr_t loading_unit_id)
Definition: dart_api.h:3439
DART_EXPORT void * Dart_CurrentIsolateGroupData(void)
DART_EXPORT void Dart_ReportSurvivingAllocations(Dart_HeapSamplingReportCallback callback, void *context, bool force_gc)
DART_EXPORT Dart_Handle Dart_HandleFromWeakPersistent(Dart_WeakPersistentHandle object)
DART_EXPORT Dart_Handle Dart_ListGetAt(Dart_Handle list, intptr_t index)
DART_EXPORT void Dart_DeletePersistentHandle(Dart_PersistentHandle object)
DART_EXPORT void Dart_SetMessageNotifyCallback(Dart_MessageNotifyCallback message_notify_callback)
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_DeferredLoadCompleteError(intptr_t loading_unit_id, const char *error_message, bool transient)
DART_EXPORT Dart_Handle Dart_MapGetAt(Dart_Handle map, Dart_Handle key)
DART_EXPORT Dart_Handle Dart_IsNonNullableType(Dart_Handle type, bool *result)
DART_EXPORT Dart_IsolateGroupId Dart_CurrentIsolateGroupId(void)
DART_EXPORT bool Dart_IsString(Dart_Handle object)
DART_EXPORT const char * Dart_GetError(Dart_Handle handle)
DART_EXPORT bool Dart_IsKernelIsolate(Dart_Isolate isolate)
DART_EXPORT Dart_Handle Dart_NewListOfType(Dart_Handle element_type, intptr_t length)
DART_EXPORT Dart_Handle Dart_NewIntegerFromHexCString(const char *value)
DART_EXPORT Dart_Handle Dart_NewUnhandledExceptionError(Dart_Handle exception)
DART_EXPORT Dart_Handle Dart_ToString(Dart_Handle object)
DART_EXPORT Dart_Handle Dart_SetPeer(Dart_Handle object, void *peer)
DART_EXPORT Dart_Handle Dart_BooleanValue(Dart_Handle boolean_obj, bool *value)
DART_EXPORT Dart_Handle Dart_ClassLibrary(Dart_Handle cls_type)
void(* Dart_HeapSamplingDeleteCallback)(void *data)
Definition: dart_api.h:1288
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_RunLoop(void)
DART_EXPORT bool Dart_IsClosure(Dart_Handle object)
DART_EXPORT Dart_Handle Dart_IntegerFitsIntoUint64(Dart_Handle integer, bool *fits)
DART_EXPORT Dart_Handle Dart_GetLoadedLibraries(void)
DART_EXPORT bool Dart_IsLibrary(Dart_Handle object)
DART_EXPORT Dart_Handle Dart_SetLibraryTagHandler(Dart_LibraryTagHandler handler)
DART_EXPORT bool Dart_IsTearOff(Dart_Handle object)
DART_EXPORT Dart_Handle Dart_RootLibrary(void)
DART_EXPORT bool Dart_IsFuture(Dart_Handle object)
DART_EXPORT bool Dart_HasLivePorts(void)
DART_EXPORT bool Dart_IsList(Dart_Handle object)
DART_EXPORT bool Dart_IsExternalString(Dart_Handle object)
DART_EXPORT Dart_Handle Dart_GetNativeDoubleArgument(Dart_NativeArguments args, int index, double *value)
struct _Dart_NativeArgument_Descriptor Dart_NativeArgument_Descriptor
DART_EXPORT Dart_Handle Dart_ListSetAt(Dart_Handle list, intptr_t index, Dart_Handle value)
DART_EXPORT Dart_Handle Dart_IntegerToUint64(Dart_Handle integer, uint64_t *value)
DART_EXPORT bool Dart_IsCompilationError(Dart_Handle handle)
DART_EXPORT bool Dart_IsMap(Dart_Handle object)
void(* Dart_HeapSamplingReportCallback)(void *context, void *data)
Definition: dart_api.h:1280
DART_EXPORT Dart_Handle Dart_NewCompilationError(const char *error)
DART_EXPORT bool Dart_IsTypedData(Dart_Handle object)
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_WaitForEvent(int64_t timeout_millis)
DART_EXPORT Dart_Handle Dart_GetNativeStringArgument(Dart_NativeArguments args, int arg_index, void **peer)
DART_EXPORT Dart_Handle Dart_LoadingUnitLibraryUris(intptr_t loading_unit_id)
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_HandleMessage(void)
DART_EXPORT Dart_Handle Dart_GetNativeBooleanArgument(Dart_NativeArguments args, int index, bool *value)
DART_EXPORT Dart_Handle Dart_SetRootLibrary(Dart_Handle library)
DART_EXPORT Dart_TypedData_Type Dart_GetTypeOfTypedData(Dart_Handle object)
static SkRect offset(SkRect r, SkIPoint p)
Definition: editor.cpp:18
VkInstance instance
Definition: main.cc:47
#define DART_EXPORT
FlutterSemanticsFlag flags
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
static const uint8_t buffer[]
const uint8_t uint32_t uint32_t GError ** error
uint8_t value
GAsyncResult * result
uint32_t * target
Dart_NativeFunction function
Definition: fuchsia.cc:51
const char * name
Definition: fuchsia.cc:50
size_t length
enum flutter::testing::@2643::KeyboardChange::Type type
Definition: main.py:1
void write(SkWStream *wStream, const T &text)
Definition: skqp.cpp:168
Dart_OnNewCodeCallback on_new_code
Definition: dart_api.h:862
Dart_ThreadExitCallback thread_exit
Definition: dart_api.h:952
Dart_IsolateGroupCreateCallback create_group
Definition: dart_api.h:924
Dart_InitializeIsolateCallback initialize_isolate
Definition: dart_api.h:931
Dart_IsolateGroupCleanupCallback cleanup_group
Definition: dart_api.h:949
Dart_FileReadCallback file_read
Definition: dart_api.h:954
const uint8_t * vm_snapshot_data
Definition: dart_api.h:910
Dart_GetVMServiceAssetsArchive get_service_assets
Definition: dart_api.h:963
Dart_FileOpenCallback file_open
Definition: dart_api.h:953
Dart_IsolateShutdownCallback shutdown_isolate
Definition: dart_api.h:937
Dart_ThreadStartCallback thread_start
Definition: dart_api.h:951
Dart_CodeObserver * code_observer
Definition: dart_api.h:971
Dart_UnregisterKernelBlobCallback unregister_kernel_blob
Definition: dart_api.h:981
Dart_FileWriteCallback file_write
Definition: dart_api.h:955
Dart_EntropySource entropy_source
Definition: dart_api.h:957
Dart_RegisterKernelBlobCallback register_kernel_blob
Definition: dart_api.h:976
Dart_IsolateCleanupCallback cleanup_isolate
Definition: dart_api.h:943
const uint8_t * vm_snapshot_instructions
Definition: dart_api.h:918
Dart_FileCloseCallback file_close
Definition: dart_api.h:956
bool copy_parent_code
Definition: dart_api.h:592
bool load_vmservice_library
Definition: dart_api.h:591
bool snapshot_is_dontneed_safe
Definition: dart_api.h:595
bool branch_coverage
Definition: dart_api.h:596
int32_t version
Definition: dart_api.h:586
bool use_field_guards
Definition: dart_api.h:588
bool is_system_isolate
Definition: dart_api.h:594
Dart_KernelCompilationStatus status
Definition: dart_api.h:3761
const char * uri
Definition: dart_api.h:3820
const char * source
Definition: dart_api.h:3821
struct _Dart_NativeArgument_Value::@82 as_string
struct _Dart_NativeArgument_Value::@83 as_native_fields