Avoid identifiers reserved by Ruby

"prefix `rb` shows that it belongs to `ruby`". [RHG]

`rb` is a prefix to prevent exported symbols in libruby from
conflicting with symbols in other libraries, in particular,
dynamically loaded Ruby extension libraries.
So the prefix is reserved by Ruby by convention.

For gRPC, simply "grpc_" would be a better prefix.

[RHG]: Minero Aoki. "The Ruby Hacking Guide" (2002), chapter 4
pull/1245/head
Yuki Yugui Sonoda 10 years ago
parent e2ecc50841
commit d241bcc030
  1. 20
      src/ruby/ext/grpc/rb_byte_buffer.c
  2. 4
      src/ruby/ext/grpc/rb_byte_buffer.h
  3. 78
      src/ruby/ext/grpc/rb_call.c
  4. 8
      src/ruby/ext/grpc/rb_call.h
  5. 32
      src/ruby/ext/grpc/rb_channel.c
  6. 4
      src/ruby/ext/grpc/rb_channel.h
  7. 4
      src/ruby/ext/grpc/rb_channel_args.c
  8. 14
      src/ruby/ext/grpc/rb_completion_queue.c
  9. 4
      src/ruby/ext/grpc/rb_completion_queue.h
  10. 24
      src/ruby/ext/grpc/rb_credentials.c
  11. 4
      src/ruby/ext/grpc/rb_credentials.h
  12. 86
      src/ruby/ext/grpc/rb_event.c
  13. 8
      src/ruby/ext/grpc/rb_event.h
  14. 90
      src/ruby/ext/grpc/rb_grpc.c
  15. 14
      src/ruby/ext/grpc/rb_grpc.h
  16. 20
      src/ruby/ext/grpc/rb_metadata.c
  17. 4
      src/ruby/ext/grpc/rb_metadata.h
  18. 26
      src/ruby/ext/grpc/rb_server.c
  19. 4
      src/ruby/ext/grpc/rb_server.h
  20. 16
      src/ruby/ext/grpc/rb_server_credentials.c
  21. 4
      src/ruby/ext/grpc/rb_server_credentials.h

