@@ -265,6 +265,13 @@ void WeakReference::Get(const FunctionCallbackInfo<Value>& args) {
265
265
args.GetReturnValue ().Set (weak_ref->target_ .Get (isolate));
266
266
}
267
267
268
+ void WeakReference::GetRef (const FunctionCallbackInfo<Value>& args) {
269
+ WeakReference* weak_ref = Unwrap<WeakReference>(args.Holder ());
270
+ Isolate* isolate = args.GetIsolate ();
271
+ args.GetReturnValue ().Set (
272
+ v8::Number::New (isolate, weak_ref->reference_count_ ));
273
+ }
274
+
268
275
void WeakReference::IncRef (const FunctionCallbackInfo<Value>& args) {
269
276
WeakReference* weak_ref = Unwrap<WeakReference>(args.Holder ());
270
277
weak_ref->reference_count_ ++;
@@ -361,6 +368,7 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
361
368
registry->Register (ArrayBufferViewHasBuffer);
362
369
registry->Register (WeakReference::New);
363
370
registry->Register (WeakReference::Get);
371
+ registry->Register (WeakReference::GetRef);
364
372
registry->Register (WeakReference::IncRef);
365
373
registry->Register (WeakReference::DecRef);
366
374
registry->Register (GuessHandleType);
@@ -464,6 +472,7 @@ void Initialize(Local<Object> target,
464
472
WeakReference::kInternalFieldCount );
465
473
weak_ref->Inherit (BaseObject::GetConstructorTemplate (env));
466
474
SetProtoMethod (isolate, weak_ref, " get" , WeakReference::Get);
475
+ SetProtoMethod (isolate, weak_ref, " getRef" , WeakReference::GetRef);
467
476
SetProtoMethod (isolate, weak_ref, " incRef" , WeakReference::IncRef);
468
477
SetProtoMethod (isolate, weak_ref, " decRef" , WeakReference::DecRef);
469
478
SetConstructorFunction (context, target, " WeakReference" , weak_ref);
0 commit comments