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 
9 namespace tonic {
10 
12 
14 
15 void 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 
23  Dart_Handle name,
24  int argument_count,
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
int argument_count
Definition: fuchsia.cc:52
int argument_count
Dart_NativeFunction native_function
const uint8_t * GetSymbol(Dart_NativeFunction native_function)
std::string StdStringFromDart(Dart_Handle handle)
void Register(std::initializer_list< Entry > entries)
const char * name
Definition: fuchsia.cc:50
Dart_NativeFunction GetNativeFunction(Dart_Handle name, int argument_count, bool *auto_setup_scope)
bool auto_setup_scope