Flutter Engine
tonic::DartConverterWrappable Struct Reference

#include <dart_wrappable.h>

Static Public Member Functions

static DartWrappableFromDart (Dart_Handle handle)
 
static DartWrappableFromArguments (Dart_NativeArguments args, int index, Dart_Handle &exception)
 

Detailed Description

Definition at line 93 of file dart_wrappable.h.

Member Function Documentation

◆ FromArguments()

DartWrappable * tonic::DartConverterWrappable::FromArguments ( Dart_NativeArguments  args,
int  index,
Dart_Handle &  exception 
)
static

Definition at line 99 of file dart_wrappable.cc.

References tonic::DartError::kInvalidArgument, tonic::DartWrappable::kNumberOfNativeFields, and tonic::DartWrappable::kPeerIndex.

Referenced by tonic::DartConverter< T *, typename std::enable_if< std::is_convertible< T *, const DartWrappable * >::value >::type >::FromArguments().

101  {
102  intptr_t native_fields[DartWrappable::kNumberOfNativeFields];
103  Dart_Handle result = Dart_GetNativeFieldsOfArgument(
104  args, index, DartWrappable::kNumberOfNativeFields, native_fields);
105  if (Dart_IsError(result)) {
106  exception = Dart_NewStringFromCString(DartError::kInvalidArgument);
107  return nullptr;
108  }
109  if (!native_fields[DartWrappable::kPeerIndex])
110  return nullptr;
111  return reinterpret_cast<DartWrappable*>(
112  native_fields[DartWrappable::kPeerIndex]);
113 }
const char kInvalidArgument[]
Definition: dart_error.cc:12

◆ FromDart()

DartWrappable * tonic::DartConverterWrappable::FromDart ( Dart_Handle  handle)
static

Definition at line 90 of file dart_wrappable.cc.

References tonic::DartWrappable::kPeerIndex.

Referenced by tonic::DartConverter< T *, typename std::enable_if< std::is_convertible< T *, const DartWrappable * >::value >::type >::FromDart().

90  {
91  intptr_t peer = 0;
92  Dart_Handle result =
93  Dart_GetNativeInstanceField(handle, DartWrappable::kPeerIndex, &peer);
94  if (Dart_IsError(result))
95  return nullptr;
96  return reinterpret_cast<DartWrappable*>(peer);
97 }

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