• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 *  Copyright 2012 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// This file is a supermacro
12// (see http://wanderinghorse.net/computing/papers/supermacros_cpp.html) to
13// expand a definition of a late-binding symbol table class.
14//
15// Arguments:
16// LATE_BINDING_SYMBOL_TABLE_CLASS_NAME: Name of the class to generate.
17// LATE_BINDING_SYMBOL_TABLE_SYMBOLS_LIST: List of symbols to load from the DLL,
18//     as an X-Macro list (see http://www.drdobbs.com/blogs/cpp/228700289).
19// LATE_BINDING_SYMBOL_TABLE_DLL_NAME: String literal for the DLL file name to
20//     load.
21//
22// From a .cc file, include the header file containing your call to the .h.def
23// supermacro, and then call this supermacro (optionally from inside the
24// namespace for the class to generate, if any). Example:
25//
26// #include "myclassname.h"
27//
28// namespace foo {
29//
30// #define LATE_BINDING_SYMBOL_TABLE_CLASS_NAME MY_CLASS_NAME
31// #define LATE_BINDING_SYMBOL_TABLE_SYMBOLS_LIST MY_SYMBOLS_LIST
32// #define LATE_BINDING_SYMBOL_TABLE_DLL_NAME "libdll.so.n"
33// #include "webrtc/base/latebindingsymboltable.cc.def"
34//
35// }
36
37#ifndef LATE_BINDING_SYMBOL_TABLE_CLASS_NAME
38#error You must define LATE_BINDING_SYMBOL_TABLE_CLASS_NAME
39#endif
40
41#ifndef LATE_BINDING_SYMBOL_TABLE_SYMBOLS_LIST
42#error You must define LATE_BINDING_SYMBOL_TABLE_SYMBOLS_LIST
43#endif
44
45#ifndef LATE_BINDING_SYMBOL_TABLE_DLL_NAME
46#error You must define LATE_BINDING_SYMBOL_TABLE_DLL_NAME
47#endif
48
49#define X(sym) #sym,
50const char* const LATE_BINDING_SYMBOL_TABLE_CLASS_NAME::kSymbolNames[] = {
51  LATE_BINDING_SYMBOL_TABLE_SYMBOLS_LIST
52};
53#undef X
54
55const ::rtc::LateBindingSymbolTable::TableInfo
56    LATE_BINDING_SYMBOL_TABLE_CLASS_NAME::kTableInfo = {
57  LATE_BINDING_SYMBOL_TABLE_DLL_NAME,
58  SYMBOL_TABLE_SIZE,
59  LATE_BINDING_SYMBOL_TABLE_CLASS_NAME::kSymbolNames
60};
61
62LATE_BINDING_SYMBOL_TABLE_CLASS_NAME::LATE_BINDING_SYMBOL_TABLE_CLASS_NAME()
63    : ::rtc::LateBindingSymbolTable(&kTableInfo, table_) {}
64
65LATE_BINDING_SYMBOL_TABLE_CLASS_NAME::~LATE_BINDING_SYMBOL_TABLE_CLASS_NAME() {}
66
67#undef LATE_BINDING_SYMBOL_TABLE_CLASS_NAME
68#undef LATE_BINDING_SYMBOL_TABLE_SYMBOLS_LIST
69#undef LATE_BINDING_SYMBOL_TABLE_DLL_NAME
70