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;
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);
namespace node {
-using v8::Object;
+using v8::AccessorInfo;
+using v8::Arguments;
+using v8::Context;
+using v8::Exception;
+using v8::Function;
+using v8::FunctionTemplate;
using v8::Handle;
+using v8::HandleScope;
+using v8::Integer;
using v8::Local;
+using v8::Number;
+using v8::Object;
using v8::Persistent;
-using v8::Value;
-using v8::HandleScope;
-using v8::FunctionTemplate;
using v8::String;
-using v8::Function;
using v8::TryCatch;
-using v8::Context;
-using v8::Arguments;
-using v8::Integer;
-using v8::Number;
-using v8::Exception;
-
+using v8::Value;
typedef class ReqWrap<uv_shutdown_t> ShutdownWrap;
}
+Handle<Value> StreamWrap::GetFD(Local<String>, const AccessorInfo& args) {
+#if defined(_WIN32)
+ return v8::Null(node_isolate);
+#else
+ HandleScope scope;
+ UNWRAP(StreamWrap)
+ int fd = -1;
+ if (wrap != NULL && wrap->stream_ != NULL) fd = wrap->stream_->io_watcher.fd;
+ return scope.Close(Integer::New(fd, node_isolate));
+#endif
+}
+
+
void StreamWrap::SetHandle(uv_handle_t* h) {
HandleWrap::SetHandle(h);
stream_ = reinterpret_cast<uv_stream_t*>(h);
static void Initialize(v8::Handle<v8::Object> target);
+ static v8::Handle<v8::Value> GetFD(v8::Local<v8::String>,
+ const v8::AccessorInfo&);
+
// JavaScript functions
static v8::Handle<v8::Value> ReadStart(const v8::Arguments& args);
static v8::Handle<v8::Value> ReadStop(const v8::Arguments& args);
using v8::HandleScope;
using v8::Integer;
using v8::Local;
-using v8::Object;
using v8::Null;
+using v8::Object;
using v8::Persistent;
+using v8::PropertyAttribute;
using v8::String;
using v8::TryCatch;
using v8::Undefined;
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, "ref", HandleWrap::Ref);
namespace node {
-using v8::Object;
+using v8::Arguments;
+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::Undefined;
+using v8::Value;
void TTYWrap::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);
namespace node {
+using v8::AccessorInfo;
using v8::Arguments;
using v8::Function;
using v8::FunctionTemplate;
using v8::Local;
using v8::Object;
using v8::Persistent;
+using v8::PropertyAttribute;
using v8::String;
using v8::Value;
t->InstanceTemplate()->SetInternalFieldCount(1);
t->SetClassName(String::NewSymbol("UDP"));
+ enum PropertyAttribute attributes =
+ static_cast<PropertyAttribute>(v8::ReadOnly | v8::DontDelete);
+ t->InstanceTemplate()->SetAccessor(String::New("fd"),
+ UDPWrap::GetFD,
+ NULL,
+ Handle<Value>(),
+ v8::DEFAULT,
+ attributes);
+
NODE_SET_PROTOTYPE_METHOD(t, "bind", Bind);
NODE_SET_PROTOTYPE_METHOD(t, "send", Send);
NODE_SET_PROTOTYPE_METHOD(t, "bind6", Bind6);
return scope.Close(args.This());
}
+
+Handle<Value> UDPWrap::GetFD(Local<String>, const AccessorInfo& args) {
+#if defined(_WIN32)
+ return v8::Null(node_isolate);
+#else
+ HandleScope scope;
+ UNWRAP(UDPWrap)
+ int fd = (wrap == NULL) ? -1 : wrap->handle_.io_watcher.fd;
+ return scope.Close(Integer::New(fd, node_isolate));
+#endif
+}
+
+
Handle<Value> UDPWrap::DoBind(const Arguments& args, int family) {
HandleScope scope;
int r;
class UDPWrap: public HandleWrap {
public:
static void Initialize(v8::Handle<v8::Object> target);
+ static v8::Handle<v8::Value> GetFD(v8::Local<v8::String>,
+ const v8::AccessorInfo&);
static v8::Handle<v8::Value> New(const v8::Arguments& args);
static v8::Handle<v8::Value> Bind(const v8::Arguments& args);
static v8::Handle<v8::Value> Send(const v8::Arguments& args);