FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Deprecate RubyHash constructors for 10.1 abstraction by headius · Pull Request #9474 · jruby/jruby · GitHub

/ jruby Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .java  (10) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyEnumerable.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1981,7 +1981,7 @@ public static IRubyObject zipEnumNext(ThreadContext context, IRubyObject arg) {
public static IRubyObject group_by(ThreadContext context, IRubyObject self, final Block block) {
if (!block.isGiven()) return enumeratorizeWithSize(context, self, "group_by", RubyEnumerable::size);

final RubyHash result = new RubyHash(context.runtime);
final RubyHash result = RubyHash.newHash(context.runtime);

callEach(context, eachSite(context), self, Signature.OPTIONAL, (ctx, largs, blk) -> {
IRubyObject larg = packEnumValues(ctx, largs);
Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/org/jruby/RubyGlobal.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,7 @@ public static class StringOnlyRubyHash extends RubyHash {
// the op_aset to also update the real ENV map via setenv/unsetenv.
private final boolean updateRealENV;

@SuppressWarnings(value = {"deprecation", "removal"})
public StringOnlyRubyHash(Ruby runtime, Map<RubyString, RubyString> valueMap, IRubyObject defaultValue, boolean updateRealENV) {
super(runtime, valueMap, defaultValue);
this.updateRealENV = updateRealENV;
Expand Down
25 changes: 25 additions & 0 deletions core/src/main/java/org/jruby/RubyHash.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public class RubyHash extends RubyObject implements Map {
public static final int COMPARE_BY_IDENTITY_F = ObjectFlags.COMPARE_BY_IDENTITY_F;
public static final int RUBY2_KEYWORD_F = ObjectFlags.RUBY2_KEYWORD_F;

@SuppressWarnings("removal")
public static RubyClass createHashClass(ThreadContext context, RubyClass Object, RubyModule Enumerable) {
return defineClass(context, "Hash", Object, RubyHash::new).
reifiedClass(RubyHash.class).
Expand Down Expand Up @@ -212,6 +213,7 @@ public static final RubyHash newHash(Ruby runtime) {
/** rb_hash_new
*
*/
@SuppressWarnings("deprecation")
public static final RubyHash newSmallHash(Ruby runtime) {
return new RubyHash(runtime, 1);
}
Expand All @@ -226,6 +228,23 @@ public static RubyHash newHash(Ruby runtime, IRubyObject key, IRubyObject value)
return kwargs;
}

@SuppressWarnings("deprecation")
public static RubyHash newHash(Ruby runtime, IRubyObject defaultValue) {
return new RubyHash(runtime, defaultValue);
}

@SuppressWarnings("deprecation")
public static RubyHash newHash(Ruby runtime, int buckets) {
return new RubyHash(runtime, buckets);
}

@SuppressWarnings("deprecation")
public static RubyHash newHash(Ruby runtime, IRubyObject defaultValue, int buckets) {
RubyHash hash = new RubyHash(runtime, buckets, true);
hash.ifNone = defaultValue;
return hash;
}

/** rb_hash_new
*
*/
Expand Down Expand Up @@ -256,26 +275,31 @@ private static void copyFrom(RubyHash self, RubyHash other, boolean identity) {
self.setComparedByIdentity(identity);
}

@Deprecated(since = "10.0.6.0", forRemoval = true)
public RubyHash(Ruby runtime, RubyClass klass) {
super(runtime, klass);
this.ifNone = UNDEF;
allocFirst();
}

@Deprecated(since = "10.0.6.0", forRemoval = true)
public RubyHash(Ruby runtime, int buckets) {
this(runtime, UNDEF, buckets);
}

@Deprecated(since = "10.0.6.0", forRemoval = true)
public RubyHash(Ruby runtime) {
this(runtime, UNDEF);
}

@Deprecated(since = "10.0.6.0", forRemoval = true)
public RubyHash(Ruby runtime, IRubyObject defaultValue) {
super(runtime, runtime.getHash());
this.ifNone = defaultValue;
allocFirst();
}

@Deprecated(since = "10.0.6.0", forRemoval = true)
public RubyHash(Ruby runtime, IRubyObject defaultValue, int buckets) {
this(runtime, buckets, true);
this.ifNone = defaultValue;
Expand All @@ -301,6 +325,7 @@ protected RubyHash(Ruby runtime, RubyClass metaClass, IRubyObject defaultValue,
}

// TODO should this be deprecated ? (to be efficient, internals should deal with RubyHash directly)
@Deprecated(since = "10.0.3.0", forRemoval = true)
public RubyHash(Ruby runtime, Map valueMap, IRubyObject defaultValue) {
super(runtime, runtime.getHash());
this.ifNone = defaultValue;
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/java/org/jruby/api/Create.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public static RubyArray<?> newArray(ThreadContext context, Collection<? extends
*/
// MRI: rb_hash_new
public static RubyHash newHash(ThreadContext context) {
return new RubyHash(context.runtime);
return RubyHash.newHash(context.runtime);
}

/**
Expand Down Expand Up @@ -224,7 +224,7 @@ public static RubyHash newEmptyHash(ThreadContext context) {
*/
// MRI: rb_hash_new
public static RubyHash newSmallHash(ThreadContext context) {
return new RubyHash(context.runtime, 1);
return RubyHash.newHash(context.runtime, 1);
}

/**
Expand All @@ -237,7 +237,7 @@ public static RubyHash newSmallHash(ThreadContext context) {
*/
// MRI: rb_hash_new
public static RubyHash newSmallHash(ThreadContext context, IRubyObject key, IRubyObject value) {
RubyHash hash = new RubyHash(context.runtime, 1);
RubyHash hash = RubyHash.newHash(context.runtime, 1);
hash.fastASetSmall(context.runtime, key, value, true);
return hash;
}
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public void load(Ruby runtime, boolean wrap) {
defineConstant(context, "DESTDIR", destDir); // DESTDIR on make install.

// The hash configurations stored.
final RubyHash CONFIG = new RubyHash(runtime, 48);
final RubyHash CONFIG = RubyHash.newHash(runtime, 48);

CONFIG.fastASetCheckString(runtime, newString(context, "DESTDIR"), destDir);

Expand Down Expand Up @@ -392,7 +392,7 @@ public void load(Ruby runtime, boolean wrap) {


// TODO CONFIG and MAKEFILE_CONFIG seems to be the same Hash in Ruby 2.5
final RubyHash mkmfHash = new RubyHash(runtime, 64);
final RubyHash mkmfHash = RubyHash.newHash(runtime, 64);

setConfig(context, mkmfHash, "libdir", vendorDirGeneral);
setConfig(context, mkmfHash, "arch", "java");
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private static void defineLexStateConstants(ThreadContext context, RubyClass rip

// Creates mapping table of token to arity for on_* method calls for the scanner support
private static RubyHash createScannerEventTable(ThreadContext context) {
RubyHash hash = new RubyHash(context.runtime);
RubyHash hash = RubyHash.newHash(context.runtime);

hash.fastASet(asSymbol(context, "CHAR"), asFixnum(context, 1));
hash.fastASet(asSymbol(context, "__end__"), asFixnum(context, 1));
Expand Down Expand Up @@ -131,7 +131,7 @@ private static RubyHash createScannerEventTable(ThreadContext context) {

// Creates mapping table of token to arity for on_* method calls for the parser support
private static RubyHash createParserEventTable(ThreadContext context) {
RubyHash hash = new RubyHash(context.runtime);
RubyHash hash = RubyHash.newHash(context.runtime);

hash.fastASet(asSymbol(context, "BEGIN"), asFixnum(context, 1));
hash.fastASet(asSymbol(context, "END"), asFixnum(context, 1));
Expand Down
9 changes: 5 additions & 4 deletions core/src/main/java/org/jruby/ext/set/RubySet.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,15 @@ private RubySet(Ruby runtime, RubyHash hash) {
// ... this is important with Rails using Sprockets at its marshalling Set instances

final void allocHash(final ThreadContext context) {
setHash(new RubyHash(context.runtime, context.fals));
setHash(RubyHash.newHash(context.runtime, context.fals));
}

final void allocHash(final Ruby runtime) {
setHash(new RubyHash(runtime, runtime.getFalse()));
setHash(RubyHash.newHash(runtime, runtime.getFalse()));
}

final void allocHash(final ThreadContext context, final int size) {
setHash(new RubyHash(context.runtime, context.fals, size));
setHash(RubyHash.newHash(context.runtime, context.fals, size));
}

final void setHash(final RubyHash hash) {
Expand Down Expand Up @@ -918,7 +918,7 @@ public RubyFixnum hash(ThreadContext context) { // @hash.hash
public IRubyObject classify(ThreadContext context, final Block block) {
if (!block.isGiven()) return enumeratorizeWithSize(context, this, "classify", RubySet::size);

final RubyHash h = new RubyHash(context.runtime, size());
final RubyHash h = RubyHash.newHash(context.runtime, size());

for ( IRubyObject i : elementsOrdered() ) {
final IRubyObject key = block.yield(context, i);
Expand Down Expand Up @@ -1036,6 +1036,7 @@ static DivideTSortHash newInstance(final ThreadContext context) {
return new DivideTSortHash(context.runtime, klass);
}

@SuppressWarnings("removal")
DivideTSortHash(final Ruby runtime, final RubyClass metaClass) {
super(runtime, metaClass);
}
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static CallSite kwargsHash(MethodHandles.Lookup lookup, String name, Meth

public static RubyHash hash(ThreadContext context, IRubyObject[] pairs) {
Ruby runtime = context.runtime;
RubyHash hash = new RubyHash(runtime, pairs.length / 2 + 1);
RubyHash hash = RubyHash.newHash(runtime, pairs.length / 2 + 1);
for (int i = 0; i < pairs.length;) {
hash.fastASetCheckString(runtime, pairs[i++], pairs[i++]);
}
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ public IRubyObject shift(ThreadContext context) {
@Override
public RubyHash to_hash(ThreadContext context) {
final Ruby runtime = context.runtime;
final RubyHash hash = new RubyHash(runtime);
final RubyHash hash = RubyHash.newHash(runtime);
@SuppressWarnings("unchecked")
Set<Map.Entry> entries = mapDelegate().entrySet();
for ( Map.Entry entry : entries ) {
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public void testRestructuring() throws Exception {
}

public void testGet() {
RubyHash rubyHash = new RubyHash(Ruby.getGlobalRuntime());
RubyHash rubyHash = RubyHash.newHash(Ruby.getGlobalRuntime());
assertEquals(null, rubyHash.get("Non matching key"));
}

Expand Down
Loading

Back | FazBrowse Home | New Git URL