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

#include <typed_list.h>

Public Member Functions

 TypedList (Dart_Handle list)
 
 TypedList (TypedList< kTypeName, ElemType > &&other)
 
 TypedList ()
 
 ~TypedList ()
 
ElemType & at (intptr_t i)
 
const ElemType & at (intptr_t i) const
 
ElemType & operator[] (intptr_t i)
 
const ElemType & operator[] (intptr_t i) const
 
const ElemType * data () const
 
intptr_t num_elements () const
 
Dart_Handle dart_handle () const
 
void Release ()
 

Detailed Description

template<Dart_TypedData_Type kTypeName, typename ElemType>
class tonic::TypedList< kTypeName, ElemType >

Definition at line 19 of file typed_list.h.

Constructor & Destructor Documentation

◆ TypedList() [1/3]

template<Dart_TypedData_Type kTypeName, typename ElemType >
tonic::TypedList< kTypeName, ElemType >::TypedList ( Dart_Handle  list)
explicit

Definition at line 18 of file typed_list.cc.

References tonic::LogIfError(), tonic::ToDart(), and TONIC_DCHECK.

19  : data_(nullptr), num_elements_(0), dart_handle_(list) {
20  if (Dart_IsNull(list))
21  return;
22 
23  Dart_TypedData_Type type;
24  Dart_TypedDataAcquireData(list, &type, reinterpret_cast<void**>(&data_),
25  &num_elements_);
26  TONIC_DCHECK(!LogIfError(list));
27  if (type != kTypeName)
28  Dart_ThrowException(ToDart("Non-genuine TypedData passed to engine."));
29 }
#define TONIC_DCHECK
Definition: macros.h:32
Dart_Handle ToDart(const T &object)
bool LogIfError(Dart_Handle handle)
Definition: dart_error.cc:15

◆ TypedList() [2/3]

template<Dart_TypedData_Type kTypeName, typename ElemType >
tonic::TypedList< kTypeName, ElemType >::TypedList ( TypedList< kTypeName, ElemType > &&  other)

Definition at line 32 of file typed_list.cc.

34  : data_(other.data_),
35  num_elements_(other.num_elements_),
36  dart_handle_(other.dart_handle_) {
37  other.data_ = nullptr;
38  other.num_elements_ = 0;
39  other.dart_handle_ = nullptr;
40 }

◆ TypedList() [3/3]

template<Dart_TypedData_Type kTypeName, typename ElemType >
tonic::TypedList< kTypeName, ElemType >::TypedList ( )

Definition at line 14 of file typed_list.cc.

15  : data_(nullptr), num_elements_(0), dart_handle_(nullptr) {}

◆ ~TypedList()

template<Dart_TypedData_Type kTypeName, typename ElemType >
tonic::TypedList< kTypeName, ElemType >::~TypedList ( )

Definition at line 43 of file typed_list.cc.

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

43  {
44  Release();
45 }

Member Function Documentation

◆ at() [1/2]

template<Dart_TypedData_Type kTypeName, typename ElemType>
ElemType& tonic::TypedList< kTypeName, ElemType >::at ( intptr_t  i)
inline

Definition at line 26 of file typed_list.h.

References TONIC_CHECK.

Referenced by tonic::TypedList< kTypeName, ElemType >::operator[]().

26  {
27  TONIC_CHECK(0 <= i);
28  TONIC_CHECK(i < num_elements_);
29  return data_[i];
30  }
#define TONIC_CHECK(condition)
Definition: macros.h:23

◆ at() [2/2]

template<Dart_TypedData_Type kTypeName, typename ElemType>
const ElemType& tonic::TypedList< kTypeName, ElemType >::at ( intptr_t  i) const
inline

Definition at line 31 of file typed_list.h.

References TONIC_CHECK.

31  {
32  TONIC_CHECK(0 <= i);
33  TONIC_CHECK(i < num_elements_);
34  return data_[i];
35  }
#define TONIC_CHECK(condition)
Definition: macros.h:23

◆ dart_handle()

template<Dart_TypedData_Type kTypeName, typename ElemType>
Dart_Handle tonic::TypedList< kTypeName, ElemType >::dart_handle ( ) const
inline

◆ data()

template<Dart_TypedData_Type kTypeName, typename ElemType>
const ElemType* tonic::TypedList< kTypeName, ElemType >::data ( ) const
inline

Definition at line 40 of file typed_list.h.

Referenced by tonic::DartConverter< TypedList< kTypeName, ElemType > >::ToDart().

40 { return data_; }

◆ num_elements()

template<Dart_TypedData_Type kTypeName, typename ElemType>
intptr_t tonic::TypedList< kTypeName, ElemType >::num_elements ( ) const
inline

Definition at line 41 of file typed_list.h.

41 { return num_elements_; }

◆ operator[]() [1/2]

template<Dart_TypedData_Type kTypeName, typename ElemType>
ElemType& tonic::TypedList< kTypeName, ElemType >::operator[] ( intptr_t  i)
inline

Definition at line 37 of file typed_list.h.

References tonic::TypedList< kTypeName, ElemType >::at().

37 { return at(i); }
ElemType & at(intptr_t i)
Definition: typed_list.h:26

◆ operator[]() [2/2]

template<Dart_TypedData_Type kTypeName, typename ElemType>
const ElemType& tonic::TypedList< kTypeName, ElemType >::operator[] ( intptr_t  i) const
inline

Definition at line 38 of file typed_list.h.

References tonic::TypedList< kTypeName, ElemType >::at().

38 { return at(i); }
ElemType & at(intptr_t i)
Definition: typed_list.h:26

◆ Release()

template<Dart_TypedData_Type kTypeName, typename ElemType >
void tonic::TypedList< kTypeName, ElemType >::Release ( )

Definition at line 48 of file typed_list.cc.

Referenced by tonic::TypedList< kTypeName, ElemType >::dart_handle(), tonic::DartConverter< TypedList< kTypeName, ElemType > >::SetReturnValue(), and tonic::TypedList< kTypeName, ElemType >::~TypedList().

48  {
49  if (data_) {
50  Dart_TypedDataReleaseData(dart_handle_);
51  data_ = nullptr;
52  num_elements_ = 0;
53  dart_handle_ = nullptr;
54  }
55 }

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