Author: petdance
Date: Thu Jun 14 10:46:46 2007
New Revision: 18999

Modified:
   trunk/config/gen/makefiles/root.in
   trunk/include/parrot/io.h
   trunk/src/io/io.c
   trunk/src/io/io_private.h
   trunk/src/io/io_win32.c
   trunk/src/ops/io.ops

Log:
* Headerized src/io/io.c
* src/ops/io.ops now uses the macro form of PIO_STD{IN,OUT,ERR} instead of the 
functions
* Removed alloc_pio_array and realloc_pio_array.  They were used once, and 
never, respectively.


Modified: trunk/config/gen/makefiles/root.in
==============================================================================
--- trunk/config/gen/makefiles/root.in  (original)
+++ trunk/config/gen/makefiles/root.in  Thu Jun 14 10:46:46 2007
@@ -1845,6 +1845,7 @@
     src/hash.o \
     src/headers.o \
     src/intlist.o \
+    src/io/io.c \
     src/key.o \
     src/list.o \
     src/mmd.o \

Modified: trunk/include/parrot/io.h
==============================================================================
--- trunk/include/parrot/io.h   (original)
+++ trunk/include/parrot/io.h   Thu Jun 14 10:46:46 2007
@@ -143,69 +143,218 @@
 
 extern INTVAL pio_errno;
 
-/* io.c - If you add new layers, register them in init_layers() */
-PARROT_API extern void PIO_init(Interp *);
-PARROT_API extern void PIO_finish(Interp *);
-PARROT_API void PIO_internal_shutdown(Interp *);
-PARROT_API extern INTVAL PIO_init_stacks(Interp *);
-PARROT_API extern void PIO_atexit(Interp *);
-PARROT_API extern INTVAL PIO_push_layer(Interp *, PMC *, ParrotIOLayer *);
-PARROT_API extern ParrotIOLayer *PIO_pop_layer(Interp *, PMC *);
-PARROT_API extern ParrotIOLayer *PIO_copy_stack(ParrotIOLayer *);
-PARROT_API ParrotIOLayer *PIO_get_layer(Interp *, const char *name);
+/* HEADERIZER BEGIN: src/io/io.c */
 
+PARROT_API PMC * new_io_pmc( Interp *interp, ParrotIO *io /*NULLOK*/ );
+PARROT_API void Parrot_IOData_mark( Interp *interp,
+    ParrotIOData *piodata /*NN*/ )
+        __attribute__nonnull__(2);
 
-PARROT_API extern struct PMC *new_io_pmc(Interp *, ParrotIO *);
-PARROT_API extern void free_io_header(ParrotIO *);
-PARROT_API extern ParrotIO *PIO_new(Interp *, INTVAL, INTVAL, INTVAL);
-PARROT_API extern void PIO_destroy(Interp *, PMC *io);
+PARROT_API PMC * PIO_accept( Interp *interp, PMC *pmc /*NN*/ )
+        __attribute__nonnull__(2);
 
-PARROT_API extern INTVAL PIO_base_init(Interp *, ParrotIOLayer *proto);
-PARROT_API extern ParrotIOLayer *PIO_base_new_layer(ParrotIOLayer *proto);
-PARROT_API extern void PIO_base_delete_layer(ParrotIOLayer *proto);
+PARROT_API INTVAL PIO_base_init( Interp *interp, ParrotIOLayer *l );
+PARROT_API INTVAL PIO_bind( Interp *interp,
+    PMC *pmc /*NN*/,
+    STRING *address /*NN*/ )
+        __attribute__nonnull__(2)
+        __attribute__nonnull__(3);
+
+PARROT_API INTVAL PIO_close( Interp *interp, PMC *pmc /*NULLOK*/ );
+PARROT_API INTVAL PIO_connect( Interp *interp,
+    PMC *pmc /*NN*/,
+    STRING *address /*NN*/ )
+        __attribute__nonnull__(2)
+        __attribute__nonnull__(3);
 
