Skip to content

Commit 2ca0ff0

Browse files
committed
Remove extra public methods on IO
* IO#read_bom_byte was never used.
1 parent bf11482 commit 2ca0ff0

File tree

3 files changed

+11
-44
lines changed

3 files changed

+11
-44
lines changed

spec/tags/truffle/methods_tags.txt

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,9 @@ fails:Public methods on IO should include pread
2525
fails:Public methods on IO should include pwrite
2626
fails:Public methods on IO should not include dup
2727
fails:Public methods on IO should not include encode_with
28-
fails:Public methods on IO should not include eof!
29-
fails:Public methods on IO should not include force_read_only
30-
fails:Public methods on IO should not include force_write_only
31-
fails:Public methods on IO should not include mode_read_only?
32-
fails:Public methods on IO should not include mode_write_only?
3328
fails:Public methods on IO should not include nonblock
3429
fails:Public methods on IO should not include nonblock=
3530
fails:Public methods on IO should not include nonblock?
36-
fails:Public methods on IO should not include pid=
37-
fails:Public methods on IO should not include pipe=
38-
fails:Public methods on IO should not include pipe?
39-
fails:Public methods on IO should not include read_bom_byte
40-
fails:Public methods on IO should not include reset_buffering
41-
fails:Public methods on IO should not include strip_bom
4231
fails:Public methods on Kernel should include then
4332
fails:Public methods on Numeric should include clone
4433
fails:Public methods on Numeric should include dup

src/main/ruby/truffleruby/core/io.rb

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def fill_from(io, skip = nil)
202202

203203
reset!
204204
if fill(io) == 0
205-
io.eof!
205+
io.instance_variable_set(:@eof, true)
206206
@eof = true
207207
end
208208

@@ -348,20 +348,20 @@ def inspect # :nodoc:
348348
end
349349
end
350350

351-
def mode_read_only?
351+
private def mode_read_only?
352352
@mode & ACCMODE == RDONLY
353353
end
354354

355-
def mode_write_only?
355+
private def mode_write_only?
356356
@mode & ACCMODE == WRONLY
357357
end
358358

359-
def force_read_only
359+
private def force_read_only
360360
@mode &= ~IO::ACCMODE
361361
@mode |= RDONLY
362362
end
363363

364-
def force_write_only
364+
private def force_write_only
365365
@mode &= ~IO::ACCMODE
366366
@mode |= WRONLY
367367
end
@@ -439,7 +439,7 @@ def run
439439
end
440440

441441
if @offset
442-
if @from_io && !@from.pipe?
442+
if @from_io && !@from.instance_variable_get(:@pipe)
443443
saved_pos = @from.pos
444444
else
445445
saved_pos = 0
@@ -903,7 +903,7 @@ def self.popen(*args)
903903
pid = Truffle::ProcessOperations.spawn(env || {}, *cmd, options)
904904
end
905905

906-
pipe.pid = pid
906+
pipe.instance_variable_set :@pid, pid
907907

908908
ch_write.close if readable
909909
ch_read.close if writable
@@ -1594,13 +1594,6 @@ def each_codepoint
15941594
end
15951595
alias_method :codepoints, :each_codepoint
15961596

1597-
1598-
##
1599-
# Set the pipe so it is at the end of the file
1600-
def eof!
1601-
@eof = true
1602-
end
1603-
16041597
##
16051598
# Returns true if ios is at end of file that means
16061599
# there are no more data to read. The stream must be
@@ -1869,16 +1862,6 @@ def pid
18691862
@pid
18701863
end
18711864

1872-
attr_writer :pid
1873-
1874-
def pipe=(v)
1875-
@pipe = !!v
1876-
end
1877-
1878-
def pipe?
1879-
@pipe
1880-
end
1881-
18821865
def pos
18831866
flush
18841867
reset_buffering
@@ -2201,7 +2184,7 @@ def reopen(other, mode=undefined)
22012184
io.ensure_open
22022185
end
22032186

2204-
io.reset_buffering
2187+
io.__send__(:reset_buffering)
22052188

22062189
Truffle::IOOperations.dup2_with_cloexec(io.fileno, @descriptor)
22072190

@@ -2250,7 +2233,7 @@ def reopen(other, mode=undefined)
22502233
##
22512234
# Internal method used to reset the state of the buffer, including the
22522235
# physical position in the stream.
2253-
def reset_buffering
2236+
private def reset_buffering
22542237
@ibuffer.unseek! self
22552238
end
22562239

@@ -2355,12 +2338,7 @@ def set_encoding(external, internal=nil, options=undefined)
23552338
self
23562339
end
23572340

2358-
def read_bom_byte
2359-
read_ios, _, _ = IO.select [self], nil, nil, 0.1
2360-
getbyte if read_ios
2361-
end
2362-
2363-
def strip_bom
2341+
private def strip_bom
23642342
mode = Truffle::POSIX.truffleposix_fstat_mode(@descriptor)
23652343
return unless Truffle::StatOperations.file?(mode)
23662344

src/main/ruby/truffleruby/core/truffle/io_operations.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def self.dup2_with_cloexec(old_fd, new_fd)
101101
def self.pipe_end_setup(io)
102102
io.close_on_exec = true
103103
io.sync = true
104-
io.pipe = true
104+
io.instance_variable_set :@pipe, true
105105
io
106106
end
107107

0 commit comments

Comments
 (0)