public static Block newCallClosure(IRubyObject self, RubyModule imClass, Signature signature, BlockCallback callback, ThreadContext context) { Binding binding = context.currentBinding(self, Visibility.PUBLIC); BlockBody body = new CallBlock(signature, callback, context); return new Block(body, binding); }
@Deprecated public static Block newCallClosure(IRubyObject self, RubyModule imClass, Arity arity, BlockCallback callback, ThreadContext context) { return newCallClosure(self, imClass, Signature.from(arity), callback, context); }
@Override public IRubyObject call(ThreadContext context, Block block, IRubyObject[] args, Block blockArg) { return callback.call(context, adjustArgs(block, args), blockArg); }
@Override public IRubyObject yieldSpecific(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Binding binding, Block.Type type) { return yield(context, new IRubyObject[] {arg0, arg1, arg2}, Block.NULL_BLOCK); }
private IRubyObject yield(ThreadContext context, IRubyObject[] args, Block block) { IRubyObject[] preppedArgs = RubyProc.prepareProcArgs(context, arity(), args); return callback.call(context, preppedArgs, Block.NULL_BLOCK); }
@Override public IRubyObject yieldSpecific(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Binding binding, Block.Type type) { return yield(context, new IRubyObject[] {arg0, arg1}, Block.NULL_BLOCK); }
private IRubyObject yield(ThreadContext context, IRubyObject[] args, Block block) { IRubyObject[] preppedArgs = RubyProc.prepareProcArgs(context, arity(), args); return callback.call(context, preppedArgs, Block.NULL_BLOCK); }
@Deprecated public static Block newCallClosure(IRubyObject self, RubyModule imClass, Arity arity, BlockCallback callback, ThreadContext context) { return newCallClosure(self, imClass, Signature.from(arity), callback, context); }
public static Block newCallClosure(IRubyObject self, RubyModule imClass, Arity arity, BlockCallback callback, ThreadContext context) { Binding binding = context.currentBinding(self, Visibility.PUBLIC); BlockBody body = new CallBlock(arity, callback, context); return new Block(body, binding); }
@Override protected IRubyObject doYield(ThreadContext context, Block block, IRubyObject[] args, IRubyObject self) { return callback.call(context, adjustArgs(block, args), Block.NULL_BLOCK); }
@Override public IRubyObject yieldSpecific(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Binding binding, Block.Type type) { return yield(context, new IRubyObject[] {arg0, arg1}, Block.NULL_BLOCK); }
@Deprecated public static IRubyObject callEach(Ruby runtime, ThreadContext context, IRubyObject self, Arity arity, BlockCallback callback) { return Helpers.invoke(context, self, "each", CallBlock.newCallClosure(self, runtime.getEnumerable(), arity, callback, context)); }
public static Block newCallClosure(IRubyObject self, RubyModule imClass, Arity arity, BlockCallback callback, ThreadContext context) { Binding binding = context.currentBinding(self, Visibility.PUBLIC); BlockBody body = new CallBlock(arity, callback, context); return new Block(body, binding); }
@Override protected IRubyObject doYield(ThreadContext context, Block block, IRubyObject[] args, IRubyObject self) { return callback.call(context, adjustArgs(block, args), Block.NULL_BLOCK); }
@Override public IRubyObject yieldSpecific(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Binding binding, Block.Type type) { return yield(context, new IRubyObject[] {arg0, arg1, arg2}, Block.NULL_BLOCK); }
@Deprecated public static IRubyObject callEach(Ruby runtime, ThreadContext context, IRubyObject self, IRubyObject[] args, Arity arity, BlockCallback callback) { return Helpers.invoke(context, self, "each", args, CallBlock.newCallClosure(self, runtime.getEnumerable(), arity, callback, context)); }
public static Block newCallClosure(IRubyObject self, RubyModule imClass, Signature signature, BlockCallback callback, ThreadContext context) { Binding binding = context.currentBinding(self, Visibility.PUBLIC); BlockBody body = new CallBlock(signature, callback, context); return new Block(body, binding); }
@Override public IRubyObject call(ThreadContext context, Block block, IRubyObject[] args) { return callback.call(context, adjustArgs(block, args), Block.NULL_BLOCK); }
/** * Yield to this block, usually passed to the current call. * * @param context represents the current thread-specific data * @param value The value to yield, either a single value or an array of values * @param self The current self * @param klass * @param aValue Should value be arrayified or not? * @return */ public IRubyObject yield(ThreadContext context, IRubyObject value, IRubyObject self, RubyModule klass, boolean aValue, Binding binding, Block.Type type) { IRubyObject[] args = value.respondsTo("to_a") ? value.convertToArray().toJavaArray() : new IRubyObject[] {value}; return yield(context, args, Block.NULL_BLOCK); }
@Deprecated public static IRubyObject callEach(Ruby runtime, ThreadContext context, IRubyObject self, IRubyObject[] args, BlockCallback callback) { return Helpers.invoke(context, self, "each", args, CallBlock.newCallClosure(self, runtime.getEnumerable(), Signature.OPTIONAL, callback, context)); }