|
|
@ -118,35 +118,36 @@ static void grpc_rb_call_destroy(void *p) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static size_t md_ary_datasize(const void *p) { |
|
|
|
static size_t md_ary_datasize(const void *p) { |
|
|
|
const grpc_metadata_array* const ary = (grpc_metadata_array*)p; |
|
|
|
const grpc_metadata_array *const ary = (grpc_metadata_array *)p; |
|
|
|
size_t i, datasize = sizeof(grpc_metadata_array); |
|
|
|
size_t i, datasize = sizeof(grpc_metadata_array); |
|
|
|
for (i = 0; i < ary->count; ++i) { |
|
|
|
for (i = 0; i < ary->count; ++i) { |
|
|
|
const grpc_metadata* const md = &ary->metadata[i]; |
|
|
|
const grpc_metadata *const md = &ary->metadata[i]; |
|
|
|
datasize += strlen(md->key); |
|
|
|
datasize += strlen(md->key); |
|
|
|
datasize += md->value_length; |
|
|
|
datasize += md->value_length; |
|
|
|
} |
|
|
|
} |
|
|
|
datasize += ary->capacity * sizeof(grpc_metadata); |
|
|
|
datasize += ary->capacity * sizeof(grpc_metadata); |
|
|
|
return datasize; |
|
|
|
return datasize; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static const rb_data_type_t grpc_rb_md_ary_data_type = { |
|
|
|
static const rb_data_type_t grpc_rb_md_ary_data_type = { |
|
|
|
"grpc_metadata_array", |
|
|
|
"grpc_metadata_array", |
|
|
|
{GRPC_RB_GC_NOT_MARKED, GRPC_RB_GC_DONT_FREE, md_ary_datasize}, |
|
|
|
{GRPC_RB_GC_NOT_MARKED, GRPC_RB_GC_DONT_FREE, md_ary_datasize}, |
|
|
|
NULL, NULL, |
|
|
|
NULL, |
|
|
|
0 |
|
|
|
NULL, |
|
|
|
}; |
|
|
|
0}; |
|
|
|
|
|
|
|
|
|
|
|
/* Describes grpc_call struct for RTypedData */ |
|
|
|
/* Describes grpc_call struct for RTypedData */ |
|
|
|
static const rb_data_type_t grpc_call_data_type = { |
|
|
|
static const rb_data_type_t grpc_call_data_type = { |
|
|
|
"grpc_call", |
|
|
|
"grpc_call", |
|
|
|
{GRPC_RB_GC_NOT_MARKED, grpc_rb_call_destroy, GRPC_RB_MEMSIZE_UNAVAILABLE}, |
|
|
|
{GRPC_RB_GC_NOT_MARKED, grpc_rb_call_destroy, GRPC_RB_MEMSIZE_UNAVAILABLE}, |
|
|
|
NULL, NULL, |
|
|
|
NULL, |
|
|
|
/* it is unsafe to specify RUBY_TYPED_FREE_IMMEDIATELY because grpc_rb_call_destroy
|
|
|
|
NULL, |
|
|
|
|
|
|
|
/* it is unsafe to specify RUBY_TYPED_FREE_IMMEDIATELY because
|
|
|
|
|
|
|
|
* grpc_rb_call_destroy |
|
|
|
* touches a hash object. |
|
|
|
* touches a hash object. |
|
|
|
* TODO(yugui) Directly use st_table and call the free function earlier? |
|
|
|
* TODO(yugui) Directly use st_table and call the free function earlier? |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
0 |
|
|
|
0}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Error code details is a hash containing text strings describing errors */ |
|
|
|
/* Error code details is a hash containing text strings describing errors */ |
|
|
|
VALUE rb_error_code_details; |
|
|
|
VALUE rb_error_code_details; |
|
|
@ -250,7 +251,7 @@ static int grpc_rb_md_ary_fill_hash_cb(VALUE key, VALUE val, VALUE md_ary_obj) { |
|
|
|
} |
|
|
|
} |
|
|
|
md_ary->metadata[md_ary->count].value = RSTRING_PTR(rb_ary_entry(val, i)); |
|
|
|
md_ary->metadata[md_ary->count].value = RSTRING_PTR(rb_ary_entry(val, i)); |
|
|
|
md_ary->metadata[md_ary->count].value_length = |
|
|
|
md_ary->metadata[md_ary->count].value_length = |
|
|
|
RSTRING_LEN(rb_ary_entry(val, i)); |
|
|
|
RSTRING_LEN(rb_ary_entry(val, i)); |
|
|
|
md_ary->count += 1; |
|
|
|
md_ary->count += 1; |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -290,10 +291,11 @@ static int grpc_rb_md_ary_capacity_hash_cb(VALUE key, VALUE val, |
|
|
|
/* grpc_rb_md_ary_convert converts a ruby metadata hash into
|
|
|
|
/* grpc_rb_md_ary_convert converts a ruby metadata hash into
|
|
|
|
a grpc_metadata_array. |
|
|
|
a grpc_metadata_array. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
static 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; |
|
|
|
VALUE md_ary_obj = Qnil; |
|
|
|
if (md_ary_hash == Qnil) { |
|
|
|
if (md_ary_hash == Qnil) { |
|
|
|
return; /* Do nothing if the expected has value is nil */ |
|
|
|
return; /* Do nothing if the expected has value is nil */ |
|
|
|
} |
|
|
|
} |
|
|
|
if (TYPE(md_ary_hash) != T_HASH) { |
|
|
|
if (TYPE(md_ary_hash) != T_HASH) { |
|
|
|
rb_raise(rb_eTypeError, "md_ary_convert: got <%s>, want <Hash>", |
|
|
|
rb_raise(rb_eTypeError, "md_ary_convert: got <%s>, want <Hash>", |
|
|
@ -303,8 +305,8 @@ static void grpc_rb_md_ary_convert(VALUE md_ary_hash, grpc_metadata_array *md_ar |
|
|
|
|
|
|
|
|
|
|
|
/* Initialize the array, compute it's capacity, then fill it. */ |
|
|
|
/* Initialize the array, compute it's capacity, then fill it. */ |
|
|
|
grpc_metadata_array_init(md_ary); |
|
|
|
grpc_metadata_array_init(md_ary); |
|
|
|
md_ary_obj = TypedData_Wrap_Struct(grpc_rb_cMdAry, &grpc_rb_md_ary_data_type, |
|
|
|
md_ary_obj = |
|
|
|
md_ary); |
|
|
|
TypedData_Wrap_Struct(grpc_rb_cMdAry, &grpc_rb_md_ary_data_type, md_ary); |
|
|
|
rb_hash_foreach(md_ary_hash, grpc_rb_md_ary_capacity_hash_cb, md_ary_obj); |
|
|
|
rb_hash_foreach(md_ary_hash, grpc_rb_md_ary_capacity_hash_cb, md_ary_obj); |
|
|
|
md_ary->metadata = gpr_malloc(md_ary->capacity * sizeof(grpc_metadata)); |
|
|
|
md_ary->metadata = gpr_malloc(md_ary->capacity * sizeof(grpc_metadata)); |
|
|
|
rb_hash_foreach(md_ary_hash, grpc_rb_md_ary_fill_hash_cb, md_ary_obj); |
|
|
|
rb_hash_foreach(md_ary_hash, grpc_rb_md_ary_fill_hash_cb, md_ary_obj); |
|
|
@ -327,16 +329,14 @@ VALUE grpc_rb_md_ary_to_h(grpc_metadata_array *md_ary) { |
|
|
|
rb_hash_aset(result, key, value); |
|
|
|
rb_hash_aset(result, key, value); |
|
|
|
} else if (TYPE(value) == T_ARRAY) { |
|
|
|
} else if (TYPE(value) == T_ARRAY) { |
|
|
|
/* Add the string to the returned array */ |
|
|
|
/* Add the string to the returned array */ |
|
|
|
rb_ary_push(value, |
|
|
|
rb_ary_push(value, rb_str_new(md_ary->metadata[i].value, |
|
|
|
rb_str_new(md_ary->metadata[i].value, |
|
|
|
md_ary->metadata[i].value_length)); |
|
|
|
md_ary->metadata[i].value_length)); |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
/* Add the current value with this key and the new one to an array */ |
|
|
|
/* Add the current value with this key and the new one to an array */ |
|
|
|
new_ary = rb_ary_new(); |
|
|
|
new_ary = rb_ary_new(); |
|
|
|
rb_ary_push(new_ary, value); |
|
|
|
rb_ary_push(new_ary, value); |
|
|
|
rb_ary_push(new_ary, |
|
|
|
rb_ary_push(new_ary, rb_str_new(md_ary->metadata[i].value, |
|
|
|
rb_str_new(md_ary->metadata[i].value, |
|
|
|
md_ary->metadata[i].value_length)); |
|
|
|
md_ary->metadata[i].value_length)); |
|
|
|
|
|
|
|
rb_hash_aset(result, key, new_ary); |
|
|
|
rb_hash_aset(result, key, new_ary); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -355,7 +355,7 @@ static int grpc_rb_call_check_op_keys_hash_cb(VALUE key, VALUE val, |
|
|
|
rb_obj_classname(key)); |
|
|
|
rb_obj_classname(key)); |
|
|
|
return ST_STOP; |
|
|
|
return ST_STOP; |
|
|
|
} |
|
|
|
} |
|
|
|
switch(NUM2INT(key)) { |
|
|
|
switch (NUM2INT(key)) { |
|
|
|
case GRPC_OP_SEND_INITIAL_METADATA: |
|
|
|
case GRPC_OP_SEND_INITIAL_METADATA: |
|
|
|
case GRPC_OP_SEND_MESSAGE: |
|
|
|
case GRPC_OP_SEND_MESSAGE: |
|
|
|
case GRPC_OP_SEND_CLOSE_FROM_CLIENT: |
|
|
|
case GRPC_OP_SEND_CLOSE_FROM_CLIENT: |
|
|
@ -367,8 +367,7 @@ static int grpc_rb_call_check_op_keys_hash_cb(VALUE key, VALUE val, |
|
|
|
rb_ary_push(ops_ary, key); |
|
|
|
rb_ary_push(ops_ary, key); |
|
|
|
return ST_CONTINUE; |
|
|
|
return ST_CONTINUE; |
|
|
|
default: |
|
|
|
default: |
|
|
|
rb_raise(rb_eTypeError, "invalid operation : bad value %d", |
|
|
|
rb_raise(rb_eTypeError, "invalid operation : bad value %d", NUM2INT(key)); |
|
|
|
NUM2INT(key)); |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
return ST_STOP; |
|
|
|
return ST_STOP; |
|
|
|
} |
|
|
|
} |
|
|
@ -377,8 +376,8 @@ static int grpc_rb_call_check_op_keys_hash_cb(VALUE key, VALUE val, |
|
|
|
struct to the 'send_status_from_server' portion of an op. |
|
|
|
struct to the 'send_status_from_server' portion of an op. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
static 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, |
|
|
|
grpc_metadata_array *md_ary, |
|
|
|
VALUE status) { |
|
|
|
VALUE status) { |
|
|
|
VALUE code = rb_struct_aref(status, sym_code); |
|
|
|
VALUE code = rb_struct_aref(status, sym_code); |
|
|
|
VALUE details = rb_struct_aref(status, sym_details); |
|
|
|
VALUE details = rb_struct_aref(status, sym_details); |
|
|
|
VALUE metadata_hash = rb_struct_aref(status, sym_metadata); |
|
|
|
VALUE metadata_hash = rb_struct_aref(status, sym_metadata); |
|
|
@ -405,8 +404,8 @@ static void grpc_rb_op_update_status_from_server(grpc_op *op, |
|
|
|
* grpc_rb_call_run_batch function */ |
|
|
|
* grpc_rb_call_run_batch function */ |
|
|
|
typedef struct run_batch_stack { |
|
|
|
typedef struct run_batch_stack { |
|
|
|
/* The batch ops */ |
|
|
|
/* The batch ops */ |
|
|
|
grpc_op ops[8]; /* 8 is the maximum number of operations */ |
|
|
|
grpc_op ops[8]; /* 8 is the maximum number of operations */ |
|
|
|
size_t op_num; /* tracks the last added operation */ |
|
|
|
size_t op_num; /* tracks the last added operation */ |
|
|
|
|
|
|
|
|
|
|
|
/* Data being sent */ |
|
|
|
/* Data being sent */ |
|
|
|
grpc_metadata_array send_metadata; |
|
|
|
grpc_metadata_array send_metadata; |
|
|
@ -424,7 +423,7 @@ typedef struct run_batch_stack { |
|
|
|
|
|
|
|
|
|
|
|
/* grpc_run_batch_stack_init ensures the run_batch_stack is properly
|
|
|
|
/* grpc_run_batch_stack_init ensures the run_batch_stack is properly
|
|
|
|
* initialized */ |
|
|
|
* initialized */ |
|
|
|
static void grpc_run_batch_stack_init(run_batch_stack* st) { |
|
|
|
static void grpc_run_batch_stack_init(run_batch_stack *st) { |
|
|
|
MEMZERO(st, run_batch_stack, 1); |
|
|
|
MEMZERO(st, run_batch_stack, 1); |
|
|
|
grpc_metadata_array_init(&st->send_metadata); |
|
|
|
grpc_metadata_array_init(&st->send_metadata); |
|
|
|
grpc_metadata_array_init(&st->send_trailing_metadata); |
|
|
|
grpc_metadata_array_init(&st->send_trailing_metadata); |
|
|
@ -435,7 +434,7 @@ static void grpc_run_batch_stack_init(run_batch_stack* st) { |
|
|
|
|
|
|
|
|
|
|
|
/* grpc_run_batch_stack_cleanup ensures the run_batch_stack is properly
|
|
|
|
/* grpc_run_batch_stack_cleanup ensures the run_batch_stack is properly
|
|
|
|
* cleaned up */ |
|
|
|
* cleaned up */ |
|
|
|
static void grpc_run_batch_stack_cleanup(run_batch_stack* st) { |
|
|
|
static void grpc_run_batch_stack_cleanup(run_batch_stack *st) { |
|
|
|
grpc_metadata_array_destroy(&st->send_metadata); |
|
|
|
grpc_metadata_array_destroy(&st->send_metadata); |
|
|
|
grpc_metadata_array_destroy(&st->send_trailing_metadata); |
|
|
|
grpc_metadata_array_destroy(&st->send_trailing_metadata); |
|
|
|
grpc_metadata_array_destroy(&st->recv_metadata); |
|
|
|
grpc_metadata_array_destroy(&st->recv_metadata); |
|
|
@ -447,7 +446,7 @@ static void grpc_run_batch_stack_cleanup(run_batch_stack* st) { |
|
|
|
|
|
|
|
|
|
|
|
/* grpc_run_batch_stack_fill_ops fills the run_batch_stack ops array from
|
|
|
|
/* grpc_run_batch_stack_fill_ops fills the run_batch_stack ops array from
|
|
|
|
* ops_hash */ |
|
|
|
* ops_hash */ |
|
|
|
static void grpc_run_batch_stack_fill_ops(run_batch_stack* st, VALUE ops_hash) { |
|
|
|
static void grpc_run_batch_stack_fill_ops(run_batch_stack *st, VALUE ops_hash) { |
|
|
|
VALUE this_op = Qnil; |
|
|
|
VALUE this_op = Qnil; |
|
|
|
VALUE this_value = Qnil; |
|
|
|
VALUE this_value = Qnil; |
|
|
|
VALUE ops_ary = rb_ary_new(); |
|
|
|
VALUE ops_ary = rb_ary_new(); |
|
|
@ -460,7 +459,7 @@ static void grpc_run_batch_stack_fill_ops(run_batch_stack* st, VALUE ops_hash) { |
|
|
|
for (i = 0; i < (size_t)RARRAY_LEN(ops_ary); i++) { |
|
|
|
for (i = 0; i < (size_t)RARRAY_LEN(ops_ary); i++) { |
|
|
|
this_op = rb_ary_entry(ops_ary, i); |
|
|
|
this_op = rb_ary_entry(ops_ary, i); |
|
|
|
this_value = rb_hash_aref(ops_hash, this_op); |
|
|
|
this_value = rb_hash_aref(ops_hash, this_op); |
|
|
|
switch(NUM2INT(this_op)) { |
|
|
|
switch (NUM2INT(this_op)) { |
|
|
|
case GRPC_OP_SEND_INITIAL_METADATA: |
|
|
|
case GRPC_OP_SEND_INITIAL_METADATA: |
|
|
|
/* N.B. later there is no need to explicitly delete the metadata keys
|
|
|
|
/* N.B. later there is no need to explicitly delete the metadata keys
|
|
|
|
* and values, they are references to data in ruby objects. */ |
|
|
|
* and values, they are references to data in ruby objects. */ |
|
|
@ -471,18 +470,16 @@ static void grpc_run_batch_stack_fill_ops(run_batch_stack* st, VALUE ops_hash) { |
|
|
|
st->send_metadata.metadata; |
|
|
|
st->send_metadata.metadata; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case GRPC_OP_SEND_MESSAGE: |
|
|
|
case GRPC_OP_SEND_MESSAGE: |
|
|
|
st->ops[st->op_num].data.send_message = |
|
|
|
st->ops[st->op_num].data.send_message = grpc_rb_s_to_byte_buffer( |
|
|
|
grpc_rb_s_to_byte_buffer(RSTRING_PTR(this_value), |
|
|
|
RSTRING_PTR(this_value), RSTRING_LEN(this_value)); |
|
|
|
RSTRING_LEN(this_value)); |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
case GRPC_OP_SEND_CLOSE_FROM_CLIENT: |
|
|
|
case GRPC_OP_SEND_CLOSE_FROM_CLIENT: |
|
|
|
break; |
|
|
|
break; |
|
|
|
case GRPC_OP_SEND_STATUS_FROM_SERVER: |
|
|
|
case GRPC_OP_SEND_STATUS_FROM_SERVER: |
|
|
|
/* N.B. later there is no need to explicitly delete the metadata keys
|
|
|
|
/* N.B. later there is no need to explicitly delete the metadata keys
|
|
|
|
* and values, they are references to data in ruby objects. */ |
|
|
|
* and values, they are references to data in ruby objects. */ |
|
|
|
grpc_rb_op_update_status_from_server(&st->ops[st->op_num], |
|
|
|
grpc_rb_op_update_status_from_server( |
|
|
|
&st->send_trailing_metadata, |
|
|
|
&st->ops[st->op_num], &st->send_trailing_metadata, this_value); |
|
|
|
this_value); |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
case GRPC_OP_RECV_INITIAL_METADATA: |
|
|
|
case GRPC_OP_RECV_INITIAL_METADATA: |
|
|
|
st->ops[st->op_num].data.recv_initial_metadata = &st->recv_metadata; |
|
|
|
st->ops[st->op_num].data.recv_initial_metadata = &st->recv_metadata; |
|
|
@ -516,12 +513,12 @@ static void grpc_run_batch_stack_fill_ops(run_batch_stack* st, VALUE ops_hash) { |
|
|
|
|
|
|
|
|
|
|
|
/* grpc_run_batch_stack_build_result fills constructs a ruby BatchResult struct
|
|
|
|
/* grpc_run_batch_stack_build_result fills constructs a ruby BatchResult struct
|
|
|
|
after the results have run */ |
|
|
|
after the results have run */ |
|
|
|
static VALUE grpc_run_batch_stack_build_result(run_batch_stack* st) { |
|
|
|
static VALUE grpc_run_batch_stack_build_result(run_batch_stack *st) { |
|
|
|
size_t i = 0; |
|
|
|
size_t i = 0; |
|
|
|
VALUE result = rb_struct_new(grpc_rb_sBatchResult, Qnil, Qnil, Qnil, Qnil, |
|
|
|
VALUE result = rb_struct_new(grpc_rb_sBatchResult, Qnil, Qnil, Qnil, Qnil, |
|
|
|
Qnil, Qnil, Qnil, Qnil, NULL); |
|
|
|
Qnil, Qnil, Qnil, Qnil, NULL); |
|
|
|
for (i = 0; i < st->op_num; i++) { |
|
|
|
for (i = 0; i < st->op_num; i++) { |
|
|
|
switch(st->ops[i].op) { |
|
|
|
switch (st->ops[i].op) { |
|
|
|
case GRPC_OP_SEND_INITIAL_METADATA: |
|
|
|
case GRPC_OP_SEND_INITIAL_METADATA: |
|
|
|
rb_struct_aset(result, sym_send_metadata, Qtrue); |
|
|
|
rb_struct_aset(result, sym_send_metadata, Qtrue); |
|
|
|
break; |
|
|
|
break; |
|
|
@ -544,13 +541,11 @@ static VALUE grpc_run_batch_stack_build_result(run_batch_stack* st) { |
|
|
|
break; |
|
|
|
break; |
|
|
|
case GRPC_OP_RECV_STATUS_ON_CLIENT: |
|
|
|
case GRPC_OP_RECV_STATUS_ON_CLIENT: |
|
|
|
rb_struct_aset( |
|
|
|
rb_struct_aset( |
|
|
|
result, |
|
|
|
result, sym_status, |
|
|
|
sym_status, |
|
|
|
rb_struct_new(grpc_rb_sStatus, UINT2NUM(st->recv_status), |
|
|
|
rb_struct_new(grpc_rb_sStatus, |
|
|
|
|
|
|
|
UINT2NUM(st->recv_status), |
|
|
|
|
|
|
|
(st->recv_status_details == NULL |
|
|
|
(st->recv_status_details == NULL |
|
|
|
? Qnil |
|
|
|
? Qnil |
|
|
|
: rb_str_new2(st->recv_status_details)), |
|
|
|
: rb_str_new2(st->recv_status_details)), |
|
|
|
grpc_rb_md_ary_to_h(&st->recv_trailing_metadata), |
|
|
|
grpc_rb_md_ary_to_h(&st->recv_trailing_metadata), |
|
|
|
NULL)); |
|
|
|
NULL)); |
|
|
|
break; |
|
|
|
break; |
|
|
@ -682,8 +677,7 @@ static void Init_grpc_error_codes() { |
|
|
|
|
|
|
|
|
|
|
|
static void Init_grpc_op_codes() { |
|
|
|
static void Init_grpc_op_codes() { |
|
|
|
/* Constants representing operation type codes in grpc.h */ |
|
|
|
/* Constants representing operation type codes in grpc.h */ |
|
|
|
VALUE grpc_rb_mCallOps = |
|
|
|
VALUE grpc_rb_mCallOps = rb_define_module_under(grpc_rb_mGrpcCore, "CallOps"); |
|
|
|
rb_define_module_under(grpc_rb_mGrpcCore, "CallOps"); |
|
|
|
|
|
|
|
rb_define_const(grpc_rb_mCallOps, "SEND_INITIAL_METADATA", |
|
|
|
rb_define_const(grpc_rb_mCallOps, "SEND_INITIAL_METADATA", |
|
|
|
UINT2NUM(GRPC_OP_SEND_INITIAL_METADATA)); |
|
|
|
UINT2NUM(GRPC_OP_SEND_INITIAL_METADATA)); |
|
|
|
rb_define_const(grpc_rb_mCallOps, "SEND_MESSAGE", |
|
|
|
rb_define_const(grpc_rb_mCallOps, "SEND_MESSAGE", |
|
|
@ -709,14 +703,14 @@ void Init_grpc_call() { |
|
|
|
grpc_rb_eOutOfTime = |
|
|
|
grpc_rb_eOutOfTime = |
|
|
|
rb_define_class_under(grpc_rb_mGrpcCore, "OutOfTime", rb_eException); |
|
|
|
rb_define_class_under(grpc_rb_mGrpcCore, "OutOfTime", rb_eException); |
|
|
|
grpc_rb_cCall = rb_define_class_under(grpc_rb_mGrpcCore, "Call", rb_cObject); |
|
|
|
grpc_rb_cCall = rb_define_class_under(grpc_rb_mGrpcCore, "Call", rb_cObject); |
|
|
|
grpc_rb_cMdAry = rb_define_class_under(grpc_rb_mGrpcCore, "MetadataArray", |
|
|
|
grpc_rb_cMdAry = |
|
|
|
rb_cObject); |
|
|
|
rb_define_class_under(grpc_rb_mGrpcCore, "MetadataArray", rb_cObject); |
|
|
|
|
|
|
|
|
|
|
|
/* Prevent allocation or inialization of the Call class */ |
|
|
|
/* Prevent allocation or inialization of the Call class */ |
|
|
|
rb_define_alloc_func(grpc_rb_cCall, grpc_rb_cannot_alloc); |
|
|
|
rb_define_alloc_func(grpc_rb_cCall, grpc_rb_cannot_alloc); |
|
|
|
rb_define_method(grpc_rb_cCall, "initialize", grpc_rb_cannot_init, 0); |
|
|
|
rb_define_method(grpc_rb_cCall, "initialize", grpc_rb_cannot_init, 0); |
|
|
|
rb_define_method(grpc_rb_cCall, "initialize_copy", |
|
|
|
rb_define_method(grpc_rb_cCall, "initialize_copy", grpc_rb_cannot_init_copy, |
|
|
|
grpc_rb_cannot_init_copy, 1); |
|
|
|
1); |
|
|
|
|
|
|
|
|
|
|
|
/* Add ruby analogues of the Call methods. */ |
|
|
|
/* Add ruby analogues of the Call methods. */ |
|
|
|
rb_define_method(grpc_rb_cCall, "run_batch", grpc_rb_call_run_batch, 4); |
|
|
|
rb_define_method(grpc_rb_cCall, "run_batch", grpc_rb_call_run_batch, 4); |
|
|
@ -746,16 +740,8 @@ void Init_grpc_call() { |
|
|
|
|
|
|
|
|
|
|
|
/* The Struct used to return the run_batch result. */ |
|
|
|
/* The Struct used to return the run_batch result. */ |
|
|
|
grpc_rb_sBatchResult = rb_struct_define( |
|
|
|
grpc_rb_sBatchResult = rb_struct_define( |
|
|
|
"BatchResult", |
|
|
|
"BatchResult", "send_message", "send_metadata", "send_close", |
|
|
|
"send_message", |
|
|
|
"send_status", "message", "metadata", "status", "cancelled", NULL); |
|
|
|
"send_metadata", |
|
|
|
|
|
|
|
"send_close", |
|
|
|
|
|
|
|
"send_status", |
|
|
|
|
|
|
|
"message", |
|
|
|
|
|
|
|
"metadata", |
|
|
|
|
|
|
|
"status", |
|
|
|
|
|
|
|
"cancelled", |
|
|
|
|
|
|
|
NULL); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* The hash for reference counting calls, to ensure they can't be destroyed
|
|
|
|
/* The hash for reference counting calls, to ensure they can't be destroyed
|
|
|
|
* more than once */ |
|
|
|
* more than once */ |
|
|
|