diff options
author | 2015-04-17 08:06:01 +0900 | |
---|---|---|
committer | 2015-04-17 08:06:01 +0900 | |
commit | e8696fb2864a01bb3fd568323466485d2b96b12d (patch) | |
tree | 18731c7688f54f9b788decbd99d810f20d26768c /src/ruby/ext | |
parent | 22887917f54dfa3f1b42f2bc4627fb8dbd968cfb (diff) | |
parent | d35b7107f8c54196ba8ddd55a0760e5f559e2014 (diff) |
Merge branch 'master' into fix/header
Conflicts:
src/ruby/ext/grpc/rb_grpc.c
Diffstat (limited to 'src/ruby/ext')
-rw-r--r-- | src/ruby/ext/grpc/rb_call.c | 40 | ||||
-rw-r--r-- | src/ruby/ext/grpc/rb_call.h | 7 | ||||
-rw-r--r-- | src/ruby/ext/grpc/rb_channel.c | 5 | ||||
-rw-r--r-- | src/ruby/ext/grpc/rb_channel.h | 3 | ||||
-rw-r--r-- | src/ruby/ext/grpc/rb_completion_queue.c | 8 | ||||
-rw-r--r-- | src/ruby/ext/grpc/rb_completion_queue.h | 4 | ||||
-rw-r--r-- | src/ruby/ext/grpc/rb_credentials.c | 6 | ||||
-rw-r--r-- | src/ruby/ext/grpc/rb_credentials.h | 4 | ||||
-rw-r--r-- | src/ruby/ext/grpc/rb_grpc.c | 19 | ||||
-rw-r--r-- | src/ruby/ext/grpc/rb_grpc.h | 9 | ||||
-rw-r--r-- | src/ruby/ext/grpc/rb_server.c | 2 | ||||
-rw-r--r-- | src/ruby/ext/grpc/rb_server.h | 4 | ||||
-rw-r--r-- | src/ruby/ext/grpc/rb_server_credentials.c | 8 | ||||
-rw-r--r-- | src/ruby/ext/grpc/rb_server_credentials.h | 4 |
14 files changed, 50 insertions, 73 deletions
diff --git a/src/ruby/ext/grpc/rb_call.c b/src/ruby/ext/grpc/rb_call.c index 1b1958fd26..b0963411d1 100644 --- a/src/ruby/ext/grpc/rb_call.c +++ b/src/ruby/ext/grpc/rb_call.c @@ -42,6 +42,17 @@ #include "rb_completion_queue.h" #include "rb_grpc.h" +/* grpc_rb_cCall is the Call class whose instances proxy grpc_call. */ +static VALUE grpc_rb_cCall; + +/* grpc_rb_eCallError is the ruby class of the exception thrown during call + operations; */ +VALUE grpc_rb_eCallError = Qnil; + +/* grpc_rb_eOutOfTime is the ruby class of the exception thrown to indicate + a timeout. */ +static VALUE grpc_rb_eOutOfTime = Qnil; + /* grpc_rb_sBatchResult is struct class used to hold the results of a batch * call. */ static VALUE grpc_rb_sBatchResult; @@ -86,7 +97,7 @@ static VALUE sym_cancelled; static VALUE hash_all_calls; /* Destroys a Call. */ -void grpc_rb_call_destroy(void *p) { +static void grpc_rb_call_destroy(void *p) { grpc_call *call = NULL; VALUE ref_count = Qnil; if (p == NULL) { @@ -188,7 +199,7 @@ static VALUE grpc_rb_call_set_metadata(VALUE self, VALUE metadata) { it's capacity should have been computed via a prior call to grpc_rb_md_ary_fill_hash_cb */ -int grpc_rb_md_ary_fill_hash_cb(VALUE key, VALUE val, VALUE md_ary_obj) { +static int grpc_rb_md_ary_fill_hash_cb(VALUE key, VALUE val, VALUE md_ary_obj) { grpc_metadata_array *md_ary = NULL; int array_length; int i; @@ -227,7 +238,8 @@ int grpc_rb_md_ary_fill_hash_cb(VALUE key, VALUE val, VALUE md_ary_obj) { /* grpc_rb_md_ary_capacity_hash_cb is the hash iteration callback used to pre-compute the capacity a grpc_metadata_array. */ -int grpc_rb_md_ary_capacity_hash_cb(VALUE key, VALUE val, VALUE md_ary_obj) { +static int grpc_rb_md_ary_capacity_hash_cb(VALUE key, VALUE val, + VALUE md_ary_obj) { grpc_metadata_array *md_ary = NULL; /* Construct a metadata object from key and value and add it */ @@ -245,7 +257,7 @@ int grpc_rb_md_ary_capacity_hash_cb(VALUE key, VALUE val, VALUE md_ary_obj) { /* grpc_rb_md_ary_convert converts a ruby metadata hash into a grpc_metadata_array. */ -void grpc_rb_md_ary_convert(VALUE md_ary_hash, grpc_metadata_array *md_ary) { +static void grpc_rb_md_ary_convert(VALUE md_ary_hash, grpc_metadata_array *md_ary) { VALUE md_ary_obj = Qnil; if (md_ary_hash == Qnil) { return; /* Do nothing if the expected has value is nil */ @@ -301,7 +313,8 @@ VALUE grpc_rb_md_ary_to_h(grpc_metadata_array *md_ary) { /* grpc_rb_call_check_op_keys_hash_cb is a hash iteration func that checks each key of an ops hash is valid. */ -int grpc_rb_call_check_op_keys_hash_cb(VALUE key, VALUE val, VALUE ops_ary) { +static int grpc_rb_call_check_op_keys_hash_cb(VALUE key, VALUE val, + VALUE ops_ary) { /* Update the capacity; the value is an array, add capacity for each value in * the array */ if (TYPE(key) != T_FIXNUM) { @@ -330,7 +343,7 @@ int grpc_rb_call_check_op_keys_hash_cb(VALUE key, VALUE val, VALUE ops_ary) { /* grpc_rb_op_update_status_from_server adds the values in a ruby status struct to the 'send_status_from_server' portion of an op. */ -void grpc_rb_op_update_status_from_server(grpc_op *op, +static void grpc_rb_op_update_status_from_server(grpc_op *op, grpc_metadata_array* md_ary, VALUE status) { VALUE code = rb_struct_aref(status, sym_code); @@ -582,18 +595,7 @@ static VALUE grpc_rb_call_run_batch(VALUE self, VALUE cqueue, VALUE tag, return result; } -/* grpc_rb_cCall is the ruby class that proxies grpc_call. */ -VALUE grpc_rb_cCall = Qnil; - -/* grpc_rb_eCallError is the ruby class of the exception thrown during call - operations; */ -VALUE grpc_rb_eCallError = Qnil; - -/* grpc_rb_eOutOfTime is the ruby class of the exception thrown to indicate - a timeout. */ -VALUE grpc_rb_eOutOfTime = Qnil; - -void Init_grpc_error_codes() { +static void Init_grpc_error_codes() { /* Constants representing the error codes of grpc_call_error in grpc.h */ VALUE grpc_rb_mRpcErrors = rb_define_module_under(grpc_rb_mGrpcCore, "RpcErrors"); @@ -645,7 +647,7 @@ void Init_grpc_error_codes() { rb_obj_freeze(rb_error_code_details); } -void Init_grpc_op_codes() { +static void Init_grpc_op_codes() { /* Constants representing operation type codes in grpc.h */ VALUE grpc_rb_mCallOps = rb_define_module_under(grpc_rb_mGrpcCore, "CallOps"); diff --git a/src/ruby/ext/grpc/rb_call.h b/src/ruby/ext/grpc/rb_call.h index e20a34c74e..003ce0429e 100644 --- a/src/ruby/ext/grpc/rb_call.h +++ b/src/ruby/ext/grpc/rb_call.h @@ -49,17 +49,10 @@ const char* grpc_call_error_detail_of(grpc_call_error err); /* Converts a metadata array to a hash. */ VALUE grpc_rb_md_ary_to_h(grpc_metadata_array *md_ary); -/* grpc_rb_cCall is the Call class whose instances proxy grpc_call. */ -extern VALUE grpc_rb_cCall; - /* grpc_rb_eCallError is the ruby class of the exception thrown during call operations. */ extern VALUE grpc_rb_eCallError; -/* grpc_rb_eOutOfTime is the ruby class of the exception thrown to indicate - a timeout. */ -extern VALUE grpc_rb_eOutOfTime; - /* Initializes the Call class. */ void Init_grpc_call(); diff --git a/src/ruby/ext/grpc/rb_channel.c b/src/ruby/ext/grpc/rb_channel.c index 3480280a03..9bd7c2edf9 100644 --- a/src/ruby/ext/grpc/rb_channel.c +++ b/src/ruby/ext/grpc/rb_channel.c @@ -58,6 +58,8 @@ static ID id_target; * GCed before the channel */ static ID id_cqueue; +/* grpc_rb_cChannel is the ruby class that proxies grpc_channel. */ +static VALUE grpc_rb_cChannel = Qnil; /* Used during the conversion of a hash to channel args during channel setup */ static VALUE grpc_rb_cChannelArgs; @@ -240,9 +242,6 @@ static VALUE grpc_rb_channel_destroy(VALUE self) { return Qnil; } -/* grpc_rb_cChannel is the ruby class that proxies grpc_channel. */ -VALUE grpc_rb_cChannel = Qnil; - void Init_grpc_channel() { grpc_rb_cChannelArgs = rb_define_class("TmpChannelArgs", rb_cObject); grpc_rb_cChannel = diff --git a/src/ruby/ext/grpc/rb_channel.h b/src/ruby/ext/grpc/rb_channel.h index 5c57b31fb2..6e3c087689 100644 --- a/src/ruby/ext/grpc/rb_channel.h +++ b/src/ruby/ext/grpc/rb_channel.h @@ -37,9 +37,6 @@ #include <ruby.h> #include <grpc/grpc.h> -/* grpc_rb_cChannel is the Channel class whose instances proxy grpc_channel. */ -extern VALUE grpc_rb_cChannel; - /* Initializes the Channel class. */ void Init_grpc_channel(); diff --git a/src/ruby/ext/grpc/rb_completion_queue.c b/src/ruby/ext/grpc/rb_completion_queue.c index bc5ca109c3..369adeb915 100644 --- a/src/ruby/ext/grpc/rb_completion_queue.c +++ b/src/ruby/ext/grpc/rb_completion_queue.c @@ -40,6 +40,10 @@ #include <grpc/support/time.h> #include "rb_grpc.h" +/* grpc_rb_cCompletionQueue is the ruby class that proxies + * grpc_completion_queue. */ +static VALUE grpc_rb_cCompletionQueue = Qnil; + /* Used to allow grpc_completion_queue_next call to release the GIL */ typedef struct next_call_stack { grpc_completion_queue *cq; @@ -169,10 +173,6 @@ grpc_event* grpc_rb_completion_queue_pluck_event(VALUE self, VALUE tag, return next_call.event; } -/* grpc_rb_cCompletionQueue is the ruby class that proxies - * grpc_completion_queue. */ -VALUE grpc_rb_cCompletionQueue = Qnil; - void Init_grpc_completion_queue() { grpc_rb_cCompletionQueue = rb_define_class_under(grpc_rb_mGrpcCore, "CompletionQueue", rb_cObject); diff --git a/src/ruby/ext/grpc/rb_completion_queue.h b/src/ruby/ext/grpc/rb_completion_queue.h index 1bfb80e499..4d0f49ac47 100644 --- a/src/ruby/ext/grpc/rb_completion_queue.h +++ b/src/ruby/ext/grpc/rb_completion_queue.h @@ -48,10 +48,6 @@ grpc_completion_queue *grpc_rb_get_wrapped_completion_queue(VALUE v); grpc_event* grpc_rb_completion_queue_pluck_event(VALUE cqueue, VALUE tag, VALUE timeout); -/* grpc_rb_cCompletionQueue is the CompletionQueue class whose instances proxy - grpc_completion_queue. */ -extern VALUE grpc_rb_cCompletionQueue; - /* Initializes the CompletionQueue class. */ void Init_grpc_completion_queue(); diff --git a/src/ruby/ext/grpc/rb_credentials.c b/src/ruby/ext/grpc/rb_credentials.c index 1504a4884e..122cffc92f 100644 --- a/src/ruby/ext/grpc/rb_credentials.c +++ b/src/ruby/ext/grpc/rb_credentials.c @@ -40,6 +40,9 @@ #include "rb_grpc.h" +/* grpc_rb_cCredentials is the ruby class that proxies grpc_credentials. */ +static VALUE grpc_rb_cCredentials = Qnil; + /* grpc_rb_credentials wraps a grpc_credentials. It provides a * peer ruby object, 'mark' to minimize copying when a credential is * created from ruby. */ @@ -242,9 +245,6 @@ static VALUE grpc_rb_credentials_init(int argc, VALUE *argv, VALUE self) { return self; } -/* grpc_rb_cCredentials is the ruby class that proxies grpc_credentials. */ -VALUE grpc_rb_cCredentials = Qnil; - void Init_grpc_credentials() { grpc_rb_cCredentials = rb_define_class_under(grpc_rb_mGrpcCore, "Credentials", rb_cObject); diff --git a/src/ruby/ext/grpc/rb_credentials.h b/src/ruby/ext/grpc/rb_credentials.h index dc0a3d01e8..e7c43c9c78 100644 --- a/src/ruby/ext/grpc/rb_credentials.h +++ b/src/ruby/ext/grpc/rb_credentials.h @@ -37,10 +37,6 @@ #include <ruby.h> #include <grpc/grpc_security.h> -/* grpc_rb_cCredentials is the ruby class whose instances proxy - grpc_credentials. */ -extern VALUE grpc_rb_cCredentials; - /* Initializes the ruby Credentials class. */ void Init_grpc_credentials(); diff --git a/src/ruby/ext/grpc/rb_grpc.c b/src/ruby/ext/grpc/rb_grpc.c index 2392393ffe..050e889d55 100644 --- a/src/ruby/ext/grpc/rb_grpc.c +++ b/src/ruby/ext/grpc/rb_grpc.c @@ -51,7 +51,7 @@ const RUBY_DATA_FUNC GC_NOT_MARKED = NULL; const RUBY_DATA_FUNC GC_DONT_FREE = NULL; -VALUE grpc_rb_cTimeVal = Qnil; +static VALUE grpc_rb_cTimeVal = Qnil; /* Alloc func that blocks allocation of a given object by raising an * exception. */ @@ -151,7 +151,7 @@ gpr_timespec grpc_rb_time_timeval(VALUE time, int interval) { return t; } -void Init_grpc_status_codes() { +static void Init_grpc_status_codes() { /* Constants representing the status codes or grpc_status_code in status.h */ VALUE grpc_rb_mStatusCodes = rb_define_module_under(grpc_rb_mGrpcCore, "StatusCodes"); @@ -200,7 +200,7 @@ static ID id_inspect; static ID id_to_s; /* Converts a wrapped time constant to a standard time. */ -VALUE grpc_rb_time_val_to_time(VALUE self) { +static VALUE grpc_rb_time_val_to_time(VALUE self) { gpr_timespec *time_const = NULL; Data_Get_Struct(self, gpr_timespec, time_const); return rb_funcall(rb_cTime, id_at, 2, INT2NUM(time_const->tv_sec), @@ -208,17 +208,17 @@ VALUE grpc_rb_time_val_to_time(VALUE self) { } /* Invokes inspect on the ctime version of the time val. */ -VALUE grpc_rb_time_val_inspect(VALUE self) { +static VALUE grpc_rb_time_val_inspect(VALUE self) { return rb_funcall(grpc_rb_time_val_to_time(self), id_inspect, 0); } /* Invokes to_s on the ctime version of the time val. */ -VALUE grpc_rb_time_val_to_s(VALUE self) { +static VALUE grpc_rb_time_val_to_s(VALUE self) { return rb_funcall(grpc_rb_time_val_to_time(self), id_to_s, 0); } /* Adds a module with constants that map to gpr's static timeval structs. */ -void Init_grpc_time_consts() { +static void Init_grpc_time_consts() { VALUE grpc_rb_mTimeConsts = rb_define_module_under(grpc_rb_mGrpcCore, "TimeConsts"); grpc_rb_cTimeVal = @@ -245,7 +245,7 @@ void Init_grpc_time_consts() { id_tv_nsec = rb_intern("tv_nsec"); } -void grpc_rb_shutdown(ruby_vm_t *vm) { grpc_shutdown(); } +static void grpc_rb_shutdown(ruby_vm_t *vm) { grpc_shutdown(); } /* Initialize the GRPC module structs */ @@ -258,6 +258,11 @@ VALUE grpc_rb_sStatus = Qnil; VALUE grpc_rb_mGRPC = Qnil; VALUE grpc_rb_mGrpcCore = Qnil; +/* cached Symbols for members in Status struct */ +VALUE sym_code = Qundef; +VALUE sym_details = Qundef; +VALUE sym_metadata = Qundef; + void Init_grpc() { grpc_init(); ruby_vm_at_exit(grpc_rb_shutdown); diff --git a/src/ruby/ext/grpc/rb_grpc.h b/src/ruby/ext/grpc/rb_grpc.h index 3a93029556..1d411baf5b 100644 --- a/src/ruby/ext/grpc/rb_grpc.h +++ b/src/ruby/ext/grpc/rb_grpc.h @@ -41,9 +41,6 @@ /* grpc_rb_mGrpcCore is the module containing the ruby wrapper GRPC classes. */ extern VALUE grpc_rb_mGrpcCore; -/* Class used to wrap timeval structs. */ -extern VALUE grpc_rb_cTimeVal; - /* grpc_rb_sNewServerRpc is the struct that holds new server rpc details. */ extern VALUE grpc_rb_sNewServerRpc; @@ -51,13 +48,13 @@ extern VALUE grpc_rb_sNewServerRpc; extern VALUE grpc_rb_sStatus; /* sym_code is the symbol for the code attribute of grpc_rb_sStatus. */ -VALUE sym_code; +extern VALUE sym_code; /* sym_details is the symbol for the details attribute of grpc_rb_sStatus. */ -VALUE sym_details; +extern VALUE sym_details; /* sym_metadata is the symbol for the metadata attribute of grpc_rb_sStatus. */ -VALUE sym_metadata; +extern VALUE sym_metadata; /* GC_NOT_MARKED is used in calls to Data_Wrap_Struct to indicate that the wrapped struct does not need to participate in ruby gc. */ diff --git a/src/ruby/ext/grpc/rb_server.c b/src/ruby/ext/grpc/rb_server.c index 33d9d69500..80f7760ebb 100644 --- a/src/ruby/ext/grpc/rb_server.c +++ b/src/ruby/ext/grpc/rb_server.c @@ -44,7 +44,7 @@ #include "rb_grpc.h" /* grpc_rb_cServer is the ruby class that proxies grpc_server. */ -VALUE grpc_rb_cServer = Qnil; +static VALUE grpc_rb_cServer = Qnil; /* id_at is the constructor method of the ruby standard Time class. */ static ID id_at; diff --git a/src/ruby/ext/grpc/rb_server.h b/src/ruby/ext/grpc/rb_server.h index 22e88a7d46..5e4b711d35 100644 --- a/src/ruby/ext/grpc/rb_server.h +++ b/src/ruby/ext/grpc/rb_server.h @@ -37,10 +37,6 @@ #include <ruby.h> #include <grpc/grpc.h> -/* grpc_rb_cServer is the Server class whose instances proxy - grpc_byte_buffer. */ -extern VALUE grpc_rb_cServer; - /* Initializes the Server class. */ void Init_grpc_server(); diff --git a/src/ruby/ext/grpc/rb_server_credentials.c b/src/ruby/ext/grpc/rb_server_credentials.c index 8b813eaca1..5109b96b5f 100644 --- a/src/ruby/ext/grpc/rb_server_credentials.c +++ b/src/ruby/ext/grpc/rb_server_credentials.c @@ -40,6 +40,10 @@ #include "rb_grpc.h" +/* grpc_rb_cServerCredentials is the ruby class that proxies + grpc_server_credentials. */ +static VALUE grpc_rb_cServerCredentials = Qnil; + /* grpc_rb_server_credentials wraps a grpc_server_credentials. It provides a peer ruby object, 'mark' to minimize copying when a server credential is created from ruby. */ @@ -180,10 +184,6 @@ static VALUE grpc_rb_server_credentials_init(VALUE self, VALUE pem_root_certs, return self; } -/* grpc_rb_cServerCredentials is the ruby class that proxies - grpc_server_credentials. */ -VALUE grpc_rb_cServerCredentials = Qnil; - void Init_grpc_server_credentials() { grpc_rb_cServerCredentials = rb_define_class_under(grpc_rb_mGrpcCore, "ServerCredentials", rb_cObject); diff --git a/src/ruby/ext/grpc/rb_server_credentials.h b/src/ruby/ext/grpc/rb_server_credentials.h index f79a869358..35b395ad5c 100644 --- a/src/ruby/ext/grpc/rb_server_credentials.h +++ b/src/ruby/ext/grpc/rb_server_credentials.h @@ -37,10 +37,6 @@ #include <ruby.h> #include <grpc/grpc_security.h> -/* grpc_rb_cServerCredentials is the ruby class whose instances proxy - grpc_server_credentials. */ -extern VALUE grpc_rb_cServerCredentials; - /* Initializes the ruby ServerCredentials class. */ void Init_grpc_server_credentials(); |