-PARROT_API extern INTVAL PIO_parse_open_flags(const char *flagstr);
-PARROT_API extern PMC *PIO_open(Interp *, ParrotIOLayer *, const char *, const 
char *);
-PARROT_API extern PMC *PIO_fdopen(Interp *, ParrotIOLayer *, PIOHANDLE, const 
char *);
-PARROT_API extern INTVAL PIO_close(Interp *, PMC *);
-PARROT_API extern void PIO_flush(Interp *, PMC *);
-PARROT_API extern STRING *PIO_reads(Interp *, PMC *, size_t);
-PARROT_API extern INTVAL PIO_read(Interp *, PMC *, char *, size_t);
-PARROT_API extern INTVAL PIO_write(Interp *, PMC *, const void *, size_t);
-PARROT_API extern INTVAL PIO_setbuf(Interp *, PMC *, size_t);
-PARROT_API extern INTVAL PIO_setlinebuf(Interp *, PMC *);
-PARROT_API extern INTVAL PIO_puts(Interp *, PMC *, const char *);
-PARROT_API extern INTVAL PIO_peek(Interp *, PMC *, STRING **);
-PARROT_API extern PIOOFF_T PIO_seek(Interp *, PMC *, PIOOFF_T offset, INTVAL 
whence);
-PARROT_API extern INTVAL PIO_eof(Interp *, PMC *);
-PARROT_API extern INTVAL PIO_pioctl(Interp *, PMC *, INTVAL cmd, INTVAL arg);
-PARROT_API extern INTVAL PIO_poll(Interp *, PMC *pmc, INTVAL which, INTVAL 
sec, INTVAL usec);
-PARROT_API extern PMC *PIO_socket(Interp *, INTVAL fam, INTVAL type, INTVAL 
proto);
-PARROT_API extern INTVAL PIO_recv(Interp *, PMC *pmc, STRING **buf);
-PARROT_API extern INTVAL PIO_send(Interp *, PMC *pmc, STRING *buf);
-PARROT_API extern INTVAL PIO_connect(Interp *, PMC *pmc, STRING *address);
-PARROT_API extern INTVAL PIO_bind(Interp *, PMC *pmc, STRING *address);
-PARROT_API extern INTVAL PIO_listen(Interp *, PMC *pmc, INTVAL backlog);
-PARROT_API extern PMC *PIO_accept(Interp *, PMC *pmc);
+PARROT_API void PIO_destroy( Interp *interp, PMC *pmc /*NN*/ )
+        __attribute__nonnull__(2);
 
+PARROT_API INTVAL PIO_eof( Interp *interp, PMC *pmc /*NN*/ )
+        __attribute__nonnull__(2)
+        __attribute__warn_unused_result__;
 
-PARROT_API extern INTVAL PIO_putps(Interp *, PMC *io, STRING *s)
+PARROT_API INTVAL PIO_eprintf( Interp *interp /*NULLOK*/,
+    const char *s /*NN*/,
+    ... )
         __attribute__nonnull__(2);
