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

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

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

Ruby.newEmptyArray介绍

暂无

代码示例

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

/** nil_to_a
 *
 */
@JRubyMethod(name = "to_a")
public static RubyArray to_a(ThreadContext context, IRubyObject recv) {
  return context.runtime.newEmptyArray();
}

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

public static IRubyObject constructRestArg(ThreadContext context, Object[] args, RubyHash keywordArguments, int required, int argIndex) {
  int argsLength = keywordArguments != null ? args.length - 1 : args.length;
  int remainingArguments = argsLength - required;
  if (remainingArguments <= 0) return context.runtime.newEmptyArray();
  return RubyArray.newArrayMayCopy(context.runtime, (IRubyObject[]) args, argIndex, remainingArguments);
}

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

/** nil_to_a
 *
 */
@JRubyMethod
public static RubyArray to_a(ThreadContext context, IRubyObject recv) {
  return context.runtime.newEmptyArray();
}

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

@JRubyMethod
public static IRubyObject dimensions(ThreadContext context, IRubyObject maybeArray) {
  Ruby runtime = context.runtime;
  if (!(maybeArray instanceof RubyArray)) {
    return runtime.newEmptyArray();
  }
  RubyArray rubyArray = (RubyArray)maybeArray;
  RubyArray dims = runtime.newEmptyArray();
  
  return dimsRecurse(context, rubyArray, dims, 0);
}

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

public static IRubyObject constructRestArg(ThreadContext context, Object[] args, RubyHash keywordArguments, int required, int argIndex) {
  int argsLength = keywordArguments != null ? args.length - 1 : args.length;
  int remainingArguments = argsLength - required;
  if (remainingArguments <= 0) return context.runtime.newEmptyArray();
  return RubyArray.newArrayMayCopy(context.runtime, (IRubyObject[]) args, argIndex, remainingArguments);
}

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

/** nil_to_a
 *
 */
@JRubyMethod(name = "to_a")
public static RubyArray to_a(ThreadContext context, IRubyObject recv) {
  return context.runtime.newEmptyArray();
}

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

private static IRubyObject constructRestArg(ThreadContext context, IRubyObject[] args, RubyHash keywordArguments, int required, int argIndex) {
  int argsLength = keywordArguments != null ? args.length - 1 : args.length;
  if ( required == 0 && argsLength == args.length ) {
    return RubyArray.newArray(context.runtime, args);
  }
  int remainingArguments = argsLength - required;
  if (remainingArguments <= 0) return context.runtime.newEmptyArray();
  return RubyArray.newArrayMayCopy(context.runtime, args, argIndex, remainingArguments);
}

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

@JRubyMethod
public static IRubyObject dimensions(ThreadContext context, IRubyObject rubyArray, IRubyObject dims) {
  final Ruby runtime = context.runtime;
  if ( ! ( rubyArray instanceof RubyArray ) ) {
    return runtime.newEmptyArray();
  }
  assert dims instanceof RubyArray;
  return calcDimensions(runtime, (RubyArray) rubyArray, (RubyArray) dims, 0);
}

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

@JRubyMethod
public static IRubyObject dimensions(ThreadContext context, IRubyObject rubyArray, IRubyObject dims) {
  final Ruby runtime = context.runtime;
  if ( ! ( rubyArray instanceof RubyArray ) ) {
    return runtime.newEmptyArray();
  }
  assert dims instanceof RubyArray;
  return calcDimensions(runtime, (RubyArray) rubyArray, (RubyArray) dims, 0);
}

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

private static IRubyObject constructRestArg(ThreadContext context, IRubyObject[] args, RubyHash keywordArguments, int required, int argIndex) {
  int argsLength = keywordArguments != null ? args.length - 1 : args.length;
  if ( required == 0 && argsLength == args.length ) {
    return RubyArray.newArray(context.runtime, args);
  }
  int remainingArguments = argsLength - required;
  if (remainingArguments <= 0) return context.runtime.newEmptyArray();
  return RubyArray.newArrayMayCopy(context.runtime, args, argIndex, remainingArguments);
}

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

@JRubyMethod
public static IRubyObject dimensions(ThreadContext context, IRubyObject rubyArray) {
  return dimensions(context, rubyArray, context.runtime.newEmptyArray());
}

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

