[macruby-changes] [1021] MacRuby/branches/experimental

source_changes at macosforge.org source_changes at macosforge.org
Fri Mar 20 11:27:47 PDT 2009


Revision: 1021
          http://trac.macosforge.org/projects/ruby/changeset/1021
Author:   lsansonetti at apple.com
Date:     2009-03-20 11:27:46 -0700 (Fri, 20 Mar 2009)
Log Message:
-----------
empty implementation of #flush (for now) + re-enabled the IO finalizer

Modified Paths:
--------------
    MacRuby/branches/experimental/gc.c
    MacRuby/branches/experimental/io.c

Modified: MacRuby/branches/experimental/gc.c
===================================================================
--- MacRuby/branches/experimental/gc.c	2009-03-20 17:59:04 UTC (rev 1020)
+++ MacRuby/branches/experimental/gc.c	2009-03-20 18:27:46 UTC (rev 1021)
@@ -38,10 +38,7 @@
 #endif
 static auto_zone_t *__auto_zone = NULL;
 
-int rb_io_fptr_finalize(struct rb_io_t* t)
-{
-    rb_notimplement();
-}
+int rb_io_fptr_finalize(struct rb_io_t *io_struct);
 
 static VALUE nomem_error;
 

Modified: MacRuby/branches/experimental/io.c
===================================================================
--- MacRuby/branches/experimental/io.c	2009-03-20 17:59:04 UTC (rev 1020)
+++ MacRuby/branches/experimental/io.c	2009-03-20 18:27:46 UTC (rev 1021)
@@ -352,6 +352,24 @@
     io_struct->sync = mode & FMODE_SYNC;
 }
 
+static void
+io_struct_close(rb_io_t *io_struct, bool close_read, bool close_write)
+{
+    if (close_read && io_struct->readStream != NULL) {
+	CFReadStreamClose(io_struct->readStream);
+    }
+    if (close_write && io_struct->writeStream != NULL) {
+	CFWriteStreamClose(io_struct->writeStream);
+    }
+}
+
+int
+rb_io_fptr_finalize(rb_io_t *io_struct)
+{
+    io_struct_close(io_struct, true, true);
+    return 1;
+}
+
 static VALUE
 prep_io(int fd, int mode, VALUE klass)
 {
@@ -473,7 +491,8 @@
 VALUE
 rb_io_flush(VALUE io, SEL sel)
 {
-    rb_notimplement();
+    // TODO investigate how to flush a CFStream...
+    return io;
 }
 
 /*
@@ -1507,12 +1526,7 @@
 {
     rb_io_t *io_struct = ExtractIOStruct(io);
 
-    if (close_read && io_struct->readStream != NULL) {
-	CFReadStreamClose(io_struct->readStream);
-    }
-    if (close_write && io_struct->writeStream != NULL) {
-	CFWriteStreamClose(io_struct->writeStream);
-    }
+    io_struct_close(io_struct, close_read, close_write);
 }
 
 static VALUE
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090320/fd204bb4/attachment-0001.html>


More information about the macruby-changes mailing list