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) {
StreamWrap::Initialize(target);
- HandleScope scope;
+ HandleScope scope(node_isolate);
Local<FunctionTemplate> t = FunctionTemplate::New(New);
t->SetClassName(String::NewSymbol("TTY"));
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);
TTYWrap* TTYWrap::Unwrap(Local<Object> obj) {
assert(!obj.IsEmpty());
assert(obj->InternalFieldCount() > 0);
- return static_cast<TTYWrap*>(obj->GetPointerFromInternalField(0));
+ return static_cast<TTYWrap*>(obj->GetAlignedPointerFromInternalField(0));
}
Handle<Value> TTYWrap::GuessHandleType(const Arguments& args) {
- HandleScope scope;
+ HandleScope scope(node_isolate);
int fd = args[0]->Int32Value();
assert(fd >= 0);
default:
assert(0);
- return v8::Undefined();
+ return v8::Undefined(node_isolate);
}
}
Handle<Value> TTYWrap::IsTTY(const Arguments& args) {
- HandleScope scope;
+ HandleScope scope(node_isolate);
int fd = args[0]->Int32Value();
assert(fd >= 0);
- return uv_guess_handle(fd) == UV_TTY ? v8::True() : v8::False();
+
+ if (uv_guess_handle(fd) == UV_TTY) {
+ return v8::True(node_isolate);
+ }
+
+ return v8::False(node_isolate);
}
Handle<Value> TTYWrap::GetWindowSize(const Arguments& args) {
- HandleScope scope;
+ HandleScope scope(node_isolate);
UNWRAP(TTYWrap)
if (r) {
SetErrno(uv_last_error(uv_default_loop()));
- return v8::Undefined();
+ return v8::Undefined(node_isolate);
}
Local<v8::Array> a = v8::Array::New(2);
- a->Set(0, Integer::New(width));
- a->Set(1, Integer::New(height));
+ a->Set(0, Integer::New(width, node_isolate));
+ a->Set(1, Integer::New(height, node_isolate));
return scope.Close(a);
}
Handle<Value> TTYWrap::SetRawMode(const Arguments& args) {
- HandleScope scope;
+ HandleScope scope(node_isolate);
UNWRAP(TTYWrap)
SetErrno(uv_last_error(uv_default_loop()));
}
- return scope.Close(Integer::New(r));
+ return scope.Close(Integer::New(r, node_isolate));
}
Handle<Value> TTYWrap::New(const Arguments& args) {
- HandleScope scope;
+ HandleScope scope(node_isolate);
// This constructor should not be exposed to public javascript.
// Therefore we assert that we are not trying to call this as a