Browse Source

src: fixup strings, reduce duplication

PR-URL: https://github.com/nodejs/node/pull/14937
Reviewed-By: Anna Henningsen <anna@addaleax.net>
canary-base
James M Snell 8 years ago
parent
commit
771a03dfe3
  1. 32
      src/cares_wrap.cc
  2. 8
      src/js_stream.cc
  3. 2
      src/node_config.cc
  4. 7
      src/node_crypto.cc
  5. 7
      src/node_file.cc
  6. 3
      src/node_http2.cc
  7. 12
      src/node_serdes.cc
  8. 8
      src/node_stat_watcher.cc
  9. 6
      src/node_zlib.cc
  10. 13
      src/pipe_wrap.cc
  11. 7
      src/process_wrap.cc
  12. 8
      src/signal_wrap.cc
  13. 14
      src/stream_wrap.cc
  14. 14
      src/tcp_wrap.cc
  15. 7
      src/timer_wrap.cc
  16. 9
      src/tls_wrap.cc
  17. 7
      src/tty_wrap.cc
  18. 13
      src/udp_wrap.cc

32
src/cares_wrap.cc

@ -2190,28 +2190,28 @@ void Initialize(Local<Object> target,
FunctionTemplate::New(env->isolate(), is_construct_call_callback);
aiw->InstanceTemplate()->SetInternalFieldCount(1);
env->SetProtoMethod(aiw, "getAsyncId", AsyncWrap::GetAsyncId);
aiw->SetClassName(
FIXED_ONE_BYTE_STRING(env->isolate(), "GetAddrInfoReqWrap"));
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "GetAddrInfoReqWrap"),
aiw->GetFunction());
Local<String> addrInfoWrapString =
FIXED_ONE_BYTE_STRING(env->isolate(), "GetAddrInfoReqWrap");
aiw->SetClassName(addrInfoWrapString);
target->Set(addrInfoWrapString, aiw->GetFunction());
Local<FunctionTemplate> niw =
FunctionTemplate::New(env->isolate(), is_construct_call_callback);
niw->InstanceTemplate()->SetInternalFieldCount(1);
env->SetProtoMethod(niw, "getAsyncId", AsyncWrap::GetAsyncId);
niw->SetClassName(
FIXED_ONE_BYTE_STRING(env->isolate(), "GetNameInfoReqWrap"));
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "GetNameInfoReqWrap"),
niw->GetFunction());
Local<String> nameInfoWrapString =
FIXED_ONE_BYTE_STRING(env->isolate(), "GetNameInfoReqWrap");
niw->SetClassName(nameInfoWrapString);
target->Set(nameInfoWrapString, niw->GetFunction());
Local<FunctionTemplate> qrw =
FunctionTemplate::New(env->isolate(), is_construct_call_callback);
qrw->InstanceTemplate()->SetInternalFieldCount(1);
env->SetProtoMethod(qrw, "getAsyncId", AsyncWrap::GetAsyncId);
qrw->SetClassName(
FIXED_ONE_BYTE_STRING(env->isolate(), "QueryReqWrap"));
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "QueryReqWrap"),
qrw->GetFunction());
Local<String> queryWrapString =
FIXED_ONE_BYTE_STRING(env->isolate(), "QueryReqWrap");
qrw->SetClassName(queryWrapString);
target->Set(queryWrapString, qrw->GetFunction());
Local<FunctionTemplate> channel_wrap =
env->NewFunctionTemplate(ChannelWrap::New);
@ -2235,10 +2235,10 @@ void Initialize(Local<Object> target,
env->SetProtoMethod(channel_wrap, "setServers", SetServers);
env->SetProtoMethod(channel_wrap, "cancel", Cancel);
channel_wrap->SetClassName(
FIXED_ONE_BYTE_STRING(env->isolate(), "ChannelWrap"));
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "ChannelWrap"),
channel_wrap->GetFunction());
Local<String> channelWrapString =
FIXED_ONE_BYTE_STRING(env->isolate(), "ChannelWrap");
channel_wrap->SetClassName(channelWrapString);
target->Set(channelWrapString, channel_wrap->GetFunction());
}
} // anonymous namespace

