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

Function SetCallHandler

nan.h:3045–3064  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3043}
3044
3045inline void SetCallHandler(
3046 v8::Local<v8::FunctionTemplate> tpl
3047 , FunctionCallback callback
3048 , v8::Local<v8::Value> data = v8::Local<v8::Value>()) {
3049 HandleScope scope;
3050
3051 v8::Local<v8::ObjectTemplate> otpl = New<v8::ObjectTemplate>();
3052 otpl->SetInternalFieldCount(imp::kFunctionFieldCount);
3053 v8::Local<v8::Object> obj = NewInstance(otpl).ToLocalChecked();
3054
3055 obj->SetInternalField(
3056 imp::kFunctionIndex
3057 , New<v8::External>(reinterpret_cast<void *>(callback)));
3058
3059 if (!data.IsEmpty()) {
3060 obj->SetInternalField(imp::kDataIndex, data);
3061 }
3062
3063 tpl->SetCallHandler(imp::FunctionCallbackWrapper, obj);
3064}
3065
3066
3067inline void SetCallAsFunctionHandler(

Callers 1

NAN_METHODFunction · 0.85

Calls 3

ToLocalCheckedMethod · 0.80
NewInstanceFunction · 0.70
IsEmptyMethod · 0.45

Tested by

no test coverage detected