Flutter Engine
 
Loading...
Searching...
No Matches
fuchsia.cc File Reference
#include "dart-pkg/fuchsia/sdk_ext/fuchsia.h"
#include <zircon/syscalls.h>
#include <cstdio>
#include <cstring>
#include <memory>
#include <vector>
#include "dart-pkg/zircon/sdk_ext/handle.h"
#include "dart-pkg/zircon/sdk_ext/natives.h"
#include "dart-pkg/zircon/sdk_ext/system.h"
#include "third_party/dart/runtime/include/dart_api.h"
#include "third_party/tonic/dart_binding_macros.h"
#include "third_party/tonic/dart_class_library.h"
#include "third_party/tonic/dart_class_provider.h"
#include "third_party/tonic/dart_library_natives.h"
#include "third_party/tonic/dart_state.h"
#include "third_party/tonic/logging/dart_invoke.h"
#include "third_party/tonic/typed_data/typed_list.h"

Go to the source code of this file.

Namespaces

namespace  fuchsia
 
namespace  fuchsia::dart
 

Macros

#define REGISTER_FUNCTION(name, count)   {"" #name, name, count},
 
#define DECLARE_FUNCTION(name, count)    extern void name(Dart_NativeArguments args);
 
#define FIDL_NATIVE_LIST(V)   V(SetReturnCode, 1)
 

Functions

void fuchsia::dart::Initialize (zx::channel directory_request, std::optional< zx::eventpair > view_ref)
 Initializes Dart bindings for the Fuchsia application model.
 

Macro Definition Documentation

◆ DECLARE_FUNCTION

#define DECLARE_FUNCTION (   name,
  count 
)     extern void name(Dart_NativeArguments args);

Definition at line 41 of file fuchsia.cc.

47 {
48 const char* name;
49 Dart_NativeFunction function;
52
55 bool* auto_setup_scope) {
56 const char* function_name = nullptr;
58 if (Dart_IsError(result)) {
59 Dart_PropagateError(result);
60 }
61 FML_DCHECK(function_name != nullptr);
62 FML_DCHECK(auto_setup_scope != nullptr);
63 *auto_setup_scope = true;
64 size_t num_entries = std::size(Entries);
65 for (size_t i = 0; i < num_entries; ++i) {
66 const struct NativeEntries& entry = Entries[i];
67 if (!strcmp(function_name, entry.name) &&
68 (entry.argument_count == argument_count)) {
69 return entry.function;
70 }
71 }
72 if (!g_natives)
74 return g_natives->GetNativeFunction(name, argument_count, auto_setup_scope);
75}
76
77const uint8_t* NativeSymbol(Dart_NativeFunction native_function) {
78 size_t num_entries = std::size(Entries);
79 for (size_t i = 0; i < num_entries; ++i) {
80 const struct NativeEntries& entry = Entries[i];
81 if (entry.function == native_function) {
82 return reinterpret_cast<const uint8_t*>(entry.name);
83 }
84 }
85 if (!g_natives)
87 return g_natives->GetSymbol(native_function);
88}
89
90void SetReturnCode(Dart_NativeArguments arguments) {
92 Dart_Handle status =
94 if (!tonic::CheckAndHandleError(status)) {
96 }
97}
98
99} // namespace
100
101void Initialize(zx::channel directory_request,
102 std::optional<zx::eventpair> view_ref) {
104
105 Dart_Handle library = Dart_LookupLibrary(ToDart("dart:fuchsia"));
108 library, fuchsia::dart::NativeLookup, fuchsia::dart::NativeSymbol);
110
111 auto dart_state = tonic::DartState::Current();
112 std::unique_ptr<tonic::DartClassProvider> fuchsia_class_provider(
113 new tonic::DartClassProvider(dart_state, "dart:fuchsia"));
114 dart_state->class_library().add_provider("fuchsia",
115 std::move(fuchsia_class_provider));
116
117 if (directory_request) {
118 result = Dart_SetField(
119 library, ToDart("_outgoingServices"),
122 }
123
124 if (view_ref) {
125 result = Dart_SetField(
126 library, ToDart("_viewRef"),
127 ToDart(zircon::dart::Handle::Create((*view_ref).release())));
129 }
130}
131
132} // namespace dart
133} // namespace fuchsia
void SetReturnCode(uint32_t return_code)
Definition dart_state.cc:66
static DartState * Current()
Definition dart_state.cc:56
static fml::RefPtr< Handle > Create(zx_handle_t handle)
Definition handle.cc:28
#define FML_CHECK(condition)
Definition logging.h:104
#define FML_DCHECK(condition)
Definition logging.h:122
Dart_NativeFunction function
Definition fuchsia.cc:50
const char * name
Definition fuchsia.cc:49
#define FIDL_NATIVE_LIST(V)
Definition fuchsia.cc:44
#define REGISTER_FUNCTION(name, count)
Definition fuchsia.cc:40
int argument_count
Definition fuchsia.cc:51
void Initialize(zx::channel directory_request, std::optional< zx::eventpair > view_ref)
Initializes Dart bindings for the Fuchsia application model.
Definition fuchsia.cc:102
Dart_Handle ToDart(const T &object)
bool CheckAndHandleError(Dart_Handle handle)
Definition dart_error.cc:33
void Initialize()
Definition natives.cc:68

