本文整理了Java中org.jruby.Ruby.getNil
方法的一些代码示例,展示了Ruby.getNil
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.getNil
方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:getNil
[英]Returns the "nil" singleton instance.
[中]返回“nil”单例实例。
代码示例来源:origin: bazelbuild/bazel
@JRubyMethod
public IRubyObject clear(ThreadContext context) {
table.clear();
return context.runtime.getNil();
}
代码示例来源:origin: bazelbuild/bazel
@JRubyMethod
public IRubyObject each(ThreadContext context, Block block) {
Ruby runtime = context.runtime;
for (Descriptors.EnumValueDescriptor enumValueDescriptor : descriptor.getValues()) {
block.yield(context, runtime.newArray(runtime.newSymbol(enumValueDescriptor.getName()),
runtime.newFixnum(enumValueDescriptor.getNumber())));
}
return runtime.getNil();
}
代码示例来源:origin: bazelbuild/bazel
switch (fieldType) {
case INT32:
return runtime.newFixnum((Integer) value);
case INT64:
return runtime.newFixnum((Long) value);
case UINT32:
return runtime.newFixnum(((Integer) value) & (-1l >>> 32));
case UINT64:
long ret = (Long) value;
return runtime.getNil();
代码示例来源:origin: org.jruby/jruby-complete
@JRubyMethod(rest = true)
public static IRubyObject java_implements(IRubyObject recv, IRubyObject[] args) {
// empty stub for now
return recv.getRuntime().getNil();
}
代码示例来源:origin: bazelbuild/bazel
@JRubyMethod(name = "method_missing", rest = true)
public IRubyObject methodMissing(ThreadContext context, IRubyObject[] args) {
if (args.length == 1) {
RubyDescriptor rubyDescriptor = (RubyDescriptor) getDescriptor(context, metaClass);
IRubyObject oneofDescriptor = rubyDescriptor.lookupOneof(context, args[0]);
if (oneofDescriptor.isNil()) {
if (!hasField(args[0])) {
return Helpers.invokeSuper(context, this, metaClass, "method_missing", args, Block.NULL_BLOCK);
}
return index(context, args[0]);
}
RubyOneofDescriptor rubyOneofDescriptor = (RubyOneofDescriptor) oneofDescriptor;
Descriptors.FieldDescriptor fieldDescriptor =
oneofCases.get(rubyOneofDescriptor.getOneofDescriptor());
if (fieldDescriptor == null)
return context.runtime.getNil();
return context.runtime.newSymbol(fieldDescriptor.getName());
} else {
// fieldName is RubySymbol
RubyString field = args[0].asString();
RubyString equalSign = context.runtime.newString(Utils.EQUAL_SIGN);
if (field.end_with_p(context, equalSign).isTrue()) {
field.chomp_bang(context, equalSign);
}
if (!hasField(field)) {
return Helpers.invokeSuper(context, this, metaClass, "method_missing", args, Block.NULL_BLOCK);
}
return indexSet(context, field, args[1]);
}
}
代码示例来源:origin: bazelbuild/bazel
@JRubyMethod(required = 4, optional = 1)
public IRubyObject map(ThreadContext context, IRubyObject[] args) {
Ruby runtime = context.runtime;
IRubyObject valueType = args[2];
IRubyObject number = args[3];
IRubyObject typeClass = args.length > 4 ? args[4] : context.runtime.getNil();
keyField.setName(context, runtime.newString("key"));
keyField.setLabel(context, RubySymbol.newSymbol(runtime, "optional"));
keyField.setNumber(context, runtime.newFixnum(1));
keyField.setType(context, keyType);
mapentryDesc.addField(context, keyField);
valueField.setName(context, runtime.newString("value"));
valueField.setLabel(context, RubySymbol.newSymbol(runtime, "optional"));
valueField.setNumber(context, runtime.newFixnum(2));
valueField.setType(context, valueType);
if (! typeClass.isNil()) valueField.setSubmsgName(context, typeClass);
mapentryDesc.addField(context, valueField);
return runtime.getNil();
代码示例来源:origin: org.jruby/jruby-complete
@Override
public IRubyObject get() {
IRubyObject errorInfo = runtime.getGlobalVariables().get("$!");
IRubyObject backtrace = errorInfo.isNil() ? runtime.getNil() : errorInfo.callMethod(errorInfo.getRuntime().getCurrentContext(), "backtrace");
//$@ returns nil if $!.backtrace is not an array
if (!(backtrace instanceof RubyArray)) {
backtrace = runtime.getNil();
}
return backtrace;
}
代码示例来源:origin: bazelbuild/bazel
fields.remove(oneofCase);
if (value.isNil()) {
oneofCases.remove(oneofDescriptor);
fields.remove(fieldDescriptor);
if (fieldType == Descriptors.FieldDescriptor.Type.MESSAGE) {
typeClass = ((RubyDescriptor) getDescriptorForField(context, fieldDescriptor)).msgclass(context);
if (value.isNil()){
addValue = false;
return context.runtime.getNil();
代码示例来源:origin: org.jruby/jruby-complete
@JRubyMethod(rest = true)
public static IRubyObject java_annotation(IRubyObject recv, IRubyObject[] args) {
// empty stub for now
return recv.getRuntime().getNil();
}
代码示例来源:origin: bazelbuild/bazel
@JRubyMethod(meta = true)
public static IRubyObject resolve(ThreadContext context, IRubyObject recv, IRubyObject name) {
RubyEnumDescriptor rubyEnumDescriptorescriptor = (RubyEnumDescriptor) getDescriptor(context, recv);
Descriptors.EnumDescriptor descriptor = rubyEnumDescriptorescriptor.getDescriptor();
Descriptors.EnumValueDescriptor value = descriptor.findValueByName(name.asJavaString());
if (value == null) return context.runtime.getNil();
return context.runtime.newFixnum(value.getNumber());
}
代码示例来源:origin: bazelbuild/bazel
@JRubyMethod
public IRubyObject lookup(ThreadContext context, IRubyObject name) {
IRubyObject descriptor = this.symtab.get(name);
if (descriptor == null) {
return context.runtime.getNil();
}
return descriptor;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = "strip!", compat = RUBY1_9)
public IRubyObject strip_bang19(ThreadContext context) {
modifyCheck();
IRubyObject left = lstrip_bang19(context);
IRubyObject right = rstrip_bang19(context);
return left.isNil() && right.isNil() ? context.runtime.getNil() : this;
}
代码示例来源:origin: org.jruby/jruby-core
@Override
public IRubyObject get() {
IRubyObject errorInfo = runtime.getGlobalVariables().get("$!");
IRubyObject backtrace = errorInfo.isNil() ? runtime.getNil() : errorInfo.callMethod(errorInfo.getRuntime().getCurrentContext(), "backtrace");
//$@ returns nil if $!.backtrace is not an array
if (!(backtrace instanceof RubyArray)) {
backtrace = runtime.getNil();
}
return backtrace;
}
代码示例来源:origin: bazelbuild/bazel
private IRubyObject wrapField(ThreadContext context, Descriptors.FieldDescriptor fieldDescriptor, Object value) {
if (value == null) {
return context.runtime.getNil();
}
Ruby runtime = context.runtime;
switch (fieldDescriptor.getType()) {
case INT32:
case INT64:
case UINT32:
case UINT64:
case FLOAT:
case DOUBLE:
case BOOL:
case BYTES:
case STRING:
return Utils.wrapPrimaryValue(context, fieldDescriptor.getType(), value);
case MESSAGE:
RubyClass typeClass = (RubyClass) ((RubyDescriptor) getDescriptorForField(context, fieldDescriptor)).msgclass(context);
RubyMessage msg = (RubyMessage) typeClass.newInstance(context, Block.NULL_BLOCK);
return msg.buildFrom(context, (DynamicMessage) value);
case ENUM:
Descriptors.EnumValueDescriptor enumValueDescriptor = (Descriptors.EnumValueDescriptor) value;
if (enumValueDescriptor.getIndex() == -1) { // UNKNOWN ENUM VALUE
return runtime.newFixnum(enumValueDescriptor.getNumber());
}
return runtime.newSymbol(enumValueDescriptor.getName());
default:
return runtime.newString(value.toString());
}
}
代码示例来源:origin: org.jruby/jruby-complete
/** rb_reg_match_pre
*
*/
public static IRubyObject match_pre(IRubyObject match) {
if (match.isNil()) return match;
RubyMatchData m = (RubyMatchData)match;
m.check();
Ruby runtime = m.getRuntime();
if (m.begin == -1) return runtime.getNil();
return m.str.makeShared(runtime, 0, m.begin).infectBy(m);
}
代码示例来源:origin: org.jruby/jruby-complete
@JRubyMethod(rest = true)
public static IRubyObject java_require(IRubyObject recv, IRubyObject[] args) {
// empty stub for now
return recv.getRuntime().getNil();
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = "<=>", required = 1, compat = CompatVersion.RUBY1_8)
@Override
public IRubyObject op_cmp(ThreadContext context, IRubyObject other) {
if (other instanceof RubyTime) {
return context.runtime.newFixnum(cmp((RubyTime) other));
}
return context.runtime.getNil();
}
代码示例来源:origin: bazelbuild/bazel
@JRubyMethod(required = 3, optional = 1)
public IRubyObject optional(ThreadContext context, IRubyObject[] args) {
Ruby runtime = context.runtime;
IRubyObject typeClass = runtime.getNil();
if (args.length > 3) typeClass = args[3];
msgdefAddField(context, "optional", args[0], args[1], args[2], typeClass);
return context.runtime.getNil();
}
代码示例来源:origin: org.jruby/jruby-complete
@JRubyMethod
public IRubyObject ungetbyte(IRubyObject b) {
if (b.isNil()) return b;
try {
bufferedStream.unread(b.convertToInteger().getIntValue());
position--;
} catch (IOException ioe) {
throw getRuntime().newIOErrorFromException(ioe);
}
return getRuntime().getNil();
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@Override
public IRubyObject get() {
IRubyObject errorInfo = runtime.getGlobalVariables().get("$!");
IRubyObject backtrace = errorInfo.isNil() ? runtime.getNil() : errorInfo.callMethod(errorInfo.getRuntime().getCurrentContext(), "backtrace");
//$@ returns nil if $!.backtrace is not an array
if (!(backtrace instanceof RubyArray)) {
backtrace = runtime.getNil();
}
return backtrace;
}
内容来源于网络,如有侵权,请联系作者删除!