Flutter Engine
The Flutter Engine
typed_data_utils.cc
Go to the documentation of this file.
1// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
6#include "platform/assert.h"
7
8namespace dart {
9namespace bin {
10
13 result = Dart_TypedDataAcquireData(data, &type_, &data_, &length_);
14 if (Dart_IsError(result)) {
16 }
17}
18
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}
32
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}
57
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}
64
65} // namespace bin
66} // namespace dart
#define UNREACHABLE()
Definition: assert.h:248
const char * GetScopedCString() const
const char * GetCString() const
TypedDataScope(Dart_Handle data)
intptr_t size_in_bytes() const
struct _Dart_Handle * Dart_Handle
Definition: dart_api.h:258
@ Dart_TypedData_kFloat32x4
Definition: dart_api.h:2626
@ Dart_TypedData_kUint8
Definition: dart_api.h:2615
@ Dart_TypedData_kUint32
Definition: dart_api.h:2620
@ Dart_TypedData_kInt32
Definition: dart_api.h:2619
@ Dart_TypedData_kUint16
Definition: dart_api.h:2618
@ Dart_TypedData_kUint64
Definition: dart_api.h:2622
@ Dart_TypedData_kFloat32
Definition: dart_api.h:2623
@ Dart_TypedData_kInt16
Definition: dart_api.h:2617
@ Dart_TypedData_kFloat64
Definition: dart_api.h:2624
@ Dart_TypedData_kUint8Clamped
Definition: dart_api.h:2616
@ Dart_TypedData_kByteData
Definition: dart_api.h:2613
@ Dart_TypedData_kInt8
Definition: dart_api.h:2614
@ Dart_TypedData_kInt64
Definition: dart_api.h:2621
@ Dart_TypedData_kInvalid
Definition: dart_api.h:2628
GAsyncResult * result
Definition: dart_vm.cc:33
DART_EXPORT void Dart_PropagateError(Dart_Handle handle)
DART_EXPORT uint8_t * Dart_ScopeAllocate(intptr_t size)
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)
DART_EXPORT Dart_Handle Dart_TypedDataReleaseData(Dart_Handle object)
static int8_t data[kExtLength]