-PARROT_API extern INTVAL PIO_fprintf(Interp *, PMC *io, const char *s, ...)
+
+PARROT_API PMC * PIO_fdopen( Interp *interp,
+    ParrotIOLayer *layer /*NULLOK*/,
+    PIOHANDLE fd,
+    const char *sflags /*NN*/ )
+        __attribute__nonnull__(4)
+        __attribute__warn_unused_result__;
+
+PARROT_API void PIO_finish( Interp *interp /*NN*/ )
+        __attribute__nonnull__(1);
+
+PARROT_API void PIO_flush( Interp *interp, PMC *pmc /*NN*/ )
+        __attribute__nonnull__(2);
+
+PARROT_API INTVAL PIO_fprintf( Interp *interp /*NN*/,
+    PMC *pmc /*NN*/,
+    const char *s /*NN*/,
+    ... )
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        __attribute__nonnull__(3);
+
+PARROT_API PIOHANDLE PIO_getfd( Interp *interp, PMC *pmc /*NN*/ )
+        __attribute__nonnull__(2)
+        __attribute__warn_unused_result__;
+
+PARROT_API void PIO_init( Interp *interp /*NN*/ )
+        __attribute__nonnull__(1);
+
+PARROT_API INTVAL PIO_init_stacks( Interp *interp );
+PARROT_API void PIO_internal_shutdown( Interp *interp );
+PARROT_API INTVAL PIO_isatty( Interp *interp, PMC *pmc /*NN*/ )
+        __attribute__nonnull__(2)
+        __attribute__pure__
+        __attribute__warn_unused_result__;
+
+PARROT_API INTVAL PIO_listen( Interp *interp,
+    PMC *pmc /*NN*/,
+    INTVAL backlog )
+        __attribute__nonnull__(2)
+        __attribute__warn_unused_result__;
+
+PARROT_API ParrotIO * PIO_new( Interp *interp,
+    INTVAL iotype,
+    INTVAL flags,
+    INTVAL mode )
+        __attribute__warn_unused_result__;
+
+PARROT_API PMC * PIO_open( Interp *interp,
+    ParrotIOLayer *layer /*NULLOK*/,
+    const char *spath /*NN*/,
+    const char *sflags /*NN*/ )
+        __attribute__nonnull__(3)
+        __attribute__nonnull__(4)
+        __attribute__warn_unused_result__;
+
+PARROT_API INTVAL PIO_parse_open_flags( const char *flagstr /*NULLOK*/ )
+        __attribute__warn_unused_result__;
+
+PARROT_API INTVAL PIO_peek( Interp *interp,
+    PMC *pmc /*NN*/,
+    STRING **buffer /*NN*/ )
         __attribute__nonnull__(2)
         __attribute__nonnull__(3);
-PARROT_API extern INTVAL PIO_printf(Interp *, const char *s, ...)
+
+PARROT_API INTVAL PIO_pioctl( Interp *interp,
+    PMC *pmc /*NN*/,
+    INTVAL cmd,
+    INTVAL arg )
+        __attribute__nonnull__(2);
+
+PARROT_API INTVAL PIO_poll( Interp *interp /*NN*/,
+    PMC *pmc /*NN*/,
+    INTVAL which,
+    INTVAL sec,
+    INTVAL usec )
+        __attribute__nonnull__(1)
         __attribute__nonnull__(2);
-PARROT_API extern INTVAL PIO_eprintf(Interp *, const char *s, ...)
+
+PARROT_API INTVAL PIO_printf( Interp *interp /*NN*/,
+    const char *s /*NN*/,
+    ... )
+        __attribute__nonnull__(1)
         __attribute__nonnull__(2);
-PARROT_API extern PIOHANDLE PIO_getfd(Interp *, PMC *io)
+
+PARROT_API INTVAL PIO_putps( Interp *interp /*NN*/,
+    PMC *pmc /*NN*/,
+    STRING *s /*NULLOK*/ )
+        __attribute__nonnull__(1)
         __attribute__nonnull__(2);
-PARROT_API extern PIOOFF_T PIO_tell(Interp *, PMC *io)
+
+PARROT_API INTVAL PIO_puts( Interp *interp,
+    PMC *pmc /*NN*/,
+    const char *s /*NN*/ )
+        __attribute__nonnull__(2)
+        __attribute__nonnull__(3);
+
+PARROT_API INTVAL PIO_read( Interp *interp,
+    PMC *pmc /*NN*/,
+    char *buffer /*NN*/,
+    size_t len )
+        __attribute__nonnull__(2)
+        __attribute__nonnull__(3)
+        __attribute__warn_unused_result__;
+
+PARROT_API STRING * PIO_reads( Interp *interp, PMC *pmc /*NN*/, size_t len )
+        __attribute__nonnull__(2)
+        __attribute__warn_unused_result__;
+
+PARROT_API INTVAL PIO_recv( Interp *interp,
+    PMC *pmc /*NN*/,
+    STRING **buf /*NN*/ )
+        __attribute__nonnull__(2)
+        __attribute__nonnull__(3);
+
+PARROT_API PIOOFF_T PIO_seek( Interp *interp,
+    PMC *pmc /*NN*/,
+    PIOOFF_T offset,
+    INTVAL w )
+        __attribute__nonnull__(2)
+        __attribute__warn_unused_result__;
+
+PARROT_API INTVAL PIO_send( Interp *interp,
+    PMC *pmc /*NN*/,
+    STRING *buf /*NN*/ )
+        __attribute__nonnull__(2)
+        __attribute__nonnull__(3)
+        __attribute__warn_unused_result__;
+
+PARROT_API INTVAL PIO_setbuf( Interp *interp,
+    PMC *pmc /*NN*/,
+    size_t bufsize )
         __attribute__nonnull__(2);
 
