GCC Code Coverage Report
Directory: ../src/ Exec Total Coverage
File: /home/node-core-coverage/node-core-coverage/workdir/node/out/../src/node_javascript.cc Lines: 9 9 100.0 %
Date: 2017-01-02 Branches: 89 178 50.0 %

Line Branch Exec Source
1
#include "node.h"
2
#include "node_natives.h"
3
#include "v8.h"
4
#include "env.h"
5
#include "env-inl.h"
6
7
namespace node {
8
9
using v8::Local;
10
using v8::NewStringType;
11
using v8::Object;
12
using v8::String;
13
14
// id##_data is defined in node_natives.h.
15
#define V(id)                                                                 \
16
  static struct : public String::ExternalOneByteStringResource {              \
17
    const char* data() const override {                                       \
18
      return reinterpret_cast<const char*>(id##_data);                        \
19
    }                                                                         \
20
    size_t length() const override { return sizeof(id##_data); }              \
21
    void Dispose() override { /* Default calls `delete this`. */ }            \
22
  } id##_external_data;
23
1464532
NODE_NATIVES_MAP(V)
24
#undef V
25
26
1750
Local<String> MainSource(Environment* env) {
27
  auto maybe_string =
28
      String::NewExternalOneByte(
29
          env->isolate(),
30
1750
          &internal_bootstrap_node_external_data);
31
1750
  return maybe_string.ToLocalChecked();
32
}
33
34
1750
void DefineJavaScript(Environment* env, Local<Object> target) {
35
1750
  auto context = env->context();
36
#define V(id)                                                                 \
37
  do {                                                                        \
38
    auto key =                                                                \
39
        String::NewFromOneByte(                                               \
40
            env->isolate(), id##_name, NewStringType::kNormal,                \
41
            sizeof(id##_name)).ToLocalChecked();                              \
42
    auto value =                                                              \
43
        String::NewExternalOneByte(                                           \
44
            env->isolate(), &id##_external_data).ToLocalChecked();            \
45
    CHECK(target->Set(context, key, value).FromJust());                       \
46
  } while (0);
47











































763000
  NODE_NATIVES_MAP(V)
48
#undef V
49
1750
}
50
51

5271
}  // namespace node