Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make IO::Handle.seek use SeekType enum
Also backported from newio branch
  • Loading branch information
lizmat committed Nov 14, 2015
1 parent 31d12fb commit 2379641
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/core/IO/Handle.pm
Expand Up @@ -707,14 +707,18 @@ my class IO::Handle does IO {
}
}

# second arguemnt should probably be an enum
# valid values for $whence:
# 0 -- seek from beginning of file
# 1 -- seek relative to current position
# 2 -- seek from the end of the file
method seek(IO::Handle:D: Int:D $offset, Int:D $whence --> True) {
proto method seek(|) { * }
multi method seek(IO::Handle:D: Int:D $offset, Int:D $whence --> True) {
DEPRECATED(
SeekType.^enum_value_list[$whence],
:what("numerical seektype $whence"),
);
nqp::seekfh($!PIO, $offset, $whence);
}
multi method seek(IO::Handle:D: Int:D $offset, SeekType:D $whence) {
nqp::seekfh($!PIO, $offset, +$whence);
True;
}

method tell(IO::Handle:D:) returns Int {
nqp::p6box_i(nqp::tellfh($!PIO));
Expand Down

0 comments on commit 2379641

Please sign in to comment.