summaryrefslogtreecommitdiff
path: root/src/tty_wrap.cc
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2014-10-13 15:19:55 +0200
committerFedor Indutny <fedor@indutny.com>2014-10-13 23:46:46 +0400
commitd3c317e08ac6a624fde8b242905992eafdd954ac (patch)
tree1dd2756855ab5b4513503acc660705fa898c5c64 /src/tty_wrap.cc
parentb45d33617b569bf5fa84c9343da9f7d129756968 (diff)
downloadandroid-node-v8-d3c317e08ac6a624fde8b242905992eafdd954ac.tar.gz
android-node-v8-d3c317e08ac6a624fde8b242905992eafdd954ac.tar.bz2
android-node-v8-d3c317e08ac6a624fde8b242905992eafdd954ac.zip
src: attach env directly to api functions
Attach the per-context execution environment directly to API functions. Rationale: * Gets node one step closer to multi-isolate readiness. * Avoids multi-context confusion, e.g. when the caller and callee live in different contexts. * Avoids expensive calls to pthread_getspecific() on platforms where V8 does not know how to use the thread-local storage directly. (Linux, the BSDs.) PR-URL: https://github.com/node-forward/node/pull/18 Reviewed-By: Fedor Indutny <fedor@indutny.com>
Diffstat (limited to 'src/tty_wrap.cc')
-rw-r--r--src/tty_wrap.cc38
1 files changed, 17 insertions, 21 deletions
diff --git a/src/tty_wrap.cc b/src/tty_wrap.cc
index bd9368d3ac..1e5eff3a67 100644
--- a/src/tty_wrap.cc
+++ b/src/tty_wrap.cc
@@ -52,7 +52,7 @@ void TTYWrap::Initialize(Handle<Object> target,
Handle<Context> context) {
Environment* env = Environment::GetCurrent(context);
- Local<FunctionTemplate> t = FunctionTemplate::New(env->isolate(), New);
+ Local<FunctionTemplate> t = env->NewFunctionTemplate(New);
t->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "TTY"));
t->InstanceTemplate()->SetInternalFieldCount(1);
@@ -65,27 +65,23 @@ void TTYWrap::Initialize(Handle<Object> target,
v8::DEFAULT,
attributes);
- NODE_SET_PROTOTYPE_METHOD(t, "close", HandleWrap::Close);
- NODE_SET_PROTOTYPE_METHOD(t, "unref", HandleWrap::Unref);
+ env->SetProtoMethod(t, "close", HandleWrap::Close);
+ env->SetProtoMethod(t, "unref", HandleWrap::Unref);
- NODE_SET_PROTOTYPE_METHOD(t, "readStart", StreamWrap::ReadStart);
- NODE_SET_PROTOTYPE_METHOD(t, "readStop", StreamWrap::ReadStop);
+ env->SetProtoMethod(t, "readStart", StreamWrap::ReadStart);
+ env->SetProtoMethod(t, "readStop", StreamWrap::ReadStop);
- NODE_SET_PROTOTYPE_METHOD(t, "writeBuffer", StreamWrap::WriteBuffer);
- NODE_SET_PROTOTYPE_METHOD(t,
- "writeAsciiString",
- StreamWrap::WriteAsciiString);
- NODE_SET_PROTOTYPE_METHOD(t, "writeUtf8String", StreamWrap::WriteUtf8String);
- NODE_SET_PROTOTYPE_METHOD(t, "writeUcs2String", StreamWrap::WriteUcs2String);
- NODE_SET_PROTOTYPE_METHOD(t,
- "writeBinaryString",
- StreamWrap::WriteBinaryString);
+ env->SetProtoMethod(t, "writeBuffer", StreamWrap::WriteBuffer);
+ env->SetProtoMethod(t, "writeAsciiString", StreamWrap::WriteAsciiString);
+ env->SetProtoMethod(t, "writeUtf8String", StreamWrap::WriteUtf8String);
+ env->SetProtoMethod(t, "writeUcs2String", StreamWrap::WriteUcs2String);
+ env->SetProtoMethod(t, "writeBinaryString", StreamWrap::WriteBinaryString);
- NODE_SET_PROTOTYPE_METHOD(t, "getWindowSize", TTYWrap::GetWindowSize);
- NODE_SET_PROTOTYPE_METHOD(t, "setRawMode", SetRawMode);
+ env->SetProtoMethod(t, "getWindowSize", TTYWrap::GetWindowSize);
+ env->SetProtoMethod(t, "setRawMode", SetRawMode);
- NODE_SET_METHOD(target, "isTTY", IsTTY);
- NODE_SET_METHOD(target, "guessHandleType", GuessHandleType);
+ env->SetMethod(target, "isTTY", IsTTY);
+ env->SetMethod(target, "guessHandleType", GuessHandleType);
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "TTY"), t->GetFunction());
env->set_tty_constructor_template(t);
@@ -98,7 +94,7 @@ uv_tty_t* TTYWrap::UVHandle() {
void TTYWrap::GuessHandleType(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
int fd = args[0]->Int32Value();
CHECK_GE(fd, 0);
@@ -129,7 +125,7 @@ void TTYWrap::IsTTY(const FunctionCallbackInfo<Value>& args) {
void TTYWrap::GetWindowSize(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
TTYWrap* wrap = Unwrap<TTYWrap>(args.Holder());
CHECK(args[0]->IsArray());
@@ -155,7 +151,7 @@ void TTYWrap::SetRawMode(const FunctionCallbackInfo<Value>& args) {
void TTYWrap::New(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
// This constructor should not be exposed to public javascript.
// Therefore we assert that we are not trying to call this as a