◆ FIDL_NATIVE_LIST

#define FIDL_NATIVE_LIST (   V)    V(SetReturnCode, 1)

Definition at line 44 of file fuchsia.cc.

◆ REGISTER_FUNCTION

#define REGISTER_FUNCTION (   name,
  count 
)    {"" #name, name, count},

Definition at line 40 of file fuchsia.cc.

Variable Documentation

◆ argument_count

int argument_count

Definition at line 51 of file fuchsia.cc.

Referenced by tonic::DartLibraryNatives::GetNativeFunction().

◆ function

◆ name

const char* name

Definition at line 49 of file fuchsia.cc.

Referenced by ui::AXPlatformNodeBase::AddAttributeToList(), ui::AXPlatformNodeBase::AddAttributeToList(), ui::AXPlatformNodeBase::AddAttributeToList(), ui::AXPlatformNodeBase::AddAttributeToList(), flutter::testing::FlutterEngineTest::AddNativeCallback(), impeller::ShaderArchiveWriter::AddShader(), checkProperty(), ui::AXPlatformNodeWinTest::CheckVariantHasName(), create_settings(), impeller::egl::CreateProcAddressResolver(), dart_utils::RootInspectNode::CreateRootChild(), tonic::DartInvokeField(), decode_error_method_call(), decode_error_method_call(), decode_method_call(), decode_method_call(), impeller::ContextMTL::DescribeGpuModel(), encode_method_call(), encode_method_call(), EngineProcResolver(), impeller::compiler::testing::FindByName(), fl_accessible_node_set_name(), fl_accessible_node_set_name_impl(), fl_basic_message_channel_new(), fl_engine_gl_proc_resolver(), fl_event_channel_new(), fl_json_method_codec_decode_method_call(), fl_json_method_codec_encode_method_call(), fl_method_call_new(), fl_method_channel_new(), fl_method_codec_decode_method_call(), fl_method_codec_encode_method_call(), fl_mock_binary_messenger_invoke_json_method(), fl_mock_binary_messenger_invoke_method(), fl_mock_binary_messenger_invoke_standard_method(), fl_mock_binary_messenger_send_on_channel(), fl_plugin_registry_get_registrar_for_plugin(), fl_standard_method_codec_decode_method_call(), fl_standard_method_codec_encode_method_call(), fl_test_codec_decode_method_call(), fl_test_codec_encode_method_call(), fl_test_texture_populate(), fl_texture_gl_populate(), FlutterEngineInitialize(), FlutterEngineTraceEventDurationBegin(), FlutterEngineTraceEventDurationEnd(), FlutterEngineTraceEventInstant(), flutter_runner::GetCurrentProcessName(), VSyncClient(Testing)::getDisplayLink, impeller::CapabilitiesVK::GetEnabledDeviceExtensions(), impeller::GetGLString(), impeller::GetGLStringi(), impeller::ShaderArchive::GetMapping(), ui::AXPlatformNodeBase::GetNameAsString16(), tonic::DartLibraryNatives::GetNativeFunction(), fml::CommandLine::GetOptionValue(), fml::CommandLine::GetOptionValues(), fml::CommandLine::GetOptionValueWithDefault(), fml::GetSymbolName(), impeller::RuntimeStage::GetUniform(), impeller::GLESShaderNameToShaderKeyName(), handle_method_call(), HasExtension(), fml::CommandLine::HasOption(), impeller::AiksPlayground::ImGuiBegin(), impeller::IsExtensionInList(), flutter::LogLastEGLError(), impeller::LogShaderCompilationFailure(), message_cb(), flutter::FlutterWindowsEngine::OnChannelUpdate(), std::operator<<(), Catalog::ParseEntry(), impeller::ResourceIsLive(), flutter::FlutterWindowsEngine::Run(), RunFlutter(), flutter_runner::Runner::Runner(), set_size_arg(), impeller::ProcTableGLES::SetDebugLabel(), flutter_runner::SetInterfaceErrorHandler(), flutter_runner::SetInterfaceErrorHandler(), SetMessageHandler(), ui::AXNodeData::SetName(), ui::AXNodeData::SetName(), impeller::CapabilitiesVK::SetPhysicalDevice(), flutter_runner::SetProcessName(), fml::SetThreadName(), impeller::interop::testing::SetupImpellerHPPProcTableOnce(), impeller::compiler::SourceTypeFromString(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), flutter_runner_test::TEST_F(), ui::TEST_F(), ui::TEST_F(), ui::TEST_F(), ui::TEST_F(), ui::TEST_F(), ui::TEST_F(), fml::testing::TEST_F(), test_method_codec_decode_method_call(), test_method_codec_encode_method_call(), fml::tracing::TraceCounter(), fml::tracing::TraceEvent(), fml::tracing::TraceEventAsyncComplete(), and impeller::VKShaderNameToShaderKeyName().