[svn:parrot] r39017 - in trunk/src: io pmc
NotFound at svn.parrot.org
NotFound at svn.parrot.org
Thu May 21 18:14:23 UTC 2009
Author: NotFound
Date: Thu May 21 18:14:22 2009
New Revision: 39017
URL: https://trac.parrot.org/parrot/changeset/39017
Log:
[pio] new attribute process_id in filehandle pmc
Modified:
trunk/src/io/unix.c
trunk/src/pmc/filehandle.pmc
Modified: trunk/src/io/unix.c
==============================================================================
--- trunk/src/io/unix.c Thu May 21 16:45:50 2009 (r39016)
+++ trunk/src/io/unix.c Thu May 21 18:14:22 2009 (r39017)
@@ -346,13 +346,11 @@
if (close(file_descriptor) != 0)
result = errno;
- /* Pipes reuse the file_size attribute to store the child
- * process pid.
- * Wait for the child after closing the
+ /* Wait for the child after closing the
* handle, to let it notice the closing and finish */
if (flags & PIO_F_PIPE) {
int status;
- waitpid(Parrot_io_get_file_size(interp, filehandle), &status, 0);
+ waitpid(VTABLE_get_integer_keyed_int(interp, filehandle, 0), &status, 0);
}
}
Parrot_io_set_os_handle(interp, filehandle, -1);
@@ -682,7 +680,7 @@
io = filehandle;
/* Save the pid of the child, we'll wait for it when closing */
- Parrot_io_set_file_size(interp, io, pid);
+ VTABLE_set_integer_keyed_int(interp, io, 0, pid);
if (f_read) {
/* close this writer's end of pipe */
Modified: trunk/src/pmc/filehandle.pmc
==============================================================================
--- trunk/src/pmc/filehandle.pmc Thu May 21 16:45:50 2009 (r39016)
+++ trunk/src/pmc/filehandle.pmc Thu May 21 18:14:22 2009 (r39017)
@@ -38,7 +38,8 @@
ATTR STRING *mode; /* The mode string used in open */
ATTR STRING *encoding; /* The encoding for read/write */
ATTR PIOHANDLE os_handle; /* Low level OS descriptor */
- ATTR PIOOFF_T file_size; /* Current file size - pipe pid */
+ ATTR INTVAL process_id; /* Child process on pipes */
+ ATTR PIOOFF_T file_size; /* Current file size */
ATTR PIOOFF_T file_pos; /* Current real file pointer */
ATTR PIOOFF_T last_pos; /* Last file position */
ATTR size_t buffer_size; /* Buffer size */
@@ -48,6 +49,12 @@
ATTR unsigned char *buffer_next; /* Current read/write pointer */
/*
+ * Using INTVAL for process_id is a temporary solution.
+ * We may need to define a custom type to store it in a platform
+ * dependant way.
+ */
+
+/*
=item C<void init()>
@@ -61,29 +68,30 @@
Parrot_FileHandle_attributes *data_struct =
mem_allocate_typed(Parrot_FileHandle_attributes);
- PMC_data(SELF) = data_struct;
- data_struct->flags = 0;
- data_struct->mode = NULL;
- data_struct->encoding = NULL;
- data_struct->filename = NULL;
- data_struct->file_size = 0;
- data_struct->file_pos = piooffsetzero;
- data_struct->last_pos = piooffsetzero;
- data_struct->buffer_flags = 0;
- data_struct->buffer_size = 0;
- data_struct->buffer_start = NULL;
- data_struct->buffer_end = NULL;
- data_struct->buffer_next = NULL;
+ PMC_data(SELF) = data_struct;
+ data_struct->flags = 0;
+ data_struct->filename = NULL;
+ data_struct->mode = NULL;
+ data_struct->encoding = NULL;
+ data_struct->process_id = 0;
+ data_struct->file_size = 0;
+ data_struct->file_pos = piooffsetzero;
+ data_struct->last_pos = piooffsetzero;
+ data_struct->buffer_size = 0;
+ data_struct->buffer_flags = 0;
+ data_struct->buffer_start = NULL;
+ data_struct->buffer_end = NULL;
+ data_struct->buffer_next = NULL;
/* Initialize the os_handle to the platform-specific value for closed. */
#ifdef PIO_OS_WIN32
- data_struct->os_handle = (PIOHANDLE)INVALID_HANDLE_VALUE;
+ data_struct->os_handle = (PIOHANDLE)INVALID_HANDLE_VALUE;
#endif
#ifdef PIO_OS_UNIX
- data_struct->os_handle = (PIOHANDLE)-1;
+ data_struct->os_handle = (PIOHANDLE)-1;
#endif
#ifdef PIO_OS_STDIO
- data_struct->os_handle = (PIOHANDLE)NULL;
+ data_struct->os_handle = (PIOHANDLE)NULL;
#endif
PObj_custom_mark_SET(SELF);
@@ -160,6 +168,50 @@
/*
+=item C<INTVAL get_integer_keyed_int(INTVAL key)>
+
+Shortcut to get the value of some attributes.
+For internal usage only, subject to change without notice.
+
+=cut
+
+*/
+
+ VTABLE INTVAL get_integer_keyed_int(INTVAL key) {
+ INTVAL result;
+ switch(key) {
+ case 0:
+ GET_ATTR_process_id(INTERP, SELF, result);
+ break;
+ default:
+ result = 0;
+ }
+ return result;
+ }
+
+/*
+
+=item C<void set_integer_keyed_int(INTVAL key, INTVAL value)>
+
+Shortcut to set the value of some attributes
+For internal usage only, subject to change without notice.
+
+=cut
+
+*/
+
+ VTABLE void set_integer_keyed_int(INTVAL key, INTVAL value) {
+ switch(key) {
+ case 0:
+ SET_ATTR_process_id(INTERP, SELF, value);
+ break;
+ default:
+ break;
+ }
+ }
+
+/*
+
=item C<INTVAL get_bool()>
Returns whether the FileHandle has reached the end of the file.
More information about the parrot-commits
mailing list