Skip to content

Commit

Permalink
Fixed propagating block passed to native method.
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Ford committed Nov 27, 2010
1 parent dc1d088 commit 43842f8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions vm/builtin/nativemethod.cpp
Expand Up @@ -636,6 +636,9 @@ namespace rubinius {
env->get_handle(msg.method),
env->get_handle(msg.module));

// Propagate the block passed to the native function.
env->set_outgoing_block(env->get_handle(args.block()));

Object* ret;
ExceptionPoint ep(env);

Expand Down
13 changes: 11 additions & 2 deletions vm/capi/capi.cpp
Expand Up @@ -372,15 +372,24 @@ extern "C" {

Object* blk = RBX_Qnil;

if(VALUE blk_handle = env->outgoing_block()) {
VALUE blk_handle = env->outgoing_block();
if(blk_handle) {
blk = env->get_object(blk_handle);
env->set_outgoing_block(0);
}

return capi_funcall_backend_native(env, "", 0,
VALUE result = capi_funcall_backend_native(env, "", 0,
env->get_object(receiver),
reinterpret_cast<Symbol*>(method_name),
arg_count, args, blk);

// Ensure we reset the block in the NativeMethodFrame because
// another call may be made from a C-API function.
if(blk_handle) {
env->set_outgoing_block(blk_handle);
}

return result;
}

VALUE rb_funcall2(VALUE receiver, ID method_name, int arg_count, const VALUE* v_args) {
Expand Down

0 comments on commit 43842f8

Please sign in to comment.