Flutter Engine
The Flutter Engine
Classes | Typedefs | Functions
handle.h File Reference
#include "macros.h"
#include "include/dart_api_dl.h"
#include <stdint.h>

Go to the source code of this file.

Classes

struct  zircon_dart_handle_t
 
struct  zircon_dart_handle_pair_t
 
struct  zircon_dart_handle_list_t
 

Typedefs

typedef struct zircon_dart_handle_t zircon_dart_handle_t
 
typedef struct zircon_dart_handle_pair_t zircon_dart_handle_pair_t
 
typedef struct zircon_dart_handle_list_t zircon_dart_handle_list_t
 

Functions

ZIRCON_FFI_EXPORT zircon_dart_handle_list_tzircon_dart_handle_list_create ()
 
ZIRCON_FFI_EXPORT void zircon_dart_handle_list_append (zircon_dart_handle_list_t *list, zircon_dart_handle_t *handle)
 
ZIRCON_FFI_EXPORT void zircon_dart_handle_list_free (zircon_dart_handle_list_t *list)
 
ZIRCON_FFI_EXPORT int32_t zircon_dart_handle_is_valid (zircon_dart_handle_t *handle)
 
ZIRCON_FFI_EXPORT int32_t zircon_dart_handle_close (zircon_dart_handle_t *handle)
 
ZIRCON_FFI_EXPORT void zircon_dart_handle_free (zircon_dart_handle_t *handle)
 
ZIRCON_FFI_EXPORT int zircon_dart_handle_pair_attach_finalizer (Dart_Handle object, void *pointer, intptr_t external_allocation_size)
 
ZIRCON_FFI_EXPORT int zircon_dart_handle_attach_finalizer (Dart_Handle object, void *pointer, intptr_t external_allocation_size)
 

Typedef Documentation

◆ zircon_dart_handle_list_t

◆ zircon_dart_handle_pair_t

◆ zircon_dart_handle_t

Function Documentation

◆ zircon_dart_handle_attach_finalizer()

ZIRCON_FFI_EXPORT int zircon_dart_handle_attach_finalizer ( Dart_Handle  object,
void *  pointer,
intptr_t  external_allocation_size 
)

Definition at line 54 of file handle.cc.

56 {
57 Dart_FinalizableHandle weak_handle = Dart_NewFinalizableHandle_DL(
58 object, pointer, external_allocation_size, HandleFree);
59
60 if (weak_handle == nullptr) {
61 FML_LOG(ERROR) << "Unable to attach finalizer: " << std::hex << pointer;
62 return -1;
63 }
64
65 return 1;
66}
struct _Dart_FinalizableHandle * Dart_FinalizableHandle
Definition: dart_api.h:261
static void HandleFree(void *isolate_callback_data, void *peer)
Definition: handle.cc:14
#define FML_LOG(severity)
Definition: logging.h:82
#define ERROR(message)
Definition: elf_loader.cc:260

◆ zircon_dart_handle_close()

ZIRCON_FFI_EXPORT int32_t zircon_dart_handle_close ( zircon_dart_handle_t handle)

Definition at line 35 of file handle.cc.

35 {
36 FML_CHECK(handle->handle != ZX_HANDLE_INVALID);
37 zx_status_t status = zx_handle_close(handle->handle);
38 handle->handle = ZX_HANDLE_INVALID;
39 if (status == ZX_OK) {
40 return 1;
41 } else {
42 return 0;
43 }
44}
#define FML_CHECK(condition)
Definition: logging.h:85
uint32_t handle
Definition: handle.h:19

◆ zircon_dart_handle_free()

ZIRCON_FFI_EXPORT void zircon_dart_handle_free ( zircon_dart_handle_t handle)

Definition at line 27 of file handle.cc.

27 {
28 FML_CHECK(handle);
29 if (handle->handle != ZX_HANDLE_INVALID) {
31 }
32 free(handle);
33}
int32_t zircon_dart_handle_close(zircon_dart_handle_t *handle)
Definition: handle.cc:35

◆ zircon_dart_handle_is_valid()

ZIRCON_FFI_EXPORT int32_t zircon_dart_handle_is_valid ( zircon_dart_handle_t handle)

Definition at line 46 of file handle.cc.

46 {
47 if (!handle || (handle->handle == ZX_HANDLE_INVALID)) {
48 return 0;
49 } else {
50 return 1;
51 }
52}

◆ zircon_dart_handle_list_append()

ZIRCON_FFI_EXPORT void zircon_dart_handle_list_append ( zircon_dart_handle_list_t list,
zircon_dart_handle_t handle 
)

Definition at line 95 of file handle.cc.

96 {
97 FML_CHECK(list);
98 FML_CHECK(handle);
99 list->size++;
100 auto data = reinterpret_cast<HandleVectorPtr>(list->data);
101 data->push_back(handle);
102}
HandleVector * HandleVectorPtr
Definition: handle.cc:85
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ zircon_dart_handle_list_create()

ZIRCON_FFI_EXPORT zircon_dart_handle_list_t * zircon_dart_handle_list_create ( )

Definition at line 87 of file handle.cc.

87 {
90 result->size = 0;
91 result->data = new HandleVector();
92 return result;
93}
std::vector< zircon_dart_handle_t * > HandleVector
Definition: handle.cc:84
GAsyncResult * result
void * malloc(size_t size)
Definition: allocation.cc:19

◆ zircon_dart_handle_list_free()

ZIRCON_FFI_EXPORT void zircon_dart_handle_list_free ( zircon_dart_handle_list_t list)

Definition at line 104 of file handle.cc.

104 {
105 auto data = reinterpret_cast<HandleVectorPtr>(list->data);
106 data->clear();
107 delete data;
108 free(list);
109}

◆ zircon_dart_handle_pair_attach_finalizer()

ZIRCON_FFI_EXPORT int zircon_dart_handle_pair_attach_finalizer ( Dart_Handle  object,
void *  pointer,
intptr_t  external_allocation_size 
)

Definition at line 68 of file handle.cc.

71 {
72 Dart_FinalizableHandle weak_handle = Dart_NewFinalizableHandle_DL(
73 object, pointer, external_allocation_size, HandlePairFree);
74
75 if (weak_handle == nullptr) {
76 FML_LOG(ERROR) << "Unable to attach finalizer: " << std::hex << pointer;
77 return -1;
78 }
79
80 return 1;
81}
static void HandlePairFree(void *isolate_callback_data, void *peer)
Definition: handle.cc:20