Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 5e68ee496b0a
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 98cf3d880d87
Choose a head ref
  • 4 commits
  • 3 files changed
  • 1 contributor

Commits on Jul 20, 2017

  1. Copy the full SHA
    d15def1 View commit details
  2. Copy the full SHA
    171d2e2 View commit details
  3. Copy the full SHA
    d612739 View commit details
  4. Fix Range marshaling.

    * Use begini and endi names from MRI for stream compatibility.
    * Error if any marshaled pieces can't be found in the stream.
    headius committed Jul 20, 2017
    Copy the full SHA
    98cf3d8 View commit details
Showing with 24 additions and 8 deletions.
  1. +5 −2 core/src/main/java/org/jruby/RubyArray.java
  2. +18 −5 core/src/main/java/org/jruby/RubyRange.java
  3. +1 −1 core/src/main/ruby/jruby/kernel/proc.rb
7 changes: 5 additions & 2 deletions core/src/main/java/org/jruby/RubyArray.java
Original file line number Diff line number Diff line change
@@ -4645,8 +4645,11 @@ public RubyString pack(ThreadContext context, IRubyObject obj, IRubyObject maybe
RubyString str;

try {
IRubyObject buffer = opts.convertToHash().fastARef(runtime.newSymbol("buffer"));
if (buffer != null) {
IRubyObject buffer = ArgsUtil.extractKeywordArg(context, "buffer", opts);
if (!buffer.isNil() && !(buffer instanceof RubyString)) {
throw runtime.newTypeError("buffer must be String, not " + buffer.getType().getName());
}
if (buffer.isNil()) {
str = buffer.convertToString();
} else {
str = RubyString.newString(runtime, "");
23 changes: 18 additions & 5 deletions core/src/main/java/org/jruby/RubyRange.java
Original file line number Diff line number Diff line change
@@ -273,6 +273,7 @@ public IRubyObject initialize(ThreadContext context, IRubyObject[] args, Block u
if (this.isInited) {
throw context.runtime.newNameError("`initialize' called twice", "initialize");
}
checkFrozen();
init(context, args[0], args[1], args.length > 2 && args[2].isTrue());
return context.nil;
}
@@ -878,8 +879,8 @@ public void marshalTo(Ruby runtime, Object obj, RubyClass type,
marshalStream.registerLinkTarget(range);
List<Variable<Object>> attrs = range.getVariableList();

attrs.add(new VariableEntry<Object>("begin", range.begin));
attrs.add(new VariableEntry<Object>("end", range.end));
attrs.add(new VariableEntry<Object>("begini", range.begin));
attrs.add(new VariableEntry<Object>("endi", range.end));
attrs.add(new VariableEntry<Object>("excl", range.isExclusive ? runtime.getTrue() : runtime.getFalse()));

marshalStream.dumpVariables(attrs);
@@ -895,9 +896,21 @@ public Object unmarshalFrom(Ruby runtime, RubyClass type,
// FIXME: Maybe we can just gank these off the line directly?
unmarshalStream.defaultVariablesUnmarshal(range);

range.begin = (IRubyObject) range.removeInternalVariable("begin");
range.end = (IRubyObject) range.removeInternalVariable("end");
range.isExclusive = ((IRubyObject) range.removeInternalVariable("excl")).isTrue();
IRubyObject begin = (IRubyObject) range.removeInternalVariable("begini");
IRubyObject end = (IRubyObject) range.removeInternalVariable("endi");
IRubyObject excl = (IRubyObject) range.removeInternalVariable("excl");

// try old names as well
if (begin == null) begin = (IRubyObject) range.removeInternalVariable("begin");
if (end == null) end = (IRubyObject) range.removeInternalVariable("end");

if (begin == null || end == null || excl == null) {
throw runtime.newArgumentError("bad value for range");
}

range.begin = begin;
range.end = end;
range.isExclusive = excl.isTrue();

return range;
}
2 changes: 1 addition & 1 deletion core/src/main/ruby/jruby/kernel/proc.rb
Original file line number Diff line number Diff line change
@@ -65,7 +65,7 @@ def self.__make_curry_proc__(proc, passed, arity)
end
__make_curry_proc__(proc, my_passed, arity)
else
proc.call(*my_passed)
proc.call(*my_passed, &passed_proc)
end
end