5#ifndef LIB_TONIC_DART_WRAPPABLE_H_
6#define LIB_TONIC_DART_WRAPPABLE_H_
8#include "third_party/dart/runtime/include/dart_api.h"
48 return dart_wrapper_.
value();
59 static void FinalizeDartWrapper(
void* isolate_callback_data,
void* peer);
66#define DEFINE_WRAPPERTYPEINFO() \
68 const tonic::DartWrapperInfo& GetDartWrapperInfo() const override { \
69 return dart_wrapper_info_; \
71 static Dart_PersistentHandle GetDartType(tonic::DartState* dart_state) { \
72 return GetTypeForWrapper(dart_state, dart_wrapper_info_); \
76 static const tonic::DartWrapperInfo& dart_wrapper_info_
78#define IMPLEMENT_WRAPPERTYPEINFO(LibraryName, ClassName) \
79 static const tonic::DartWrapperInfo \
80 kDartWrapperInfo_##LibraryName_##ClassName(#LibraryName, #ClassName); \
81 const tonic::DartWrapperInfo& ClassName::dart_wrapper_info_ = \
82 kDartWrapperInfo_##LibraryName_##ClassName;
94 typename std::enable_if<
97 static constexpr const char* kFfiRepresentation =
"Pointer";
98 static constexpr const char* kDartRepresentation =
"Pointer";
99 static constexpr bool kAllowedInLeafCall =
true;
108 return strong_handle;
118 bool auto_scope =
true) {
142 bool auto_scope =
true) {
144 return static_cast<T*
>(
160template <
template <
typename T>
class PTR,
typename T>
164 static constexpr const char* kFfiRepresentation =
"Handle";
165 static constexpr const char* kDartRepresentation =
"Object";
166 static constexpr bool kAllowedInLeafCall =
false;
179 bool auto_scope =
true) {
186 bool auto_scope =
true) {
204 return static_cast<T*
>(
reinterpret_cast<DartWrappable*
>(receiver));
static DartState * Current()
Dart_WeakPersistentHandle value() const
Dart_Handle CreateDartWrapper(DartState *dart_state)
virtual const DartWrapperInfo & GetDartWrapperInfo() const =0
Dart_WeakPersistentHandle dart_wrapper() const
void AssociateWithDartWrapper(Dart_Handle wrappable)
virtual void ReleaseDartWrappableReference() const =0
virtual void RetainDartWrappableReference() const =0
static Dart_PersistentHandle GetTypeForWrapper(tonic::DartState *dart_state, const tonic::DartWrapperInfo &wrapper_info)
struct _Dart_Handle * Dart_Handle
DART_EXPORT Dart_Handle Dart_ThrowException(Dart_Handle exception)
struct _Dart_NativeArguments * Dart_NativeArguments
Dart_Handle Dart_PersistentHandle
DART_EXPORT Dart_Handle Dart_Null(void)
DART_EXPORT Dart_Handle Dart_GetNativeReceiver(Dart_NativeArguments args, intptr_t *value)
DART_EXPORT void Dart_SetReturnValue(Dart_NativeArguments args, Dart_Handle retval)
DART_EXPORT bool Dart_IsNull(Dart_Handle object)
DART_EXPORT bool Dart_IsError(Dart_Handle handle)
struct _Dart_WeakPersistentHandle * Dart_WeakPersistentHandle
DART_EXPORT Dart_Handle Dart_HandleFromWeakPersistent(Dart_WeakPersistentHandle object)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
Dart_Handle ToDart(const T &object)
T * GetReceiver(Dart_NativeArguments args)
static DartWrappable * FromArguments(Dart_NativeArguments args, int index, Dart_Handle &exception)
static DartWrappable * FromDart(Dart_Handle handle)
static FfiType ToFfi(const NativeType &val)
static bool AllowedInLeafCall()
static NativeType FromDart(Dart_Handle handle)
static Dart_Handle ToDart(const NativeType &val)
static NativeType FromFfi(FfiType val)
static const char * GetDartRepresentation()
static void SetReturnValue(Dart_NativeArguments args, const NativeType &val, bool auto_scope=true)
static const char * GetFfiRepresentation()
static NativeType FromArguments(Dart_NativeArguments args, int index, Dart_Handle &exception, bool auto_scope=true)
static T * FromArguments(Dart_NativeArguments args, int index, Dart_Handle &exception, bool auto_scope=true)
static T * FromDart(Dart_Handle handle)
static Dart_Handle ToDart(DartWrappable *val)
static const char * GetFfiRepresentation()
static bool AllowedInLeafCall()
static FfiType ToFfi(T *val)
static void SetReturnValue(Dart_NativeArguments args, DartWrappable *val, bool auto_scope=true)
static T * FromFfi(FfiType val)
static const char * GetDartRepresentation()