Flutter Engine
tonic::DartConverter< TypedList< kTypeName, ElemType > > Struct Template Reference

#include <typed_list.h>

Static Public Member Functions

static void SetReturnValue (Dart_NativeArguments args, TypedList< kTypeName, ElemType > val)
 
static TypedList< kTypeName, ElemType > FromArguments (Dart_NativeArguments args, int index, Dart_Handle &exception)
 
static Dart_Handle ToDart (const ElemType *buffer, unsigned int length)
 

Detailed Description

template<Dart_TypedData_Type kTypeName, typename ElemType>
struct tonic::DartConverter< TypedList< kTypeName, ElemType > >

Definition at line 53 of file typed_list.h.

Member Function Documentation

◆ FromArguments()

template<Dart_TypedData_Type kTypeName, typename ElemType >
TypedList< kTypeName, ElemType > tonic::DartConverter< TypedList< kTypeName, ElemType > >::FromArguments ( Dart_NativeArguments  args,
int  index,
Dart_Handle &  exception 
)
static

Definition at line 59 of file typed_list.cc.

References tonic::LogIfError(), and TONIC_DCHECK.

62  {
63  Dart_Handle list = Dart_GetNativeArgument(args, index);
64  TONIC_DCHECK(!LogIfError(list));
65  return TypedList<kTypeName, ElemType>(list);
66 }
G_BEGIN_DECLS FlValue * args
#define TONIC_DCHECK
Definition: macros.h:32
bool LogIfError(Dart_Handle handle)
Definition: dart_error.cc:15

◆ SetReturnValue()

template<Dart_TypedData_Type kTypeName, typename ElemType >
void tonic::DartConverter< TypedList< kTypeName, ElemType > >::SetReturnValue ( Dart_NativeArguments  args,
TypedList< kTypeName, ElemType >  val 
)
static

Definition at line 69 of file typed_list.cc.

References tonic::TypedList< kTypeName, ElemType >::dart_handle(), and tonic::TypedList< kTypeName, ElemType >::Release().

71  {
72  Dart_Handle result = val.dart_handle();
73  val.Release(); // Must release acquired typed data before calling Dart API.
74  Dart_SetReturnValue(args, result);
75 }
G_BEGIN_DECLS FlValue * args

◆ ToDart()

template<Dart_TypedData_Type kTypeName, typename ElemType >
Dart_Handle tonic::DartConverter< TypedList< kTypeName, ElemType > >::ToDart ( const ElemType *  buffer,
unsigned int  length 
)
static

Definition at line 78 of file typed_list.cc.

References tonic::TypedList< kTypeName, ElemType >::data(), length, tonic::LogIfError(), TONIC_CHECK, and TONIC_DCHECK.

80  {
81  const intptr_t buffer_length = static_cast<intptr_t>(length);
82  Dart_Handle array = Dart_NewTypedData(kTypeName, buffer_length);
83  TONIC_DCHECK(!LogIfError(array));
84  {
85  Dart_TypedData_Type type;
86  void* data = nullptr;
87  intptr_t data_length = 0;
88  Dart_TypedDataAcquireData(array, &type, &data, &data_length);
89  TONIC_CHECK(type == kTypeName);
90  TONIC_CHECK(data);
91  TONIC_CHECK(data_length == buffer_length);
92  std::memmove(data, buffer, data_length * sizeof(ElemType));
93  Dart_TypedDataReleaseData(array);
94  }
95  return array;
96 }
#define TONIC_DCHECK
Definition: macros.h:32
size_t length
#define TONIC_CHECK(condition)
Definition: macros.h:23
bool LogIfError(Dart_Handle handle)
Definition: dart_error.cc:15

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