@@ -294,6 +294,13 @@ void WeakReference::Get(const FunctionCallbackInfo<Value>& args) {
294
294
args.GetReturnValue ().Set (weak_ref->target_ .Get (isolate));
295
295
}
296
296
297
+ void WeakReference::GetRef (const FunctionCallbackInfo<Value>& args) {
298
+ WeakReference* weak_ref = Unwrap<WeakReference>(args.Holder ());
299
+ Isolate* isolate = args.GetIsolate ();
300
+ args.GetReturnValue ().Set (
301
+ v8::Number::New (isolate, weak_ref->reference_count_ ));
302
+ }
303
+
297
304
void WeakReference::IncRef (const FunctionCallbackInfo<Value>& args) {
298
305
WeakReference* weak_ref = Unwrap<WeakReference>(args.Holder ());
299
306
weak_ref->reference_count_ ++;
@@ -391,6 +398,7 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
391
398
registry->Register (ArrayBufferViewHasBuffer);
392
399
registry->Register (WeakReference::New);
393
400
registry->Register (WeakReference::Get);
401
+ registry->Register (WeakReference::GetRef);
394
402
registry->Register (WeakReference::IncRef);
395
403
registry->Register (WeakReference::DecRef);
396
404
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