diff options
author | Craig Tiller <ctiller@google.com> | 2017-11-03 09:09:36 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2017-11-03 09:09:36 -0700 |
commit | baa14a975ef92ee6fb301f0e684f56f18f2c55a7 (patch) | |
tree | 9a6cb2df58fe175e8abfccf2cbd40349726e46f3 /src/node/ext | |
parent | ef68fe7239a89095f1eaa89c1dd28b2b7be2a3c7 (diff) |
Update clang-format to 5.0
Diffstat (limited to 'src/node/ext')
-rw-r--r-- | src/node/ext/byte_buffer.cc | 18 | ||||
-rw-r--r-- | src/node/ext/byte_buffer.h | 4 | ||||
-rw-r--r-- | src/node/ext/call.cc | 97 | ||||
-rw-r--r-- | src/node/ext/call.h | 38 | ||||
-rw-r--r-- | src/node/ext/call_credentials.cc | 72 | ||||
-rw-r--r-- | src/node/ext/call_credentials.h | 32 | ||||
-rw-r--r-- | src/node/ext/channel.cc | 40 | ||||
-rw-r--r-- | src/node/ext/channel.h | 16 | ||||
-rw-r--r-- | src/node/ext/channel_credentials.cc | 26 | ||||
-rw-r--r-- | src/node/ext/channel_credentials.h | 14 | ||||
-rw-r--r-- | src/node/ext/completion_queue.cc | 10 | ||||
-rw-r--r-- | src/node/ext/completion_queue.h | 2 | ||||
-rw-r--r-- | src/node/ext/node_grpc.cc | 30 | ||||
-rw-r--r-- | src/node/ext/server.cc | 50 | ||||
-rw-r--r-- | src/node/ext/server.h | 12 | ||||
-rw-r--r-- | src/node/ext/server_credentials.cc | 22 | ||||
-rw-r--r-- | src/node/ext/server_credentials.h | 14 | ||||
-rw-r--r-- | src/node/ext/slice.cc | 22 |
18 files changed, 259 insertions, 260 deletions
diff --git a/src/node/ext/byte_buffer.cc b/src/node/ext/byte_buffer.cc index 1040f70d71..598b70946c 100644 --- a/src/node/ext/byte_buffer.cc +++ b/src/node/ext/byte_buffer.cc @@ -35,27 +35,27 @@ using Nan::MaybeLocal; using v8::Function; using v8::Local; -using v8::Object; using v8::Number; +using v8::Object; using v8::Value; -grpc_byte_buffer *BufferToByteBuffer(Local<Value> buffer) { +grpc_byte_buffer* BufferToByteBuffer(Local<Value> buffer) { Nan::HandleScope scope; grpc_slice slice = CreateSliceFromBuffer(buffer); - grpc_byte_buffer *byte_buffer(grpc_raw_byte_buffer_create(&slice, 1)); + grpc_byte_buffer* byte_buffer(grpc_raw_byte_buffer_create(&slice, 1)); grpc_slice_unref(slice); return byte_buffer; } namespace { -void delete_buffer(char *data, void *hint) { - grpc_slice *slice = static_cast<grpc_slice *>(hint); +void delete_buffer(char* data, void* hint) { + grpc_slice* slice = static_cast<grpc_slice*>(hint); grpc_slice_unref(*slice); delete slice; } -} +} // namespace -Local<Value> ByteBufferToBuffer(grpc_byte_buffer *buffer) { +Local<Value> ByteBufferToBuffer(grpc_byte_buffer* buffer) { Nan::EscapableHandleScope scope; if (buffer == NULL) { return scope.Escape(Nan::Null()); @@ -65,10 +65,10 @@ Local<Value> ByteBufferToBuffer(grpc_byte_buffer *buffer) { Nan::ThrowError("Error initializing byte buffer reader."); return scope.Escape(Nan::Undefined()); } - grpc_slice *slice = new grpc_slice; + grpc_slice* slice = new grpc_slice; *slice = grpc_byte_buffer_reader_readall(&reader); grpc_byte_buffer_reader_destroy(&reader); - char *result = reinterpret_cast<char *>(GRPC_SLICE_START_PTR(*slice)); + char* result = reinterpret_cast<char*>(GRPC_SLICE_START_PTR(*slice)); size_t length = GRPC_SLICE_LENGTH(*slice); Local<Value> buf = Nan::NewBuffer(result, length, delete_buffer, slice).ToLocalChecked(); diff --git a/src/node/ext/byte_buffer.h b/src/node/ext/byte_buffer.h index 6223147607..854e374a45 100644 --- a/src/node/ext/byte_buffer.h +++ b/src/node/ext/byte_buffer.h @@ -30,10 +30,10 @@ namespace node { /* Convert a Node.js Buffer to grpc_byte_buffer. Requires that ::node::Buffer::HasInstance(buffer) */ -grpc_byte_buffer *BufferToByteBuffer(v8::Local<v8::Value> buffer); +grpc_byte_buffer* BufferToByteBuffer(v8::Local<v8::Value> buffer); /* Convert a grpc_byte_buffer to a Node.js Buffer */ -v8::Local<v8::Value> ByteBufferToBuffer(grpc_byte_buffer *buffer); +v8::Local<v8::Value> ByteBufferToBuffer(grpc_byte_buffer* buffer); } // namespace node } // namespace grpc diff --git a/src/node/ext/call.cc b/src/node/ext/call.cc index 26095a78f9..1547f00519 100644 --- a/src/node/ext/call.cc +++ b/src/node/ext/call.cc @@ -35,8 +35,8 @@ #include "slice.h" #include "timeval.h" -using std::unique_ptr; using std::shared_ptr; +using std::unique_ptr; using std::vector; namespace grpc { @@ -62,11 +62,11 @@ using v8::Local; using v8::Number; using v8::Object; using v8::ObjectTemplate; -using v8::Uint32; using v8::String; +using v8::Uint32; using v8::Value; -Callback *Call::constructor; +Callback* Call::constructor; Persistent<FunctionTemplate> Call::fun_tpl; /** @@ -74,14 +74,14 @@ Persistent<FunctionTemplate> Call::fun_tpl; * Modified from the answer by Gus Goose to * http://stackoverflow.com/questions/31794200. */ -Local<Value> nanErrorWithCode(const char *msg, grpc_call_error code) { +Local<Value> nanErrorWithCode(const char* msg, grpc_call_error code) { EscapableHandleScope scope; Local<Object> err = Nan::Error(msg).As<Object>(); Nan::Set(err, Nan::New("code").ToLocalChecked(), Nan::New<Uint32>(code)); return scope.Escape(err); } -bool CreateMetadataArray(Local<Object> metadata, grpc_metadata_array *array) { +bool CreateMetadataArray(Local<Object> metadata, grpc_metadata_array* array) { HandleScope scope; Local<Array> keys = Nan::GetOwnPropertyNames(metadata).ToLocalChecked(); for (unsigned int i = 0; i < keys->Length(); i++) { @@ -93,7 +93,7 @@ bool CreateMetadataArray(Local<Object> metadata, grpc_metadata_array *array) { } array->capacity += Local<Array>::Cast(value_array)->Length(); } - array->metadata = reinterpret_cast<grpc_metadata *>( + array->metadata = reinterpret_cast<grpc_metadata*>( gpr_zalloc(array->capacity * sizeof(grpc_metadata))); for (unsigned int i = 0; i < keys->Length(); i++) { Local<String> current_key(Nan::To<String>(keys->Get(i)).ToLocalChecked()); @@ -104,7 +104,7 @@ bool CreateMetadataArray(Local<Object> metadata, grpc_metadata_array *array) { grpc_slice_unref(key_slice); for (unsigned int j = 0; j < values->Length(); j++) { Local<Value> value = Nan::Get(values, j).ToLocalChecked(); - grpc_metadata *current = &array->metadata[array->count]; + grpc_metadata* current = &array->metadata[array->count]; current->key = key_intern_slice; // Only allow binary headers for "-bin" keys if (grpc_is_binary_header(key_intern_slice)) { @@ -127,7 +127,7 @@ bool CreateMetadataArray(Local<Object> metadata, grpc_metadata_array *array) { return true; } -void DestroyMetadataArray(grpc_metadata_array *array) { +void DestroyMetadataArray(grpc_metadata_array* array) { for (size_t i = 0; i < array->count; i++) { // Don't unref keys because they are interned grpc_slice_unref(array->metadata[i].value); @@ -135,13 +135,13 @@ void DestroyMetadataArray(grpc_metadata_array *array) { grpc_metadata_array_destroy(array); } -Local<Value> ParseMetadata(const grpc_metadata_array *metadata_array) { +Local<Value> ParseMetadata(const grpc_metadata_array* metadata_array) { EscapableHandleScope scope; - grpc_metadata *metadata_elements = metadata_array->metadata; + grpc_metadata* metadata_elements = metadata_array->metadata; size_t length = metadata_array->count; Local<Object> metadata_object = Nan::New<Object>(); for (unsigned int i = 0; i < length; i++) { - grpc_metadata *elem = &metadata_elements[i]; + grpc_metadata* elem = &metadata_elements[i]; // TODO(murgatroid99): Use zero-copy string construction instead Local<String> key_string = CopyStringFromSlice(elem->key); Local<Array> array; @@ -177,7 +177,7 @@ class SendMetadataOp : public Op { EscapableHandleScope scope; return scope.Escape(Nan::True()); } - bool ParseOp(Local<Value> value, grpc_op *out) { + bool ParseOp(Local<Value> value, grpc_op* out) { if (!value->IsObject()) { return false; } @@ -214,7 +214,7 @@ class SendMessageOp : public Op { EscapableHandleScope scope; return scope.Escape(Nan::True()); } - bool ParseOp(Local<Value> value, grpc_op *out) { + bool ParseOp(Local<Value> value, grpc_op* out) { if (!::node::Buffer::HasInstance(value)) { return false; } @@ -240,7 +240,7 @@ class SendMessageOp : public Op { std::string GetTypeString() const { return "send_message"; } private: - grpc_byte_buffer *send_message; + grpc_byte_buffer* send_message; }; class SendClientCloseOp : public Op { @@ -250,7 +250,7 @@ class SendClientCloseOp : public Op { return scope.Escape(Nan::True()); } - bool ParseOp(Local<Value> value, grpc_op *out) { return true; } + bool ParseOp(Local<Value> value, grpc_op* out) { return true; } bool IsFinalOp() { return false; } void OnComplete(bool success) {} @@ -272,7 +272,7 @@ class SendServerStatusOp : public Op { EscapableHandleScope scope; return scope.Escape(Nan::True()); } - bool ParseOp(Local<Value> value, grpc_op *out) { + bool ParseOp(Local<Value> value, grpc_op* out) { if (!value->IsObject()) { return false; } @@ -341,7 +341,7 @@ class GetMetadataOp : public Op { return scope.Escape(ParseMetadata(&recv_metadata)); } - bool ParseOp(Local<Value> value, grpc_op *out) { + bool ParseOp(Local<Value> value, grpc_op* out) { out->data.recv_initial_metadata.recv_initial_metadata = &recv_metadata; return true; } @@ -368,7 +368,7 @@ class ReadMessageOp : public Op { return scope.Escape(ByteBufferToBuffer(recv_message)); } - bool ParseOp(Local<Value> value, grpc_op *out) { + bool ParseOp(Local<Value> value, grpc_op* out) { out->data.recv_message.recv_message = &recv_message; return true; } @@ -379,7 +379,7 @@ class ReadMessageOp : public Op { std::string GetTypeString() const { return "read"; } private: - grpc_byte_buffer *recv_message; + grpc_byte_buffer* recv_message; }; class ClientStatusOp : public Op { @@ -394,7 +394,7 @@ class ClientStatusOp : public Op { grpc_slice_unref(status_details); } - bool ParseOp(Local<Value> value, grpc_op *out) { + bool ParseOp(Local<Value> value, grpc_op* out) { out->data.recv_status_on_client.trailing_metadata = &metadata_array; out->data.recv_status_on_client.status = &status; out->data.recv_status_on_client.status_details = &status_details; @@ -431,7 +431,7 @@ class ServerCloseResponseOp : public Op { return scope.Escape(Nan::New<Boolean>(cancelled)); } - bool ParseOp(Local<Value> value, grpc_op *out) { + bool ParseOp(Local<Value> value, grpc_op* out) { out->data.recv_close_on_server.cancelled = &cancelled; return true; } @@ -445,7 +445,7 @@ class ServerCloseResponseOp : public Op { int cancelled; }; -tag::tag(Callback *callback, OpVec *ops, Call *call, Local<Value> call_value) +tag::tag(Callback* callback, OpVec* ops, Call* call, Local<Value> call_value) : callback(callback), ops(ops), call(call) { HandleScope scope; call_persist.Reset(call_value); @@ -456,15 +456,15 @@ tag::~tag() { delete ops; } -void CompleteTag(void *tag, const char *error_message) { +void CompleteTag(void* tag, const char* error_message) { HandleScope scope; - struct tag *tag_struct = reinterpret_cast<struct tag *>(tag); - Callback *callback = tag_struct->callback; + struct tag* tag_struct = reinterpret_cast<struct tag*>(tag); + Callback* callback = tag_struct->callback; if (error_message == NULL) { Local<Object> tag_obj = Nan::New<Object>(); for (vector<unique_ptr<Op> >::iterator it = tag_struct->ops->begin(); it != tag_struct->ops->end(); ++it) { - Op *op_ptr = it->get(); + Op* op_ptr = it->get(); Nan::Set(tag_obj, op_ptr->GetOpType(), op_ptr->GetNodeValue()); } Local<Value> argv[] = {Nan::Null(), tag_obj}; @@ -477,7 +477,7 @@ void CompleteTag(void *tag, const char *error_message) { bool is_final_op = false; for (vector<unique_ptr<Op> >::iterator it = tag_struct->ops->begin(); it != tag_struct->ops->end(); ++it) { - Op *op_ptr = it->get(); + Op* op_ptr = it->get(); op_ptr->OnComplete(success); if (op_ptr->IsFinalOp()) { is_final_op = true; @@ -489,8 +489,8 @@ void CompleteTag(void *tag, const char *error_message) { tag_struct->call->CompleteBatch(is_final_op); } -void DestroyTag(void *tag) { - struct tag *tag_struct = reinterpret_cast<struct tag *>(tag); +void DestroyTag(void* tag) { + struct tag* tag_struct = reinterpret_cast<struct tag*>(tag); delete tag_struct; } @@ -501,7 +501,7 @@ void Call::DestroyCall() { } } -Call::Call(grpc_call *call) +Call::Call(grpc_call* call) : wrapped_call(call), pending_batches(0), has_final_op_completed(false) { peer = grpc_call_get_peer(call); } @@ -532,14 +532,13 @@ bool Call::HasInstance(Local<Value> val) { return Nan::New(fun_tpl)->HasInstance(val); } -Local<Value> Call::WrapStruct(grpc_call *call) { +Local<Value> Call::WrapStruct(grpc_call* call) { EscapableHandleScope scope; if (call == NULL) { return scope.Escape(Nan::Null()); } const int argc = 1; - Local<Value> argv[argc] = { - Nan::New<External>(reinterpret_cast<void *>(call))}; + Local<Value> argv[argc] = {Nan::New<External>(reinterpret_cast<void*>(call))}; MaybeLocal<Object> maybe_instance = Nan::NewInstance(constructor->GetFunction(), argc, argv); if (maybe_instance.IsEmpty()) { @@ -569,11 +568,11 @@ NAN_METHOD(Call::New) { * 5: propagation flags */ if (info.IsConstructCall()) { - Call *call; + Call* call; if (info[0]->IsExternal()) { Local<External> ext = info[0].As<External>(); // This option is used for wrapping an existing call - grpc_call *call_value = reinterpret_cast<grpc_call *>(ext->Value()); + grpc_call* call_value = reinterpret_cast<grpc_call*>(ext->Value()); call = new Call(call_value); } else { if (!Channel::HasInstance(info[0])) { @@ -587,9 +586,9 @@ NAN_METHOD(Call::New) { "Call's third argument must be a date or a number"); } // These arguments are at the end because they are optional - grpc_call *parent_call = NULL; + grpc_call* parent_call = NULL; if (Call::HasInstance(info[4])) { - Call *parent_obj = + Call* parent_obj = ObjectWrap::Unwrap<Call>(Nan::To<Object>(info[4]).ToLocalChecked()); parent_call = parent_obj->wrapped_call; } else if (!(info[4]->IsUndefined() || info[4]->IsNull())) { @@ -604,17 +603,17 @@ NAN_METHOD(Call::New) { "Call's sixth argument must be propagate flags, if provided"); } Local<Object> channel_object = Nan::To<Object>(info[0]).ToLocalChecked(); - Channel *channel = ObjectWrap::Unwrap<Channel>(channel_object); + Channel* channel = ObjectWrap::Unwrap<Channel>(channel_object); if (channel->GetWrappedChannel() == NULL) { return Nan::ThrowError("Call cannot be created from a closed channel"); } double deadline = Nan::To<double>(info[2]).FromJust(); - grpc_channel *wrapped_channel = channel->GetWrappedChannel(); - grpc_call *wrapped_call; + grpc_channel* wrapped_channel = channel->GetWrappedChannel(); + grpc_call* wrapped_call; grpc_slice method = CreateSliceFromString(Nan::To<String>(info[1]).ToLocalChecked()); if (info[3]->IsString()) { - grpc_slice *host = new grpc_slice; + grpc_slice* host = new grpc_slice; *host = CreateSliceFromString(Nan::To<String>(info[3]).ToLocalChecked()); wrapped_call = grpc_channel_create_call( @@ -660,7 +659,7 @@ NAN_METHOD(Call::StartBatch) { return Nan::ThrowError("startBatch's second argument must be a callback"); } Local<Function> callback_func = info[1].As<Function>(); - Call *call = ObjectWrap::Unwrap<Call>(info.This()); + Call* call = ObjectWrap::Unwrap<Call>(info.This()); if (call->wrapped_call == NULL) { /* This implies that the call has completed and has been destroyed. To * emulate @@ -720,7 +719,7 @@ NAN_METHOD(Call::StartBatch) { } op_vector->push_back(std::move(op)); } - Callback *callback = new Callback(callback_func); + Callback* callback = new Callback(callback_func); grpc_call_error error = grpc_call_start_batch( call->wrapped_call, &ops[0], nops, new struct tag(callback, op_vector.release(), call, info.This()), NULL); @@ -735,7 +734,7 @@ NAN_METHOD(Call::Cancel) { if (!Call::HasInstance(info.This())) { return Nan::ThrowTypeError("cancel can only be called on Call objects"); } - Call *call = ObjectWrap::Unwrap<Call>(info.This()); + Call* call = ObjectWrap::Unwrap<Call>(info.This()); if (call->wrapped_call == NULL) { /* Cancel is supposed to be idempotent. If the call has already finished, * cancel should just complete silently */ @@ -760,7 +759,7 @@ NAN_METHOD(Call::CancelWithStatus) { return Nan::ThrowTypeError( "cancelWithStatus's second argument must be a string"); } - Call *call = ObjectWrap::Unwrap<Call>(info.This()); + Call* call = ObjectWrap::Unwrap<Call>(info.This()); if (call->wrapped_call == NULL) { /* Cancel is supposed to be idempotent. If the call has already finished, * cancel should just complete silently */ @@ -781,7 +780,7 @@ NAN_METHOD(Call::GetPeer) { if (!HasInstance(info.This())) { return Nan::ThrowTypeError("getPeer can only be called on Call objects"); } - Call *call = ObjectWrap::Unwrap<Call>(info.This()); + Call* call = ObjectWrap::Unwrap<Call>(info.This()); Local<Value> peer_value = Nan::New(call->peer).ToLocalChecked(); info.GetReturnValue().Set(peer_value); } @@ -796,14 +795,14 @@ NAN_METHOD(Call::SetCredentials) { return Nan::ThrowTypeError( "setCredentials' first argument must be a CallCredentials"); } - Call *call = ObjectWrap::Unwrap<Call>(info.This()); + Call* call = ObjectWrap::Unwrap<Call>(info.This()); if (call->wrapped_call == NULL) { return Nan::ThrowError( "Cannot set credentials on a call that has already started"); } - CallCredentials *creds_object = ObjectWrap::Unwrap<CallCredentials>( + CallCredentials* creds_object = ObjectWrap::Unwrap<CallCredentials>( Nan::To<Object>(info[0]).ToLocalChecked()); - grpc_call_credentials *creds = creds_object->GetWrappedCredentials(); + grpc_call_credentials* creds = creds_object->GetWrappedCredentials(); grpc_call_error error = GRPC_CALL_ERROR; if (creds) { error = grpc_call_set_credentials(call->wrapped_call, creds); diff --git a/src/node/ext/call.h b/src/node/ext/call.h index 50248c0bc6..a809a8b585 100644 --- a/src/node/ext/call.h +++ b/src/node/ext/call.h @@ -32,17 +32,17 @@ namespace grpc { namespace node { -using std::unique_ptr; using std::shared_ptr; +using std::unique_ptr; -v8::Local<v8::Value> nanErrorWithCode(const char *msg, grpc_call_error code); +v8::Local<v8::Value> nanErrorWithCode(const char* msg, grpc_call_error code); -v8::Local<v8::Value> ParseMetadata(const grpc_metadata_array *metadata_array); +v8::Local<v8::Value> ParseMetadata(const grpc_metadata_array* metadata_array); bool CreateMetadataArray(v8::Local<v8::Object> metadata, - grpc_metadata_array *array); + grpc_metadata_array* array); -void DestroyMetadataArray(grpc_metadata_array *array); +void DestroyMetadataArray(grpc_metadata_array* array); /* Wrapper class for grpc_call structs. */ class Call : public Nan::ObjectWrap { @@ -50,17 +50,17 @@ class Call : public Nan::ObjectWrap { 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::Local<v8::Value> WrapStruct(grpc_call *call); + static v8::Local<v8::Value> WrapStruct(grpc_call* call); void CompleteBatch(bool is_final_op); private: - explicit Call(grpc_call *call); + explicit Call(grpc_call* call); ~Call(); // Prevent copying - Call(const Call &); - Call &operator=(const Call &); + Call(const Call&); + Call& operator=(const Call&); void DestroyCall(); @@ -70,24 +70,24 @@ class Call : public Nan::ObjectWrap { static NAN_METHOD(CancelWithStatus); static NAN_METHOD(GetPeer); static NAN_METHOD(SetCredentials); - static Nan::Callback *constructor; + static Nan::Callback* constructor; // Used for typechecking instances of this javascript class static Nan::Persistent<v8::FunctionTemplate> fun_tpl; - grpc_call *wrapped_call; + grpc_call* wrapped_call; // The number of ops that were started but not completed on this call int pending_batches; /* Indicates whether the "final" op on a call has completed. For a client call, this is GRPC_OP_RECV_STATUS_ON_CLIENT and for a server call, this is GRPC_OP_SEND_STATUS_FROM_SERVER */ bool has_final_op_completed; - char *peer; + char* peer; }; class Op { public: virtual v8::Local<v8::Value> GetNodeValue() const = 0; - virtual bool ParseOp(v8::Local<v8::Value> value, grpc_op *out) = 0; + virtual bool ParseOp(v8::Local<v8::Value> value, grpc_op* out) = 0; virtual ~Op(); v8::Local<v8::Value> GetOpType() const; virtual bool IsFinalOp() = 0; @@ -99,19 +99,19 @@ class Op { typedef std::vector<unique_ptr<Op>> OpVec; struct tag { - tag(Nan::Callback *callback, OpVec *ops, Call *call, + tag(Nan::Callback* callback, OpVec* ops, Call* call, v8::Local<v8::Value> call_value); ~tag(); - Nan::Callback *callback; - OpVec *ops; - Call *call; + Nan::Callback* callback; + OpVec* ops; + Call* call; Nan::Persistent<v8::Value, Nan::CopyablePersistentTraits<v8::Value>> call_persist; }; -void DestroyTag(void *tag); +void DestroyTag(void* tag); -void CompleteTag(void *tag, const char *error_message); +void CompleteTag(void* tag, const char* error_message); } // namespace node } // namespace grpc diff --git a/src/node/ext/call_credentials.cc b/src/node/ext/call_credentials.cc index 0644a812e9..c5818a735b 100644 --- a/src/node/ext/call_credentials.cc +++ b/src/node/ext/call_credentials.cc @@ -50,12 +50,12 @@ using v8::Object; using v8::ObjectTemplate; using v8::Value; -Nan::Callback *CallCredentials::constructor; +Nan::Callback* CallCredentials::constructor; Persistent<FunctionTemplate> CallCredentials::fun_tpl; -static Callback *plugin_callback; +static Callback* plugin_callback; -CallCredentials::CallCredentials(grpc_call_credentials *credentials) +CallCredentials::CallCredentials(grpc_call_credentials* credentials) : wrapped_credentials(credentials) {} CallCredentials::~CallCredentials() { @@ -87,14 +87,14 @@ bool CallCredentials::HasInstance(Local<Value> val) { return Nan::New(fun_tpl)->HasInstance(val); } -Local<Value> CallCredentials::WrapStruct(grpc_call_credentials *credentials) { +Local<Value> CallCredentials::WrapStruct(grpc_call_credentials* credentials) { EscapableHandleScope scope; const int argc = 1; if (credentials == NULL) { return scope.Escape(Nan::Null()); } Local<Value> argv[argc] = { - Nan::New<External>(reinterpret_cast<void *>(credentials))}; + Nan::New<External>(reinterpret_cast<void*>(credentials))}; MaybeLocal<Object> maybe_instance = Nan::NewInstance(constructor->GetFunction(), argc, argv); if (maybe_instance.IsEmpty()) { @@ -104,7 +104,7 @@ Local<Value> CallCredentials::WrapStruct(grpc_call_credentials *credentials) { } } -grpc_call_credentials *CallCredentials::GetWrappedCredentials() { +grpc_call_credentials* CallCredentials::GetWrappedCredentials() { return wrapped_credentials; } @@ -115,9 +115,9 @@ NAN_METHOD(CallCredentials::New) { "CallCredentials can only be created with the provided functions"); } Local<External> ext = info[0].As<External>(); - grpc_call_credentials *creds_value = - reinterpret_cast<grpc_call_credentials *>(ext->Value()); - CallCredentials *credentials = new CallCredentials(creds_value); + grpc_call_credentials* creds_value = + reinterpret_cast<grpc_call_credentials*>(ext->Value()); + CallCredentials* credentials = new CallCredentials(creds_value); credentials->Wrap(info.This()); info.GetReturnValue().Set(info.This()); return; @@ -137,10 +137,10 @@ NAN_METHOD(CallCredentials::Compose) { return Nan::ThrowTypeError( "compose's first argument must be a CallCredentials object"); } - CallCredentials *self = ObjectWrap::Unwrap<CallCredentials>(info.This()); - CallCredentials *other = ObjectWrap::Unwrap<CallCredentials>( + CallCredentials* self = ObjectWrap::Unwrap<CallCredentials>(info.This()); + CallCredentials* other = ObjectWrap::Unwrap<CallCredentials>( Nan::To<Object>(info[0]).ToLocalChecked()); - grpc_call_credentials *creds = grpc_composite_call_credentials_create( + grpc_call_credentials* creds = grpc_composite_call_credentials_create( self->wrapped_credentials, other->wrapped_credentials, NULL); info.GetReturnValue().Set(WrapStruct(creds)); } @@ -151,20 +151,20 @@ NAN_METHOD(CallCredentials::CreateFromPlugin) { "createFromPlugin's argument must be a function"); } grpc_metadata_credentials_plugin plugin; - plugin_state *state = new plugin_state; + plugin_state* state = new plugin_state; state->callback = new Nan::Callback(info[0].As<Function>()); - state->pending_callbacks = new std::queue<plugin_callback_data *>(); + state->pending_callbacks = new std::queue<plugin_callback_data*>(); uv_mutex_init(&state->plugin_mutex); uv_async_init(uv_default_loop(), &state->plugin_async, SendPluginCallback); - uv_unref((uv_handle_t *)&state->plugin_async); + uv_unref((uv_handle_t*)&state->plugin_async); state->plugin_async.data = state; plugin.get_metadata = plugin_get_metadata; plugin.destroy = plugin_destroy_state; - plugin.state = reinterpret_cast<void *>(state); + plugin.state = reinterpret_cast<void*>(state); plugin.type = ""; - grpc_call_credentials *creds = + grpc_call_credentials* creds = grpc_metadata_credentials_create_from_plugin(plugin, NULL); info.GetReturnValue().Set(WrapStruct(creds)); } @@ -190,7 +190,7 @@ NAN_METHOD(PluginCallback) { grpc_status_code code = static_cast<grpc_status_code>(Nan::To<uint32_t>(info[0]).FromJust()); Utf8String details_utf8_str(info[1]); - char *details = *details_utf8_str; + char* details = *details_utf8_str; grpc_metadata_array array; grpc_metadata_array_init(&array); Local<Object> callback_data = Nan::To<Object>(info[3]).ToLocalChecked(); @@ -203,7 +203,7 @@ NAN_METHOD(PluginCallback) { .ToLocalChecked() .As<External>() ->Value()); - void *user_data = + void* user_data = Nan::Get(callback_data, Nan::New("user_data").ToLocalChecked()) .ToLocalChecked() .As<External>() @@ -214,17 +214,17 @@ NAN_METHOD(PluginCallback) { NAUV_WORK_CB(SendPluginCallback) { Nan::HandleScope scope; - plugin_state *state = reinterpret_cast<plugin_state *>(async->data); - std::queue<plugin_callback_data *> callbacks; + plugin_state* state = reinterpret_cast<plugin_state*>(async->data); + std::queue<plugin_callback_data*> callbacks; uv_mutex_lock(&state->plugin_mutex); state->pending_callbacks->swap(callbacks); uv_mutex_unlock(&state->plugin_mutex); while (!callbacks.empty()) { - plugin_callback_data *data = callbacks.front(); + plugin_callback_data* data = callbacks.front(); callbacks.pop(); Local<Object> callback_data = Nan::New<Object>(); Nan::Set(callback_data, Nan::New("cb").ToLocalChecked(), - Nan::New<v8::External>(reinterpret_cast<void *>(data->cb))); + Nan::New<v8::External>(reinterpret_cast<void*>(data->cb))); Nan::Set(callback_data, Nan::New("user_data").ToLocalChecked(), Nan::New<v8::External>(data->user_data)); const int argc = 3; @@ -232,20 +232,20 @@ NAUV_WORK_CB(SendPluginCallback) { Nan::New(data->service_url).ToLocalChecked(), callback_data, // Get Local<Function> from Nan::Callback* **plugin_callback}; - Nan::Callback *callback = state->callback; + Nan::Callback* callback = state->callback; callback->Call(argc, argv); delete data; } } int plugin_get_metadata( - void *state, grpc_auth_metadata_context context, - grpc_credentials_plugin_metadata_cb cb, void *user_data, + void* state, grpc_auth_metadata_context context, + grpc_credentials_plugin_metadata_cb cb, void* user_data, grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX], - size_t *num_creds_md, grpc_status_code *status, - const char **error_details) { - plugin_state *p_state = reinterpret_cast<plugin_state *>(state); - plugin_callback_data *data = new plugin_callback_data; + size_t* num_creds_md, grpc_status_code* status, + const char** error_details) { + plugin_state* p_state = reinterpret_cast<plugin_state*>(state); + plugin_callback_data* data = new plugin_callback_data; data->service_url = context.service_url; data->cb = cb; data->user_data = user_data; @@ -258,18 +258,18 @@ int plugin_get_metadata( return 0; // Async processing. } -void plugin_uv_close_cb(uv_handle_t *handle) { - uv_async_t *async = reinterpret_cast<uv_async_t *>(handle); - plugin_state *state = reinterpret_cast<plugin_state *>(async->data); +void plugin_uv_close_cb(uv_handle_t* handle) { + uv_async_t* async = reinterpret_cast<uv_async_t*>(handle); + plugin_state* state = reinterpret_cast<plugin_state*>(async->data); uv_mutex_destroy(&state->plugin_mutex); delete state->pending_callbacks; delete state->callback; delete state; } -void plugin_destroy_state(void *ptr) { - plugin_state *state = reinterpret_cast<plugin_state *>(ptr); - uv_close((uv_handle_t *)&state->plugin_async, plugin_uv_close_cb); +void plugin_destroy_state(void* ptr) { + plugin_state* state = reinterpret_cast<plugin_state*>(ptr); + uv_close((uv_handle_t*)&state->plugin_async, plugin_uv_close_cb); } } // namespace node diff --git a/src/node/ext/call_credentials.h b/src/node/ext/call_credentials.h index 3a54bbf0cf..6474ba5f12 100644 --- a/src/node/ext/call_credentials.h +++ b/src/node/ext/call_credentials.h @@ -34,60 +34,60 @@ class CallCredentials : public Nan::ObjectWrap { static void Init(v8::Local<v8::Object> exports); static bool HasInstance(v8::Local<v8::Value> val); /* Wrap a grpc_call_credentials struct in a javascript object */ - static v8::Local<v8::Value> WrapStruct(grpc_call_credentials *credentials); + static v8::Local<v8::Value> WrapStruct(grpc_call_credentials* credentials); /* Returns the grpc_call_credentials struct that this object wraps */ - grpc_call_credentials *GetWrappedCredentials(); + grpc_call_credentials* GetWrappedCredentials(); private: - explicit CallCredentials(grpc_call_credentials *credentials); + explicit CallCredentials(grpc_call_credentials* credentials); ~CallCredentials(); // Prevent copying - CallCredentials(const CallCredentials &); - CallCredentials &operator=(const CallCredentials &); + CallCredentials(const CallCredentials&); + CallCredentials& operator=(const CallCredentials&); static NAN_METHOD(New); static NAN_METHOD(CreateSsl); static NAN_METHOD(CreateFromPlugin); static NAN_METHOD(Compose); - static Nan::Callback *constructor; + static Nan::Callback* constructor; // Used for typechecking instances of this javascript class static Nan::Persistent<v8::FunctionTemplate> fun_tpl; - grpc_call_credentials *wrapped_credentials; + grpc_call_credentials* wrapped_credentials; }; /* Auth metadata plugin functionality */ typedef struct plugin_callback_data { - const char *service_url; + const char* service_url; grpc_credentials_plugin_metadata_cb cb; - void *user_data; + void* user_data; } plugin_callback_data; typedef struct plugin_state { - Nan::Callback *callback; - std::queue<plugin_callback_data *> *pending_callbacks; + Nan::Callback* callback; + std::queue<plugin_callback_data*>* pending_callbacks; uv_mutex_t plugin_mutex; // async.data == this uv_async_t plugin_async; } plugin_state; int plugin_get_metadata( - void *state, grpc_auth_metadata_context context, - grpc_credentials_plugin_metadata_cb cb, void *user_data, + void* state, grpc_auth_metadata_context context, + grpc_credentials_plugin_metadata_cb cb, void* user_data, grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX], - size_t *num_creds_md, grpc_status_code *status, const char **error_details); + size_t* num_creds_md, grpc_status_code* status, const char** error_details); -void plugin_destroy_state(void *state); +void plugin_destroy_state(void* state); NAN_METHOD(PluginCallback); NAUV_WORK_CB(SendPluginCallback); } // namespace node -} // namepsace grpc +} // namespace grpc #endif // GRPC_NODE_CALL_CREDENTIALS_H_ diff --git a/src/node/ext/channel.cc b/src/node/ext/channel.cc index fc085fa011..2c072d5113 100644 --- a/src/node/ext/channel.cc +++ b/src/node/ext/channel.cc @@ -53,11 +53,11 @@ using v8::Object; using v8::String; using v8::Value; -Callback *Channel::constructor; +Callback* Channel::constructor; Persistent<FunctionTemplate> Channel::fun_tpl; bool ParseChannelArgs(Local<Value> args_val, - grpc_channel_args **channel_args_ptr) { + grpc_channel_args** channel_args_ptr) { if (args_val->IsUndefined() || args_val->IsNull()) { *channel_args_ptr = NULL; return true; @@ -66,13 +66,13 @@ bool ParseChannelArgs(Local<Value> args_val, *channel_args_ptr = NULL; return false; } - grpc_channel_args *channel_args = - reinterpret_cast<grpc_channel_args *>(malloc(sizeof(grpc_channel_args))); + grpc_channel_args* channel_args = + reinterpret_cast<grpc_channel_args*>(malloc(sizeof(grpc_channel_args))); *channel_args_ptr = channel_args; Local<Object> args_hash = Nan::To<Object>(args_val).ToLocalChecked(); Local<Array> keys = Nan::GetOwnPropertyNames(args_hash).ToLocalChecked(); 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))); for (unsigned int i = 0; i < channel_args->num_args; i++) { Local<Value> key = Nan::Get(keys, i).ToLocalChecked(); @@ -89,7 +89,7 @@ bool ParseChannelArgs(Local<Value> args_val, Utf8String val_str(value); channel_args->args[i].type = GRPC_ARG_STRING; channel_args->args[i].value.string = - reinterpret_cast<char *>(calloc(val_str.length() + 1, sizeof(char))); + reinterpret_cast<char*>(calloc(val_str.length() + 1, sizeof(char))); memcpy(channel_args->args[i].value.string, *val_str, val_str.length() + 1); } else { @@ -97,13 +97,13 @@ bool ParseChannelArgs(Local<Value> args_val, return false; } channel_args->args[i].key = - reinterpret_cast<char *>(calloc(key_str.length() + 1, sizeof(char))); + reinterpret_cast<char*>(calloc(key_str.length() + 1, sizeof(char))); memcpy(channel_args->args[i].key, *key_str, key_str.length() + 1); } return true; } -void DeallocateChannelArgs(grpc_channel_args *channel_args) { +void DeallocateChannelArgs(grpc_channel_args* channel_args) { if (channel_args == NULL) { return; } @@ -122,7 +122,7 @@ void DeallocateChannelArgs(grpc_channel_args *channel_args) { free(channel_args); } -Channel::Channel(grpc_channel *channel) : wrapped_channel(channel) {} +Channel::Channel(grpc_channel* channel) : wrapped_channel(channel) {} Channel::~Channel() { gpr_log(GPR_DEBUG, "Destroying channel"); @@ -152,7 +152,7 @@ bool Channel::HasInstance(Local<Value> val) { return Nan::New(fun_tpl)->HasInstance(val); } -grpc_channel *Channel::GetWrappedChannel() { return this->wrapped_channel; } +grpc_channel* Channel::GetWrappedChannel() { return this->wrapped_channel; } NAN_METHOD(Channel::New) { if (info.IsConstructCall()) { @@ -160,18 +160,18 @@ NAN_METHOD(Channel::New) { return Nan::ThrowTypeError( "Channel expects a string, a credential and an object"); } - grpc_channel *wrapped_channel; + grpc_channel* wrapped_channel; // Owned by the Channel object Utf8String host(info[0]); - grpc_channel_credentials *creds; + grpc_channel_credentials* creds; if (!ChannelCredentials::HasInstance(info[1])) { return Nan::ThrowTypeError( "Channel's second argument must be a ChannelCredentials"); } - ChannelCredentials *creds_object = ObjectWrap::Unwrap<ChannelCredentials>( + ChannelCredentials* creds_object = ObjectWrap::Unwrap<ChannelCredentials>( Nan::To<Object>(info[1]).ToLocalChecked()); creds = creds_object->GetWrappedCredentials(); - grpc_channel_args *channel_args_ptr = NULL; + grpc_channel_args* channel_args_ptr = NULL; if (!ParseChannelArgs(info[2], &channel_args_ptr)) { DeallocateChannelArgs(channel_args_ptr); return Nan::ThrowTypeError( @@ -186,7 +186,7 @@ NAN_METHOD(Channel::New) { grpc_secure_channel_create(creds, *host, channel_args_ptr, NULL); } DeallocateChannelArgs(channel_args_ptr); - Channel *channel = new Channel(wrapped_channel); + Channel* channel = new Channel(wrapped_channel); channel->Wrap(info.This()); info.GetReturnValue().Set(info.This()); return; @@ -208,7 +208,7 @@ NAN_METHOD(Channel::Close) { if (!HasInstance(info.This())) { return Nan::ThrowTypeError("close can only be called on Channel objects"); } - Channel *channel = ObjectWrap::Unwrap<Channel>(info.This()); + Channel* channel = ObjectWrap::Unwrap<Channel>(info.This()); if (channel->wrapped_channel != NULL) { grpc_channel_destroy(channel->wrapped_channel); channel->wrapped_channel = NULL; @@ -220,7 +220,7 @@ NAN_METHOD(Channel::GetTarget) { return Nan::ThrowTypeError( "getTarget can only be called on Channel objects"); } - Channel *channel = ObjectWrap::Unwrap<Channel>(info.This()); + Channel* channel = ObjectWrap::Unwrap<Channel>(info.This()); info.GetReturnValue().Set( Nan::New(grpc_channel_get_target(channel->wrapped_channel)) .ToLocalChecked()); @@ -231,7 +231,7 @@ NAN_METHOD(Channel::GetConnectivityState) { return Nan::ThrowTypeError( "getConnectivityState can only be called on Channel objects"); } - Channel *channel = ObjectWrap::Unwrap<Channel>(info.This()); + Channel* channel = ObjectWrap::Unwrap<Channel>(info.This()); int try_to_connect = (int)info[0]->Equals(Nan::True()); info.GetReturnValue().Set(grpc_channel_check_connectivity_state( channel->wrapped_channel, try_to_connect)); @@ -258,8 +258,8 @@ NAN_METHOD(Channel::WatchConnectivityState) { Nan::To<uint32_t>(info[0]).FromJust()); double deadline = Nan::To<double>(info[1]).FromJust(); Local<Function> callback_func = info[2].As<Function>(); - Nan::Callback *callback = new Callback(callback_func); - Channel *channel = ObjectWrap::Unwrap<Channel>(info.This()); + Nan::Callback* callback = new Callback(callback_func); + Channel* channel = ObjectWrap::Unwrap<Channel>(info.This()); unique_ptr<OpVec> ops(new OpVec()); grpc_channel_watch_connectivity_state( channel->wrapped_channel, last_state, MillisecondsToTimespec(deadline), diff --git a/src/node/ext/channel.h b/src/node/ext/channel.h index a93dbe9d25..bfdcbe617c 100644 --- a/src/node/ext/channel.h +++ b/src/node/ext/channel.h @@ -27,9 +27,9 @@ namespace grpc { namespace node { bool ParseChannelArgs(v8::Local<v8::Value> args_val, - grpc_channel_args **channel_args_ptr); + grpc_channel_args** channel_args_ptr); -void DeallocateChannelArgs(grpc_channel_args *channel_args); +void DeallocateChannelArgs(grpc_channel_args* channel_args); /* Wrapper class for grpc_channel structs */ class Channel : public Nan::ObjectWrap { @@ -41,25 +41,25 @@ class Channel : public Nan::ObjectWrap { static v8::Persistent<v8::Value> prototype; /* Returns the grpc_channel struct that this object wraps */ - grpc_channel *GetWrappedChannel(); + grpc_channel* GetWrappedChannel(); private: - explicit Channel(grpc_channel *channel); + explicit Channel(grpc_channel* channel); ~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); static NAN_METHOD(GetTarget); static NAN_METHOD(GetConnectivityState); static NAN_METHOD(WatchConnectivityState); - static Nan::Callback *constructor; + static Nan::Callback* constructor; static Nan::Persistent<v8::FunctionTemplate> fun_tpl; - grpc_channel *wrapped_channel; + grpc_channel* wrapped_channel; }; } // namespace node diff --git a/src/node/ext/channel_credentials.cc b/src/node/ext/channel_credentials.cc index 9e87fb61bb..a145c0c53a 100644 --- a/src/node/ext/channel_credentials.cc +++ b/src/node/ext/channel_credentials.cc @@ -47,10 +47,10 @@ using v8::Object; using v8::ObjectTemplate; using v8::Value; -Nan::Callback *ChannelCredentials::constructor; +Nan::Callback* ChannelCredentials::constructor; Persistent<FunctionTemplate> ChannelCredentials::fun_tpl; -ChannelCredentials::ChannelCredentials(grpc_channel_credentials *credentials) +ChannelCredentials::ChannelCredentials(grpc_channel_credentials* credentials) : wrapped_credentials(credentials) {} ChannelCredentials::~ChannelCredentials() { @@ -81,11 +81,11 @@ bool ChannelCredentials::HasInstance(Local<Value> val) { } Local<Value> ChannelCredentials::WrapStruct( - grpc_channel_credentials *credentials) { + grpc_channel_credentials* credentials) { EscapableHandleScope scope; const int argc = 1; Local<Value> argv[argc] = { - Nan::New<External>(reinterpret_cast<void *>(credentials))}; + Nan::New<External>(reinterpret_cast<void*>(credentials))}; MaybeLocal<Object> maybe_instance = Nan::NewInstance(constructor->GetFunction(), argc, argv); if (maybe_instance.IsEmpty()) { @@ -95,7 +95,7 @@ Local<Value> ChannelCredentials::WrapStruct( } } -grpc_channel_credentials *ChannelCredentials::GetWrappedCredentials() { +grpc_channel_credentials* ChannelCredentials::GetWrappedCredentials() { return wrapped_credentials; } @@ -106,9 +106,9 @@ NAN_METHOD(ChannelCredentials::New) { "ChannelCredentials can only be created with the provided functions"); } Local<External> ext = info[0].As<External>(); - grpc_channel_credentials *creds_value = - reinterpret_cast<grpc_channel_credentials *>(ext->Value()); - ChannelCredentials *credentials = new ChannelCredentials(creds_value); + grpc_channel_credentials* creds_value = + reinterpret_cast<grpc_channel_credentials*>(ext->Value()); + ChannelCredentials* credentials = new ChannelCredentials(creds_value); credentials->Wrap(info.This()); info.GetReturnValue().Set(info.This()); return; @@ -120,7 +120,7 @@ NAN_METHOD(ChannelCredentials::New) { } NAN_METHOD(ChannelCredentials::CreateSsl) { - char *root_certs = NULL; + char* root_certs = NULL; grpc_ssl_pem_key_cert_pair key_cert_pair = {NULL, NULL}; if (::node::Buffer::HasInstance(info[0])) { root_certs = ::node::Buffer::Data(info[0]); @@ -145,7 +145,7 @@ NAN_METHOD(ChannelCredentials::CreateSsl) { "createSsl's second and third arguments must be" " provided or omitted together"); } - grpc_channel_credentials *creds = grpc_ssl_credentials_create( + grpc_channel_credentials* creds = grpc_ssl_credentials_create( root_certs, key_cert_pair.private_key == NULL ? NULL : &key_cert_pair, NULL); if (creds == NULL) { @@ -164,14 +164,14 @@ NAN_METHOD(ChannelCredentials::Compose) { return Nan::ThrowTypeError( "compose's first argument must be a CallCredentials object"); } - ChannelCredentials *self = + ChannelCredentials* self = ObjectWrap::Unwrap<ChannelCredentials>(info.This()); if (self->wrapped_credentials == NULL) { return Nan::ThrowTypeError("Cannot compose insecure credential"); } - CallCredentials *other = ObjectWrap::Unwrap<CallCredentials>( + CallCredentials* other = ObjectWrap::Unwrap<CallCredentials>( Nan::To<Object>(info[0]).ToLocalChecked()); - grpc_channel_credentials *creds = grpc_composite_channel_credentials_create( + grpc_channel_credentials* creds = grpc_composite_channel_credentials_create( self->wrapped_credentials, other->GetWrappedCredentials(), NULL); if (creds == NULL) { info.GetReturnValue().SetNull(); diff --git a/src/node/ext/channel_credentials.h b/src/node/ext/channel_credentials.h index 18c14837cc..3be5a22719 100644 --- a/src/node/ext/channel_credentials.h +++ b/src/node/ext/channel_credentials.h @@ -33,29 +33,29 @@ class ChannelCredentials : public Nan::ObjectWrap { static void Init(v8::Local<v8::Object> exports); static bool HasInstance(v8::Local<v8::Value> val); /* Wrap a grpc_channel_credentials struct in a javascript object */ - static v8::Local<v8::Value> WrapStruct(grpc_channel_credentials *credentials); + static v8::Local<v8::Value> WrapStruct(grpc_channel_credentials* credentials); /* Returns the grpc_channel_credentials struct that this object wraps */ - grpc_channel_credentials *GetWrappedCredentials(); + grpc_channel_credentials* GetWrappedCredentials(); private: - explicit ChannelCredentials(grpc_channel_credentials *credentials); + explicit ChannelCredentials(grpc_channel_credentials* credentials); ~ChannelCredentials(); // Prevent copying - ChannelCredentials(const ChannelCredentials &); - ChannelCredentials &operator=(const ChannelCredentials &); + ChannelCredentials(const ChannelCredentials&); + ChannelCredentials& operator=(const ChannelCredentials&); static NAN_METHOD(New); static NAN_METHOD(CreateSsl); static NAN_METHOD(CreateInsecure); static NAN_METHOD(Compose); - static Nan::Callback *constructor; + static Nan::Callback* constructor; // Used for typechecking instances of this javascript class static Nan::Persistent<v8::FunctionTemplate> fun_tpl; - grpc_channel_credentials *wrapped_credentials; + grpc_channel_credentials* wrapped_credentials; }; } // namespace node diff --git a/src/node/ext/completion_queue.cc b/src/node/ext/completion_queue.cc index a08febbb2c..2b99481d38 100644 --- a/src/node/ext/completion_queue.cc +++ b/src/node/ext/completion_queue.cc @@ -31,11 +31,11 @@ using v8::Local; using v8::Object; using v8::Value; -grpc_completion_queue *queue; +grpc_completion_queue* queue; uv_prepare_t prepare; int pending_batches; -void drain_completion_queue(uv_prepare_t *handle) { +void drain_completion_queue(uv_prepare_t* handle) { Nan::HandleScope scope; grpc_event event; (void)handle; @@ -44,7 +44,7 @@ void drain_completion_queue(uv_prepare_t *handle) { NULL); if (event.type == GRPC_OP_COMPLETE) { - const char *error_message; + const char* error_message; if (event.success) { error_message = NULL; } else { @@ -60,11 +60,11 @@ void drain_completion_queue(uv_prepare_t *handle) { } while (event.type != GRPC_QUEUE_TIMEOUT); } -grpc_completion_queue *GetCompletionQueue() { return queue; } +grpc_completion_queue* GetCompletionQueue() { return queue; } void CompletionQueueNext() { if (pending_batches == 0) { - GPR_ASSERT(!uv_is_active((uv_handle_t *)&prepare)); + GPR_ASSERT(!uv_is_active((uv_handle_t*)&prepare)); uv_prepare_start(&prepare, drain_completion_queue); } pending_batches++; diff --git a/src/node/ext/completion_queue.h b/src/node/ext/completion_queue.h index f91d5ea8b6..2422b2f76c 100644 --- a/src/node/ext/completion_queue.h +++ b/src/node/ext/completion_queue.h @@ -22,7 +22,7 @@ namespace grpc { namespace node { -grpc_completion_queue *GetCompletionQueue(); +grpc_completion_queue* GetCompletionQueue(); void CompletionQueueNext(); diff --git a/src/node/ext/node_grpc.cc b/src/node/ext/node_grpc.cc index 11ed0838bc..1c2d60d5a7 100644 --- a/src/node/ext/node_grpc.cc +++ b/src/node/ext/node_grpc.cc @@ -46,11 +46,11 @@ using grpc::node::CreateSliceFromString; using v8::FunctionTemplate; using v8::Local; -using v8::Value; using v8::Number; using v8::Object; -using v8::Uint32; using v8::String; +using v8::Uint32; +using v8::Value; typedef struct log_args { gpr_log_func_args core_args; @@ -58,8 +58,8 @@ typedef struct log_args { } log_args; typedef struct logger_state { - Nan::Callback *callback; - std::queue<log_args *> *pending_args; + Nan::Callback* callback; + std::queue<log_args*>* pending_args; uv_mutex_t mutex; uv_async_t async; // Indicates that a logger has been set @@ -68,7 +68,7 @@ typedef struct logger_state { logger_state grpc_logger_state; -static char *pem_root_certs = NULL; +static char* pem_root_certs = NULL; void InitOpTypeConstants(Local<Object> exports) { Nan::HandleScope scope; @@ -158,7 +158,7 @@ NAN_METHOD(MetadataKeyIsBinary) { } static grpc_ssl_roots_override_result get_ssl_roots_override( - char **pem_root_certs_ptr) { + char** pem_root_certs_ptr) { *pem_root_certs_ptr = pem_root_certs; if (pem_root_certs == NULL) { return GRPC_SSL_ROOTS_OVERRIDE_FAIL; @@ -177,21 +177,21 @@ NAN_METHOD(SetDefaultRootsPem) { Nan::Utf8String utf8_roots(info[0]); size_t length = static_cast<size_t>(utf8_roots.length()); if (length > 0) { - const char *data = *utf8_roots; - pem_root_certs = (char *)gpr_malloc((length + 1) * sizeof(char)); + const char* data = *utf8_roots; + pem_root_certs = (char*)gpr_malloc((length + 1) * sizeof(char)); memcpy(pem_root_certs, data, length + 1); } } NAUV_WORK_CB(LogMessagesCallback) { Nan::HandleScope scope; - std::queue<log_args *> args; + std::queue<log_args*> args; uv_mutex_lock(&grpc_logger_state.mutex); grpc_logger_state.pending_args->swap(args); uv_mutex_unlock(&grpc_logger_state.mutex); /* Call the callback with each log message */ while (!args.empty()) { - log_args *arg = args.front(); + log_args* arg = args.front(); args.pop(); Local<Value> file = Nan::New(arg->core_args.file).ToLocalChecked(); Local<Value> line = Nan::New<Uint32, uint32_t>(arg->core_args.line); @@ -210,11 +210,11 @@ NAUV_WORK_CB(LogMessagesCallback) { } } -void node_log_func(gpr_log_func_args *args) { +void node_log_func(gpr_log_func_args* args) { // TODO(mlumish): Use the core's log formatter when it becomes available - log_args *args_copy = new log_args; + log_args* args_copy = new log_args; size_t message_len = strlen(args->message) + 1; - char *message = new char[message_len]; + char* message = new char[message_len]; memcpy(message, args->message, message_len); memcpy(&args_copy->core_args, args, sizeof(gpr_log_func_args)); args_copy->core_args.message = message; @@ -229,11 +229,11 @@ void node_log_func(gpr_log_func_args *args) { void init_logger() { memset(&grpc_logger_state, 0, sizeof(logger_state)); - grpc_logger_state.pending_args = new std::queue<log_args *>(); + grpc_logger_state.pending_args = new std::queue<log_args*>(); uv_mutex_init(&grpc_logger_state.mutex); uv_async_init(uv_default_loop(), &grpc_logger_state.async, LogMessagesCallback); - uv_unref((uv_handle_t *)&grpc_logger_state.async); + uv_unref((uv_handle_t*)&grpc_logger_state.async); grpc_logger_state.logger_set = false; gpr_log_verbosity_init(); diff --git a/src/node/ext/server.cc b/src/node/ext/server.cc index c6ab5e1895..6bd6f09811 100644 --- a/src/node/ext/server.cc +++ b/src/node/ext/server.cc @@ -59,20 +59,20 @@ using v8::Object; using v8::String; using v8::Value; -Nan::Callback *Server::constructor; +Nan::Callback* Server::constructor; Persistent<FunctionTemplate> Server::fun_tpl; -static Callback *shutdown_callback = NULL; +static Callback* shutdown_callback = NULL; class ServerShutdownOp : public Op { public: - ServerShutdownOp(grpc_server *server) : server(server) {} + ServerShutdownOp(grpc_server* server) : server(server) {} ~ServerShutdownOp() {} Local<Value> GetNodeValue() const { return Nan::Null(); } - bool ParseOp(Local<Value> value, grpc_op *out) { return true; } + bool ParseOp(Local<Value> value, grpc_op* out) { return true; } bool IsFinalOp() { return false; } void OnComplete(bool success) { /* Because cancel_all_calls was called, we assume that shutdown_and_notify @@ -80,7 +80,7 @@ class ServerShutdownOp : public Op { grpc_server_destroy(server); } - grpc_server *server; + grpc_server* server; protected: std::string GetTypeString() const { return "shutdown"; } @@ -119,11 +119,11 @@ class NewCallOp : public Op { return scope.Escape(obj); } - bool ParseOp(Local<Value> value, grpc_op *out) { return true; } + bool ParseOp(Local<Value> value, grpc_op* out) { return true; } bool IsFinalOp() { return false; } void OnComplete(bool success) {} - grpc_call *call; + grpc_call* call; grpc_call_details details; grpc_metadata_array request_metadata; @@ -133,14 +133,14 @@ class NewCallOp : public Op { class TryShutdownOp : public Op { public: - TryShutdownOp(Server *server, Local<Value> server_value) : server(server) { + TryShutdownOp(Server* server, Local<Value> server_value) : server(server) { server_persist.Reset(server_value); } Local<Value> GetNodeValue() const { EscapableHandleScope scope; return scope.Escape(Nan::New(server_persist)); } - bool ParseOp(Local<Value> value, grpc_op *out) { return true; } + bool ParseOp(Local<Value> value, grpc_op* out) { return true; } bool IsFinalOp() { return false; } void OnComplete(bool success) { if (success) { @@ -152,12 +152,12 @@ class TryShutdownOp : public Op { std::string GetTypeString() const { return "try_shutdown"; } private: - Server *server; + Server* server; Nan::Persistent<v8::Value, Nan::CopyablePersistentTraits<v8::Value>> server_persist; }; -Server::Server(grpc_server *server) : wrapped_server(server) {} +Server::Server(grpc_server* server) : wrapped_server(server) {} Server::~Server() { this->ShutdownServer(); } @@ -205,7 +205,7 @@ void Server::ShutdownServer() { new Callback(Nan::GetFunction(callback_tpl).ToLocalChecked()); } - ServerShutdownOp *op = new ServerShutdownOp(this->wrapped_server); + ServerShutdownOp* op = new ServerShutdownOp(this->wrapped_server); unique_ptr<OpVec> ops(new OpVec()); ops->push_back(unique_ptr<Op>(op)); @@ -235,9 +235,9 @@ NAN_METHOD(Server::New) { return; } } - grpc_server *wrapped_server; - grpc_completion_queue *queue = GetCompletionQueue(); - grpc_channel_args *channel_args; + grpc_server* wrapped_server; + grpc_completion_queue* queue = GetCompletionQueue(); + grpc_channel_args* channel_args; if (!ParseChannelArgs(info[0], &channel_args)) { DeallocateChannelArgs(channel_args); return Nan::ThrowTypeError( @@ -247,7 +247,7 @@ NAN_METHOD(Server::New) { wrapped_server = grpc_server_create(channel_args, NULL); DeallocateChannelArgs(channel_args); grpc_server_register_completion_queue(wrapped_server, queue, NULL); - Server *server = new Server(wrapped_server); + Server* server = new Server(wrapped_server); server->Wrap(info.This()); info.GetReturnValue().Set(info.This()); } @@ -256,8 +256,8 @@ NAN_METHOD(Server::RequestCall) { if (!HasInstance(info.This())) { return Nan::ThrowTypeError("requestCall can only be called on a Server"); } - Server *server = ObjectWrap::Unwrap<Server>(info.This()); - NewCallOp *op = new NewCallOp(); + Server* server = ObjectWrap::Unwrap<Server>(info.This()); + NewCallOp* op = new NewCallOp(); unique_ptr<OpVec> ops(new OpVec()); ops->push_back(unique_ptr<Op>(op)); grpc_call_error error = grpc_server_request_call( @@ -283,10 +283,10 @@ NAN_METHOD(Server::AddHttp2Port) { return Nan::ThrowTypeError( "addHttp2Port's second argument must be ServerCredentials"); } - Server *server = ObjectWrap::Unwrap<Server>(info.This()); - ServerCredentials *creds_object = ObjectWrap::Unwrap<ServerCredentials>( + Server* server = ObjectWrap::Unwrap<Server>(info.This()); + ServerCredentials* creds_object = ObjectWrap::Unwrap<ServerCredentials>( Nan::To<Object>(info[1]).ToLocalChecked()); - grpc_server_credentials *creds = creds_object->GetWrappedServerCredentials(); + grpc_server_credentials* creds = creds_object->GetWrappedServerCredentials(); int port; if (creds == NULL) { port = grpc_server_add_insecure_http2_port(server->wrapped_server, @@ -303,7 +303,7 @@ NAN_METHOD(Server::Start) { if (!HasInstance(info.This())) { return Nan::ThrowTypeError("start can only be called on a Server"); } - Server *server = ObjectWrap::Unwrap<Server>(info.This()); + Server* server = ObjectWrap::Unwrap<Server>(info.This()); grpc_server_start(server->wrapped_server); } @@ -312,14 +312,14 @@ NAN_METHOD(Server::TryShutdown) { if (!HasInstance(info.This())) { return Nan::ThrowTypeError("tryShutdown can only be called on a Server"); } - Server *server = ObjectWrap::Unwrap<Server>(info.This()); + Server* server = ObjectWrap::Unwrap<Server>(info.This()); if (server->wrapped_server == NULL) { // Server is already shut down. Call callback immediately. Nan::Callback callback(info[0].As<Function>()); callback.Call(0, {}); return; } - TryShutdownOp *op = new TryShutdownOp(server, info.This()); + TryShutdownOp* op = new TryShutdownOp(server, info.This()); unique_ptr<OpVec> ops(new OpVec()); ops->push_back(unique_ptr<Op>(op)); grpc_server_shutdown_and_notify( @@ -334,7 +334,7 @@ NAN_METHOD(Server::ForceShutdown) { if (!HasInstance(info.This())) { return Nan::ThrowTypeError("forceShutdown can only be called on a Server"); } - Server *server = ObjectWrap::Unwrap<Server>(info.This()); + Server* server = ObjectWrap::Unwrap<Server>(info.This()); server->ShutdownServer(); } diff --git a/src/node/ext/server.h b/src/node/ext/server.h index 66b3ac5267..2a0bf19ba8 100644 --- a/src/node/ext/server.h +++ b/src/node/ext/server.h @@ -41,12 +41,12 @@ class Server : public Nan::ObjectWrap { void DestroyWrappedServer(); private: - explicit Server(grpc_server *server); + explicit Server(grpc_server* server); ~Server(); // Prevent copying - Server(const Server &); - Server &operator=(const Server &); + Server(const Server&); + Server& operator=(const Server&); void ShutdownServer(); @@ -56,11 +56,11 @@ class Server : public Nan::ObjectWrap { static NAN_METHOD(Start); static NAN_METHOD(TryShutdown); static NAN_METHOD(ForceShutdown); - static Nan::Callback *constructor; + static Nan::Callback* constructor; static Nan::Persistent<v8::FunctionTemplate> fun_tpl; - grpc_server *wrapped_server; - grpc_completion_queue *shutdown_queue; + grpc_server* wrapped_server; + grpc_completion_queue* shutdown_queue; }; } // namespace node diff --git a/src/node/ext/server_credentials.cc b/src/node/ext/server_credentials.cc index b7fa478844..0c5e7749c5 100644 --- a/src/node/ext/server_credentials.cc +++ b/src/node/ext/server_credentials.cc @@ -47,10 +47,10 @@ using v8::ObjectTemplate; using v8::String; using v8::Value; -Nan::Callback *ServerCredentials::constructor; +Nan::Callback* ServerCredentials::constructor; Persistent<FunctionTemplate> ServerCredentials::fun_tpl; -ServerCredentials::ServerCredentials(grpc_server_credentials *credentials) +ServerCredentials::ServerCredentials(grpc_server_credentials* credentials) : wrapped_credentials(credentials) {} ServerCredentials::~ServerCredentials() { @@ -80,11 +80,11 @@ bool ServerCredentials::HasInstance(Local<Value> val) { } Local<Value> ServerCredentials::WrapStruct( - grpc_server_credentials *credentials) { + grpc_server_credentials* credentials) { Nan::EscapableHandleScope scope; const int argc = 1; Local<Value> argv[argc] = { - Nan::New<External>(reinterpret_cast<void *>(credentials))}; + Nan::New<External>(reinterpret_cast<void*>(credentials))}; MaybeLocal<Object> maybe_instance = Nan::NewInstance(constructor->GetFunction(), argc, argv); if (maybe_instance.IsEmpty()) { @@ -94,7 +94,7 @@ Local<Value> ServerCredentials::WrapStruct( } } -grpc_server_credentials *ServerCredentials::GetWrappedServerCredentials() { +grpc_server_credentials* ServerCredentials::GetWrappedServerCredentials() { return wrapped_credentials; } @@ -105,9 +105,9 @@ NAN_METHOD(ServerCredentials::New) { "ServerCredentials can only be created with the provided functions"); } Local<External> ext = info[0].As<External>(); - grpc_server_credentials *creds_value = - reinterpret_cast<grpc_server_credentials *>(ext->Value()); - ServerCredentials *credentials = new ServerCredentials(creds_value); + grpc_server_credentials* creds_value = + reinterpret_cast<grpc_server_credentials*>(ext->Value()); + ServerCredentials* credentials = new ServerCredentials(creds_value); credentials->Wrap(info.This()); info.GetReturnValue().Set(info.This()); } else { @@ -119,7 +119,7 @@ NAN_METHOD(ServerCredentials::New) { NAN_METHOD(ServerCredentials::CreateSsl) { Nan::HandleScope scope; - char *root_certs = NULL; + char* root_certs = NULL; if (::node::Buffer::HasInstance(info[0])) { root_certs = ::node::Buffer::Data(info[0]); } else if (!(info[0]->IsNull() || info[0]->IsUndefined())) { @@ -145,7 +145,7 @@ NAN_METHOD(ServerCredentials::CreateSsl) { } Local<Array> pair_list = Local<Array>::Cast(info[1]); uint32_t key_cert_pair_count = pair_list->Length(); - grpc_ssl_pem_key_cert_pair *key_cert_pairs = + grpc_ssl_pem_key_cert_pair* key_cert_pairs = new grpc_ssl_pem_key_cert_pair[key_cert_pair_count]; Local<String> key_key = Nan::New("private_key").ToLocalChecked(); @@ -171,7 +171,7 @@ NAN_METHOD(ServerCredentials::CreateSsl) { key_cert_pairs[i].private_key = ::node::Buffer::Data(maybe_key); key_cert_pairs[i].cert_chain = ::node::Buffer::Data(maybe_cert); } - grpc_server_credentials *creds = grpc_ssl_server_credentials_create_ex( + grpc_server_credentials* creds = grpc_ssl_server_credentials_create_ex( root_certs, key_cert_pairs, key_cert_pair_count, client_certificate_request, NULL); delete[] key_cert_pairs; diff --git a/src/node/ext/server_credentials.h b/src/node/ext/server_credentials.h index 59f91481a2..d514e4dea9 100644 --- a/src/node/ext/server_credentials.h +++ b/src/node/ext/server_credentials.h @@ -33,27 +33,27 @@ class ServerCredentials : public Nan::ObjectWrap { static void Init(v8::Local<v8::Object> exports); static bool HasInstance(v8::Local<v8::Value> val); /* Wrap a grpc_server_credentials struct in a javascript object */ - static v8::Local<v8::Value> WrapStruct(grpc_server_credentials *credentials); + static v8::Local<v8::Value> WrapStruct(grpc_server_credentials* credentials); /* Returns the grpc_server_credentials struct that this object wraps */ - grpc_server_credentials *GetWrappedServerCredentials(); + grpc_server_credentials* GetWrappedServerCredentials(); private: - explicit ServerCredentials(grpc_server_credentials *credentials); + explicit ServerCredentials(grpc_server_credentials* credentials); ~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); static NAN_METHOD(CreateInsecure); - static Nan::Callback *constructor; + static Nan::Callback* constructor; // Used for typechecking instances of this javascript class static Nan::Persistent<v8::FunctionTemplate> fun_tpl; - grpc_server_credentials *wrapped_credentials; + grpc_server_credentials* wrapped_credentials; }; } // namespace node diff --git a/src/node/ext/slice.cc b/src/node/ext/slice.cc index 8806a61a9e..0ba6a54a59 100644 --- a/src/node/ext/slice.cc +++ b/src/node/ext/slice.cc @@ -33,24 +33,24 @@ using v8::String; using v8::Value; namespace { -void SliceFreeCallback(char *data, void *hint) { - grpc_slice *slice = reinterpret_cast<grpc_slice *>(hint); +void SliceFreeCallback(char* data, void* hint) { + grpc_slice* slice = reinterpret_cast<grpc_slice*>(hint); grpc_slice_unref(*slice); delete slice; } -void string_destroy_func(void *user_data) { - delete reinterpret_cast<Nan::Utf8String *>(user_data); +void string_destroy_func(void* user_data) { + delete reinterpret_cast<Nan::Utf8String*>(user_data); } -void buffer_destroy_func(void *user_data) { - delete reinterpret_cast<PersistentValue *>(user_data); +void buffer_destroy_func(void* user_data) { + delete reinterpret_cast<PersistentValue*>(user_data); } } // namespace grpc_slice CreateSliceFromString(const Local<String> source) { Nan::HandleScope scope; - Nan::Utf8String *utf8_value = new Nan::Utf8String(source); + Nan::Utf8String* utf8_value = new Nan::Utf8String(source); return grpc_slice_new_with_user_data(**utf8_value, source->Length(), string_destroy_func, utf8_value); } @@ -68,7 +68,7 @@ Local<String> CopyStringFromSlice(const grpc_slice slice) { return scope.Escape(Nan::EmptyString()); } return scope.Escape( - Nan::New<String>(const_cast<char *>(reinterpret_cast<const char *>( + Nan::New<String>(const_cast<char*>(reinterpret_cast<const char*>( GRPC_SLICE_START_PTR(slice))), GRPC_SLICE_LENGTH(slice)) .ToLocalChecked()); @@ -76,12 +76,12 @@ Local<String> CopyStringFromSlice(const grpc_slice slice) { Local<Value> CreateBufferFromSlice(const grpc_slice slice) { Nan::EscapableHandleScope scope; - grpc_slice *slice_ptr = new grpc_slice; + grpc_slice* slice_ptr = new grpc_slice; *slice_ptr = grpc_slice_ref(slice); return scope.Escape( Nan::NewBuffer( - const_cast<char *>( - reinterpret_cast<const char *>(GRPC_SLICE_START_PTR(*slice_ptr))), + const_cast<char*>( + reinterpret_cast<const char*>(GRPC_SLICE_START_PTR(*slice_ptr))), GRPC_SLICE_LENGTH(*slice_ptr), SliceFreeCallback, slice_ptr) .ToLocalChecked()); } |