Flutter Engine
 
Loading...
Searching...
No Matches
test_dart_native_resolver.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 FLUTTER_TESTING_TEST_DART_NATIVE_RESOLVER_H_
6#define FLUTTER_TESTING_TEST_DART_NATIVE_RESOLVER_H_
7
8#include <functional>
9#include <map>
10#include <memory>
11#include <string>
12
13#include "flutter/fml/macros.h"
14#include "third_party/dart/runtime/include/dart_api.h"
15
16#define CREATE_NATIVE_ENTRY(native_entry) \
17 ([&]() { \
18 static ::flutter::testing::NativeEntry closure; \
19 static Dart_NativeFunction entrypoint = [](Dart_NativeArguments args) { \
20 closure(args); \
21 }; \
22 closure = (native_entry); \
23 return entrypoint; \
24 })()
25
26namespace flutter::testing {
27
28using NativeEntry = std::function<void(Dart_NativeArguments)>;
29
31 : public std::enable_shared_from_this<TestDartNativeResolver> {
32 public:
34
36
37 void AddNativeCallback(const std::string& name, Dart_NativeFunction callback);
38 void AddFfiNativeCallback(const std::string& name, void* callback_ptr);
39
41
42 private:
43 std::map<std::string, Dart_NativeFunction> native_callbacks_;
44 std::map<std::string, void*> ffi_native_callbacks_;
45
46 Dart_NativeFunction ResolveCallback(const std::string& name) const;
47 void* ResolveFfiCallback(const std::string& name) const;
48
49 static Dart_NativeFunction DartNativeEntryResolverCallback(
50 Dart_Handle dart_name,
51 int num_of_arguments,
52 bool* auto_setup_scope);
53 static void* FfiNativeResolver(const char* name, uintptr_t args_n);
54
56};
57
58} // namespace flutter::testing
59
60#endif // FLUTTER_TESTING_TEST_DART_NATIVE_RESOLVER_H_
void AddFfiNativeCallback(const std::string &name, void *callback_ptr)
void AddNativeCallback(const std::string &name, Dart_NativeFunction callback)
FlutterDesktopBinaryReply callback
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27
std::function< void(Dart_NativeArguments)> NativeEntry
DEF_SWITCHES_START aot vmservice shared library name
Definition switch_defs.h:27