Skip to content

Commit

Permalink
Showing 58 changed files with 721 additions and 255 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -100,7 +100,7 @@ branches:
- ruby-2.3

script: tool/travis_runner.sh
install: travis_retry ./mvnw -Pbootstrap clean install -Dinvoker.skip -Dmaven.test.skip
install: travis_retry ./mvnw -Pbootstrap clean install -B -Dinvoker.skip -Dmaven.test.skip

notifications:
irc:
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9.0.5.0-SNAPSHOT
9.0.5.0
2 changes: 1 addition & 1 deletion core/pom.rb
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@

jar 'org.jruby.joni:joni:2.1.9'
jar 'org.jruby.extras:bytelist:1.0.13'
jar 'org.jruby.jcodings:jcodings:1.0.17-SNAPSHOT'
jar 'org.jruby.jcodings:jcodings:1.0.17'
jar 'org.jruby:dirgra:0.3'

jar 'com.headius:invokebinder:1.7'
4 changes: 2 additions & 2 deletions core/pom.xml
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ DO NOT MODIFIY - GENERATED CODE
<parent>
<groupId>org.jruby</groupId>
<artifactId>jruby-parent</artifactId>
<version>9.0.5.0-SNAPSHOT</version>
<version>9.0.5.0</version>
</parent>
<artifactId>jruby-core</artifactId>
<name>JRuby Core</name>
@@ -184,7 +184,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>org.jruby.jcodings</groupId>
<artifactId>jcodings</artifactId>
<version>1.0.17-SNAPSHOT</version>
<version>1.0.17</version>
</dependency>
<dependency>
<groupId>org.jruby</groupId>
161 changes: 88 additions & 73 deletions core/src/main/java/org/jruby/RubyIO.java
Original file line number Diff line number Diff line change
@@ -4049,99 +4049,114 @@ public static IRubyObject copy_stream(ThreadContext context, IRubyObject recv, I
}
}

if (arg1 instanceof RubyString) {
io1 = (RubyIO) RubyFile.open(context, runtime.getFile(), new IRubyObject[] {arg1}, Block.NULL_BLOCK);
} else if (arg1 instanceof RubyIO) {
io1 = (RubyIO) arg1;
} else if (arg1.respondsTo("to_path")) {
RubyString path = (RubyString) TypeConverter.convertToType19(arg1, runtime.getString(), "to_path");
io1 = (RubyIO) RubyFile.open(context, runtime.getFile(), new IRubyObject[] {path}, Block.NULL_BLOCK);
} else if (arg1.respondsTo("read")) {
if (length == null) {
read = arg1.callMethod(context, "read", runtime.getNil()).convertToString();
} else {
read = arg1.callMethod(context, "read", length).convertToString();
}
} else {
throw runtime.newArgumentError("Should be String or IO");
}

