summaryrefslogtreecommitdiff
path: root/src/signal_wrap.cc
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2013-07-03 04:23:44 +0200
committerBen Noordhuis <info@bnoordhuis.nl>2013-07-06 17:44:44 +0200
commit110a9cd8db515c4d1a9ac5cd8837291da7c6c5ea (patch)
tree71e5a14a98131d89d670f842eb36bfcccab00b7b /src/signal_wrap.cc
parent9b3de60d3537df657e75887436a5b1df5ed80c2d (diff)
downloadnode-new-110a9cd8db515c4d1a9ac5cd8837291da7c6c5ea.tar.gz
lib, src: upgrade after v8 api change
This is a big commit that touches just about every file in the src/ directory. The V8 API has changed in significant ways. The most important changes are: * Binding functions take a const v8::FunctionCallbackInfo<T>& argument rather than a const v8::Arguments& argument. * Binding functions return void rather than v8::Handle<v8::Value>. The return value is returned with the args.GetReturnValue().Set() family of functions. * v8::Persistent<T> no longer derives from v8::Handle<T> and no longer allows you to directly dereference the object that the persistent handle points to. This means that the common pattern of caching oft-used JS values in a persistent handle no longer quite works, you first need to reconstruct a v8::Local<T> from the persistent handle with the Local<T>::New(isolate, persistent) factory method. A handful of (internal) convenience classes and functions have been added to make dealing with the new API a little easier. The most visible one is node::Cached<T>, which wraps a v8::Persistent<T> with some template sugar. It can hold arbitrary types but so far it's exclusively used for v8::Strings (which was by far the most commonly cached handle type.)
Diffstat (limited to 'src/signal_wrap.cc')
-rw-r--r--src/signal_wrap.cc28
1 files changed, 9 insertions, 19 deletions
diff --git a/src/signal_wrap.cc b/src/signal_wrap.cc
index 7f84553dea..201e033592 100644
--- a/src/signal_wrap.cc
+++ b/src/signal_wrap.cc
@@ -25,19 +25,18 @@
namespace node {
-using v8::Arguments;
using v8::Function;
+using v8::FunctionCallbackInfo;
using v8::FunctionTemplate;
using v8::Handle;
using v8::HandleScope;
using v8::Integer;
using v8::Local;
using v8::Object;
-using v8::Persistent;
using v8::String;
using v8::Value;
-static Persistent<String> onsignal_sym;
+static Cached<String> onsignal_sym;
class SignalWrap : public HandleWrap {
@@ -57,13 +56,13 @@ class SignalWrap : public HandleWrap {
NODE_SET_PROTOTYPE_METHOD(constructor, "start", Start);
NODE_SET_PROTOTYPE_METHOD(constructor, "stop", Stop);
- onsignal_sym = NODE_PSYMBOL("onsignal");
+ onsignal_sym = String::New("onsignal");
target->Set(String::NewSymbol("Signal"), constructor->GetFunction());
}
private:
- static Handle<Value> New(const Arguments& args) {
+ static void New(const FunctionCallbackInfo<Value>& args) {
// This constructor should not be exposed to public javascript.
// Therefore we assert that we are not trying to call this as a
// normal function.
@@ -71,8 +70,6 @@ class SignalWrap : public HandleWrap {
HandleScope scope(node_isolate);
new SignalWrap(args.This());
-
- return scope.Close(args.This());
}
SignalWrap(Handle<Object> object)
@@ -84,30 +81,23 @@ class SignalWrap : public HandleWrap {
~SignalWrap() {
}
- static Handle<Value> Start(const Arguments& args) {
+ static void Start(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
-
UNWRAP(SignalWrap)
int signum = args[0]->Int32Value();
-
int r = uv_signal_start(&wrap->handle_, OnSignal, signum);
-
if (r) SetErrno(uv_last_error(uv_default_loop()));
-
- return scope.Close(Integer::New(r, node_isolate));
+ args.GetReturnValue().Set(r);
}
- static Handle<Value> Stop(const Arguments& args) {
+ static void Stop(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
-
UNWRAP(SignalWrap)
int r = uv_signal_stop(&wrap->handle_);
-
if (r) SetErrno(uv_last_error(uv_default_loop()));
-
- return scope.Close(Integer::New(r, node_isolate));
+ args.GetReturnValue().Set(r);
}
static void OnSignal(uv_signal_t* handle, int signum) {
@@ -117,7 +107,7 @@ class SignalWrap : public HandleWrap {
assert(wrap);
Local<Value> argv[1] = { Integer::New(signum, node_isolate) };
- MakeCallback(wrap->object_, onsignal_sym, ARRAY_SIZE(argv), argv);
+ MakeCallback(wrap->object(), onsignal_sym, ARRAY_SIZE(argv), argv);
}
uv_signal_t handle_;