Skip to content

Commit

Permalink
Copypasta mistakes and define some constants
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Oct 23, 2023
1 parent 243c56a commit fbce6e2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/FiberScheduler.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ public static IRubyObject ioPRead(ThreadContext context, IRubyObject scheduler,
// MRI: rb_fiber_scheduler_io_write
public static IRubyObject ioWrite(ThreadContext context, IRubyObject scheduler, IRubyObject io, IRubyObject buffer, int length, int offset) {
Ruby runtime = context.runtime;
return Helpers.invokeChecked(context, scheduler, "io_read", io, buffer, runtime.newFixnum(length), runtime.newFixnum(offset));
return Helpers.invokeChecked(context, scheduler, "io_write", io, buffer, runtime.newFixnum(length), runtime.newFixnum(offset));
}

public static IRubyObject ioWrite(ThreadContext context, IRubyObject scheduler, IRubyObject io, IRubyObject buffer, RubyInteger length, RubyInteger offset) {
return Helpers.invokeChecked(context, scheduler, "io_read", io, buffer, length, offset);
return Helpers.invokeChecked(context, scheduler, "io_write", io, buffer, length, offset);
}

// MRI: rb_fiber_scheduler_io_pwrite
Expand Down
7 changes: 6 additions & 1 deletion core/src/main/java/org/jruby/RubyIOBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public static RubyClass createIOBufferClass(Ruby runtime) {
IOBuffer.defineAnnotatedMethods(RubyIOBuffer.class);
IOBuffer.defineAnnotatedConstants(RubyIOBuffer.class);

RubyClass IO = runtime.getIO();

IO.setConstant("READABLE", runtime.newFixnum(OpenFile.READABLE));
IO.setConstant("WRITABLE", runtime.newFixnum(OpenFile.WRITABLE));

return IOBuffer;
}

Expand Down Expand Up @@ -2067,7 +2072,7 @@ public IRubyObject write(ThreadContext context, IRubyObject io, IRubyObject leng
public IRubyObject write(ThreadContext context, IRubyObject io, int length, int offset) {
validateRange(context, offset, length);

ByteBuffer buffer = getBufferForWriting(context);
ByteBuffer buffer = getBufferForReading(context);

return writeInternal(context, RubyIO.convertToIO(context, io), buffer, offset, length);
}
Expand Down

0 comments on commit fbce6e2

Please sign in to comment.