Skip to content

Commit

Permalink
Follows callback declaration updates
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu authored and eregon committed Sep 29, 2019
1 parent 99cd8ce commit c1eab60
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
6 changes: 3 additions & 3 deletions optional/capi/ext/array_spec.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ static VALUE array_spec_rb_assoc_new(VALUE self, VALUE first, VALUE second) {
return rb_assoc_new(first, second);
}

static VALUE copy_ary(VALUE el, VALUE new_ary) {
static VALUE copy_ary(RB_BLOCK_CALL_FUNC_ARGLIST(el, new_ary)) {
return rb_ary_push(new_ary, el);
}

Expand All @@ -178,7 +178,7 @@ static VALUE array_spec_rb_iterate(VALUE self, VALUE ary) {
return new_ary;
}

static VALUE sub_pair(VALUE el, VALUE holder) {
static VALUE sub_pair(RB_BLOCK_CALL_FUNC_ARGLIST(el, holder)) {
return rb_ary_push(holder, rb_ary_entry(el, 1));
}

Expand All @@ -194,7 +194,7 @@ static VALUE array_spec_rb_iterate_each_pair(VALUE self, VALUE obj) {
return new_ary;
}

static VALUE iter_yield(VALUE el, VALUE ary) {
static VALUE iter_yield(RB_BLOCK_CALL_FUNC_ARGLIST(el, ary)) {
rb_yield(el);
return Qnil;
}
Expand Down
14 changes: 9 additions & 5 deletions optional/capi/ext/kernel_spec.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ VALUE kernel_spec_call_proc(VALUE arg_array) {
return rb_funcall(proc, rb_intern("call"), 1, arg);
}

VALUE kernel_spec_call_proc_raise(VALUE arg_array, VALUE raised_exc) {
return kernel_spec_call_proc(arg_array);
}

static VALUE kernel_spec_rb_block_given_p(VALUE self) {
return rb_block_given_p() ? Qtrue : Qfalse;
}
Expand All @@ -30,7 +34,7 @@ VALUE kernel_spec_rb_block_lambda(VALUE self) {
return rb_block_lambda();
}

VALUE block_call_inject(VALUE yield_value, VALUE data2) {
VALUE block_call_inject(RB_BLOCK_CALL_FUNC_ARGLIST(yield_value, data2)) {
/* yield_value yields the first block argument */
VALUE elem = yield_value;
VALUE elem_incr = INT2FIX(FIX2INT(elem) + 1);
Expand All @@ -41,7 +45,7 @@ VALUE kernel_spec_rb_block_call(VALUE self, VALUE ary) {
return rb_block_call(ary, rb_intern("map"), 0, NULL, block_call_inject, Qnil);
}

VALUE block_call_inject_multi_arg(VALUE yield_value, VALUE data2, int argc, VALUE argv[]) {
VALUE block_call_inject_multi_arg(RB_BLOCK_CALL_FUNC_ARGLIST(yield_value, data2)) {
/* yield_value yields the first block argument */
VALUE sum = yield_value;
VALUE elem = argv[1];
Expand Down Expand Up @@ -80,15 +84,15 @@ VALUE kernel_spec_rb_ensure(VALUE self, VALUE main_proc, VALUE arg,
kernel_spec_call_proc, ensure_array);
}

VALUE kernel_spec_call_proc_with_catch(VALUE arg, VALUE data) {
VALUE kernel_spec_call_proc_with_catch(RB_BLOCK_CALL_FUNC_ARGLIST(arg, data)) {
return rb_funcall(data, rb_intern("call"), 0);
}

VALUE kernel_spec_rb_catch(VALUE self, VALUE sym, VALUE main_proc) {
return rb_catch(StringValuePtr(sym), kernel_spec_call_proc_with_catch, main_proc);
}

VALUE kernel_spec_call_proc_with_catch_obj(VALUE arg, VALUE data) {
VALUE kernel_spec_call_proc_with_catch_obj(RB_BLOCK_CALL_FUNC_ARGLIST(arg, data)) {
return rb_funcall(data, rb_intern("call"), 0);
}

Expand Down Expand Up @@ -161,7 +165,7 @@ VALUE kernel_spec_rb_rescue2(int argc, VALUE *args, VALUE self) {
rb_ary_push(raise_array, args[3]);

return rb_rescue2(kernel_spec_call_proc, main_array,
kernel_spec_call_proc, raise_array, args[4], args[5], (VALUE)0);
kernel_spec_call_proc_raise, raise_array, args[4], args[5], (VALUE)0);
}

static VALUE kernel_spec_rb_protect_yield(VALUE self, VALUE obj, VALUE ary) {
Expand Down
2 changes: 1 addition & 1 deletion optional/capi/ext/proc_spec.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
extern "C" {
#endif

VALUE proc_spec_rb_proc_new_function(VALUE args) {
VALUE proc_spec_rb_proc_new_function(RB_BLOCK_CALL_FUNC_ARGLIST(args, dummy)) {
return rb_funcall(args, rb_intern("inspect"), 0);
}

Expand Down
5 changes: 3 additions & 2 deletions optional/capi/ext/thread_spec.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ static VALUE thread_spec_rb_thread_wait_for(VALUE self, VALUE s, VALUE ms) {
}


VALUE thread_spec_call_proc(VALUE arg_array) {
VALUE thread_spec_call_proc(void *arg_ptr) {
VALUE arg_array = (VALUE)arg_ptr;
VALUE arg = rb_ary_pop(arg_array);
VALUE proc = rb_ary_pop(arg_array);
return rb_funcall(proc, rb_intern("call"), 1, arg);
Expand All @@ -125,7 +126,7 @@ static VALUE thread_spec_rb_thread_create(VALUE self, VALUE proc, VALUE arg) {
rb_ary_push(args, proc);
rb_ary_push(args, arg);

return rb_thread_create((VALUE (*)(void *))thread_spec_call_proc, (void*)args);
return rb_thread_create(thread_spec_call_proc, (void*)args);
}


Expand Down

0 comments on commit c1eab60

Please sign in to comment.