Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
dart::bin::TypedDataScope Class Reference

#include <typed_data_utils.h>

Public Member Functions

 TypedDataScope (Dart_Handle data)
 
 ~TypedDataScope ()
 
void Release ()
 
const char * GetCString () const
 
const char * GetScopedCString () const
 
void * data () const
 
intptr_t length () const
 
intptr_t size_in_bytes () const
 
Dart_TypedData_Type type () const
 

Detailed Description

Definition at line 14 of file typed_data_utils.h.

Constructor & Destructor Documentation

◆ TypedDataScope()

dart::bin::TypedDataScope::TypedDataScope ( Dart_Handle  data)
explicit

Definition at line 11 of file typed_data_utils.cc.

11 : data_handle_(data) {
13 result = Dart_TypedDataAcquireData(data, &type_, &data_, &length_);
14 if (Dart_IsError(result)) {
16 }
17}
struct _Dart_Handle * Dart_Handle
Definition dart_api.h:258
GAsyncResult * result
DART_EXPORT void Dart_PropagateError(Dart_Handle handle)
DART_EXPORT Dart_Handle Dart_TypedDataAcquireData(Dart_Handle object, Dart_TypedData_Type *type, void **data, intptr_t *len)
DART_EXPORT bool Dart_IsError(Dart_Handle handle)

◆ ~TypedDataScope()

dart::bin::TypedDataScope::~TypedDataScope ( )
inline

Definition at line 17 of file typed_data_utils.h.

Member Function Documentation

◆ data()

void * dart::bin::TypedDataScope::data ( ) const
inline

Definition at line 27 of file typed_data_utils.h.

27{ return data_; }

◆ GetCString()

const char * dart::bin::TypedDataScope::GetCString ( ) const
inline

Definition at line 21 of file typed_data_utils.h.

21 {
22 return reinterpret_cast<const char*>(data_);
23 }

◆ GetScopedCString()

const char * dart::bin::TypedDataScope::GetScopedCString ( ) const

Definition at line 58 of file typed_data_utils.cc.

58 {
59 char* buf = reinterpret_cast<char*>(Dart_ScopeAllocate(size_in_bytes() + 1));
60 strncpy(buf, GetCString(), size_in_bytes());
61 buf[size_in_bytes()] = '\0';
62 return buf;
63}
const char * GetCString() const
DART_EXPORT uint8_t * Dart_ScopeAllocate(intptr_t size)

◆ length()

intptr_t dart::bin::TypedDataScope::length ( ) const
inline

Definition at line 28 of file typed_data_utils.h.

28{ return length_; }

◆ Release()

void dart::bin::TypedDataScope::Release ( )

Definition at line 19 of file typed_data_utils.cc.

19 {
20 if (data_handle_ == nullptr) {
21 return;
22 }
24 if (Dart_IsError(result)) {
26 }
27 data_handle_ = nullptr;
28 data_ = nullptr;
29 length_ = 0;
31}
@ Dart_TypedData_kInvalid
Definition dart_api.h:2619
DART_EXPORT Dart_Handle Dart_TypedDataReleaseData(Dart_Handle object)

◆ size_in_bytes()

intptr_t dart::bin::TypedDataScope::size_in_bytes ( ) const

Definition at line 33 of file typed_data_utils.cc.

33 {
34 switch (type_) {
39 return length_;
42 return length_ * 2;
46 return length_ * 4;
50 return length_ * 8;
52 return length_ * 16;
53 default:
55 }
56}
#define UNREACHABLE()
Definition assert.h:248
@ Dart_TypedData_kFloat32x4
Definition dart_api.h:2617
@ Dart_TypedData_kUint8
Definition dart_api.h:2606
@ Dart_TypedData_kUint32
Definition dart_api.h:2611
@ Dart_TypedData_kInt32
Definition dart_api.h:2610
@ Dart_TypedData_kUint16
Definition dart_api.h:2609
@ Dart_TypedData_kUint64
Definition dart_api.h:2613
@ Dart_TypedData_kFloat32
Definition dart_api.h:2614
@ Dart_TypedData_kInt16
Definition dart_api.h:2608
@ Dart_TypedData_kFloat64
Definition dart_api.h:2615
@ Dart_TypedData_kUint8Clamped
Definition dart_api.h:2607
@ Dart_TypedData_kByteData
Definition dart_api.h:2604
@ Dart_TypedData_kInt8
Definition dart_api.h:2605
@ Dart_TypedData_kInt64
Definition dart_api.h:2612

◆ type()

Dart_TypedData_Type dart::bin::TypedDataScope::type ( ) const
inline

Definition at line 30 of file typed_data_utils.h.

30{ return type_; }

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