org.jruby.runtime.Block.call()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中org.jruby.runtime.Block.call()方法的一些代码示例,展示了Block.call()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Block.call()方法的具体详情如下:
包路径:org.jruby.runtime.Block
类名称:Block
方法名:call

Block.call介绍

暂无

代码示例

代码示例来源:origin: org.jruby/jruby-complete

@Override
  public IRubyObject size(IRubyObject[] args) {
    return block.call(context, args);
  }
};

代码示例来源:origin: org.jruby/jruby-core

@Override
  public IRubyObject size(IRubyObject[] args) {
    return block.call(context, args);
  }
};

代码示例来源:origin: org.jruby/jruby-core

public final IRubyObject compare(final ThreadContext context,
  final IRubyObject o1, final IRubyObject o2) {
  return block.call(context, o1, o2);
}

代码示例来源:origin: org.jruby/jruby-complete

private IRubyObject callImpl(ThreadContext context, RubyModule clazz, Block block, IRubyObject... args) {
  if ( methodNames == null ) return implBlock.call(context, args); // "hot" path
  if ( methodNames.length == 1 ) {
    if ( methodNames[0].equals(args[0]) ) return implBlock.call(context, args);
  }
  else if ( Arrays.binarySearch(methodNames, args[0]) >= 0 ) {
    return implBlock.call(context, args);
  }
  return clazz.getSuperClass().callMethod(context, "method_missing", args, block);
}

代码示例来源:origin: org.jruby/jruby-core

private IRubyObject callImpl(ThreadContext context, RubyModule clazz, Block block, IRubyObject... args) {
  if ( methodNames == null ) return implBlock.call(context, args); // "hot" path
  if ( methodNames.length == 1 ) {
    if ( methodNames[0].equals(args[0]) ) return implBlock.call(context, args);
  }
  else if ( Arrays.binarySearch(methodNames, args[0]) >= 0 ) {
    return implBlock.call(context, args);
  }
  return clazz.getSuperClass().callMethod(context, "method_missing", args, block);
}

代码示例来源:origin: org.jruby/jruby-core

public IRubyObject call(ThreadContext context, IRubyObject[] iargs, Block block) {
    return this.block.call(context, packEnumValues(context, iargs), context.runtime.newFixnum(index++));
  }
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) {
    return block.call(ctx, new IRubyObject[]{runtime.newArray(packEnumValues(runtime, largs), arg)});
  }
});

代码示例来源:origin: org.jruby/jruby-complete

public final IRubyObject call(ThreadContext context, IRubyObject[] args, IRubyObject self, Block passedBlock) {
  assert args != null;
  Block newBlock;
  // bind to new self, if given
  if (self == null) {
    newBlock = block;
  } else {
    newBlock = block.cloneBlockAndFrame();
    newBlock.getBinding().setSelf(self);
  }
  return newBlock.call(context, args, passedBlock);
}

代码示例来源:origin: org.jruby/jruby-core

public final IRubyObject call(ThreadContext context, IRubyObject[] args, IRubyObject self, Block passedBlock) {
  assert args != null;
  Block newBlock;
  // bind to new self, if given
  if (self == null) {
    newBlock = block;
  } else {
    newBlock = block.cloneBlockAndFrame();
    newBlock.getBinding().setSelf(self);
  }
  return newBlock.call(context, args, passedBlock);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) {
    block.call(ctx, new IRubyObject[]{runtime.newArray(packEnumValues(runtime, largs), arg)});
    return runtime.getNil();
  }
});

代码示例来源:origin: org.jruby/jruby-core

protected final void invoke(Buffer buffer, Object recv) {
  ThreadContext context = runtime.getCurrentContext();
  IRubyObject[] params = new IRubyObject[closureInfo.parameterTypes.length];
  for (int i = 0; i < params.length; ++i) {
    params[i] = fromNative(runtime, closureInfo.parameterTypes[i], buffer, i);
  }
  IRubyObject retVal = recv instanceof Block
      ? ((Block) recv).call(context, params)
      : callSite.call(context, (IRubyObject) recv, (IRubyObject) recv, params);
  setReturnValue(runtime, closureInfo.returnType, buffer, retVal);
}

代码示例来源:origin: org.jruby/jruby-complete