-PARROT_API extern void Parrot_IOData_mark(Interp *, ParrotIOData *piodata);
+PARROT_API INTVAL PIO_setlinebuf( Interp *interp, PMC *pmc /*NN*/ )
+        __attribute__nonnull__(2);
+
+PARROT_API PMC * PIO_socket( Interp *interp,
+    INTVAL fam,
+    INTVAL type,
+    INTVAL proto );
+
+PARROT_API PMC * PIO_STDERR( Interp *interp );
+PARROT_API PMC * PIO_STDIN( Interp *interp /*NN*/ )
+        __attribute__nonnull__(1);
+
+PARROT_API PMC * PIO_STDOUT( Interp *interp /*NN*/ )
+        __attribute__nonnull__(1);
+
+PARROT_API PIOOFF_T PIO_tell( Interp *interp, PMC *pmc /*NN*/ )
+        __attribute__nonnull__(2)
+        __attribute__warn_unused_result__;
+
+PARROT_API INTVAL PIO_write( Interp *interp,
+    PMC *pmc /*NN*/,
+    const void *buffer /*NN*/,
+    size_t len )
+        __attribute__nonnull__(2)
+        __attribute__nonnull__(3)
+        __attribute__warn_unused_result__;
+
+STRING * PIO_make_io_string( Interp *interp, STRING **buf /*NN*/, size_t len )
+        __attribute__nonnull__(2)
+        __attribute__warn_unused_result__;
+
+PIOOFF_T PIO_make_offset( INTVAL offset );
+PIOOFF_T PIO_make_offset32( INTVAL hi, INTVAL lo );
+PIOOFF_T PIO_make_offset_pmc( Interp *interp, PMC *pmc );
+/* HEADERIZER END: src/io/io.c */
 
-PARROT_API extern INTVAL PIO_isatty(Interp *, PMC *io);
+/* io_layers.c - If you add new layers, register them in init_layers() */
+PARROT_API extern INTVAL PIO_push_layer(Interp *, PMC *, ParrotIOLayer *);
+PARROT_API extern ParrotIOLayer *PIO_pop_layer(Interp *, PMC *);
+PARROT_API extern ParrotIOLayer *PIO_copy_stack(ParrotIOLayer *);
+PARROT_API ParrotIOLayer *PIO_get_layer(Interp *, const char *name);
+PARROT_API extern ParrotIOLayer *PIO_base_new_layer(ParrotIOLayer *proto);
+PARROT_API extern void PIO_base_delete_layer(ParrotIOLayer *proto);
 
 /* Put platform specific macros here if you must */
 #ifdef PIO_OS_WIN32
@@ -226,14 +375,6 @@
 #  define PIO_getblksize(x)   PIO_stdio_getblksize(x)
 #endif
 
