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

Function wrap

test/cpp/weak2.cpp:26–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24}
25
26v8::Local<v8::String> wrap() {
27 EscapableHandleScope scope;
28 v8::Local<v8::String> lstring = New("result").ToLocalChecked();
29 v8::Local<v8::ObjectTemplate> otpl = New<v8::ObjectTemplate>();
30 otpl->SetInternalFieldCount(1);
31 v8::Local<v8::Object> obj = NewInstance(otpl).ToLocalChecked();
32 SetInternalFieldPointer(obj, 0, new int(42));
33 Persistent<v8::Object> persistent(obj);
34 persistent.SetWeak(
35 static_cast<int*>(0)
36 , weakCallback
37 , WeakCallbackType::kInternalFields);
38 assert(persistent.IsWeak());
39 return scope.Escape(lstring);
40}
41
42NAN_METHOD(Hustle) {
43 async_resource = new AsyncResource("nan:test:weak2");

Callers 1

NAN_METHODFunction · 0.70

Calls 7

SetInternalFieldPointerFunction · 0.85
ToLocalCheckedMethod · 0.80
IsWeakMethod · 0.80
EscapeMethod · 0.80
NewFunction · 0.50
NewInstanceFunction · 0.50
SetWeakMethod · 0.45

Tested by

no test coverage detected