Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2013-02-13 19:09:03 +0400
committerBen Noordhuis <info@bnoordhuis.nl>2013-02-13 19:11:20 +0400
commit7bdd05bd66607886d633332e1397550d9b8d9b39 (patch)
tree459c80d81efb317a0f220cb67116f16eb94e30bc /src/pipe_wrap.cc
parent2d069c52107b02999476c8a2aee5cf2b190b8d12 (diff)
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.
Diffstat (limited to 'src/pipe_wrap.cc')
-rw-r--r--src/pipe_wrap.cc28
1 files changed, 19 insertions, 9 deletions
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<Function> pipeConstructor;
@@ -82,6 +83,15 @@ void PipeWrap::Initialize(Handle<Object> target) {
t->InstanceTemplate()->SetInternalFieldCount(1);
+ enum PropertyAttribute attributes =
+ static_cast<PropertyAttribute>(v8::ReadOnly | v8::DontDelete);
+ t->InstanceTemplate()->SetAccessor(String::New("fd"),
+ StreamWrap::GetFD,
+ NULL,
+ Handle<Value>(),
+ 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);