-PIOOFF_T PIO_make_offset(INTVAL offset);
-PIOOFF_T PIO_make_offset32(INTVAL hi, INTVAL lo);
-PIOOFF_T PIO_make_offset_pmc(Interp *, PMC *pmc);
-
-/* the internal system redefines them as macros */
-PARROT_API extern PMC *PIO_STDIN(Interp *);
-PARROT_API extern PMC *PIO_STDOUT(Interp *);
-PARROT_API extern PMC *PIO_STDERR(Interp *);
 
 /*
  * pioctl definitions -- These are mostly for reference

Modified: trunk/src/io/io.c
==============================================================================
--- trunk/src/io/io.c   (original)
+++ trunk/src/io/io.c   Thu Jun 14 10:46:46 2007
@@ -118,41 +118,6 @@
 
 /*
 
-FUNCDOC: alloc_pio_array
-
-Allocates an interpreter's IO handle table with room for C<numhandles> IO
-handles.
-
-Called from C<PIO_init()>.
-
-*/
-
-ParrotIOTable
-alloc_pio_array(int numhandles)
-    /* MALLOC, WARN_UNUSED */
-{
-    const size_t size = numhandles * sizeof (ParrotIO *);
-    return (ParrotIOTable)mem_sys_allocate_zeroed(size);
-}
-
-/*
-
-FUNCDOC: realloc_pio_array
-
-Unimplemented; returns C<-1>.
-
-*/
-
-int
-realloc_pio_array(ParrotIOTable *table, int numhandles)
-{
-    UNUSED(table);
-    UNUSED(numhandles);
-    return -1;
-}
-
-/*
-
 FUNCDOC: PIO_new
 
 Creates a new IO stream.
@@ -283,7 +248,7 @@
     if (interp->piodata == NULL)
         internal_exception(PIO_ERROR, "PIO alloc piodata failure.");
     interp->piodata->default_stack = NULL;
-    interp->piodata->table = alloc_pio_array(PIO_NR_OPEN);
+    interp->piodata->table = mem_sys_allocate_zeroed(PIO_NR_OPEN * 
sizeof(ParrotIO *));
     if (interp->piodata->table == NULL)
         internal_exception(PIO_ERROR, "PIO alloc table failure.");
 
@@ -739,6 +704,7 @@
 
 */
 
