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 
13 namespace tonic {
14 
15 class DartByteData {
16  public:
17  static Dart_Handle Create(const void* data, size_t length);
18 
19  explicit DartByteData(Dart_Handle list);
20  DartByteData(DartByteData&& other);
21  DartByteData();
22  ~DartByteData();
23 
24  const void* data() const { return data_; }
25  void* data() { return data_; }
26  size_t length_in_bytes() const { return length_in_bytes_; }
27  Dart_Handle dart_handle() const { return dart_handle_; }
28 
29  std::vector<char> Copy() const;
30  void Release() const;
31 
32  explicit operator bool() const { return data_ != nullptr; }
33 
34  private:
35  mutable void* data_;
36  intptr_t length_in_bytes_;
37  Dart_Handle dart_handle_;
38 
39  DartByteData(const DartByteData& other) = delete;
40  DartByteData(const void* data, size_t length);
41 };
42 
43 template <>
45  static void SetReturnValue(Dart_NativeArguments args, DartByteData val);
46  static DartByteData FromArguments(Dart_NativeArguments args,
47  int index,
48  Dart_Handle& exception);
49 };
50 
51 } // namespace tonic
52 
53 #endif // LIB_TONIC_TYPED_DATA_DART_BYTE_DATA_H_
G_BEGIN_DECLS FlValue * args
const void * data() const
std::vector< char > Copy() const
size_t length_in_bytes() const
size_t length
Dart_Handle dart_handle() const
static Dart_Handle Create(const void *data, size_t length)
void Release() const