diff --git a/src/node/byte_buffer.cc b/src/node/byte_buffer.cc index cd70486ccbf..142951475a1 100644 --- a/src/node/byte_buffer.cc +++ b/src/node/byte_buffer.cc @@ -65,12 +65,12 @@ Handle ByteBufferToBuffer(grpc_byte_buffer *buffer) { NanReturnNull(); } size_t length = grpc_byte_buffer_length(buffer); - char *result = reinterpret_cast(calloc(length, sizeof(char))); + char *result = reinterpret_cast(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 850f7cd9b97..b8ee1786a68 100644 --- a/src/node/call.cc +++ b/src/node/call.cc @@ -67,12 +67,9 @@ using v8::Value; Persistent Call::constructor; Persistent 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 exports) { NanScope(); @@ -86,8 +83,7 @@ void Call::Init(Handle 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 Call::WrapStruct(grpc_call *call) { return NanEscapeScope(NanNull()); } const int argc = 1; - Handle argv[argc] = { External::New(reinterpret_cast(call)) }; + Handle argv[argc] = {External::New(reinterpret_cast(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( - External::Unwrap(args[0])); + grpc_call *call_value = + reinterpret_cast(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 argv[argc] = { args[0], args[1], args[2], args[3] }; + Local 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(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(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(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(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(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(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(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(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 5777b3413cb..55a6fc65b84 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 c64b8eb7837..9087d6f919b 100644 --- a/src/node/channel.cc +++ b/src/node/channel.cc @@ -63,8 +63,7 @@ Persistent Channel::constructor; Persistent 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 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( - creds_value->ToObject()); + Credentials *creds_object = + ObjectWrap::Unwrap(creds_value->ToObject()); creds = creds_object->GetWrappedCredentials(); args_hash->Delete(NanNew("credentials")); } Handle keys(args_hash->GetOwnPropertyNames()); grpc_channel_args channel_args; channel_args.num_args = keys->Length(); - channel_args.args = reinterpret_cast( + channel_args.args = reinterpret_cast( 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 key_strings(keys->Length()); - std::vector value_strings(keys->Length()); + std::vector key_strings(keys->Length()); + std::vector value_strings(keys->Length()); for (unsigned int i = 0; i < channel_args.num_args; i++) { Handle current_key(keys->Get(i)->ToString()); Handle 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 argv[argc] = { args[0], args[1] }; + Local argv[argc] = {args[0], args[1]}; NanReturnValue(constructor->NewInstance(argc, argv)); } } diff --git a/src/node/channel.h b/src/node/channel.h index 87e24df7f90..140cbf201a1 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 21842ffdb29..8de7db66d50 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 exports) { void CompletionQueueAsyncWorker::HandleOKCallback() { NanScope(); NanCallback event_callback(GetTagHandle(result->tag).As()); - Handle argv[] = { - CreateEventObject(result) - }; + Handle argv[] = {CreateEventObject(result)}; DestroyTag(result->tag); grpc_event_finish(result); diff --git a/src/node/credentials.cc b/src/node/credentials.cc index 95e7c3cd8ee..d58b7eda893 100644 --- a/src/node/credentials.cc +++ b/src/node/credentials.cc @@ -60,8 +60,7 @@ Persistent Credentials::constructor; Persistent 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 Credentials::WrapStruct(grpc_credentials *credentials) { } const int argc = 1; Handle argv[argc] = { - External::New(reinterpret_cast(credentials)) }; + External::New(reinterpret_cast(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( - External::Unwrap(args[0])); + grpc_credentials *creds_value = + reinterpret_cast(External::Unwrap(args[0])); Credentials *credentials = new Credentials(creds_value); credentials->Wrap(args.This()); NanReturnValue(args.This()); } else { const int argc = 1; - Local argv[argc] = { args[0] }; + Local 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(root_certs), root_certs_length, - reinterpret_cast(private_key), private_key_length, - reinterpret_cast(cert_chain), cert_chain_length))); + reinterpret_cast(root_certs), root_certs_length, + reinterpret_cast(private_key), private_key_length, + reinterpret_cast(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 a9c35b8a965..981e5a99bc7 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 61b2e82fdd9..2ca38b7448e 100644 --- a/src/node/event.cc +++ b/src/node/event.cc @@ -77,20 +77,19 @@ Handle GetEventData(grpc_event *event) { Handle item_obj = NanNew(); item_obj->Set(NanNew("key"), NanNew(items[i].key)); - item_obj->Set(NanNew("value"), - NanNew( - items[i].value, - static_cast(items[i].value_length))); + item_obj->Set( + NanNew("value"), + NanNew(items[i].value, + static_cast(items[i].value_length))); metadata->Set(i, item_obj); } return NanEscapeScope(metadata); case GRPC_FINISHED: status = NanNew(); - status->Set(NanNew("code"), NanNew( - event->data.finished.status)); + status->Set(NanNew("code"), NanNew(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 GetEventData(grpc_event *event) { Handle item_obj = NanNew(); item_obj->Set(NanNew("key"), NanNew(items[i].key)); - item_obj->Set(NanNew("value"), - NanNew( - items[i].value, - static_cast(items[i].value_length))); + item_obj->Set( + NanNew("value"), + NanNew(items[i].value, + static_cast(items[i].value_length))); metadata->Set(i, item_obj); } status->Set(NanNew("metadata"), metadata); @@ -112,12 +111,12 @@ Handle GetEventData(grpc_event *event) { if (event->data.server_rpc_new.method == NULL) { return NanEscapeScope(NanNull()); } - rpc_new->Set(NanNew("method"), - NanNew( - event->data.server_rpc_new.method)); - rpc_new->Set(NanNew("host"), - NanNew( - event->data.server_rpc_new.host)); + rpc_new->Set( + NanNew("method"), + NanNew(event->data.server_rpc_new.method)); + rpc_new->Set( + NanNew("host"), + NanNew(event->data.server_rpc_new.host)); rpc_new->Set(NanNew("absolute_deadline"), NanNew(TimespecToMilliseconds( event->data.server_rpc_new.deadline))); @@ -128,10 +127,10 @@ Handle GetEventData(grpc_event *event) { Handle item_obj = Object::New(); item_obj->Set(NanNew("key"), NanNew(items[i].key)); - item_obj->Set(NanNew("value"), - NanNew( - items[i].value, - static_cast(items[i].value_length))); + item_obj->Set( + NanNew("value"), + NanNew(items[i].value, + static_cast(items[i].value_length))); metadata->Set(i, item_obj); } rpc_new->Set(NanNew("metadata"), metadata); diff --git a/src/node/node_grpc.cc b/src/node/node_grpc.cc index b3f05463381..acee0386d20 100644 --- a/src/node/node_grpc.cc +++ b/src/node/node_grpc.cc @@ -124,8 +124,7 @@ void InitCallErrorConstants(Handle exports) { call_error->Set(NanNew("ALREADY_FINISHED"), ALREADY_FINISHED); Handle TOO_MANY_OPERATIONS( NanNew(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 INVALID_FLAGS( NanNew(GRPC_CALL_ERROR_INVALID_FLAGS)); call_error->Set(NanNew("INVALID_FLAGS"), INVALID_FLAGS); @@ -157,8 +156,7 @@ void InitCompletionTypeConstants(Handle exports) { completion_type->Set(NanNew("FINISH_ACCEPTED"), FINISH_ACCEPTED); Handle CLIENT_METADATA_READ( NanNew(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 FINISHED(NanNew(GRPC_FINISHED)); completion_type->Set(NanNew("FINISHED"), FINISHED); Handle SERVER_RPC_NEW(NanNew(GRPC_SERVER_RPC_NEW)); diff --git a/src/node/server.cc b/src/node/server.cc index e2f0563fdad..64826897cda 100644 --- a/src/node/server.cc +++ b/src/node/server.cc @@ -67,12 +67,9 @@ using v8::Value; Persistent Server::constructor; Persistent 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 exports) { NanScope(); @@ -85,9 +82,9 @@ void Server::Init(Handle 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 argv[argc] = { args[0] }; + Local 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( - creds_value->ToObject()); + ServerCredentials *creds_object = + ObjectWrap::Unwrap(creds_value->ToObject()); creds = creds_object->GetWrappedServerCredentials(); args_hash->Delete(NanNew("credentials")); } Handle keys(args_hash->GetOwnPropertyNames()); grpc_channel_args channel_args; channel_args.num_args = keys->Length(); - channel_args.args = reinterpret_cast( + channel_args.args = reinterpret_cast( 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 key_strings(keys->Length()); - std::vector value_strings(keys->Length()); + std::vector key_strings(keys->Length()); + std::vector value_strings(keys->Length()); for (unsigned int i = 0; i < channel_args.num_args; i++) { Handle current_key(keys->Get(i)->ToString()); Handle 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(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(args.This()); NanReturnValue(NanNew(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(args.This()); NanReturnValue(NanNew(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 a54024555da..d50f1fb6c5e 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 fa9425b5c7c..38df5475278 100644 --- a/src/node/server_credentials.cc +++ b/src/node/server_credentials.cc @@ -60,8 +60,7 @@ Persistent ServerCredentials::constructor; Persistent 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 ServerCredentials::WrapStruct( } const int argc = 1; Handle argv[argc] = { - External::New(reinterpret_cast(credentials)) }; + External::New(reinterpret_cast(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(External::Unwrap(args[0])); + reinterpret_cast(External::Unwrap(args[0])); ServerCredentials *credentials = new ServerCredentials(creds_value); credentials->Wrap(args.This()); NanReturnValue(args.This()); } else { const int argc = 1; - Local argv[argc] = { args[0] }; + Local 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(root_certs), root_certs_length, - reinterpret_cast(private_key), private_key_length, - reinterpret_cast(cert_chain), cert_chain_length))); + reinterpret_cast(root_certs), root_certs_length, + reinterpret_cast(private_key), private_key_length, + reinterpret_cast(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 0052c480e4f..8baae3f185a 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 0a663505a0c..dc8e523e12e 100644 --- a/src/node/tag.cc +++ b/src/node/tag.cc @@ -46,8 +46,7 @@ using v8::Value; struct tag { tag(Persistent *tag, Persistent *call) - : persist_tag(tag), persist_call(call) { - } + : persist_tag(tag), persist_call(call) {} ~tag() { persist_tag->Dispose(); @@ -71,24 +70,24 @@ void *CreateTag(Handle tag, Handle call) { NanAssignPersistent(*persist_call, call); } struct tag *tag_struct = new struct tag(persist_tag, persist_call); - return reinterpret_cast(tag_struct); + return reinterpret_cast(tag_struct); } Handle GetTagHandle(void *tag) { NanEscapableScope(); - struct tag *tag_struct = reinterpret_cast(tag); + struct tag *tag_struct = reinterpret_cast(tag); Handle tag_value = NanNew(*tag_struct->persist_tag); return NanEscapeScope(tag_value); } bool TagHasCall(void *tag) { - struct tag *tag_struct = reinterpret_cast(tag); + struct tag *tag_struct = reinterpret_cast(tag); return tag_struct->persist_call != NULL; } Handle TagGetCall(void *tag) { NanEscapableScope(); - struct tag *tag_struct = reinterpret_cast(tag); + struct tag *tag_struct = reinterpret_cast(tag); if (tag_struct->persist_call == NULL) { return NanEscapeScope(NanNull()); } @@ -96,9 +95,7 @@ Handle TagGetCall(void *tag) { return NanEscapeScope(call_value); } -void DestroyTag(void *tag) { - delete reinterpret_cast(tag); -} +void DestroyTag(void *tag) { delete reinterpret_cast(tag); } } // namespace node } // namespace grpc diff --git a/src/node/timeval.cc b/src/node/timeval.cc index 30a45325590..687e33576b4 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::infinity()) { return gpr_inf_past; } else { - return gpr_time_from_micros(static_cast(millis*1000)); + return gpr_time_from_micros(static_cast(millis * 1000)); } }