[svn:parrot] r39196 - branches/io_rewiring/src/pmc

whiteknight at svn.parrot.org whiteknight at svn.parrot.org
Wed May 27 15:37:41 UTC 2009


Author: whiteknight
Date: Wed May 27 15:37:40 2009
New Revision: 39196
URL: https://trac.parrot.org/parrot/changeset/39196

Log:
[io_rewiring] add a prototype does() vtable for FileHandle

Modified:
   branches/io_rewiring/src/pmc/filehandle.pmc
   branches/io_rewiring/src/pmc/handle.pmc

Modified: branches/io_rewiring/src/pmc/filehandle.pmc
==============================================================================
--- branches/io_rewiring/src/pmc/filehandle.pmc	Wed May 27 13:28:57 2009	(r39195)
+++ branches/io_rewiring/src/pmc/filehandle.pmc	Wed May 27 15:37:40 2009	(r39196)
@@ -102,6 +102,31 @@
 
 /*
 
+=item C<INTVAL does(STRING * role)>
+
+Determines the capabilities of the PMC
+
+=cut
+
+*/
+
+    VTABLE INTVAL does(STRING * role) {
+        Parrot_FileHandle_attributes * const attrs = PARROT_FILEHANDLE(SELF);
+        if (Parrot_str_equal(interp, role, CONST_STRING(interp, "file")))
+            return 1;
+        if (attrs->flags != 0) {
+            if((attrs->flags & PIO_F_READ) && Parrot_str_equal(interp, role, CONST_STRING(INTERP, "read")))
+                return 1;
+            if((attrs->flags & PIO_F_WRITE) && Parrot_str_equal(interp, role, CONST_STRING(INTERP, "write")))
+                return 1;
+            if((attrs->flags & PIO_F_APPEND) && Parrot_str_equal(interp, role, CONST_STRING(INTERP, "append")))
+                return 1;
+        }
+        return SUPER(role);
+    }
+
+/*
+
 =item C<PMC *clone()>
 
 Create a copy of the filehandle.
@@ -316,6 +341,7 @@
     METHOD close() {
         INTVAL status;
         status = Parrot_io_close_filehandle(interp, SELF);
+        PARROT_FILEHANDLE(SELF)->flags = 0;
         RETURN(INTVAL status);
     }
 

Modified: branches/io_rewiring/src/pmc/handle.pmc
==============================================================================
--- branches/io_rewiring/src/pmc/handle.pmc	Wed May 27 13:28:57 2009	(r39195)
+++ branches/io_rewiring/src/pmc/handle.pmc	Wed May 27 15:37:40 2009	(r39196)
@@ -35,7 +35,10 @@
     }
 
     VTABLE INTVAL does(STRING * role) {
-        /* TODO: Handle should does "IO" */
+        /*
+        if (Parrot_str_equal(interp, role, Parrot_str_new(INTERP, "IO"))
+            return 1;
+        */
         return 0;
     }
 }


More information about the parrot-commits mailing list