Skip to content

Commit 8eb7790

Browse files
committedApr 24, 2017
src: replace IsConstructCalls with lambda
I've added a deprecation notice as the functions are public, but not sure if this is correct or the format of the deprecation notice. PR-URL: nodejs#12533 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent cf68280 commit 8eb7790

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed
 

‎src/stream_base.h

-8
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ class ShutdownWrap : public ReqWrap<uv_shutdown_t>,
5353
Wrap(req_wrap_obj, this);
5454
}
5555

56-
static void NewShutdownWrap(const v8::FunctionCallbackInfo<v8::Value>& args) {
57-
CHECK(args.IsConstructCall());
58-
}
59-
6056
static ShutdownWrap* from_req(uv_shutdown_t* req) {
6157
return ContainerOf(&ShutdownWrap::req_, req);
6258
}
@@ -83,10 +79,6 @@ class WriteWrap: public ReqWrap<uv_write_t>,
8379

8480
size_t self_size() const override { return storage_size_; }
8581

86-
static void NewWriteWrap(const v8::FunctionCallbackInfo<v8::Value>& args) {
87-
CHECK(args.IsConstructCall());
88-
}
89-
9082
static WriteWrap* from_req(uv_write_t* req) {
9183
return ContainerOf(&WriteWrap::req_, req);
9284
}

‎src/stream_wrap.cc

+6-2
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,19 @@ void StreamWrap::Initialize(Local<Object> target,
5959
Local<Context> context) {
6060
Environment* env = Environment::GetCurrent(context);
6161

62+
auto is_construct_call_callback =
63+
[](const FunctionCallbackInfo<Value>& args) {
64+
CHECK(args.IsConstructCall());
65+
};
6266
Local<FunctionTemplate> sw =
63-
FunctionTemplate::New(env->isolate(), ShutdownWrap::NewShutdownWrap);
67+
FunctionTemplate::New(env->isolate(), is_construct_call_callback);
6468
sw->InstanceTemplate()->SetInternalFieldCount(1);
6569
sw->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "ShutdownWrap"));
6670
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "ShutdownWrap"),
6771
sw->GetFunction());
6872

6973
Local<FunctionTemplate> ww =
70-
FunctionTemplate::New(env->isolate(), WriteWrap::NewWriteWrap);
74+
FunctionTemplate::New(env->isolate(), is_construct_call_callback);
7175
ww->InstanceTemplate()->SetInternalFieldCount(1);
7276
ww->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "WriteWrap"));
7377
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "WriteWrap"),

0 commit comments

Comments
 (0)
Please sign in to comment.