Index: MANIFEST
===================================================================
RCS file: /cvs/public/parrot/MANIFEST,v
retrieving revision 1.405
diff -u -r1.405 MANIFEST
--- MANIFEST	20 Aug 2003 11:01:35 -0000	1.405
+++ MANIFEST	21 Aug 2003 11:43:47 -0000
@@ -1348,6 +1348,7 @@
 io/TODO                                           [main]doc
 io/io.c                                           []
 io/io_buf.c                                       []
+io/io_private.h                                   []
 io/io_stdio.c                                     []
 io/io_unix.c                                      []
 io/io_win32.c                                     []
Index: classes/parrotio.pmc
===================================================================
RCS file: /cvs/public/parrot/classes/parrotio.pmc,v
retrieving revision 1.7
diff -u -r1.7 parrotio.pmc
--- classes/parrotio.pmc	16 Aug 2003 15:28:28 -0000	1.7
+++ classes/parrotio.pmc	21 Aug 2003 11:43:47 -0000
@@ -14,6 +13,9 @@
 
 #include "parrot/parrot.h"
 
+/* This class is actually part of the io subsystem */
+#include "../io/io_private.h"
+
 static void
 enter_nci_method(struct Parrot_Interp *interpreter, PMC *method_table,
 		 void *func, const char *name, const char *proto)
Index: config/gen/makefiles/root.in
===================================================================
RCS file: /cvs/public/parrot/config/gen/makefiles/root.in,v
retrieving revision 1.112
diff -u -r1.112 root.in
--- config/gen/makefiles/root.in	16 Aug 2003 17:44:19 -0000	1.112
+++ config/gen/makefiles/root.in	21 Aug 2003 11:43:47 -0000
@@ -445,15 +445,15 @@
 
 interpreter$(O) : interpreter.c $(GENERAL_H_FILES) ${jit_h}
 
-io/io$(O) : $(GENERAL_H_FILES)
+io/io$(O) : $(GENERAL_H_FILES) io/io_private.h
 
-io/io_buf$(O) : $(GENERAL_H_FILES)
+io/io_buf$(O) : $(GENERAL_H_FILES) io/io_private.h
 
-io/io_unix$(O) : $(GENERAL_H_FILES)
+io/io_unix$(O) : $(GENERAL_H_FILES) io/io_private.h
 
-io/io_win32$(O) : $(GENERAL_H_FILES)
+io/io_win32$(O) : $(GENERAL_H_FILES) io/io_private.h
 
-io/io_stdio$(O) : $(GENERAL_H_FILES)
+io/io_stdio$(O) : $(GENERAL_H_FILES) io/io_private.h
 
 memory$(O) : $(GENERAL_H_FILES)
 
Index: include/parrot/io.h
===================================================================
RCS file: /cvs/public/parrot/include/parrot/io.h,v
retrieving revision 1.38
diff -u -r1.38 io.h
--- include/parrot/io.h	12 Aug 2003 18:56:49 -0000	1.38
+++ include/parrot/io.h	21 Aug 2003 11:43:47 -0000
@@ -7,6 +7,7 @@
  *  Data Structure and Algorithms:
  *  History:
  *      Originally written by Melvin Smith
+ *      2003-08-18: Internal structures moved to io/io_private.h
  *  Notes:
  *  References:
  *      Perl6 RFCs (14,30,47,60,186,239,321,345,350)
@@ -82,43 +83,10 @@
 };
 /* &end_gen */
 
