| 29 | class 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); |
nothing calls this directly
no test coverage detected