GCC Code Coverage Report
Directory: ../ Exec Total Coverage
File: /home/iojs/build/workspace/node-test-commit-linux-coverage-daily/nodes/benchmark/out/../src/node_binding.h Lines: 1 1 100.0 %
Date: 2019-09-23 22:30:09 Branches: 0 0 - %

Line Branch Exec Source
1
#ifndef SRC_NODE_BINDING_H_
2
#define SRC_NODE_BINDING_H_
3
4
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
6
#if defined(__POSIX__)
7
#include <dlfcn.h>
8
#endif
9
10
#include "node.h"
11
#define NAPI_EXPERIMENTAL
12
#include "node_api.h"
13
#include "util.h"
14
#include "uv.h"
15
#include "v8.h"
16
17
enum {
18
  NM_F_BUILTIN = 1 << 0,  // Unused.
19
  NM_F_LINKED = 1 << 1,
20
  NM_F_INTERNAL = 1 << 2,
21
  NM_F_DELETEME = 1 << 3,
22
};
23
24
// Make sure our internal values match the public API's values.
25
static_assert(static_cast<int>(NM_F_LINKED) ==
26
              static_cast<int>(node::ModuleFlags::kLinked),
27
              "NM_F_LINKED != node::ModuleFlags::kLinked");
28
29
#define NODE_MODULE_CONTEXT_AWARE_CPP(modname, regfunc, priv, flags)           \
30
  static node::node_module _module = {                                         \
31
      NODE_MODULE_VERSION,                                                     \
32
      flags,                                                                   \
33
      nullptr,                                                                 \
34
      __FILE__,                                                                \
35
      nullptr,                                                                 \
36
      (node::addon_context_register_func)(regfunc),                            \
37
      NODE_STRINGIFY(modname),                                                 \
38
      priv,                                                                    \
39
      nullptr};                                                                \
40
  void _register_##modname() { node_module_register(&_module); }
41
42
void napi_module_register_by_symbol(v8::Local<v8::Object> exports,
43
                                    v8::Local<v8::Value> module,
44
                                    v8::Local<v8::Context> context,
45
                                    napi_addon_register_func init);
46
47
namespace node {
48
49
#define NODE_MODULE_CONTEXT_AWARE_INTERNAL(modname, regfunc)                   \
50
  NODE_MODULE_CONTEXT_AWARE_CPP(modname, regfunc, nullptr, NM_F_INTERNAL)
51
52
// Globals per process
53
// This is set by node::Init() which is used by embedders
54
extern bool node_is_initialized;
55
56
namespace binding {
57
58
150
class DLib {
59
 public:
60
#ifdef __POSIX__
61
  static const int kDefaultFlags = RTLD_LAZY;
62
#else
63
  static const int kDefaultFlags = 0;
64
#endif
65
66
  DLib(const char* filename, int flags);
67
68
  bool Open();
69
  void Close();
70
  void* GetSymbolAddress(const char* name);
71
  void SaveInGlobalHandleMap(node_module* mp);
72
  node_module* GetSavedModuleFromGlobalHandleMap();
73
74
  const std::string filename_;
75
  const int flags_;
76
  std::string errmsg_;
77
  void* handle_;
78
#ifndef __POSIX__
79
  uv_lib_t lib_;
80
#endif
81
  bool has_entry_in_global_handle_map_ = false;
82
83
  DLib(const DLib&) = delete;
84
  DLib& operator=(const DLib&) = delete;
85
};
86
87
// Call _register<module_name> functions for all of
88
// the built-in modules. Because built-in modules don't
89
// use the __attribute__((constructor)). Need to
90
// explicitly call the _register* functions.
91
void RegisterBuiltinModules();
92
void GetInternalBinding(const v8::FunctionCallbackInfo<v8::Value>& args);
93
void GetLinkedBinding(const v8::FunctionCallbackInfo<v8::Value>& args);
94
void DLOpen(const v8::FunctionCallbackInfo<v8::Value>& args);
95
96
}  // namespace binding
97
98
}  // namespace node
99
100
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
101
#endif  // SRC_NODE_BINDING_H_