[macruby-changes] [1840] MacRuby/branches/experimental
source_changes at macosforge.org
source_changes at macosforge.org
Thu Jun 11 17:55:58 PDT 2009
Revision: 1840
http://trac.macosforge.org/projects/ruby/changeset/1840
Author: pthomson at apple.com
Date: 2009-06-11 17:55:52 -0700 (Thu, 11 Jun 2009)
Log Message:
-----------
Got all the lineno and tty specs working and fixed a print spec. One of the open specs fails; I will fix it soon.
Modified Paths:
--------------
MacRuby/branches/experimental/io.c
MacRuby/branches/experimental/spec/frozen/tags/macruby/core/io/new_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/macruby/core/io/open_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/macruby/core/io/print_tags.txt
Removed Paths:
-------------
MacRuby/branches/experimental/spec/frozen/tags/macruby/core/io/lineno_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/macruby/core/io/tty_tags.txt
Modified: MacRuby/branches/experimental/io.c
===================================================================
--- MacRuby/branches/experimental/io.c 2009-06-11 20:44:52 UTC (rev 1839)
+++ MacRuby/branches/experimental/io.c 2009-06-12 00:55:52 UTC (rev 1840)
@@ -583,8 +583,14 @@
offset += rb_io_read_stream_get_offset(io_struct->readStream);
}
// TODO: make this work with IO::SEEK_CUR, SEEK_END, etc.
+ if (CFReadStreamGetStatus(io_struct->readStream) == kCFStreamStatusAtEnd) {
+ // Terrible hack to work around the fact that CFReadStreams, once they
+ // reach EOF, are permanently exhausted even if we set the offset.
+ GC_WB(&io_struct->readStream, _CFReadStreamCreateFromFileDescriptor(NULL, io_struct->fd));
+ CFReadStreamOpen(io_struct->readStream);
+ CFMakeCollectable(io_struct->readStream);
+ }
rb_io_read_stream_set_offset(io_struct->readStream, NUM2OFFT(offset));
-
return INT2FIX(0); // is this right?
}
@@ -670,6 +676,7 @@
static VALUE
rb_io_rewind(VALUE io, SEL sel)
{
+ ExtractIOStruct(io)->lineno = 0;
return rb_io_seek(io, INT2FIX(0), SEEK_SET);
}
@@ -1167,7 +1174,7 @@
VALUE maxlen, buffer;
rb_scan_args(argc, argv, "11", &maxlen, &buffer);
if (FIX2INT(maxlen) == 0) {
- return (VALUE)CFSTR("");
+ return rb_str_new2("");
}
else if (FIX2INT(maxlen) < 0) {
rb_raise(rb_eArgError, "negative numbers not valid");
@@ -1283,7 +1290,8 @@
}
CFDataSetLength(data, data_read);
}
-
+ io_struct->lineno += 1;
+ ARGF.lineno = INT2FIX(io_struct->lineno);
return bstr;
}
@@ -1310,6 +1318,7 @@
rb_io_lineno(VALUE io, SEL sel)
{
rb_io_t *io_s = ExtractIOStruct(io);
+ rb_io_assert_open(io_s);
return INT2FIX(io_s->lineno);
}
@@ -1334,6 +1343,7 @@
rb_io_set_lineno(VALUE io, SEL sel, VALUE line_no)
{
rb_io_t *io_s = ExtractIOStruct(io);
+ rb_io_assert_open(io_s);
io_s->lineno = FIX2INT(line_no);
return line_no;
}
@@ -2318,7 +2328,7 @@
// This is too simplistic.
rb_io_t *other = ExtractIOStruct(path_or_io);
rb_io_assert_open(other);
- RFILE(io)->fptr = other;
+ GC_WB(&RFILE(io)->fptr, other);
return io;
}
}
@@ -2399,6 +2409,7 @@
VALUE
rb_io_print(VALUE io, SEL sel, int argc, VALUE *argv)
{
+ rb_io_assert_writable(ExtractIOStruct(io));
VALUE line;
if (argc == 0) {
// No arguments? Bloody Perlisms...
Deleted: MacRuby/branches/experimental/spec/frozen/tags/macruby/core/io/lineno_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/macruby/core/io/lineno_tags.txt 2009-06-11 20:44:52 UTC (rev 1839)
+++ MacRuby/branches/experimental/spec/frozen/tags/macruby/core/io/lineno_tags.txt 2009-06-12 00:55:52 UTC (rev 1840)
@@ -1,5 +0,0 @@
-fails:IO#lineno raises IOError on closed stream
-fails:IO#lineno returns the current line number
-fails:IO#lineno= raises IOError on closed stream
-fails:IO#lineno= sets the current line number to the given value
-fails:IO#lineno= does not change $. until next read
Modified: MacRuby/branches/experimental/spec/frozen/tags/macruby/core/io/new_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/macruby/core/io/new_tags.txt 2009-06-11 20:44:52 UTC (rev 1839)
+++ MacRuby/branches/experimental/spec/frozen/tags/macruby/core/io/new_tags.txt 2009-06-12 00:55:52 UTC (rev 1840)
@@ -1,3 +1,4 @@
fails:IO.new associates new IO with the old descriptor so each IO directly affects the other
fails:IO.new raises EINVAL if mode is not compatible with the descriptor's current mode
fails:IO.new cannot open an IO with incompatible flags
+fails:IO.new takes an Integer or #to_int argument as the descriptor to open
Modified: MacRuby/branches/experimental/spec/frozen/tags/macruby/core/io/open_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/macruby/core/io/open_tags.txt 2009-06-11 20:44:52 UTC (rev 1839)
+++ MacRuby/branches/experimental/spec/frozen/tags/macruby/core/io/open_tags.txt 2009-06-12 00:55:52 UTC (rev 1840)
@@ -3,3 +3,4 @@
fails:IO.open cannot open an IO with incompatible flags
fails:IO.open with a block invokes close on opened IO object when exiting the block
fails:IO.open with a block propagates non-StandardErrors produced by close
+fails:IO.open takes an Integer or #to_int argument as the descriptor to open
Modified: MacRuby/branches/experimental/spec/frozen/tags/macruby/core/io/print_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/macruby/core/io/print_tags.txt 2009-06-11 20:44:52 UTC (rev 1839)
+++ MacRuby/branches/experimental/spec/frozen/tags/macruby/core/io/print_tags.txt 2009-06-12 00:55:52 UTC (rev 1840)
@@ -1,2 +1 @@
fails:IO#print writes $_.to_s followed by $\ (if any) to the stream if no arguments given
-fails:IO#print raises IOError on closed stream
Deleted: MacRuby/branches/experimental/spec/frozen/tags/macruby/core/io/tty_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/macruby/core/io/tty_tags.txt 2009-06-11 20:44:52 UTC (rev 1839)
+++ MacRuby/branches/experimental/spec/frozen/tags/macruby/core/io/tty_tags.txt 2009-06-12 00:55:52 UTC (rev 1840)
@@ -1 +0,0 @@
-fails:IO#tty? raises IOError on closed stream
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090611/54c97bcc/attachment-0001.html>
More information about the macruby-changes
mailing list