summaryrefslogtreecommitdiff
path: root/src/udp_wrap.cc
diff options
context:
space:
mode:
authorTrevor Norris <trev.norris@gmail.com>2014-12-09 05:29:47 +0100
committerBert Belder <bertbelder@gmail.com>2014-12-09 17:57:15 +0100
commit819690fd983d61f90cdf05714a30782fe3b553cd (patch)
treed4dad55e559776cb72e7e79fb55586393e396a21 /src/udp_wrap.cc
parent8f41db6104deca82d74f55501a7f2689357fb45d (diff)
downloadandroid-node-v8-819690fd983d61f90cdf05714a30782fe3b553cd.tar.gz
android-node-v8-819690fd983d61f90cdf05714a30782fe3b553cd.tar.bz2
android-node-v8-819690fd983d61f90cdf05714a30782fe3b553cd.zip
src: all wraps now use actual FunctionTemplate
Instead of simply creating a new v8::Object to contain the connection information, instantiate a new instance of a FunctionTemplate. This will allow future improvements for debugging and performance probes. Additionally, the "provider" argument in the ReqWrap constructor is no longer optional. PR-URL: https://github.com/joyent/node/pull/8110 Signed-off-by: Trevor Norris <trev.norris@gmail.com> Reviewed-by: Fedor Indutny <fedor@indutny.com> Reviewed-by: Alexis Campailla <alexis@janeasystems.com> Reviewed-by: Julien Gilli <julien.gilli@joyent.com>
Diffstat (limited to 'src/udp_wrap.cc')
-rw-r--r--src/udp_wrap.cc16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc
index fa047eccc9..9fbf391207 100644
--- a/src/udp_wrap.cc
+++ b/src/udp_wrap.cc
@@ -62,8 +62,9 @@ class SendWrap : public ReqWrap<uv_udp_send_t> {
SendWrap::SendWrap(Environment* env,
Local<Object> req_wrap_obj,
bool have_callback)
- : ReqWrap<uv_udp_send_t>(env, req_wrap_obj),
+ : ReqWrap(env, req_wrap_obj, AsyncWrap::PROVIDER_UDPWRAP),
have_callback_(have_callback) {
+ Wrap<SendWrap>(req_wrap_obj, this);
}
@@ -72,6 +73,11 @@ inline bool SendWrap::have_callback() const {
}
+static void NewSendWrap(const FunctionCallbackInfo<Value>& args) {
+ CHECK(args.IsConstructCall());
+}
+
+
UDPWrap::UDPWrap(Environment* env, Handle<Object> object)
: HandleWrap(env,
object,
@@ -120,6 +126,14 @@ void UDPWrap::Initialize(Handle<Object> target,
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "UDP"), t->GetFunction());
env->set_udp_constructor_function(t->GetFunction());
+
+ // Create FunctionTemplate for SendWrap
+ Local<FunctionTemplate> swt =
+ FunctionTemplate::New(env->isolate(), NewSendWrap);
+ swt->InstanceTemplate()->SetInternalFieldCount(1);
+ swt->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "SendWrap"));
+ target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "SendWrap"),
+ swt->GetFunction());
}