+PARROT_API
 INTVAL
 PIO_close(Interp *interp, PMC *pmc /*NULLOK*/)
 {
@@ -1297,6 +1263,7 @@
 
 */
 
+PARROT_API
 INTVAL
 PIO_send(Interp *interp, PMC *pmc /*NN*/, STRING *buf /*NN*/)
     /* WARN_UNUSED */
@@ -1358,6 +1325,7 @@
 
 */
 
+PARROT_API
 INTVAL
 PIO_listen(Interp *interp, PMC *pmc /*NN*/, INTVAL backlog)
     /* WARN_UNUSED */
@@ -1379,6 +1347,7 @@
 
 */
 
+PARROT_API
 PMC *
 PIO_accept(Interp *interp, PMC *pmc /*NN*/)
 {

Modified: trunk/src/io/io_private.h
==============================================================================
--- trunk/src/io/io_private.h   (original)
+++ trunk/src/io/io_private.h   Thu Jun 14 10:46:46 2007
@@ -126,9 +126,6 @@
 };
 
 /* functions internal to the subsystem */
-extern ParrotIOTable alloc_pio_array(int);
-extern int realloc_pio_array(ParrotIOTable *, int);
-extern STRING * PIO_make_io_string(Interp *interp, STRING **buf, size_t);
 
 /* redefine PIO_STD* for internal use */
 #define _PIO_STDIN(i)   (((ParrotIOData*)i->piodata)->table[PIO_STDIN_FILENO])

Modified: trunk/src/io/io_win32.c
==============================================================================
--- trunk/src/io/io_win32.c     (original)
+++ trunk/src/io/io_win32.c     Thu Jun 14 10:46:46 2007
@@ -143,21 +143,21 @@
 #  endif
 
     if ((h = GetStdHandle(STD_INPUT_HANDLE)) != INVALID_HANDLE_VALUE) {
-        PIO_STDIN(interp) = new_io_pmc(interp,
+        _PIO_STDIN(interp) = new_io_pmc(interp,
             PIO_win32_fdopen(interp, layer, h, PIO_F_READ));
     }
     else {
         return -1;
     }
     if ((h = GetStdHandle(STD_OUTPUT_HANDLE)) != INVALID_HANDLE_VALUE) {
-        PIO_STDOUT(interp) = new_io_pmc(interp,
+        _PIO_STDOUT(interp) = new_io_pmc(interp,
             PIO_win32_fdopen(interp, layer, h, PIO_F_WRITE));
     }
     else {
         return -2;
     }
     if ((h = GetStdHandle(STD_ERROR_HANDLE)) != INVALID_HANDLE_VALUE) {
-        PIO_STDERR(interp) = new_io_pmc(interp,
+        _PIO_STDERR(interp) = new_io_pmc(interp,
             PIO_win32_fdopen(interp, layer, h, PIO_F_WRITE));
     }
     else {

Modified: trunk/src/ops/io.ops
==============================================================================
--- trunk/src/ops/io.ops        (original)
+++ trunk/src/ops/io.ops        Thu Jun 14 10:46:46 2007
@@ -102,17 +102,17 @@
 =cut
 
 inline op getstdin(out PMC) :base_io {
-  $1 = PIO_STDIN(interp);
+  $1 = _PIO_STDIN(interp);
   goto NEXT();
 }
 
 inline op getstdout(out PMC) :base_io {
-  $1 = PIO_STDOUT(interp);
+  $1 = _PIO_STDOUT(interp);
   goto NEXT();
 }
 
 inline op getstderr(out PMC) :base_io {
-  $1 = PIO_STDERR(interp);
+  $1 = _PIO_STDERR(interp);
   goto NEXT();
 }
 
@@ -132,12 +132,12 @@
 =cut
 
 inline op setstdout(invar PMC) :base_io {
-        PIO_STDOUT(interp) = $1;
+        _PIO_STDOUT(interp) = $1;
         goto NEXT();
 }
 
 inline op setstderr(invar PMC) :base_io {
-        PIO_STDERR(interp) = $1;
+        _PIO_STDERR(interp) = $1;
         goto NEXT();
 }
 
@@ -226,7 +226,7 @@
 op print(in STR) :base_io {
   STRING * const s = $1;
   if (s && string_length(interp, s)) {
-    PIO_putps(interp, PIO_STDOUT(interp), s);
+    PIO_putps(interp, _PIO_STDOUT(interp), s);
   }
   goto NEXT();
 }
@@ -235,7 +235,7 @@
   PMC * const p = $1;
   STRING * const s = (VTABLE_get_string(interp, p));
   if (s) {
-    PIO_putps(interp, PIO_STDOUT(interp), s);
+    PIO_putps(interp, _PIO_STDOUT(interp), s);
   }
   goto NEXT();
 }
@@ -267,7 +267,7 @@
 op printerr(in STR) :base_io {
   STRING * const s = $1;
   if (s && string_length(interp, s)) {
-    PIO_putps(interp, PIO_STDERR(interp), s);
+    PIO_putps(interp, _PIO_STDERR(interp), s);
   }
   goto NEXT();
 }
@@ -276,7 +276,7 @@
   PMC * const p = $1;
   STRING * const s = (VTABLE_get_string(interp, p));
   if (s) {
-    PIO_putps(interp, PIO_STDERR(interp), s);
+    PIO_putps(interp, _PIO_STDERR(interp), s);
   }
   goto NEXT();
 }
@@ -351,7 +351,7 @@
 =cut
 
 op read(out STR, in INT) :base_io {
-  $1 = PIO_reads(interp, PIO_STDIN(interp), (size_t)$2);
+  $1 = PIO_reads(interp, _PIO_STDIN(interp), (size_t)$2);
   goto NEXT();
 }
 
@@ -405,7 +405,7 @@
   STRING ** const s = &$1;
 
   *s = NULL;
-  PIO_peek(interp, PIO_STDIN(interp), s);
+  PIO_peek(interp, _PIO_STDIN(interp), s);
   goto NEXT();
 }
 

Reply via email to