Flutter Engine
The Flutter Engine
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 * Initialization and Globals
562 * ==========================
563 */
564
565/**
566 * Gets the version string for the Dart VM.
567 *
568 * The version of the Dart VM can be accessed without initializing the VM.
569 *
570 * \return The version string for the embedded Dart VM.
571 */
573
574/**
575 * Isolate specific flags are set when creating a new isolate using the
576 * Dart_IsolateFlags structure.
577 *
578 * Current version of flags is encoded in a 32-bit integer with 16 bits used
579 * for each part.
580 */
581
582#define DART_FLAGS_CURRENT_VERSION (0x0000000d)
583
584typedef struct {
585 int32_t version;
599
600/**
601 * Initialize Dart_IsolateFlags with correct version and default values.
602 */
604
605/**
606 * An isolate creation and initialization callback function.
607 *
608 * This callback, provided by the embedder, is called when the VM
609 * needs to create an isolate. The callback should create an isolate
610 * by calling Dart_CreateIsolateGroup and load any scripts required for
611 * execution.
612 *
613 * This callback may be called on a different thread than the one
614 * running the parent isolate.
615 *
616 * When the function returns NULL, it is the responsibility of this
617 * function to ensure that Dart_ShutdownIsolate has been called if
618 * required (for example, if the isolate was created successfully by
619 * Dart_CreateIsolateGroup() but the root library fails to load
620 * successfully, then the function should call Dart_ShutdownIsolate
621 * before returning).
622 *
623 * When the function returns NULL, the function should set *error to
624 * a malloc-allocated buffer containing a useful error message. The
625 * caller of this function (the VM) will make sure that the buffer is
626 * freed.
627 *
628 * \param script_uri The uri of the main source file or snapshot to load.
629 * Either the URI of the parent isolate set in Dart_CreateIsolateGroup for
630 * Isolate.spawn, or the argument to Isolate.spawnUri canonicalized by the
631 * library tag handler of the parent isolate.
632 * The callback is responsible for loading the program by a call to
633 * Dart_LoadScriptFromKernel.
634 * \param main The name of the main entry point this isolate will
635 * eventually run. This is provided for advisory purposes only to
636 * improve debugging messages. The main function is not invoked by
637 * this function.
638 * \param package_root Ignored.
639 * \param package_config Uri of the package configuration file (either in format
640 * of .packages or .dart_tool/package_config.json) for this isolate
641 * to resolve package imports against. If this parameter is not passed the
642 * package resolution of the parent isolate should be used.
643 * \param flags Default flags for this isolate being spawned. Either inherited
644 * from the spawning isolate or passed as parameters when spawning the
645 * isolate from Dart code.
646 * \param isolate_data The isolate data which was passed to the
647 * parent isolate when it was created by calling Dart_CreateIsolateGroup().
648 * \param error A structure into which the embedder can place a
649 * C string containing an error message in the case of failures.
650 *
651 * \return The embedder returns NULL if the creation and
652 * initialization was not successful and the isolate if successful.
653 */
655 const char* script_uri,
656 const char* main,
657 const char* package_root,
658 const char* package_config,
660 void* isolate_data,
661 char** error);
662
663/**
664 * An isolate initialization callback function.
665 *
666 * This callback, provided by the embedder, is called when the VM has created an
667 * isolate within an existing isolate group (i.e. from the same source as an
668 * existing isolate).
669 *
670 * The callback should setup native resolvers and might want to set a custom
671 * message handler via [Dart_SetMessageNotifyCallback] and mark the isolate as
672 * runnable.
673 *
674 * This callback may be called on a different thread than the one
675 * running the parent isolate.
676 *
677 * When the function returns `false`, it is the responsibility of this
678 * function to ensure that `Dart_ShutdownIsolate` has been called.
679 *
680 * When the function returns `false`, the function should set *error to
681 * a malloc-allocated buffer containing a useful error message. The
682 * caller of this function (the VM) will make sure that the buffer is
683 * freed.
684 *
685 * \param child_isolate_data The callback data to associate with the new
686 * child isolate.
687 * \param error A structure into which the embedder can place a
688 * C string containing an error message in the case the initialization fails.
689 *
690 * \return The embedder returns true if the initialization was successful and
691 * false otherwise (in which case the VM will terminate the isolate).
692 */
693typedef bool (*Dart_InitializeIsolateCallback)(void** child_isolate_data,
694 char** error);
695
696/**
697 * An isolate shutdown callback function.
698 *
699 * This callback, provided by the embedder, is called before the vm
700 * shuts down an isolate. The isolate being shutdown will be the current
701 * isolate. It is safe to run Dart code.
702 *
703 * This function should be used to dispose of native resources that
704 * are allocated to an isolate in order to avoid leaks.
705 *
706 * \param isolate_group_data The same callback data which was passed to the
707 * isolate group when it was created.
708 * \param isolate_data The same callback data which was passed to the isolate
709 * when it was created.
710 */
711typedef void (*Dart_IsolateShutdownCallback)(void* isolate_group_data,
712 void* isolate_data);
713
714/**
715 * An isolate cleanup callback function.
716 *
717 * This callback, provided by the embedder, is called after the vm
718 * shuts down an isolate. There will be no current isolate and it is *not*
719 * safe to run Dart code.
720 *
721 * This function should be used to dispose of native resources that
722 * are allocated to an isolate in order to avoid leaks.
723 *
724 * \param isolate_group_data The same callback data which was passed to the
725 * isolate group when it was created.
726 * \param isolate_data The same callback data which was passed to the isolate
727 * when it was created.
728 */
729typedef void (*Dart_IsolateCleanupCallback)(void* isolate_group_data,
730 void* isolate_data);
731
732/**
733 * An isolate group cleanup callback function.
734 *
735 * This callback, provided by the embedder, is called after the vm
736 * shuts down an isolate group.
737 *
738 * This function should be used to dispose of native resources that
739 * are allocated to an isolate in order to avoid leaks.
740 *
741 * \param isolate_group_data The same callback data which was passed to the
742 * isolate group when it was created.
743 *
744 */
745typedef void (*Dart_IsolateGroupCleanupCallback)(void* isolate_group_data);
746
747/**
748 * A thread start callback function.
749 * This callback, provided by the embedder, is called after a thread in the
750 * vm thread pool starts.
751 * This function could be used to adjust thread priority or attach native
752 * resources to the thread.
753 */
754typedef void (*Dart_ThreadStartCallback)(void);
755
756/**
757 * A thread death callback function.
758 * This callback, provided by the embedder, is called before a thread in the
759 * vm thread pool exits.
760 * This function could be used to dispose of native resources that
761 * are associated and attached to the thread, in order to avoid leaks.
762 */
763typedef void (*Dart_ThreadExitCallback)(void);
764
765/**
766 * Opens a file for reading or writing.
767 *
768 * Callback provided by the embedder for file operations. If the
769 * embedder does not allow file operations this callback can be
770 * NULL.
771 *
772 * \param name The name of the file to open.
773 * \param write A boolean variable which indicates if the file is to
774 * opened for writing. If there is an existing file it needs to truncated.
775 */
776typedef void* (*Dart_FileOpenCallback)(const char* name, bool write);
777
778/**
779 * Read contents of file.
780 *
781 * Callback provided by the embedder for file operations. If the
782 * embedder does not allow file operations this callback can be
783 * NULL.
784 *
785 * \param data Buffer allocated in the callback into which the contents
786 * of the file are read into. It is the responsibility of the caller to
787 * free this buffer.
788 * \param file_length A variable into which the length of the file is returned.
789 * In the case of an error this value would be -1.
790 * \param stream Handle to the opened file.
791 */
792typedef void (*Dart_FileReadCallback)(uint8_t** data,
793 intptr_t* file_length,
794 void* stream);
795
796/**
797 * Write data into file.
798 *
799 * Callback provided by the embedder for file operations. If the
800 * embedder does not allow file operations this callback can be
801 * NULL.
802 *
803 * \param data Buffer which needs to be written into the file.
804 * \param length Length of the buffer.
805 * \param stream Handle to the opened file.
806 */
807typedef void (*Dart_FileWriteCallback)(const void* data,
808 intptr_t length,
809 void* stream);
810
811/**
812 * Closes the opened file.
813 *
814 * Callback provided by the embedder for file operations. If the
815 * embedder does not allow file operations this callback can be
816 * NULL.
817 *
818 * \param stream Handle to the opened file.
819 */
820typedef void (*Dart_FileCloseCallback)(void* stream);
821
822typedef bool (*Dart_EntropySource)(uint8_t* buffer, intptr_t length);
823
824/**
825 * Callback provided by the embedder that is used by the vmservice isolate
826 * to request the asset archive. The asset archive must be an uncompressed tar
827 * archive that is stored in a Uint8List.
828 *
829 * If the embedder has no vmservice isolate assets, the callback can be NULL.
830 *
831 * \return The embedder must return a handle to a Uint8List containing an
832 * uncompressed tar archive or null.
833 */
835
836/**
837 * The current version of the Dart_InitializeFlags. Should be incremented every
838 * time Dart_InitializeFlags changes in a binary incompatible way.
839 */
840#define DART_INITIALIZE_PARAMS_CURRENT_VERSION (0x00000008)
841
842/** Forward declaration */
843struct Dart_CodeObserver;
844
845/**
846 * Callback provided by the embedder that is used by the VM to notify on code
847 * object creation, *before* it is invoked the first time.
848 * This is useful for embedders wanting to e.g. keep track of PCs beyond
849 * the lifetime of the garbage collected code objects.
850 * Note that an address range may be used by more than one code object over the
851 * lifecycle of a process. Clients of this function should record timestamps for
852 * these compilation events and when collecting PCs to disambiguate reused
853 * address ranges.
854 */
855typedef void (*Dart_OnNewCodeCallback)(struct Dart_CodeObserver* observer,
856 const char* name,
857 uintptr_t base,
858 uintptr_t size);
859
860typedef struct Dart_CodeObserver {
861 void* data;
862
865
866/**
867 * Optional callback provided by the embedder that is used by the VM to
868 * implement registration of kernel blobs for the subsequent Isolate.spawnUri
869 * If no callback is provided, the registration of kernel blobs will throw
870 * an error.
871 *
872 * \param kernel_buffer A buffer which contains a kernel program. Callback
873 * should copy the contents of `kernel_buffer` as
874 * it may be freed immediately after registration.
875 * \param kernel_buffer_size The size of `kernel_buffer`.
876 *
877 * \return A C string representing URI which can be later used
878 * to spawn a new isolate. This C String should be scope allocated
879 * or owned by the embedder.
880 * Returns NULL if embedder runs out of memory.
881 */
882typedef const char* (*Dart_RegisterKernelBlobCallback)(
883 const uint8_t* kernel_buffer,
884 intptr_t kernel_buffer_size);
885
886/**
887 * Optional callback provided by the embedder that is used by the VM to
888 * unregister kernel blobs.
889 * If no callback is provided, the unregistration of kernel blobs will throw
890 * an error.
891 *
892 * \param kernel_blob_uri URI of the kernel blob to unregister.
893 */
894typedef void (*Dart_UnregisterKernelBlobCallback)(const char* kernel_blob_uri);
895
896/**
897 * Describes how to initialize the VM. Used with Dart_Initialize.
898 */
899typedef struct {
900 /**
901 * Identifies the version of the struct used by the client.
902 * should be initialized to DART_INITIALIZE_PARAMS_CURRENT_VERSION.
903 */
904 int32_t version;
905
906 /**
907 * A buffer containing snapshot data, or NULL if no snapshot is provided.
908 *
909 * If provided, the buffer must remain valid until Dart_Cleanup returns.
910 */
911 const uint8_t* vm_snapshot_data;
912
913 /**
914 * A buffer containing a snapshot of precompiled instructions, or NULL if
915 * no snapshot is provided.
916 *
917 * If provided, the buffer must remain valid until Dart_Cleanup returns.
918 */
920
921 /**
922 * A function to be called during isolate group creation.
923 * See Dart_IsolateGroupCreateCallback.
924 */
926
927 /**
928 * A function to be called during isolate
929 * initialization inside an existing isolate group.
930 * See Dart_InitializeIsolateCallback.
931 */
933
934 /**
935 * A function to be called right before an isolate is shutdown.
936 * See Dart_IsolateShutdownCallback.
937 */
939
940 /**
941 * A function to be called after an isolate was shutdown.
942 * See Dart_IsolateCleanupCallback.
943 */
945
946 /**
947 * A function to be called after an isolate group is
948 * shutdown. See Dart_IsolateGroupCleanupCallback.
949 */
951
959
960 /**
961 * A function to be called by the service isolate when it requires the
962 * vmservice assets archive. See Dart_GetVMServiceAssetsArchive.
963 */
965
967
968 /**
969 * An external code observer callback function. The observer can be invoked
970 * as early as during the Dart_Initialize() call.
971 */
973
974 /**
975 * Kernel blob registration callback function. See Dart_RegisterKernelBlobCallback.
976 */
978
979 /**
980 * Kernel blob unregistration callback function. See Dart_UnregisterKernelBlobCallback.
981 */
983
984#if defined(__Fuchsia__)
985 /**
986 * The resource needed to use zx_vmo_replace_as_executable. Can be
987 * ZX_HANDLE_INVALID if the process has ambient-replace-as-executable or if
988 * executable memory is not needed (e.g., this is an AOT runtime).
989 */
990 zx_handle_t vmex_resource;
991#endif
993
994/**
995 * Initializes the VM.
996 *
997 * \param params A struct containing initialization information. The version
998 * field of the struct must be DART_INITIALIZE_PARAMS_CURRENT_VERSION.
999 *
1000 * \return NULL if initialization is successful. Returns an error message
1001 * otherwise. The caller is responsible for freeing the error message.
1002 */
1005
1006/**
1007 * Cleanup state in the VM before process termination.
1008 *
1009 * \return NULL if cleanup is successful. Returns an error message otherwise.
1010 * The caller is responsible for freeing the error message.
1011 *
1012 * NOTE: This function must not be called on a thread that was created by the VM
1013 * itself.
1014 */
1016
1017/**
1018 * Sets command line flags. Should be called before Dart_Initialize.
1019 *
1020 * \param argc The length of the arguments array.
1021 * \param argv An array of arguments.
1022 *
1023 * \return NULL if successful. Returns an error message otherwise.
1024 * The caller is responsible for freeing the error message.
1025 *
1026 * NOTE: This call does not store references to the passed in c-strings.
1027 */
1029 const char** argv);
1030
1031/**
1032 * Returns true if the named VM flag is of boolean type, specified, and set to
1033 * true.
1034 *
1035 * \param flag_name The name of the flag without leading punctuation
1036 * (example: "enable_asserts").
1037 */
1038DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name);
1039
1040/*
1041 * ========
1042 * Isolates
1043 * ========
1044 */
1045
1046/**
1047 * Creates a new isolate. The new isolate becomes the current isolate.
1048 *
1049 * A snapshot can be used to restore the VM quickly to a saved state
1050 * and is useful for fast startup. If snapshot data is provided, the
1051 * isolate will be started using that snapshot data. Requires a core snapshot or
1052 * an app snapshot created by Dart_CreateSnapshot or
1053 * Dart_CreatePrecompiledSnapshot* from a VM with the same version.
1054 *
1055 * Requires there to be no current isolate.
1056 *
1057 * \param script_uri The main source file or snapshot this isolate will load.
1058 * The VM will provide this URI to the Dart_IsolateGroupCreateCallback when a
1059 * child isolate is created by Isolate.spawn. The embedder should use a URI
1060 * that allows it to load the same program into such a child isolate.
1061 * \param name A short name for the isolate to improve debugging messages.
1062 * Typically of the format 'foo.dart:main()'.
1063 * \param isolate_snapshot_data Buffer containing the snapshot data of the
1064 * isolate or NULL if no snapshot is provided. If provided, the buffer must
1065 * remain valid until the isolate shuts down.
1066 * \param isolate_snapshot_instructions Buffer containing the snapshot
1067 * instructions of the isolate or NULL if no snapshot is provided. If
1068 * provided, the buffer must remain valid until the isolate shuts down.
1069 * \param flags Pointer to VM specific flags or NULL for default flags.
1070 * \param isolate_group_data Embedder group data. This data can be obtained
1071 * by calling Dart_IsolateGroupData and will be passed to the
1072 * Dart_IsolateShutdownCallback, Dart_IsolateCleanupCallback, and
1073 * Dart_IsolateGroupCleanupCallback.
1074 * \param isolate_data Embedder data. This data will be passed to
1075 * the Dart_IsolateGroupCreateCallback when new isolates are spawned from
1076 * this parent isolate.
1077 * \param error Returns NULL if creation is successful, an error message
1078 * otherwise. The caller is responsible for calling free() on the error
1079 * message.
1080 *
1081 * \return The new isolate on success, or NULL if isolate creation failed.
1082 */
1084Dart_CreateIsolateGroup(const char* script_uri,
1085 const char* name,
1086 const uint8_t* isolate_snapshot_data,
1087 const uint8_t* isolate_snapshot_instructions,
1089 void* isolate_group_data,
1090 void* isolate_data,
1091 char** error);
1092/**
1093 * Creates a new isolate inside the isolate group of [group_member].
1094 *
1095 * Requires there to be no current isolate.
1096 *
1097 * \param group_member An isolate from the same group into which the newly created
1098 * isolate should be born into. Other threads may not have entered / enter this
1099 * member isolate.
1100 * \param name A short name for the isolate for debugging purposes.
1101 * \param shutdown_callback A callback to be called when the isolate is being
1102 * shutdown (may be NULL).
1103 * \param cleanup_callback A callback to be called when the isolate is being
1104 * cleaned up (may be NULL).
1105 * \param child_isolate_data The embedder-specific data associated with this isolate.
1106 * \param error Set to NULL if creation is successful, set to an error
1107 * message otherwise. The caller is responsible for calling free() on the
1108 * error message.
1109 *
1110 * \return The newly created isolate on success, or NULL if isolate creation
1111 * failed.
1112 *
1113 * If successful, the newly created isolate will become the current isolate.
1114 */
1117 const char* name,
1118 Dart_IsolateShutdownCallback shutdown_callback,
1119 Dart_IsolateCleanupCallback cleanup_callback,
1120 void* child_isolate_data,
1121 char** error);
1122
1123/* TODO(turnidge): Document behavior when there is already a current
1124 * isolate. */
1125
1126/**
1127 * Creates a new isolate from a Dart Kernel file. The new isolate
1128 * becomes the current isolate.
1129 *
1130 * Requires there to be no current isolate.
1131 *
1132 * \param script_uri The main source file or snapshot this isolate will load.
1133 * The VM will provide this URI to the Dart_IsolateGroupCreateCallback when a
1134 * child isolate is created by Isolate.spawn. The embedder should use a URI that
1135 * allows it to load the same program into such a child isolate.
1136 * \param name A short name for the isolate to improve debugging messages.
1137 * Typically of the format 'foo.dart:main()'.
1138 * \param kernel_buffer A buffer which contains a kernel/DIL program. Must
1139 * remain valid until isolate shutdown.
1140 * \param kernel_buffer_size The size of `kernel_buffer`.
1141 * \param flags Pointer to VM specific flags or NULL for default flags.
1142 * \param isolate_group_data Embedder group data. This data can be obtained
1143 * by calling Dart_IsolateGroupData and will be passed to the
1144 * Dart_IsolateShutdownCallback, Dart_IsolateCleanupCallback, and
1145 * Dart_IsolateGroupCleanupCallback.
1146 * \param isolate_data Embedder data. This data will be passed to
1147 * the Dart_IsolateGroupCreateCallback when new isolates are spawned from
1148 * this parent isolate.
1149 * \param error Returns NULL if creation is successful, an error message
1150 * otherwise. The caller is responsible for calling free() on the error
1151 * message.
1152 *
1153 * \return The new isolate on success, or NULL if isolate creation failed.
1154 */
1157 const char* name,
1158 const uint8_t* kernel_buffer,
1159 intptr_t kernel_buffer_size,
1161 void* isolate_group_data,
1162 void* isolate_data,
1163 char** error);
1164/**
1165 * Shuts down the current isolate. After this call, the current isolate is NULL.
1166 * Any current scopes created by Dart_EnterScope will be exited. Invokes the
1167 * shutdown callback and any callbacks of remaining weak persistent handles.
1168 *
1169 * Requires there to be a current isolate.
1170 */
1172/* TODO(turnidge): Document behavior when there is no current isolate. */
1173
1174/**
1175 * Returns the current isolate. Will return NULL if there is no
1176 * current isolate.
1177 */
1179
1180/**
1181 * Returns the callback data associated with the current isolate. This
1182 * data was set when the isolate got created or initialized.
1183 */
1185
1186/**
1187 * Returns the callback data associated with the given isolate. This
1188 * data was set when the isolate got created or initialized.
1189 */
1191
1192/**
1193 * Returns the current isolate group. Will return NULL if there is no
1194 * current isolate group.
1195 */
1197
1198/**
1199 * Returns the callback data associated with the current isolate group. This
1200 * data was passed to the isolate group when it was created.
1201 */
1203
1204/**
1205 * Gets an id that uniquely identifies current isolate group.
1206 *
1207 * It is the responsibility of the caller to free the returned ID.
1208 */
1209typedef int64_t Dart_IsolateGroupId;
1211
1212/**
1213 * Returns the callback data associated with the specified isolate group. This
1214 * data was passed to the isolate when it was created.
1215 * The embedder is responsible for ensuring the consistency of this data
1216 * with respect to the lifecycle of an isolate group.
1217 */
1219
1220/**
1221 * Returns the debugging name for the current isolate.
1222 *
1223 * This name is unique to each isolate and should only be used to make
1224 * debugging messages more comprehensible.
1225 */
1227
1228/**
1229 * Returns the debugging name for the current isolate.
1230 *
1231 * This name is unique to each isolate and should only be used to make
1232 * debugging messages more comprehensible.
1233 *
1234 * The returned string is scope allocated and is only valid until the next call
1235 * to Dart_ExitScope.
1236 */
1238
1239/**
1240 * Returns the ID for an isolate which is used to query the service protocol.
1241 *
1242 * It is the responsibility of the caller to free the returned ID.
1243 */
1245
1246/**
1247 * Enters an isolate. After calling this function,
1248 * the current isolate will be set to the provided isolate.
1249 *
1250 * Requires there to be no current isolate. Multiple threads may not be in
1251 * the same isolate at once.
1252 */
1254
1255/**
1256 * Kills the given isolate.
1257 *
1258 * This function has the same effect as dart:isolate's
1259 * Isolate.kill(priority:immediate).
1260 * It can interrupt ordinary Dart code but not native code. If the isolate is
1261 * in the middle of a long running native function, the isolate will not be
1262 * killed until control returns to Dart.
1263 *
1264 * Does not require a current isolate. It is safe to kill the current isolate if
1265 * there is one.
1266 */
1268
1269/**
1270 * Notifies the VM that the embedder expects to be idle until |deadline|. The VM
1271 * may use this time to perform garbage collection or other tasks to avoid
1272 * delays during execution of Dart code in the future.
1273 *
1274 * |deadline| is measured in microseconds against the system's monotonic time.
1275 * This clock can be accessed via Dart_TimelineGetMicros().
1276 *
1277 * Requires there to be a current isolate.
1278 */
1279DART_EXPORT void Dart_NotifyIdle(int64_t deadline);
1280
1281typedef void (*Dart_HeapSamplingReportCallback)(void* context, 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);
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;
1526typedef struct {
1527 int64_t port_id;
1528 int64_t origin_id;
1529} Dart_PortEx;
1530
1531/**
1532 * ILLEGAL_PORT is a port number guaranteed never to be associated with a valid
1533 * port.
1534 */
1535#define ILLEGAL_PORT ((Dart_Port)0)
1536
1537/**
1538 * A message notification callback.
1539 *
1540 * This callback allows the embedder to provide a custom wakeup mechanism for
1541 * the delivery of inter-isolate messages. This function is called once per
1542 * message on an arbitrary thread. It is the responsibility of the embedder to
1543 * eventually call Dart_HandleMessage once per callback received with the
1544 * destination isolate set as the current isolate to process the message.
1545 */
1546typedef void (*Dart_MessageNotifyCallback)(Dart_Isolate destination_isolate);
1547
1548/**
1549 * Allows embedders to provide a custom wakeup mechanism for the delivery of
1550 * inter-isolate messages. This setting only applies to the current isolate.
1551 *
1552 * This mechanism is optional: if not provided, the isolate will be scheduled on
1553 * a VM-managed thread pool. An embedder should provide this callback if it
1554 * wants to run an isolate on a specific thread or to interleave handling of
1555 * inter-isolate messages with other event sources.
1556 *
1557 * Most embedders will only call this function once, before isolate
1558 * execution begins. If this function is called after isolate
1559 * execution begins, the embedder is responsible for threading issues.
1560 */
1562 Dart_MessageNotifyCallback message_notify_callback);
1563/* TODO(turnidge): Consider moving this to isolate creation so that it
1564 * is impossible to mess up. */
1565
1566/**
1567 * Query the current message notify callback for the isolate.
1568 *
1569 * \return The current message notify callback for the isolate.
1570 */
1572
1573/**
1574 * The VM's default message handler supports pausing an isolate before it
1575 * processes the first message and right after the it processes the isolate's
1576 * final message. This can be controlled for all isolates by two VM flags:
1577 *
1578 * `--pause-isolates-on-start`
1579 * `--pause-isolates-on-exit`
1580 *
1581 * Additionally, Dart_SetShouldPauseOnStart and Dart_SetShouldPauseOnExit can be
1582 * used to control this behaviour on a per-isolate basis.
1583 *
1584 * When an embedder is using a Dart_MessageNotifyCallback the embedder
1585 * needs to cooperate with the VM so that the service protocol can report
1586 * accurate information about isolates and so that tools such as debuggers
1587 * work reliably.
1588 *
1589 * The following functions can be used to implement pausing on start and exit.
1590 */
1591
1592/**
1593 * If the VM flag `--pause-isolates-on-start` was passed this will be true.
1594 *
1595 * \return A boolean value indicating if pause on start was requested.
1596 */
1598
1599/**
1600 * Override the VM flag `--pause-isolates-on-start` for the current isolate.
1601 *
1602 * \param should_pause Should the isolate be paused on start?
1603 *
1604 * NOTE: This must be called before Dart_IsolateMakeRunnable.
1605 */
1607
1608/**
1609 * Is the current isolate paused on start?
1610 *
1611 * \return A boolean value indicating if the isolate is paused on start.
1612 */
1614
1615/**
1616 * Called when the embedder has paused the current isolate on start and when
1617 * the embedder has resumed the isolate.
1618 *
1619 * \param paused Is the isolate paused on start?
1620 */
1622
1623/**
1624 * If the VM flag `--pause-isolates-on-exit` was passed this will be true.
1625 *
1626 * \return A boolean value indicating if pause on exit was requested.
1627 */
1629
1630/**
1631 * Override the VM flag `--pause-isolates-on-exit` for the current isolate.
1632 *
1633 * \param should_pause Should the isolate be paused on exit?
1634 *
1635 */
1637
1638/**
1639 * Is the current isolate paused on exit?
1640 *
1641 * \return A boolean value indicating if the isolate is paused on exit.
1642 */
1644
1645/**
1646 * Called when the embedder has paused the current isolate on exit and when
1647 * the embedder has resumed the isolate.
1648 *
1649 * \param paused Is the isolate paused on exit?
1650 */
1652
1653/**
1654 * Called when the embedder has caught a top level unhandled exception error
1655 * in the current isolate.
1656 *
1657 * NOTE: It is illegal to call this twice on the same isolate without first
1658 * clearing the sticky error to null.
1659 *
1660 * \param error The unhandled exception error.
1661 */
1663
1664/**
1665 * Does the current isolate have a sticky error?
1666 */
1668
1669/**
1670 * Gets the sticky error for the current isolate.
1671 *
1672 * \return A handle to the sticky error object or null.
1673 */
1675
1676/**
1677 * Handles the next pending message for the current isolate.
1678 *
1679 * May generate an unhandled exception error.
1680 *
1681 * \return A valid handle if no error occurs during the operation.
1682 */
1684
1685/**
1686 * Handles any pending messages for the vm service for the current
1687 * isolate.
1688 *
1689 * This function may be used by an embedder at a breakpoint to avoid
1690 * pausing the vm service.
1691 *
1692 * This function can indirectly cause the message notify callback to
1693 * be called.
1694 *
1695 * \return true if the vm service requests the program resume
1696 * execution, false otherwise
1697 */
1699
1700/**
1701 * Does the current isolate have pending service messages?
1702 *
1703 * \return true if the isolate has pending service messages, false otherwise.
1704 */
1706
1707/**
1708 * Processes any incoming messages for the current isolate.
1709 *
1710 * This function may only be used when the embedder has not provided
1711 * an alternate message delivery mechanism with
1712 * Dart_SetMessageCallbacks. It is provided for convenience.
1713 *
1714 * This function waits for incoming messages for the current
1715 * isolate. As new messages arrive, they are handled using
1716 * Dart_HandleMessage. The routine exits when all ports to the
1717 * current isolate are closed.
1718 *
1719 * \return A valid handle if the run loop exited successfully. If an
1720 * exception or other error occurs while processing messages, an
1721 * error handle is returned.
1722 */
1724
1725/**
1726 * Lets the VM run message processing for the isolate.
1727 *
1728 * This function expects there to a current isolate and the current isolate
1729 * must not have an active api scope. The VM will take care of making the
1730 * isolate runnable (if not already), handles its message loop and will take
1731 * care of shutting the isolate down once it's done.
1732 *
1733 * \param errors_are_fatal Whether uncaught errors should be fatal.
1734 * \param on_error_port A port to notify on uncaught errors (or ILLEGAL_PORT).
1735 * \param on_exit_port A port to notify on exit (or ILLEGAL_PORT).
1736 * \param error A non-NULL pointer which will hold an error message if the call
1737 * fails. The error has to be free()ed by the caller.
1738 *
1739 * \return If successful the VM takes ownership of the isolate and takes care
1740 * of its message loop. If not successful the caller retains ownership of the
1741 * isolate.
1742 */
1744 bool errors_are_fatal,
1745 Dart_Port on_error_port,
1746 Dart_Port on_exit_port,
1747 char** error);
1748
1749/* TODO(turnidge): Should this be removed from the public api? */
1750
1751/**
1752 * Gets the main port id for the current isolate.
1753 */
1755
1756/**
1757 * Does the current isolate have live ReceivePorts?
1758 *
1759 * A ReceivePort is live when it has not been closed.
1760 */
1762
1763/**
1764 * Posts a message for some isolate. The message is a serialized
1765 * object.
1766 *
1767 * Requires there to be a current isolate.
1768 *
1769 * For posting messages outside of an isolate see \ref Dart_PostCObject.
1770 *
1771 * \param port_id The destination port.
1772 * \param object An object from the current isolate.
1773 *
1774 * \return True if the message was posted.
1775 */
1777
1778/**
1779 * Returns a new SendPort with the provided port id.
1780 *
1781 * If there is a possibility of a port closing since port_id was acquired
1782 * for a SendPort, one should use Dart_NewSendPortEx and
1783 * Dart_SendPortGetIdEx.
1784 *
1785 * \param port_id The destination port.
1786 *
1787 * \return A new SendPort if no errors occurs. Otherwise returns
1788 * an error handle.
1789 */
1791
1792/**
1793 * Returns a new SendPort with the provided port id and origin id.
1794 *
1795 * \param portex_id The destination composte port id.
1796 *
1797 * \return A new SendPort if no errors occurs. Otherwise returns
1798 * an error handle.
1799 */
1801
1802/**
1803 * Gets the SendPort id for the provided SendPort.
1804 * \param port A SendPort object whose id is desired.
1805 * \param port_id Returns the id of the SendPort.
1806 * \return Success if no error occurs. Otherwise returns
1807 * an error handle.
1808 */
1810 Dart_Port* port_id);
1811
1812/**
1813 * Gets the SendPort and Origin ids for the provided SendPort.
1814 * \param port A SendPort object whose id is desired.
1815 * \param portex_id Returns composite id of the SendPort.
1816 * \return Success if no error occurs. Otherwise returns
1817 * an error handle.
1818 */
1820 Dart_PortEx* portex_id);
1821/*
1822 * ======
1823 * Scopes
1824 * ======
1825 */
1826
1827/**
1828 * Enters a new scope.
1829 *
1830 * All new local handles will be created in this scope. Additionally,
1831 * some functions may return "scope allocated" memory which is only
1832 * valid within this scope.
1833 *
1834 * Requires there to be a current isolate.
1835 */
1837
1838/**
1839 * Exits a scope.
1840 *
1841 * The previous scope (if any) becomes the current scope.
1842 *
1843 * Requires there to be a current isolate.
1844 */
1846
1847/**
1848 * The Dart VM uses "zone allocation" for temporary structures. Zones
1849 * support very fast allocation of small chunks of memory. The chunks
1850 * cannot be deallocated individually, but instead zones support
1851 * deallocating all chunks in one fast operation.
1852 *
1853 * This function makes it possible for the embedder to allocate
1854 * temporary data in the VMs zone allocator.
1855 *
1856 * Zone allocation is possible:
1857 * 1. when inside a scope where local handles can be allocated
1858 * 2. when processing a message from a native port in a native port
1859 * handler
1860 *
1861 * All the memory allocated this way will be reclaimed either on the
1862 * next call to Dart_ExitScope or when the native port handler exits.
1863 *
1864 * \param size Size of the memory to allocate.
1865 *
1866 * \return A pointer to the allocated memory. NULL if allocation
1867 * failed. Failure might due to is no current VM zone.
1868 */
1870
1871/*
1872 * =======
1873 * Objects
1874 * =======
1875 */
1876
1877/**
1878 * Returns the null object.
1879 *
1880 * \return A handle to the null object.
1881 */
1883
1884/**
1885 * Is this object null?
1886 */
1888
1889/**
1890 * Returns the empty string object.
1891 *
1892 * \return A handle to the empty string object.
1893 */
1895
1896/**
1897 * Returns types that are not classes, and which therefore cannot be looked up
1898 * as library members by Dart_GetType.
1899 *
1900 * \return A handle to the dynamic, void or Never type.
1901 */
1905
1906/**
1907 * Checks if the two objects are equal.
1908 *
1909 * The result of the comparison is returned through the 'equal'
1910 * parameter. The return value itself is used to indicate success or
1911 * failure, not equality.
1912 *
1913 * May generate an unhandled exception error.
1914 *
1915 * \param obj1 An object to be compared.
1916 * \param obj2 An object to be compared.
1917 * \param equal Returns the result of the equality comparison.
1918 *
1919 * \return A valid handle if no error occurs during the comparison.
1920 */
1922 Dart_Handle obj2,
1923 bool* equal);
1924
1925/**
1926 * Is this object an instance of some type?
1927 *
1928 * The result of the test is returned through the 'instanceof' parameter.
1929 * The return value itself is used to indicate success or failure.
1930 *
1931 * \param object An object.
1932 * \param type A type.
1933 * \param instanceof Return true if 'object' is an instance of type 'type'.
1934 *
1935 * \return A valid handle if no error occurs during the operation.
1936 */
1939 bool* instanceof);
1940
1941/**
1942 * Query object type.
1943 *
1944 * \param object Some Object.
1945 *
1946 * \return true if Object is of the specified type.
1947 */
1954DART_EXPORT bool Dart_IsStringLatin1(Dart_Handle object); /* (ISO-8859-1) */
1966
1967/*
1968 * =========
1969 * Instances
1970 * =========
1971 */
1972
1973/*
1974 * For the purposes of the embedding api, not all objects returned are
1975 * Dart language objects. Within the api, we use the term 'Instance'
1976 * to indicate handles which refer to true Dart language objects.
1977 *
1978 * TODO(turnidge): Reorganize the "Object" section above, pulling down
1979 * any functions that more properly belong here. */
1980
1981/**
1982 * Gets the type of a Dart language object.
1983 *
1984 * \param instance Some Dart object.
1985 *
1986 * \return If no error occurs, the type is returned. Otherwise an
1987 * error handle is returned.
1988 */
1990
1991/**
1992 * Returns the name for the provided class type.
1993 *
1994 * \return A valid string handle if no error occurs during the
1995 * operation.
1996 */
1998
1999/**
2000 * Returns the name for the provided function or method.
2001 *
2002 * \return A valid string handle if no error occurs during the
2003 * operation.
2004 */
2006
2007/**
2008 * Returns a handle to the owner of a function.
2009 *
2010 * The owner of an instance method or a static method is its defining
2011 * class. The owner of a top-level function is its defining
2012 * library. The owner of the function of a non-implicit closure is the
2013 * function of the method or closure that defines the non-implicit
2014 * closure.
2015 *
2016 * \return A valid handle to the owner of the function, or an error
2017 * handle if the argument is not a valid handle to a function.
2018 */
2020
2021/**
2022 * Determines whether a function handle refers to a static function
2023 * of method.
2024 *
2025 * For the purposes of the embedding API, a top-level function is
2026 * implicitly declared static.
2027 *
2028 * \param function A handle to a function or method declaration.
2029 * \param is_static Returns whether the function or method is declared static.
2030 *
2031 * \return A valid handle if no error occurs during the operation.
2032 */
2034 bool* is_static);
2035
2036/**
2037 * Is this object a closure resulting from a tear-off (closurized method)?
2038 *
2039 * Returns true for closures produced when an ordinary method is accessed
2040 * through a getter call. Returns false otherwise, in particular for closures
2041 * produced from local function declarations.
2042 *
2043 * \param object Some Object.
2044 *
2045 * \return true if Object is a tear-off.
2046 */
2048
2049/**
2050 * Retrieves the function of a closure.
2051 *
2052 * \return A handle to the function of the closure, or an error handle if the
2053 * argument is not a closure.
2054 */
2056
2057/**
2058 * Returns a handle to the library which contains class.
2059 *
2060 * \return A valid handle to the library with owns class, null if the class
2061 * has no library or an error handle if the argument is not a valid handle
2062 * to a class type.
2063 */
2065
2066/*
2067 * =============================
2068 * Numbers, Integers and Doubles
2069 * =============================
2070 */
2071
2072/**
2073 * Does this Integer fit into a 64-bit signed integer?
2074 *
2075 * \param integer An integer.
2076 * \param fits Returns true if the integer fits into a 64-bit signed integer.
2077 *
2078 * \return A valid handle if no error occurs during the operation.
2079 */
2081 bool* fits);
2082
2083/**
2084 * Does this Integer fit into a 64-bit unsigned integer?
2085 *
2086 * \param integer An integer.
2087 * \param fits Returns true if the integer fits into a 64-bit unsigned integer.
2088 *
2089 * \return A valid handle if no error occurs during the operation.
2090 */
2092 bool* fits);
2093
2094/**
2095 * Returns an Integer with the provided value.
2096 *
2097 * \param value The value of the integer.
2098 *
2099 * \return The Integer object if no error occurs. Otherwise returns
2100 * an error handle.
2101 */
2103
2104/**
2105 * Returns an Integer with the provided value.
2106 *
2107 * \param value The unsigned value of the integer.
2108 *
2109 * \return The Integer object if no error occurs. Otherwise returns
2110 * an error handle.
2111 */
2113
2114/**
2115 * Returns an Integer with the provided value.
2116 *
2117 * \param value The value of the integer represented as a C string
2118 * containing a hexadecimal number.
2119 *
2120 * \return The Integer object if no error occurs. Otherwise returns
2121 * an error handle.
2122 */
2124
2125/**
2126 * Gets the value of an Integer.
2127 *
2128 * The integer must fit into a 64-bit signed integer, otherwise an error occurs.
2129 *
2130 * \param integer An Integer.
2131 * \param value Returns the value of the Integer.
2132 *
2133 * \return A valid handle if no error occurs during the operation.
2134 */
2136 int64_t* value);
2137
2138/**
2139 * Gets the value of an Integer.
2140 *
2141 * The integer must fit into a 64-bit unsigned integer, otherwise an
2142 * error occurs.
2143 *
2144 * \param integer An Integer.
2145 * \param value Returns the value of the Integer.
2146 *
2147 * \return A valid handle if no error occurs during the operation.
2148 */
2150 uint64_t* value);
2151
2152/**
2153 * Gets the value of an integer as a hexadecimal C string.
2154 *
2155 * \param integer An Integer.
2156 * \param value Returns the value of the Integer as a hexadecimal C
2157 * string. This C string is scope allocated and is only valid until
2158 * the next call to Dart_ExitScope.
2159 *
2160 * \return A valid handle if no error occurs during the operation.
2161 */
2163 const char** value);
2164
2165/**
2166 * Returns a Double with the provided value.
2167 *
2168 * \param value A double.
2169 *
2170 * \return The Double object if no error occurs. Otherwise returns
2171 * an error handle.
2172 */
2174
2175/**
2176 * Gets the value of a Double
2177 *
2178 * \param double_obj A Double
2179 * \param value Returns the value of the Double.
2180 *
2181 * \return A valid handle if no error occurs during the operation.
2182 */
2184
2185/**
2186 * Returns a closure of static function 'function_name' in the class 'class_name'
2187 * in the exported namespace of specified 'library'.
2188 *
2189 * \param library Library object
2190 * \param cls_type Type object representing a Class
2191 * \param function_name Name of the static function in the class
2192 *
2193 * \return A valid Dart instance if no error occurs during the operation.
2194 */
2196 Dart_Handle cls_type,
2198
2199/*
2200 * ========
2201 * Booleans
2202 * ========
2203 */
2204
2205/**
2206 * Returns the True object.
2207 *
2208 * Requires there to be a current isolate.
2209 *
2210 * \return A handle to the True object.
2211 */
2213
2214/**
2215 * Returns the False object.
2216 *
2217 * Requires there to be a current isolate.
2218 *
2219 * \return A handle to the False object.
2220 */
2222
2223/**
2224 * Returns a Boolean with the provided value.
2225 *
2226 * \param value true or false.
2227 *
2228 * \return The Boolean object if no error occurs. Otherwise returns
2229 * an error handle.
2230 */
2232
2233/**
2234 * Gets the value of a Boolean
2235 *
2236 * \param boolean_obj A Boolean
2237 * \param value Returns the value of the Boolean.
2238 *
2239 * \return A valid handle if no error occurs during the operation.
2240 */
2242
2243/*
2244 * =======
2245 * Strings
2246 * =======
2247 */
2248
2249/**
2250 * Gets the length of a String.
2251 *
2252 * \param str A String.
2253 * \param length Returns the length of the String.
2254 *
2255 * \return A valid handle if no error occurs during the operation.
2256 */
2258
2259/**
2260 * Gets the length of UTF-8 encoded representation for a string.
2261 *
2262 * \param str A String.
2263 * \param length Returns the length of UTF-8 encoded representation for string.
2264 *
2265 * \return A valid handle if no error occurs during the operation.
2266 */
2268 intptr_t* length);
2269
2270/**
2271 * Returns a String built from the provided C string
2272 * (There is an implicit assumption that the C string passed in contains
2273 * UTF-8 encoded characters and '\0' is considered as a termination
2274 * character).
2275 *
2276 * \param str A C String
2277 *
2278 * \return The String object if no error occurs. Otherwise returns
2279 * an error handle.
2280 */
2282/* TODO(turnidge): Document what happens when we run out of memory
2283 * during this call. */
2284
2285/**
2286 * Returns a String built from an array of UTF-8 encoded characters.
2287 *
2288 * \param utf8_array An array of UTF-8 encoded characters.
2289 * \param length The length of the codepoints array.
2290 *
2291 * \return The String object if no error occurs. Otherwise returns
2292 * an error handle.
2293 */
2295 intptr_t length);
2296
2297/**
2298 * Returns a String built from an array of UTF-16 encoded characters.
2299 *
2300 * \param utf16_array An array of UTF-16 encoded characters.
2301 * \param length The length of the codepoints array.
2302 *
2303 * \return The String object if no error occurs. Otherwise returns
2304 * an error handle.
2305 */
2307 intptr_t length);
2308
2309/**
2310 * Returns a String built from an array of UTF-32 encoded characters.
2311 *
2312 * \param utf32_array An array of UTF-32 encoded characters.
2313 * \param length The length of the codepoints array.
2314 *
2315 * \return The String object if no error occurs. Otherwise returns
2316 * an error handle.
2317 */
2319 intptr_t length);
2320
2321/**
2322 * Gets the C string representation of a String.
2323 * (It is a sequence of UTF-8 encoded values with a '\0' termination.)
2324 *
2325 * \param str A string.
2326 * \param cstr Returns the String represented as a C string.
2327 * This C string is scope allocated and is only valid until
2328 * the next call to Dart_ExitScope.
2329 *
2330 * \return A valid handle if no error occurs during the operation.
2331 */
2333 const char** cstr);
2334
2335/**
2336 * Gets a UTF-8 encoded representation of a String.
2337 *
2338 * Any unpaired surrogate code points in the string will be converted as
2339 * replacement characters (U+FFFD, 0xEF 0xBF 0xBD in UTF-8). If you need
2340 * to preserve unpaired surrogates, use the Dart_StringToUTF16 function.
2341 *
2342 * \param str A string.
2343 * \param utf8_array Returns the String represented as UTF-8 code
2344 * units. This UTF-8 array is scope allocated and is only valid
2345 * until the next call to Dart_ExitScope.
2346 * \param length Used to return the length of the array which was
2347 * actually used.
2348 *
2349 * \return A valid handle if no error occurs during the operation.
2350 */
2352 uint8_t** utf8_array,
2353 intptr_t* length);
2354
2355/**
2356 * Copies the UTF-8 encoded representation of a String into specified buffer.
2357 *
2358 * Any unpaired surrogate code points in the string will be converted as
2359 * replacement characters (U+FFFD, 0xEF 0xBF 0xBD in UTF-8).
2360 *
2361 * \param str A string.
2362 * \param utf8_array Buffer into which the UTF-8 encoded representation of
2363 * the string is copied into.
2364 * The buffer is allocated and managed by the caller.
2365 * \param length Specifies the length of the buffer passed in.
2366 *
2367 * \return A valid handle if no error occurs during the operation.
2368 */
2370 uint8_t* utf8_array,
2371 intptr_t length);
2372
2373/**
2374 * Gets the data corresponding to the string object. This function returns
2375 * the data only for Latin-1 (ISO-8859-1) string objects. For all other
2376 * string objects it returns an error.
2377 *
2378 * \param str A string.
2379 * \param latin1_array An array allocated by the caller, used to return
2380 * the string data.
2381 * \param length Used to pass in the length of the provided array.
2382 * Used to return the length of the array which was actually used.
2383 *
2384 * \return A valid handle if no error occurs during the operation.
2385 */
2387 uint8_t* latin1_array,
2388 intptr_t* length);
2389
2390/**
2391 * Gets the UTF-16 encoded representation of a string.
2392 *
2393 * \param str A string.
2394 * \param utf16_array An array allocated by the caller, used to return
2395 * the array of UTF-16 encoded characters.
2396 * \param length Used to pass in the length of the provided array.
2397 * Used to return the length of the array which was actually used.
2398 *
2399 * \return A valid handle if no error occurs during the operation.
2400 */
2402 uint16_t* utf16_array,
2403 intptr_t* length);
2404
2405/**
2406 * Gets the storage size in bytes of a String.
2407 *
2408 * \param str A String.
2409 * \param size Returns the storage size in bytes of the String.
2410 * This is the size in bytes needed to store the String.
2411 *
2412 * \return A valid handle if no error occurs during the operation.
2413 */
2415
2416/**
2417 * Retrieves some properties associated with a String.
2418 * Properties retrieved are:
2419 * - character size of the string (one or two byte)
2420 * - length of the string
2421 * - peer pointer of string if it is an external string.
2422 * \param str A String.
2423 * \param char_size Returns the character size of the String.
2424 * \param str_len Returns the length of the String.
2425 * \param peer Returns the peer pointer associated with the String or 0 if
2426 * there is no peer pointer for it.
2427 * \return Success if no error occurs. Otherwise returns
2428 * an error handle.
2429 */
2431 intptr_t* char_size,
2432 intptr_t* str_len,
2433 void** peer);
2434
2435/*
2436 * =====
2437 * Lists
2438 * =====
2439 */
2440
2441/**
2442 * Returns a List<dynamic> of the desired length.
2443 *
2444 * \param length The length of the list.
2445 *
2446 * \return The List object if no error occurs. Otherwise returns
2447 * an error handle.
2448 */
2450
2451/**
2452 * Returns a List of the desired length with the desired element type.
2453 *
2454 * \param element_type Handle to a nullable type object. E.g., from
2455 * Dart_GetType or Dart_GetNullableType.
2456 *
2457 * \param length The length of the list.
2458 *
2459 * \return The List object if no error occurs. Otherwise returns
2460 * an error handle.
2461 */
2463 intptr_t length);
2464
2465/**
2466 * Returns a List of the desired length with the desired element type, filled
2467 * with the provided object.
2468 *
2469 * \param element_type Handle to a type object. E.g., from Dart_GetType.
2470 *
2471 * \param fill_object Handle to an object of type 'element_type' that will be
2472 * used to populate the list. This parameter can only be Dart_Null() if the
2473 * length of the list is 0 or 'element_type' is a nullable type.
2474 *
2475 * \param length The length of the list.
2476 *
2477 * \return The List object if no error occurs. Otherwise returns
2478 * an error handle.
2479 */
2481 Dart_Handle fill_object,
2482 intptr_t length);
2483
2484/**
2485 * Gets the length of a List.
2486 *
2487 * May generate an unhandled exception error.
2488 *
2489 * \param list A List.
2490 * \param length Returns the length of the List.
2491 *
2492 * \return A valid handle if no error occurs during the operation.
2493 */
2495
2496/**
2497 * Gets the Object at some index of a List.
2498 *
2499 * If the index is out of bounds, an error occurs.
2500 *
2501 * May generate an unhandled exception error.
2502 *
2503 * \param list A List.
2504 * \param index A valid index into the List.
2505 *
2506 * \return The Object in the List at the specified index if no error
2507 * occurs. Otherwise returns an error handle.
2508 */
2510
2511/**
2512* Gets a range of Objects from a List.
2513*
2514* If any of the requested index values are out of bounds, an error occurs.
2515*
2516* May generate an unhandled exception error.
2517*
2518* \param list A List.
2519* \param offset The offset of the first item to get.
2520* \param length The number of items to get.
2521* \param result A pointer to fill with the objects.
2522*
2523* \return Success if no error occurs during the operation.
2524*/
2526 intptr_t offset,
2527 intptr_t length,
2529
2530/**
2531 * Sets the Object at some index of a List.
2532 *
2533 * If the index is out of bounds, an error occurs.
2534 *
2535 * May generate an unhandled exception error.
2536 *
2537 * \param list A List.
2538 * \param index A valid index into the List.
2539 * \param value The Object to put in the List.
2540 *
2541 * \return A valid handle if no error occurs during the operation.
2542 */
2544 intptr_t index,
2546
2547/**
2548 * May generate an unhandled exception error.
2549 */
2551 intptr_t offset,
2552 uint8_t* native_array,
2553 intptr_t length);
2554
2555/**
2556 * May generate an unhandled exception error.
2557 */
2559 intptr_t offset,
2560 const uint8_t* native_array,
2561 intptr_t length);
2562
2563/*
2564 * ====
2565 * Maps
2566 * ====
2567 */
2568
2569/**
2570 * Gets the Object at some key of a Map.
2571 *
2572 * May generate an unhandled exception error.
2573 *
2574 * \param map A Map.
2575 * \param key An Object.
2576 *
2577 * \return The value in the map at the specified key, null if the map does not
2578 * contain the key, or an error handle.
2579 */
2581
2582/**
2583 * Returns whether the Map contains a given key.
2584 *
2585 * May generate an unhandled exception error.
2586 *
2587 * \param map A Map.
2588 *
2589 * \return A handle on a boolean indicating whether map contains the key.
2590 * Otherwise returns an error handle.
2591 */
2593
2594/**
2595 * Gets the list of keys of a Map.
2596 *
2597 * May generate an unhandled exception error.
2598 *
2599 * \param map A Map.
2600 *
2601 * \return The list of key Objects if no error occurs. Otherwise returns an
2602 * error handle.
2603 */
2605
2606/*
2607 * ==========
2608 * Typed Data
2609 * ==========
2610 */
2611
2612typedef enum {
2630
2631/**
2632 * Return type if this object is a TypedData object.
2633 *
2634 * \return kInvalid if the object is not a TypedData object or the appropriate
2635 * Dart_TypedData_Type.
2636 */
2638
2639/**
2640 * Return type if this object is an external TypedData object.
2641 *
2642 * \return kInvalid if the object is not an external TypedData object or
2643 * the appropriate Dart_TypedData_Type.
2644 */
2647
2648/**
2649 * Returns a TypedData object of the desired length and type.
2650 *
2651 * \param type The type of the TypedData object.
2652 * \param length The length of the TypedData object (length in type units).
2653 *
2654 * \return The TypedData object if no error occurs. Otherwise returns
2655 * an error handle.
2656 */
2658 intptr_t length);
2659
2660/**
2661 * Returns a TypedData object which references an external data array.
2662 *
2663 * \param type The type of the data array.
2664 * \param data A data array. This array must not move.
2665 * \param length The length of the data array (length in type units).
2666 *
2667 * \return The TypedData object if no error occurs. Otherwise returns
2668 * an error handle.
2669 */
2671 void* data,
2672 intptr_t length);
2673
2674/**
2675 * Returns a TypedData object which references an external data array.
2676 *
2677 * \param type The type of the data array.
2678 * \param data A data array. This array must not move.
2679 * \param length The length of the data array (length in type units).
2680 * \param peer A pointer to a native object or NULL. This value is
2681 * provided to callback when it is invoked.
2682 * \param external_allocation_size The number of externally allocated
2683 * bytes for peer. Used to inform the garbage collector.
2684 * \param callback A function pointer that will be invoked sometime
2685 * after the object is garbage collected, unless the handle has been deleted.
2686 * A valid callback needs to be specified it cannot be NULL.
2687 *
2688 * \return The TypedData object if no error occurs. Otherwise returns
2689 * an error handle.
2690 */
2693 void* data,
2694 intptr_t length,
2695 void* peer,
2696 intptr_t external_allocation_size,
2700 const void* data,
2701 intptr_t length,
2702 void* peer,
2703 intptr_t external_allocation_size,
2705
2706/**
2707 * Returns a ByteBuffer object for the typed data.
2708 *
2709 * \param typed_data The TypedData object.
2710 *
2711 * \return The ByteBuffer object if no error occurs. Otherwise returns
2712 * an error handle.
2713 */
2715
2716/**
2717 * Acquires access to the internal data address of a TypedData object.
2718 *
2719 * \param object The typed data object whose internal data address is to
2720 * be accessed.
2721 * \param type The type of the object is returned here.
2722 * \param data The internal data address is returned here.
2723 * \param len Size of the typed array is returned here.
2724 *
2725 * Notes:
2726 * When the internal address of the object is acquired any calls to a
2727 * Dart API function that could potentially allocate an object or run
2728 * any Dart code will return an error.
2729 *
2730 * Any Dart API functions for accessing the data should not be called
2731 * before the corresponding release. In particular, the object should
2732 * not be acquired again before its release. This leads to undefined
2733 * behavior.
2734 *
2735 * \return Success if the internal data address is acquired successfully.
2736 * Otherwise, returns an error handle.
2737 */
2740 void** data,
2741 intptr_t* len);
2742
2743/**
2744 * Releases access to the internal data address that was acquired earlier using
2745 * Dart_TypedDataAcquireData.
2746 *
2747 * \param object The typed data object whose internal data address is to be
2748 * released.
2749 *
2750 * \return Success if the internal data address is released successfully.
2751 * Otherwise, returns an error handle.
2752 */
2754
2755/**
2756 * Returns the TypedData object associated with the ByteBuffer object.
2757 *
2758 * \param byte_buffer The ByteBuffer object.
2759 *
2760 * \return The TypedData object if no error occurs. Otherwise returns
2761 * an error handle.
2762 */
2764
2765/*
2766 * ============================================================
2767 * Invoking Constructors, Methods, Closures and Field accessors
2768 * ============================================================
2769 */
2770
2771/**
2772 * Invokes a constructor, creating a new object.
2773 *
2774 * This function allows hidden constructors (constructors with leading
2775 * underscores) to be called.
2776 *
2777 * \param type Type of object to be constructed.
2778 * \param constructor_name The name of the constructor to invoke. Use
2779 * Dart_Null() or Dart_EmptyString() to invoke the unnamed constructor.
2780 * This name should not include the name of the class.
2781 * \param number_of_arguments Size of the arguments array.
2782 * \param arguments An array of arguments to the constructor.
2783 *
2784 * \return If the constructor is called and completes successfully,
2785 * then the new object. If an error occurs during execution, then an
2786 * error handle is returned.
2787 */
2790 Dart_Handle constructor_name,
2791 int number_of_arguments,
2792 Dart_Handle* arguments);
2793
2794/**
2795 * Allocate a new object without invoking a constructor.
2796 *
2797 * \param type The type of an object to be allocated.
2798 *
2799 * \return The new object. If an error occurs during execution, then an
2800 * error handle is returned.
2801 */
2803
2804/**
2805 * Allocate a new object without invoking a constructor, and sets specified
2806 * native fields.
2807 *
2808 * \param type The type of an object to be allocated.
2809 * \param num_native_fields The number of native fields to set.
2810 * \param native_fields An array containing the value of native fields.
2811 *
2812 * \return The new object. If an error occurs during execution, then an
2813 * error handle is returned.
2814 */
2817 intptr_t num_native_fields,
2818 const intptr_t* native_fields);
2819
2820/**
2821 * Invokes a method or function.
2822 *
2823 * The 'target' parameter may be an object, type, or library. If
2824 * 'target' is an object, then this function will invoke an instance
2825 * method. If 'target' is a type, then this function will invoke a
2826 * static method. If 'target' is a library, then this function will
2827 * invoke a top-level function from that library.
2828 * NOTE: This API call cannot be used to invoke methods of a type object.
2829 *
2830 * This function ignores visibility (leading underscores in names).
2831 *
2832 * May generate an unhandled exception error.
2833 *
2834 * \param target An object, type, or library.
2835 * \param name The name of the function or method to invoke.
2836 * \param number_of_arguments Size of the arguments array.
2837 * \param arguments An array of arguments to the function.
2838 *
2839 * \return If the function or method is called and completes
2840 * successfully, then the return value is returned. If an error
2841 * occurs during execution, then an error handle is returned.
2842 */
2846 int number_of_arguments,
2847 Dart_Handle* arguments);
2848/* TODO(turnidge): Document how to invoke operators. */
2849
2850/**
2851 * Invokes a Closure with the given arguments.
2852 *
2853 * May generate an unhandled exception error.
2854 *
2855 * \return If no error occurs during execution, then the result of
2856 * invoking the closure is returned. If an error occurs during
2857 * execution, then an error handle is returned.
2858 */
2861 int number_of_arguments,
2862 Dart_Handle* arguments);
2863
2864/**
2865 * Invokes a Generative Constructor on an object that was previously
2866 * allocated using Dart_Allocate/Dart_AllocateWithNativeFields.
2867 *
2868 * The 'object' parameter must be an object.
2869 *
2870 * This function ignores visibility (leading underscores in names).
2871 *
2872 * May generate an unhandled exception error.
2873 *
2874 * \param object An object.
2875 * \param name The name of the constructor to invoke.
2876 * Use Dart_Null() or Dart_EmptyString() to invoke the unnamed constructor.
2877 * \param number_of_arguments Size of the arguments array.
2878 * \param arguments An array of arguments to the function.
2879 *
2880 * \return If the constructor is called and completes
2881 * successfully, then the object is returned. If an error
2882 * occurs during execution, then an error handle is returned.
2883 */
2887 int number_of_arguments,
2888 Dart_Handle* arguments);
2889
2890/**
2891 * Gets the value of a field.
2892 *
2893 * The 'container' parameter may be an object, type, or library. If
2894 * 'container' is an object, then this function will access an
2895 * instance field. If 'container' is a type, then this function will
2896 * access a static field. If 'container' is a library, then this
2897 * function will access a top-level variable.
2898 * NOTE: This API call cannot be used to access fields of a type object.
2899 *
2900 * This function ignores field visibility (leading underscores in names).
2901 *
2902 * May generate an unhandled exception error.
2903 *
2904 * \param container An object, type, or library.
2905 * \param name A field name.
2906 *
2907 * \return If no error occurs, then the value of the field is
2908 * returned. Otherwise an error handle is returned.
2909 */
2912
2913/**
2914 * Sets the value of a field.
2915 *
2916 * The 'container' parameter may actually be an object, type, or
2917 * library. If 'container' is an object, then this function will
2918 * access an instance field. If 'container' is a type, then this
2919 * function will access a static field. If 'container' is a library,
2920 * then this function will access a top-level variable.
2921 * NOTE: This API call cannot be used to access fields of a type object.
2922 *
2923 * This function ignores field visibility (leading underscores in names).
2924 *
2925 * May generate an unhandled exception error.
2926 *
2927 * \param container An object, type, or library.
2928 * \param name A field name.
2929 * \param value The new field value.
2930 *
2931 * \return A valid handle if no error occurs.
2932 */
2935
2936/*
2937 * ==========
2938 * Exceptions
2939 * ==========
2940 */
2941
2942/*
2943 * TODO(turnidge): Remove these functions from the api and replace all
2944 * uses with Dart_NewUnhandledExceptionError. */
2945
2946/**
2947 * Throws an exception.
2948 *
2949 * This function causes a Dart language exception to be thrown. This
2950 * will proceed in the standard way, walking up Dart frames until an
2951 * appropriate 'catch' block is found, executing 'finally' blocks,
2952 * etc.
2953 *
2954 * If an error handle is passed into this function, the error is
2955 * propagated immediately. See Dart_PropagateError for a discussion
2956 * of error propagation.
2957 *
2958 * If successful, this function does not return. Note that this means
2959 * that the destructors of any stack-allocated C++ objects will not be
2960 * called. If there are no Dart frames on the stack, an error occurs.
2961 *
2962 * \return An error handle if the exception was not thrown.
2963 * Otherwise the function does not return.
2964 */
2966
2967/**
2968 * Rethrows an exception.
2969 *
2970 * Rethrows an exception, unwinding all dart frames on the stack. If
2971 * successful, this function does not return. Note that this means
2972 * that the destructors of any stack-allocated C++ objects will not be
2973 * called. If there are no Dart frames on the stack, an error occurs.
2974 *
2975 * \return An error handle if the exception was not thrown.
2976 * Otherwise the function does not return.
2977 */
2979 Dart_Handle stacktrace);
2980
2981/*
2982 * ===========================
2983 * Native fields and functions
2984 * ===========================
2985 */
2986
2987/**
2988 * Gets the number of native instance fields in an object.
2989 */
2991 int* count);
2992
2993/**
2994 * Gets the value of a native field.
2995 *
2996 * TODO(turnidge): Document.
2997 */
2999 int index,
3000 intptr_t* value);
3001
3002/**
3003 * Sets the value of a native field.
3004 *
3005 * TODO(turnidge): Document.
3006 */
3008 int index,
3009 intptr_t value);
3010
3011/**
3012 * The arguments to a native function.
3013 *
3014 * This object is passed to a native function to represent its
3015 * arguments and return value. It allows access to the arguments to a
3016 * native function by index. It also allows the return value of a
3017 * native function to be set.
3018 */
3019typedef struct _Dart_NativeArguments* Dart_NativeArguments;
3020
3021/**
3022 * Extracts current isolate group data from the native arguments structure.
3023 */
3025
3026typedef enum {
3037
3039 uint8_t type;
3040 uint8_t index;
3042
3045 int32_t as_int32;
3046 uint32_t as_uint32;
3047 int64_t as_int64;
3048 uint64_t as_uint64;
3050 struct {
3052 void* peer;
3054 struct {
3055 intptr_t num_fields;
3056 intptr_t* values;
3060
3061enum {
3066};
3067
3068#define BITMASK(size) ((1 << size) - 1)
3069#define DART_NATIVE_ARG_DESCRIPTOR(type, position) \
3070 (((type & BITMASK(kNativeArgTypeSize)) << kNativeArgTypePos) | \
3071 (position & BITMASK(kNativeArgNumberSize)))
3072
3073/**
3074 * Gets the native arguments based on the types passed in and populates
3075 * the passed arguments buffer with appropriate native values.
3076 *
3077 * \param args the Native arguments block passed into the native call.
3078 * \param num_arguments length of argument descriptor array and argument
3079 * values array passed in.
3080 * \param arg_descriptors an array that describes the arguments that
3081 * need to be retrieved. For each argument to be retrieved the descriptor
3082 * contains the argument number (0, 1 etc.) and the argument type
3083 * described using Dart_NativeArgument_Type, e.g:
3084 * DART_NATIVE_ARG_DESCRIPTOR(Dart_NativeArgument_kBool, 1) indicates
3085 * that the first argument is to be retrieved and it should be a boolean.
3086 * \param arg_values array into which the native arguments need to be
3087 * extracted into, the array is allocated by the caller (it could be
3088 * stack allocated to avoid the malloc/free performance overhead).
3089 *
3090 * \return Success if all the arguments could be extracted correctly,
3091 * returns an error handle if there were any errors while extracting the
3092 * arguments (mismatched number of arguments, incorrect types, etc.).
3093 */
3096 int num_arguments,
3097 const Dart_NativeArgument_Descriptor* arg_descriptors,
3098 Dart_NativeArgument_Value* arg_values);
3099
3100/**
3101 * Gets the native argument at some index.
3102 */
3104 int index);
3105/* TODO(turnidge): Specify the behavior of an out-of-bounds access. */
3106
3107/**
3108 * Gets the number of native arguments.
3109 */
3111
3112/**
3113 * Gets all the native fields of the native argument at some index.
3114 * \param args Native arguments structure.
3115 * \param arg_index Index of the desired argument in the structure above.
3116 * \param num_fields size of the intptr_t array 'field_values' passed in.
3117 * \param field_values intptr_t array in which native field values are returned.
3118 * \return Success if the native fields where copied in successfully. Otherwise
3119 * returns an error handle. On success the native field values are copied
3120 * into the 'field_values' array, if the argument at 'arg_index' is a
3121 * null object then 0 is copied as the native field values into the
3122 * 'field_values' array.
3123 */
3126 int arg_index,
3127 int num_fields,
3128 intptr_t* field_values);
3129
3130/**
3131 * Gets the native field of the receiver.
3132 */
3134 intptr_t* value);
3135
3136/**
3137 * Gets a string native argument at some index.
3138 * \param args Native arguments structure.
3139 * \param arg_index Index of the desired argument in the structure above.
3140 * \param peer Returns the peer pointer if the string argument has one.
3141 * \return Success if the string argument has a peer, if it does not
3142 * have a peer then the String object is returned. Otherwise returns
3143 * an error handle (argument is not a String object).
3144 */
3146 int arg_index,
3147 void** peer);
3148
3149/**
3150 * Gets an integer native argument at some index.
3151 * \param args Native arguments structure.
3152 * \param index Index of the desired argument in the structure above.
3153 * \param value Returns the integer value if the argument is an Integer.
3154 * \return Success if no error occurs. Otherwise returns an error handle.
3155 */
3157 int index,
3158 int64_t* value);
3159
3160/**
3161 * Gets a boolean native argument at some index.
3162 * \param args Native arguments structure.
3163 * \param index Index of the desired argument in the structure above.
3164 * \param value Returns the boolean value if the argument is a Boolean.
3165 * \return Success if no error occurs. Otherwise returns an error handle.
3166 */
3168 int index,
3169 bool* value);
3170
3171/**
3172 * Gets a double native argument at some index.
3173 * \param args Native arguments structure.
3174 * \param index Index of the desired argument in the structure above.
3175 * \param value Returns the double value if the argument is a double.
3176 * \return Success if no error occurs. Otherwise returns an error handle.
3177 */
3179 int index,
3180 double* value);
3181
3182/**
3183 * Sets the return value for a native function.
3184 *
3185 * If retval is an Error handle, then error will be propagated once
3186 * the native functions exits. See Dart_PropagateError for a
3187 * discussion of how different types of errors are propagated.
3188 */
3190 Dart_Handle retval);
3191
3194
3196 bool retval);
3197
3199 int64_t retval);
3200
3202 double retval);
3203
3204/**
3205 * A native function.
3206 */
3208
3209/**
3210 * Native entry resolution callback.
3211 *
3212 * For libraries and scripts which have native functions, the embedder
3213 * can provide a native entry resolver. This callback is used to map a
3214 * name/arity to a Dart_NativeFunction. If no function is found, the
3215 * callback should return NULL.
3216 *
3217 * The parameters to the native resolver function are:
3218 * \param name a Dart string which is the name of the native function.
3219 * \param num_of_arguments is the number of arguments expected by the
3220 * native function.
3221 * \param auto_setup_scope is a boolean flag that can be set by the resolver
3222 * to indicate if this function needs a Dart API scope (see Dart_EnterScope/
3223 * Dart_ExitScope) to be setup automatically by the VM before calling into
3224 * the native function. By default most native functions would require this
3225 * to be true but some light weight native functions which do not call back
3226 * into the VM through the Dart API may not require a Dart scope to be
3227 * setup automatically.
3228 *
3229 * \return A valid Dart_NativeFunction which resolves to a native entry point
3230 * for the native function.
3231 *
3232 * See Dart_SetNativeResolver.
3233 */
3235 int num_of_arguments,
3236 bool* auto_setup_scope);
3237/* TODO(turnidge): Consider renaming to NativeFunctionResolver or
3238 * NativeResolver. */
3239
3240/**
3241 * Native entry symbol lookup callback.
3242 *
3243 * For libraries and scripts which have native functions, the embedder
3244 * can provide a callback for mapping a native entry to a symbol. This callback
3245 * maps a native function entry PC to the native function name. If no native
3246 * entry symbol can be found, the callback should return NULL.
3247 *
3248 * The parameters to the native reverse resolver function are:
3249 * \param nf A Dart_NativeFunction.
3250 *
3251 * \return A const UTF-8 string containing the symbol name or NULL.
3252 *
3253 * See Dart_SetNativeResolver.
3254 */
3255typedef const uint8_t* (*Dart_NativeEntrySymbol)(Dart_NativeFunction nf);
3256
3257/**
3258 * FFI Native C function pointer resolver callback.
3259 *
3260 * See Dart_SetFfiNativeResolver.
3261 */
3262typedef void* (*Dart_FfiNativeResolver)(const char* name, uintptr_t args_n);
3263
3264/*
3265 * ===========
3266 * Environment
3267 * ===========
3268 */
3269
3270/**
3271 * An environment lookup callback function.
3272 *
3273 * \param name The name of the value to lookup in the environment.
3274 *
3275 * \return A valid handle to a string if the name exists in the
3276 * current environment or Dart_Null() if not.
3277 */
3279
3280/**
3281 * Sets the environment callback for the current isolate. This
3282 * callback is used to lookup environment values by name in the
3283 * current environment. This enables the embedder to supply values for
3284 * the const constructors bool.fromEnvironment, int.fromEnvironment
3285 * and String.fromEnvironment.
3286 */
3289
3290/**
3291 * Sets the callback used to resolve native functions for a library.
3292 *
3293 * \param library A library.
3294 * \param resolver A native entry resolver.
3295 *
3296 * \return A valid handle if the native resolver was set successfully.
3297 */
3300 Dart_NativeEntryResolver resolver,
3301 Dart_NativeEntrySymbol symbol);
3302/* TODO(turnidge): Rename to Dart_LibrarySetNativeResolver? */
3303
3304/**
3305 * Returns the callback used to resolve native functions for a library.
3306 *
3307 * \param library A library.
3308 * \param resolver a pointer to a Dart_NativeEntryResolver
3309 *
3310 * \return A valid handle if the library was found.
3311 */
3314
3315/**
3316 * Returns the callback used to resolve native function symbols for a library.
3317 *
3318 * \param library A library.
3319 * \param resolver a pointer to a Dart_NativeEntrySymbol.
3320 *
3321 * \return A valid handle if the library was found.
3322 */
3324 Dart_NativeEntrySymbol* resolver);
3325
3326/**
3327 * Sets the callback used to resolve FFI native functions for a library.
3328 * The resolved functions are expected to be a C function pointer of the
3329 * correct signature (as specified in the `@Native<NFT>()` function
3330 * annotation in Dart code).
3331 *
3332 * NOTE: This is an experimental feature and might change in the future.
3333 *
3334 * \param library A library.
3335 * \param resolver A native function resolver.
3336 *
3337 * \return A valid handle if the native resolver was set successfully.
3338 */
3341
3342/**
3343 * Callback provided by the embedder that is used by the VM to resolve asset
3344 * paths.
3345 * If no callback is provided, using `@Native`s with `native_asset.yaml`s will
3346 * fail.
3347 *
3348 * The VM is responsible for looking up the asset path with the asset id in the
3349 * kernel mapping.
3350 * The embedder is responsible for providing the asset mapping during kernel
3351 * compilation and using the asset path to return a library handle in this
3352 * function.
3353 *
3354 * \param path The string in the asset path as passed in native_assets.yaml
3355 * during kernel compilation.
3356 *
3357 * \param error Returns NULL if creation is successful, an error message
3358 * otherwise. The caller is responsible for calling free() on the error
3359 * message.
3360 *
3361 * \return The library handle. If |error| is not-null, the return value is
3362 * undefined.
3363 */
3364typedef void* (*Dart_NativeAssetsDlopenCallback)(const char* path,
3365 char** error);
3366typedef void* (*Dart_NativeAssetsDlopenCallbackNoPath)(char** error);
3367
3368/**
3369 * Callback provided by the embedder that is used by the VM to lookup symbols
3370 * in native code assets.
3371 * If no callback is provided, using `@Native`s with `native_asset.yaml`s will
3372 * fail.
3373 *
3374 * \param handle The library handle returned from a
3375 * `Dart_NativeAssetsDlopenCallback` or
3376 * `Dart_NativeAssetsDlopenCallbackNoPath`.
3377 *
3378 * \param symbol The symbol to look up. Is a string.
3379 *
3380 * \param error Returns NULL if creation is successful, an error message
3381 * otherwise. The caller is responsible for calling free() on the error
3382 * message.
3383 *
3384 * \return The symbol address. If |error| is not-null, the return value is
3385 * undefined.
3386 */
3387typedef void* (*Dart_NativeAssetsDlsymCallback)(void* handle,
3388 const char* symbol,
3389 char** error);
3390
3391typedef struct {
3399
3400/**
3401 * Initializes native asset resolution for the current isolate group.
3402 *
3403 * The caller is responsible for ensuring this is called right after isolate
3404 * group creation, and before running any dart code (or spawning isolates).
3405 *
3406 * @param native_assets_api The callbacks used by native assets resolution.
3407 * The VM does not take ownership of the parameter,
3408 * it can be freed immediately after the call.
3409 */
3411 NativeAssetsApi* native_assets_api);
3412
3413/*
3414 * =====================
3415 * Scripts and Libraries
3416 * =====================
3417 */
3418
3419typedef enum {
3424
3425/**
3426 * The library tag handler is a multi-purpose callback provided by the
3427 * embedder to the Dart VM. The embedder implements the tag handler to
3428 * provide the ability to load Dart scripts and imports.
3429 *
3430 * -- TAGS --
3431 *
3432 * Dart_kCanonicalizeUrl
3433 *
3434 * This tag indicates that the embedder should canonicalize 'url' with
3435 * respect to 'library'. For most embedders, this is resolving the `url`
3436 * relative to the `library`s url (see `Dart_LibraryUrl`).
3437 *
3438 * Dart_kImportTag
3439 *
3440 * This tag is used to load a library from IsolateMirror.loadUri. The embedder
3441 * should call Dart_LoadLibraryFromKernel to provide the library to the VM. The
3442 * return value should be an error or library (the result from
3443 * Dart_LoadLibraryFromKernel).
3444 *
3445 * Dart_kKernelTag
3446 *
3447 * This tag is used to load the intermediate file (kernel) generated by
3448 * the Dart front end. This tag is typically used when a 'hot-reload'
3449 * of an application is needed and the VM is 'use dart front end' mode.
3450 * The dart front end typically compiles all the scripts, imports and part
3451 * files into one intermediate file hence we don't use the source/import or
3452 * script tags. The return value should be an error or a TypedData containing
3453 * the kernel bytes.
3454 *
3455 */
3457 Dart_LibraryTag tag,
3458 Dart_Handle library_or_package_map_url,
3459 Dart_Handle url);
3460
3461/**
3462 * Sets library tag handler for the current isolate. This handler is
3463 * used to handle the various tags encountered while loading libraries
3464 * or scripts in the isolate.
3465 *
3466 * \param handler Handler code to be used for handling the various tags
3467 * encountered while loading libraries or scripts in the isolate.
3468 *
3469 * \return If no error occurs, the handler is set for the isolate.
3470 * Otherwise an error handle is returned.
3471 *
3472 * TODO(turnidge): Document.
3473 */
3476
3477/**
3478 * Handles deferred loading requests. When this handler is invoked, it should
3479 * eventually load the deferred loading unit with the given id and call
3480 * Dart_DeferredLoadComplete or Dart_DeferredLoadCompleteError. It is
3481 * recommended that the loading occur asynchronously, but it is permitted to
3482 * call Dart_DeferredLoadComplete or Dart_DeferredLoadCompleteError before the
3483 * handler returns.
3484 *
3485 * If an error is returned, it will be propagated through
3486 * `prefix.loadLibrary()`. This is useful for synchronous
3487 * implementations, which must propagate any unwind errors from
3488 * Dart_DeferredLoadComplete or Dart_DeferredLoadComplete. Otherwise the handler
3489 * should return a non-error such as `Dart_Null()`.
3490 */
3491typedef Dart_Handle (*Dart_DeferredLoadHandler)(intptr_t loading_unit_id);
3492
3493/**
3494 * Sets the deferred load handler for the current isolate. This handler is
3495 * used to handle loading deferred imports in an AppJIT or AppAOT program.
3496 */
3499
3500/**
3501 * Notifies the VM that a deferred load completed successfully. This function
3502 * will eventually cause the corresponding `prefix.loadLibrary()` futures to
3503 * complete.
3504 *
3505 * Requires the current isolate to be the same current isolate during the
3506 * invocation of the Dart_DeferredLoadHandler.
3507 */
3509Dart_DeferredLoadComplete(intptr_t loading_unit_id,
3510 const uint8_t* snapshot_data,
3511 const uint8_t* snapshot_instructions);
3512
3513/**
3514 * Notifies the VM that a deferred load failed. This function
3515 * will eventually cause the corresponding `prefix.loadLibrary()` futures to
3516 * complete with an error.
3517 *
3518 * If `transient` is true, future invocations of `prefix.loadLibrary()` will
3519 * trigger new load requests. If false, futures invocation will complete with
3520 * the same error.
3521 *
3522 * Requires the current isolate to be the same current isolate during the
3523 * invocation of the Dart_DeferredLoadHandler.
3524 */
3526Dart_DeferredLoadCompleteError(intptr_t loading_unit_id,
3527 const char* error_message,
3528 bool transient);
3529
3530/**
3531 * Loads the root library for the current isolate.
3532 *
3533 * Requires there to be no current root library.
3534 *
3535 * \param kernel_buffer A buffer which contains a kernel binary (see
3536 * pkg/kernel/binary.md). Must remain valid until isolate group shutdown.
3537 * \param kernel_size Length of the passed in buffer.
3538 *
3539 * \return A handle to the root library, or an error.
3540 */
3542Dart_LoadScriptFromKernel(const uint8_t* kernel_buffer, intptr_t kernel_size);
3543
3544/**
3545 * Gets the library for the root script for the current isolate.
3546 *
3547 * If the root script has not yet been set for the current isolate,
3548 * this function returns Dart_Null(). This function never returns an
3549 * error handle.
3550 *
3551 * \return Returns the root Library for the current isolate or Dart_Null().
3552 */
3554
3555/**
3556 * Sets the root library for the current isolate.
3557 *
3558 * \return Returns an error handle if `library` is not a library handle.
3559 */
3561
3562/**
3563 * Lookup or instantiate a legacy type by name and type arguments from a
3564 * Library.
3565 *
3566 * \param library The library containing the class or interface.
3567 * \param class_name The class name for the type.
3568 * \param number_of_type_arguments Number of type arguments.
3569 * For non parametric types the number of type arguments would be 0.
3570 * \param type_arguments Pointer to an array of type arguments.
3571 * For non parametric types a NULL would be passed in for this argument.
3572 *
3573 * \return If no error occurs, the type is returned.
3574 * Otherwise an error handle is returned.
3575 */
3578 intptr_t number_of_type_arguments,
3579 Dart_Handle* type_arguments);
3580
3581/**
3582 * Lookup or instantiate a nullable type by name and type arguments from
3583 * Library.
3584 *
3585 * \param library The library containing the class or interface.
3586 * \param class_name The class name for the type.
3587 * \param number_of_type_arguments Number of type arguments.
3588 * For non parametric types the number of type arguments would be 0.
3589 * \param type_arguments Pointer to an array of type arguments.
3590 * For non parametric types a NULL would be passed in for this argument.
3591 *
3592 * \return If no error occurs, the type is returned.
3593 * Otherwise an error handle is returned.
3594 */
3597 intptr_t number_of_type_arguments,
3598 Dart_Handle* type_arguments);
3599
3600/**
3601 * Lookup or instantiate a non-nullable type by name and type arguments from
3602 * Library.
3603 *
3604 * \param library The library containing the class or interface.
3605 * \param class_name The class name for the type.
3606 * \param number_of_type_arguments Number of type arguments.
3607 * For non parametric types the number of type arguments would be 0.
3608 * \param type_arguments Pointer to an array of type arguments.
3609 * For non parametric types a NULL would be passed in for this argument.
3610 *
3611 * \return If no error occurs, the type is returned.
3612 * Otherwise an error handle is returned.
3613 */
3617 intptr_t number_of_type_arguments,
3618 Dart_Handle* type_arguments);
3619
3620/**
3621 * Creates a nullable version of the provided type.
3622 *
3623 * \param type The type to be converted to a nullable type.
3624 *
3625 * \return If no error occurs, a nullable type is returned.
3626 * Otherwise an error handle is returned.
3627 */
3629
3630/**
3631 * Creates a non-nullable version of the provided type.
3632 *
3633 * \param type The type to be converted to a non-nullable type.
3634 *
3635 * \return If no error occurs, a non-nullable type is returned.
3636 * Otherwise an error handle is returned.
3637 */
3639
3640/**
3641 * A type's nullability.
3642 *
3643 * \param type A Dart type.
3644 * \param result An out parameter containing the result of the check. True if
3645 * the type is of the specified nullability, false otherwise.
3646 *
3647 * \return Returns an error handle if type is not of type Type.
3648 */
3651
3652/**
3653 * Lookup a class or interface by name from a Library.
3654 *
3655 * \param library The library containing the class or interface.
3656 * \param class_name The name of the class or interface.
3657 *
3658 * \return If no error occurs, the class or interface is
3659 * returned. Otherwise an error handle is returned.
3660 */
3663/* TODO(asiva): The above method needs to be removed once all uses
3664 * of it are removed from the embedder code. */
3665
3666/**
3667 * Returns an import path to a Library, such as "file:///test.dart" or
3668 * "dart:core".
3669 */
3671
3672/**
3673 * Returns a URL from which a Library was loaded.
3674 */
3676
3677/**
3678 * \return An array of libraries.
3679 */
3681
3683/* TODO(turnidge): Consider returning Dart_Null() when the library is
3684 * not found to distinguish that from a true error case. */
3685
3686/**
3687 * Report an loading error for the library.
3688 *
3689 * \param library The library that failed to load.
3690 * \param error The Dart error instance containing the load error.
3691 *
3692 * \return If the VM handles the error, the return value is
3693 * a null handle. If it doesn't handle the error, the error
3694 * object is returned.
3695 */
3698
3699/**
3700 * Called by the embedder to load a partial program. Does not set the root
3701 * library.
3702 *
3703 * \param kernel_buffer A buffer which contains a kernel binary (see
3704 * pkg/kernel/binary.md). Must remain valid until isolate shutdown.
3705 * \param kernel_buffer_size Length of the passed in buffer.
3706 *
3707 * \return A handle to the main library of the compilation unit, or an error.
3708 */
3710Dart_LoadLibraryFromKernel(const uint8_t* kernel_buffer,
3711 intptr_t kernel_buffer_size);
3714
3715/**
3716 * Indicates that all outstanding load requests have been satisfied.
3717 * This finalizes all the new classes loaded and optionally completes
3718 * deferred library futures.
3719 *
3720 * Requires there to be a current isolate.
3721 *
3722 * \param complete_futures Specify true if all deferred library
3723 * futures should be completed, false otherwise.
3724 *
3725 * \return Success if all classes have been finalized and deferred library
3726 * futures are completed. Otherwise, returns an error.
3727 */
3729Dart_FinalizeLoading(bool complete_futures);
3730
3731/*
3732 * =====
3733 * Peers
3734 * =====
3735 */
3736
3737/**
3738 * The peer field is a lazily allocated field intended for storage of
3739 * an uncommonly used values. Most instances types can have a peer
3740 * field allocated. The exceptions are subtypes of Null, num, and
3741 * bool.
3742 */
3743
3744/**
3745 * Returns the value of peer field of 'object' in 'peer'.
3746 *
3747 * \param object An object.
3748 * \param peer An out parameter that returns the value of the peer
3749 * field.
3750 *
3751 * \return Returns an error if 'object' is a subtype of Null, num, or
3752 * bool.
3753 */
3755
3756/**
3757 * Sets the value of the peer field of 'object' to the value of
3758 * 'peer'.
3759 *
3760 * \param object An object.
3761 * \param peer A value to store in the peer field.
3762 *
3763 * \return Returns an error if 'object' is a subtype of Null, num, or
3764 * bool.
3765 */
3767
3768/*
3769 * ======
3770 * Kernel
3771 * ======
3772 */
3773
3774/**
3775 * Experimental support for Dart to Kernel parser isolate.
3776 *
3777 * TODO(hausner): Document finalized interface.
3778 *
3779 */
3780
3781// TODO(33433): Remove kernel service from the embedding API.
3782
3783typedef enum {
3790
3791typedef struct {
3793 char* error;
3794 uint8_t* kernel;
3795 intptr_t kernel_size;
3797
3798typedef enum {
3804
3808
3809/**
3810 * Compiles the given `script_uri` to a kernel file.
3811 *
3812 * \param platform_kernel A buffer containing the kernel of the platform (e.g.
3813 * `vm_platform_strong.dill`). The VM does not take ownership of this memory.
3814 *
3815 * \param platform_kernel_size The length of the platform_kernel buffer.
3816 *
3817 * \param snapshot_compile Set to `true` when the compilation is for a snapshot.
3818 * This is used by the frontend to determine if compilation related information
3819 * should be printed to console (e.g., null safety mode).
3820 *
3821 * \param embed_sources Set to `true` when sources should be embedded in the
3822 * kernel file.
3823 *
3824 * \param verbosity Specifies the logging behavior of the kernel compilation
3825 * service.
3826 *
3827 * \return Returns the result of the compilation.
3828 *
3829 * On a successful compilation the returned [Dart_KernelCompilationResult] has
3830 * a status of [Dart_KernelCompilationStatus_Ok] and the `kernel`/`kernel_size`
3831 * fields are set. The caller takes ownership of the malloc()ed buffer.
3832 *
3833 * On a failed compilation the `error` might be set describing the reason for
3834 * the failed compilation. The caller takes ownership of the malloc()ed
3835 * error.
3836 *
3837 * Requires there to be a current isolate.
3838 */
3840Dart_CompileToKernel(const char* script_uri,
3841 const uint8_t* platform_kernel,
3842 const intptr_t platform_kernel_size,
3843 bool incremental_compile,
3844 bool snapshot_compile,
3845 bool embed_sources,
3846 const char* package_config,
3848
3849typedef struct {
3850 const char* uri;
3851 const char* source;
3853
3855
3856/**
3857 * Sets the kernel buffer which will be used to load Dart SDK sources
3858 * dynamically at runtime.
3859 *
3860 * \param platform_kernel A buffer containing kernel which has sources for the
3861 * Dart SDK populated. Note: The VM does not take ownership of this memory.
3862 *
3863 * \param platform_kernel_size The length of the platform_kernel buffer.
3864 */
3866 const uint8_t* platform_kernel,
3867 const intptr_t platform_kernel_size);
3868
3869/**
3870 * Always return true as the VM only supports strong null safety.
3871 */
3872DART_EXPORT bool Dart_DetectNullSafety(const char* script_uri,
3873 const char* package_config,
3874 const char* original_working_directory,
3875 const uint8_t* snapshot_data,
3876 const uint8_t* snapshot_instructions,
3877 const uint8_t* kernel_buffer,
3878 intptr_t kernel_buffer_size);
3879
3880#define DART_KERNEL_ISOLATE_NAME "kernel-service"
3881
3882/*
3883 * =======
3884 * Service
3885 * =======
3886 */
3887
3888#define DART_VM_SERVICE_ISOLATE_NAME "vm-service"
3889
3890/**
3891 * Returns true if isolate is the service isolate.
3892 *
3893 * \param isolate An isolate
3894 *
3895 * \return Returns true if 'isolate' is the service isolate.
3896 */
3898
3899/**
3900 * Writes the CPU profile to the timeline as a series of 'instant' events.
3901 *
3902 * Note that this is an expensive operation.
3903 *
3904 * \param main_port The main port of the Isolate whose profile samples to write.
3905 * \param error An optional error, must be free()ed by caller.
3906 *
3907 * \return Returns true if the profile is successfully written and false
3908 * otherwise.
3909 */
3911
3912/*
3913 * ==============
3914 * Precompilation
3915 * ==============
3916 */
3917
3918/**
3919 * Compiles all functions reachable from entry points and marks
3920 * the isolate to disallow future compilation.
3921 *
3922 * Entry points should be specified using `@pragma("vm:entry-point")`
3923 * annotation.
3924 *
3925 * \return An error handle if a compilation error or runtime error running const
3926 * constructors was encountered.
3927 */
3929
3931 void* callback_data,
3932 intptr_t loading_unit_id,
3933 void** write_callback_data,
3934 void** write_debug_callback_data);
3935typedef void (*Dart_StreamingWriteCallback)(void* callback_data,
3936 const uint8_t* buffer,
3937 intptr_t size);
3938typedef void (*Dart_StreamingCloseCallback)(void* callback_data);
3939
3941
3942// On Darwin systems, 'dlsym' adds an '_' to the beginning of the symbol name.
3943// Use the '...CSymbol' definitions for resolving through 'dlsym'. The actual
3944// symbol names in the objects are given by the '...AsmSymbol' definitions.
3945#if defined(__APPLE__)
3946#define kSnapshotBuildIdCSymbol "kDartSnapshotBuildId"
3947#define kVmSnapshotDataCSymbol "kDartVmSnapshotData"
3948#define kVmSnapshotInstructionsCSymbol "kDartVmSnapshotInstructions"
3949#define kVmSnapshotBssCSymbol "kDartVmSnapshotBss"
3950#define kIsolateSnapshotDataCSymbol "kDartIsolateSnapshotData"
3951#define kIsolateSnapshotInstructionsCSymbol "kDartIsolateSnapshotInstructions"
3952#define kIsolateSnapshotBssCSymbol "kDartIsolateSnapshotBss"
3953#else
3954#define kSnapshotBuildIdCSymbol "_kDartSnapshotBuildId"
3955#define kVmSnapshotDataCSymbol "_kDartVmSnapshotData"
3956#define kVmSnapshotInstructionsCSymbol "_kDartVmSnapshotInstructions"
3957#define kVmSnapshotBssCSymbol "_kDartVmSnapshotBss"
3958#define kIsolateSnapshotDataCSymbol "_kDartIsolateSnapshotData"
3959#define kIsolateSnapshotInstructionsCSymbol "_kDartIsolateSnapshotInstructions"
3960#define kIsolateSnapshotBssCSymbol "_kDartIsolateSnapshotBss"
3961#endif
3962
3963#define kSnapshotBuildIdAsmSymbol "_kDartSnapshotBuildId"
3964#define kVmSnapshotDataAsmSymbol "_kDartVmSnapshotData"
3965#define kVmSnapshotInstructionsAsmSymbol "_kDartVmSnapshotInstructions"
3966#define kVmSnapshotBssAsmSymbol "_kDartVmSnapshotBss"
3967#define kIsolateSnapshotDataAsmSymbol "_kDartIsolateSnapshotData"
3968#define kIsolateSnapshotInstructionsAsmSymbol \
3969 "_kDartIsolateSnapshotInstructions"
3970#define kIsolateSnapshotBssAsmSymbol "_kDartIsolateSnapshotBss"
3971
3972/**
3973 * Creates a precompiled snapshot.
3974 * - A root library must have been loaded.
3975 * - Dart_Precompile must have been called.
3976 *
3977 * Outputs an assembly file defining the symbols listed in the definitions
3978 * above.
3979 *
3980 * The assembly should be compiled as a static or shared library and linked or
3981 * loaded by the embedder. Running this snapshot requires a VM compiled with
3982 * DART_PRECOMPILED_SNAPSHOT. The kDartVmSnapshotData and
3983 * kDartVmSnapshotInstructions should be passed to Dart_Initialize. The
3984 * kDartIsolateSnapshotData and kDartIsolateSnapshotInstructions should be
3985 * passed to Dart_CreateIsolateGroup.
3986 *
3987 * The callback will be invoked one or more times to provide the assembly code.
3988 *
3989 * If stripped is true, then the assembly code will not include DWARF
3990 * debugging sections.
3991 *
3992 * If debug_callback_data is provided, debug_callback_data will be used with
3993 * the callback to provide separate debugging information.
3994 *
3995 * \return A valid handle if no error occurs during the operation.
3996 */
3999 void* callback_data,
4000 bool stripped,
4001 void* debug_callback_data);
4004 Dart_CreateLoadingUnitCallback next_callback,
4005 void* next_callback_data,
4006 bool stripped,
4007 Dart_StreamingWriteCallback write_callback,
4008 Dart_StreamingCloseCallback close_callback);
4009
4010/**
4011 * Creates a precompiled snapshot.
4012 * - A root library must have been loaded.
4013 * - Dart_Precompile must have been called.
4014 *
4015 * Outputs an ELF shared library defining the symbols
4016 * - _kDartVmSnapshotData
4017 * - _kDartVmSnapshotInstructions
4018 * - _kDartIsolateSnapshotData
4019 * - _kDartIsolateSnapshotInstructions
4020 *
4021 * The shared library should be dynamically loaded by the embedder.
4022 * Running this snapshot requires a VM compiled with DART_PRECOMPILED_SNAPSHOT.
4023 * The kDartVmSnapshotData and kDartVmSnapshotInstructions should be passed to
4024 * Dart_Initialize. The kDartIsolateSnapshotData and
4025 * kDartIsolateSnapshotInstructions should be passed to Dart_CreateIsolate.
4026 *
4027 * The callback will be invoked one or more times to provide the binary output.
4028 *
4029 * If stripped is true, then the binary output will not include DWARF
4030 * debugging sections.
4031 *
4032 * If debug_callback_data is provided, debug_callback_data will be used with
4033 * the callback to provide separate debugging information.
4034 *
4035 * \return A valid handle if no error occurs during the operation.
4036 */
4039 void* callback_data,
4040 bool stripped,
4041 void* debug_callback_data);
4044 void* next_callback_data,
4045 bool stripped,
4046 Dart_StreamingWriteCallback write_callback,
4047 Dart_StreamingCloseCallback close_callback);
4048
4049/**
4050 * Like Dart_CreateAppAOTSnapshotAsAssembly, but only includes
4051 * kDartVmSnapshotData and kDartVmSnapshotInstructions. It also does
4052 * not strip DWARF information from the generated assembly or allow for
4053 * separate debug information.
4054 */
4057 void* callback_data);
4058
4059/**
4060 * Sorts the class-ids in depth first traversal order of the inheritance
4061 * tree. This is a costly operation, but it can make method dispatch
4062 * more efficient and is done before writing snapshots.
4063 *
4064 * \return A valid handle if no error occurs during the operation.
4065 */
4067
4068/**
4069 * Creates a snapshot that caches compiled code and type feedback for faster
4070 * startup and quicker warmup in a subsequent process.
4071 *
4072 * Outputs a snapshot in two pieces. The pieces should be passed to
4073 * Dart_CreateIsolateGroup in a VM using the same VM snapshot pieces used in the
4074 * current VM. The instructions piece must be loaded with read and execute
4075 * permissions; the data piece may be loaded as read-only.
4076 *
4077 * - Requires the VM to have not been started with --precompilation.
4078 * - Not supported when targeting IA32.
4079 * - The VM writing the snapshot and the VM reading the snapshot must be the
4080 * same version, must be built in the same DEBUG/RELEASE/PRODUCT mode, must
4081 * be targeting the same architecture, and must both be in checked mode or
4082 * both in unchecked mode.
4083 *
4084 * The buffers are scope allocated and are only valid until the next call to
4085 * Dart_ExitScope.
4086 *
4087 * \return A valid handle if no error occurs during the operation.
4088 */
4090Dart_CreateAppJITSnapshotAsBlobs(uint8_t** isolate_snapshot_data_buffer,
4091 intptr_t* isolate_snapshot_data_size,
4092 uint8_t** isolate_snapshot_instructions_buffer,
4093 intptr_t* isolate_snapshot_instructions_size);
4094
4095/**
4096 * Get obfuscation map for precompiled code.
4097 *
4098 * Obfuscation map is encoded as a JSON array of pairs (original name,
4099 * obfuscated name).
4100 *
4101 * \return Returns an error handler if the VM was built in a mode that does not
4102 * support obfuscation.
4103 */
4105Dart_GetObfuscationMap(uint8_t** buffer, intptr_t* buffer_length);
4106
4107/**
4108 * Returns whether the VM only supports running from precompiled snapshots and
4109 * not from any other kind of snapshot or from source (that is, the VM was
4110 * compiled with DART_PRECOMPILED_RUNTIME).
4111 */
4113
4114/**
4115 * Print a native stack trace. Used for crash handling.
4116 *
4117 * If context is NULL, prints the current stack trace. Otherwise, context
4118 * should be a CONTEXT* (Windows) or ucontext_t* (POSIX) from a signal handler
4119 * running on the current thread.
4120 */
4122
4123/**
4124 * Indicate that the process is about to abort, and the Dart VM should not
4125 * attempt to cleanup resources.
4126 */
4128
4129/**
4130 * Callback provided by the embedder that is used by the VM to
4131 * produce footnotes appended to DWARF stack traces.
4132 *
4133 * Whenever VM formats a stack trace as a string it would call this callback
4134 * passing raw program counters for each frame in the stack trace.
4135 *
4136 * Embedder can then return a string which if not-null will be appended to the
4137 * formatted stack trace.
4138 *
4139 * Returned string is expected to be `malloc()` allocated. VM takes ownership
4140 * of the returned string and will `free()` it.
4141 *
4142 * \param addresses raw program counter addresses for each frame
4143 * \param count number of elements in the addresses array
4144 */
4145typedef char* (*Dart_DwarfStackTraceFootnoteCallback)(void* addresses[],
4146 intptr_t count);
4147
4148/**
4149 * Configure DWARF stack trace footnote callback.
4150 */
4153
4154#endif /* INCLUDE_DART_API_H_ */ /* NOLINT */
int count
Definition: FontMgrTest.cpp:50
static uint32_t buffer_size(uint32_t offset, uint32_t maxAlignment)
static bool equal(const SkBitmap &a, const SkBitmap &b)
Definition: ImageTest.cpp:1395
int main(int argc, char **argv)
Definition: benchmarking.cc:29
GLenum type
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_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:894
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:3278
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:3935
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:807
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:654
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:3783
@ Dart_KernelCompilationStatus_MsgFailed
Definition: dart_api.h:3788
@ Dart_KernelCompilationStatus_Error
Definition: dart_api.h:3786
@ Dart_KernelCompilationStatus_Crash
Definition: dart_api.h:3787
@ Dart_KernelCompilationStatus_Unknown
Definition: dart_api.h:3784
@ Dart_KernelCompilationStatus_Ok
Definition: dart_api.h:3785
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:729
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:820
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_ErrorGetStackTrace(Dart_Handle handle)
void(* Dart_MessageNotifyCallback)(Dart_Isolate destination_isolate)
Definition: dart_api.h:1546
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)
@ kNativeArgNumberPos
Definition: dart_api.h:3062
@ kNativeArgNumberSize
Definition: dart_api.h:3063
@ kNativeArgTypePos
Definition: dart_api.h:3064
@ kNativeArgTypeSize
Definition: dart_api.h:3065
void(* Dart_FileReadCallback)(uint8_t **data, intptr_t *file_length, void *stream)
Definition: dart_api.h:792
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:882
DART_EXPORT Dart_Handle Dart_ClassName(Dart_Handle cls_type)
bool(* Dart_EntropySource)(uint8_t *buffer, intptr_t length)
Definition: dart_api.h:822
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:3234
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:3938
void(* Dart_HandleFinalizer)(void *isolate_callback_data, void *peer)
Definition: dart_api.h:265
void(* Dart_ThreadStartCallback)(void)
Definition: dart_api.h:754
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_NewSendPortEx(Dart_PortEx portex_id)
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)
const uint8_t *(* Dart_NativeEntrySymbol)(Dart_NativeFunction nf)
Definition: dart_api.h:3255
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)
void *(* Dart_NativeAssetsDlopenCallback)(const char *path, char **error)
Definition: dart_api.h:3364
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:3262
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_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:3019
bool(* Dart_InitializeIsolateCallback)(void **child_isolate_data, char **error)
Definition: dart_api.h:693
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:2612
@ Dart_TypedData_kFloat32x4
Definition: dart_api.h:2626
@ Dart_TypedData_kInt32x4
Definition: dart_api.h:2625
@ Dart_TypedData_kUint8
Definition: dart_api.h:2615
@ Dart_TypedData_kUint32
Definition: dart_api.h:2620
@ Dart_TypedData_kInt32
Definition: dart_api.h:2619
@ Dart_TypedData_kUint16
Definition: dart_api.h:2618
@ Dart_TypedData_kFloat64x2
Definition: dart_api.h:2627
@ Dart_TypedData_kUint64
Definition: dart_api.h:2622
@ Dart_TypedData_kFloat32
Definition: dart_api.h:2623
@ Dart_TypedData_kInt16
Definition: dart_api.h:2617
@ Dart_TypedData_kFloat64
Definition: dart_api.h:2624
@ Dart_TypedData_kUint8Clamped
Definition: dart_api.h:2616
@ Dart_TypedData_kByteData
Definition: dart_api.h:2613
@ Dart_TypedData_kInt8
Definition: dart_api.h:2614
@ Dart_TypedData_kInt64
Definition: dart_api.h:2621
@ Dart_TypedData_kInvalid
Definition: dart_api.h:2628
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:745
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:855
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:3419
@ Dart_kImportTag
Definition: dart_api.h:3421
@ Dart_kCanonicalizeUrl
Definition: dart_api.h:3420
@ Dart_kKernelTag
Definition: dart_api.h:3422
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:3930
void *(* Dart_FileOpenCallback)(const char *name, bool write)
Definition: dart_api.h:776
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:711
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_Handle Dart_SendPortGetIdEx(Dart_Handle port, Dart_PortEx *portex_id)
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
void *(* Dart_NativeAssetsDlopenCallbackNoPath)(char **error)
Definition: dart_api.h:3366
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:763
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_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:3207
Dart_Handle(* Dart_GetVMServiceAssetsArchive)(void)
Definition: dart_api.h:834
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)
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:3456
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:3026
@ Dart_NativeArgument_kString
Definition: dart_api.h:3033
@ Dart_NativeArgument_kInt64
Definition: dart_api.h:3030
@ Dart_NativeArgument_kNativeFields
Definition: dart_api.h:3035
@ Dart_NativeArgument_kInstance
Definition: dart_api.h:3034
@ Dart_NativeArgument_kInt32
Definition: dart_api.h:3028
@ Dart_NativeArgument_kUint64
Definition: dart_api.h:3031
@ Dart_NativeArgument_kUint32
Definition: dart_api.h:3029
@ Dart_NativeArgument_kDouble
Definition: dart_api.h:3032
@ Dart_NativeArgument_kBool
Definition: dart_api.h:3027
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)
struct Dart_CodeObserver Dart_CodeObserver
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:1209
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:4145
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:3798
@ Dart_KernelCompilationVerbosityLevel_Error
Definition: dart_api.h:3799
@ Dart_KernelCompilationVerbosityLevel_Warning
Definition: dart_api.h:3800
@ Dart_KernelCompilationVerbosityLevel_All
Definition: dart_api.h:3802
@ Dart_KernelCompilationVerbosityLevel_Info
Definition: dart_api.h:3801
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 Dart_Handle Dart_StringUTF8Length(Dart_Handle str, intptr_t *length)
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:3491
DART_EXPORT void * Dart_CurrentIsolateGroupData(void)
void *(* Dart_NativeAssetsDlsymCallback)(void *handle, const char *symbol, char **error)
Definition: dart_api.h:3387
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 Dart_Handle Dart_CopyUTF8EncodingOfString(Dart_Handle str, uint8_t *utf8_array, intptr_t length)
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 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:1281
DART_EXPORT Dart_Handle Dart_NewCompilationError(const char *error)
DART_EXPORT bool Dart_IsTypedData(Dart_Handle object)
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 void Dart_InitializeNativeAssetsResolver(NativeAssetsApi *native_assets_api)
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)
const EmbeddedViewParams * params
VkInstance instance
Definition: main.cc:48
#define DART_EXPORT
FlutterSemanticsFlag flags
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
const uint8_t uint32_t uint32_t GError ** error
uint8_t value
GAsyncResult * result
uint32_t * target
Dart_NativeFunction function
Definition: fuchsia.cc:51
size_t length
char ** argv
Definition: library.h:9
const uint8_t * isolate_snapshot_data
Definition: gen_snapshot.cc:69
const uint8_t * isolate_snapshot_instructions
Definition: gen_snapshot.cc:70
const char *const class_name
const char *const function_name
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service port
Definition: switches.h:87
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
Definition: switches.h:228
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
std::function< void()> closure
Definition: closure.h:14
SI auto map(std::index_sequence< I... >, Fn &&fn, const Args &... args) -> skvx::Vec< sizeof...(I), decltype(fn(args[0]...))>
Definition: SkVx.h:680
void write(SkWStream *wStream, const T &text)
Definition: skqp.cpp:188
SeparatedVector2 offset
Dart_OnNewCodeCallback on_new_code
Definition: dart_api.h:863
Dart_ThreadExitCallback thread_exit
Definition: dart_api.h:953
Dart_IsolateGroupCreateCallback create_group
Definition: dart_api.h:925
Dart_InitializeIsolateCallback initialize_isolate
Definition: dart_api.h:932
Dart_IsolateGroupCleanupCallback cleanup_group
Definition: dart_api.h:950
Dart_FileReadCallback file_read
Definition: dart_api.h:955
const uint8_t * vm_snapshot_data
Definition: dart_api.h:911
Dart_GetVMServiceAssetsArchive get_service_assets
Definition: dart_api.h:964
Dart_FileOpenCallback file_open
Definition: dart_api.h:954
Dart_IsolateShutdownCallback shutdown_isolate
Definition: dart_api.h:938
Dart_ThreadStartCallback thread_start
Definition: dart_api.h:952
Dart_CodeObserver * code_observer
Definition: dart_api.h:972
Dart_UnregisterKernelBlobCallback unregister_kernel_blob
Definition: dart_api.h:982
Dart_FileWriteCallback file_write
Definition: dart_api.h:956
Dart_EntropySource entropy_source
Definition: dart_api.h:958
Dart_RegisterKernelBlobCallback register_kernel_blob
Definition: dart_api.h:977
Dart_IsolateCleanupCallback cleanup_isolate
Definition: dart_api.h:944
const uint8_t * vm_snapshot_instructions
Definition: dart_api.h:919
Dart_FileCloseCallback file_close
Definition: dart_api.h:957
bool is_service_isolate
Definition: dart_api.h:593
bool load_vmservice_library
Definition: dart_api.h:590
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:585
bool is_kernel_isolate
Definition: dart_api.h:594
bool use_field_guards
Definition: dart_api.h:587
bool is_system_isolate
Definition: dart_api.h:592
Dart_KernelCompilationStatus status
Definition: dart_api.h:3792
int64_t port_id
Definition: dart_api.h:1527
int64_t origin_id
Definition: dart_api.h:1528
const char * uri
Definition: dart_api.h:3850
const char * source
Definition: dart_api.h:3851
Dart_NativeAssetsDlopenCallback dlopen_system
Definition: dart_api.h:3394
Dart_NativeAssetsDlopenCallback dlopen_absolute
Definition: dart_api.h:3392
Dart_NativeAssetsDlopenCallbackNoPath dlopen_process
Definition: dart_api.h:3395
Dart_NativeAssetsDlopenCallback dlopen_relative
Definition: dart_api.h:3393
Dart_NativeAssetsDlsymCallback dlsym
Definition: dart_api.h:3397
Dart_NativeAssetsDlopenCallbackNoPath dlopen_executable
Definition: dart_api.h:3396
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63
struct _Dart_NativeArgument_Value::@83 as_string
struct _Dart_NativeArgument_Value::@84 as_native_fields