Flutter Engine
The Flutter Engine
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
native_library_win.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
5#include "flutter/fml/native_library.h"
6
7#include <windows.h>
8
9#include "flutter/fml/platform/win/wstring_conversion.h"
10
11namespace fml {
12
13NativeLibrary::NativeLibrary(const char* path)
14 : handle_(nullptr), close_handle_(true) {
15 if (path == nullptr) {
16 return;
17 }
18
20}
21
22NativeLibrary::NativeLibrary(Handle handle, bool close_handle)
23 : handle_(handle), close_handle_(close_handle) {}
24
25NativeLibrary::~NativeLibrary() {
26 if (handle_ != nullptr && close_handle_) {
27 ::FreeLibrary(handle_);
28 }
29}
30
31NativeLibrary::Handle NativeLibrary::GetHandle() const {
32 return handle_;
33}
34
36 auto library = fml::AdoptRef(new NativeLibrary(path));
37 return library->GetHandle() != nullptr ? library : nullptr;
38}
39
40fml::RefPtr<NativeLibrary> NativeLibrary::CreateWithHandle(
41 Handle handle,
42 bool close_handle_when_done) {
43 auto library =
44 fml::AdoptRef(new NativeLibrary(handle, close_handle_when_done));
45 return library->GetHandle() != nullptr ? library : nullptr;
46}
47
48fml::RefPtr<NativeLibrary> NativeLibrary::CreateForCurrentProcess() {
49 return fml::AdoptRef(new NativeLibrary(::GetModuleHandle(nullptr), false));
50}
51
52NativeLibrary::SymbolHandle NativeLibrary::Resolve(const char* symbol) const {
53 if (symbol == nullptr || handle_ == nullptr) {
54 return nullptr;
55 }
56 return ::GetProcAddress(handle_, symbol);
57}
58
59} // namespace fml
static sk_sp< Effect > Create()
Definition: RefCntTest.cpp:117
static FunctionPtr Resolve(Thread *thread, Zone *zone, const GrowableArray< const Instance * > &caller_arguments, const Class &receiver_class, const String &name, const Array &descriptor)
static Dart_Handle LoadLibrary(Thread *T, const ExternalTypedData &td)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57
Definition: ascii_trie.cc:9
std::wstring Utf8ToWideString(const std::string_view str)
RefPtr< T > AdoptRef(T *ptr)
Definition: ref_ptr.h:222
fuchsia::ui::composition::ParentViewportWatcherHandle handle_