Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
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.

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

◆ 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.

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.

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.

31 {
32 TONIC_CHECK(0 <= i);
33 TONIC_CHECK(i < num_elements_);
34 return data_[i];
35 }

◆ dart_handle()

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

Definition at line 42 of file typed_list.h.

42{ return dart_handle_; }

◆ 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.

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.

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.

38{ return at(i); }

◆ Release()

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

Definition at line 48 of file typed_list.cc.

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

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