-/* IO object flags */
-#define PIO_F_READ      00000001
-#define PIO_F_WRITE     00000002
-#define PIO_F_APPEND    00000004
-#define PIO_F_TRUNC     00000010
-#define PIO_F_EOF       00000020
-#define PIO_F_FILE      00000100
-#define PIO_F_PIPE      00000200
-#define PIO_F_SOCKET    00000400
-#define PIO_F_CONSOLE   00001000        /* A terminal                   */
-#define PIO_F_LINEBUF   00010000        /* Flushes on newline           */
-#define PIO_F_BLKBUF    00020000
-#define PIO_F_SHARED    00100000        /* Stream shares a file handle  */
-
-/* Buffer flags */
-#define PIO_BF_MALLOC   00000001        /* Buffer malloced              */
-#define PIO_BF_READBUF  00000002        /* Buffer is read-buffer        */
-#define PIO_BF_WRITEBUF 00000004        /* Buffer is write-buffer       */
-
-
-#define PIO_ACCMODE     0000003
-#define PIO_DEFAULTMODE DEFAULT_OPEN_MODE
-#define PIO_UNBOUND     (size_t)-1
-
 /* This is temporary until subs/code refs are done..*/
 typedef void *DummyCodeRef;
 
 
-struct _ParrotIOBuf {
-    INTVAL flags;               /* Buffer specific flags        */
-    size_t size;
-    unsigned char *startb;      /* Start of buffer              */
-    unsigned char *endb;        /* End of buffer                */
-    unsigned char *next;        /* Current read/write pointer   */
-};
-
-
 #ifdef PIO_OS_WIN32
 typedef Parrot_WIN32_HANDLE PIOHANDLE;
 typedef Parrot_OFF_T PIOOFF_T;
@@ -137,22 +105,8 @@
 typedef struct _ParrotIOLayerAPI ParrotIOLayerAPI;
 typedef struct _ParrotIOLayer ParrotIOLayer;
 typedef struct _ParrotIOFilter ParrotIOFilter;
-typedef struct _ParrotIOBuf ParrotIOBuf;
 typedef struct _ParrotIO ParrotIO;
 typedef struct _ParrotIOData ParrotIOData;
-typedef PMC **ParrotIOTable;
-
-struct _ParrotIO {
-    PIOHANDLE fd;               /* Low level OS descriptor      */
-    INTVAL mode;                /* Read/Write/etc.              */
-    INTVAL flags;               /* Da flags                     */
-    PIOOFF_T fsize;             /* Current file size            */
-    PIOOFF_T fpos;              /* Current real file pointer    */
-    PIOOFF_T lpos;              /* Last file position           */
-    ParrotIOBuf b;              /* Buffer structure             */
-    ParrotIOLayer *stack;
-    /* ParrotIOFilter * filters; */
-};
 
 struct _ParrotIOLayer {
     void *self;                 /* Instance specific data       */
@@ -163,11 +117,6 @@
     ParrotIOLayer *down;
 };
 
-struct _ParrotIOData {
-    ParrotIOTable table;
-    ParrotIOLayer *default_stack;
-    PMC *method_table;
-};
 
 
 
@@ -176,9 +125,6 @@
 #define PIO_UPLAYER(x)     x->up
 #define GET_INTERP_IO(i)   (((ParrotIOData*)i->piodata)->default_stack)
 #define GET_INTERP_IOD(i)  ((ParrotIOData *)i->piodata)
-#define PIO_STDIN(i)   (((ParrotIOData*)i->piodata)->table[PIO_STDIN_FILENO])
-#define PIO_STDOUT(i)  (((ParrotIOData*)i->piodata)->table[PIO_STDOUT_FILENO])
-#define PIO_STDERR(i)  (((ParrotIOData*)i->piodata)->table[PIO_STDERR_FILENO])
 
 /*
  * Terminal layer can't be pushed on top of other layers;
@@ -306,8 +252,6 @@
 
 extern struct PMC *new_io_pmc(struct Parrot_Interp *, ParrotIO *);
 extern void free_io_header(ParrotIO *);
-extern ParrotIOTable alloc_pio_array(int);
-extern int realloc_pio_array(ParrotIOTable *, int);
 extern ParrotIO *PIO_new(struct Parrot_Interp *, INTVAL, INTVAL, INTVAL);
 extern void PIO_destroy(theINTERP, PMC *io);
 
@@ -360,6 +304,11 @@
 PIOOFF_T PIO_make_offset(INTVAL offset);
 PIOOFF_T PIO_make_offset32(INTVAL hi, INTVAL lo);
 PIOOFF_T PIO_make_offset_pmc(theINTERP, PMC *pmc);
+
+/* the internal system redefines them as macros */
+extern PMC *PIO_STDIN(theINTERP);
+extern PMC *PIO_STDOUT(theINTERP);
+extern PMC *PIO_STDERR(theINTERP);
 
 #endif
 