@Deprecated // not used
public static RubyArray splatValue19(IRubyObject value) {
  if (value.isNil()) {
    return value.getRuntime().newEmptyArray();
  }
  return arrayValue(value);
}

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

@JRubyMethod
public static IRubyObject dimensions(ThreadContext context, IRubyObject rubyArray, IRubyObject dims, IRubyObject index) {
  final Ruby runtime = context.runtime;
  if ( ! ( rubyArray instanceof RubyArray ) ) {
    return runtime.newEmptyArray();
  }
  assert dims instanceof RubyArray;
  assert index instanceof RubyFixnum;
  final int i = (int) ((RubyFixnum) index).getLongValue();
  return calcDimensions(runtime, (RubyArray) rubyArray, (RubyArray) dims, i);
}

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

@JRubyMethod
public static IRubyObject dimensions(ThreadContext context, IRubyObject maybeArray, IRubyObject dims, IRubyObject index) {
  Ruby runtime = context.runtime;
  if (!(maybeArray instanceof RubyArray)) {
    return runtime.newEmptyArray();
  }
  assert dims instanceof RubyArray;
  assert index instanceof RubyFixnum;
  
  RubyArray rubyArray = (RubyArray)maybeArray;
  
  return dimsRecurse(context, rubyArray, (RubyArray)dims, (int)((RubyFixnum)index).getLongValue());
}

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

@JRubyMethod
public static IRubyObject dimensions(ThreadContext context, IRubyObject rubyArray, IRubyObject dims, IRubyObject index) {
  final Ruby runtime = context.runtime;
  if ( ! ( rubyArray instanceof RubyArray ) ) {
    return runtime.newEmptyArray();
  }
  assert dims instanceof RubyArray;
  assert index instanceof RubyFixnum;
  final int i = (int) ((RubyFixnum) index).getLongValue();
  return calcDimensions(runtime, (RubyArray) rubyArray, (RubyArray) dims, i);
}

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

public static RubyArray asArray(ThreadContext context, IRubyObject value) {
  RubyClass array = context.runtime.getArray();
  IRubyObject tmp = TypeConverter.convertToTypeWithCheck19(value, array, "to_ary");
  
  if (tmp.isNil()) {
    tmp = TypeConverter.convertToTypeWithCheck19(value, array, "to_a");
    if (tmp.isNil()) return context.runtime.newEmptyArray();
  }
  
  return (RubyArray) tmp; // converters will guarantee it is RubyArray or raise.
}

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

public static RubyArray asArray(ThreadContext context, IRubyObject value) {
  RubyClass array = context.runtime.getArray();
  IRubyObject tmp = TypeConverter.convertToTypeWithCheck19(value, array, "to_ary");
  
  if (tmp.isNil()) {
    tmp = TypeConverter.convertToTypeWithCheck19(value, array, "to_a");
    if (tmp.isNil()) return context.runtime.newEmptyArray();
  }
  
  return (RubyArray) tmp; // converters will guarantee it is RubyArray or raise.
}

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

/** rb_ary_take
 *
 */
@JRubyMethod(name = "drop")
public IRubyObject drop(ThreadContext context, IRubyObject n) {
  Ruby runtime = context.runtime;
  long pos = RubyNumeric.num2long(n);
  if (pos < 0) throw runtime.newArgumentError("attempt to drop negative size");
  IRubyObject result = subseq(pos, realLength);
  return result.isNil() ? runtime.newEmptyArray() : result;
}

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

/** rb_ary_take
 *
 */
@JRubyMethod(name = "drop")
public IRubyObject drop(ThreadContext context, IRubyObject n) {
  Ruby runtime = context.runtime;
  long pos = RubyNumeric.num2long(n);
  if (pos < 0) throw runtime.newArgumentError("attempt to drop negative size");
  IRubyObject result = subseq(pos, realLength);
  return result.isNil() ? runtime.newEmptyArray() : result;
}

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

/** rb_ary_take
 * 
 */
@JRubyMethod(name = "drop")
public IRubyObject drop(ThreadContext context, IRubyObject n) {
  Ruby runtime = context.runtime;
  long pos = RubyNumeric.num2long(n);
  if (pos < 0) throw runtime.newArgumentError("attempt to drop negative size");
  IRubyObject result = subseq(pos, realLength);
  return result.isNil() ? runtime.newEmptyArray() : result;
}

相关文章

微信公众号

最新文章

更多

Ruby类方法