Flutter Engine
tonic::DartConverter< T *, typename std::enable_if< std::is_convertible< T *, const DartWrappable * >::value >::type > Struct Template Reference

#include <dart_wrappable.h>

Static Public Member Functions

static Dart_Handle ToDart (DartWrappable *val)
 
static void SetReturnValue (Dart_NativeArguments args, DartWrappable *val, bool auto_scope=true)
 
static T * FromDart (Dart_Handle handle)
 
static T * FromArguments (Dart_NativeArguments args, int index, Dart_Handle &exception, bool auto_scope=true)
 

Detailed Description

template<typename T>
struct tonic::DartConverter< T *, typename std::enable_if< std::is_convertible< T *, const DartWrappable * >::value >::type >

Definition at line 101 of file dart_wrappable.h.

Member Function Documentation

◆ FromArguments()

template<typename T >
static T* tonic::DartConverter< T *, typename std::enable_if< std::is_convertible< T *, const DartWrappable * >::value >::type >::FromArguments ( Dart_NativeArguments  args,
int  index,
Dart_Handle &  exception,
bool  auto_scope = true 
)
inlinestatic

Definition at line 143 of file dart_wrappable.h.

References tonic::DartConverterWrappable::FromArguments().

146  {
147  // TODO(abarth): We're missing a type check.
148  return static_cast<T*>(
149  DartConverterWrappable::FromArguments(args, index, exception));
150  }
G_BEGIN_DECLS FlValue * args
static DartWrappable * FromArguments(Dart_NativeArguments args, int index, Dart_Handle &exception)

◆ FromDart()

template<typename T >
static T* tonic::DartConverter< T *, typename std::enable_if< std::is_convertible< T *, const DartWrappable * >::value >::type >::FromDart ( Dart_Handle  handle)
inlinestatic

Definition at line 138 of file dart_wrappable.h.

References tonic::DartConverterWrappable::FromDart().

138  {
139  // TODO(abarth): We're missing a type check.
140  return static_cast<T*>(DartConverterWrappable::FromDart(handle));
141  }
static DartWrappable * FromDart(Dart_Handle handle)

◆ SetReturnValue()

template<typename T >
static void tonic::DartConverter< T *, typename std::enable_if< std::is_convertible< T *, const DartWrappable * >::value >::type >::SetReturnValue ( Dart_NativeArguments  args,
DartWrappable val,
bool  auto_scope = true 
)
inlinestatic

Definition at line 120 of file dart_wrappable.h.

References tonic::DartWrappable::CreateDartWrapper(), tonic::DartState::Current(), and tonic::DartWrappable::dart_wrapper().

122  {
123  if (!val) {
124  Dart_SetReturnValue(args, Dart_Null());
125  return;
126  } else if (Dart_WeakPersistentHandle wrapper = val->dart_wrapper()) {
127  auto strong_handle = Dart_HandleFromWeakPersistent(wrapper);
128  if (!Dart_IsNull(strong_handle)) {
129  Dart_SetReturnValue(args, strong_handle);
130  return;
131  }
132  // After the weak referenced object has been GCed, the handle points to
133  // Dart_Null(). Fall through create a new wrapper object.
134  }
135  Dart_SetReturnValue(args, val->CreateDartWrapper(DartState::Current()));
136  }
G_BEGIN_DECLS FlValue * args
static DartState * Current()
Definition: dart_state.cc:56

◆ ToDart()

template<typename T >
static Dart_Handle tonic::DartConverter< T *, typename std::enable_if< std::is_convertible< T *, const DartWrappable * >::value >::type >::ToDart ( DartWrappable val)
inlinestatic

Definition at line 105 of file dart_wrappable.h.

References tonic::DartWrappable::CreateDartWrapper(), tonic::DartState::Current(), and tonic::DartWrappable::dart_wrapper().

105  {
106  if (!val) {
107  return Dart_Null();
108  }
109  if (Dart_WeakPersistentHandle wrapper = val->dart_wrapper()) {
110  auto strong_handle = Dart_HandleFromWeakPersistent(wrapper);
111  if (!Dart_IsNull(strong_handle)) {
112  return strong_handle;
113  }
114  // After the weak referenced object has been GCed, the handle points to
115  // Dart_Null(). Fall through create a new wrapper object.
116  }
117  return val->CreateDartWrapper(DartState::Current());
118  }
static DartState * Current()
Definition: dart_state.cc:56

The documentation for this struct was generated from the following file: