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-02-13 22:28:58 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
};
22
23
#define NODE_MODULE_CONTEXT_AWARE_CPP(modname, regfunc, priv, flags)           \
24
  static node::node_module _module = {                                         \
25
      NODE_MODULE_VERSION,                                                     \
26
      flags,                                                                   \
27
      nullptr,                                                                 \
28
      __FILE__,                                                                \
29
      nullptr,                                                                 \
30
      (node::addon_context_register_func)(regfunc),                            \
31
      NODE_STRINGIFY(modname),                                                 \
32
      priv,                                                                    \
33
      nullptr};                                                                \
34
  void _register_##modname() { node_module_register(&_module); }
35
36
void napi_module_register_by_symbol(v8::Local<v8::Object> exports,
37
                                    v8::Local<v8::Value> module,
38
                                    v8::Local<v8::Context> context,
39
                                    napi_addon_register_func init);
40
41
namespace node {
42
43
#define NODE_MODULE_CONTEXT_AWARE_INTERNAL(modname, regfunc)                   \
44
  NODE_MODULE_CONTEXT_AWARE_CPP(modname, regfunc, nullptr, NM_F_INTERNAL)
45
46
// Globals per process
47
// This is set by node::Init() which is used by embedders
48
extern bool node_is_initialized;
49
50
namespace binding {
51
52
125
class DLib {
53
 public:
54
#ifdef __POSIX__
55
  static const int kDefaultFlags = RTLD_LAZY;
56
#else
57
  static const int kDefaultFlags = 0;
58
#endif
59
60
  DLib(const char* filename, int flags);
61
62
  bool Open();
63
  void Close();
64
  void* GetSymbolAddress(const char* name);
65
66
  const std::string filename_;
67
  const int flags_;
68
  std::string errmsg_;
69
  void* handle_;
70
#ifndef __POSIX__
71
  uv_lib_t lib_;
72
#endif
73
74
 private:
75
  DISALLOW_COPY_AND_ASSIGN(DLib);
76
};
77
78
// Call _register<module_name> functions for all of
79
// the built-in modules. Because built-in modules don't
80
// use the __attribute__((constructor)). Need to
81
// explicitly call the _register* functions.
82
void RegisterBuiltinModules();
83
void GetInternalBinding(const v8::FunctionCallbackInfo<v8::Value>& args);
84
void GetLinkedBinding(const v8::FunctionCallbackInfo<v8::Value>& args);
85
void DLOpen(const v8::FunctionCallbackInfo<v8::Value>& args);
86
87
}  // namespace binding
88
89
}  // namespace node
90
91
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
92
#endif  // SRC_NODE_BINDING_H_