MCPcopy Index your code
hub / github.com/nodejs/node-addon-api / Test

Method Test

test/objectwrap.cc:31–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29class Test : public Napi::ObjectWrap<Test> {
30 public:
31 Test(const Napi::CallbackInfo& info) : Napi::ObjectWrap<Test>(info) {
32 if (info.Length() > 0) {
33 finalizeCb_ = Napi::Persistent(info[0].As<Napi::Function>());
34 }
35 // Create an own instance property.
36 info.This().As<Napi::Object>().DefineProperty(
37 Napi::PropertyDescriptor::Accessor(info.Env(),
38 info.This().As<Napi::Object>(),
39 "ownProperty",
40 OwnPropertyGetter,
41 napi_enumerable,
42 this));
43
44 // Create an own instance property with a templated function.
45 info.This().As<Napi::Object>().DefineProperty(
46 Napi::PropertyDescriptor::Accessor<OwnPropertyGetter>(
47 "ownPropertyT", napi_enumerable, this));
48
49 bufref_ = Napi::Persistent(Napi::Buffer<uint8_t>::New(
50 Env(),
51 static_cast<uint8_t*>(malloc(1)),
52 1,
53 [](Napi::Env, uint8_t* bufaddr) { free(bufaddr); }));
54 }
55
56 static Napi::Value OwnPropertyGetter(const Napi::CallbackInfo& info) {
57 return static_cast<Test*>(info.Data())->Getter(info);

Callers

nothing calls this directly

Calls 6

PersistentFunction · 0.85
EnvClass · 0.85
LengthMethod · 0.80
DefinePropertyMethod · 0.80
ThisMethod · 0.80
EnvMethod · 0.80

Tested by

no test coverage detected