5#include "flutter/testing/test_dart_native_resolver.h"
10#include "flutter/fml/logging.h"
27 ffi_native_callbacks_[
name] = callback_ptr;
31 const std::string&
name)
const {
32 auto found = native_callbacks_.find(
name);
33 if (found == native_callbacks_.end()) {
40void* TestDartNativeResolver::ResolveFfiCallback(
41 const std::string&
name)
const {
42 auto found = ffi_native_callbacks_.find(
name);
43 if (found == ffi_native_callbacks_.end()) {
50static std::map<Dart_Isolate, std::weak_ptr<TestDartNativeResolver>>
56 bool* auto_setup_scope) {
66 if (
auto resolver = found->second.lock()) {
67 return resolver->ResolveCallback(
name);
78 return reinterpret_cast<const uint8_t*
>(
"¯\\_(ツ)_/¯");
81void* TestDartNativeResolver::FfiNativeResolver(
const char*
name,
90 if (
auto resolver = found->second.lock()) {
91 return resolver->ResolveFfiCallback(
name);
103 DartNativeEntryResolverCallback,
106 <<
"Could not set native resolver in test.";
110 <<
"Could not set FFI native resolver in test.";
115 std::vector<Dart_Isolate> isolates_with_dead_resolvers;
117 if (!entry.second.lock()) {
118 isolates_with_dead_resolvers.push_back(entry.first);
122 for (
const auto& dead_isolate : isolates_with_dead_resolvers) {
void AddFfiNativeCallback(const std::string &name, void *callback_ptr)
void SetNativeResolverForIsolate()
void AddNativeCallback(const std::string &name, Dart_NativeFunction callback)
~TestDartNativeResolver()
DART_EXPORT Dart_Handle Dart_SetFfiNativeResolver(Dart_Handle library, Dart_FfiNativeResolver resolver)
DART_EXPORT Dart_Handle Dart_SetNativeResolver(Dart_Handle library, Dart_NativeEntryResolver resolver, Dart_NativeEntrySymbol symbol)
struct _Dart_Handle * Dart_Handle
DART_EXPORT Dart_Isolate Dart_CurrentIsolate(void)
void(* Dart_NativeFunction)(Dart_NativeArguments arguments)
DART_EXPORT bool Dart_IsError(Dart_Handle handle)
DART_EXPORT Dart_Handle Dart_RootLibrary(void)
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
#define FML_LOG(severity)
#define FML_CHECK(condition)
Dart_NativeFunction function
static std::mutex gIsolateResolversMutex
static std::map< Dart_Isolate, std::weak_ptr< TestDartNativeResolver > > gIsolateResolvers
static const uint8_t * DartNativeEntrySymbolCallback(Dart_NativeFunction function)
DEF_SWITCHES_START aot vmservice shared library name
bool CheckAndHandleError(Dart_Handle handle)
std::string StdStringFromDart(Dart_Handle handle)