Skip to content

Commit

Permalink
Merge pull request jruby#8298 from enebo/api_changes
Browse files Browse the repository at this point in the history
Api changes
  • Loading branch information
enebo authored Jul 15, 2024
2 parents 55b7eb3 + 9a1e22e commit 88dc147
Show file tree
Hide file tree
Showing 52 changed files with 383 additions and 334 deletions.
3 changes: 2 additions & 1 deletion core/src/main/java/org/jruby/RubyArgsFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import static org.jruby.RubyArgsFile.Next.Stream;
import static org.jruby.RubyEnumerator.enumeratorize;
import static org.jruby.anno.FrameField.LASTLINE;
import static org.jruby.api.Convert.numericToLong;
import static org.jruby.runtime.ThreadContext.CALL_KEYWORD;
import static org.jruby.runtime.ThreadContext.resetCallInfo;
import static org.jruby.runtime.Visibility.PRIVATE;
Expand Down Expand Up @@ -872,7 +873,7 @@ public static IRubyObject read(ThreadContext context, IRubyObject recv, IRubyObj
str = length = context.nil;
}

if (length != context.nil) len = RubyNumeric.num2long(length);
if (length != context.nil) len = numericToLong(context, length);

if (str != context.nil) {
str = str.convertToString();
Expand Down
10 changes: 5 additions & 5 deletions core/src/main/java/org/jruby/RubyArithmeticSequence.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
import static org.jruby.RubyNumeric.dbl2num;
import static org.jruby.RubyNumeric.int2fix;
import static org.jruby.RubyNumeric.num2dbl;
import static org.jruby.RubyNumeric.num2long;

import static org.jruby.api.Convert.numericToLong;
import static org.jruby.runtime.Helpers.hashEnd;
import static org.jruby.runtime.Helpers.hashStart;
import static org.jruby.runtime.Helpers.murmurCombine;
Expand Down Expand Up @@ -210,7 +210,7 @@ public IRubyObject first(ThreadContext context, IRubyObject num) {
}

/* TODO: the following code should be extracted as arith_seq_take */
n = num2long(num);
n = numericToLong(context, num);

if (n < 0) {
throw runtime.newArgumentError("attempt to take negative size");
Expand Down Expand Up @@ -511,7 +511,7 @@ public IRubyObject last(ThreadContext context, IRubyObject num) {
nv = len;
}

n = num2long(nv);
n = numericToLong(context, nv);
if (n < 0) {
throw runtime.newArgumentError("negative array size");
}
Expand Down Expand Up @@ -599,15 +599,15 @@ private static FiberSites fiberSites(ThreadContext context) {

@JRubyMethod(name = "each_cons")
public IRubyObject each_cons(ThreadContext context, IRubyObject arg, final Block block) {
int size = (int) RubyNumeric.num2long(arg);
int size = (int) numericToLong(context, arg);
if (size <= 0) throw context.runtime.newArgumentError("invalid size");
return block.isGiven() ? RubyEnumerable.each_consCommon(context, this, size, block) :
enumeratorize(context.runtime, this, "each_cons", arg);
}

@JRubyMethod(name = "each_slice")
public IRubyObject each_slice(ThreadContext context, IRubyObject arg, final Block block) {
int size = (int) RubyNumeric.num2long(arg);
int size = (int) numericToLong(context, arg);
if (size <= 0) throw context.runtime.newArgumentError("invalid size");

return block.isGiven() ? RubyEnumerable.each_sliceCommon(context, this, size, block) :
Expand Down
Loading

0 comments on commit 88dc147

Please sign in to comment.