Index: io/io.c
===================================================================
RCS file: /cvs/public/parrot/io/io.c,v
retrieving revision 1.50
diff -u -r1.50 io.c
--- io/io.c	9 Aug 2003 07:22:22 -0000	1.50
+++ io/io.c	21 Aug 2003 11:43:47 -0000
@@ -8,7 +8,7 @@
  *      (io_unix, io_win32, io_buf, io_stdio, io_utf8, etc.)
  *  Data Structure and Algorithms:
  *      Uses the IO PMC defined in io.h
- *      Uses ParrotIO structs in io.h
+ *      Uses ParrotIO structs in io_private.h
  *  History:
  *      Initially written by Melvin Smith
  *  Notes:
@@ -20,6 +20,7 @@
  */
 
 #include "parrot/parrot.h"
+#include "io_private.h"
 
 #include <stdarg.h>
 
@@ -786,6 +787,28 @@
 
     /* XXX boe: increase size of the fdtable */
     return -1;
+}
+
+/* Implemenation of the PIO_STD* functions on basis of the macro */
+/* Protect prototype from expansion with identity macro */
+#define ID(a) a
+
+PMC *
+PIO_STDIN ID((theINTERP))
+{
+    return PIO_STDIN(interpreter);
+}
+
+PMC *
+PIO_STDOUT ID((theINTERP))
+{
+    return PIO_STDOUT(interpreter);
+}
+
+PMC *
+PIO_STDERR ID((theINTERP))
+{
+    return PIO_STDERR(interpreter);
 }
 
 void
Index: io/io_buf.c
===================================================================
RCS file: /cvs/public/parrot/io/io_buf.c,v
retrieving revision 1.9
diff -u -r1.9 io_buf.c
--- io/io_buf.c	1 Aug 2003 14:50:56 -0000	1.9
+++ io/io_buf.c	21 Aug 2003 11:43:47 -0000
@@ -14,6 +14,7 @@
  */
 
 #include "parrot/parrot.h"
+#include "io_private.h"
 
 /* Defined at bottom */
 extern ParrotIOLayerAPI pio_buf_layer_api;
