Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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
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)
struct _Dart_Handle * Dart_Handle
Definition dart_api.h:258
@ 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
@ Dart_TypedData_kInvalid
Definition dart_api.h:2619
GAsyncResult * result
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]