@ -110,7 +110,7 @@ static VALUE grpc_rb_byte_buffer_init_copy(VALUE copy, VALUE orig) {
/* Raise an error if orig is not a metadata object or a subclass. */
if (TYPE(orig) != T_DATA ||
RDATA(orig)->dfree != (RUBY_DATA_FUNC)grpc_rb_byte_buffer_free) {
rb_raise(rb_eTypeError, "not a %s", rb_obj_classname(rb_cByteBuffer));
rb_raise(rb_eTypeError, "not a %s", rb_obj_classname(grpc_cByteBuffer));
}
Data_Get_Struct(orig, grpc_rb_byte_buffer, orig_bb);
@ -199,23 +199,23 @@ static VALUE grpc_rb_byte_buffer_init(VALUE self, VALUE src) {
return self;
}
/* rb_cByteBuffer is the ruby class that proxies grpc_byte_buffer. */
VALUE rb_cByteBuffer = Qnil;
/* grpc_cByteBuffer is the ruby class that proxies grpc_byte_buffer. */
VALUE grpc_cByteBuffer = Qnil;
void Init_grpc_byte_buffer() {
rb_cByteBuffer =
rb_define_class_under(rb_mGrpcCore, "ByteBuffer", rb_cObject);
grpc_cByteBuffer =
rb_define_class_under(grpc_mGrpcCore, "ByteBuffer", rb_cObject);
/* Allocates an object managed by the ruby runtime */
rb_define_alloc_func(rb_cByteBuffer, grpc_rb_byte_buffer_alloc);
rb_define_alloc_func(grpc_cByteBuffer, grpc_rb_byte_buffer_alloc);
/* Provides a ruby constructor and support for dup/clone. */
rb_define_method(rb_cByteBuffer, "initialize", grpc_rb_byte_buffer_init, 1);
rb_define_method(rb_cByteBuffer, "initialize_copy",
rb_define_method(grpc_cByteBuffer, "initialize", grpc_rb_byte_buffer_init, 1);
rb_define_method(grpc_cByteBuffer, "initialize_copy",
grpc_rb_byte_buffer_init_copy, 1);
/* Provides a to_s method that returns the buffer value */
rb_define_method(rb_cByteBuffer, "to_s", grpc_rb_byte_buffer_to_s, 0);
rb_define_method(grpc_cByteBuffer, "to_s", grpc_rb_byte_buffer_to_s, 0);
id_source = rb_intern("__source");
id_empty = rb_intern("");
@ -229,7 +229,7 @@ VALUE grpc_rb_byte_buffer_create_with_mark(VALUE mark, grpc_byte_buffer *bb) {
byte_buffer = ALLOC(grpc_rb_byte_buffer);
byte_buffer->wrapped = bb;
byte_buffer->mark = mark;
return Data_Wrap_Struct(rb_cByteBuffer, grpc_rb_byte_buffer_mark,
return Data_Wrap_Struct(grpc_cByteBuffer, grpc_rb_byte_buffer_mark,
grpc_rb_byte_buffer_free, byte_buffer);
}

@ -37,9 +37,9 @@
#include <grpc/grpc.h>
#include <ruby.h>
/* rb_cByteBuffer is the ByteBuffer class whose instances proxy
/* grpc_cByteBuffer is the ByteBuffer class whose instances proxy
grpc_byte_buffer. */
extern VALUE rb_cByteBuffer;
extern VALUE grpc_cByteBuffer;
/* Initializes the ByteBuffer class. */
void Init_grpc_byte_buffer();

@ -123,22 +123,22 @@ int grpc_rb_call_add_metadata_hash_cb(VALUE key, VALUE val, VALUE call_obj) {
array_length = RARRAY_LEN(val);
for (i = 0; i < array_length; i++) {
md_obj_args[1] = rb_ary_entry(val, i);
md_obj = rb_class_new_instance(2, md_obj_args, rb_cMetadata);
md_obj = rb_class_new_instance(2, md_obj_args, grpc_cMetadata);
md = grpc_rb_get_wrapped_metadata(md_obj);
err = grpc_call_add_metadata_old(call, md, NUM2UINT(flags));
if (err != GRPC_CALL_OK) {
rb_raise(rb_eCallError, "add metadata failed: %s (code=%d)",
rb_raise(grpc_eCallError, "add metadata failed: %s (code=%d)",
grpc_call_error_detail_of(err), err);
return ST_STOP;
}
}
} else {
md_obj_args[1] = val;
md_obj = rb_class_new_instance(2, md_obj_args, rb_cMetadata);
md_obj = rb_class_new_instance(2, md_obj_args, grpc_cMetadata);
md = grpc_rb_get_wrapped_metadata(md_obj);
err = grpc_call_add_metadata_old(call, md, NUM2UINT(flags));
if (err != GRPC_CALL_OK) {
rb_raise(rb_eCallError, "add metadata failed: %s (code=%d)",
rb_raise(grpc_eCallError, "add metadata failed: %s (code=%d)",
grpc_call_error_detail_of(err), err);
return ST_STOP;
}
@ -187,7 +187,7 @@ static VALUE grpc_rb_call_cancel(VALUE self) {
Data_Get_Struct(self, grpc_call, call);
err = grpc_call_cancel(call);
if (err != GRPC_CALL_OK) {
rb_raise(rb_eCallError, "cancel failed: %s (code=%d)",
rb_raise(grpc_eCallError, "cancel failed: %s (code=%d)",
grpc_call_error_detail_of(err), err);
}
@ -223,7 +223,7 @@ static VALUE grpc_rb_call_invoke(int argc, VALUE *argv, VALUE self) {
err = grpc_call_invoke_old(call, cq, ROBJECT(metadata_read_tag),
ROBJECT(finished_tag), NUM2UINT(flags));
if (err != GRPC_CALL_OK) {
rb_raise(rb_eCallError, "invoke failed: %s (code=%d)",
rb_raise(grpc_eCallError, "invoke failed: %s (code=%d)",
grpc_call_error_detail_of(err), err);
}
@ -244,7 +244,7 @@ static VALUE grpc_rb_call_start_read(VALUE self, VALUE tag) {
Data_Get_Struct(self, grpc_call, call);
err = grpc_call_start_read_old(call, ROBJECT(tag));
if (err != GRPC_CALL_OK) {
rb_raise(rb_eCallError, "start read failed: %s (code=%d)",
rb_raise(grpc_eCallError, "start read failed: %s (code=%d)",
grpc_call_error_detail_of(err), err);
}
@ -266,7 +266,7 @@ static VALUE grpc_rb_call_get_status(VALUE self) {
Saves a status object on the call. */
static VALUE grpc_rb_call_set_status(VALUE self, VALUE status) {
if (!NIL_P(status) && rb_obj_class(status) != rb_sStatus) {
if (!NIL_P(status) && rb_obj_class(status) != grpc_sStatus) {
rb_raise(rb_eTypeError, "bad status: got:<%s> want: <Struct::Status>",
rb_obj_classname(status));
return Qnil;
@ -332,7 +332,7 @@ static VALUE grpc_rb_call_start_write(int argc, VALUE *argv, VALUE self) {
Data_Get_Struct(self, grpc_call, call);
err = grpc_call_start_write_old(call, bfr, ROBJECT(tag), NUM2UINT(flags));
if (err != GRPC_CALL_OK) {
rb_raise(rb_eCallError, "start write failed: %s (code=%d)",
rb_raise(grpc_eCallError, "start write failed: %s (code=%d)",
grpc_call_error_detail_of(err), err);
}
@ -361,7 +361,7 @@ static VALUE grpc_rb_call_start_write_status(VALUE self, VALUE code,
err = grpc_call_start_write_status_old(call, NUM2UINT(code),
StringValueCStr(status), ROBJECT(tag));
if (err != GRPC_CALL_OK) {
rb_raise(rb_eCallError, "start write status: %s (code=%d)",
rb_raise(grpc_eCallError, "start write status: %s (code=%d)",
grpc_call_error_detail_of(err), err);
}
@ -376,7 +376,7 @@ static VALUE grpc_rb_call_writes_done(VALUE self, VALUE tag) {
Data_Get_Struct(self, grpc_call, call);
err = grpc_call_writes_done_old(call, ROBJECT(tag));
if (err != GRPC_CALL_OK) {
rb_raise(rb_eCallError, "writes done: %s (code=%d)",
rb_raise(grpc_eCallError, "writes done: %s (code=%d)",
grpc_call_error_detail_of(err), err);
}
@ -407,7 +407,7 @@ static VALUE grpc_rb_call_server_end_initial_metadata(int argc, VALUE *argv,
Data_Get_Struct(self, grpc_call, call);
err = grpc_call_server_end_initial_metadata_old(call, NUM2UINT(flags));
if (err != GRPC_CALL_OK) {
rb_raise(rb_eCallError, "end_initial_metadata failed: %s (code=%d)",
rb_raise(grpc_eCallError, "end_initial_metadata failed: %s (code=%d)",
grpc_call_error_detail_of(err), err);
}
return Qnil;
@ -432,7 +432,7 @@ static VALUE grpc_rb_call_server_accept(VALUE self, VALUE cqueue,
Data_Get_Struct(self, grpc_call, call);
err = grpc_call_server_accept_old(call, cq, ROBJECT(finished_tag));
if (err != GRPC_CALL_OK) {
rb_raise(rb_eCallError, "server_accept failed: %s (code=%d)",
rb_raise(grpc_eCallError, "server_accept failed: %s (code=%d)",
grpc_call_error_detail_of(err), err);
}
@ -442,16 +442,16 @@ static VALUE grpc_rb_call_server_accept(VALUE self, VALUE cqueue,
return Qnil;
}
/* rb_cCall is the ruby class that proxies grpc_call. */
VALUE rb_cCall = Qnil;
/* grpc_cCall is the ruby class that proxies grpc_call. */
VALUE grpc_cCall = Qnil;
/* rb_eCallError is the ruby class of the exception thrown during call
/* grpc_eCallError is the ruby class of the exception thrown during call
operations; */
VALUE rb_eCallError = Qnil;
VALUE grpc_eCallError = Qnil;
void Init_grpc_error_codes() {
/* Constants representing the error codes of grpc_call_error in grpc.h */
VALUE rb_RpcErrors = rb_define_module_under(rb_mGrpcCore, "RpcErrors");
VALUE rb_RpcErrors = rb_define_module_under(grpc_mGrpcCore, "RpcErrors");
rb_define_const(rb_RpcErrors, "OK", UINT2NUM(GRPC_CALL_OK));
rb_define_const(rb_RpcErrors, "ERROR", UINT2NUM(GRPC_CALL_ERROR));
rb_define_const(rb_RpcErrors, "NOT_ON_SERVER",
@ -502,31 +502,31 @@ void Init_grpc_error_codes() {
void Init_grpc_call() {
/* CallError inherits from Exception to signal that it is non-recoverable */
rb_eCallError =
rb_define_class_under(rb_mGrpcCore, "CallError", rb_eException);
rb_cCall = rb_define_class_under(rb_mGrpcCore, "Call", rb_cObject);
grpc_eCallError =
rb_define_class_under(grpc_mGrpcCore, "CallError", rb_eException);
grpc_cCall = rb_define_class_under(grpc_mGrpcCore, "Call", rb_cObject);
/* Prevent allocation or inialization of the Call class */
rb_define_alloc_func(rb_cCall, grpc_rb_cannot_alloc);
rb_define_method(rb_cCall, "initialize", grpc_rb_cannot_init, 0);
rb_define_method(rb_cCall, "initialize_copy", grpc_rb_cannot_init_copy, 1);
rb_define_alloc_func(grpc_cCall, grpc_rb_cannot_alloc);
rb_define_method(grpc_cCall, "initialize", grpc_rb_cannot_init, 0);
rb_define_method(grpc_cCall, "initialize_copy", grpc_rb_cannot_init_copy, 1);
/* Add ruby analogues of the Call methods. */
rb_define_method(rb_cCall, "server_accept", grpc_rb_call_server_accept, 2);
rb_define_method(rb_cCall, "server_end_initial_metadata",
rb_define_method(grpc_cCall, "server_accept", grpc_rb_call_server_accept, 2);
rb_define_method(grpc_cCall, "server_end_initial_metadata",
grpc_rb_call_server_end_initial_metadata, -1);
rb_define_method(rb_cCall, "add_metadata", grpc_rb_call_add_metadata, -1);
rb_define_method(rb_cCall, "cancel", grpc_rb_call_cancel, 0);
rb_define_method(rb_cCall, "invoke", grpc_rb_call_invoke, -1);
rb_define_method(rb_cCall, "start_read", grpc_rb_call_start_read, 1);
rb_define_method(rb_cCall, "start_write", grpc_rb_call_start_write, -1);
rb_define_method(rb_cCall, "start_write_status",
rb_define_method(grpc_cCall, "add_metadata", grpc_rb_call_add_metadata, -1);
rb_define_method(grpc_cCall, "cancel", grpc_rb_call_cancel, 0);
rb_define_method(grpc_cCall, "invoke", grpc_rb_call_invoke, -1);
rb_define_method(grpc_cCall, "start_read", grpc_rb_call_start_read, 1);
rb_define_method(grpc_cCall, "start_write", grpc_rb_call_start_write, -1);
rb_define_method(grpc_cCall, "start_write_status",
grpc_rb_call_start_write_status, 3);
rb_define_method(rb_cCall, "writes_done", grpc_rb_call_writes_done, 1);
rb_define_method(rb_cCall, "status", grpc_rb_call_get_status, 0);
rb_define_method(rb_cCall, "status=", grpc_rb_call_set_status, 1);
rb_define_method(rb_cCall, "metadata", grpc_rb_call_get_metadata, 0);
rb_define_method(rb_cCall, "metadata=", grpc_rb_call_set_metadata, 1);
rb_define_method(grpc_cCall, "writes_done", grpc_rb_call_writes_done, 1);
rb_define_method(grpc_cCall, "status", grpc_rb_call_get_status, 0);
rb_define_method(grpc_cCall, "status=", grpc_rb_call_set_status, 1);
rb_define_method(grpc_cCall, "metadata", grpc_rb_call_get_metadata, 0);
rb_define_method(grpc_cCall, "metadata=", grpc_rb_call_set_metadata, 1);
/* Ids used to support call attributes */
id_metadata = rb_intern("metadata");
@ -540,7 +540,7 @@ void Init_grpc_call() {
/* The hash for reference counting calls, to ensure they can't be destroyed
* more than once */
hash_all_calls = rb_hash_new();
rb_define_const(rb_cCall, "INTERNAL_ALL_CALLs", hash_all_calls);
rb_define_const(grpc_cCall, "INTERNAL_ALL_CALLs", hash_all_calls);
Init_grpc_error_codes();
}
@ -565,5 +565,5 @@ VALUE grpc_rb_wrap_call(grpc_call *c) {
rb_hash_aset(hash_all_calls, OFFT2NUM((VALUE)c),
UINT2NUM(NUM2UINT(obj) + 1));
}
return Data_Wrap_Struct(rb_cCall, GC_NOT_MARKED, grpc_rb_call_destroy, c);
return Data_Wrap_Struct(grpc_cCall, GC_NOT_MARKED, grpc_rb_call_destroy, c);
}

@ -46,12 +46,12 @@ VALUE grpc_rb_wrap_call(grpc_call* c);
/* Provides the details of an call error */
const char* grpc_call_error_detail_of(grpc_call_error err);
/* rb_cCall is the Call class whose instances proxy grpc_call. */
extern VALUE rb_cCall;
/* grpc_cCall is the Call class whose instances proxy grpc_call. */
extern VALUE grpc_cCall;
/* rb_cCallError is the ruby class of the exception thrown during call
/* grpc_cCallError is the ruby class of the exception thrown during call
operations. */
extern VALUE rb_eCallError;
extern VALUE grpc_eCallError;
/* Initializes the Call class. */
void Init_grpc_call();

@ -54,7 +54,7 @@ static ID id_channel;
static ID id_target;
/* Used during the conversion of a hash to channel args during channel setup */
static VALUE rb_cChannelArgs;
static VALUE grpc_cChannelArgs;
/* grpc_rb_channel wraps a grpc_channel. It provides a peer ruby object,
* 'mark' to minimize copying when a channel is created from ruby. */
@ -163,7 +163,7 @@ static VALUE grpc_rb_channel_init_copy(VALUE copy, VALUE orig) {
/* 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(rb_cChannel));
rb_raise(rb_eTypeError, "not a %s", rb_obj_classname(grpc_cChannel));
}
Data_Get_Struct(orig, grpc_rb_channel, orig_ch);
@ -224,35 +224,35 @@ static VALUE grpc_rb_channel_destroy(VALUE self) {
return Qnil;
}
/* rb_cChannel is the ruby class that proxies grpc_channel. */
VALUE rb_cChannel = Qnil;
/* grpc_cChannel is the ruby class that proxies grpc_channel. */
VALUE grpc_cChannel = Qnil;
void Init_grpc_channel() {
rb_cChannelArgs = rb_define_class("TmpChannelArgs", rb_cObject);
rb_cChannel = rb_define_class_under(rb_mGrpcCore, "Channel", rb_cObject);
grpc_cChannelArgs = rb_define_class("TmpChannelArgs", rb_cObject);
grpc_cChannel = rb_define_class_under(grpc_mGrpcCore, "Channel", rb_cObject);
/* Allocates an object managed by the ruby runtime */
rb_define_alloc_func(rb_cChannel, grpc_rb_channel_alloc);
rb_define_alloc_func(grpc_cChannel, grpc_rb_channel_alloc);
/* Provides a ruby constructor and support for dup/clone. */
rb_define_method(rb_cChannel, "initialize", grpc_rb_channel_init, -1);
rb_define_method(rb_cChannel, "initialize_copy", grpc_rb_channel_init_copy,
rb_define_method(grpc_cChannel, "initialize", grpc_rb_channel_init, -1);
rb_define_method(grpc_cChannel, "initialize_copy", grpc_rb_channel_init_copy,
1);
/* Add ruby analogues of the Channel methods. */
rb_define_method(rb_cChannel, "create_call", grpc_rb_channel_create_call, 3);
rb_define_method(rb_cChannel, "destroy", grpc_rb_channel_destroy, 0);
rb_define_alias(rb_cChannel, "close", "destroy");
rb_define_method(grpc_cChannel, "create_call", grpc_rb_channel_create_call, 3);
rb_define_method(grpc_cChannel, "destroy", grpc_rb_channel_destroy, 0);
rb_define_alias(grpc_cChannel, "close", "destroy");
id_channel = rb_intern("__channel");
id_target = rb_intern("__target");
rb_define_const(rb_cChannel, "SSL_TARGET",
rb_define_const(grpc_cChannel, "SSL_TARGET",
ID2SYM(rb_intern(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG)));
rb_define_const(rb_cChannel, "ENABLE_CENSUS",
rb_define_const(grpc_cChannel, "ENABLE_CENSUS",
ID2SYM(rb_intern(GRPC_ARG_ENABLE_CENSUS)));
rb_define_const(rb_cChannel, "MAX_CONCURRENT_STREAMS",
rb_define_const(grpc_cChannel, "MAX_CONCURRENT_STREAMS",
ID2SYM(rb_intern(GRPC_ARG_MAX_CONCURRENT_STREAMS)));
rb_define_const(rb_cChannel, "MAX_MESSAGE_LENGTH",
rb_define_const(grpc_cChannel, "MAX_MESSAGE_LENGTH",
ID2SYM(rb_intern(GRPC_ARG_MAX_MESSAGE_LENGTH)));
}

@ -37,8 +37,8 @@
#include <ruby.h>
#include <grpc/grpc.h>
/* rb_cChannel is the Channel class whose instances proxy grpc_channel. */
extern VALUE rb_cChannel;
/* grpc_cChannel is the Channel class whose instances proxy grpc_channel. */
extern VALUE grpc_cChannel;
/* Initializes the Channel class. */
void Init_grpc_channel();

@ -109,7 +109,7 @@ typedef struct channel_convert_params {
static VALUE grpc_rb_hash_convert_to_channel_args0(VALUE as_value) {
ID id_size = rb_intern("size");
VALUE rb_cChannelArgs = rb_define_class("TmpChannelArgs", rb_cObject);
VALUE grpc_cChannelArgs = rb_define_class("TmpChannelArgs", rb_cObject);
channel_convert_params* params = (channel_convert_params*)as_value;
size_t num_args = 0;
@ -126,7 +126,7 @@ static VALUE grpc_rb_hash_convert_to_channel_args0(VALUE as_value) {
MEMZERO(params->dst->args, grpc_arg, num_args);
rb_hash_foreach(params->src_hash,
grpc_rb_channel_create_in_process_add_args_hash_cb,
Data_Wrap_Struct(rb_cChannelArgs, GC_NOT_MARKED,
Data_Wrap_Struct(grpc_cChannelArgs, GC_NOT_MARKED,
GC_DONT_FREE, params->dst));
/* reset num_args as grpc_rb_channel_create_in_process_add_args_hash_cb
* decrements it during has processing */

@ -156,24 +156,24 @@ static VALUE grpc_rb_completion_queue_pluck(VALUE self, VALUE tag,
return grpc_rb_new_event(next_call.event);
}
/* rb_cCompletionQueue is the ruby class that proxies grpc_completion_queue. */
VALUE rb_cCompletionQueue = Qnil;
/* grpc_cCompletionQueue is the ruby class that proxies grpc_completion_queue. */
VALUE grpc_cCompletionQueue = Qnil;
void Init_grpc_completion_queue() {
rb_cCompletionQueue =
rb_define_class_under(rb_mGrpcCore, "CompletionQueue", rb_cObject);
grpc_cCompletionQueue =
rb_define_class_under(grpc_mGrpcCore, "CompletionQueue", rb_cObject);
/* constructor: uses an alloc func without an initializer. Using a simple
alloc func works here as the grpc header does not specify any args for
this func, so no separate initialization step is necessary. */
rb_define_alloc_func(rb_cCompletionQueue, grpc_rb_completion_queue_alloc);
rb_define_alloc_func(grpc_cCompletionQueue, grpc_rb_completion_queue_alloc);
/* Add the next method that waits for the next event. */
rb_define_method(rb_cCompletionQueue, "next", grpc_rb_completion_queue_next,
rb_define_method(grpc_cCompletionQueue, "next", grpc_rb_completion_queue_next,
1);
/* Add the pluck method that waits for the next event of given tag */
rb_define_method(rb_cCompletionQueue, "pluck", grpc_rb_completion_queue_pluck,
rb_define_method(grpc_cCompletionQueue, "pluck", grpc_rb_completion_queue_pluck,
2);
}

@ -40,9 +40,9 @@
/* Gets the wrapped completion queue from the ruby wrapper */
grpc_completion_queue *grpc_rb_get_wrapped_completion_queue(VALUE v);
/* rb_cCompletionQueue is the CompletionQueue class whose instances proxy
/* grpc_cCompletionQueue is the CompletionQueue class whose instances proxy
grpc_completion_queue. */
extern VALUE rb_cCompletionQueue;
extern VALUE grpc_cCompletionQueue;
/* Initializes the CompletionQueue class. */
void Init_grpc_completion_queue();

@ -107,7 +107,7 @@ static VALUE grpc_rb_credentials_init_copy(VALUE copy, VALUE orig) {
/* 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_credentials_free) {
rb_raise(rb_eTypeError, "not a %s", rb_obj_classname(rb_cCredentials));
rb_raise(rb_eTypeError, "not a %s", rb_obj_classname(grpc_cCredentials));
}
Data_Get_Struct(orig, grpc_rb_credentials, orig_cred);
@ -178,7 +178,7 @@ static VALUE grpc_rb_composite_credentials_create(VALUE self, VALUE other) {
}
wrapper->mark = Qnil;
return Data_Wrap_Struct(rb_cCredentials, grpc_rb_credentials_mark,
return Data_Wrap_Struct(grpc_cCredentials, grpc_rb_credentials_mark,
grpc_rb_credentials_free, wrapper);
}
@ -242,30 +242,30 @@ static VALUE grpc_rb_credentials_init(int argc, VALUE *argv, VALUE self) {
return self;
}
/* rb_cCredentials is the ruby class that proxies grpc_credentials. */
VALUE rb_cCredentials = Qnil;
/* grpc_cCredentials is the ruby class that proxies grpc_credentials. */
VALUE grpc_cCredentials = Qnil;
void Init_grpc_credentials() {
rb_cCredentials =
rb_define_class_under(rb_mGrpcCore, "Credentials", rb_cObject);
grpc_cCredentials =
rb_define_class_under(grpc_mGrpcCore, "Credentials", rb_cObject);
/* Allocates an object managed by the ruby runtime */
rb_define_alloc_func(rb_cCredentials, grpc_rb_credentials_alloc);
rb_define_alloc_func(grpc_cCredentials, grpc_rb_credentials_alloc);
/* Provides a ruby constructor and support for dup/clone. */
rb_define_method(rb_cCredentials, "initialize", grpc_rb_credentials_init, -1);
rb_define_method(rb_cCredentials, "initialize_copy",
rb_define_method(grpc_cCredentials, "initialize", grpc_rb_credentials_init, -1);
rb_define_method(grpc_cCredentials, "initialize_copy",
grpc_rb_credentials_init_copy, 1);
/* Provide static funcs that create new special instances. */
rb_define_singleton_method(rb_cCredentials, "default",
rb_define_singleton_method(grpc_cCredentials, "default",
grpc_rb_default_credentials_create, 0);
rb_define_singleton_method(rb_cCredentials, "compute_engine",
rb_define_singleton_method(grpc_cCredentials, "compute_engine",
grpc_rb_compute_engine_credentials_create, 0);
/* Provide other methods. */
rb_define_method(rb_cCredentials, "compose",
rb_define_method(grpc_cCredentials, "compose",
grpc_rb_composite_credentials_create, 1);
id_pem_cert_chain = rb_intern("__pem_cert_chain");

@ -37,9 +37,9 @@
#include <ruby.h>
#include <grpc/grpc_security.h>
/* rb_cCredentials is the ruby class whose instances proxy
/* grpc_cCredentials is the ruby class whose instances proxy
grpc_credentials. */
extern VALUE rb_cCredentials;
extern VALUE grpc_cCredentials;
/* Initializes the ruby Credentials class. */
void Init_grpc_credentials();

@ -50,8 +50,8 @@ typedef struct grpc_rb_event {
grpc_event *wrapped;
} grpc_rb_event;
/* rb_mCompletionType is a ruby module that holds the completion type values */
VALUE rb_mCompletionType = Qnil;
/* grpc_mCompletionType is a ruby module that holds the completion type values */
VALUE grpc_mCompletionType = Qnil;
/* Destroys Event instances. */
static void grpc_rb_event_free(void *p) {
@ -100,28 +100,28 @@ static VALUE grpc_rb_event_type(VALUE self) {
event = wrapper->wrapped;
switch (event->type) {
case GRPC_QUEUE_SHUTDOWN:
return rb_const_get(rb_mCompletionType, rb_intern("QUEUE_SHUTDOWN"));
return rb_const_get(grpc_mCompletionType, rb_intern("QUEUE_SHUTDOWN"));
case GRPC_READ:
return rb_const_get(rb_mCompletionType, rb_intern("READ"));
return rb_const_get(grpc_mCompletionType, rb_intern("READ"));
case GRPC_WRITE_ACCEPTED:
grpc_rb_event_result(self); /* validates the result */
return rb_const_get(rb_mCompletionType, rb_intern("WRITE_ACCEPTED"));
return rb_const_get(grpc_mCompletionType, rb_intern("WRITE_ACCEPTED"));
case GRPC_FINISH_ACCEPTED:
grpc_rb_event_result(self); /* validates the result */
return rb_const_get(rb_mCompletionType, rb_intern("FINISH_ACCEPTED"));
return rb_const_get(grpc_mCompletionType, rb_intern("FINISH_ACCEPTED"));
case GRPC_CLIENT_METADATA_READ:
return rb_const_get(rb_mCompletionType,
return rb_const_get(grpc_mCompletionType,
rb_intern("CLIENT_METADATA_READ"));
case GRPC_FINISHED:
return rb_const_get(rb_mCompletionType, rb_intern("FINISHED"));
return rb_const_get(grpc_mCompletionType, rb_intern("FINISHED"));
case GRPC_SERVER_RPC_NEW:
return rb_const_get(rb_mCompletionType, rb_intern("SERVER_RPC_NEW"));
return rb_const_get(grpc_mCompletionType, rb_intern("SERVER_RPC_NEW"));
default:
rb_raise(rb_eRuntimeError, "unrecognized event code for an rpc event:%d",
@ -252,7 +252,7 @@ static VALUE grpc_rb_event_result(VALUE self) {
if (event->data.finish_accepted == GRPC_OP_OK) {
return Qnil;
}
rb_raise(rb_eEventError, "finish failed, not sure why (code=%d)",
rb_raise(grpc_eEventError, "finish failed, not sure why (code=%d)",
event->data.finish_accepted);
break;
@ -260,7 +260,7 @@ static VALUE grpc_rb_event_result(VALUE self) {
if (event->data.write_accepted == GRPC_OP_OK) {
return Qnil;
}
rb_raise(rb_eEventError, "write failed, not sure why (code=%d)",
rb_raise(grpc_eEventError, "write failed, not sure why (code=%d)",
event->data.write_accepted);
break;
@ -268,7 +268,7 @@ static VALUE grpc_rb_event_result(VALUE self) {
return grpc_rb_event_metadata(self);
case GRPC_FINISHED:
return rb_struct_new(rb_sStatus, UINT2NUM(event->data.finished.status),
return rb_struct_new(grpc_sStatus, UINT2NUM(event->data.finished.status),
(event->data.finished.details == NULL
? Qnil
: rb_str_new2(event->data.finished.details)),
@ -277,9 +277,9 @@ static VALUE grpc_rb_event_result(VALUE self) {
case GRPC_SERVER_RPC_NEW:
return rb_struct_new(
rb_sNewServerRpc, rb_str_new2(event->data.server_rpc_new.method),
grpc_sNewServerRpc, rb_str_new2(event->data.server_rpc_new.method),
rb_str_new2(event->data.server_rpc_new.host),
Data_Wrap_Struct(rb_cTimeVal, GC_NOT_MARKED, GC_DONT_FREE,
Data_Wrap_Struct(grpc_cTimeVal, GC_NOT_MARKED, GC_DONT_FREE,
(void *)&event->data.server_rpc_new.deadline),
grpc_rb_event_metadata(self), NULL);
@ -305,50 +305,50 @@ static VALUE grpc_rb_event_finish(VALUE self) {
return Qnil;
}
/* rb_cEvent is the Event class whose instances proxy grpc_event */
VALUE rb_cEvent = Qnil;
/* grpc_cEvent is the Event class whose instances proxy grpc_event */
VALUE grpc_cEvent = Qnil;
/* rb_eEventError is the ruby class of the exception thrown on failures during
/* grpc_eEventError is the ruby class of the exception thrown on failures during
rpc event processing. */
VALUE rb_eEventError = Qnil;
VALUE grpc_eEventError = Qnil;
void Init_grpc_event() {
rb_eEventError =
rb_define_class_under(rb_mGrpcCore, "EventError", rb_eStandardError);
rb_cEvent = rb_define_class_under(rb_mGrpcCore, "Event", rb_cObject);
grpc_eEventError =
rb_define_class_under(grpc_mGrpcCore, "EventError", rb_eStandardError);
grpc_cEvent = rb_define_class_under(grpc_mGrpcCore, "Event", rb_cObject);
/* Prevent allocation or inialization from ruby. */
rb_define_alloc_func(rb_cEvent, grpc_rb_cannot_alloc);
rb_define_method(rb_cEvent, "initialize", grpc_rb_cannot_init, 0);
rb_define_method(rb_cEvent, "initialize_copy", grpc_rb_cannot_init_copy, 1);
rb_define_alloc_func(grpc_cEvent, grpc_rb_cannot_alloc);
rb_define_method(grpc_cEvent, "initialize", grpc_rb_cannot_init, 0);
rb_define_method(grpc_cEvent, "initialize_copy", grpc_rb_cannot_init_copy, 1);
/* Accessors for the data available in an event. */
rb_define_method(rb_cEvent, "call", grpc_rb_event_call, 0);
rb_define_method(rb_cEvent, "result", grpc_rb_event_result, 0);
rb_define_method(rb_cEvent, "tag", grpc_rb_event_tag, 0);
rb_define_method(rb_cEvent, "type", grpc_rb_event_type, 0);
rb_define_method(rb_cEvent, "finish", grpc_rb_event_finish, 0);
rb_define_alias(rb_cEvent, "close", "finish");
rb_define_method(grpc_cEvent, "call", grpc_rb_event_call, 0);
rb_define_method(grpc_cEvent, "result", grpc_rb_event_result, 0);
rb_define_method(grpc_cEvent, "tag", grpc_rb_event_tag, 0);
rb_define_method(grpc_cEvent, "type", grpc_rb_event_type, 0);
rb_define_method(grpc_cEvent, "finish", grpc_rb_event_finish, 0);
rb_define_alias(grpc_cEvent, "close", "finish");
/* Constants representing the completion types */
rb_mCompletionType =
rb_define_module_under(rb_mGrpcCore, "CompletionType");
rb_define_const(rb_mCompletionType, "QUEUE_SHUTDOWN",
grpc_mCompletionType =
rb_define_module_under(grpc_mGrpcCore, "CompletionType");
rb_define_const(grpc_mCompletionType, "QUEUE_SHUTDOWN",
INT2NUM(GRPC_QUEUE_SHUTDOWN));
rb_define_const(rb_mCompletionType, "OP_COMPLETE", INT2NUM(GRPC_OP_COMPLETE));
rb_define_const(rb_mCompletionType, "READ", INT2NUM(GRPC_READ));
rb_define_const(rb_mCompletionType, "WRITE_ACCEPTED",
rb_define_const(grpc_mCompletionType, "OP_COMPLETE", INT2NUM(GRPC_OP_COMPLETE));
rb_define_const(grpc_mCompletionType, "READ", INT2NUM(GRPC_READ));
rb_define_const(grpc_mCompletionType, "WRITE_ACCEPTED",
INT2NUM(GRPC_WRITE_ACCEPTED));
rb_define_const(rb_mCompletionType, "FINISH_ACCEPTED",
rb_define_const(grpc_mCompletionType, "FINISH_ACCEPTED",
INT2NUM(GRPC_FINISH_ACCEPTED));
rb_define_const(rb_mCompletionType, "CLIENT_METADATA_READ",
rb_define_const(grpc_mCompletionType, "CLIENT_METADATA_READ",
INT2NUM(GRPC_CLIENT_METADATA_READ));
rb_define_const(rb_mCompletionType, "FINISHED", INT2NUM(GRPC_FINISHED));
rb_define_const(rb_mCompletionType, "SERVER_RPC_NEW",
rb_define_const(grpc_mCompletionType, "FINISHED", INT2NUM(GRPC_FINISHED));
rb_define_const(grpc_mCompletionType, "SERVER_RPC_NEW",
INT2NUM(GRPC_SERVER_RPC_NEW));
rb_define_const(rb_mCompletionType, "SERVER_SHUTDOWN",
rb_define_const(grpc_mCompletionType, "SERVER_SHUTDOWN",
INT2NUM(GRPC_SERVER_SHUTDOWN));
rb_define_const(rb_mCompletionType, "RESERVED",
rb_define_const(grpc_mCompletionType, "RESERVED",
INT2NUM(GRPC_COMPLETION_DO_NOT_USE));
}
@ -356,6 +356,6 @@ VALUE grpc_rb_new_event(grpc_event *ev) {
grpc_rb_event *wrapper = ALLOC(grpc_rb_event);
wrapper->wrapped = ev;
wrapper->mark = Qnil;
return Data_Wrap_Struct(rb_cEvent, grpc_rb_event_mark, grpc_rb_event_free,
return Data_Wrap_Struct(grpc_cEvent, grpc_rb_event_mark, grpc_rb_event_free,
wrapper);
}

@ -37,12 +37,12 @@
#include <ruby.h>
#include <grpc/grpc.h>
/* rb_cEvent is the Event class whose instances proxy grpc_event. */
extern VALUE rb_cEvent;
/* grpc_cEvent is the Event class whose instances proxy grpc_event. */
extern VALUE grpc_cEvent;
/* rb_cEventError is the ruby class that acts the exception thrown during rpc
/* grpc_eEventError is the ruby class that acts the exception thrown during rpc
event processing. */
extern VALUE rb_eEventError;
extern VALUE grpc_eEventError;
/* Used to create new ruby event objects */
VALUE grpc_rb_new_event(grpc_event *ev);

@ -53,7 +53,7 @@
const RUBY_DATA_FUNC GC_NOT_MARKED = NULL;
const RUBY_DATA_FUNC GC_DONT_FREE = NULL;
VALUE rb_cTimeVal = Qnil;
VALUE grpc_cTimeVal = Qnil;
/* Alloc func that blocks allocation of a given object by raising an
* exception. */
@ -99,7 +99,7 @@ gpr_timespec grpc_rb_time_timeval(VALUE time, int interval) {
switch (TYPE(time)) {
case T_DATA:
if (CLASS_OF(time) == rb_cTimeVal) {
if (CLASS_OF(time) == grpc_cTimeVal) {
Data_Get_Struct(time, gpr_timespec, time_const);
t = *time_const;
} else if (CLASS_OF(time) == rb_cTime) {
@ -155,35 +155,35 @@ gpr_timespec grpc_rb_time_timeval(VALUE time, int interval) {
void Init_grpc_status_codes() {
/* Constants representing the status codes or grpc_status_code in status.h */
VALUE rb_mStatusCodes =
rb_define_module_under(rb_mGrpcCore, "StatusCodes");
rb_define_const(rb_mStatusCodes, "OK", INT2NUM(GRPC_STATUS_OK));
rb_define_const(rb_mStatusCodes, "CANCELLED", INT2NUM(GRPC_STATUS_CANCELLED));
rb_define_const(rb_mStatusCodes, "UNKNOWN", INT2NUM(GRPC_STATUS_UNKNOWN));
rb_define_const(rb_mStatusCodes, "INVALID_ARGUMENT",
VALUE grpc_mStatusCodes =
rb_define_module_under(grpc_mGrpcCore, "StatusCodes");
rb_define_const(grpc_mStatusCodes, "OK", INT2NUM(GRPC_STATUS_OK));
rb_define_const(grpc_mStatusCodes, "CANCELLED", INT2NUM(GRPC_STATUS_CANCELLED));
rb_define_const(grpc_mStatusCodes, "UNKNOWN", INT2NUM(GRPC_STATUS_UNKNOWN));
rb_define_const(grpc_mStatusCodes, "INVALID_ARGUMENT",
INT2NUM(GRPC_STATUS_INVALID_ARGUMENT));
rb_define_const(rb_mStatusCodes, "DEADLINE_EXCEEDED",
rb_define_const(grpc_mStatusCodes, "DEADLINE_EXCEEDED",
INT2NUM(GRPC_STATUS_DEADLINE_EXCEEDED));
rb_define_const(rb_mStatusCodes, "NOT_FOUND", INT2NUM(GRPC_STATUS_NOT_FOUND));
rb_define_const(rb_mStatusCodes, "ALREADY_EXISTS",
rb_define_const(grpc_mStatusCodes, "NOT_FOUND", INT2NUM(GRPC_STATUS_NOT_FOUND));
rb_define_const(grpc_mStatusCodes, "ALREADY_EXISTS",
INT2NUM(GRPC_STATUS_ALREADY_EXISTS));
rb_define_const(rb_mStatusCodes, "PERMISSION_DENIED",
rb_define_const(grpc_mStatusCodes, "PERMISSION_DENIED",
INT2NUM(GRPC_STATUS_PERMISSION_DENIED));
rb_define_const(rb_mStatusCodes, "UNAUTHENTICATED",
rb_define_const(grpc_mStatusCodes, "UNAUTHENTICATED",
INT2NUM(GRPC_STATUS_UNAUTHENTICATED));
rb_define_const(rb_mStatusCodes, "RESOURCE_EXHAUSTED",
rb_define_const(grpc_mStatusCodes, "RESOURCE_EXHAUSTED",
INT2NUM(GRPC_STATUS_RESOURCE_EXHAUSTED));
rb_define_const(rb_mStatusCodes, "FAILED_PRECONDITION",
rb_define_const(grpc_mStatusCodes, "FAILED_PRECONDITION",
INT2NUM(GRPC_STATUS_FAILED_PRECONDITION));
rb_define_const(rb_mStatusCodes, "ABORTED", INT2NUM(GRPC_STATUS_ABORTED));
rb_define_const(rb_mStatusCodes, "OUT_OF_RANGE",
rb_define_const(grpc_mStatusCodes, "ABORTED", INT2NUM(GRPC_STATUS_ABORTED));
rb_define_const(grpc_mStatusCodes, "OUT_OF_RANGE",
INT2NUM(GRPC_STATUS_OUT_OF_RANGE));
rb_define_const(rb_mStatusCodes, "UNIMPLEMENTED",
rb_define_const(grpc_mStatusCodes, "UNIMPLEMENTED",
INT2NUM(GRPC_STATUS_UNIMPLEMENTED));
rb_define_const(rb_mStatusCodes, "INTERNAL", INT2NUM(GRPC_STATUS_INTERNAL));
rb_define_const(rb_mStatusCodes, "UNAVAILABLE",
rb_define_const(grpc_mStatusCodes, "INTERNAL", INT2NUM(GRPC_STATUS_INTERNAL));
rb_define_const(grpc_mStatusCodes, "UNAVAILABLE",
INT2NUM(GRPC_STATUS_UNAVAILABLE));
rb_define_const(rb_mStatusCodes, "DATA_LOSS", INT2NUM(GRPC_STATUS_DATA_LOSS));
rb_define_const(grpc_mStatusCodes, "DATA_LOSS", INT2NUM(GRPC_STATUS_DATA_LOSS));
}
/* id_at is the constructor method of the ruby standard Time class. */
@ -215,22 +215,22 @@ VALUE grpc_rb_time_val_to_s(VALUE self) {
/* Adds a module with constants that map to gpr's static timeval structs. */
void Init_grpc_time_consts() {
VALUE rb_mTimeConsts =
rb_define_module_under(rb_mGrpcCore, "TimeConsts");
rb_cTimeVal =
rb_define_class_under(rb_mGrpcCore, "TimeSpec", rb_cObject);
rb_define_const(rb_mTimeConsts, "ZERO",
Data_Wrap_Struct(rb_cTimeVal, GC_NOT_MARKED, GC_DONT_FREE,
VALUE grpc_mTimeConsts =
rb_define_module_under(grpc_mGrpcCore, "TimeConsts");
grpc_cTimeVal =
rb_define_class_under(grpc_mGrpcCore, "TimeSpec", rb_cObject);
rb_define_const(grpc_mTimeConsts, "ZERO",
Data_Wrap_Struct(grpc_cTimeVal, GC_NOT_MARKED, GC_DONT_FREE,
(void *)&gpr_time_0));
rb_define_const(rb_mTimeConsts, "INFINITE_FUTURE",
Data_Wrap_Struct(rb_cTimeVal, GC_NOT_MARKED, GC_DONT_FREE,
rb_define_const(grpc_mTimeConsts, "INFINITE_FUTURE",
Data_Wrap_Struct(grpc_cTimeVal, GC_NOT_MARKED, GC_DONT_FREE,
(void *)&gpr_inf_future));
rb_define_const(rb_mTimeConsts, "INFINITE_PAST",
Data_Wrap_Struct(rb_cTimeVal, GC_NOT_MARKED, GC_DONT_FREE,
rb_define_const(grpc_mTimeConsts, "INFINITE_PAST",
Data_Wrap_Struct(grpc_cTimeVal, GC_NOT_MARKED, GC_DONT_FREE,
(void *)&gpr_inf_past));
rb_define_method(rb_cTimeVal, "to_time", grpc_rb_time_val_to_time, 0);
rb_define_method(rb_cTimeVal, "inspect", grpc_rb_time_val_inspect, 0);
rb_define_method(rb_cTimeVal, "to_s", grpc_rb_time_val_to_s, 0);
rb_define_method(grpc_cTimeVal, "to_time", grpc_rb_time_val_to_time, 0);
rb_define_method(grpc_cTimeVal, "inspect", grpc_rb_time_val_inspect, 0);
rb_define_method(grpc_cTimeVal, "to_s", grpc_rb_time_val_to_s, 0);
id_at = rb_intern("at");
id_inspect = rb_intern("inspect");
id_to_s = rb_intern("to_s");
@ -242,23 +242,23 @@ void grpc_rb_shutdown(void *vm) { grpc_shutdown(); }
/* Initialize the GRPC module structs */
/* rb_sNewServerRpc is the struct that holds new server rpc details. */
VALUE rb_sNewServerRpc = Qnil;
/* rb_sStatus is the struct that holds status details. */
VALUE rb_sStatus = Qnil;
/* grpc_sNewServerRpc is the struct that holds new server rpc details. */
VALUE grpc_sNewServerRpc = Qnil;
/* grpc_sStatus is the struct that holds status details. */
VALUE grpc_sStatus = Qnil;
/* Initialize the GRPC module. */
VALUE rb_mGRPC = Qnil;
VALUE rb_mGrpcCore = Qnil;
VALUE grpc_mGRPC = Qnil;
VALUE grpc_mGrpcCore = Qnil;
void Init_grpc() {
grpc_init();
ruby_vm_at_exit(grpc_rb_shutdown);
rb_mGRPC = rb_define_module("GRPC");
rb_mGrpcCore = rb_define_module_under(rb_mGRPC, "Core");
rb_sNewServerRpc = rb_struct_define("NewServerRpc", "method", "host",
"deadline", "metadata", NULL);
rb_sStatus = rb_struct_define("Status", "code", "details", "metadata", NULL);
grpc_mGRPC = rb_define_module("GRPC");
grpc_mGrpcCore = rb_define_module_under(grpc_mGRPC, "Core");
grpc_sNewServerRpc = rb_struct_define("NewServerRpc", "method", "host",
"deadline", "metadata", NULL);
grpc_sStatus = rb_struct_define("Status", "code", "details", "metadata", NULL);
Init_grpc_byte_buffer();
Init_grpc_event();

@ -38,17 +38,17 @@
#include <ruby.h>
#include <grpc/support/time.h>
/* rb_mGrpcCore is the module containing the ruby wrapper GRPC classes. */
extern VALUE rb_mGrpcCore;
/* grpc_mGrpcCore is the module containing the ruby wrapper GRPC classes. */
extern VALUE grpc_mGrpcCore;
/* Class used to wrap timeval structs. */
extern VALUE rb_cTimeVal;
extern VALUE grpc_cTimeVal;
/* rb_sNewServerRpc is the struct that holds new server rpc details. */
extern VALUE rb_sNewServerRpc;
/* grpc_sNewServerRpc is the struct that holds new server rpc details. */
extern VALUE grpc_sNewServerRpc;
/* rb_sStruct is the struct that holds status details. */
extern VALUE rb_sStatus;
/* grpc_sStruct is the struct that holds status details. */
extern VALUE grpc_sStatus;
/* 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. */

@ -131,7 +131,7 @@ static VALUE grpc_rb_metadata_init_copy(VALUE copy, VALUE orig) {
/* Raise an error if orig is not a metadata object or a subclass. */
if (TYPE(orig) != T_DATA ||
RDATA(orig)->dfree != (RUBY_DATA_FUNC)grpc_rb_metadata_free) {
rb_raise(rb_eTypeError, "not a %s", rb_obj_classname(rb_cMetadata));
rb_raise(rb_eTypeError, "not a %s", rb_obj_classname(grpc_cMetadata));
}
Data_Get_Struct(orig, grpc_rb_metadata, orig_md);
@ -185,23 +185,23 @@ static VALUE grpc_rb_metadata_value(VALUE self) {
return rb_str_new2(md->value);
}
/* rb_cMetadata is the Metadata class whose instances proxy grpc_metadata. */
VALUE rb_cMetadata = Qnil;
/* grpc_cMetadata is the Metadata class whose instances proxy grpc_metadata. */
VALUE grpc_cMetadata = Qnil;
void Init_grpc_metadata() {
rb_cMetadata =
rb_define_class_under(rb_mGrpcCore, "Metadata", rb_cObject);
grpc_cMetadata =
rb_define_class_under(grpc_mGrpcCore, "Metadata", rb_cObject);
/* Allocates an object managed by the ruby runtime */
rb_define_alloc_func(rb_cMetadata, grpc_rb_metadata_alloc);
rb_define_alloc_func(grpc_cMetadata, grpc_rb_metadata_alloc);
/* Provides a ruby constructor and support for dup/clone. */
rb_define_method(rb_cMetadata, "initialize", grpc_rb_metadata_init, 2);
rb_define_method(rb_cMetadata, "initialize_copy", grpc_rb_metadata_init_copy,
rb_define_method(grpc_cMetadata, "initialize", grpc_rb_metadata_init, 2);
rb_define_method(grpc_cMetadata, "initialize_copy", grpc_rb_metadata_init_copy,
1);
/* Provides accessors for the code and details. */
rb_define_method(rb_cMetadata, "key", grpc_rb_metadata_key, 0);
rb_define_method(rb_cMetadata, "value", grpc_rb_metadata_value, 0);
rb_define_method(grpc_cMetadata, "key", grpc_rb_metadata_key, 0);
rb_define_method(grpc_cMetadata, "value", grpc_rb_metadata_value, 0);
id_key = rb_intern("__key");
id_value = rb_intern("__value");

@ -37,8 +37,8 @@
#include <grpc/grpc.h>
#include <ruby.h>
/* rb_cMetadata is the Metadata class whose instances proxy grpc_metadata. */
extern VALUE rb_cMetadata;
/* grpc_cMetadata is the Metadata class whose instances proxy grpc_metadata. */
extern VALUE grpc_cMetadata;
/* grpc_rb_metadata_create_with_mark creates a grpc_rb_metadata with a ruby mark
* object that will be kept alive while the metadata is alive. */

@ -43,8 +43,8 @@
#include "rb_server_credentials.h"
#include "rb_grpc.h"
/* rb_cServer is the ruby class that proxies grpc_server. */
VALUE rb_cServer = Qnil;
/* grpc_cServer is the ruby class that proxies grpc_server. */
VALUE grpc_cServer = Qnil;
/* grpc_rb_server wraps a grpc_server. It provides a peer ruby object,
'mark' to minimize copying when a server is created from ruby. */
@ -140,7 +140,7 @@ static VALUE grpc_rb_server_init_copy(VALUE copy, VALUE orig) {
/* 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(rb_cServer));
rb_raise(rb_eTypeError, "not a %s", rb_obj_classname(grpc_cServer));
}
Data_Get_Struct(orig, grpc_rb_server, orig_srv);
@ -161,7 +161,7 @@ static VALUE grpc_rb_server_request_call(VALUE self, VALUE tag_new) {
} else {
err = grpc_server_request_call_old(s->wrapped, ROBJECT(tag_new));
if (err != GRPC_CALL_OK) {
rb_raise(rb_eCallError, "server request failed: %s (code=%d)",
rb_raise(grpc_eCallError, "server request failed: %s (code=%d)",
grpc_call_error_detail_of(err), err);
}
}
@ -239,21 +239,21 @@ static VALUE grpc_rb_server_add_http2_port(int argc, VALUE *argv, VALUE self) {
}
void Init_grpc_server() {
rb_cServer = rb_define_class_under(rb_mGrpcCore, "Server", rb_cObject);
grpc_cServer = rb_define_class_under(grpc_mGrpcCore, "Server", rb_cObject);
/* Allocates an object managed by the ruby runtime */
rb_define_alloc_func(rb_cServer, grpc_rb_server_alloc);
rb_define_alloc_func(grpc_cServer, grpc_rb_server_alloc);
/* Provides a ruby constructor and support for dup/clone. */
rb_define_method(rb_cServer, "initialize", grpc_rb_server_init, 2);
rb_define_method(rb_cServer, "initialize_copy", grpc_rb_server_init_copy, 1);
rb_define_method(grpc_cServer, "initialize", grpc_rb_server_init, 2);
rb_define_method(grpc_cServer, "initialize_copy", grpc_rb_server_init_copy, 1);
/* Add the server methods. */
rb_define_method(rb_cServer, "request_call", grpc_rb_server_request_call, 1);
rb_define_method(rb_cServer, "start", grpc_rb_server_start, 0);
rb_define_method(rb_cServer, "destroy", grpc_rb_server_destroy, 0);
rb_define_alias(rb_cServer, "close", "destroy");
rb_define_method(rb_cServer, "add_http2_port", grpc_rb_server_add_http2_port,
rb_define_method(grpc_cServer, "request_call", grpc_rb_server_request_call, 1);
rb_define_method(grpc_cServer, "start", grpc_rb_server_start, 0);
rb_define_method(grpc_cServer, "destroy", grpc_rb_server_destroy, 0);
rb_define_alias(grpc_cServer, "close", "destroy");
rb_define_method(grpc_cServer, "add_http2_port", grpc_rb_server_add_http2_port,
-1);
}

@ -37,9 +37,9 @@
#include <ruby.h>
#include <grpc/grpc.h>
/* rb_cServer is the Server class whose instances proxy
/* grpc_cServer is the Server class whose instances proxy
grpc_byte_buffer. */
extern VALUE rb_cServer;
extern VALUE grpc_cServer;
/* Initializes the Server class. */
void Init_grpc_server();

@ -109,7 +109,7 @@ static VALUE grpc_rb_server_credentials_init_copy(VALUE copy, VALUE orig) {
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(rb_cServerCredentials));
rb_obj_classname(grpc_cServerCredentials));
}
Data_Get_Struct(orig, grpc_rb_server_credentials, orig_ch);
@ -180,21 +180,21 @@ static VALUE grpc_rb_server_credentials_init(VALUE self, VALUE pem_root_certs,
return self;
}
/* rb_cServerCredentials is the ruby class that proxies
/* grpc_cServerCredentials is the ruby class that proxies
grpc_server_credentials. */
VALUE rb_cServerCredentials = Qnil;
VALUE grpc_cServerCredentials = Qnil;
void Init_grpc_server_credentials() {
rb_cServerCredentials =
rb_define_class_under(rb_mGrpcCore, "ServerCredentials", rb_cObject);
grpc_cServerCredentials =
rb_define_class_under(grpc_mGrpcCore, "ServerCredentials", rb_cObject);
/* Allocates an object managed by the ruby runtime */
rb_define_alloc_func(rb_cServerCredentials, grpc_rb_server_credentials_alloc);
rb_define_alloc_func(grpc_cServerCredentials, grpc_rb_server_credentials_alloc);
/* Provides a ruby constructor and support for dup/clone. */
rb_define_method(rb_cServerCredentials, "initialize",
rb_define_method(grpc_cServerCredentials, "initialize",
grpc_rb_server_credentials_init, 3);
rb_define_method(rb_cServerCredentials, "initialize_copy",
rb_define_method(grpc_cServerCredentials, "initialize_copy",
grpc_rb_server_credentials_init_copy, 1);
id_pem_cert_chain = rb_intern("__pem_cert_chain");

@ -37,9 +37,9 @@
#include <ruby.h>
#include <grpc/grpc_security.h>
/* rb_cServerCredentials is the ruby class whose instances proxy
/* grpc_cServerCredentials is the ruby class whose instances proxy
grpc_server_credentials. */
extern VALUE rb_cServerCredentials;
extern VALUE grpc_cServerCredentials;
/* Initializes the ruby ServerCredentials class. */
void Init_grpc_server_credentials();

Loading…
Cancel
Save