• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 FLUTTER_LIB_UI_DART_WRAPPER_H_
6 #define FLUTTER_LIB_UI_DART_WRAPPER_H_
7 
8 #include <initializer_list>
9 #include <vector>
10 
11 #include "flutter/fml/logging.h"
12 #include "flutter/fml/memory/ref_counted.h"
13 
14 using Dart_Handle = const void*;
15 Dart_Handle Dart_Null();
16 
17 class Dart_NativeArguments {
18 };
19 
20 using Dart_NativeFunction = void (*)(Dart_NativeArguments);
21 
22 #define DEFINE_WRAPPERTYPEINFO()
23 #define DART_BIND_ALL(a,b)
24 #define IMPLEMENT_WRAPPERTYPEINFO(a,b)
25 
26 #define DartCallConstructor(a,b)
27 
28 #define DART_NATIVE_CALLBACK(a,b)
29 
30 #define DART_REGISTER_NATIVE(a,b)
31 
32 #define Dart_NewTypedData(a,b) (b)
33 namespace tonic {
34 
35 using Float32List = std::vector<float>;
36 using Float64List = std::vector<double>;
37 using Int32List = std::vector<int>;
38 using Uint16List = std::vector<unsigned short>;
39 using Uint8List = std::vector<unsigned char>;
40 
41 class DartWrappable {
42   public:
43     virtual size_t GetAllocationSize();
ClearDartWrapper()44     void ClearDartWrapper() {}
45   private:
~DartWrappable()46     virtual ~DartWrappable() {};
47 };
48 
49 }
50 
51 namespace flutter {
52 
53 template <typename T>
54 class RefCountedDartWrappable : public fml::RefCountedThreadSafe<T> {
55  public:
~RefCountedDartWrappable()56   virtual ~RefCountedDartWrappable() {}
GetAllocationSize()57   virtual size_t GetAllocationSize() { return 0;}
ClearDartWrapper()58   void ClearDartWrapper() {}
59 };
60 
61 }  // namespace flutter
62 
63 namespace tonic {
64 class DartLibraryNatives {
65  public:
66   struct Entry {
67     const char* symbol;
68     Dart_NativeFunction func;
69     int argument_count;
70     bool auto_setup;
71   };
72   void Register(std::initializer_list<Entry> entries);
73 };
74 
75 class DartPersistentValue {
76 };
77 
78 template <typename T, typename Enable = void>
79 struct DartConverter {};
80 
81 Dart_Handle ToDart(const char*msg);
82 Dart_Handle ToDart(int);
83 
84 template <typename T>
85 struct DartListFactory {
86 };
87 
88 }// namespace tonic
89 
90 void Dart_ThrowException(Dart_Handle handle);
91 
92 using Dart_CoreType_Id = enum {
93   Dart_CoreType_Dynamic,
94   Dart_CoreType_Int,
95   Dart_CoreType_String
96 };
97 
98 Dart_Handle Dart_NewListOf(Dart_CoreType_Id id, intptr_t len);
99 
100 Dart_Handle Dart_ListSetAt(Dart_Handle list, intptr_t index, Dart_Handle value);
101 
102 Dart_Handle Dart_NewListOfType(Dart_Handle type, intptr_t len);
103 
104 bool LogIfError(Dart_Handle type);
105 
106 #define FLUTTER_LIB_UI_ISOLATE_NAME_SERVER_H_
107 
108 #endif  // FLUTTER_LIB_UI_DART_WRAPPER_H_
109