GCC Code Coverage Report
Directory: ../src/ Exec Total Coverage
File: /home/node-core-coverage/node-core-coverage/workdir/node/src/uv.cc Lines: 13 13 100.0 %
Date: 2016-07-23 Branches: 1 2 50.0 %

Line Exec Source
1
#include "uv.h"
2
#include "node.h"
3
#include "env.h"
4
#include "env-inl.h"
5
6
namespace node {
7
namespace uv {
8
9
using v8::Context;
10
using v8::FunctionCallbackInfo;
11
using v8::FunctionTemplate;
12
using v8::Integer;
13
using v8::Local;
14
using v8::Object;
15
using v8::String;
16
using v8::Value;
17
18
19
142
void ErrName(const FunctionCallbackInfo<Value>& args) {
20
142
  Environment* env = Environment::GetCurrent(args);
21
142
  int err = args[0]->Int32Value();
22
142
  if (err >= 0)
23
    return env->ThrowError("err >= 0");
24
142
  const char* name = uv_err_name(err);
25
284
  args.GetReturnValue().Set(OneByteString(env->isolate(), name));
26
}
27
28
29
1563
void Initialize(Local<Object> target,
30
                Local<Value> unused,
31
                Local<Context> context) {
32
1563
  Environment* env = Environment::GetCurrent(context);
33
6252
  target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "errname"),
34
4689
              env->NewFunctionTemplate(ErrName)->GetFunction());
35
#define V(name, _)                                                            \
36
  target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "UV_" # name),            \
37
              Integer::New(env->isolate(), UV_ ## name));
38
239139
  UV_ERRNO_MAP(V)
39
#undef V
40
1563
}
41
42
43
}  // namespace uv
44
}  // namespace node
45
46
1569
NODE_MODULE_CONTEXT_AWARE_BUILTIN(uv, node::uv::Initialize)