From 2b09783f8ad3aff8af6b1e5a9e3d799c4df1d4f1 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Thu, 17 Sep 2015 13:56:25 -0700 Subject: Update to nan 2.0 --- src/node/ext/call.h | 57 +++++++++++++++++++++-------------------------------- 1 file changed, 22 insertions(+), 35 deletions(-) (limited to 'src/node/ext/call.h') diff --git a/src/node/ext/call.h b/src/node/ext/call.h index 89f81dcf4d..1f387edc64 100644 --- a/src/node/ext/call.h +++ b/src/node/ext/call.h @@ -51,6 +51,8 @@ namespace node { using std::unique_ptr; using std::shared_ptr; +typedef Nan::Persistent> PersistentValue; + /** * Helper function for throwing errors with a grpc_call_error value. * Modified from the answer by Gus Goose to @@ -58,40 +60,25 @@ using std::shared_ptr; */ inline v8::Local nanErrorWithCode(const char *msg, grpc_call_error code) { - NanEscapableScope(); - v8::Local err = NanError(msg).As(); - err->Set(NanNew("code"), NanNew(code)); - return NanEscapeScope(err); + Nan::EscapableHandleScope scope; + v8::Local err = Nan::Error(msg).As(); + Nan::Set(err, Nan::New("code").ToLocalChecked(), Nan::New(code)); + return scope.Escape(err); } -v8::Handle ParseMetadata(const grpc_metadata_array *metadata_array); - -class PersistentHolder { - public: - explicit PersistentHolder(v8::Persistent *persist) : - persist(persist) { - } - - ~PersistentHolder() { - NanDisposePersistent(*persist); - delete persist; - } - - private: - v8::Persistent *persist; -}; +v8::Local ParseMetadata(const grpc_metadata_array *metadata_array); struct Resources { - std::vector > strings; - std::vector > handles; + std::vector > strings; + std::vector > handles; }; class Op { public: - virtual v8::Handle GetNodeValue() const = 0; - virtual bool ParseOp(v8::Handle value, grpc_op *out, + virtual v8::Local GetNodeValue() const = 0; + virtual bool ParseOp(v8::Local value, grpc_op *out, shared_ptr resources) = 0; - v8::Handle GetOpType() const; + v8::Local GetOpType() const; protected: virtual std::string GetTypeString() const = 0; @@ -100,27 +87,27 @@ class Op { typedef std::vector> OpVec; struct tag { - tag(NanCallback *callback, OpVec *ops, + tag(Nan::Callback *callback, OpVec *ops, shared_ptr resources); ~tag(); - NanCallback *callback; + Nan::Callback *callback; OpVec *ops; shared_ptr resources; }; -v8::Handle GetTagNodeValue(void *tag); +v8::Local GetTagNodeValue(void *tag); -NanCallback *GetTagCallback(void *tag); +Nan::Callback *GetTagCallback(void *tag); void DestroyTag(void *tag); /* Wrapper class for grpc_call structs. */ -class Call : public ::node::ObjectWrap { +class Call : public Nan::ObjectWrap { public: - static void Init(v8::Handle exports); - static bool HasInstance(v8::Handle val); + static void Init(v8::Local exports); + static bool HasInstance(v8::Local val); /* Wrap a grpc_call struct in a javascript object */ - static v8::Handle WrapStruct(grpc_call *call); + static v8::Local WrapStruct(grpc_call *call); private: explicit Call(grpc_call *call); @@ -135,9 +122,9 @@ class Call : public ::node::ObjectWrap { static NAN_METHOD(Cancel); static NAN_METHOD(CancelWithStatus); static NAN_METHOD(GetPeer); - static NanCallback *constructor; + static Nan::Callback *constructor; // Used for typechecking instances of this javascript class - static v8::Persistent fun_tpl; + static Nan::Persistent fun_tpl; grpc_call *wrapped_call; }; -- cgit v1.2.3