本文整理了Java中org.jruby.RubyHash.visitAll
方法的一些代码示例,展示了RubyHash.visitAll
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RubyHash.visitAll
方法的具体详情如下:
包路径:org.jruby.RubyHash
类名称:RubyHash
方法名:visitAll
暂无
代码示例来源:origin: bazelbuild/bazel
protected RubyMap mergeIntoSelf(final ThreadContext context, IRubyObject hashmap) {
if (hashmap instanceof RubyHash) {
((RubyHash) hashmap).visitAll(new RubyHash.Visitor() {
@Override
public void visit(IRubyObject key, IRubyObject val) {
indexSet(context, key, val);
}
});
} else if (hashmap instanceof RubyMap) {
RubyMap other = (RubyMap) hashmap;
if (!typeCompatible(other)) {
throw context.runtime.newTypeError("Attempt to merge Map with mismatching types");
}
} else {
throw context.runtime.newTypeError("Unknown type merging into Map");
}
return this;
}
代码示例来源:origin: bazelbuild/bazel
hash.visitAll(new RubyHash.Visitor() {
@Override
public void visit(IRubyObject key, IRubyObject value) {
代码示例来源:origin: org.jruby/jruby-complete
private boolean hasValue(ThreadContext context, IRubyObject expected) {
try {
visitAll(context, FoundIfEqualVisitor, expected);
return false;
} catch (Found found) {
return true;
}
}
代码示例来源:origin: org.jruby/jruby-core
private boolean hasValue(ThreadContext context, IRubyObject expected) {
try {
visitAll(context, FoundIfEqualVisitor, expected);
return false;
} catch (Found found) {
return true;
}
}
代码示例来源:origin: org.jruby/jruby-complete
private IRubyObject internalIndex(final ThreadContext context, final IRubyObject expected) {
try {
visitAll(context, FoundKeyIfEqual, expected);
return null;
} catch (FoundKey found) {
return found.key;
}
}
代码示例来源:origin: org.jruby/jruby-complete
public static void checkForExtraUnwantedKeywordArgs(ThreadContext context, final StaticScope scope, RubyHash keywordArgs) {
// we do an inexpensive non-gathering scan first to see if there's a bad keyword
try {
keywordArgs.visitAll(context, CheckUnwantedKeywordsVisitor, scope);
} catch (InvalidKeyException ike) {
// there's a bad keyword; perform more expensive scan to gather all bad names
GatherUnwantedKeywordsVisitor visitor = new GatherUnwantedKeywordsVisitor();
keywordArgs.visitAll(context, visitor, scope);
visitor.raiseIfError(context);
}
}
代码示例来源:origin: org.jruby/jruby-core
public static void checkForExtraUnwantedKeywordArgs(ThreadContext context, final StaticScope scope, RubyHash keywordArgs) {
// we do an inexpensive non-gathering scan first to see if there's a bad keyword
try {
keywordArgs.visitAll(context, CheckUnwantedKeywordsVisitor, scope);
} catch (InvalidKeyException ike) {
// there's a bad keyword; perform more expensive scan to gather all bad names
GatherUnwantedKeywordsVisitor visitor = new GatherUnwantedKeywordsVisitor();
keywordArgs.visitAll(context, visitor, scope);
visitor.raiseIfError(context);
}
}
代码示例来源:origin: org.jruby/jruby-core
@JRubyMethod(name = "assoc")
public IRubyObject assoc(final ThreadContext context, final IRubyObject obj) {
try {
visitAll(context, FoundPairIfEqualKeyVisitor, obj);
return context.nil;
} catch (FoundPair found) {
return context.runtime.newArray(found.key, found.value);
}
}
代码示例来源:origin: org.jruby/jruby-core
@JRubyMethod(name = "rassoc")
public IRubyObject rassoc(final ThreadContext context, final IRubyObject obj) {
try {
visitAll(context, FoundPairIfEqualValueVisitor, obj);
return context.nil;
} catch (FoundPair found) {
return context.runtime.newArray(found.key, found.value);
}
}
代码示例来源:origin: org.jruby/jruby-complete
private <T> void iteratorVisitAll(ThreadContext context, VisitorWithState<T> visitor, T state) {
try {
iteratorEntry();
visitAll(context, visitor, state);
} finally {
iteratorExit();
}
}
代码示例来源:origin: org.jruby/jruby-complete
@JRubyMethod(name = "rassoc")
public IRubyObject rassoc(final ThreadContext context, final IRubyObject obj) {
try {
visitAll(context, FoundPairIfEqualValueVisitor, obj);
return context.nil;
} catch (FoundPair found) {
return context.runtime.newArray(found.key, found.value);
}
}
代码示例来源:origin: org.jruby/jruby-complete
@JRubyMethod(name = "assoc")
public IRubyObject assoc(final ThreadContext context, final IRubyObject obj) {
try {
visitAll(context, FoundPairIfEqualKeyVisitor, obj);
return context.nil;
} catch (FoundPair found) {
return context.runtime.newArray(found.key, found.value);
}
}
代码示例来源:origin: org.jruby/jruby-complete
/** rb_hash_invert
*
*/
@JRubyMethod(name = "invert")
public RubyHash invert(final ThreadContext context) {
final RubyHash result = newHash(getRuntime());
visitAll(context, InvertVisitor, result);
return result;
}
代码示例来源:origin: org.jruby/jruby-complete
/** inspect_hash
*
*/
private IRubyObject inspectHash(final ThreadContext context) {
final RubyString str = RubyString.newStringLight(context.runtime, DEFAULT_INSPECT_STR_SIZE, USASCIIEncoding.INSTANCE);
str.infectBy(this);
str.cat((byte)'{');
visitAll(context, InspectVisitor, str);
str.cat((byte)'}');
return str;
}
代码示例来源:origin: org.jruby/jruby-complete
@JRubyMethod(name = "transform_keys")
public IRubyObject transform_keys(final ThreadContext context, final Block block) {
if (block.isGiven()) {
RubyHash result = newHash(context.runtime);
visitAll(context, new TransformKeysVisitor(block), result);
return result;
}
return enumeratorizeWithSize(context, this, "transform_keys", enumSizeFn());
}
代码示例来源:origin: org.jruby/jruby-complete
/** rb_hash_update
*
*/
@JRubyMethod(name = {"merge!", "update"}, required = 1)
public RubyHash merge_bang(ThreadContext context, IRubyObject other, Block block) {
modify();
final RubyHash otherHash = other.convertToHash();
if (otherHash.empty_p().isTrue()) return this;
otherHash.visitAll(context, new MergeVisitor(this), block);
return this;
}
代码示例来源:origin: org.jruby/jruby-complete
@JRubyMethod(name = "uniq")
public IRubyObject uniq19(ThreadContext context, Block block) {
if (!block.isGiven()) return uniq(context);
RubyHash hash = makeHash(context, block);
RubyArray result = new RubyArray(context.runtime, getMetaClass(), hash.size());
hash.visitAll(context, RubyHash.StoreValueVisitor, result);
return result;
}
代码示例来源:origin: org.jruby/jruby-core
@JRubyMethod(name = "uniq")
public IRubyObject uniq19(ThreadContext context, Block block) {
if (!block.isGiven()) return uniq(context);
RubyHash hash = makeHash(context, block);
RubyArray result = new RubyArray(context.runtime, getMetaClass(), hash.size());
hash.visitAll(context, RubyHash.StoreValueVisitor, result);
return result;
}
代码示例来源:origin: org.jruby/jruby-core
@JIT @Interp
public static IRubyObject mergeKeywordArguments(ThreadContext context, IRubyObject restKwarg, IRubyObject explicitKwarg) {
RubyHash hash = (RubyHash) TypeConverter.checkHashType(context.runtime, restKwarg).dup();
hash.modify();
final RubyHash otherHash = explicitKwarg.convertToHash();
if (otherHash.empty_p().isTrue()) return hash;
otherHash.visitAll(context, new KwargMergeVisitor(hash), Block.NULL_BLOCK);
return hash;
}
代码示例来源:origin: org.jruby/jruby-complete
@JIT @Interp
public static IRubyObject mergeKeywordArguments(ThreadContext context, IRubyObject restKwarg, IRubyObject explicitKwarg) {
RubyHash hash = (RubyHash) TypeConverter.checkHashType(context.runtime, restKwarg).dup();
hash.modify();
final RubyHash otherHash = explicitKwarg.convertToHash();
if (otherHash.empty_p().isTrue()) return hash;
otherHash.visitAll(context, new KwargMergeVisitor(hash), Block.NULL_BLOCK);
return hash;
}
内容来源于网络,如有侵权,请联系作者删除!