8
src/js_stream.cc

@ -18,6 +18,7 @@ using v8::HandleScope;
using v8::Local;
using v8::MaybeLocal;
using v8::Object;
using v8::String;
using v8::Value;
@ -212,7 +213,9 @@ void JSStream::Initialize(Local<Object> target,
Environment* env = Environment::GetCurrent(context);
Local<FunctionTemplate> t = env->NewFunctionTemplate(New);
t->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "JSStream"));
Local<String> jsStreamString =
FIXED_ONE_BYTE_STRING(env->isolate(), "JSStream");
t->SetClassName(jsStreamString);
t->InstanceTemplate()->SetInternalFieldCount(1);
env->SetProtoMethod(t, "getAsyncId", AsyncWrap::GetAsyncId);
@ -226,8 +229,7 @@ void JSStream::Initialize(Local<Object> target,
env->SetProtoMethod(t, "emitEOF", EmitEOF);
StreamBase::AddMethods<JSStream>(env, t, StreamBase::kFlagHasWritev);
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "JSStream"),
t->GetFunction());
target->Set(jsStreamString, t->GetFunction());
env->set_jsstream_constructor_template(t);
}

2
src/node_config.cc

@ -105,7 +105,7 @@ static void InitConfig(Local<Object> target,
debugOptions->DefineOwnProperty(
context,
FIXED_ONE_BYTE_STRING(isolate, "port"),
env->port_string(),
Integer::New(isolate, debug_options.port()),
ReadOnly).FromJust();

7
src/node_crypto.cc

@ -312,7 +312,9 @@ bool EntropySource(unsigned char* buffer, size_t length) {
void SecureContext::Initialize(Environment* env, Local<Object> target) {
Local<FunctionTemplate> t = env->NewFunctionTemplate(SecureContext::New);
t->InstanceTemplate()->SetInternalFieldCount(1);
t->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "SecureContext"));
Local<String> secureContextString =
FIXED_ONE_BYTE_STRING(env->isolate(), "SecureContext");
t->SetClassName(secureContextString);
env->SetProtoMethod(t, "init", SecureContext::Init);
env->SetProtoMethod(t, "setKey", SecureContext::SetKey);
@ -359,8 +361,7 @@ void SecureContext::Initialize(Environment* env, Local<Object> target) {
static_cast<PropertyAttribute>(ReadOnly | DontDelete),
AccessorSignature::New(env->isolate(), t));
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "SecureContext"),
t->GetFunction());
target->Set(secureContextString, t->GetFunction());
env->set_secure_context_constructor_template(t);
}

7
src/node_file.cc

@ -1484,9 +1484,10 @@ void InitFs(Local<Object> target,
FunctionTemplate::New(env->isolate(), NewFSReqWrap);
fst->InstanceTemplate()->SetInternalFieldCount(1);
env->SetProtoMethod(fst, "getAsyncId", AsyncWrap::GetAsyncId);
fst->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "FSReqWrap"));
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "FSReqWrap"),
fst->GetFunction());
Local<String> wrapString =
FIXED_ONE_BYTE_STRING(env->isolate(), "FSReqWrap");
fst->SetClassName(wrapString);
target->Set(wrapString, fst->GetFunction());
}
} // end namespace node

3
src/node_http2.cc

