@@ -8,8 +8,10 @@ namespace util {
8
8
using v8::ALL_PROPERTIES;
9
9
using v8::Array;
10
10
using v8::ArrayBufferView;
11
+ using v8::BigInt;
11
12
using v8::Boolean ;
12
13
using v8::Context;
14
+ using v8::External;
13
15
using v8::FunctionCallbackInfo;
14
16
using v8::FunctionTemplate;
15
17
using v8::Global;
@@ -18,6 +20,7 @@ using v8::Integer;
18
20
using v8::Isolate;
19
21
using v8::KeyCollectionMode;
20
22
using v8::Local;
23
+ using v8::MaybeLocal;
21
24
using v8::Object;
22
25
using v8::ONLY_CONFIGURABLE;
23
26
using v8::ONLY_ENUMERABLE;
@@ -67,6 +70,18 @@ static void GetConstructorName(
67
70
args.GetReturnValue ().Set (name);
68
71
}
69
72
73
+ static void GetExternalValue (
74
+ const FunctionCallbackInfo<Value>& args) {
75
+ CHECK (args[0 ]->IsExternal ());
76
+ Isolate* isolate = args.GetIsolate ();
77
+ Local<External> external = args[0 ].As <External>();
78
+
79
+ void * ptr = external->Value ();
80
+ uint64_t value = reinterpret_cast <uint64_t >(ptr);
81
+ Local<BigInt> ret = BigInt::NewFromUnsigned (isolate, value);
82
+ args.GetReturnValue ().Set (ret);
83
+ }
84
+
70
85
static void GetPromiseDetails (const FunctionCallbackInfo<Value>& args) {
71
86
// Return undefined if it's not a Promise.
72
87
if (!args[0 ]->IsPromise ())
@@ -296,6 +311,7 @@ void Initialize(Local<Object> target,
296
311
env->SetMethodNoSideEffect (target, " getOwnNonIndexProperties" ,
297
312
GetOwnNonIndexProperties);
298
313
env->SetMethodNoSideEffect (target, " getConstructorName" , GetConstructorName);
314
+ env->SetMethodNoSideEffect (target, " getExternalValue" , GetExternalValue);
299
315
env->SetMethod (target, " sleep" , Sleep);
300
316
301
317
env->SetMethod (target, " arrayBufferViewHasBuffer" , ArrayBufferViewHasBuffer);
0 commit comments