@JRubyMethod public IRubyObject build(ThreadContext context, Block block) { RubyBuilder ctx = (RubyBuilder) cBuilder.newInstance(context, Block.NULL_BLOCK); if (block.arity() == Arity.ONE_ARGUMENT) { block.yield(context, ctx); } else { Binding binding = block.getBinding(); binding.setSelf(ctx); block.yieldSpecific(context); } ctx.finalizeToPool(context, this); buildFileDescriptor(context); return context.runtime.getNil(); }
@JRubyMethod(name = "add_message") public IRubyObject addMessage(ThreadContext context, IRubyObject name, Block block) { RubyDescriptor msgdef = (RubyDescriptor) cDescriptor.newInstance(context, Block.NULL_BLOCK); IRubyObject ctx = cMessageBuilderContext.newInstance(context, msgdef, this, Block.NULL_BLOCK); msgdef.setName(context, name); if (block.isGiven()) { if (block.arity() == Arity.ONE_ARGUMENT) { block.yield(context, ctx); } else { Binding binding = block.getBinding(); binding.setSelf(ctx); block.yieldSpecific(context); } } this.pendingList.add(msgdef); return context.runtime.getNil(); }
@JRubyMethod(name = "add_enum") public IRubyObject addEnum(ThreadContext context, IRubyObject name, Block block) { RubyEnumDescriptor enumDef = (RubyEnumDescriptor) cEnumDescriptor.newInstance(context, Block.NULL_BLOCK); IRubyObject ctx = cEnumBuilderContext.newInstance(context, enumDef, Block.NULL_BLOCK); enumDef.setName(context, name); if (block.isGiven()) { if (block.arity() == Arity.ONE_ARGUMENT) { block.yield(context, ctx); } else { Binding binding = block.getBinding(); binding.setSelf(ctx); block.yieldSpecific(context); } } this.pendingList.add(enumDef); return context.runtime.getNil(); }
@Override public Arity getArity() { return proc.getBlock().arity(); }
@JRubyMethod(name = "find_index", compat = RUBY1_9) public static IRubyObject find_index19(ThreadContext context, IRubyObject self, final Block block) { return find_index(context, self, block, block.arity()); }
@JRubyMethod(name = "one?", compat = RUBY1_9) public static IRubyObject one_p19(ThreadContext context, IRubyObject self, final Block block) { return one_p(context, self, block, block.arity()); }
@JRubyMethod(name = "count", compat = CompatVersion.RUBY1_9) public static IRubyObject count(ThreadContext context, IRubyObject self, final Block block) { return countCommon(context, self, block, block.arity()); }
@JRubyMethod(name = "none?", compat = RUBY1_9) public static IRubyObject none_p19(ThreadContext context, IRubyObject self, final Block block) { return none_p(context, self, block, block.arity()); }
@JRubyMethod(name = "find_index", compat = RUBY1_9) public static IRubyObject find_index19(ThreadContext context, IRubyObject self, final Block block) { return find_index(context, self, block, block.arity()); }
@JRubyMethod(name = "none?", compat = RUBY1_9) public static IRubyObject none_p19(ThreadContext context, IRubyObject self, final Block block) { return none_p(context, self, block, block.arity()); }
@JRubyMethod(name = "all?", compat = RUBY1_9) public static IRubyObject all_p19(ThreadContext context, IRubyObject self, final Block block) { if (self instanceof RubyArray) return ((RubyArray) self).all_p(context, block); return all_pCommon(context, self, block, block.arity()); }
@JRubyMethod(name = {"call", "[]", "yield", "==="}, rest = true, compat = RUBY1_9) public IRubyObject call19(ThreadContext context, IRubyObject[] args, Block blockCallArg) { if (isLambda()) { block.arity().checkArity(context.runtime, args.length); } if (isProc()) args = prepareProcArgs(context, block.arity(), args); return call(context, args, null, blockCallArg); }
@JRubyMethod(name = {"call", "[]", "yield", "==="}, rest = true, compat = RUBY1_9) public IRubyObject call19(ThreadContext context, IRubyObject[] args, Block blockCallArg) { if (isLambda()) { block.arity().checkArity(context.runtime, args.length); } if (isProc()) args = prepareProcArgs(context, block.arity(), args); return call(context, args, null, blockCallArg); }
public static IRubyObject unsplatValue19IfArityOne(IRubyObject argsResult, Block block) { if (block.isGiven() && block.arity().getValue() > 1) argsResult = Helpers.unsplatValue19(argsResult); return argsResult; }
@JRubyMethod(name = "any?", compat = CompatVersion.RUBY1_9) public static IRubyObject any_p(ThreadContext context, IRubyObject self, final Block block) { if (self instanceof RubyArray) return ((RubyArray) self).any_p(context, block); return any_pCommon(context, self, block, block.arity()); }
@JRubyMethod(name = "any?", compat = CompatVersion.RUBY1_9) public static IRubyObject any_p(ThreadContext context, IRubyObject self, final Block block) { if (self instanceof RubyArray) return ((RubyArray) self).any_p(context, block); return any_pCommon(context, self, block, block.arity()); }
@JRubyMethod(name = "all?", compat = RUBY1_9) public static IRubyObject all_p19(ThreadContext context, IRubyObject self, final Block block) { if (self instanceof RubyArray) return ((RubyArray) self).all_p(context, block); return all_pCommon(context, self, block, block.arity()); }
@JRubyMethod(name = "arity") public RubyFixnum arity() { return getRuntime().newFixnum(block.arity().getValue()); }
/** default_proc_arity_check * */ private void checkDefaultProcArity(IRubyObject proc) { int n = ((RubyProc)proc).getBlock().arity().getValue(); if(((RubyProc)proc).getBlock().type == Block.Type.LAMBDA && n != 2 && (n >= 0 || n < -3)) { if(n < 0) n = -n-1; throw getRuntime().newTypeError("default_proc takes two arguments (2 for " + n + ")"); } }
/** default_proc_arity_check * */ private void checkDefaultProcArity(IRubyObject proc) { int n = ((RubyProc)proc).getBlock().arity().getValue(); if(((RubyProc)proc).getBlock().type == Block.Type.LAMBDA && n != 2 && (n >= 0 || n < -3)) { if(n < 0) n = -n-1; throw getRuntime().newTypeError("default_proc takes two arguments (2 for " + n + ")"); } }