MCPcopy Create free account
hub / github.com/nodejs/nan / NAN_MODULE_INIT

Function NAN_MODULE_INIT

test/cpp/methodswithdata.cpp:165–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

163}
164
165NAN_MODULE_INIT(Init) {
166 SetMethod(target, "testWithData", TestWithData, New("test-value").ToLocalChecked());
167
168 v8::Local<v8::FunctionTemplate> tpl =
169 Nan::New<v8::FunctionTemplate>(SetterGetter::New, New("new-data").ToLocalChecked());
170 settergetter_constructor.Reset(tpl);
171 tpl->SetClassName(Nan::New<v8::String>("SetterGetter").ToLocalChecked());
172 tpl->InstanceTemplate()->SetInternalFieldCount(1);
173 SetPrototypeMethod(
174 tpl,
175 "log",
176 SetterGetter::Log,
177 Nan::New("log-data").ToLocalChecked());
178 v8::Local<v8::ObjectTemplate> itpl = tpl->InstanceTemplate();
179 SetAccessor(
180 itpl
181 , Nan::New("prop1").ToLocalChecked()
182 , SetterGetter::GetProp1
183 , 0
184 , Nan::New("prop1-data").ToLocalChecked());
185 SetAccessor(
186 itpl
187 , Nan::New<v8::String>("prop2").ToLocalChecked()
188 , SetterGetter::GetProp2
189 , SetterGetter::SetProp2
190 , Nan::New("prop2-data").ToLocalChecked()
191 );
192
193 v8::Local<v8::Function> createnew =
194 Nan::GetFunction(
195 Nan::New<v8::FunctionTemplate>(
196 CreateNew, Nan::New("create-data").ToLocalChecked())).ToLocalChecked();
197 Set(target, Nan::New<v8::String>("create").ToLocalChecked(), createnew);
198}
199
200NODE_MODULE(methodswithdata, Init)

Callers

nothing calls this directly

Calls 8

SetMethodFunction · 0.85
SetPrototypeMethodFunction · 0.85
SetAccessorFunction · 0.85
ToLocalCheckedMethod · 0.80
NewFunction · 0.50
GetFunctionFunction · 0.50
SetFunction · 0.50
ResetMethod · 0.45

Tested by

no test coverage detected