本文整理了Java中org.jruby.Ruby.newArrayNoCopy
方法的一些代码示例,展示了Ruby.newArrayNoCopy
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.newArrayNoCopy
方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:newArrayNoCopy
暂无
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@Override
public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
IRubyObject[] array = interpretPrimitive(runtime, context, self, aBlock);
return lightweight ? runtime.newArrayNoCopyLight(array) : runtime.newArrayNoCopy(array);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
/**
* Package the arguments appropriately depending on how many there are
* Corresponds to rb_enum_values_pack in MRI
*/
static IRubyObject packEnumValues(Ruby runtime, IRubyObject[] args) {
if (args.length < 2) {
return args.length == 0 ? runtime.getNil() : args[0];
} else {
// For more than 1 arg, we pack them as an array
return runtime.newArrayNoCopy(args);
}
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
/**
* Package the arguments appropriately depending on how many there are
* Corresponds to rb_enum_values_pack in MRI
*/
static IRubyObject packEnumValues(Ruby runtime, IRubyObject[] args) {
if (args.length < 2) {
return args.length == 0 ? runtime.getNil() : args[0];
} else {
// For more than 1 arg, we pack them as an array
return runtime.newArrayNoCopy(args);
}
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
private static IRubyObject intoStringArray(Ruby runtime, String[] members) {
IRubyObject[] arr = new IRubyObject[members.length];
for(int i = 0; i<arr.length; i++) {
arr[i] = runtime.newString(members[i]);
}
return runtime.newArrayNoCopy(arr);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@Override
public IRubyObject call(ThreadContext context, Binding binding, Type type) {
throw context.runtime.newLocalJumpError(RubyLocalJumpError.Reason.NOREASON, context.runtime.newArrayNoCopy(IRubyObject.NULL_ARRAY), "yield called out of block");
}
@Override
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@Override
public IRubyObject call(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Binding binding, Type type) {
throw context.runtime.newLocalJumpError(RubyLocalJumpError.Reason.NOREASON, context.runtime.newArrayNoCopy(new IRubyObject[]{arg0, arg1}), "yield called out of block");
}
@Override
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public static RubyArray getRubyArray(Ruby runtime, Class<?>[] classes) {
IRubyObject[] javaClasses = new IRubyObject[classes.length];
for (int i = classes.length; --i >= 0; ) {
javaClasses[i] = get(runtime, classes[i]);
}
return runtime.newArrayNoCopy(javaClasses);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@Override
public IRubyObject call(ThreadContext context, IRubyObject arg0, Binding binding, Type type) {
throw context.runtime.newLocalJumpError(RubyLocalJumpError.Reason.NOREASON, context.runtime.newArrayNoCopy(new IRubyObject[]{arg0}), "yield called out of block");
}
@Override
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
private static IRubyObject asRubyStringList(Ruby runtime, List<ByteList> dirs) {
List<RubyString> allFiles = new ArrayList<RubyString>();
Encoding enc = runtime.getDefaultExternalEncoding();
if (enc == null) {
enc = UTF8;
}
for (ByteList dir : dirs) {
allFiles.add(RubyString.newString(runtime, dir, enc));
}
IRubyObject[] tempFileList = new IRubyObject[allFiles.size()];
allFiles.toArray(tempFileList);
return runtime.newArrayNoCopy(tempFileList);
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
private static RubyArray entriesCommon(Ruby runtime, String path) {
String adjustedPath = RubyFile.adjustRootPathOnWindows(runtime, path, null);
checkDirIsTwoSlashesOnWindows(runtime, adjustedPath);
Object[] files = getEntries(runtime, adjustedPath).toArray();
return runtime.newArrayNoCopy(JavaUtil.convertJavaArrayToRuby(runtime, files));
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
private static RubyArray entriesCommon(Ruby runtime, String path) {
String adjustedPath = RubyFile.adjustRootPathOnWindows(runtime, path, null);
checkDirIsTwoSlashesOnWindows(runtime, adjustedPath);
Object[] files = getEntries(runtime, adjustedPath).toArray();
return runtime.newArrayNoCopy(JavaUtil.convertJavaArrayToRuby(runtime, files));
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
public IRubyObject each_pairInternal(ThreadContext context, Block block) {
RubyArray member = __member__();
for (int i = 0; i < values.length; i++) {
block.yield(context, getRuntime().newArrayNoCopy(new IRubyObject[]{member.eltInternal(i), values[i]}));
}
return this;
}
代码示例来源:origin: org.jruby/jruby-complete
@JRubyMethod // [ ajd, @of, @sg ]
public IRubyObject marshal_dump(ThreadContext context) {
final Ruby runtime = context.runtime;
return context.runtime.newArrayNoCopy(new IRubyObject[] {
ajd(context),
RubyFixnum.newFixnum(runtime, off),
RubyFixnum.newFixnum(runtime, start)
});
}
代码示例来源:origin: org.jruby/jruby-core
@JRubyMethod // [ ajd, @of, @sg ]
public IRubyObject marshal_dump(ThreadContext context) {
final Ruby runtime = context.runtime;
return context.runtime.newArrayNoCopy(new IRubyObject[] {
ajd(context),
RubyFixnum.newFixnum(runtime, off),
RubyFixnum.newFixnum(runtime, start)
});
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
/**
* @return all entries for this Dir
*/
@JRubyMethod(name = "entries")
public RubyArray entries() {
return getRuntime().newArrayNoCopy(JavaUtil.convertJavaArrayToRuby(getRuntime(), snapshot));
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public IRubyObject each_pairInternal(ThreadContext context, Block block) {
RubyArray member = __member__();
for (int i = 0; i < values.length; i++) {
block.yield(context, getRuntime().newArrayNoCopy(new IRubyObject[]{member.eltInternal(i), values[i]}));
}
return this;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
public static IRubyObject gethostbyaddr(ThreadContext context, IRubyObject[] args) {
Ruby runtime = context.runtime;
IRubyObject[] ret = new IRubyObject[4];
ret[0] = runtime.newString(Sockaddr.addressFromString(runtime, args[0].convertToString().toString()).getCanonicalHostName());
ret[1] = runtime.newArray();
ret[2] = runtime.newFixnum(2); // AF_INET
ret[3] = args[0];
return runtime.newArrayNoCopy(ret);
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = "list", meta = true)
public static RubyArray list(IRubyObject recv) {
RubyThread[] activeThreads = recv.getRuntime().getThreadService().getActiveRubyThreads();
return recv.getRuntime().newArrayNoCopy(activeThreads);
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = "to_a")
@Override
public RubyArray to_a() {
return getRuntime().newArrayNoCopy(new IRubyObject[] { sec(), min(), hour(), mday(), month(),
year(), wday(), yday(), isdst(), zone() });
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = "to_a")
@Override
public RubyArray to_a() {
return getRuntime().newArrayNoCopy(new IRubyObject[] { sec(), min(), hour(), mday(), month(),
year(), wday(), yday(), isdst(), zone() });
}
内容来源于网络,如有侵权,请联系作者删除!