Version 17 (modified by whiteknight, 11 years ago)



  • Separate pipe-related logic out of FileHandle. Create a Pipe PMC type.
  • Add a "Close" or "Disconnect" method to the Socket PMC
  • Create a "Select" PMC
  • Add an improved file-like API to the Socket PMC (open, close, readline, etc). Internally, these methods should direct to similar functions in src/io/api.c
  • Move buffering logic from FileHandle and StringHandle to Handle. Be able to inherit it from all other PMC types. (include buffering-related ATTRs, METHOD_buffer_type, and METHOD_buffer_size)
  • Move METHOD_get_fd from FileHandle to Handle. Be able to inherit this into Socket, Pipe, etc. (Set up as GCI task)
  • Move encoding logic (METHOD_encoding, ATTR_encoding, etc) from StringHandle and FileHandle to Handle. Be able to inherit it from all other PMC types.
  • Unify logic wherever possible so multiple IO types can share
  • Use GET_ATTR macros in src/io/filehandle.c so all functions will be able to handle subclasses


  • Change IO API to not use PCCINVOKE calls. Method calls on IO PMCs should call the API functions, not the other way around
  • Unify the codepaths for Socket and Pipe into the IO API. Refactor the IO API to be more unified.
  • Add externally-visible socket functions to src/io/api.c from src/io/socket_*.c
  • Rename Parrot_io_new_pmc to Parrot_io_new_filehandle_pmc
  • Add Pipe and Socket logic to Parrot_io_open. Call into Parrot_io_open from the "Open" method of each
  • Add Pipe and Socket logic to Parrot_io_close.
  • Add Pipe and Socket logic to Parrot_io_is_closed.
  • Add Pipe and Socket logic to Parrot_io_flush
  • Add Pipe and Socket logic to Parrot_io_reads
  • Add Pipe and Socket logic to Parrot_io_readline
  • Error handling: Figure out what happens if an unsuitable PMC type is passed to Parrot_io_seek, Parrot_io_tell, Parrot_io_eof, Parrot_io_is_tty
  • Extract a sane buffering API.
  • Cleanup Parrot_io_write, Parrot_io_puts, Parrot_io_putps. Unify where possible and remove duplicated effort

Misc Cleanup

  • Add an src/io/pipe.c and src/io/stringhandle.c files for type-specific logic similar to src/io/filehandle.c
  • Make sure the functions in src/io/buffer.c will work with all buffer-enabled PMC types
  • Evaluate Parrot_io_make_offset, Parrot_io_make_offset32, Parrot_io_make_offset_pmc. If they do not need to be in src/io/api.c, move them elsewhere (src/io/filehandle.c?)
  • Make 'print' and 'say' stringify the same way. (See
  • Change 'fprintf' to 'PIO_fprintf' where relevant.
  • Plain %s in parrot printf-alike functions do not handle NULL C strings well. Fix.
  • Further optimize where possible.
  • Move src/io/filehandle.c:Parrot_io_clear_buffer to src/io/buffer.c
  • Move src/io/filehandle.c:Parrot_io_is_encoding to src/io/core.c
  • Rename PARROT_NET_DEVEL to PARROT_NETWORKING_SUPPORT. Cleanup it's uses (#534)

Asynchronous IO

various IO related RT tickets


  • Create "StreamDescriptor" PMC type to abstract out system-dependent IO descriptors. Would allow FileHandles and Sockets to be subclassed more easily
  • Create a "StreamBuffer" PMC type to abstract out buffering details. Would allow FileHandles and Sockets to be subclassed more easily, and give all IO types easy access to buffering
  • Parrot_io_printf should output to Parrot's standard output PMC, not stdout
  • Parrot_io_eprintf should output to Parrot's standard error PMC, not stderr


  • Create an abstract "IOHandle" class
  • Abstract relevant API code from FileHandle and Socket into IOHandle
  • Fix StringHandle to be a proper subclass of IOHandle
  • Rip out the layers structures and macros. (After the migration is complete.)
  • Remove src/io/io_mmap.c, unused and not useful.
  • Convert I/O layers to I/O objects. (allison)
  • src/io/io_unix.c is the guts of most I/O on most platforms. src/io/io_win32.c is Windows. src/io/io_stdio.c is STDIN, STDOUT, and STDERR. These three need to be ported to the new system. (allison)
  • src/io/io_utf8.c is really the wrong way to go about it. Filehandles should be marked with character set and encoding similar to strings. (allison)
  • Create a PMC named "FileHandle", as a core file handle object, which can be subclassed by various HLLs. (allison)
  • Continue to support different I/O operations on different platforms, using C '#ifdef's on platform-specific sections. (allison)
  • All 'PIO_*' functions change to 'Parrot_io_*'. (Since the implementation is completely changing, better to create new functions with the new names than to change the names of existing functions.) (allison)
  • Remove deprecated opcode 'pioctl', and fix related documentation. (See
  • Decide if we plan to use AIO before the 1.0 release. (See
  • Remove src/io/io_passdown.c and src/io/io_layers.c, purely implementation artifacts of I/O layers implementation.
  • Change src/io/io_string.c to a subclass of FileHandle PMC, that provides the same interface, but to a string instead of a file handle.
  • All IO PMC types should inherit from Handle