Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
dart_api_dl.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020, 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_DL_H_
8#define RUNTIME_INCLUDE_DART_API_DL_H_
9
10#include "dart_api.h" /* NOLINT */
11#include "dart_native_api.h" /* NOLINT */
12
13/** \mainpage Dynamically Linked Dart API
14 *
15 * This exposes a subset of symbols from dart_api.h and dart_native_api.h
16 * available in every Dart embedder through dynamic linking.
17 *
18 * All symbols are postfixed with _DL to indicate that they are dynamically
19 * linked and to prevent conflicts with the original symbol.
20 *
21 * Link `dart_api_dl.c` file into your library and invoke
22 * `Dart_InitializeApiDL` with `NativeApi.initializeApiDLData`.
23 *
24 * Returns 0 on success.
25 */
26
27DART_EXPORT intptr_t Dart_InitializeApiDL(void* data);
28
29// ============================================================================
30// IMPORTANT! Never update these signatures without properly updating
31// DART_API_DL_MAJOR_VERSION and DART_API_DL_MINOR_VERSION.
32//
33// Verbatim copy of `dart_native_api.h` and `dart_api.h` symbol names and types
34// to trigger compile-time errors if the symbols in those files are updated
35// without updating these.
36//
37// Function return and argument types, and typedefs are carbon copied. Structs
38// are typechecked nominally in C/C++, so they are not copied, instead a
39// comment is added to their definition.
40typedef int64_t Dart_Port_DL;
41
42typedef void (*Dart_NativeMessageHandler_DL)(Dart_Port_DL dest_port_id,
44
45// dart_native_api.h symbols can be called on any thread.
46#define DART_NATIVE_API_DL_SYMBOLS(F) \
47 /***** dart_native_api.h *****/ \
48 /* Dart_Port */ \
49 F(Dart_PostCObject, bool, (Dart_Port_DL port_id, Dart_CObject * message)) \
50 F(Dart_PostInteger, bool, (Dart_Port_DL port_id, int64_t message)) \
51 F(Dart_NewNativePort, Dart_Port_DL, \
52 (const char* name, Dart_NativeMessageHandler_DL handler, \
53 bool handle_concurrently)) \
54 F(Dart_CloseNativePort, bool, (Dart_Port_DL native_port_id))
55
56// dart_api.h symbols can only be called on Dart threads.
57#define DART_API_DL_SYMBOLS(F) \
58 /***** dart_api.h *****/ \
59 /* Errors */ \
60 F(Dart_IsError, bool, (Dart_Handle handle)) \
61 F(Dart_IsApiError, bool, (Dart_Handle handle)) \
62 F(Dart_IsUnhandledExceptionError, bool, (Dart_Handle handle)) \
63 F(Dart_IsCompilationError, bool, (Dart_Handle handle)) \
64 F(Dart_IsFatalError, bool, (Dart_Handle handle)) \
65 F(Dart_GetError, const char*, (Dart_Handle handle)) \
66 F(Dart_ErrorHasException, bool, (Dart_Handle handle)) \
67 F(Dart_ErrorGetException, Dart_Handle, (Dart_Handle handle)) \
68 F(Dart_ErrorGetStackTrace, Dart_Handle, (Dart_Handle handle)) \
69 F(Dart_NewApiError, Dart_Handle, (const char* error)) \
70 F(Dart_NewCompilationError, Dart_Handle, (const char* error)) \
71 F(Dart_NewUnhandledExceptionError, Dart_Handle, (Dart_Handle exception)) \
72 F(Dart_PropagateError, void, (Dart_Handle handle)) \
73 /* Dart_Handle, Dart_PersistentHandle, Dart_WeakPersistentHandle */ \
74 F(Dart_HandleFromPersistent, Dart_Handle, (Dart_PersistentHandle object)) \
75 F(Dart_HandleFromWeakPersistent, Dart_Handle, \
76 (Dart_WeakPersistentHandle object)) \
77 F(Dart_NewPersistentHandle, Dart_PersistentHandle, (Dart_Handle object)) \
78 F(Dart_SetPersistentHandle, void, \
79 (Dart_PersistentHandle obj1, Dart_Handle obj2)) \
80 F(Dart_DeletePersistentHandle, void, (Dart_PersistentHandle object)) \
81 F(Dart_NewWeakPersistentHandle, Dart_WeakPersistentHandle, \
82 (Dart_Handle object, void* peer, intptr_t external_allocation_size, \
83 Dart_HandleFinalizer callback)) \
84 F(Dart_DeleteWeakPersistentHandle, void, (Dart_WeakPersistentHandle object)) \
85 F(Dart_NewFinalizableHandle, Dart_FinalizableHandle, \
86 (Dart_Handle object, void* peer, intptr_t external_allocation_size, \
87 Dart_HandleFinalizer callback)) \
88 F(Dart_DeleteFinalizableHandle, void, \
89 (Dart_FinalizableHandle object, Dart_Handle strong_ref_to_object)) \
90 /* Isolates */ \
91 F(Dart_CurrentIsolate, Dart_Isolate, (void)) \
92 F(Dart_ExitIsolate, void, (void)) \
93 F(Dart_EnterIsolate, void, (Dart_Isolate)) \
94 /* Dart_Port */ \
95 F(Dart_Post, bool, (Dart_Port_DL port_id, Dart_Handle object)) \
96 F(Dart_NewSendPort, Dart_Handle, (Dart_Port_DL port_id)) \
97 F(Dart_SendPortGetId, Dart_Handle, \
98 (Dart_Handle port, Dart_Port_DL * port_id)) \
99 /* Scopes */ \
100 F(Dart_EnterScope, void, (void)) \
101 F(Dart_ExitScope, void, (void)) \
102 /* Objects */ \
103 F(Dart_IsNull, bool, (Dart_Handle)) \
104 F(Dart_Null, Dart_Handle, (void))
105
106// dart_api.h symbols that have been deprecated but are retained here
107// until we can make a breaking change bumping the major version number
108// (DART_API_DL_MAJOR_VERSION)
109#define DART_API_DEPRECATED_DL_SYMBOLS(F) \
110 F(Dart_UpdateExternalSize, void, \
111 (Dart_WeakPersistentHandle object, intptr_t external_allocation_size)) \
112 F(Dart_UpdateFinalizableExternalSize, void, \
113 (Dart_FinalizableHandle object, Dart_Handle strong_ref_to_object, \
114 intptr_t external_allocation_size))
115
116#define DART_API_ALL_DL_SYMBOLS(F) \
117 DART_NATIVE_API_DL_SYMBOLS(F) \
118 DART_API_DL_SYMBOLS(F)
119// IMPORTANT! Never update these signatures without properly updating
120// DART_API_DL_MAJOR_VERSION and DART_API_DL_MINOR_VERSION.
121//
122// End of verbatim copy.
123// ============================================================================
124
125// Copy of definition of DART_EXPORT without 'used' attribute.
126//
127// The 'used' attribute cannot be used with DART_API_ALL_DL_SYMBOLS because
128// they are not function declarations, but variable declarations with a
129// function pointer type.
130//
131// The function pointer variables are initialized with the addresses of the
132// functions in the VM. If we were to use function declarations instead, we
133// would need to forward the call to the VM adding indirection.
134#if defined(__CYGWIN__)
135#error Tool chain and platform not supported.
136#elif defined(_WIN32)
137#if defined(DART_SHARED_LIB)
138#define DART_EXPORT_DL DART_EXTERN_C __declspec(dllexport)
139#else
140#define DART_EXPORT_DL DART_EXTERN_C
141#endif
142#else
143#if __GNUC__ >= 4
144#if defined(DART_SHARED_LIB)
145#define DART_EXPORT_DL DART_EXTERN_C __attribute__((visibility("default")))
146#else
147#define DART_EXPORT_DL DART_EXTERN_C
148#endif
149#else
150#error Tool chain not supported.
151#endif
152#endif
153
154#define DART_API_DL_DECLARATIONS(name, R, A) \
155 typedef R(*name##_Type) A; \
156 DART_EXPORT_DL name##_Type name##_DL;
157
160
161#undef DART_API_DL_DECLARATIONS
162
163#undef DART_EXPORT_DL
164
165#endif /* RUNTIME_INCLUDE_DART_API_DL_H_ */ /* NOLINT */
DART_EXPORT intptr_t Dart_InitializeApiDL(void *data)
Definition dart_api_dl.c:45
void(* Dart_NativeMessageHandler_DL)(Dart_Port_DL dest_port_id, Dart_CObject *message)
Definition dart_api_dl.h:42
int64_t Dart_Port_DL
Definition dart_api_dl.h:40
#define DART_API_DL_DECLARATIONS(name, R, A)
#define DART_API_ALL_DL_SYMBOLS(F)
#define DART_API_DEPRECATED_DL_SYMBOLS(F)
#define DART_EXPORT
Win32Message message