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