Flutter Engine
The Flutter Engine
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
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;
41typedef struct {
42 int64_t port_id;
43 int64_t origin_id;
45
46typedef void (*Dart_NativeMessageHandler_DL)(Dart_Port_DL dest_port_id,
48
49// dart_native_api.h symbols can be called on any thread.
50#define DART_NATIVE_API_DL_SYMBOLS(F) \
51 /***** dart_native_api.h *****/ \
52 /* Dart_Port */ \
53 F(Dart_PostCObject, bool, (Dart_Port_DL port_id, Dart_CObject * message)) \
54 F(Dart_PostInteger, bool, (Dart_Port_DL port_id, int64_t message)) \
55 F(Dart_NewNativePort, Dart_Port_DL, \
56 (const char* name, Dart_NativeMessageHandler_DL handler, \
57 bool handle_concurrently)) \
58 F(Dart_CloseNativePort, bool, (Dart_Port_DL native_port_id))
59
60// dart_api.h symbols can only be called on Dart threads.
61#define DART_API_DL_SYMBOLS(F) \
62 /***** dart_api.h *****/ \
63 /* Errors */ \
64 F(Dart_IsError, bool, (Dart_Handle handle)) \
65 F(Dart_IsApiError, bool, (Dart_Handle handle)) \
66 F(Dart_IsUnhandledExceptionError, bool, (Dart_Handle handle)) \
67 F(Dart_IsCompilationError, bool, (Dart_Handle handle)) \
68 F(Dart_IsFatalError, bool, (Dart_Handle handle)) \
69 F(Dart_GetError, const char*, (Dart_Handle handle)) \
70 F(Dart_ErrorHasException, bool, (Dart_Handle handle)) \
71 F(Dart_ErrorGetException, Dart_Handle, (Dart_Handle handle)) \
72 F(Dart_ErrorGetStackTrace, Dart_Handle, (Dart_Handle handle)) \
73 F(Dart_NewApiError, Dart_Handle, (const char* error)) \
74 F(Dart_NewCompilationError, Dart_Handle, (const char* error)) \
75 F(Dart_NewUnhandledExceptionError, Dart_Handle, (Dart_Handle exception)) \
76 F(Dart_PropagateError, void, (Dart_Handle handle)) \
77 /* Dart_Handle, Dart_PersistentHandle, Dart_WeakPersistentHandle */ \
78 F(Dart_HandleFromPersistent, Dart_Handle, (Dart_PersistentHandle object)) \
79 F(Dart_HandleFromWeakPersistent, Dart_Handle, \
80 (Dart_WeakPersistentHandle object)) \
81 F(Dart_NewPersistentHandle, Dart_PersistentHandle, (Dart_Handle object)) \
82 F(Dart_SetPersistentHandle, void, \
83 (Dart_PersistentHandle obj1, Dart_Handle obj2)) \
84 F(Dart_DeletePersistentHandle, void, (Dart_PersistentHandle object)) \
85 F(Dart_NewWeakPersistentHandle, Dart_WeakPersistentHandle, \
86 (Dart_Handle object, void* peer, intptr_t external_allocation_size, \
87 Dart_HandleFinalizer callback)) \
88 F(Dart_DeleteWeakPersistentHandle, void, (Dart_WeakPersistentHandle object)) \
89 F(Dart_NewFinalizableHandle, Dart_FinalizableHandle, \
90 (Dart_Handle object, void* peer, intptr_t external_allocation_size, \
91 Dart_HandleFinalizer callback)) \
92 F(Dart_DeleteFinalizableHandle, void, \
93 (Dart_FinalizableHandle object, Dart_Handle strong_ref_to_object)) \
94 /* Isolates */ \
95 F(Dart_CurrentIsolate, Dart_Isolate, (void)) \
96 F(Dart_ExitIsolate, void, (void)) \
97 F(Dart_EnterIsolate, void, (Dart_Isolate)) \
98 /* Dart_Port */ \
99 F(Dart_Post, bool, (Dart_Port_DL port_id, Dart_Handle object)) \
100 F(Dart_NewSendPort, Dart_Handle, (Dart_Port_DL port_id)) \
101 F(Dart_NewSendPortEx, Dart_Handle, (Dart_PortEx_DL portex_id)) \
102 F(Dart_SendPortGetId, Dart_Handle, \
103 (Dart_Handle port, Dart_Port_DL * port_id)) \
104 F(Dart_SendPortGetIdEx, Dart_Handle, \
105 (Dart_Handle port, Dart_PortEx_DL * portex_id)) \
106 /* Scopes */ \
107 F(Dart_EnterScope, void, (void)) \
108 F(Dart_ExitScope, void, (void)) \
109 /* Objects */ \
110 F(Dart_IsNull, bool, (Dart_Handle)) \
111 F(Dart_Null, Dart_Handle, (void))
112
113// dart_api.h symbols that have been deprecated but are retained here
114// until we can make a breaking change bumping the major version number
115// (DART_API_DL_MAJOR_VERSION)
116#define DART_API_DEPRECATED_DL_SYMBOLS(F) \
117 F(Dart_UpdateExternalSize, void, \
118 (Dart_WeakPersistentHandle object, intptr_t external_allocation_size)) \
119 F(Dart_UpdateFinalizableExternalSize, void, \
120 (Dart_FinalizableHandle object, Dart_Handle strong_ref_to_object, \
121 intptr_t external_allocation_size))
122
123#define DART_API_ALL_DL_SYMBOLS(F) \
124 DART_NATIVE_API_DL_SYMBOLS(F) \
125 DART_API_DL_SYMBOLS(F)
126// IMPORTANT! Never update these signatures without properly updating
127// DART_API_DL_MAJOR_VERSION and DART_API_DL_MINOR_VERSION.
128//
129// End of verbatim copy.
130// ============================================================================
131
132// Copy of definition of DART_EXPORT without 'used' attribute.
133//
134// The 'used' attribute cannot be used with DART_API_ALL_DL_SYMBOLS because
135// they are not function declarations, but variable declarations with a
136// function pointer type.
137//
138// The function pointer variables are initialized with the addresses of the
139// functions in the VM. If we were to use function declarations instead, we
140// would need to forward the call to the VM adding indirection.
141#if defined(__CYGWIN__)
142#error Tool chain and platform not supported.
143#elif defined(_WIN32)
144#if defined(DART_SHARED_LIB)
145#define DART_EXPORT_DL DART_EXTERN_C __declspec(dllexport)
146#else
147#define DART_EXPORT_DL DART_EXTERN_C
148#endif
149#else
150#if __GNUC__ >= 4
151#if defined(DART_SHARED_LIB)
152#define DART_EXPORT_DL DART_EXTERN_C __attribute__((visibility("default")))
153#else
154#define DART_EXPORT_DL DART_EXTERN_C
155#endif
156#else
157#error Tool chain not supported.
158#endif
159#endif
160
161#define DART_API_DL_DECLARATIONS(name, R, A) \
162 typedef R(*name##_Type) A; \
163 DART_EXPORT_DL name##_Type name##_DL;
164
167
168#undef DART_API_DL_DECLARATIONS
169
170#undef DART_EXPORT_DL
171
172#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:46
int64_t Dart_Port_DL
Definition: dart_api_dl.h:40
#define DART_API_DL_DECLARATIONS(name, R, A)
Definition: dart_api_dl.h:161
#define DART_API_ALL_DL_SYMBOLS(F)
Definition: dart_api_dl.h:123
#define DART_API_DEPRECATED_DL_SYMBOLS(F)
Definition: dart_api_dl.h:116
#define DART_EXPORT
Win32Message message
int64_t port_id
Definition: dart_api_dl.h:42
int64_t origin_id
Definition: dart_api_dl.h:43
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63