diff options
Diffstat (limited to 'src/node')
-rw-r--r-- | src/node/byte_buffer.cc | 4 | ||||
-rw-r--r-- | src/node/call.cc | 91 | ||||
-rw-r--r-- | src/node/call.h | 4 | ||||
-rw-r--r-- | src/node/channel.cc | 28 | ||||
-rw-r--r-- | src/node/channel.h | 4 | ||||
-rw-r--r-- | src/node/completion_queue_async_worker.cc | 16 | ||||
-rw-r--r-- | src/node/credentials.cc | 30 | ||||
-rw-r--r-- | src/node/credentials.h | 4 | ||||
-rw-r--r-- | src/node/event.cc | 43 | ||||
-rw-r--r-- | src/node/node_grpc.cc | 6 | ||||
-rw-r--r-- | src/node/server.cc | 41 | ||||
-rw-r--r-- | src/node/server.h | 4 | ||||
-rw-r--r-- | src/node/server_credentials.cc | 25 | ||||
-rw-r--r-- | src/node/server_credentials.h | 4 | ||||
-rw-r--r-- | src/node/tag.cc | 15 | ||||
-rw-r--r-- | src/node/timeval.cc | 2 |
16 files changed, 131 insertions, 190 deletions
diff --git a/src/node/byte_buffer.cc b/src/node/byte_buffer.cc index cd70486ccb..142951475a 100644 --- a/src/node/byte_buffer.cc +++ b/src/node/byte_buffer.cc @@ -65,12 +65,12 @@ Handle<Value> ByteBufferToBuffer(grpc_byte_buffer *buffer) { NanReturnNull(); } size_t length = grpc_byte_buffer_length(buffer); - char *result = reinterpret_cast<char*>(calloc(length, sizeof(char))); + char *result = reinterpret_cast<char *>(calloc(length, sizeof(char))); size_t offset = 0; grpc_byte_buffer_reader *reader = grpc_byte_buffer_reader_create(buffer); gpr_slice next; while (grpc_byte_buffer_reader_next(reader, &next) != 0) { - memcpy(result+offset, GPR_SLICE_START_PTR(next), GPR_SLICE_LENGTH(next)); + memcpy(result + offset, GPR_SLICE_START_PTR(next), GPR_SLICE_LENGTH(next)); offset += GPR_SLICE_LENGTH(next); } return NanEscapeScope(NanNewBufferHandle(result, length)); diff --git a/src/node/call.cc b/src/node/call.cc index 850f7cd9b9..b8ee1786a6 100644 --- a/src/node/call.cc +++ b/src/node/call.cc @@ -67,12 +67,9 @@ using v8::Value; Persistent<Function> Call::constructor; Persistent<FunctionTemplate> Call::fun_tpl; -Call::Call(grpc_call *call) : wrapped_call(call) { -} +Call::Call(grpc_call *call) : wrapped_call(call) {} -Call::~Call() { - grpc_call_destroy(wrapped_call); -} +Call::~Call() { grpc_call_destroy(wrapped_call); } void Call::Init(Handle<Object> exports) { NanScope(); @@ -86,8 +83,7 @@ void Call::Init(Handle<Object> exports) { NanSetPrototypeTemplate(tpl, "serverAccept", FunctionTemplate::New(ServerAccept)->GetFunction()); NanSetPrototypeTemplate( - tpl, - "serverEndInitialMetadata", + tpl, "serverEndInitialMetadata", FunctionTemplate::New(ServerEndInitialMetadata)->GetFunction()); NanSetPrototypeTemplate(tpl, "cancel", FunctionTemplate::New(Cancel)->GetFunction()); @@ -122,7 +118,7 @@ Handle<Value> Call::WrapStruct(grpc_call *call) { return NanEscapeScope(NanNull()); } const int argc = 1; - Handle<Value> argv[argc] = { External::New(reinterpret_cast<void*>(call)) }; + Handle<Value> argv[argc] = {External::New(reinterpret_cast<void *>(call))}; return NanEscapeScope(constructor->NewInstance(argc, argv)); } @@ -133,8 +129,8 @@ NAN_METHOD(Call::New) { Call *call; if (args[0]->IsExternal()) { // This option is used for wrapping an existing call - grpc_call *call_value = reinterpret_cast<grpc_call*>( - External::Unwrap(args[0])); + grpc_call *call_value = + reinterpret_cast<grpc_call *>(External::Unwrap(args[0])); call = new Call(call_value); } else { if (!Channel::HasInstance(args[0])) { @@ -155,11 +151,9 @@ NAN_METHOD(Call::New) { NanUtf8String method(args[1]); double deadline = args[2]->NumberValue(); grpc_channel *wrapped_channel = channel->GetWrappedChannel(); - grpc_call *wrapped_call = grpc_channel_create_call( - wrapped_channel, - *method, - channel->GetHost(), - MillisecondsToTimespec(deadline)); + grpc_call *wrapped_call = + grpc_channel_create_call(wrapped_channel, *method, channel->GetHost(), + MillisecondsToTimespec(deadline)); call = new Call(wrapped_call); args.This()->SetHiddenValue(String::NewSymbol("channel_"), channel_object); @@ -168,7 +162,7 @@ NAN_METHOD(Call::New) { NanReturnValue(args.This()); } else { const int argc = 4; - Local<Value> argv[argc] = { args[0], args[1], args[2], args[3] }; + Local<Value> argv[argc] = {args[0], args[1], args[2], args[3]}; NanReturnValue(constructor->NewInstance(argc, argv)); } } @@ -176,11 +170,10 @@ NAN_METHOD(Call::New) { NAN_METHOD(Call::AddMetadata) { NanScope(); if (!HasInstance(args.This())) { - return NanThrowTypeError( - "addMetadata can only be called on Call objects"); + return NanThrowTypeError("addMetadata can only be called on Call objects"); } Call *call = ObjectWrap::Unwrap<Call>(args.This()); - for (int i=0; !args[i]->IsUndefined(); i++) { + for (int i = 0; !args[i]->IsUndefined(); i++) { if (!args[i]->IsObject()) { return NanThrowTypeError( "addMetadata arguments must be objects with key and value"); @@ -201,9 +194,8 @@ NAN_METHOD(Call::AddMetadata) { metadata.key = *utf8_key; metadata.value = Buffer::Data(value); metadata.value_length = Buffer::Length(value); - grpc_call_error error = grpc_call_add_metadata(call->wrapped_call, - &metadata, - 0); + grpc_call_error error = + grpc_call_add_metadata(call->wrapped_call, &metadata, 0); if (error != GRPC_CALL_OK) { return NanThrowError("addMetadata failed", error); } @@ -217,16 +209,14 @@ NAN_METHOD(Call::StartInvoke) { return NanThrowTypeError("startInvoke can only be called on Call objects"); } if (!args[0]->IsFunction()) { - return NanThrowTypeError( - "StartInvoke's first argument must be a function"); + return NanThrowTypeError("StartInvoke's first argument must be a function"); } if (!args[1]->IsFunction()) { return NanThrowTypeError( "StartInvoke's second argument must be a function"); } if (!args[2]->IsFunction()) { - return NanThrowTypeError( - "StartInvoke's third argument must be a function"); + return NanThrowTypeError("StartInvoke's third argument must be a function"); } if (!args[3]->IsUint32()) { return NanThrowTypeError( @@ -235,12 +225,9 @@ NAN_METHOD(Call::StartInvoke) { Call *call = ObjectWrap::Unwrap<Call>(args.This()); unsigned int flags = args[3]->Uint32Value(); grpc_call_error error = grpc_call_start_invoke( - call->wrapped_call, - CompletionQueueAsyncWorker::GetQueue(), - CreateTag(args[0], args.This()), - CreateTag(args[1], args.This()), - CreateTag(args[2], args.This()), - flags); + call->wrapped_call, CompletionQueueAsyncWorker::GetQueue(), + CreateTag(args[0], args.This()), CreateTag(args[1], args.This()), + CreateTag(args[2], args.This()), flags); if (error == GRPC_CALL_OK) { CompletionQueueAsyncWorker::Next(); CompletionQueueAsyncWorker::Next(); @@ -257,13 +244,11 @@ NAN_METHOD(Call::ServerAccept) { return NanThrowTypeError("accept can only be called on Call objects"); } if (!args[0]->IsFunction()) { - return NanThrowTypeError( - "accept's first argument must be a function"); + return NanThrowTypeError("accept's first argument must be a function"); } Call *call = ObjectWrap::Unwrap<Call>(args.This()); grpc_call_error error = grpc_call_server_accept( - call->wrapped_call, - CompletionQueueAsyncWorker::GetQueue(), + call->wrapped_call, CompletionQueueAsyncWorker::GetQueue(), CreateTag(args[0], args.This())); if (error == GRPC_CALL_OK) { CompletionQueueAsyncWorker::Next(); @@ -285,9 +270,8 @@ NAN_METHOD(Call::ServerEndInitialMetadata) { } Call *call = ObjectWrap::Unwrap<Call>(args.This()); unsigned int flags = args[1]->Uint32Value(); - grpc_call_error error = grpc_call_server_end_initial_metadata( - call->wrapped_call, - flags); + grpc_call_error error = + grpc_call_server_end_initial_metadata(call->wrapped_call, flags); if (error != GRPC_CALL_OK) { return NanThrowError("serverEndInitialMetadata failed", error); } @@ -313,12 +297,10 @@ NAN_METHOD(Call::StartWrite) { return NanThrowTypeError("startWrite can only be called on Call objects"); } if (!Buffer::HasInstance(args[0])) { - return NanThrowTypeError( - "startWrite's first argument must be a Buffer"); + return NanThrowTypeError("startWrite's first argument must be a Buffer"); } if (!args[1]->IsFunction()) { - return NanThrowTypeError( - "startWrite's second argument must be a function"); + return NanThrowTypeError("startWrite's second argument must be a function"); } if (!args[2]->IsUint32()) { return NanThrowTypeError( @@ -327,10 +309,8 @@ NAN_METHOD(Call::StartWrite) { Call *call = ObjectWrap::Unwrap<Call>(args.This()); grpc_byte_buffer *buffer = BufferToByteBuffer(args[0]); unsigned int flags = args[2]->Uint32Value(); - grpc_call_error error = grpc_call_start_write(call->wrapped_call, - buffer, - CreateTag(args[1], args.This()), - flags); + grpc_call_error error = grpc_call_start_write( + call->wrapped_call, buffer, CreateTag(args[1], args.This()), flags); if (error == GRPC_CALL_OK) { CompletionQueueAsyncWorker::Next(); } else { @@ -360,9 +340,7 @@ NAN_METHOD(Call::StartWriteStatus) { Call *call = ObjectWrap::Unwrap<Call>(args.This()); NanUtf8String details(args[1]); grpc_call_error error = grpc_call_start_write_status( - call->wrapped_call, - (grpc_status_code)args[0]->Uint32Value(), - *details, + call->wrapped_call, (grpc_status_code)args[0]->Uint32Value(), *details, CreateTag(args[2], args.This())); if (error == GRPC_CALL_OK) { CompletionQueueAsyncWorker::Next(); @@ -378,13 +356,11 @@ NAN_METHOD(Call::WritesDone) { return NanThrowTypeError("writesDone can only be called on Call objects"); } if (!args[0]->IsFunction()) { - return NanThrowTypeError( - "writesDone's first argument must be a function"); + return NanThrowTypeError("writesDone's first argument must be a function"); } Call *call = ObjectWrap::Unwrap<Call>(args.This()); grpc_call_error error = grpc_call_writes_done( - call->wrapped_call, - CreateTag(args[0], args.This())); + call->wrapped_call, CreateTag(args[0], args.This())); if (error == GRPC_CALL_OK) { CompletionQueueAsyncWorker::Next(); } else { @@ -399,12 +375,11 @@ NAN_METHOD(Call::StartRead) { return NanThrowTypeError("startRead can only be called on Call objects"); } if (!args[0]->IsFunction()) { - return NanThrowTypeError( - "startRead's first argument must be a function"); + return NanThrowTypeError("startRead's first argument must be a function"); } Call *call = ObjectWrap::Unwrap<Call>(args.This()); - grpc_call_error error = grpc_call_start_read(call->wrapped_call, - CreateTag(args[0], args.This())); + grpc_call_error error = + grpc_call_start_read(call->wrapped_call, CreateTag(args[0], args.This())); if (error == GRPC_CALL_OK) { CompletionQueueAsyncWorker::Next(); } else { diff --git a/src/node/call.h b/src/node/call.h index 5777b3413c..55a6fc65b8 100644 --- a/src/node/call.h +++ b/src/node/call.h @@ -56,8 +56,8 @@ class Call : public ::node::ObjectWrap { ~Call(); // Prevent copying - Call(const Call&); - Call& operator=(const Call&); + Call(const Call &); + Call &operator=(const Call &); static NAN_METHOD(New); static NAN_METHOD(AddMetadata); diff --git a/src/node/channel.cc b/src/node/channel.cc index c64b8eb783..9087d6f919 100644 --- a/src/node/channel.cc +++ b/src/node/channel.cc @@ -63,8 +63,7 @@ Persistent<Function> Channel::constructor; Persistent<FunctionTemplate> Channel::fun_tpl; Channel::Channel(grpc_channel *channel, NanUtf8String *host) - : wrapped_channel(channel), host(host) { -} + : wrapped_channel(channel), host(host) {} Channel::~Channel() { if (wrapped_channel != NULL) { @@ -90,13 +89,9 @@ bool Channel::HasInstance(Handle<Value> val) { return NanHasInstance(fun_tpl, val); } -grpc_channel *Channel::GetWrappedChannel() { - return this->wrapped_channel; -} +grpc_channel *Channel::GetWrappedChannel() { return this->wrapped_channel; } -char *Channel::GetHost() { - return **this->host; -} +char *Channel::GetHost() { return **this->host; } NAN_METHOD(Channel::New) { NanScope(); @@ -119,20 +114,20 @@ NAN_METHOD(Channel::New) { return NanThrowTypeError( "credentials arg must be a Credentials object"); } - Credentials *creds_object = ObjectWrap::Unwrap<Credentials>( - creds_value->ToObject()); + Credentials *creds_object = + ObjectWrap::Unwrap<Credentials>(creds_value->ToObject()); creds = creds_object->GetWrappedCredentials(); args_hash->Delete(NanNew("credentials")); } Handle<Array> keys(args_hash->GetOwnPropertyNames()); grpc_channel_args channel_args; channel_args.num_args = keys->Length(); - channel_args.args = reinterpret_cast<grpc_arg*>( + channel_args.args = reinterpret_cast<grpc_arg *>( calloc(channel_args.num_args, sizeof(grpc_arg))); /* These are used to keep all strings until then end of the block, then destroy them */ - std::vector<NanUtf8String*> key_strings(keys->Length()); - std::vector<NanUtf8String*> value_strings(keys->Length()); + std::vector<NanUtf8String *> key_strings(keys->Length()); + std::vector<NanUtf8String *> value_strings(keys->Length()); for (unsigned int i = 0; i < channel_args.num_args; i++) { Handle<String> current_key(keys->Get(i)->ToString()); Handle<Value> current_value(args_hash->Get(current_key)); @@ -153,9 +148,8 @@ NAN_METHOD(Channel::New) { if (creds == NULL) { wrapped_channel = grpc_channel_create(**host, &channel_args); } else { - wrapped_channel = grpc_secure_channel_create(creds, - **host, - &channel_args); + wrapped_channel = + grpc_secure_channel_create(creds, **host, &channel_args); } free(channel_args.args); } else { @@ -166,7 +160,7 @@ NAN_METHOD(Channel::New) { NanReturnValue(args.This()); } else { const int argc = 2; - Local<Value> argv[argc] = { args[0], args[1] }; + Local<Value> argv[argc] = {args[0], args[1]}; NanReturnValue(constructor->NewInstance(argc, argv)); } } diff --git a/src/node/channel.h b/src/node/channel.h index 87e24df7f9..140cbf201a 100644 --- a/src/node/channel.h +++ b/src/node/channel.h @@ -61,8 +61,8 @@ class Channel : public ::node::ObjectWrap { ~Channel(); // Prevent copying - Channel(const Channel&); - Channel& operator=(const Channel&); + Channel(const Channel &); + Channel &operator=(const Channel &); static NAN_METHOD(New); static NAN_METHOD(Close); diff --git a/src/node/completion_queue_async_worker.cc b/src/node/completion_queue_async_worker.cc index 21842ffdb2..8de7db66d5 100644 --- a/src/node/completion_queue_async_worker.cc +++ b/src/node/completion_queue_async_worker.cc @@ -51,20 +51,16 @@ using v8::Value; grpc_completion_queue *CompletionQueueAsyncWorker::queue; -CompletionQueueAsyncWorker::CompletionQueueAsyncWorker() : - NanAsyncWorker(NULL) { -} +CompletionQueueAsyncWorker::CompletionQueueAsyncWorker() + : NanAsyncWorker(NULL) {} -CompletionQueueAsyncWorker::~CompletionQueueAsyncWorker() { -} +CompletionQueueAsyncWorker::~CompletionQueueAsyncWorker() {} void CompletionQueueAsyncWorker::Execute() { result = grpc_completion_queue_next(queue, gpr_inf_future); } -grpc_completion_queue *CompletionQueueAsyncWorker::GetQueue() { - return queue; -} +grpc_completion_queue *CompletionQueueAsyncWorker::GetQueue() { return queue; } void CompletionQueueAsyncWorker::Next() { NanScope(); @@ -80,9 +76,7 @@ void CompletionQueueAsyncWorker::Init(Handle<Object> exports) { void CompletionQueueAsyncWorker::HandleOKCallback() { NanScope(); NanCallback event_callback(GetTagHandle(result->tag).As<Function>()); - Handle<Value> argv[] = { - CreateEventObject(result) - }; + Handle<Value> argv[] = {CreateEventObject(result)}; DestroyTag(result->tag); grpc_event_finish(result); diff --git a/src/node/credentials.cc b/src/node/credentials.cc index 95e7c3cd8e..d58b7eda89 100644 --- a/src/node/credentials.cc +++ b/src/node/credentials.cc @@ -60,8 +60,7 @@ Persistent<Function> Credentials::constructor; Persistent<FunctionTemplate> Credentials::fun_tpl; Credentials::Credentials(grpc_credentials *credentials) - : wrapped_credentials(credentials) { -} + : wrapped_credentials(credentials) {} Credentials::~Credentials() { gpr_log(GPR_DEBUG, "Destroying credentials object"); @@ -102,7 +101,7 @@ Handle<Value> Credentials::WrapStruct(grpc_credentials *credentials) { } const int argc = 1; Handle<Value> argv[argc] = { - External::New(reinterpret_cast<void*>(credentials)) }; + External::New(reinterpret_cast<void *>(credentials))}; return NanEscapeScope(constructor->NewInstance(argc, argv)); } @@ -118,14 +117,14 @@ NAN_METHOD(Credentials::New) { return NanThrowTypeError( "Credentials can only be created with the provided functions"); } - grpc_credentials *creds_value = reinterpret_cast<grpc_credentials*>( - External::Unwrap(args[0])); + grpc_credentials *creds_value = + reinterpret_cast<grpc_credentials *>(External::Unwrap(args[0])); Credentials *credentials = new Credentials(creds_value); credentials->Wrap(args.This()); NanReturnValue(args.This()); } else { const int argc = 1; - Local<Value> argv[argc] = { args[0] }; + Local<Value> argv[argc] = {args[0]}; NanReturnValue(constructor->NewInstance(argc, argv)); } } @@ -142,8 +141,7 @@ NAN_METHOD(Credentials::CreateSsl) { char *cert_chain = NULL; int root_certs_length, private_key_length = 0, cert_chain_length = 0; if (!Buffer::HasInstance(args[0])) { - return NanThrowTypeError( - "createSsl's first argument must be a Buffer"); + return NanThrowTypeError("createSsl's first argument must be a Buffer"); } root_certs = Buffer::Data(args[0]); root_certs_length = Buffer::Length(args[0]); @@ -162,9 +160,9 @@ NAN_METHOD(Credentials::CreateSsl) { "createSSl's third argument must be a Buffer if provided"); } NanReturnValue(WrapStruct(grpc_ssl_credentials_create( - reinterpret_cast<unsigned char*>(root_certs), root_certs_length, - reinterpret_cast<unsigned char*>(private_key), private_key_length, - reinterpret_cast<unsigned char*>(cert_chain), cert_chain_length))); + reinterpret_cast<unsigned char *>(root_certs), root_certs_length, + reinterpret_cast<unsigned char *>(private_key), private_key_length, + reinterpret_cast<unsigned char *>(cert_chain), cert_chain_length))); } NAN_METHOD(Credentials::CreateComposite) { @@ -196,17 +194,15 @@ NAN_METHOD(Credentials::CreateFake) { NAN_METHOD(Credentials::CreateIam) { NanScope(); if (!args[0]->IsString()) { - return NanThrowTypeError( - "createIam's first argument must be a string"); + return NanThrowTypeError("createIam's first argument must be a string"); } if (!args[1]->IsString()) { - return NanThrowTypeError( - "createIam's second argument must be a string"); + return NanThrowTypeError("createIam's second argument must be a string"); } NanUtf8String auth_token(args[0]); NanUtf8String auth_selector(args[1]); - NanReturnValue(WrapStruct(grpc_iam_credentials_create(*auth_token, - *auth_selector))); + NanReturnValue( + WrapStruct(grpc_iam_credentials_create(*auth_token, *auth_selector))); } } // namespace node diff --git a/src/node/credentials.h b/src/node/credentials.h index a9c35b8a96..981e5a99bc 100644 --- a/src/node/credentials.h +++ b/src/node/credentials.h @@ -58,8 +58,8 @@ class Credentials : public ::node::ObjectWrap { ~Credentials(); // Prevent copying - Credentials(const Credentials&); - Credentials& operator=(const Credentials&); + Credentials(const Credentials &); + Credentials &operator=(const Credentials &); static NAN_METHOD(New); static NAN_METHOD(CreateDefault); diff --git a/src/node/event.cc b/src/node/event.cc index 61b2e82fdd..2ca38b7448 100644 --- a/src/node/event.cc +++ b/src/node/event.cc @@ -77,20 +77,19 @@ Handle<Value> GetEventData(grpc_event *event) { Handle<Object> item_obj = NanNew<Object>(); item_obj->Set(NanNew<String, const char *>("key"), NanNew<String, char *>(items[i].key)); - item_obj->Set(NanNew<String, const char *>("value"), - NanNew<String, char *>( - items[i].value, - static_cast<int>(items[i].value_length))); + item_obj->Set( + NanNew<String, const char *>("value"), + NanNew<String, char *>(items[i].value, + static_cast<int>(items[i].value_length))); metadata->Set(i, item_obj); } return NanEscapeScope(metadata); case GRPC_FINISHED: status = NanNew<Object>(); - status->Set(NanNew("code"), NanNew<Number>( - event->data.finished.status)); + status->Set(NanNew("code"), NanNew<Number>(event->data.finished.status)); if (event->data.finished.details != NULL) { - status->Set(NanNew("details"), String::New( - event->data.finished.details)); + status->Set(NanNew("details"), + String::New(event->data.finished.details)); } count = event->data.finished.metadata_count; items = event->data.finished.metadata_elements; @@ -99,10 +98,10 @@ Handle<Value> GetEventData(grpc_event *event) { Handle<Object> item_obj = NanNew<Object>(); item_obj->Set(NanNew<String, const char *>("key"), NanNew<String, char *>(items[i].key)); - item_obj->Set(NanNew<String, const char *>("value"), - NanNew<String, char *>( - items[i].value, - static_cast<int>(items[i].value_length))); + item_obj->Set( + NanNew<String, const char *>("value"), + NanNew<String, char *>(items[i].value, + static_cast<int>(items[i].value_length))); metadata->Set(i, item_obj); } status->Set(NanNew("metadata"), metadata); @@ -112,12 +111,12 @@ Handle<Value> GetEventData(grpc_event *event) { if (event->data.server_rpc_new.method == NULL) { return NanEscapeScope(NanNull()); } - rpc_new->Set(NanNew<String, const char *>("method"), - NanNew<String, const char *>( - event->data.server_rpc_new.method)); - rpc_new->Set(NanNew<String, const char *>("host"), - NanNew<String, const char *>( - event->data.server_rpc_new.host)); + rpc_new->Set( + NanNew<String, const char *>("method"), + NanNew<String, const char *>(event->data.server_rpc_new.method)); + rpc_new->Set( + NanNew<String, const char *>("host"), + NanNew<String, const char *>(event->data.server_rpc_new.host)); rpc_new->Set(NanNew<String, const char *>("absolute_deadline"), NanNew<Date>(TimespecToMilliseconds( event->data.server_rpc_new.deadline))); @@ -128,10 +127,10 @@ Handle<Value> GetEventData(grpc_event *event) { Handle<Object> item_obj = Object::New(); item_obj->Set(NanNew<String, const char *>("key"), NanNew<String, char *>(items[i].key)); - item_obj->Set(NanNew<String, const char *>("value"), - NanNew<String, char *>( - items[i].value, - static_cast<int>(items[i].value_length))); + item_obj->Set( + NanNew<String, const char *>("value"), + NanNew<String, char *>(items[i].value, + static_cast<int>(items[i].value_length))); metadata->Set(i, item_obj); } rpc_new->Set(NanNew<String, const char *>("metadata"), metadata); diff --git a/src/node/node_grpc.cc b/src/node/node_grpc.cc index b3f0546338..acee0386d2 100644 --- a/src/node/node_grpc.cc +++ b/src/node/node_grpc.cc @@ -124,8 +124,7 @@ void InitCallErrorConstants(Handle<Object> exports) { call_error->Set(NanNew("ALREADY_FINISHED"), ALREADY_FINISHED); Handle<Value> TOO_MANY_OPERATIONS( NanNew<Uint32, uint32_t>(GRPC_CALL_ERROR_TOO_MANY_OPERATIONS)); - call_error->Set(NanNew("TOO_MANY_OPERATIONS"), - TOO_MANY_OPERATIONS); + call_error->Set(NanNew("TOO_MANY_OPERATIONS"), TOO_MANY_OPERATIONS); Handle<Value> INVALID_FLAGS( NanNew<Uint32, uint32_t>(GRPC_CALL_ERROR_INVALID_FLAGS)); call_error->Set(NanNew("INVALID_FLAGS"), INVALID_FLAGS); @@ -157,8 +156,7 @@ void InitCompletionTypeConstants(Handle<Object> exports) { completion_type->Set(NanNew("FINISH_ACCEPTED"), FINISH_ACCEPTED); Handle<Value> CLIENT_METADATA_READ( NanNew<Uint32, uint32_t>(GRPC_CLIENT_METADATA_READ)); - completion_type->Set(NanNew("CLIENT_METADATA_READ"), - CLIENT_METADATA_READ); + completion_type->Set(NanNew("CLIENT_METADATA_READ"), CLIENT_METADATA_READ); Handle<Value> FINISHED(NanNew<Uint32, uint32_t>(GRPC_FINISHED)); completion_type->Set(NanNew("FINISHED"), FINISHED); Handle<Value> SERVER_RPC_NEW(NanNew<Uint32, uint32_t>(GRPC_SERVER_RPC_NEW)); diff --git a/src/node/server.cc b/src/node/server.cc index e2f0563fda..64826897cd 100644 --- a/src/node/server.cc +++ b/src/node/server.cc @@ -67,12 +67,9 @@ using v8::Value; Persistent<Function> Server::constructor; Persistent<FunctionTemplate> Server::fun_tpl; -Server::Server(grpc_server *server) : wrapped_server(server) { -} +Server::Server(grpc_server *server) : wrapped_server(server) {} -Server::~Server() { - grpc_server_destroy(wrapped_server); -} +Server::~Server() { grpc_server_destroy(wrapped_server); } void Server::Init(Handle<Object> exports) { NanScope(); @@ -85,9 +82,9 @@ void Server::Init(Handle<Object> exports) { NanSetPrototypeTemplate(tpl, "addHttp2Port", FunctionTemplate::New(AddHttp2Port)->GetFunction()); - NanSetPrototypeTemplate(tpl, "addSecureHttp2Port", - FunctionTemplate::New( - AddSecureHttp2Port)->GetFunction()); + NanSetPrototypeTemplate( + tpl, "addSecureHttp2Port", + FunctionTemplate::New(AddSecureHttp2Port)->GetFunction()); NanSetPrototypeTemplate(tpl, "start", FunctionTemplate::New(Start)->GetFunction()); @@ -111,7 +108,7 @@ NAN_METHOD(Server::New) { the result */ if (!args.IsConstructCall()) { const int argc = 1; - Local<Value> argv[argc] = { args[0] }; + Local<Value> argv[argc] = {args[0]}; NanReturnValue(constructor->NewInstance(argc, argv)); } grpc_server *wrapped_server; @@ -127,20 +124,20 @@ NAN_METHOD(Server::New) { return NanThrowTypeError( "credentials arg must be a ServerCredentials object"); } - ServerCredentials *creds_object = ObjectWrap::Unwrap<ServerCredentials>( - creds_value->ToObject()); + ServerCredentials *creds_object = + ObjectWrap::Unwrap<ServerCredentials>(creds_value->ToObject()); creds = creds_object->GetWrappedServerCredentials(); args_hash->Delete(NanNew("credentials")); } Handle<Array> keys(args_hash->GetOwnPropertyNames()); grpc_channel_args channel_args; channel_args.num_args = keys->Length(); - channel_args.args = reinterpret_cast<grpc_arg*>( + channel_args.args = reinterpret_cast<grpc_arg *>( calloc(channel_args.num_args, sizeof(grpc_arg))); /* These are used to keep all strings until then end of the block, then destroy them */ - std::vector<NanUtf8String*> key_strings(keys->Length()); - std::vector<NanUtf8String*> value_strings(keys->Length()); + std::vector<NanUtf8String *> key_strings(keys->Length()); + std::vector<NanUtf8String *> value_strings(keys->Length()); for (unsigned int i = 0; i < channel_args.num_args; i++) { Handle<String> current_key(keys->Get(i)->ToString()); Handle<Value> current_value(args_hash->Get(current_key)); @@ -159,12 +156,9 @@ NAN_METHOD(Server::New) { } } if (creds == NULL) { - wrapped_server = grpc_server_create(queue, - &channel_args); + wrapped_server = grpc_server_create(queue, &channel_args); } else { - wrapped_server = grpc_secure_server_create(creds, - queue, - &channel_args); + wrapped_server = grpc_secure_server_create(creds, queue, &channel_args); } free(channel_args.args); } else { @@ -182,8 +176,7 @@ NAN_METHOD(Server::RequestCall) { } Server *server = ObjectWrap::Unwrap<Server>(args.This()); grpc_call_error error = grpc_server_request_call( - server->wrapped_server, - CreateTag(args[0], NanNull())); + server->wrapped_server, CreateTag(args[0], NanNull())); if (error == GRPC_CALL_OK) { CompletionQueueAsyncWorker::Next(); } else { @@ -202,8 +195,7 @@ NAN_METHOD(Server::AddHttp2Port) { } Server *server = ObjectWrap::Unwrap<Server>(args.This()); NanReturnValue(NanNew<Boolean>(grpc_server_add_http2_port( - server->wrapped_server, - *NanUtf8String(args[0])))); + server->wrapped_server, *NanUtf8String(args[0])))); } NAN_METHOD(Server::AddSecureHttp2Port) { @@ -217,8 +209,7 @@ NAN_METHOD(Server::AddSecureHttp2Port) { } Server *server = ObjectWrap::Unwrap<Server>(args.This()); NanReturnValue(NanNew<Boolean>(grpc_server_add_secure_http2_port( - server->wrapped_server, - *NanUtf8String(args[0])))); + server->wrapped_server, *NanUtf8String(args[0])))); } NAN_METHOD(Server::Start) { diff --git a/src/node/server.h b/src/node/server.h index a54024555d..d50f1fb6c5 100644 --- a/src/node/server.h +++ b/src/node/server.h @@ -58,8 +58,8 @@ class Server : public ::node::ObjectWrap { ~Server(); // Prevent copying - Server(const Server&); - Server& operator=(const Server&); + Server(const Server &); + Server &operator=(const Server &); static NAN_METHOD(New); static NAN_METHOD(RequestCall); diff --git a/src/node/server_credentials.cc b/src/node/server_credentials.cc index fa9425b5c7..38df547527 100644 --- a/src/node/server_credentials.cc +++ b/src/node/server_credentials.cc @@ -60,8 +60,7 @@ Persistent<Function> ServerCredentials::constructor; Persistent<FunctionTemplate> ServerCredentials::fun_tpl; ServerCredentials::ServerCredentials(grpc_server_credentials *credentials) - : wrapped_credentials(credentials) { -} + : wrapped_credentials(credentials) {} ServerCredentials::~ServerCredentials() { gpr_log(GPR_DEBUG, "Destroying server credentials object"); @@ -95,7 +94,7 @@ Handle<Value> ServerCredentials::WrapStruct( } const int argc = 1; Handle<Value> argv[argc] = { - External::New(reinterpret_cast<void*>(credentials)) }; + External::New(reinterpret_cast<void *>(credentials))}; return NanEscapeScope(constructor->NewInstance(argc, argv)); } @@ -112,13 +111,13 @@ NAN_METHOD(ServerCredentials::New) { "ServerCredentials can only be created with the provide functions"); } grpc_server_credentials *creds_value = - reinterpret_cast<grpc_server_credentials*>(External::Unwrap(args[0])); + reinterpret_cast<grpc_server_credentials *>(External::Unwrap(args[0])); ServerCredentials *credentials = new ServerCredentials(creds_value); credentials->Wrap(args.This()); NanReturnValue(args.This()); } else { const int argc = 1; - Local<Value> argv[argc] = { args[0] }; + Local<Value> argv[argc] = {args[0]}; NanReturnValue(constructor->NewInstance(argc, argv)); } } @@ -137,27 +136,25 @@ NAN_METHOD(ServerCredentials::CreateSsl) { "createSSl's first argument must be a Buffer if provided"); } if (!Buffer::HasInstance(args[1])) { - return NanThrowTypeError( - "createSsl's second argument must be a Buffer"); + return NanThrowTypeError("createSsl's second argument must be a Buffer"); } private_key = Buffer::Data(args[1]); private_key_length = Buffer::Length(args[1]); if (!Buffer::HasInstance(args[2])) { - return NanThrowTypeError( - "createSsl's third argument must be a Buffer"); + return NanThrowTypeError("createSsl's third argument must be a Buffer"); } cert_chain = Buffer::Data(args[2]); cert_chain_length = Buffer::Length(args[2]); NanReturnValue(WrapStruct(grpc_ssl_server_credentials_create( - reinterpret_cast<unsigned char*>(root_certs), root_certs_length, - reinterpret_cast<unsigned char*>(private_key), private_key_length, - reinterpret_cast<unsigned char*>(cert_chain), cert_chain_length))); + reinterpret_cast<unsigned char *>(root_certs), root_certs_length, + reinterpret_cast<unsigned char *>(private_key), private_key_length, + reinterpret_cast<unsigned char *>(cert_chain), cert_chain_length))); } NAN_METHOD(ServerCredentials::CreateFake) { NanScope(); - NanReturnValue(WrapStruct( - grpc_fake_transport_security_server_credentials_create())); + NanReturnValue( + WrapStruct(grpc_fake_transport_security_server_credentials_create())); } } // namespace node diff --git a/src/node/server_credentials.h b/src/node/server_credentials.h index 0052c480e4..8baae3f185 100644 --- a/src/node/server_credentials.h +++ b/src/node/server_credentials.h @@ -58,8 +58,8 @@ class ServerCredentials : public ::node::ObjectWrap { ~ServerCredentials(); // Prevent copying - ServerCredentials(const ServerCredentials&); - ServerCredentials& operator=(const ServerCredentials&); + ServerCredentials(const ServerCredentials &); + ServerCredentials &operator=(const ServerCredentials &); static NAN_METHOD(New); static NAN_METHOD(CreateSsl); diff --git a/src/node/tag.cc b/src/node/tag.cc index 0a663505a0..dc8e523e12 100644 --- a/src/node/tag.cc +++ b/src/node/tag.cc @@ -46,8 +46,7 @@ using v8::Value; struct tag { tag(Persistent<Value> *tag, Persistent<Value> *call) - : persist_tag(tag), persist_call(call) { - } + : persist_tag(tag), persist_call(call) {} ~tag() { persist_tag->Dispose(); @@ -71,24 +70,24 @@ void *CreateTag(Handle<Value> tag, Handle<Value> call) { NanAssignPersistent(*persist_call, call); } struct tag *tag_struct = new struct tag(persist_tag, persist_call); - return reinterpret_cast<void*>(tag_struct); + return reinterpret_cast<void *>(tag_struct); } Handle<Value> GetTagHandle(void *tag) { NanEscapableScope(); - struct tag *tag_struct = reinterpret_cast<struct tag*>(tag); + struct tag *tag_struct = reinterpret_cast<struct tag *>(tag); Handle<Value> tag_value = NanNew<Value>(*tag_struct->persist_tag); return NanEscapeScope(tag_value); } bool TagHasCall(void *tag) { - struct tag *tag_struct = reinterpret_cast<struct tag*>(tag); + struct tag *tag_struct = reinterpret_cast<struct tag *>(tag); return tag_struct->persist_call != NULL; } Handle<Value> TagGetCall(void *tag) { NanEscapableScope(); - struct tag *tag_struct = reinterpret_cast<struct tag*>(tag); + struct tag *tag_struct = reinterpret_cast<struct tag *>(tag); if (tag_struct->persist_call == NULL) { return NanEscapeScope(NanNull()); } @@ -96,9 +95,7 @@ Handle<Value> TagGetCall(void *tag) { return NanEscapeScope(call_value); } -void DestroyTag(void *tag) { - delete reinterpret_cast<struct tag*>(tag); -} +void DestroyTag(void *tag) { delete reinterpret_cast<struct tag *>(tag); } } // namespace node } // namespace grpc diff --git a/src/node/timeval.cc b/src/node/timeval.cc index 30a4532559..687e33576b 100644 --- a/src/node/timeval.cc +++ b/src/node/timeval.cc @@ -46,7 +46,7 @@ gpr_timespec MillisecondsToTimespec(double millis) { } else if (millis == -std::numeric_limits<double>::infinity()) { return gpr_inf_past; } else { - return gpr_time_from_micros(static_cast<int64_t>(millis*1000)); + return gpr_time_from_micros(static_cast<int64_t>(millis * 1000)); } } |