forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
native_library.h
56 lines (38 loc) · 1.27 KB
/
native_library.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright 2018 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_FML_NATIVE_LIBRARY_H_
#define FLUTTER_FML_NATIVE_LIBRARY_H_
#include "flutter/fml/macros.h"
#include "lib/fxl/memory/ref_counted.h"
#include "lib/fxl/memory/ref_ptr.h"
#if OS_WIN
#include <windows.h>
#endif // OS_WIN
namespace fml {
class NativeLibrary : public fxl::RefCountedThreadSafe<NativeLibrary> {
public:
#if OS_WIN
using Handle = HMODULE;
#else // OS_WIN
using Handle = void*;
#endif // OS_WIN
static fxl::RefPtr<NativeLibrary> Create(const char* path);
static fxl::RefPtr<NativeLibrary> CreateWithHandle(
Handle handle,
bool close_handle_when_done);
static fxl::RefPtr<NativeLibrary> CreateForCurrentProcess();
const uint8_t* ResolveSymbol(const char* symbol);
private:
Handle handle_ = nullptr;
bool close_handle_ = true;
NativeLibrary(const char* path);
NativeLibrary(Handle handle, bool close_handle);
~NativeLibrary();
Handle GetHandle() const;
FML_DISALLOW_COPY_AND_ASSIGN(NativeLibrary);
FRIEND_REF_COUNTED_THREAD_SAFE(NativeLibrary);
FRIEND_MAKE_REF_COUNTED(NativeLibrary);
};
} // namespace fml
#endif // FLUTTER_FML_NATIVE_LIBRARY_H_