Index: io/io_private.h
===================================================================
RCS file: io/io_private.h
diff -N io/io_private.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ io/io_private.h	21 Aug 2003 11:43:47 -0000
@@ -0,0 +1,97 @@
+/* io.h
+ *  Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
+ *  CVS Info
+ *     $Id:$
+ *  Overview:
+ *      Internal Details of the Parrot IO subsystem
+ *  Data Structure and Algorithms:
+ *  History:
+ *      Internal Definitions moved from include/parrot/io.h
+ *  Notes:
+ *      TODO: move the Layer structure to here also
+ *  References:
+ *      Perl6 RFCs (14,30,47,60,186,239,321,345,350)
+ *      Some ideas and goals from Perl5.7 and Nick Ing-Simmons' work
+ *      Some ideas from AT&T SFIO
+ */
+
+#if !defined(PARROT_IO_PRIVATE_H_GUARD)
+#define PARROT_IO_PRIVATE_H_GUARD
+
+#define PARROT_IN_IO 1
+
+#include <parrot/io.h>
+
+/* IO object flags */
+#define PIO_F_READ      00000001
+#define PIO_F_WRITE     00000002
+#define PIO_F_APPEND    00000004
+#define PIO_F_TRUNC     00000010
+#define PIO_F_EOF       00000020
+#define PIO_F_FILE      00000100
+#define PIO_F_PIPE      00000200
+#define PIO_F_SOCKET    00000400
+#define PIO_F_CONSOLE   00001000        /* A terminal                   */
+#define PIO_F_LINEBUF   00010000        /* Flushes on newline           */
+#define PIO_F_BLKBUF    00020000
+#define PIO_F_SHARED    00100000        /* Stream shares a file handle  */
+
+/* Buffer flags */
+#define PIO_BF_MALLOC   00000001        /* Buffer malloced              */
+#define PIO_BF_READBUF  00000002        /* Buffer is read-buffer        */
+#define PIO_BF_WRITEBUF 00000004        /* Buffer is write-buffer       */
+
+
+#define PIO_ACCMODE     0000003
+#define PIO_DEFAULTMODE DEFAULT_OPEN_MODE
+#define PIO_UNBOUND     (size_t)-1
+
+typedef struct _ParrotIOBuf ParrotIOBuf;
+typedef PMC **ParrotIOTable;
+
+struct _ParrotIOBuf {
+    INTVAL flags;               /* Buffer specific flags        */
+    size_t size;
+    unsigned char *startb;      /* Start of buffer              */
+    unsigned char *endb;        /* End of buffer                */
+    unsigned char *next;        /* Current read/write pointer   */
+};
+
+struct _ParrotIO {
+    PIOHANDLE fd;               /* Low level OS descriptor      */
+    INTVAL mode;                /* Read/Write/etc.              */
+    INTVAL flags;               /* Da flags                     */
+    PIOOFF_T fsize;             /* Current file size            */
+    PIOOFF_T fpos;              /* Current real file pointer    */
+    PIOOFF_T lpos;              /* Last file position           */
+    ParrotIOBuf b;              /* Buffer structure             */
+    ParrotIOLayer *stack;
+    /* ParrotIOFilter * filters; */
+};
+
+struct _ParrotIOData {
+    ParrotIOTable table;
+    ParrotIOLayer *default_stack;
+    PMC *method_table;
+};
+
+/* functions internal to the subsystem */
+extern ParrotIOTable alloc_pio_array(int);
+extern int realloc_pio_array(ParrotIOTable *, int);
+
+/* redefine PIO_STD* for internal use */
+#define PIO_STDIN(i)   (((ParrotIOData*)i->piodata)->table[PIO_STDIN_FILENO])
+#define PIO_STDOUT(i)  (((ParrotIOData*)i->piodata)->table[PIO_STDOUT_FILENO])
+#define PIO_STDERR(i)  (((ParrotIOData*)i->piodata)->table[PIO_STDERR_FILENO])
+
+#endif /* !defined(PARROT_IO_PRIVATE_H_GUARD) */
+
+/*
+ * Local variables:
+ * c-indentation-style: bsd
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vim: expandtab shiftwidth=4:
+ */
Index: io/io_stdio.c
===================================================================
RCS file: /cvs/public/parrot/io/io_stdio.c,v
retrieving revision 1.26
diff -u -r1.26 io_stdio.c
--- io/io_stdio.c	9 Aug 2003 07:22:22 -0000	1.26
+++ io/io_stdio.c	21 Aug 2003 11:43:47 -0000
@@ -17,6 +17,7 @@
 
 #include <stdio.h>
 #include "parrot/parrot.h"
+#include "io_private.h"
 
 #ifdef PIO_OS_STDIO
 
Index: io/io_unix.c
===================================================================
RCS file: /cvs/public/parrot/io/io_unix.c,v
retrieving revision 1.30
diff -u -r1.30 io_unix.c
--- io/io_unix.c	16 Aug 2003 15:28:30 -0000	1.30
+++ io/io_unix.c	21 Aug 2003 11:43:47 -0000
@@ -16,6 +16,7 @@
  */
 
 #include "parrot/parrot.h"
+#include "io_private.h"
 
 #ifdef PIO_OS_UNIX
 
Index: io/io_win32.c
===================================================================
RCS file: /cvs/public/parrot/io/io_win32.c,v
retrieving revision 1.28
diff -u -r1.28 io_win32.c
--- io/io_win32.c	12 Aug 2003 10:09:39 -0000	1.28
+++ io/io_win32.c	21 Aug 2003 11:43:47 -0000
@@ -17,6 +17,7 @@
 #endif
 
 #include "parrot/parrot.h"
+#include "io_private.h"
 
 #ifdef PIO_OS_WIN32
 

Reply via email to