if (arg2 instanceof RubyString) {
io2 = (RubyIO) RubyFile.open(context, runtime.getFile(), new IRubyObject[] {arg2, runtime.newString("w")}, Block.NULL_BLOCK);
} else if (arg2 instanceof RubyIO) {
io2 = (RubyIO) arg2;
} else if (arg2.respondsTo("to_path")) {
RubyString path = (RubyString) TypeConverter.convertToType19(arg2, runtime.getString(), "to_path");
io2 = (RubyIO) RubyFile.open(context, runtime.getFile(), new IRubyObject[] {path, runtime.newString("w")}, Block.NULL_BLOCK);
} else if (arg2.respondsTo("write")) {
if (read == null) {
boolean close1 = false;
boolean close2 = false;
try {
if (arg1 instanceof RubyString) {
io1 = (RubyIO) RubyFile.open(context, runtime.getFile(), new IRubyObject[]{arg1}, Block.NULL_BLOCK);
close1 = true;
} else if (arg1 instanceof RubyIO) {
io1 = (RubyIO) arg1;
} else if (arg1.respondsTo("to_path")) {
RubyString path = (RubyString) TypeConverter.convertToType19(arg1, runtime.getString(), "to_path");
io1 = (RubyIO) RubyFile.open(context, runtime.getFile(), new IRubyObject[]{path}, Block.NULL_BLOCK);
close1 = true;
} else if (arg1.respondsTo("read")) {
if (length == null) {
read = io1.read(context, runtime.getNil()).convertToString();
read = arg1.callMethod(context, "read", runtime.getNil()).convertToString();
} else {
read = io1.read(context, length).convertToString();
read = arg1.callMethod(context, "read", length).convertToString();
}
} else {
throw runtime.newArgumentError("Should be String or IO");
}
return arg2.callMethod(context, "write", read);
} else {
throw runtime.newArgumentError("Should be String or IO");
}

if (io1 == null) {
IRubyObject size = io2.write(context, read);
io2.flush(context);
return size;
}
if (arg2 instanceof RubyString) {
io2 = (RubyIO) RubyFile.open(context, runtime.getFile(), new IRubyObject[]{arg2, runtime.newString("w")}, Block.NULL_BLOCK);
close2 = true;
} else if (arg2 instanceof RubyIO) {
io2 = (RubyIO) arg2;
} else if (arg2.respondsTo("to_path")) {
RubyString path = (RubyString) TypeConverter.convertToType19(arg2, runtime.getString(), "to_path");
io2 = (RubyIO) RubyFile.open(context, runtime.getFile(), new IRubyObject[]{path, runtime.newString("w")}, Block.NULL_BLOCK);
close2 = true;
} else if (arg2.respondsTo("write")) {
if (read == null) {
if (length == null) {
read = io1.read(context, runtime.getNil()).convertToString();
} else {
read = io1.read(context, length).convertToString();
}
}
return arg2.callMethod(context, "write", read);
} else {
throw runtime.newArgumentError("Should be String or IO");
}

io2 = io2.GetWriteIO();
if (io1 == null) {
IRubyObject size = io2.write(context, read);
io2.flush(context);
return size;
}

if (!io1.openFile.isReadable()) throw runtime.newIOError("from IO is not readable");
if (!io2.openFile.isWritable()) throw runtime.newIOError("to IO is not writable");
io2 = io2.GetWriteIO();

// attempt to preserve position of original
OpenFile fptr = io1.getOpenFileChecked();
if (!io1.openFile.isReadable()) throw runtime.newIOError("from IO is not readable");
if (!io2.openFile.isWritable()) throw runtime.newIOError("to IO is not writable");

boolean locked = fptr.lock();
try {
long pos = fptr.tell(context);
long size = 0;
// attempt to preserve position of original
OpenFile fptr = io1.getOpenFileChecked();

boolean locked = fptr.lock();
try {
if (io1.openFile.fileChannel() == null) {
long remaining = length == null ? -1 : length.getLongValue();
long position = offset == null ? -1 : offset.getLongValue();
if (io2.openFile.fileChannel() == null) {
ReadableByteChannel from = io1.openFile.readChannel();
WritableByteChannel to = io2.openFile.writeChannel();
long pos = fptr.tell(context);
long size = 0;

size = transfer(context, from, to, remaining, position);
try {
if (io1.openFile.fileChannel() == null) {
long remaining = length == null ? -1 : length.getLongValue();
long position = offset == null ? -1 : offset.getLongValue();
if (io2.openFile.fileChannel() == null) {
ReadableByteChannel from = io1.openFile.readChannel();
WritableByteChannel to = io2.openFile.writeChannel();

size = transfer(context, from, to, remaining, position);
} else {
ReadableByteChannel from = io1.openFile.readChannel();
FileChannel to = io2.openFile.fileChannel();

size = transfer(context, from, to, remaining, position);
}
} else {
ReadableByteChannel from = io1.openFile.readChannel();
FileChannel to = io2.openFile.fileChannel();
FileChannel from = io1.openFile.fileChannel();
WritableByteChannel to = io2.openFile.writeChannel();
long remaining = length == null ? from.size() : length.getLongValue();
long position = offset == null ? from.position() : offset.getLongValue();

size = transfer(context, from, to, remaining, position);
size = transfer(from, to, remaining, position);
}
} else {
FileChannel from = io1.openFile.fileChannel();
WritableByteChannel to = io2.openFile.writeChannel();
long remaining = length == null ? from.size() : length.getLongValue();
long position = offset == null ? from.position() : offset.getLongValue();

size = transfer(from, to, remaining, position);
return context.runtime.newFixnum(size);
} catch (IOException ioe) {
ioe.printStackTrace();
throw runtime.newIOErrorFromException(ioe);
} finally {
if (offset != null) {
fptr.seek(context, pos, PosixShim.SEEK_SET);
} else {
fptr.seek(context, pos + size, PosixShim.SEEK_SET);
}
}

return context.runtime.newFixnum(size);
} catch (IOException ioe) {
ioe.printStackTrace();
throw runtime.newIOErrorFromException(ioe);
} finally {
if (offset != null) {
fptr.seek(context, pos, PosixShim.SEEK_SET);
} else {
fptr.seek(context, pos + size, PosixShim.SEEK_SET);
}
if (locked) fptr.unlock();
}
} finally {
if (locked) fptr.unlock();
if (close1 && io1 != null) {
try {io1.close();} catch (Exception e) {}
}
if (close2 && io2 != null) {
try {io2.close();} catch (Exception e) {}
}
}
}

17 changes: 15 additions & 2 deletions core/src/main/java/org/jruby/RubyRational.java
Original file line number Diff line number Diff line change
@@ -129,7 +129,7 @@ private RubyRational(Ruby runtime, IRubyObject clazz, IRubyObject num, IRubyObje
/** rb_rational_raw
*
*/
static RubyRational newRationalRaw(Ruby runtime, IRubyObject x, IRubyObject y) {
public static RubyRational newRationalRaw(Ruby runtime, IRubyObject x, IRubyObject y) {
return new RubyRational(runtime, runtime.getRational(), x, y);
}

@@ -150,7 +150,7 @@ static IRubyObject newRationalCanonicalize(ThreadContext context, IRubyObject x)
/** rb_rational_new
*
*/
static IRubyObject newRationalCanonicalize(ThreadContext context, IRubyObject x, IRubyObject y) {
public static IRubyObject newRationalCanonicalize(ThreadContext context, IRubyObject x, IRubyObject y) {
return canonicalizeInternal(context, context.runtime.getRational(), x, y);
}

@@ -189,6 +189,11 @@ private static RubyRational newRationalBang(ThreadContext context, IRubyObject c
private static RubyRational newRationalBang(ThreadContext context, IRubyObject clazz, IRubyObject x) {
return newRationalBang(context, clazz, x, RubyFixnum.one(context.runtime));
}

@Override
public ClassIndex getNativeClassIndex() {
return ClassIndex.RATIONAL;
}

private IRubyObject num;
private IRubyObject den;
@@ -405,6 +410,14 @@ public IRubyObject denominator(ThreadContext context) {
return den;
}

public IRubyObject getNumerator() {
return num;
}

public IRubyObject getDenominator() {
return den;
}

/** f_imul
*
*/
Loading

0 comments on commit f989af9

Please sign in to comment.