7#include <zircon/syscalls.h>
17#include "flutter/fml/size.h"
18#include "third_party/dart/runtime/include/dart_api.h"
41#define REGISTER_FUNCTION(name, count) {"" #name, name, count},
42#define DECLARE_FUNCTION(name, count) \
43 extern void name(Dart_NativeArguments args);
45#define FIDL_NATIVE_LIST(V) V(SetReturnCode, 1)
49static struct NativeEntries {
57 bool* auto_setup_scope) {
65 *auto_setup_scope =
true;
67 for (
size_t i = 0;
i < num_entries; ++
i) {
68 const struct NativeEntries& entry = Entries[
i];
71 return entry.function;
75 g_natives = InitNatives();
81 for (
size_t i = 0;
i < num_entries; ++
i) {
82 const struct NativeEntries& entry = Entries[
i];
83 if (entry.function == native_function) {
84 return reinterpret_cast<const uint8_t*
>(entry.name);
88 g_natives = InitNatives();
89 return g_natives->
GetSymbol(native_function);
104 std::optional<zx::eventpair> view_ref) {
114 std::unique_ptr<tonic::DartClassProvider> fuchsia_class_provider(
116 dart_state->class_library().add_provider(
"fuchsia",
117 std::move(fuchsia_class_provider));
119 if (directory_request) {
121 library,
ToDart(
"_outgoingServices"),
128 library,
ToDart(
"_viewRef"),
const uint8_t * GetSymbol(Dart_NativeFunction native_function)
Dart_NativeFunction GetNativeFunction(Dart_Handle name, int argument_count, bool *auto_setup_scope)
void SetReturnCode(uint32_t return_code)
static DartState * Current()
static fml::RefPtr< Handle > Create(zx_handle_t handle)
DART_EXPORT Dart_Handle Dart_SetNativeResolver(Dart_Handle library, Dart_NativeEntryResolver resolver, Dart_NativeEntrySymbol symbol)
struct _Dart_Handle * Dart_Handle
DART_EXPORT void Dart_PropagateError(Dart_Handle handle)
DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url)
struct _Dart_NativeArguments * Dart_NativeArguments
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_SetField(Dart_Handle container, Dart_Handle name, Dart_Handle value)
DART_EXPORT Dart_Handle Dart_GetNativeIntegerArgument(Dart_NativeArguments args, int index, int64_t *value)
DART_EXPORT Dart_Handle Dart_StringToCString(Dart_Handle str, const char **cstr)
void(* Dart_NativeFunction)(Dart_NativeArguments arguments)
DART_EXPORT bool Dart_IsError(Dart_Handle handle)
#define FML_CHECK(condition)
#define FML_DCHECK(condition)
Dart_NativeFunction function
#define FIDL_NATIVE_LIST(V)
#define REGISTER_FUNCTION(name, count)
#define DECLARE_FUNCTION(name, count)
static Dart_NativeFunction NativeLookup(Dart_Handle name, int argc, bool *auto_setup_scope)
const char *const function_name
constexpr std::size_t size(T(&array)[N])
void Initialize(zx::channel directory_request, std::optional< zx::eventpair > view_ref)
Initializes Dart bindings for the Fuchsia application model.
Dart_Handle ToDart(const T &object)
bool CheckAndHandleError(Dart_Handle handle)