@@ -255,6 +255,13 @@ void WeakReference::Get(const FunctionCallbackInfo<Value>& args) {
255
255
args.GetReturnValue ().Set (weak_ref->target_ .Get (isolate));
256
256
}
257
257
258
+ void WeakReference::GetRef (const FunctionCallbackInfo<Value>& args) {
259
+ WeakReference* weak_ref = Unwrap<WeakReference>(args.Holder ());
260
+ Isolate* isolate = args.GetIsolate ();
261
+ args.GetReturnValue ().Set (
262
+ v8::Number::New (isolate, weak_ref->reference_count_ ));
263
+ }
264
+
258
265
void WeakReference::IncRef (const FunctionCallbackInfo<Value>& args) {
259
266
WeakReference* weak_ref = Unwrap<WeakReference>(args.Holder ());
260
267
weak_ref->reference_count_ ++;
@@ -350,6 +357,7 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
350
357
registry->Register (ArrayBufferViewHasBuffer);
351
358
registry->Register (WeakReference::New);
352
359
registry->Register (WeakReference::Get);
360
+ registry->Register (WeakReference::GetRef);
353
361
registry->Register (WeakReference::IncRef);
354
362
registry->Register (WeakReference::DecRef);
355
363
registry->Register (GuessHandleType);
@@ -438,6 +446,7 @@ void Initialize(Local<Object> target,
438
446
WeakReference::kInternalFieldCount );
439
447
weak_ref->Inherit (BaseObject::GetConstructorTemplate (env));
440
448
SetProtoMethod (isolate, weak_ref, " get" , WeakReference::Get);
449
+ SetProtoMethod (isolate, weak_ref, " getRef" , WeakReference::GetRef);
441
450
SetProtoMethod (isolate, weak_ref, " incRef" , WeakReference::IncRef);
442
451
SetProtoMethod (isolate, weak_ref, " decRef" , WeakReference::DecRef);
443
452
SetConstructorFunction (context, target, " WeakReference" , weak_ref);
0 commit comments