aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/node/ext/call.cc
diff options
context:
space:
mode:
authorGravatar murgatroid99 <mlumish@google.com>2015-03-04 11:28:37 -0800
committerGravatar murgatroid99 <mlumish@google.com>2015-03-04 11:28:37 -0800
commit5f875d29869de606432531ecdd630bc5aa6f9574 (patch)
treeccc3bd77af6650006e3fd5422c1f3760684bcdca /src/node/ext/call.cc
parent3a982182824a49d764309287c06d0187b3c73859 (diff)
Updated some c++ files for 0.11/0.12 compatibility
Diffstat (limited to 'src/node/ext/call.cc')
-rw-r--r--src/node/ext/call.cc47
1 files changed, 23 insertions, 24 deletions
diff --git a/src/node/ext/call.cc b/src/node/ext/call.cc
index 9ed389f3bc..1d85abb1d2 100644
--- a/src/node/ext/call.cc
+++ b/src/node/ext/call.cc
@@ -54,8 +54,6 @@ using std::vector;
namespace grpc {
namespace node {
-using ::node::Buffer;
-using v8::Arguments;
using v8::Array;
using v8::Boolean;
using v8::Exception;
@@ -74,7 +72,7 @@ using v8::Uint32;
using v8::String;
using v8::Value;
-Persistent<Function> Call::constructor;
+NanCallback *Call::constructor;
Persistent<FunctionTemplate> Call::fun_tpl;
@@ -101,9 +99,9 @@ bool CreateMetadataArray(Handle<Object> metadata, grpc_metadata_array *array,
Handle<Value> value = values->Get(j);
grpc_metadata *current = &array->metadata[array->count];
current->key = **utf8_key;
- if (Buffer::HasInstance(value)) {
- current->value = Buffer::Data(value);
- current->value_length = Buffer::Length(value);
+ if (::node::Buffer::HasInstance(value)) {
+ current->value = ::node::Buffer::Data(value);
+ current->value_length = ::node::Buffer::Length(value);
Persistent<Value> handle;
NanAssignPersistent(handle, value);
resources->handles.push_back(unique_ptr<PersistentHolder>(
@@ -140,7 +138,7 @@ Handle<Value> ParseMetadata(const grpc_metadata_array *metadata_array) {
Handle<Object> metadata_object = NanNew<Object>();
for (unsigned int i = 0; i < length; i++) {
grpc_metadata* elem = &metadata_elements[i];
- Handle<String> key_string = String::New(elem->key);
+ Handle<String> key_string = NanNew(elem->key);
Handle<Array> array;
if (metadata_object->Has(key_string)) {
array = Handle<Array>::Cast(metadata_object->Get(key_string));
@@ -194,7 +192,7 @@ class SendMessageOp : public Op {
}
bool ParseOp(Handle<Value> value, grpc_op *out,
shared_ptr<Resources> resources) {
- if (!Buffer::HasInstance(value)) {
+ if (!::node::Buffer::HasInstance(value)) {
return false;
}
out->data.send_message = BufferToByteBuffer(value);
@@ -357,7 +355,7 @@ class ClientStatusOp : public Op {
Handle<Object> status_obj = NanNew<Object>();
status_obj->Set(NanNew("code"), NanNew<Number>(status));
if (status_details != NULL) {
- status_obj->Set(NanNew("details"), String::New(status_details));
+ status_obj->Set(NanNew("details"), NanNew(status_details));
}
status_obj->Set(NanNew("metadata"), ParseMetadata(&metadata_array));
return NanEscapeScope(status_obj);
@@ -436,20 +434,21 @@ Call::~Call() {
void Call::Init(Handle<Object> exports) {
NanScope();
- Local<FunctionTemplate> tpl = FunctionTemplate::New(New);
+ Local<FunctionTemplate> tpl = NanNew<FunctionTemplate>(New);
tpl->SetClassName(NanNew("Call"));
tpl->InstanceTemplate()->SetInternalFieldCount(1);
NanSetPrototypeTemplate(tpl, "startBatch",
- FunctionTemplate::New(StartBatch)->GetFunction());
+ NanNew<FunctionTemplate>(StartBatch)->GetFunction());
NanSetPrototypeTemplate(tpl, "cancel",
- FunctionTemplate::New(Cancel)->GetFunction());
+ NanNew<FunctionTemplate>(Cancel)->GetFunction());
NanAssignPersistent(fun_tpl, tpl);
- NanAssignPersistent(constructor, tpl->GetFunction());
- constructor->Set(NanNew("WRITE_BUFFER_HINT"),
- NanNew<Uint32, uint32_t>(GRPC_WRITE_BUFFER_HINT));
- constructor->Set(NanNew("WRITE_NO_COMPRESS"),
- NanNew<Uint32, uint32_t>(GRPC_WRITE_NO_COMPRESS));
- exports->Set(String::NewSymbol("Call"), constructor);
+ Handle<Function> ctr = tpl->GetFunction();
+ ctr->Set(NanNew("WRITE_BUFFER_HINT"),
+ NanNew<Uint32, uint32_t>(GRPC_WRITE_BUFFER_HINT));
+ ctr->Set(NanNew("WRITE_NO_COMPRESS"),
+ NanNew<Uint32, uint32_t>(GRPC_WRITE_NO_COMPRESS));
+ exports->Set(NanNew("Call"), ctr);
+ constructor = new NanCallback(ctr);
}
bool Call::HasInstance(Handle<Value> val) {
@@ -463,8 +462,8 @@ Handle<Value> Call::WrapStruct(grpc_call *call) {
return NanEscapeScope(NanNull());
}
const int argc = 1;
- Handle<Value> argv[argc] = {External::New(reinterpret_cast<void *>(call))};
- return NanEscapeScope(constructor->NewInstance(argc, argv));
+ Handle<Value> argv[argc] = {NanNew<External>(reinterpret_cast<void *>(call))};
+ return NanEscapeScope(constructor->GetFunction()->NewInstance(argc, argv));
}
NAN_METHOD(Call::New) {
@@ -473,9 +472,10 @@ NAN_METHOD(Call::New) {
if (args.IsConstructCall()) {
Call *call;
if (args[0]->IsExternal()) {
+ Handle<External> ext = args[0].As<External>();
// This option is used for wrapping an existing call
grpc_call *call_value =
- reinterpret_cast<grpc_call *>(External::Unwrap(args[0]));
+ reinterpret_cast<grpc_call *>(ext->Value());
call = new Call(call_value);
} else {
if (!Channel::HasInstance(args[0])) {
@@ -500,15 +500,14 @@ NAN_METHOD(Call::New) {
wrapped_channel, CompletionQueueAsyncWorker::GetQueue(), *method,
channel->GetHost(), MillisecondsToTimespec(deadline));
call = new Call(wrapped_call);
- args.This()->SetHiddenValue(String::NewSymbol("channel_"),
- channel_object);
+ args.This()->SetHiddenValue(NanNew("channel_"), channel_object);
}
call->Wrap(args.This());
NanReturnValue(args.This());
} else {
const int argc = 4;
Local<Value> argv[argc] = {args[0], args[1], args[2], args[3]};
- NanReturnValue(constructor->NewInstance(argc, argv));
+ NanReturnValue(constructor->GetFunction()->NewInstance(argc, argv));
}
}