@ -1206,8 +1206,7 @@ void Initialize(Local<Object> target,
env->SetMethod(target, "nghttp2ErrorString", HttpErrorString);
Local<String> http2SessionClassName =
String::NewFromUtf8(isolate, "Http2Session",
v8::NewStringType::kInternalized).ToLocalChecked();
FIXED_ONE_BYTE_STRING(isolate, "Http2Session");
Local<FunctionTemplate> session =
env->NewFunctionTemplate(Http2Session::New);

12
src/node_serdes.cc

@ -451,9 +451,11 @@ void InitializeSerdesBindings(Local<Object> target,
"_setTreatArrayBufferViewsAsHostObjects",
SerializerContext::SetTreatArrayBufferViewsAsHostObjects);
ser->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "Serializer"));
Local<String> serializerString =
FIXED_ONE_BYTE_STRING(env->isolate(), "Serializer");
ser->SetClassName(serializerString);
target->Set(env->context(),
FIXED_ONE_BYTE_STRING(env->isolate(), "Serializer"),
serializerString,
ser->GetFunction(env->context()).ToLocalChecked()).FromJust();
Local<FunctionTemplate> des =
@ -474,9 +476,11 @@ void InitializeSerdesBindings(Local<Object> target,
env->SetProtoMethod(des, "readDouble", DeserializerContext::ReadDouble);
env->SetProtoMethod(des, "_readRawBytes", DeserializerContext::ReadRawBytes);
des->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "Deserializer"));
Local<String> deserializerString =
FIXED_ONE_BYTE_STRING(env->isolate(), "Deserializer");
des->SetClassName(deserializerString);
target->Set(env->context(),
FIXED_ONE_BYTE_STRING(env->isolate(), "Deserializer"),
deserializerString,
des->GetFunction(env->context()).ToLocalChecked()).FromJust();
}

8
src/node_stat_watcher.cc

@ -39,6 +39,7 @@ using v8::HandleScope;
using v8::Integer;
using v8::Local;
using v8::Object;
using v8::String;
using v8::Value;
@ -47,14 +48,15 @@ void StatWatcher::Initialize(Environment* env, Local<Object> target) {
Local<FunctionTemplate> t = env->NewFunctionTemplate(StatWatcher::New);
t->InstanceTemplate()->SetInternalFieldCount(1);
t->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "StatWatcher"));
Local<String> statWatcherString =
FIXED_ONE_BYTE_STRING(env->isolate(), "StatWatcher");
t->SetClassName(statWatcherString);
env->SetProtoMethod(t, "getAsyncId", AsyncWrap::GetAsyncId);
env->SetProtoMethod(t, "start", StatWatcher::Start);
env->SetProtoMethod(t, "stop", StatWatcher::Stop);
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "StatWatcher"),
t->GetFunction());
target->Set(statWatcherString, t->GetFunction());
}

6
src/node_zlib.cc

@ -50,6 +50,7 @@ using v8::Local;
using v8::Number;
using v8::Object;
using v8::Persistent;
using v8::String;
using v8::Uint32Array;
using v8::Value;
@ -693,8 +694,9 @@ void InitZlib(Local<Object> target,
env->SetProtoMethod(z, "params", ZCtx::Params);
env->SetProtoMethod(z, "reset", ZCtx::Reset);
z->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "Zlib"));
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "Zlib"), z->GetFunction());
Local<String> zlibString = FIXED_ONE_BYTE_STRING(env->isolate(), "Zlib");
z->SetClassName(zlibString);
target->Set(zlibString, z->GetFunction());
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "ZLIB_VERSION"),
FIXED_ONE_BYTE_STRING(env->isolate(), ZLIB_VERSION));

13
src/pipe_wrap.cc

