OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license | |
5 * that can be found in the LICENSE file in the root of the source | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #ifndef WEBRTC_BASE_LATEBINDINGSYMBOLTABLE_H_ | |
12 #define WEBRTC_BASE_LATEBINDINGSYMBOLTABLE_H_ | |
13 | |
14 #include <string.h> | |
15 | |
16 #include "webrtc/base/common.h" | |
17 #include "webrtc/base/constructormagic.h" | |
18 | |
19 namespace rtc { | |
20 | |
21 #if defined(WEBRTC_POSIX) | |
22 typedef void *DllHandle; | |
23 #else | |
24 #error Not implemented for this platform | |
25 #endif | |
26 | |
27 // This is the base class for "symbol table" classes to simplify the dynamic | |
28 // loading of symbols from DLLs. Currently the implementation only supports | |
29 // Linux and OS X, and pure C symbols (or extern "C" symbols that wrap C++ | |
30 // functions). Sub-classes for specific DLLs are generated via the "supermacro" | |
31 // files latebindingsymboltable.h.def and latebindingsymboltable.cc.def. See | |
32 // talk/sound/pulseaudiosymboltable.(h|cc) for an example. | |
33 class LateBindingSymbolTable { | |
34 public: | |
35 struct TableInfo { | |
36 const char *dll_name; | |
37 int num_symbols; | |
38 // Array of size num_symbols. | |
39 const char *const *symbol_names; | |
40 }; | |
41 | |
42 LateBindingSymbolTable(const TableInfo *info, void **table); | |
43 ~LateBindingSymbolTable(); | |
44 | |
45 bool IsLoaded() const; | |
46 // Loads the DLL and the symbol table. Returns true iff the DLL and symbol | |
47 // table loaded successfully. | |
48 bool Load(); | |
49 // Like load, but allows overriding the dll path for when the dll path is | |
50 // dynamic. | |
51 bool LoadFromPath(const char *dll_path); | |
52 void Unload(); | |
53 | |
54 // Gets the raw OS handle to the DLL. Be careful what you do with it. | |
55 DllHandle GetDllHandle() const { return handle_; } | |
56 | |
57 private: | |
58 void ClearSymbols(); | |
59 | |
60 const TableInfo *info_; | |
61 void **table_; | |
62 DllHandle handle_; | |
63 bool undefined_symbols_; | |
64 | |
65 RTC_DISALLOW_COPY_AND_ASSIGN(LateBindingSymbolTable); | |
66 }; | |
67 | |
68 } // namespace rtc | |
69 | |
70 #endif // WEBRTC_BASE_LATEBINDINGSYMBOLTABLE_H_ | |
OLD | NEW |