From 7bdd05bd66607886d633332e1397550d9b8d9b39 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 13 Feb 2013 16:09:03 +0100 Subject: stream_wrap, udp_wrap: add read-only fd property Expose the file descriptor as a read-only property on the internal handle objects. Intended for debugging purposes, not part of the API proper. The property is always null on Windows. Fixes #4754. --- src/pipe_wrap.cc | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'src/pipe_wrap.cc') diff --git a/src/pipe_wrap.cc b/src/pipe_wrap.cc index 39897af6951..149c4f21269 100644 --- a/src/pipe_wrap.cc +++ b/src/pipe_wrap.cc @@ -28,20 +28,21 @@ namespace node { -using v8::Object; +using v8::Arguments; +using v8::Boolean; +using v8::Context; +using v8::Function; +using v8::FunctionTemplate; using v8::Handle; +using v8::HandleScope; +using v8::Integer; using v8::Local; +using v8::Object; using v8::Persistent; -using v8::Value; -using v8::HandleScope; -using v8::FunctionTemplate; +using v8::PropertyAttribute; using v8::String; -using v8::Function; using v8::TryCatch; -using v8::Context; -using v8::Arguments; -using v8::Integer; -using v8::Boolean; +using v8::Value; Persistent pipeConstructor; @@ -82,6 +83,15 @@ void PipeWrap::Initialize(Handle target) { t->InstanceTemplate()->SetInternalFieldCount(1); + enum PropertyAttribute attributes = + static_cast(v8::ReadOnly | v8::DontDelete); + t->InstanceTemplate()->SetAccessor(String::New("fd"), + StreamWrap::GetFD, + NULL, + Handle(), + v8::DEFAULT, + attributes); + NODE_SET_PROTOTYPE_METHOD(t, "close", HandleWrap::Close); NODE_SET_PROTOTYPE_METHOD(t, "unref", HandleWrap::Unref); NODE_SET_PROTOTYPE_METHOD(t, "ref", HandleWrap::Ref); -- cgit v1.2.3