org.jruby.Ruby.getSingleNilArray()方法的使用及代码示例

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

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

Ruby.getSingleNilArray介绍

暂无

代码示例

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

protected IRubyObject[] convertToRubyArray(ThreadContext context, IRubyObject[] args) {
  return (args.length == 0) ? context.runtime.getSingleNilArray()
               : new IRubyObject[] {context.runtime.newArrayNoCopy(args)};
}

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

protected IRubyObject[] convertToRubyArray(ThreadContext context, IRubyObject[] args) {
  return (args.length == 0) ? context.runtime.getSingleNilArray()
               : new IRubyObject[] {context.runtime.newArrayNoCopy(args)};
}

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

public static IRubyObject[] splatToArguments(IRubyObject value) {
  Ruby runtime = value.getRuntime();
  
  if (value.isNil()) {
    return runtime.getSingleNilArray();
  }
  
  return splatToArgumentsCommon(runtime, value);
}

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

public static IRubyObject[] splatToArguments(IRubyObject value) {
  Ruby runtime = value.getRuntime();
  
  if (value.isNil()) {
    return runtime.getSingleNilArray();
  }
  
  return splatToArgumentsCommon(runtime, value);
}

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

@Deprecated // no longer used
public static IRubyObject[] splatToArguments(IRubyObject value) {
  if (value.isNil()) {
    return value.getRuntime().getSingleNilArray();
  }
  IRubyObject tmp = value.checkArrayType();
  if (tmp.isNil()) {
    return convertSplatToJavaArray(value.getRuntime(), value);
  }
  return ((RubyArray)tmp).toJavaArrayMaybeUnsafe();
}

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

@Deprecated // no longer used
public static IRubyObject[] splatToArguments(IRubyObject value) {
  if (value.isNil()) {
    return value.getRuntime().getSingleNilArray();
  }
  IRubyObject tmp = value.checkArrayType();
  if (tmp.isNil()) {
    return convertSplatToJavaArray(value.getRuntime(), value);
  }
  return ((RubyArray)tmp).toJavaArrayMaybeUnsafe();
}

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

private static IRubyObject[] splatToArgumentsCommon(Ruby runtime, IRubyObject value) {
  
  if (value.isNil()) {
    return runtime.getSingleNilArray();
  }
  
  IRubyObject tmp = value.checkArrayType();
  if (tmp.isNil()) {
    return convertSplatToJavaArray(runtime, value);
  }
  return ((RubyArray)tmp).toJavaArrayMaybeUnsafe();
}

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

private static IRubyObject[] splatToArgumentsCommon(Ruby runtime, IRubyObject value) {
  
  if (value.isNil()) {
    return runtime.getSingleNilArray();
  }
  
  IRubyObject tmp = value.checkArrayType();
  if (tmp.isNil()) {
    return convertSplatToJavaArray(runtime, value);
  }
  return ((RubyArray)tmp).toJavaArrayMaybeUnsafe();
}

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

@Override
  public IRubyObject[] prepareArgumentsForCall(ThreadContext context, IRubyObject[] args, Block.Type type) {
    if (type == Block.Type.LAMBDA) {
      arity().checkArity(context.runtime, args);
    } else {
      // SSS FIXME: How is it even possible to "call" a NORMAL block?
      // I thought only procs & lambdas can be called, and blocks are yielded to.
      if (args.length == 1) {
        // Convert value to arg-array, unwrapping where necessary
        args = convertValueIntoArgArray(context, args[0], true, (type == Block.Type.NORMAL) && (args[0] instanceof RubyArray));
      } else if (arity().getValue() == 1) {
        // discard excess arguments
        args = (args.length == 0) ? context.runtime.getSingleNilArray() : new IRubyObject[] { args[0] };
      }
    }

    return args;
  }
}

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

@Override
  public IRubyObject[] prepareArgumentsForCall(ThreadContext context, IRubyObject[] args, Block.Type type) {
    if (type == Block.Type.LAMBDA) {
      arity().checkArity(context.runtime, args);
    } else {
      // SSS FIXME: How is it even possible to "call" a NORMAL block?
      // I thought only procs & lambdas can be called, and blocks are yielded to.
      if (args.length == 1) {
        // Convert value to arg-array, unwrapping where necessary
        args = convertValueIntoArgArray(context, args[0], true, (type == Block.Type.NORMAL) && (args[0] instanceof RubyArray));
      } else if (arity().getValue() == 1) {
        // discard excess arguments
        args = (args.length == 0) ? context.runtime.getSingleNilArray() : new IRubyObject[] { args[0] };
      }
    }

    return args;
  }
}

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

