Skip to content

Commit 37b411a

Browse files
gahaasnodejs-github-bot
authored andcommitted
test: add type tags to uses of v8::External
1 parent 987b6ce commit 37b411a

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

test/addons/async-resource/binding.cc

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,22 @@ void CreateAsyncResource(const FunctionCallbackInfo<Value>& args) {
3939
r = new AsyncResource(isolate, args[0].As<Object>(), "foobär");
4040
}
4141

42-
args.GetReturnValue().Set(
43-
External::New(isolate, static_cast<void*>(r)));
42+
args.GetReturnValue().Set(External::New(
43+
isolate, static_cast<void*>(r), v8::kExternalPointerTypeTagDefault));
4444
}
4545

4646
void DestroyAsyncResource(const FunctionCallbackInfo<Value>& args) {
4747
assert(args[0]->IsExternal());
48-
auto r = static_cast<AsyncResource*>(args[0].As<External>()->Value());
48+
auto r = static_cast<AsyncResource*>(
49+
args[0].As<External>()->Value(v8::kExternalPointerTypeTagDefault));
4950
delete r;
5051
}
5152

5253
void CallViaFunction(const FunctionCallbackInfo<Value>& args) {
5354
Isolate* isolate = args.GetIsolate();
5455
assert(args[0]->IsExternal());
55-
auto r = static_cast<AsyncResource*>(args[0].As<External>()->Value());
56+
auto r = static_cast<AsyncResource*>(
57+
args[0].As<External>()->Value(v8::kExternalPointerTypeTagDefault));
5658

5759
Local<String> name =
5860
String::NewFromUtf8(isolate, "methöd").ToLocalChecked();
@@ -69,7 +71,8 @@ void CallViaFunction(const FunctionCallbackInfo<Value>& args) {
6971
void CallViaString(const FunctionCallbackInfo<Value>& args) {
7072
Isolate* isolate = args.GetIsolate();
7173
assert(args[0]->IsExternal());
72-
auto r = static_cast<AsyncResource*>(args[0].As<External>()->Value());
74+
auto r = static_cast<AsyncResource*>(
75+
args[0].As<External>()->Value(v8::kExternalPointerTypeTagDefault));
7376

7477
Local<String> name =
7578
String::NewFromUtf8(isolate, "methöd").ToLocalChecked();
@@ -82,7 +85,8 @@ void CallViaString(const FunctionCallbackInfo<Value>& args) {
8285
void CallViaUtf8Name(const FunctionCallbackInfo<Value>& args) {
8386
Isolate* isolate = args.GetIsolate();
8487
assert(args[0]->IsExternal());
85-
auto r = static_cast<AsyncResource*>(args[0].As<External>()->Value());
88+
auto r = static_cast<AsyncResource*>(
89+
args[0].As<External>()->Value(v8::kExternalPointerTypeTagDefault));
8690

8791
Local<Value> arg = Integer::New(isolate, 42);
8892
MaybeLocal<Value> ret = r->MakeCallback("methöd", 1, &arg);
@@ -91,19 +95,22 @@ void CallViaUtf8Name(const FunctionCallbackInfo<Value>& args) {
9195

9296
void GetAsyncId(const FunctionCallbackInfo<Value>& args) {
9397
assert(args[0]->IsExternal());
94-
auto r = static_cast<AsyncResource*>(args[0].As<External>()->Value());
98+
auto r = static_cast<AsyncResource*>(
99+
args[0].As<External>()->Value(v8::kExternalPointerTypeTagDefault));
95100
args.GetReturnValue().Set(r->get_async_id());
96101
}
97102

98103
void GetTriggerAsyncId(const FunctionCallbackInfo<Value>& args) {
99104
assert(args[0]->IsExternal());
100-
auto r = static_cast<AsyncResource*>(args[0].As<External>()->Value());
105+
auto r = static_cast<AsyncResource*>(
106+
args[0].As<External>()->Value(v8::kExternalPointerTypeTagDefault));
101107
args.GetReturnValue().Set(r->get_trigger_async_id());
102108
}
103109

104110
void GetResource(const FunctionCallbackInfo<Value>& args) {
105111
assert(args[0]->IsExternal());
106-
auto r = static_cast<AsyncResource*>(args[0].As<External>()->Value());
112+
auto r = static_cast<AsyncResource*>(
113+
args[0].As<External>()->Value(v8::kExternalPointerTypeTagDefault));
107114
args.GetReturnValue().Set(r->get_resource());
108115
}
109116

0 commit comments

Comments
 (0)