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

whiteknight at svn.parrot.org whiteknight at svn.parrot.org
Sun Jun 7 01:55:17 UTC 2009


Author: whiteknight
Date: Sun Jun  7 01:55:16 2009
New Revision: 39443
URL: https://trac.parrot.org/parrot/changeset/39443

Log:
[io_rewiring] StringHandle may pass a NULL path, even though FileHandles don't. Change an assertion to allow for this behavior, which resolves a test failure.

Modified:
   branches/io_rewiring/include/parrot/io.h
   branches/io_rewiring/src/io/api.c
   branches/io_rewiring/src/pmc/filehandle.pmc
   branches/io_rewiring/src/pmc/handle.pmc
   branches/io_rewiring/src/pmc/pipe.pmc
   branches/io_rewiring/src/pmc/pipehandle.pmc
   branches/io_rewiring/src/pmc/stringhandle.pmc

Modified: branches/io_rewiring/include/parrot/io.h
==============================================================================
--- branches/io_rewiring/include/parrot/io.h	Sun Jun  7 01:50:47 2009	(r39442)
+++ branches/io_rewiring/include/parrot/io.h	Sun Jun  7 01:55:16 2009	(r39443)
@@ -233,10 +233,9 @@
 PARROT_CANNOT_RETURN_NULL
 PMC * Parrot_io_open(PARROT_INTERP,
     ARGIN_NULLOK(PMC *pmc),
-    ARGIN(STRING *path),
+    ARGIN_NULLOK(STRING *path),
     ARGIN_NULLOK(STRING *mode))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(3);
+        __attribute__nonnull__(1);
 
 PARROT_EXPORT
 PARROT_WARN_UNUSED_RESULT
@@ -386,8 +385,7 @@
 #define ASSERT_ARGS_Parrot_io_new_pmc __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp)
 #define ASSERT_ARGS_Parrot_io_open __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp) \
-    || PARROT_ASSERT_ARG(path)
+       PARROT_ASSERT_ARG(interp)
 #define ASSERT_ARGS_Parrot_io_peek __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp) \
     || PARROT_ASSERT_ARG(pmc) \

Modified: branches/io_rewiring/src/io/api.c
==============================================================================
--- branches/io_rewiring/src/io/api.c	Sun Jun  7 01:50:47 2009	(r39442)
+++ branches/io_rewiring/src/io/api.c	Sun Jun  7 01:55:16 2009	(r39443)
@@ -117,7 +117,7 @@
 PARROT_CANNOT_RETURN_NULL
 PMC *
 Parrot_io_open(PARROT_INTERP, ARGIN_NULLOK(PMC *pmc),
-        ARGIN(STRING *path), ARGIN_NULLOK(STRING *mode))
+        ARGIN_NULLOK(STRING *path), ARGIN_NULLOK(STRING *mode))
 {
     ASSERT_ARGS(Parrot_io_open)
     PMC *new_filehandle, *filehandle;
@@ -133,6 +133,8 @@
 
     flags = Parrot_io_parse_open_flags(interp, mode);
     if (new_filehandle->vtable->base_type == enum_class_FileHandle) {
+        /* TODO: StringHandle may have a null path, but a filehandle really
+           shouldn't allow that. */
         PARROT_ASSERT(new_filehandle->vtable->base_type == enum_class_FileHandle);
         filehandle = PIO_OPEN(interp, new_filehandle, path, flags);
         if (PMC_IS_NULL(filehandle))

Modified: branches/io_rewiring/src/pmc/filehandle.pmc
==============================================================================
--- branches/io_rewiring/src/pmc/filehandle.pmc	Sun Jun  7 01:50:47 2009	(r39442)
+++ branches/io_rewiring/src/pmc/filehandle.pmc	Sun Jun  7 01:55:16 2009	(r39443)
@@ -90,31 +90,6 @@
 
 /*
 
-=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 && !Parrot_io_is_closed(INTERP, SELF)) {
-            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.

Modified: branches/io_rewiring/src/pmc/handle.pmc
==============================================================================
--- branches/io_rewiring/src/pmc/handle.pmc	Sun Jun  7 01:50:47 2009	(r39442)
+++ branches/io_rewiring/src/pmc/handle.pmc	Sun Jun  7 01:55:16 2009	(r39443)
@@ -34,12 +34,6 @@
         Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
             "Handle cannot be instantiated directly.");
     }
-
-    VTABLE INTVAL does(STRING * role) {
-        if (Parrot_str_equal(interp, role, Parrot_str_new(INTERP, "IO", 2)))
-            return 1;
-        return 0;
-    }
 }
 
 /*

Modified: branches/io_rewiring/src/pmc/pipe.pmc
==============================================================================
--- branches/io_rewiring/src/pmc/pipe.pmc	Sun Jun  7 01:50:47 2009	(r39442)
+++ branches/io_rewiring/src/pmc/pipe.pmc	Sun Jun  7 01:55:16 2009	(r39443)
@@ -83,21 +83,6 @@
         return SELF;
     }
 
-/*
-
-=item C<INTVAL does(STRING * role)>
-
-=cut
-
-*/
-
-    VTABLE INTVAL does(STRING * role) {
-        if (Parrot_str_equal(INTERP, role, CONST_STRING(INTERP, "pipe")))
-            return 1;
-        /* TODO: Pipe should does read or write also, depending on what
-           type of pipe it is */
-        return SUPER(role);
-    }
 
 /*
 

Modified: branches/io_rewiring/src/pmc/pipehandle.pmc
==============================================================================
--- branches/io_rewiring/src/pmc/pipehandle.pmc	Sun Jun  7 01:50:47 2009	(r39442)
+++ branches/io_rewiring/src/pmc/pipehandle.pmc	Sun Jun  7 01:55:16 2009	(r39443)
@@ -72,23 +72,6 @@
         return SELF;
     }
 
-
-/*
-
-=item C<INTVAL does(STRING * role)>
-
-=cut
-
-*/
-
-    VTABLE INTVAL does(STRING * role) {
-        Parrot_PipeHandle_attributes * const attrs = PARROT_PIPEHANDLE(SELF);
-        if (Parrot_str_equal(interp, role, CONST_STRING(interp, "socket")))
-            return 1;
-        return SUPER(role);
-    }
-
-
 /*
 
 =item C<void destroy()>

Modified: branches/io_rewiring/src/pmc/stringhandle.pmc
==============================================================================
--- branches/io_rewiring/src/pmc/stringhandle.pmc	Sun Jun  7 01:50:47 2009	(r39442)
+++ branches/io_rewiring/src/pmc/stringhandle.pmc	Sun Jun  7 01:55:16 2009	(r39443)
@@ -83,29 +83,6 @@
 
 /*
 
-=item <INTVAL does(STRING * role)>
-
-=cut
-
-*/
-
-    VTABLE INTVAL does(STRING * role) {
-        Parrot_StringHandle_attributes * const attrs = PMC_data(SELF);
-        if (Parrot_str_equal(INTERP, role, CONST_STRING(INTERP, "string")))
-            return 1;
-        if (attrs->flags != 0 && !STRING_IS_NULL(attrs->stringhandle)) {
-            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<void mark()>
 
 Mark active stringhandle data as live.


More information about the parrot-commits mailing list