[svn:parrot] r39209 - in branches/io_rewiring/src: io pmc

whiteknight at svn.parrot.org whiteknight at svn.parrot.org
Thu May 28 00:48:50 UTC 2009


Author: whiteknight
Date: Thu May 28 00:48:49 2009
New Revision: 39209
URL: https://trac.parrot.org/parrot/changeset/39209

Log:
[io_rewiring] convert Parrot_io_is_closed. Also, clean up a few things, and start differentiating IO PMCs based on roles

Modified:
   branches/io_rewiring/src/io/api.c
   branches/io_rewiring/src/pmc/filehandle.pmc

Modified: branches/io_rewiring/src/io/api.c
==============================================================================
--- branches/io_rewiring/src/io/api.c	Thu May 28 00:35:57 2009	(r39208)
+++ branches/io_rewiring/src/io/api.c	Thu May 28 00:48:49 2009	(r39209)
@@ -119,6 +119,8 @@
     INTVAL flags;
 
     if (PMC_IS_NULL(pmc))
+        /* TODO: We should look up the HLL mapped type, instead of always
+           using FileHandle here */
         new_filehandle = pmc_new(interp, enum_class_FileHandle);
     else {
         if (!VTABLE_does(interp, pmc, CONST_STRING(interp, "file")))
@@ -207,8 +209,10 @@
     if (PMC_IS_NULL(pmc))
         return -1;
 
-    result = Parrot_io_close_filehandle(interp, pmc);
-    SETATTR_FileHandle_flags(interp, pmc, 0);
+    if (VTABLE_does(interp, pmc, CONST_STRING(interp, "file"))) {
+        result = Parrot_io_close_filehandle(interp, pmc);
+        SETATTR_FileHandle_flags(interp, pmc, 0);
+    }
 
     return result;
 }
@@ -230,12 +234,13 @@
 Parrot_io_is_closed(PARROT_INTERP, ARGMOD(PMC *pmc))
 {
     ASSERT_ARGS(Parrot_io_is_closed)
-    INTVAL result;
+    INTVAL result = 1;
 
     if (PMC_IS_NULL(pmc))
         return 1;
+    if (VTABLE_does(interp, pmc, CONST_STRING(interp, "file")))
+        result = Parrot_io_is_closed_filehandle(interp, pmc);
 
-    Parrot_PCCINVOKE(interp, pmc, CONST_STRING(interp, "is_closed"), "->I", &result);
     return result;
 }
 

Modified: branches/io_rewiring/src/pmc/filehandle.pmc
==============================================================================
--- branches/io_rewiring/src/pmc/filehandle.pmc	Thu May 28 00:35:57 2009	(r39208)
+++ branches/io_rewiring/src/pmc/filehandle.pmc	Thu May 28 00:48:49 2009	(r39209)
@@ -346,7 +346,7 @@
 
     METHOD is_closed() {
         INTVAL status;
-        status = Parrot_io_is_closed_filehandle(interp, SELF);
+        status = Parrot_io_is_closed(interp, SELF);
         RETURN(INTVAL status);
     }
 


More information about the parrot-commits mailing list