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

Function SetCallAsFunctionHandler

nan.h:3067–3086  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3065
3066
3067inline void SetCallAsFunctionHandler(
3068 v8::Local<v8::ObjectTemplate> tpl,
3069 FunctionCallback callback,
3070 v8::Local<v8::Value> data = v8::Local<v8::Value>()) {
3071 HandleScope scope;
3072
3073 v8::Local<v8::ObjectTemplate> otpl = New<v8::ObjectTemplate>();
3074 otpl->SetInternalFieldCount(imp::kFunctionFieldCount);
3075 v8::Local<v8::Object> obj = NewInstance(otpl).ToLocalChecked();
3076
3077 obj->SetInternalField(
3078 imp::kFunctionIndex
3079 , New<v8::External>(reinterpret_cast<void *>(callback)));
3080
3081 if (!data.IsEmpty()) {
3082 obj->SetInternalField(imp::kDataIndex, data);
3083 }
3084
3085 tpl->SetCallAsFunctionHandler(imp::FunctionCallbackWrapper, obj);
3086}
3087
3088//=== Weak Persistent Handling =================================================
3089

Callers 1

NAN_METHODFunction · 0.85

Calls 3

ToLocalCheckedMethod · 0.80
NewInstanceFunction · 0.70
IsEmptyMethod · 0.45

Tested by

no test coverage detected