public IRubyObject[] prepareArgumentsForCall(ThreadContext context, IRubyObject[] args, Block.Type type) {
  if (type == Block.Type.LAMBDA) {
    signature.checkArity(context.runtime, args);
  } else {
    // SSS FIXME: How is it even possible to "call" a NORMAL block?
    // I thought only procs & lambdas can be called, and blocks are yielded to.
    if (args.length == 1) {
      // Convert value to arg-array, unwrapping where necessary
      args = IRRuntimeHelpers.convertValueIntoArgArray(context, args[0], signature, type == Block.Type.NORMAL && args[0] instanceof RubyArray);
    } else if (getSignature().arityValue() == 1 && !getSignature().restKwargs()) {
      // discard excess arguments
      args = args.length == 0 ? context.runtime.getSingleNilArray() : new IRubyObject[] { args[0] };
    }
  }
  return args;
}

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

public IRubyObject[] prepareArgumentsForCall(ThreadContext context, IRubyObject[] args, Block.Type type) {
  if (type == Block.Type.LAMBDA) {
    signature.checkArity(context.runtime, args);
  } else {
    // SSS FIXME: How is it even possible to "call" a NORMAL block?
    // I thought only procs & lambdas can be called, and blocks are yielded to.
    if (args.length == 1) {
      // Convert value to arg-array, unwrapping where necessary
      args = IRRuntimeHelpers.convertValueIntoArgArray(context, args[0], signature, type == Block.Type.NORMAL && args[0] instanceof RubyArray);
    } else if (getSignature().arityValue() == 1 && !getSignature().restKwargs()) {
      // discard excess arguments
      args = args.length == 0 ? context.runtime.getSingleNilArray() : new IRubyObject[] { args[0] };
    }
  }
  return args;
}

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

@Interp @JIT
public static IRubyObject[] prepareSingleBlockArgs(ThreadContext context, Block block, IRubyObject[] args) {
  if (args == null) args = IRubyObject.NULL_ARRAY;
  switch (block.type) {
    case LAMBDA:
      block.getBody().getSignature().checkArity(context.runtime, args);
      return args;
    case PROC:
      if (args.length == 0) {
        args = context.runtime.getSingleNilArray();
      } else if (args.length == 1) {
        args = prepareProcArgs(context, block, args);
      } else {
        args = new IRubyObject[] { args[0] };
      }
  }
  // If there are insufficient args, ReceivePreReqdInstr will return nil
  return args;
}

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

@Interp @JIT
public static IRubyObject[] prepareSingleBlockArgs(ThreadContext context, Block block, IRubyObject[] args) {
  if (args == null) args = IRubyObject.NULL_ARRAY;
  switch (block.type) {
    case LAMBDA:
      block.getBody().getSignature().checkArity(context.runtime, args);
      return args;
    case PROC:
      if (args.length == 0) {
        args = context.runtime.getSingleNilArray();
      } else if (args.length == 1) {
        args = prepareProcArgs(context, block, args);
      } else {
        args = new IRubyObject[] { args[0] };
      }
  }
  // If there are insufficient args, ReceivePreReqdInstr will return nil
  return args;
}

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

IRubyObject exitHandlerProc = trapResultEntries[0];
if (exitHandlerProc instanceof RubyProc) {
  ((RubyProc) exitHandlerProc).call(context, getSingleNilArray());

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

IRubyObject exitHandlerProc = trapResultEntries[0];
if (exitHandlerProc instanceof RubyProc) {
  ((RubyProc) exitHandlerProc).call(context, getSingleNilArray());

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

context.runtime.getWarnings().warn(ID.MULTIPLE_VALUES_FOR_BLOCK, "multiple values for a block parameter (" + args.length + " for " + arity().getValue() + ")");
if (args.length == 0) {
  args = context.runtime.getSingleNilArray();
} else {
  args = new IRubyObject[] {context.runtime.newArrayNoCopy(args)};

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

context.runtime.getWarnings().warn(ID.MULTIPLE_VALUES_FOR_BLOCK, "multiple values for a block parameter (" + args.length + " for " + arity().getValue() + ")");
if (args.length == 0) {
  args = context.runtime.getSingleNilArray();
} else {
  args = new IRubyObject[] {context.runtime.newArrayNoCopy(args)};

相关文章

微信公众号

最新文章

更多

Ruby类方法