Skip to content

Commit abe9052

Browse files
joyeecheungRafaelGSS
authored andcommitted
src: register udp_wrap external references
PR-URL: #50943 Refs: #50924 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 84e2f51 commit abe9052

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

src/node_external_reference.h

+1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ class ExternalReferenceRegistry {
115115
V(task_queue) \
116116
V(tcp_wrap) \
117117
V(tty_wrap) \
118+
V(udp_wrap) \
118119
V(url) \
119120
V(util) \
120121
V(pipe_wrap) \

src/udp_wrap.cc

+38-1
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@
2121

2222
#include "udp_wrap.h"
2323
#include "env-inl.h"
24+
#include "handle_wrap.h"
2425
#include "node_buffer.h"
2526
#include "node_errors.h"
27+
#include "node_external_reference.h"
2628
#include "node_sockaddr-inl.h"
27-
#include "handle_wrap.h"
2829
#include "req_wrap-inl.h"
2930
#include "util-inl.h"
3031

@@ -133,6 +134,12 @@ void UDPWrapBase::AddMethods(Environment* env, Local<FunctionTemplate> t) {
133134
SetProtoMethod(env->isolate(), t, "recvStop", RecvStop);
134135
}
135136

137+
void UDPWrapBase::RegisterExternalReferences(
138+
ExternalReferenceRegistry* registry) {
139+
registry->Register(RecvStart);
140+
registry->Register(RecvStop);
141+
}
142+
136143
UDPWrap::UDPWrap(Environment* env, Local<Object> object)
137144
: HandleWrap(env,
138145
object,
@@ -229,6 +236,34 @@ void UDPWrap::Initialize(Local<Object> target,
229236
constants).Check();
230237
}
231238

239+
void UDPWrap::RegisterExternalReferences(ExternalReferenceRegistry* registry) {
240+
UDPWrapBase::RegisterExternalReferences(registry);
241+
registry->Register(New);
242+
registry->Register(GetFD);
243+
244+
registry->Register(Open);
245+
registry->Register(Bind);
246+
registry->Register(Connect);
247+
registry->Register(Send);
248+
registry->Register(Bind6);
249+
registry->Register(Connect6);
250+
registry->Register(Send6);
251+
registry->Register(Disconnect);
252+
registry->Register(GetSockOrPeerName<UDPWrap, uv_udp_getpeername>);
253+
registry->Register(GetSockOrPeerName<UDPWrap, uv_udp_getsockname>);
254+
registry->Register(AddMembership);
255+
registry->Register(DropMembership);
256+
registry->Register(AddSourceSpecificMembership);
257+
registry->Register(DropSourceSpecificMembership);
258+
registry->Register(SetMulticastInterface);
259+
registry->Register(SetLibuvInt32<uv_udp_set_multicast_ttl>);
260+
registry->Register(SetLibuvInt32<uv_udp_set_multicast_loop>);
261+
registry->Register(SetLibuvInt32<uv_udp_set_broadcast>);
262+
registry->Register(SetLibuvInt32<uv_udp_set_ttl>);
263+
registry->Register(BufferSize);
264+
registry->Register(GetSendQueueSize);
265+
registry->Register(GetSendQueueCount);
266+
}
232267

233268
void UDPWrap::New(const FunctionCallbackInfo<Value>& args) {
234269
CHECK(args.IsConstructCall());
@@ -807,3 +842,5 @@ void UDPWrap::GetSendQueueCount(const FunctionCallbackInfo<Value>& args) {
807842
} // namespace node
808843

809844
NODE_BINDING_CONTEXT_AWARE_INTERNAL(udp_wrap, node::UDPWrap::Initialize)
845+
NODE_BINDING_EXTERNAL_REFERENCE(udp_wrap,
846+
node::UDPWrap::RegisterExternalReferences)

src/udp_wrap.h

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
namespace node {
3434

35+
class ExternalReferenceRegistry;
3536
class UDPWrapBase;
3637

3738
// A listener that can be attached to an `UDPWrapBase` object and generally
@@ -110,6 +111,7 @@ class UDPWrapBase {
110111
static void RecvStart(const v8::FunctionCallbackInfo<v8::Value>& args);
111112
static void RecvStop(const v8::FunctionCallbackInfo<v8::Value>& args);
112113
static void AddMethods(Environment* env, v8::Local<v8::FunctionTemplate> t);
114+
static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
113115

114116
private:
115117
UDPListener* listener_ = nullptr;
@@ -126,6 +128,7 @@ class UDPWrap final : public HandleWrap,
126128
v8::Local<v8::Value> unused,
127129
v8::Local<v8::Context> context,
128130
void* priv);
131+
static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
129132
static void GetFD(const v8::FunctionCallbackInfo<v8::Value>& args);
130133
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
131134
static void Open(const v8::FunctionCallbackInfo<v8::Value>& args);

0 commit comments

Comments
 (0)