本文整理了Java中org.jruby.Ruby.getStopIteration
方法的一些代码示例,展示了Ruby.getStopIteration
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.getStopIteration
方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:getStopIteration
暂无
代码示例来源:origin: org.jruby/jruby-complete
public static RubyStopIteration newInstance(ThreadContext context, IRubyObject result, String message) {
final Ruby runtime = context.runtime;
RubyClass StopIteration = runtime.getStopIteration();
final IRubyObject msg = message == null ? context.nil : runtime.newString(message);
RubyStopIteration instance = (RubyStopIteration)
StopIteration.newInstance(context, msg, Block.NULL_BLOCK);
instance.result = result;
return instance;
}
代码示例来源:origin: org.jruby/jruby-core
public static RubyStopIteration newInstance(ThreadContext context, IRubyObject result, String message) {
final Ruby runtime = context.runtime;
RubyClass StopIteration = runtime.getStopIteration();
final IRubyObject msg = message == null ? context.nil : runtime.newString(message);
RubyStopIteration instance = (RubyStopIteration)
StopIteration.newInstance(context, msg, Block.NULL_BLOCK);
instance.result = result;
return instance;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public static IRubyObject zipEnumNext(ThreadContext context, IRubyObject arg) {
Ruby runtime = context.runtime;
if (arg.isNil()) {
return context.nil;
} else {
try {
return arg.callMethod(context, "next");
} catch (RaiseException re) {
if (re.getException().getMetaClass() == runtime.getStopIteration()) {
return context.nil;
} else {
throw re;
}
}
}
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
public static IRubyObject zipEnumNext(ThreadContext context, IRubyObject arg) {
Ruby runtime = context.runtime;
if (arg.isNil()) {
return context.nil;
} else {
try {
return arg.callMethod(context, "next");
} catch (RaiseException re) {
if (re.getException().getMetaClass() == runtime.getStopIteration()) {
return context.nil;
} else {
throw re;
}
}
}
}
代码示例来源:origin: org.jruby/jruby-complete
public static void setup(Ruby runtime) {
RubyClass cQueue = runtime.getThread().defineClassUnder("Queue", runtime.getObject(), new ObjectAllocator() {
public IRubyObject allocate(Ruby runtime, RubyClass klass) {
return new Queue(runtime, klass);
}
});
cQueue.undefineMethod("initialize_copy");
cQueue.setReifiedClass(Queue.class);
cQueue.defineAnnotatedMethods(Queue.class);
runtime.getObject().setConstant("Queue", cQueue);
RubyClass cClosedQueueError = cQueue.defineClassUnder("ClosedQueueError", runtime.getStopIteration(), runtime.getStopIteration().getAllocator());
runtime.getObject().setConstant("ClosedQueueError", cClosedQueueError);
}
代码示例来源:origin: org.jruby/jruby-core
public static void setup(Ruby runtime) {
RubyClass cQueue = runtime.getThread().defineClassUnder("Queue", runtime.getObject(), new ObjectAllocator() {
public IRubyObject allocate(Ruby runtime, RubyClass klass) {
return new Queue(runtime, klass);
}
});
cQueue.undefineMethod("initialize_copy");
cQueue.setReifiedClass(Queue.class);
cQueue.defineAnnotatedMethods(Queue.class);
runtime.getObject().setConstant("Queue", cQueue);
RubyClass cClosedQueueError = cQueue.defineClassUnder("ClosedQueueError", runtime.getStopIteration(), runtime.getStopIteration().getAllocator());
runtime.getObject().setConstant("ClosedQueueError", cClosedQueueError);
}
代码示例来源:origin: org.jruby/jruby-complete
public static IRubyObject zipEnumNext(ThreadContext context, IRubyObject arg) {
if (arg.isNil()) return context.nil;
final Ruby runtime = context.runtime;
IRubyObject oldExc = runtime.getGlobalVariables().get("$!");
try {
return arg.callMethod(context, "next");
} catch (RaiseException re) {
if (re.getException().getMetaClass() == runtime.getStopIteration()) {
runtime.getGlobalVariables().set("$!", oldExc);
return context.nil;
}
throw re;
}
}
代码示例来源:origin: org.jruby/jruby-core
public static IRubyObject zipEnumNext(ThreadContext context, IRubyObject arg) {
if (arg.isNil()) return context.nil;
final Ruby runtime = context.runtime;
IRubyObject oldExc = runtime.getGlobalVariables().get("$!");
try {
return arg.callMethod(context, "next");
} catch (RaiseException re) {
if (re.getException().getMetaClass() == runtime.getStopIteration()) {
runtime.getGlobalVariables().set("$!", oldExc);
return context.nil;
}
throw re;
}
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = "loop", module = true, visibility = PRIVATE)
public static IRubyObject loop(ThreadContext context, IRubyObject recv, Block block) {
if (context.runtime.is1_9() && !block.isGiven()) {
return RubyEnumerator.enumeratorize(context.runtime, recv, "loop");
}
IRubyObject nil = context.runtime.getNil();
RubyClass stopIteration = context.runtime.getStopIteration();
try {
while (true) {
block.yieldSpecific(context);
context.pollThreadEvents();
}
} catch (RaiseException ex) {
if (!stopIteration.op_eqq(context, ex.getException()).isTrue()) {
throw ex;
}
}
return nil;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = "loop", module = true, visibility = PRIVATE)
public static IRubyObject loop(ThreadContext context, IRubyObject recv, Block block) {
if (context.runtime.is1_9() && !block.isGiven()) {
return RubyEnumerator.enumeratorize(context.runtime, recv, "loop");
}
IRubyObject nil = context.runtime.getNil();
RubyClass stopIteration = context.runtime.getStopIteration();
try {
while (true) {
block.yieldSpecific(context);
context.pollThreadEvents();
}
} catch (RaiseException ex) {
if (!stopIteration.op_eqq(context, ex.getException()).isTrue()) {
throw ex;
}
}
return nil;
}
代码示例来源:origin: org.jruby/jruby-complete
@JRubyMethod(name = "loop", module = true, visibility = PRIVATE)
public static IRubyObject loop(ThreadContext context, IRubyObject recv, Block block) {
if ( ! block.isGiven() ) {
return RubyEnumerator.enumeratorizeWithSize(context, recv, "loop", loopSizeFn(context));
}
final Ruby runtime = context.runtime;
IRubyObject oldExc = runtime.getGlobalVariables().get("$!"); // Save $!
try {
while (true) {
block.yieldSpecific(context);
context.pollThreadEvents();
}
}
catch (RaiseException ex) {
final RubyClass StopIteration = runtime.getStopIteration();
if ( StopIteration.isInstance(ex.getException()) ) {
runtime.getGlobalVariables().set("$!", oldExc); // Restore $!
return ex.getException().callMethod("result");
}
else {
throw ex;
}
}
}
代码示例来源:origin: org.jruby/jruby-core
@JRubyMethod(name = "loop", module = true, visibility = PRIVATE)
public static IRubyObject loop(ThreadContext context, IRubyObject recv, Block block) {
if ( ! block.isGiven() ) {
return RubyEnumerator.enumeratorizeWithSize(context, recv, "loop", loopSizeFn(context));
}
final Ruby runtime = context.runtime;
IRubyObject oldExc = runtime.getGlobalVariables().get("$!"); // Save $!
try {
while (true) {
block.yieldSpecific(context);
context.pollThreadEvents();
}
}
catch (RaiseException ex) {
final RubyClass StopIteration = runtime.getStopIteration();
if ( StopIteration.isInstance(ex.getException()) ) {
runtime.getGlobalVariables().set("$!", oldExc); // Restore $!
return ex.getException().callMethod("result");
}
else {
throw ex;
}
}
}
内容来源于网络,如有侵权,请联系作者删除!