@ -44,6 +44,7 @@ using v8::FunctionTemplate;
using v8::HandleScope;
using v8::Local;
using v8::Object;
using v8::String;
using v8::Value;
using AsyncHooks = Environment::AsyncHooks;
@ -67,7 +68,8 @@ void PipeWrap::Initialize(Local<Object> target,
Environment* env = Environment::GetCurrent(context);
Local<FunctionTemplate> t = env->NewFunctionTemplate(New);
t->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "Pipe"));
Local<String> pipeString = FIXED_ONE_BYTE_STRING(env->isolate(), "Pipe");
t->SetClassName(pipeString);
t->InstanceTemplate()->SetInternalFieldCount(1);
env->SetProtoMethod(t, "getAsyncId", AsyncWrap::GetAsyncId);
@ -92,7 +94,7 @@ void PipeWrap::Initialize(Local<Object> target,
env->SetProtoMethod(t, "setPendingInstances", SetPendingInstances);
#endif
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "Pipe"), t->GetFunction());
target->Set(pipeString, t->GetFunction());
env->set_pipe_constructor_template(t);
// Create FunctionTemplate for PipeConnectWrap.
@ -103,9 +105,10 @@ void PipeWrap::Initialize(Local<Object> target,
auto cwt = FunctionTemplate::New(env->isolate(), constructor);
cwt->InstanceTemplate()->SetInternalFieldCount(1);
env->SetProtoMethod(cwt, "getAsyncId", AsyncWrap::GetAsyncId);
cwt->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "PipeConnectWrap"));
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "PipeConnectWrap"),
cwt->GetFunction());
Local<String> wrapString =
FIXED_ONE_BYTE_STRING(env->isolate(), "PipeConnectWrap");
cwt->SetClassName(wrapString);
target->Set(wrapString, cwt->GetFunction());
}

7
src/process_wrap.cc

@ -53,7 +53,9 @@ class ProcessWrap : public HandleWrap {
Environment* env = Environment::GetCurrent(context);
Local<FunctionTemplate> constructor = env->NewFunctionTemplate(New);
constructor->InstanceTemplate()->SetInternalFieldCount(1);
constructor->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "Process"));
Local<String> processString =
FIXED_ONE_BYTE_STRING(env->isolate(), "Process");
constructor->SetClassName(processString);
env->SetProtoMethod(constructor, "getAsyncId", AsyncWrap::GetAsyncId);
@ -66,8 +68,7 @@ class ProcessWrap : public HandleWrap {
env->SetProtoMethod(constructor, "unref", HandleWrap::Unref);
env->SetProtoMethod(constructor, "hasRef", HandleWrap::HasRef);
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "Process"),
constructor->GetFunction());
target->Set(processString, constructor->GetFunction());
}
size_t self_size() const override { return sizeof(*this); }

8
src/signal_wrap.cc

@ -37,6 +37,7 @@ using v8::HandleScope;
using v8::Integer;
using v8::Local;
using v8::Object;
using v8::String;
using v8::Value;
namespace {
@ -49,7 +50,9 @@ class SignalWrap : public HandleWrap {
Environment* env = Environment::GetCurrent(context);
Local<FunctionTemplate> constructor = env->NewFunctionTemplate(New);
constructor->InstanceTemplate()->SetInternalFieldCount(1);
constructor->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "Signal"));
Local<String> signalString =
FIXED_ONE_BYTE_STRING(env->isolate(), "Signal");
constructor->SetClassName(signalString);
env->SetProtoMethod(constructor, "getAsyncId", AsyncWrap::GetAsyncId);
env->SetProtoMethod(constructor, "close", HandleWrap::Close);
@ -59,8 +62,7 @@ class SignalWrap : public HandleWrap {
env->SetProtoMethod(constructor, "start", Start);
env->SetProtoMethod(constructor, "stop", Stop);
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "Signal"),
constructor->GetFunction());
target->Set(signalString, constructor->GetFunction());
}
size_t self_size() const override { return sizeof(*this); }

14
src/stream_wrap.cc

