aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ruby
diff options
context:
space:
mode:
authorGravatar Yuki Yugui Sonoda <yugui@yugui.jp>2015-04-13 08:26:09 +0900
committerGravatar Yuki Yugui Sonoda <yugui@yugui.jp>2015-04-16 18:45:14 +0900
commit29ee1dbc93d1b97578d39c796bfc19b99e57545f (patch)
tree99d473de9a2245f9c2e75077b7ce05bd00c4cc5d /src/ruby
parent9232f124e0c06cf2c0523d0b7c09b2dd462449d1 (diff)
Use TypedData for GRPC::Core::ServerCredentials
Diffstat (limited to 'src/ruby')
-rw-r--r--src/ruby/ext/grpc/rb_server_credentials.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/ruby/ext/grpc/rb_server_credentials.c b/src/ruby/ext/grpc/rb_server_credentials.c
index 8b813eaca1..ab16c05650 100644
--- a/src/ruby/ext/grpc/rb_server_credentials.c
+++ b/src/ruby/ext/grpc/rb_server_credentials.c
@@ -82,6 +82,14 @@ static void grpc_rb_server_credentials_mark(void *p) {
}
}
+static const rb_data_type_t grpc_rb_server_credentials_data_type = {
+ "grpc_server_credentials",
+ {grpc_rb_server_credentials_mark, grpc_rb_server_credentials_free,
+ GRPC_RB_MEMSIZE_UNAVAILABLE},
+ NULL, NULL,
+ RUBY_TYPED_FREE_IMMEDIATELY
+};
+
/* Allocates ServerCredential instances.
Provides safe initial defaults for the instance fields. */
@@ -89,8 +97,8 @@ static VALUE grpc_rb_server_credentials_alloc(VALUE cls) {
grpc_rb_server_credentials *wrapper = ALLOC(grpc_rb_server_credentials);
wrapper->wrapped = NULL;
wrapper->mark = Qnil;
- return Data_Wrap_Struct(cls, grpc_rb_server_credentials_mark,
- grpc_rb_server_credentials_free, wrapper);
+ return TypedData_Wrap_Struct(cls, &grpc_rb_server_credentials_data_type,
+ wrapper);
}
/* Clones ServerCredentials instances.
@@ -112,8 +120,10 @@ static VALUE grpc_rb_server_credentials_init_copy(VALUE copy, VALUE orig) {
rb_obj_classname(grpc_rb_cServerCredentials));
}
- Data_Get_Struct(orig, grpc_rb_server_credentials, orig_ch);
- Data_Get_Struct(copy, grpc_rb_server_credentials, copy_ch);
+ 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. */
@@ -149,7 +159,8 @@ static VALUE grpc_rb_server_credentials_init(VALUE self, VALUE pem_root_certs,
grpc_rb_server_credentials *wrapper = NULL;
grpc_server_credentials *creds = NULL;
grpc_ssl_pem_key_cert_pair key_cert_pair = {NULL, NULL};
- Data_Get_Struct(self, grpc_rb_server_credentials, wrapper);
+ TypedData_Get_Struct(self, grpc_rb_server_credentials,
+ &grpc_rb_server_credentials_data_type, wrapper);
if (pem_cert_chain == Qnil) {
rb_raise(rb_eRuntimeError,
"could not create a server credential: nil pem_cert_chain");
@@ -206,6 +217,7 @@ void Init_grpc_server_credentials() {
/* Gets the wrapped grpc_server_credentials from the ruby wrapper */
grpc_server_credentials *grpc_rb_get_wrapped_server_credentials(VALUE v) {
grpc_rb_server_credentials *wrapper = NULL;
- Data_Get_Struct(v, grpc_rb_server_credentials, wrapper);
+ TypedData_Get_Struct(v, grpc_rb_server_credentials,
+ &grpc_rb_server_credentials_data_type, wrapper);
return wrapper->wrapped;
}