src: pass Isolate to all applicable api
[platform/upstream/nodejs.git] / src / tty_wrap.cc
index 7875c7d..080e53b 100644 (file)
 
 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);
 
@@ -88,7 +98,7 @@ uv_tty_t* TTYWrap::UVHandle() {
 
 
 Handle<Value> TTYWrap::GuessHandleType(const Arguments& args) {
-  HandleScope scope;
+  HandleScope scope(node_isolate);
   int fd = args[0]->Int32Value();
   assert(fd >= 0);
 
@@ -109,21 +119,26 @@ Handle<Value> TTYWrap::GuessHandleType(const Arguments& args) {
 
     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)
 
@@ -132,7 +147,7 @@ Handle<Value> TTYWrap::GetWindowSize(const Arguments& args) {
 
   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);
@@ -144,7 +159,7 @@ Handle<Value> TTYWrap::GetWindowSize(const Arguments& args) {
 
 
 Handle<Value> TTYWrap::SetRawMode(const Arguments& args) {
-  HandleScope scope;
+  HandleScope scope(node_isolate);
 
   UNWRAP(TTYWrap)
 
@@ -159,7 +174,7 @@ Handle<Value> TTYWrap::SetRawMode(const Arguments& args) {
 
 
 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