Flutter Engine
The Flutter Engine
dart_library_natives.cc
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
6
8
9namespace tonic {
10
12
14
15void DartLibraryNatives::Register(std::initializer_list<Entry> entries) {
16 for (const Entry& entry : entries) {
17 symbols_.emplace(entry.native_function, entry.symbol);
18 entries_.emplace(entry.symbol, entry);
19 }
20}
21
25 bool* auto_setup_scope) {
26 std::string name_string = StdStringFromDart(name);
27 auto it = entries_.find(name_string);
28 if (it == entries_.end())
29 return nullptr;
30 const Entry& entry = it->second;
31 if (entry.argument_count != argument_count)
32 return nullptr;
33 *auto_setup_scope = entry.auto_setup_scope;
34 return entry.native_function;
35}
36
38 Dart_NativeFunction native_function) {
39 auto it = symbols_.find(native_function);
40 if (it == symbols_.end())
41 return nullptr;
42 return reinterpret_cast<const uint8_t*>(it->second);
43}
44
45} // namespace tonic
void Register(std::initializer_list< Entry > entries)
const uint8_t * GetSymbol(Dart_NativeFunction native_function)
Dart_NativeFunction GetNativeFunction(Dart_Handle name, int argument_count, bool *auto_setup_scope)
struct _Dart_Handle * Dart_Handle
Definition: dart_api.h:258
void(* Dart_NativeFunction)(Dart_NativeArguments arguments)
Definition: dart_api.h:3207
int argument_count
Definition: fuchsia.cc:52
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32
std::string StdStringFromDart(Dart_Handle handle)