GCC Code Coverage Report
Directory: ../ Exec Total Coverage
File: /home/node-core-coverage/node-core-coverage/workdir/node/out/../src/node_wrap.h Lines: 0 3 0.0 %
Date: 2016-09-05 Branches: 0 24 0.0 %

Line Branch Exec Source
1
#ifndef SRC_NODE_WRAP_H_
2
#define SRC_NODE_WRAP_H_
3
4
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
6
#include "env.h"
7
#include "env-inl.h"
8
#include "js_stream.h"
9
#include "pipe_wrap.h"
10
#include "tcp_wrap.h"
11
#include "tty_wrap.h"
12
#include "udp_wrap.h"
13
#include "util.h"
14
#include "util-inl.h"
15
#include "uv.h"
16
#include "v8.h"
17
18
namespace node {
19
20
#define WITH_GENERIC_UV_STREAM(env, obj, BODY, ELSE)                          \
21
    do {                                                                      \
22
      if (env->tcp_constructor_template().IsEmpty() == false &&               \
23
          env->tcp_constructor_template()->HasInstance(obj)) {                \
24
        TCPWrap* const wrap = Unwrap<TCPWrap>(obj);                           \
25
        BODY                                                                  \
26
      } else if (env->tty_constructor_template().IsEmpty() == false &&        \
27
                 env->tty_constructor_template()->HasInstance(obj)) {         \
28
        TTYWrap* const wrap = Unwrap<TTYWrap>(obj);                           \
29
        BODY                                                                  \
30
      } else if (env->pipe_constructor_template().IsEmpty() == false &&       \
31
                 env->pipe_constructor_template()->HasInstance(obj)) {        \
32
        PipeWrap* const wrap = Unwrap<PipeWrap>(obj);                         \
33
        BODY                                                                  \
34
      } else {                                                                \
35
        ELSE                                                                  \
36
      }                                                                       \
37
    } while (0)
38
39
inline uv_stream_t* HandleToStream(Environment* env,
40
                                   v8::Local<v8::Object> obj) {
41
  v8::HandleScope scope(env->isolate());
42
43
  WITH_GENERIC_UV_STREAM(env, obj, {
44
    if (wrap == nullptr)
45
      return nullptr;
46
    return reinterpret_cast<uv_stream_t*>(wrap->UVHandle());
47
  }, {});
48
49
  return nullptr;
50
}
51
52
}  // namespace node
53
54
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
55
56
#endif  // SRC_NODE_WRAP_H_