aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/node/ext/call.h
diff options
context:
space:
mode:
authorGravatar murgatroid99 <mlumish@google.com>2015-09-17 13:56:25 -0700
committerGravatar murgatroid99 <mlumish@google.com>2015-09-17 13:56:25 -0700
commit2b09783f8ad3aff8af6b1e5a9e3d799c4df1d4f1 (patch)
treea3335cdd2edf0ca19a140b3bc91d88c20145ce9a /src/node/ext/call.h
parente8659971a9cedeccb90d39d2dfe784048baa2f19 (diff)
Update to nan 2.0
Diffstat (limited to 'src/node/ext/call.h')
-rw-r--r--src/node/ext/call.h57
1 files changed, 22 insertions, 35 deletions
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<v8::Value, Nan::CopyablePersistentTraits<v8::Value>> 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<v8::Value> nanErrorWithCode(const char *msg,
grpc_call_error code) {
- NanEscapableScope();
- v8::Local<v8::Object> err = NanError(msg).As<v8::Object>();
- err->Set(NanNew("code"), NanNew<v8::Uint32>(code));
- return NanEscapeScope(err);
+ Nan::EscapableHandleScope scope;
+ v8::Local<v8::Object> err = Nan::Error(msg).As<v8::Object>();
+ Nan::Set(err, Nan::New("code").ToLocalChecked(), Nan::New<v8::Uint32>(code));
+ return scope.Escape(err);
}
-v8::Handle<v8::Value> ParseMetadata(const grpc_metadata_array *metadata_array);
-
-class PersistentHolder {
- public:
- explicit PersistentHolder(v8::Persistent<v8::Value> *persist) :
- persist(persist) {
- }
-
- ~PersistentHolder() {
- NanDisposePersistent(*persist);
- delete persist;
- }
-
- private:
- v8::Persistent<v8::Value> *persist;
-};
+v8::Local<v8::Value> ParseMetadata(const grpc_metadata_array *metadata_array);
struct Resources {
- std::vector<unique_ptr<NanUtf8String> > strings;
- std::vector<unique_ptr<PersistentHolder> > handles;
+ std::vector<unique_ptr<Nan::Utf8String> > strings;
+ std::vector<unique_ptr<PersistentValue> > handles;
};
class Op {
public:
- virtual v8::Handle<v8::Value> GetNodeValue() const = 0;
- virtual bool ParseOp(v8::Handle<v8::Value> value, grpc_op *out,
+ virtual v8::Local<v8::Value> GetNodeValue() const = 0;
+ virtual bool ParseOp(v8::Local<v8::Value> value, grpc_op *out,
shared_ptr<Resources> resources) = 0;
- v8::Handle<v8::Value> GetOpType() const;
+ v8::Local<v8::Value> GetOpType() const;
protected:
virtual std::string GetTypeString() const = 0;
@@ -100,27 +87,27 @@ class Op {
typedef std::vector<unique_ptr<Op>> OpVec;
struct tag {
- tag(NanCallback *callback, OpVec *ops,
+ tag(Nan::Callback *callback, OpVec *ops,
shared_ptr<Resources> resources);
~tag();
- NanCallback *callback;
+ Nan::Callback *callback;
OpVec *ops;
shared_ptr<Resources> resources;
};
-v8::Handle<v8::Value> GetTagNodeValue(void *tag);
+v8::Local<v8::Value> 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<v8::Object> exports);
- static bool HasInstance(v8::Handle<v8::Value> val);
+ static void Init(v8::Local<v8::Object> exports);
+ static bool HasInstance(v8::Local<v8::Value> val);
/* Wrap a grpc_call struct in a javascript object */
- static v8::Handle<v8::Value> WrapStruct(grpc_call *call);
+ static v8::Local<v8::Value> 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<v8::FunctionTemplate> fun_tpl;
+ static Nan::Persistent<v8::FunctionTemplate> fun_tpl;
grpc_call *wrapped_call;
};