develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r34611 - in branches/pdd22io_part3: include/parrot src/io src/ops

From:
allison
Date:
December 29, 2008 20:59
Subject:
[svn:parrot] r34611 - in branches/pdd22io_part3: include/parrot src/io src/ops
Message ID:
20081230045930.25C2BCB9FA@x12.develooper.com
Author: allison
Date: Mon Dec 29 20:59:29 2008
New Revision: 34611

Modified:
   branches/pdd22io_part3/include/parrot/io.h
   branches/pdd22io_part3/src/io/api.c
   branches/pdd22io_part3/src/ops/io.ops

Log:
[pdd22io] Change the 'readline' op to call a public interface, which calls the
'readline' method.


Modified: branches/pdd22io_part3/include/parrot/io.h
==============================================================================
--- branches/pdd22io_part3/include/parrot/io.h	(original)
+++ branches/pdd22io_part3/include/parrot/io.h	Mon Dec 29 20:59:29 2008
@@ -254,7 +254,15 @@
 PARROT_EXPORT
 PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
-STRING * Parrot_io_reads(PARROT_INTERP, ARGMOD(PMC *pmc), size_t len)
+STRING * Parrot_io_readline(PARROT_INTERP, ARGMOD(PMC *pmc))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        FUNC_MODIFIES(*pmc);
+
+PARROT_EXPORT
+PARROT_WARN_UNUSED_RESULT
+PARROT_CANNOT_RETURN_NULL
+STRING * Parrot_io_reads(PARROT_INTERP, ARGMOD(PMC *pmc), size_t length)
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)
         FUNC_MODIFIES(*pmc);
@@ -299,7 +307,7 @@
 INTVAL Parrot_io_write(PARROT_INTERP,
     ARGMOD(PMC *pmc),
     ARGIN(const void *buffer),
-    size_t len)
+    size_t length)
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)
         __attribute__nonnull__(3)

Modified: branches/pdd22io_part3/src/io/api.c
==============================================================================
--- branches/pdd22io_part3/src/io/api.c	(original)
+++ branches/pdd22io_part3/src/io/api.c	Mon Dec 29 20:59:29 2008
@@ -228,6 +228,29 @@
 
 /*
 
+=item C<STRING * Parrot_io_readline>
+
+Return a new C<STRING*> holding the next line read from the file.
+
+=cut
+
+*/
+
+
+PARROT_EXPORT
+PARROT_WARN_UNUSED_RESULT
+PARROT_CANNOT_RETURN_NULL
+STRING *
+Parrot_io_readline(PARROT_INTERP, ARGMOD(PMC *pmc))
+{
+    STRING *result;
+    Parrot_PCCINVOKE(interp, pmc, CONST_STRING(interp, "readline"), "->S",
+            &result);
+    return result;
+}
+
+/*
+
 =item C<INTVAL Parrot_io_write>
 
 Writes C<len> bytes from C<*buffer> to C<*pmc>.

Modified: branches/pdd22io_part3/src/ops/io.ops
==============================================================================
--- branches/pdd22io_part3/src/ops/io.ops	(original)
+++ branches/pdd22io_part3/src/ops/io.ops	Mon Dec 29 20:59:29 2008
@@ -312,30 +312,7 @@
 =cut
 
 inline op readline(out STR, invar PMC) :base_io {
-    PMC * const pio = $2;
-    /* this ugly error handling will go away, when all the
-     * io stuff are methods
-     */
-    opcode_t *dest = expr NEXT();
-    if (pio->vtable->base_type != enum_class_FileHandle) {
-        opcode_t *handler = Parrot_ex_throw_from_op_args(interp, dest,
-            EXCEPTION_PIO_ERROR,
-            "Cannot read line from empty filehandle");
-        goto ADDRESS(handler);
-    }
-    else {
-        INTVAL flags = Parrot_io_get_flags(interp, pio);
-        if (Parrot_io_is_closed(interp, pio)) {
-            opcode_t *handler = Parrot_ex_throw_from_op_args(interp, dest,
-                EXCEPTION_PIO_ERROR,
-                "Cannot read line from empty filehandle");
-            goto ADDRESS(handler);
-        }
-
-        if (!(flags & PIO_F_LINEBUF))
-            Parrot_io_setlinebuf(interp, pio);
-        $1 = Parrot_io_reads(interp, pio, 0);
-    }
+    $1 = Parrot_io_readline(interp, $2);
 }
 
 ##########################################



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About