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

Function CreateFunctionReferenceUsingNewVec

test/function_reference.cc:152–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

150}
151
152Value CreateFunctionReferenceUsingNewVec(const Napi::CallbackInfo& info) {
153 Napi::Function func = ObjectWrap<FuncRefObject>::DefineClass(
154 info.Env(),
155 "MyObject",
156 {ObjectWrap<FuncRefObject>::InstanceMethod("getValue",
157 &FuncRefObject::GetValue)});
158 Napi::FunctionReference* constructor = new Napi::FunctionReference();
159 *constructor = Napi::Persistent(func);
160 std::vector<napi_value> newVec;
161 newVec.push_back(info[0]);
162
163 return MaybeUnwrapOr(constructor->New(newVec), Object());
164}
165
166Value Call(const CallbackInfo& info) {
167 EscapableHandleScope scope(info.Env());

Callers

nothing calls this directly

Calls 5

PersistentFunction · 0.85
MaybeUnwrapOrFunction · 0.85
ObjectClass · 0.85
EnvMethod · 0.80
NewMethod · 0.80

Tested by

no test coverage detected