@ -67,18 +67,20 @@ void StreamWrap::Initialize(Local<Object> target,
Local<FunctionTemplate> sw =
FunctionTemplate::New(env->isolate(), is_construct_call_callback);
sw->InstanceTemplate()->SetInternalFieldCount(1);
sw->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "ShutdownWrap"));
Local<String> wrapString =
FIXED_ONE_BYTE_STRING(env->isolate(), "ShutdownWrap");
sw->SetClassName(wrapString);
env->SetProtoMethod(sw, "getAsyncId", AsyncWrap::GetAsyncId);
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "ShutdownWrap"),
sw->GetFunction());
target->Set(wrapString, sw->GetFunction());
Local<FunctionTemplate> ww =
FunctionTemplate::New(env->isolate(), is_construct_call_callback);
ww->InstanceTemplate()->SetInternalFieldCount(1);
ww->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "WriteWrap"));
Local<String> writeWrapString =
FIXED_ONE_BYTE_STRING(env->isolate(), "WriteWrap");
ww->SetClassName(writeWrapString);
env->SetProtoMethod(ww, "getAsyncId", AsyncWrap::GetAsyncId);
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "WriteWrap"),
ww->GetFunction());
target->Set(writeWrapString, ww->GetFunction());
env->set_write_wrap_constructor_function(ww->GetFunction());
}

14
src/tcp_wrap.cc

@ -71,11 +71,12 @@ void TCPWrap::Initialize(Local<Object> target,
Environment* env = Environment::GetCurrent(context);
Local<FunctionTemplate> t = env->NewFunctionTemplate(New);
t->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "TCP"));
Local<String> tcpString = FIXED_ONE_BYTE_STRING(env->isolate(), "TCP");
t->SetClassName(tcpString);
t->InstanceTemplate()->SetInternalFieldCount(1);
// Init properties
t->InstanceTemplate()->Set(String::NewFromUtf8(env->isolate(), "reading"),
t->InstanceTemplate()->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "reading"),
Boolean::New(env->isolate(), false));
t->InstanceTemplate()->Set(env->owner_string(), Null(env->isolate()));
t->InstanceTemplate()->Set(env->onread_string(), Null(env->isolate()));
@ -109,7 +110,7 @@ void TCPWrap::Initialize(Local<Object> target,
env->SetProtoMethod(t, "setSimultaneousAccepts", SetSimultaneousAccepts);
#endif
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "TCP"), t->GetFunction());
target->Set(tcpString, t->GetFunction());
env->set_tcp_constructor_template(t);
// Create FunctionTemplate for TCPConnectWrap.
@ -120,9 +121,10 @@ void TCPWrap::Initialize(Local<Object> target,
auto cwt = FunctionTemplate::New(env->isolate(), constructor);
cwt->InstanceTemplate()->SetInternalFieldCount(1);
env->SetProtoMethod(cwt, "getAsyncId", AsyncWrap::GetAsyncId);
cwt->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "TCPConnectWrap"));
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "TCPConnectWrap"),
cwt->GetFunction());
Local<String> wrapString =
FIXED_ONE_BYTE_STRING(env->isolate(), "TCPConnectWrap");
cwt->SetClassName(wrapString);
target->Set(wrapString, cwt->GetFunction());
}

7
src/timer_wrap.cc

@ -39,6 +39,7 @@ using v8::HandleScope;
using v8::Integer;
using v8::Local;
using v8::Object;
using v8::String;
using v8::Value;
const uint32_t kOnTimeout = 0;
@ -50,8 +51,9 @@ class TimerWrap : public HandleWrap {
Local<Context> context) {
Environment* env = Environment::GetCurrent(context);
Local<FunctionTemplate> constructor = env->NewFunctionTemplate(New);
Local<String> timerString = FIXED_ONE_BYTE_STRING(env->isolate(), "Timer");
constructor->InstanceTemplate()->SetInternalFieldCount(1);
constructor->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "Timer"));
constructor->SetClassName(timerString);
constructor->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "kOnTimeout"),
Integer::New(env->isolate(), kOnTimeout));
@ -67,8 +69,7 @@ class TimerWrap : public HandleWrap {
env->SetProtoMethod(constructor, "start", Start);
env->SetProtoMethod(constructor, "stop", Stop);
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "Timer"),
constructor->GetFunction());
target->Set(timerString, constructor->GetFunction());
}
size_t self_size() const override { return sizeof(*this); }

