Skip to content

Commit cd3fc3a

Browse files
Fix CI
1 parent 197e71f commit cd3fc3a

File tree

22 files changed

+31843
-1
lines changed

22 files changed

+31843
-1
lines changed

pkgs/jnigen/example/in_app_java/src/android_utils/include/dart_api.h

Lines changed: 4185 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
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+
25+
DART_EXPORT intptr_t Dart_InitializeApiDL(void* data);
26+
27+
// ============================================================================
28+
// IMPORTANT! Never update these signatures without properly updating
29+
// DART_API_DL_MAJOR_VERSION and DART_API_DL_MINOR_VERSION.
30+
//
31+
// Verbatim copy of `dart_native_api.h` and `dart_api.h` symbol names and types
32+
// to trigger compile-time errors if the symbols in those files are updated
33+
// without updating these.
34+
//
35+
// Function return and argument types, and typedefs are carbon copied. Structs
36+
// are typechecked nominally in C/C++, so they are not copied, instead a
37+
// comment is added to their definition.
38+
typedef int64_t Dart_Port_DL;
39+
40+
typedef void (*Dart_NativeMessageHandler_DL)(Dart_Port_DL dest_port_id,
41+
Dart_CObject* message);
42+
43+
// dart_native_api.h symbols can be called on any thread.
44+
#define DART_NATIVE_API_DL_SYMBOLS(F) \
45+
/***** dart_native_api.h *****/ \
46+
/* Dart_Port */ \
47+
F(Dart_PostCObject, bool, (Dart_Port_DL port_id, Dart_CObject * message)) \
48+
F(Dart_PostInteger, bool, (Dart_Port_DL port_id, int64_t message)) \
49+
F(Dart_NewNativePort, Dart_Port_DL, \
50+
(const char* name, Dart_NativeMessageHandler_DL handler, \
51+
bool handle_concurrently)) \
52+
F(Dart_CloseNativePort, bool, (Dart_Port_DL native_port_id))
53+
54+
// dart_api.h symbols can only be called on Dart threads.
55+
#define DART_API_DL_SYMBOLS(F) \
56+
/***** dart_api.h *****/ \
57+
/* Errors */ \
58+
F(Dart_IsError, bool, (Dart_Handle handle)) \
59+
F(Dart_IsApiError, bool, (Dart_Handle handle)) \
60+
F(Dart_IsUnhandledExceptionError, bool, (Dart_Handle handle)) \
61+
F(Dart_IsCompilationError, bool, (Dart_Handle handle)) \
62+
F(Dart_IsFatalError, bool, (Dart_Handle handle)) \
63+
F(Dart_GetError, const char*, (Dart_Handle handle)) \
64+
F(Dart_ErrorHasException, bool, (Dart_Handle handle)) \
65+
F(Dart_ErrorGetException, Dart_Handle, (Dart_Handle handle)) \
66+
F(Dart_ErrorGetStackTrace, Dart_Handle, (Dart_Handle handle)) \
67+
F(Dart_NewApiError, Dart_Handle, (const char* error)) \
68+
F(Dart_NewCompilationError, Dart_Handle, (const char* error)) \
69+
F(Dart_NewUnhandledExceptionError, Dart_Handle, (Dart_Handle exception)) \
70+
F(Dart_PropagateError, void, (Dart_Handle handle)) \
71+
/* Dart_Handle, Dart_PersistentHandle, Dart_WeakPersistentHandle */ \
72+
F(Dart_HandleFromPersistent, Dart_Handle, (Dart_PersistentHandle object)) \
73+
F(Dart_HandleFromWeakPersistent, Dart_Handle, \
74+
(Dart_WeakPersistentHandle object)) \
75+
F(Dart_NewPersistentHandle, Dart_PersistentHandle, (Dart_Handle object)) \
76+
F(Dart_SetPersistentHandle, void, \
77+
(Dart_PersistentHandle obj1, Dart_Handle obj2)) \
78+
F(Dart_DeletePersistentHandle, void, (Dart_PersistentHandle object)) \
79+
F(Dart_NewWeakPersistentHandle, Dart_WeakPersistentHandle, \
80+
(Dart_Handle object, void* peer, intptr_t external_allocation_size, \
81+
Dart_HandleFinalizer callback)) \
82+
F(Dart_DeleteWeakPersistentHandle, void, (Dart_WeakPersistentHandle object)) \
83+
F(Dart_UpdateExternalSize, void, \
84+
(Dart_WeakPersistentHandle object, intptr_t external_allocation_size)) \
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+
F(Dart_UpdateFinalizableExternalSize, void, \
91+
(Dart_FinalizableHandle object, Dart_Handle strong_ref_to_object, \
92+
intptr_t external_allocation_size)) \
93+
/* Isolates */ \
94+
F(Dart_CurrentIsolate, Dart_Isolate, (void)) \
95+
F(Dart_ExitIsolate, void, (void)) \
96+
F(Dart_EnterIsolate, void, (Dart_Isolate)) \
97+
/* Dart_Port */ \
98+
F(Dart_Post, bool, (Dart_Port_DL port_id, Dart_Handle object)) \
99+
F(Dart_NewSendPort, Dart_Handle, (Dart_Port_DL port_id)) \
100+
F(Dart_SendPortGetId, Dart_Handle, \
101+
(Dart_Handle port, Dart_Port_DL * port_id)) \
102+
/* Scopes */ \
103+
F(Dart_EnterScope, void, (void)) \
104+
F(Dart_ExitScope, void, (void)) \
105+
/* Objects */ \
106+
F(Dart_IsNull, bool, (Dart_Handle))
107+
108+
#define DART_API_ALL_DL_SYMBOLS(F) \
109+
DART_NATIVE_API_DL_SYMBOLS(F) \
110+
DART_API_DL_SYMBOLS(F)
111+
// IMPORTANT! Never update these signatures without properly updating
112+
// DART_API_DL_MAJOR_VERSION and DART_API_DL_MINOR_VERSION.
113+
//
114+
// End of verbatim copy.
115+
// ============================================================================
116+
117+
// Copy of definition of DART_EXPORT without 'used' attribute.
118+
//
119+
// The 'used' attribute cannot be used with DART_API_ALL_DL_SYMBOLS because
120+
// they are not function declarations, but variable declarations with a
121+
// function pointer type.
122+
//
123+
// The function pointer variables are initialized with the addresses of the
124+
// functions in the VM. If we were to use function declarations instead, we
125+
// would need to forward the call to the VM adding indirection.
126+
#if defined(__CYGWIN__)
127+
#error Tool chain and platform not supported.
128+
#elif defined(_WIN32)
129+
#if defined(DART_SHARED_LIB)
130+
#define DART_EXPORT_DL DART_EXTERN_C __declspec(dllexport)
131+
#else
132+
#define DART_EXPORT_DL DART_EXTERN_C
133+
#endif
134+
#else
135+
#if __GNUC__ >= 4
136+
#if defined(DART_SHARED_LIB)
137+
#define DART_EXPORT_DL DART_EXTERN_C __attribute__((visibility("default")))
138+
#else
139+
#define DART_EXPORT_DL DART_EXTERN_C
140+
#endif
141+
#else
142+
#error Tool chain not supported.
143+
#endif
144+
#endif
145+
146+
#define DART_API_DL_DECLARATIONS(name, R, A) \
147+
typedef R(*name##_Type) A; \
148+
DART_EXPORT_DL name##_Type name##_DL;
149+
150+
DART_API_ALL_DL_SYMBOLS(DART_API_DL_DECLARATIONS)
151+
152+
#undef DART_API_DL_DECLARATIONS
153+
154+
#undef DART_EXPORT_DL
155+
156+
#endif /* RUNTIME_INCLUDE_DART_API_DL_H_ */ /* NOLINT */
Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
/*
2+
* Copyright (c) 2013, 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_NATIVE_API_H_
8+
#define RUNTIME_INCLUDE_DART_NATIVE_API_H_
9+
10+
#include "dart_api.h" /* NOLINT */
11+
12+
/*
13+
* ==========================================
14+
* Message sending/receiving from native code
15+
* ==========================================
16+
*/
17+
18+
/**
19+
* A Dart_CObject is used for representing Dart objects as native C
20+
* data outside the Dart heap. These objects are totally detached from
21+
* the Dart heap. Only a subset of the Dart objects have a
22+
* representation as a Dart_CObject.
23+
*
24+
* The string encoding in the 'value.as_string' is UTF-8.
25+
*
26+
* All the different types from dart:typed_data are exposed as type
27+
* kTypedData. The specific type from dart:typed_data is in the type
28+
* field of the as_typed_data structure. The length in the
29+
* as_typed_data structure is always in bytes.
30+
*
31+
* The data for kTypedData is copied on message send and ownership remains with
32+
* the caller. The ownership of data for kExternalTyped is passed to the VM on
33+
* message send and returned when the VM invokes the
34+
* Dart_HandleFinalizer callback; a non-NULL callback must be provided.
35+
*
36+
* Note that Dart_CObject_kNativePointer is intended for internal use by
37+
* dart:io implementation and has no connection to dart:ffi Pointer class.
38+
* It represents a pointer to a native resource of a known type.
39+
* The receiving side will only see this pointer as an integer and will not
40+
* see the specified finalizer.
41+
* The specified finalizer will only be invoked if the message is not delivered.
42+
*/
43+
typedef enum {
44+
Dart_CObject_kNull = 0,
45+
Dart_CObject_kBool,
46+
Dart_CObject_kInt32,
47+
Dart_CObject_kInt64,
48+
Dart_CObject_kDouble,
49+
Dart_CObject_kString,
50+
Dart_CObject_kArray,
51+
Dart_CObject_kTypedData,
52+
Dart_CObject_kExternalTypedData,
53+
Dart_CObject_kSendPort,
54+
Dart_CObject_kCapability,
55+
Dart_CObject_kNativePointer,
56+
Dart_CObject_kUnsupported,
57+
Dart_CObject_kUnmodifiableExternalTypedData,
58+
Dart_CObject_kNumberOfTypes
59+
} Dart_CObject_Type;
60+
// This enum is versioned by DART_API_DL_MAJOR_VERSION, only add at the end
61+
// and bump the DART_API_DL_MINOR_VERSION.
62+
63+
typedef struct _Dart_CObject {
64+
Dart_CObject_Type type;
65+
union {
66+
bool as_bool;
67+
int32_t as_int32;
68+
int64_t as_int64;
69+
double as_double;
70+
const char* as_string;
71+
struct {
72+
Dart_Port id;
73+
Dart_Port origin_id;
74+
} as_send_port;
75+
struct {
76+
int64_t id;
77+
} as_capability;
78+
struct {
79+
intptr_t length;
80+
struct _Dart_CObject** values;
81+
} as_array;
82+
struct {
83+
Dart_TypedData_Type type;
84+
intptr_t length; /* in elements, not bytes */
85+
const uint8_t* values;
86+
} as_typed_data;
87+
struct {
88+
Dart_TypedData_Type type;
89+
intptr_t length; /* in elements, not bytes */
90+
uint8_t* data;
91+
void* peer;
92+
Dart_HandleFinalizer callback;
93+
} as_external_typed_data;
94+
struct {
95+
intptr_t ptr;
96+
intptr_t size;
97+
Dart_HandleFinalizer callback;
98+
} as_native_pointer;
99+
} value;
100+
} Dart_CObject;
101+
// This struct is versioned by DART_API_DL_MAJOR_VERSION, bump the version when
102+
// changing this struct.
103+
104+
/**
105+
* Posts a message on some port. The message will contain the Dart_CObject
106+
* object graph rooted in 'message'.
107+
*
108+
* While the message is being sent the state of the graph of Dart_CObject
109+
* structures rooted in 'message' should not be accessed, as the message
110+
* generation will make temporary modifications to the data. When the message
111+
* has been sent the graph will be fully restored.
112+
*
113+
* If true is returned, the message was enqueued, and finalizers for external
114+
* typed data will eventually run, even if the receiving isolate shuts down
115+
* before processing the message. If false is returned, the message was not
116+
* enqueued and ownership of external typed data in the message remains with the
117+
* caller.
118+
*
119+
* This function may be called on any thread when the VM is running (that is,
120+
* after Dart_Initialize has returned and before Dart_Cleanup has been called).
121+
*
122+
* \param port_id The destination port.
123+
* \param message The message to send.
124+
*
125+
* \return True if the message was posted.
126+
*/
127+
DART_EXPORT bool Dart_PostCObject(Dart_Port port_id, Dart_CObject* message);
128+
129+
/**
130+
* Posts a message on some port. The message will contain the integer 'message'.
131+
*
132+
* \param port_id The destination port.
133+
* \param message The message to send.
134+
*
135+
* \return True if the message was posted.
136+
*/
137+
DART_EXPORT bool Dart_PostInteger(Dart_Port port_id, int64_t message);
138+
139+
/**
140+
* A native message handler.
141+
*
142+
* This handler is associated with a native port by calling
143+
* Dart_NewNativePort.
144+
*
145+
* The message received is decoded into the message structure. The
146+
* lifetime of the message data is controlled by the caller. All the
147+
* data references from the message are allocated by the caller and
148+
* will be reclaimed when returning to it.
149+
*/
150+
typedef void (*Dart_NativeMessageHandler)(Dart_Port dest_port_id,
151+
Dart_CObject* message);
152+
153+
/**
154+
* Creates a new native port. When messages are received on this
155+
* native port, then they will be dispatched to the provided native
156+
* message handler.
157+
*
158+
* \param name The name of this port in debugging messages.
159+
* \param handler The C handler to run when messages arrive on the port.
160+
* \param handle_concurrently Is it okay to process requests on this
161+
* native port concurrently?
162+
*
163+
* \return If successful, returns the port id for the native port. In
164+
* case of error, returns ILLEGAL_PORT.
165+
*/
166+
DART_EXPORT Dart_Port Dart_NewNativePort(const char* name,
167+
Dart_NativeMessageHandler handler,
168+
bool handle_concurrently);
169+
/* TODO(turnidge): Currently handle_concurrently is ignored. */
170+
171+
/**
172+
* Closes the native port with the given id.
173+
*
174+
* The port must have been allocated by a call to Dart_NewNativePort.
175+
*
176+
* \param native_port_id The id of the native port to close.
177+
*
178+
* \return Returns true if the port was closed successfully.
179+
*/
180+
DART_EXPORT bool Dart_CloseNativePort(Dart_Port native_port_id);
181+
182+
/*
183+
* ==================
184+
* Verification Tools
185+
* ==================
186+
*/
187+
188+
/**
189+
* Forces all loaded classes and functions to be compiled eagerly in
190+
* the current isolate..
191+
*
192+
* TODO(turnidge): Document.
193+
*/
194+
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_CompileAll(void);
195+
196+
/**
197+
* Finalizes all classes.
198+
*/
199+
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_FinalizeAllClasses(void);
200+
201+
/* This function is intentionally undocumented.
202+
*
203+
* It should not be used outside internal tests.
204+
*/
205+
DART_EXPORT void* Dart_ExecuteInternalCommand(const char* command, void* arg);
206+
207+
#endif /* INCLUDE_DART_NATIVE_API_H_ */ /* NOLINT */

0 commit comments

Comments
 (0)