aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ruby
diff options
context:
space:
mode:
authorGravatar murgatroid99 <mlumish@google.com>2016-06-02 16:00:54 -0700
committerGravatar murgatroid99 <mlumish@google.com>2016-06-02 16:00:54 -0700
commitcc0f4e1c807090c97aa64f83649013e0e6ab879b (patch)
tree21ee39c0ed34334864b24369c0a2d7ae8ea8aef0 /src/ruby
parente5d37dd50ef40ac4e6c5f7fe39081d3be4354f5a (diff)
Remove Ruby copy initializers. They don't make sense with wrapped structs, and we don't use them anyway
Diffstat (limited to 'src/ruby')
-rw-r--r--src/ruby/ext/grpc/rb_call_credentials.c31
-rw-r--r--src/ruby/ext/grpc/rb_channel.c30
-rw-r--r--src/ruby/ext/grpc/rb_channel_credentials.c32
-rw-r--r--src/ruby/ext/grpc/rb_grpc.c2
-rw-r--r--src/ruby/ext/grpc/rb_server.c31
-rw-r--r--src/ruby/ext/grpc/rb_server_credentials.c32
6 files changed, 6 insertions, 152 deletions
diff --git a/src/ruby/ext/grpc/rb_call_credentials.c b/src/ruby/ext/grpc/rb_call_credentials.c
index 79ca5b32ce..9b6675da84 100644
--- a/src/ruby/ext/grpc/rb_call_credentials.c
+++ b/src/ruby/ext/grpc/rb_call_credentials.c
@@ -211,35 +211,6 @@ VALUE grpc_rb_wrap_call_credentials(grpc_call_credentials *c, VALUE mark) {
return rb_wrapper;
}
-/* Clones CallCredentials instances.
- Gives CallCredentials a consistent implementation of Ruby's object copy/dup
- protocol. */
-static VALUE grpc_rb_call_credentials_init_copy(VALUE copy, VALUE orig) {
- grpc_rb_call_credentials *orig_cred = NULL;
- grpc_rb_call_credentials *copy_cred = NULL;
-
- if (copy == orig) {
- return copy;
- }
-
- /* Raise an error if orig is not a credentials object or a subclass. */
- if (TYPE(orig) != T_DATA ||
- RDATA(orig)->dfree != (RUBY_DATA_FUNC)grpc_rb_call_credentials_free) {
- rb_raise(rb_eTypeError, "not a %s",
- rb_obj_classname(grpc_rb_cCallCredentials));
- }
-
- TypedData_Get_Struct(orig, grpc_rb_call_credentials,
- &grpc_rb_call_credentials_data_type, orig_cred);
- TypedData_Get_Struct(copy, grpc_rb_call_credentials,
- &grpc_rb_call_credentials_data_type, copy_cred);
-
- /* use ruby's MEMCPY to make a byte-for-byte copy of the credentials
- * wrapper object. */
- MEMCPY(copy_cred, orig_cred, grpc_rb_call_credentials, 1);
- return copy;
-}
-
/* The attribute used on the mark object to hold the callback */
static ID id_callback;
@@ -308,7 +279,7 @@ void Init_grpc_call_credentials() {
rb_define_method(grpc_rb_cCallCredentials, "initialize",
grpc_rb_call_credentials_init, 1);
rb_define_method(grpc_rb_cCallCredentials, "initialize_copy",
- grpc_rb_call_credentials_init_copy, 1);
+ grpc_rb_cannot_init_copy, 1);
rb_define_method(grpc_rb_cCallCredentials, "compose",
grpc_rb_call_credentials_compose, -1);
diff --git a/src/ruby/ext/grpc/rb_channel.c b/src/ruby/ext/grpc/rb_channel.c
index 013321ffc8..9d29b96a35 100644
--- a/src/ruby/ext/grpc/rb_channel.c
+++ b/src/ruby/ext/grpc/rb_channel.c
@@ -231,34 +231,6 @@ static VALUE grpc_rb_channel_watch_connectivity_state(VALUE self,
return Qnil;
}
-/* Clones Channel instances.
-
- Gives Channel a consistent implementation of Ruby's object copy/dup
- protocol. */
-static VALUE grpc_rb_channel_init_copy(VALUE copy, VALUE orig) {
- grpc_rb_channel *orig_ch = NULL;
- grpc_rb_channel *copy_ch = NULL;
-
- if (copy == orig) {
- return copy;
- }
-
- /* Raise an error if orig is not a channel object or a subclass. */
- if (TYPE(orig) != T_DATA ||
- RDATA(orig)->dfree != (RUBY_DATA_FUNC)grpc_rb_channel_free) {
- rb_raise(rb_eTypeError, "not a %s", rb_obj_classname(grpc_rb_cChannel));
- return Qnil;
- }
-
- TypedData_Get_Struct(orig, grpc_rb_channel, &grpc_channel_data_type, orig_ch);
- TypedData_Get_Struct(copy, grpc_rb_channel, &grpc_channel_data_type, copy_ch);
-
- /* use ruby's MEMCPY to make a byte-for-byte copy of the channel wrapper
- * object. */
- MEMCPY(copy_ch, orig_ch, grpc_rb_channel, 1);
- return copy;
-}
-
/* Create a call given a grpc_channel, in order to call method. The request
is not sent until grpc_call_invoke is called. */
static VALUE grpc_rb_channel_create_call(VALUE self, VALUE cqueue,
@@ -387,7 +359,7 @@ void Init_grpc_channel() {
/* Provides a ruby constructor and support for dup/clone. */
rb_define_method(grpc_rb_cChannel, "initialize", grpc_rb_channel_init, -1);
rb_define_method(grpc_rb_cChannel, "initialize_copy",
- grpc_rb_channel_init_copy, 1);
+ grpc_rb_cannot_init_copy, 1);
/* Add ruby analogues of the Channel methods. */
rb_define_method(grpc_rb_cChannel, "connectivity_state",
diff --git a/src/ruby/ext/grpc/rb_channel_credentials.c b/src/ruby/ext/grpc/rb_channel_credentials.c
index cbb23885aa..5b7aa3417e 100644
--- a/src/ruby/ext/grpc/rb_channel_credentials.c
+++ b/src/ruby/ext/grpc/rb_channel_credentials.c
@@ -126,36 +126,6 @@ VALUE grpc_rb_wrap_channel_credentials(grpc_channel_credentials *c, VALUE mark)
return rb_wrapper;
}
-/* Clones ChannelCredentials instances.
- Gives ChannelCredentials a consistent implementation of Ruby's object copy/dup
- protocol. */
-static VALUE grpc_rb_channel_credentials_init_copy(VALUE copy, VALUE orig) {
- grpc_rb_channel_credentials *orig_cred = NULL;
- grpc_rb_channel_credentials *copy_cred = NULL;
-
- if (copy == orig) {
- return copy;
- }
-
- /* Raise an error if orig is not a credentials object or a subclass. */
- if (TYPE(orig) != T_DATA ||
- RDATA(orig)->dfree != (RUBY_DATA_FUNC)grpc_rb_channel_credentials_free) {
- rb_raise(rb_eTypeError, "not a %s",
- rb_obj_classname(grpc_rb_cChannelCredentials));
- }
-
- TypedData_Get_Struct(orig, grpc_rb_channel_credentials,
- &grpc_rb_channel_credentials_data_type, orig_cred);
- TypedData_Get_Struct(copy, grpc_rb_channel_credentials,
- &grpc_rb_channel_credentials_data_type, copy_cred);
-
- /* use ruby's MEMCPY to make a byte-for-byte copy of the credentials
- * wrapper object. */
- MEMCPY(copy_cred, orig_cred, grpc_rb_channel_credentials, 1);
- return copy;
-}
-
-
/* The attribute used on the mark object to hold the pem_root_certs. */
static ID id_pem_root_certs;
@@ -271,7 +241,7 @@ void Init_grpc_channel_credentials() {
rb_define_method(grpc_rb_cChannelCredentials, "initialize",
grpc_rb_channel_credentials_init, -1);
rb_define_method(grpc_rb_cChannelCredentials, "initialize_copy",
- grpc_rb_channel_credentials_init_copy, 1);
+ grpc_rb_cannot_init_copy, 1);
rb_define_method(grpc_rb_cChannelCredentials, "compose",
grpc_rb_channel_credentials_compose, -1);
rb_define_module_function(grpc_rb_cChannelCredentials,
diff --git a/src/ruby/ext/grpc/rb_grpc.c b/src/ruby/ext/grpc/rb_grpc.c
index 9246893f9f..8527da52d2 100644
--- a/src/ruby/ext/grpc/rb_grpc.c
+++ b/src/ruby/ext/grpc/rb_grpc.c
@@ -85,7 +85,7 @@ VALUE grpc_rb_cannot_init(VALUE self) {
VALUE grpc_rb_cannot_init_copy(VALUE copy, VALUE self) {
(void)self;
rb_raise(rb_eTypeError,
- "initialization of %s only allowed from the gRPC native layer",
+ "Copy initialization of %s is not supported",
rb_obj_classname(copy));
return Qnil;
}
diff --git a/src/ruby/ext/grpc/rb_server.c b/src/ruby/ext/grpc/rb_server.c
index f108b8acfc..c92059d12c 100644
--- a/src/ruby/ext/grpc/rb_server.c
+++ b/src/ruby/ext/grpc/rb_server.c
@@ -154,35 +154,6 @@ static VALUE grpc_rb_server_init(VALUE self, VALUE cqueue, VALUE channel_args) {
return self;
}
-/* Clones Server instances.
-
- Gives Server a consistent implementation of Ruby's object copy/dup
- protocol. */
-static VALUE grpc_rb_server_init_copy(VALUE copy, VALUE orig) {
- grpc_rb_server *orig_srv = NULL;
- grpc_rb_server *copy_srv = NULL;
-
- if (copy == orig) {
- return copy;
- }
-
- /* Raise an error if orig is not a server object or a subclass. */
- if (TYPE(orig) != T_DATA ||
- RDATA(orig)->dfree != (RUBY_DATA_FUNC)grpc_rb_server_free) {
- rb_raise(rb_eTypeError, "not a %s", rb_obj_classname(grpc_rb_cServer));
- }
-
- TypedData_Get_Struct(orig, grpc_rb_server, &grpc_rb_server_data_type,
- orig_srv);
- TypedData_Get_Struct(copy, grpc_rb_server, &grpc_rb_server_data_type,
- copy_srv);
-
- /* use ruby's MEMCPY to make a byte-for-byte copy of the server wrapper
- object. */
- MEMCPY(copy_srv, orig_srv, grpc_rb_server, 1);
- return copy;
-}
-
/* request_call_stack holds various values used by the
* grpc_rb_server_request_call function */
typedef struct request_call_stack {
@@ -378,7 +349,7 @@ void Init_grpc_server() {
/* Provides a ruby constructor and support for dup/clone. */
rb_define_method(grpc_rb_cServer, "initialize", grpc_rb_server_init, 2);
rb_define_method(grpc_rb_cServer, "initialize_copy",
- grpc_rb_server_init_copy, 1);
+ grpc_rb_cannot_init_copy, 1);
/* Add the server methods. */
rb_define_method(grpc_rb_cServer, "request_call",
diff --git a/src/ruby/ext/grpc/rb_server_credentials.c b/src/ruby/ext/grpc/rb_server_credentials.c
index 3b0fb6c910..58ec852505 100644
--- a/src/ruby/ext/grpc/rb_server_credentials.c
+++ b/src/ruby/ext/grpc/rb_server_credentials.c
@@ -111,36 +111,6 @@ static VALUE grpc_rb_server_credentials_alloc(VALUE cls) {
wrapper);
}
-/* Clones ServerCredentials instances.
-
- Gives ServerCredentials a consistent implementation of Ruby's object copy/dup
- protocol. */
-static VALUE grpc_rb_server_credentials_init_copy(VALUE copy, VALUE orig) {
- grpc_rb_server_credentials *orig_ch = NULL;
- grpc_rb_server_credentials *copy_ch = NULL;
-
- if (copy == orig) {
- return copy;
- }
-
- /* Raise an error if orig is not a server_credentials object or a subclass. */
- if (TYPE(orig) != T_DATA ||
- RDATA(orig)->dfree != (RUBY_DATA_FUNC)grpc_rb_server_credentials_free) {
- rb_raise(rb_eTypeError, "not a %s",
- rb_obj_classname(grpc_rb_cServerCredentials));
- }
-
- TypedData_Get_Struct(orig, grpc_rb_server_credentials,
- &grpc_rb_server_credentials_data_type, orig_ch);
- TypedData_Get_Struct(copy, grpc_rb_server_credentials,
- &grpc_rb_server_credentials_data_type, copy_ch);
-
- /* use ruby's MEMCPY to make a byte-for-byte copy of the server_credentials
- wrapper object. */
- MEMCPY(copy_ch, orig_ch, grpc_rb_server_credentials, 1);
- return copy;
-}
-
/* The attribute used on the mark object to preserve the pem_root_certs. */
static ID id_pem_root_certs;
@@ -270,7 +240,7 @@ void Init_grpc_server_credentials() {
rb_define_method(grpc_rb_cServerCredentials, "initialize",
grpc_rb_server_credentials_init, 3);
rb_define_method(grpc_rb_cServerCredentials, "initialize_copy",
- grpc_rb_server_credentials_init_copy, 1);
+ grpc_rb_cannot_init_copy, 1);
id_pem_key_certs = rb_intern("__pem_key_certs");
id_pem_root_certs = rb_intern("__pem_root_certs");