Reformat the WebRTC code base
Running clang-format with chromium's style guide. The goal is n-fold: * providing consistency and readability (that's what code guidelines are for) * preventing noise with presubmit checks and git cl format * building on the previous point: making it easier to automatically fix format issues * you name it Please consider using git-hyper-blame to ignore this commit. Bug: webrtc:9340 Change-Id: I694567c4cdf8cee2860958cfe82bfaf25848bb87 Reviewed-on: https://webrtc-review.googlesource.com/81185 Reviewed-by: Patrik Höglund <phoglund@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23660}
This commit is contained in:
@ -26,7 +26,7 @@ namespace webrtc {
|
||||
namespace adm_linux {
|
||||
|
||||
#ifdef WEBRTC_LINUX
|
||||
typedef void *DllHandle;
|
||||
typedef void* DllHandle;
|
||||
|
||||
const DllHandle kInvalidDllHandle = NULL;
|
||||
#else
|
||||
@ -40,37 +40,30 @@ void InternalUnloadDll(DllHandle handle);
|
||||
|
||||
bool InternalLoadSymbols(DllHandle handle,
|
||||
int num_symbols,
|
||||
const char *const symbol_names[],
|
||||
void *symbols[]);
|
||||
const char* const symbol_names[],
|
||||
void* symbols[]);
|
||||
|
||||
template <int SYMBOL_TABLE_SIZE,
|
||||
const char kDllName[],
|
||||
const char *const kSymbolNames[]>
|
||||
const char* const kSymbolNames[]>
|
||||
class LateBindingSymbolTable {
|
||||
public:
|
||||
LateBindingSymbolTable()
|
||||
: handle_(kInvalidDllHandle),
|
||||
undefined_symbols_(false) {
|
||||
: handle_(kInvalidDllHandle), undefined_symbols_(false) {
|
||||
memset(symbols_, 0, sizeof(symbols_));
|
||||
}
|
||||
|
||||
~LateBindingSymbolTable() {
|
||||
Unload();
|
||||
}
|
||||
~LateBindingSymbolTable() { Unload(); }
|
||||
|
||||
static int NumSymbols() {
|
||||
return SYMBOL_TABLE_SIZE;
|
||||
}
|
||||
static int NumSymbols() { return SYMBOL_TABLE_SIZE; }
|
||||
|
||||
// We do not use this, but we offer it for theoretical convenience.
|
||||
static const char *GetSymbolName(int index) {
|
||||
static const char* GetSymbolName(int index) {
|
||||
assert(index < NumSymbols());
|
||||
return kSymbolNames[index];
|
||||
}
|
||||
|
||||
bool IsLoaded() const {
|
||||
return handle_ != kInvalidDllHandle;
|
||||
}
|
||||
bool IsLoaded() const { return handle_ != kInvalidDllHandle; }
|
||||
|
||||
// Loads the DLL and the symbol table. Returns true iff the DLL and symbol
|
||||
// table loaded successfully.
|
||||
@ -106,7 +99,7 @@ class LateBindingSymbolTable {
|
||||
|
||||
// Retrieves the given symbol. NOTE: Recommended to use LATESYM_GET below
|
||||
// instead of this.
|
||||
void *GetSymbol(int index) const {
|
||||
void* GetSymbol(int index) const {
|
||||
assert(IsLoaded());
|
||||
assert(index < NumSymbols());
|
||||
return symbols_[index];
|
||||
@ -115,15 +108,13 @@ class LateBindingSymbolTable {
|
||||
private:
|
||||
DllHandle handle_;
|
||||
bool undefined_symbols_;
|
||||
void *symbols_[SYMBOL_TABLE_SIZE];
|
||||
void* symbols_[SYMBOL_TABLE_SIZE];
|
||||
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(LateBindingSymbolTable);
|
||||
};
|
||||
|
||||
// This macro must be invoked in a header to declare a symbol table class.
|
||||
#define LATE_BINDING_SYMBOL_TABLE_DECLARE_BEGIN(ClassName) \
|
||||
enum {
|
||||
|
||||
#define LATE_BINDING_SYMBOL_TABLE_DECLARE_BEGIN(ClassName) enum {
|
||||
// This macro must be invoked in the header declaration once for each symbol
|
||||
// (recommended to use an X-Macro to avoid duplication).
|
||||
// This macro defines an enum with names built from the symbols, which
|
||||
@ -150,26 +141,24 @@ enum {
|
||||
// This macro must be invoked in a .cc file to define a previously-declared
|
||||
// symbol table class.
|
||||
#define LATE_BINDING_SYMBOL_TABLE_DEFINE_BEGIN(ClassName, dllName) \
|
||||
const char ClassName##_kDllName[] = dllName; \
|
||||
const char *const ClassName##_kSymbolNames[ClassName##_SYMBOL_TABLE_SIZE] = {
|
||||
|
||||
const char ClassName##_kDllName[] = dllName; \
|
||||
const char* const ClassName##_kSymbolNames[ClassName##_SYMBOL_TABLE_SIZE] = {
|
||||
// This macro must be invoked in the .cc definition once for each symbol
|
||||
// (recommended to use an X-Macro to avoid duplication).
|
||||
// This would have to use the mangled name if we were to ever support C++
|
||||
// symbols.
|
||||
#define LATE_BINDING_SYMBOL_TABLE_DEFINE_ENTRY(ClassName, sym) \
|
||||
#sym,
|
||||
#define LATE_BINDING_SYMBOL_TABLE_DEFINE_ENTRY(ClassName, sym) #sym,
|
||||
|
||||
#define LATE_BINDING_SYMBOL_TABLE_DEFINE_END(ClassName) \
|
||||
};
|
||||
} \
|
||||
;
|
||||
|
||||
// Index of a given symbol in the given symbol table class.
|
||||
#define LATESYM_INDEXOF(ClassName, sym) \
|
||||
(ClassName##_SYMBOL_TABLE_INDEX_##sym)
|
||||
#define LATESYM_INDEXOF(ClassName, sym) (ClassName##_SYMBOL_TABLE_INDEX_##sym)
|
||||
|
||||
// Returns a reference to the given late-binded symbol, with the correct type.
|
||||
#define LATESYM_GET(ClassName, inst, sym) \
|
||||
(*reinterpret_cast<typeof(&sym)>( \
|
||||
(*reinterpret_cast<typeof(&sym)>( \
|
||||
(inst)->GetSymbol(LATESYM_INDEXOF(ClassName, sym))))
|
||||
|
||||
} // namespace adm_linux
|
||||
|
||||
Reference in New Issue
Block a user