protected final void invoke(Buffer buffer, Object recv) {
  ThreadContext context = runtime.getCurrentContext();
  IRubyObject[] params = new IRubyObject[closureInfo.parameterTypes.length];
  for (int i = 0; i < params.length; ++i) {
    params[i] = fromNative(runtime, closureInfo.parameterTypes[i], buffer, i);
  }
  IRubyObject retVal = recv instanceof Block
      ? ((Block) recv).call(context, params)
      : callSite.call(context, (IRubyObject) recv, (IRubyObject) recv, params);
  setReturnValue(runtime, closureInfo.returnType, buffer, retVal);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

protected final void invoke(Buffer buffer, Object recv) {
  ThreadContext context = runtime.getCurrentContext();
  IRubyObject[] params = new IRubyObject[closureInfo.parameterTypes.length];
  for (int i = 0; i < params.length; ++i) {
    params[i] = fromNative(runtime, closureInfo.parameterTypes[i], buffer, i);
  }
  IRubyObject retVal = recv instanceof Block
      ? ((Block) recv).call(context, params)
      : callSite.call(context, (IRubyObject) recv, (IRubyObject) recv, params);
  setReturnValue(runtime, closureInfo.returnType, buffer, retVal);
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

/** rb_yield */
public static IRubyObject yield(Ruby runtime, RubyArray args) {
  return runtime.getCurrentContext().getFrameBlock().call(runtime.getCurrentContext(), args.toJavaArray());
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

public IRubyObject call(ThreadContext context, IRubyObject[] args, Block blk) {
    // note the we do not want to call the block with packed args, since to match MRI behavior,
    // the block's test is against the raw args (using block.arity() rather than the Arity.OPTIONAL
    // we pass to callEach)
    if (!block.call(context, args).isTrue()) {
      throw JumpException.SPECIAL_JUMP;
    }
    IRubyObject packedArg = packEnumValues(context.runtime, args);
    synchronized (result) { result.append(packedArg); }
    return runtime.getNil();
  }
});

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

public IRubyObject call(ThreadContext context, IRubyObject[] args, Block blk) {
    // note the we do not want to call the block with packed args, since to match MRI behavior,
    // the block's test is against the raw args (using block.arity() rather than the Arity.OPTIONAL
    // we pass to callEach)
    if (!block.call(context, args).isTrue()) {
      throw JumpException.SPECIAL_JUMP;
    }
    IRubyObject packedArg = packEnumValues(context.runtime, args);
    synchronized (result) { result.append(packedArg); }
    return runtime.getNil();
  }
});

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

protected final void invoke(Buffer buffer, Object recv) {
  ThreadContext context = runtime.getCurrentContext();
  IRubyObject[] params = new IRubyObject[closureInfo.parameterTypes.length];
  for (int i = 0; i < params.length; ++i) {
    params[i] = fromNative(runtime, closureInfo.parameterTypes[i], buffer, i);
  }
  IRubyObject retVal = recv instanceof Block
      ? ((Block) recv).call(context, params)
      : callSite.call(context, (IRubyObject) recv, (IRubyObject) recv, params);
  setReturnValue(runtime, closureInfo.returnType, buffer, retVal);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

@Override
  public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args, Block block) {
    Arity.checkArgumentCount(context.runtime, name, args.length, 1, -1);
    if (methodNames == null || methodNames.include_p(context, args[0]).isTrue()) {
      return implBlock.call(context, args);
    } else {
      return clazz.getSuperClass().callMethod(context, "method_missing", args, block);
    }
  }
});

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

@Override
  public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args, Block block) {
    Arity.checkArgumentCount(context.runtime, name, args.length, 1, -1);
    if (methodNames == null || methodNames.include_p(context, args[0]).isTrue()) {
      return implBlock.call(context, args);
    } else {
      return clazz.getSuperClass().callMethod(context, "method_missing", args, block);
    }
  }
});

代码示例来源:origin: headius/jo

public IRubyObject call() throws Exception {
  ThreadContext context = runtime.getCurrentContext();
  try {
    return body.call(context);
  } catch (RaiseException re) {
    RubyKernel.puts(context, body.getBinding().getSelf(), new IRubyObject[] {
        RubyString.newString(runtime, "joroutine terminated with error: " + re.getMessage())});
    RubyKernel.puts(context, body.getBinding().getSelf(), new IRubyObject[] {re.getException().backtrace()});
    throw re;
  }
}

相关文章