Flutter Engine
The Flutter Engine
dart_byte_data.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef LIB_TONIC_TYPED_DATA_DART_BYTE_DATA_H_
6#define LIB_TONIC_TYPED_DATA_DART_BYTE_DATA_H_
7
8#include <vector>
9
10#include "third_party/dart/runtime/include/dart_api.h"
12
13namespace tonic {
14
16 public:
17 static const size_t kExternalSizeThreshold;
18 static Dart_Handle Create(const void* data, size_t length);
19
20 explicit DartByteData(Dart_Handle list);
24
25 const void* data() const { return data_; }
26 void* data() { return data_; }
27 size_t length_in_bytes() const { return length_in_bytes_; }
28 Dart_Handle dart_handle() const { return dart_handle_; }
29
30 std::vector<char> Copy() const;
31 void Release() const;
32
33 explicit operator bool() const { return data_ != nullptr; }
34
35 private:
36 mutable void* data_;
37 intptr_t length_in_bytes_;
38 Dart_Handle dart_handle_;
39
40 DartByteData(const DartByteData& other) = delete;
41 DartByteData(const void* data, size_t length);
42};
43
44template <>
47
48 static void SetReturnValue(Dart_NativeArguments args, DartByteData val);
49 static DartByteData FromArguments(Dart_NativeArguments args,
50 int index,
51 Dart_Handle& exception);
52
53 static DartByteData FromFfi(FfiType val) { return DartByteData(val); }
54 static FfiType ToFfi(DartByteData val) { return val.dart_handle(); }
55};
56
57} // namespace tonic
58
59#endif // LIB_TONIC_TYPED_DATA_DART_BYTE_DATA_H_
Dart_Handle dart_handle() const
static const size_t kExternalSizeThreshold
static Dart_Handle Create(const void *data, size_t length)
void Release() const
const void * data() const
std::vector< char > Copy() const
size_t length_in_bytes() const
struct _Dart_Handle * Dart_Handle
Definition: dart_api.h:258
struct _Dart_NativeArguments * Dart_NativeArguments
Definition: dart_api.h:3019
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
size_t length
static FfiType ToFfi(DartByteData val)
static DartByteData FromFfi(FfiType val)