9
src/tls_wrap.cc

@ -938,9 +938,13 @@ void TLSWrap::Initialize(Local<Object> target,
CHECK(args.IsConstructCall());
args.This()->SetAlignedPointerInInternalField(0, nullptr);
};
Local<String> tlsWrapString =
FIXED_ONE_BYTE_STRING(env->isolate(), "TLSWrap");
auto t = env->NewFunctionTemplate(constructor);
t->InstanceTemplate()->SetInternalFieldCount(1);
t->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "TLSWrap"));
t->SetClassName(tlsWrapString);
env->SetProtoMethod(t, "getAsyncId", AsyncWrap::GetAsyncId);
env->SetProtoMethod(t, "asyncReset", AsyncWrap::AsyncReset);
@ -962,8 +966,7 @@ void TLSWrap::Initialize(Local<Object> target,
env->set_tls_wrap_constructor_template(t);
env->set_tls_wrap_constructor_function(t->GetFunction());
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "TLSWrap"),
t->GetFunction());
target->Set(tlsWrapString, t->GetFunction());
}
} // namespace node

7
src/tty_wrap.cc

@ -41,6 +41,7 @@ using v8::FunctionTemplate;
using v8::Integer;
using v8::Local;
using v8::Object;
using v8::String;
using v8::Value;
@ -49,8 +50,10 @@ void TTYWrap::Initialize(Local<Object> target,
Local<Context> context) {
Environment* env = Environment::GetCurrent(context);
Local<String> ttyString = FIXED_ONE_BYTE_STRING(env->isolate(), "TTY");
Local<FunctionTemplate> t = env->NewFunctionTemplate(New);
t->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "TTY"));
t->SetClassName(ttyString);
t->InstanceTemplate()->SetInternalFieldCount(1);
env->SetProtoMethod(t, "getAsyncId", AsyncWrap::GetAsyncId);
@ -68,7 +71,7 @@ void TTYWrap::Initialize(Local<Object> target,
env->SetMethod(target, "isTTY", IsTTY);
env->SetMethod(target, "guessHandleType", GuessHandleType);
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "TTY"), t->GetFunction());
target->Set(ttyString, t->GetFunction());
env->set_tty_constructor_template(t);
}

13
src/udp_wrap.cc

@ -106,7 +106,9 @@ void UDPWrap::Initialize(Local<Object> target,
Local<FunctionTemplate> t = env->NewFunctionTemplate(New);
t->InstanceTemplate()->SetInternalFieldCount(1);
t->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "UDP"));
Local<String> udpString =
FIXED_ONE_BYTE_STRING(env->isolate(), "UDP");
t->SetClassName(udpString);
enum PropertyAttribute attributes =
static_cast<PropertyAttribute>(v8::ReadOnly | v8::DontDelete);
@ -139,7 +141,7 @@ void UDPWrap::Initialize(Local<Object> target,
env->SetProtoMethod(t, "getAsyncId", AsyncWrap::GetAsyncId);
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "UDP"), t->GetFunction());
target->Set(udpString, t->GetFunction());
env->set_udp_constructor_function(t->GetFunction());
// Create FunctionTemplate for SendWrap
@ -147,9 +149,10 @@ void UDPWrap::Initialize(Local<Object> target,
FunctionTemplate::New(env->isolate(), NewSendWrap);
swt->InstanceTemplate()->SetInternalFieldCount(1);
env->SetProtoMethod(swt, "getAsyncId", AsyncWrap::GetAsyncId);
swt->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "SendWrap"));
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "SendWrap"),
swt->GetFunction());
Local<String> sendWrapString =
FIXED_ONE_BYTE_STRING(env->isolate(), "SendWrap");
swt->SetClassName(sendWrapString);
target->Set(sendWrapString, swt->GetFunction());
}

Loading…
Cancel
Save