This page details all the necessary improvements to Parrot's I/O subsystem that need to be made. If you work on any of these tasks, make sure you remove it from the list when you're done.
Here are some details of a major refactor proposed by Whiteknight which will probably be pursued soon:
io_vtablefor dispatching operations to the subsystem API
These are some older TODO items which will be covered by this refactor:
peek(), but sockets or pipes usually don't use output buffering.
FileHandle. Create a
PipePMC type. Alternatively, we could deprecate opening pipes to external commands via
Handle. Be able to inherit it from all other PMC types. Include buffering-related
METHOD_buffer_size(). We should keep the buffering logic at a C-level. All that is needed for now is to pass the buffering functions a pair of read/write callbacks for files and sockets (e.g.
send()). (Also, maybe add a flag to the buffer_type and buffer_size methods to specify whether this is for input-only or output-only or both, (default)).
PCCINVOKE(). Method calls on I/O PMC's should call the API functions, not the other way around.
Pipeinto the I/O API. Refactor the I/O API to be more unified.
Parrot_io_putps(). Unify where possible and remove duplicate code.
Here are a list of previously-mentioned TODO items which become unnecessary in this refactor:
from theopen()` method of each
GET_ATTRmacros in src/io/filehandle.c so all functions will be able to handle subclasses.
ATTR_encoding(), etc.) from
Handle. Be able to inherit it from all other PMC types. The encoding logic is encapsulated in the string code quite well now, so we should have the
StringHandlePMC handle encodings on its own. Only the encoding attribute should be shared.
Parrot_io_make_offset_pmc(). If they do not need to be in src/io/api.c, move them elsewhere, possibly src/io/filehandle.c.
say()stringify the same way (see http://rt.perl.org/rt3/Ticket/Display.html?id=55196).
%sconversion specification in the
printf()-like functions do not handle null C strings well.
PARROT_NETWORKING_SUPPORT(see TT #534).
Following are various I/O related RT tickets:
StreamBufferPMC to abstract away buffering details. This would allow
SocketPMC's to be subclassed more easily and give all I/O types easy access to buffering.
Parrot_io_printf()should output to Parrot's standard output PMC, not
Parrot_io_eprintf()should output to Parrot's standard error PMC, not
OSProcessPMC that works like this (see IPC::Open3).
proc = new 'OSProcess' # The 'flags' argument is something like EXEC_STDIN | EXEC_STDOUT | EXEC_STDERR proc.'exec'(command, args, flags) # Get stdin of exec()'ed process for writing w_handle = proc.'stdin'() # Get stdout of exec()'ed process for reading r_handle = proc.'stdout'()
StringHandleto be a proper subclass of
STDERR. These three need to be ported to the new system.
FilehandlePMC's should be marked with their character set and encoding, similar to strings.
FileHandlePMC as a core filehandle object which can be subclassed by various HLL's.
#ifdefdirective on platform-specific sections.
PIO_*functions to 'Parrot_io_*'. Since the implementation is completely changing, it's better to create new functions with the new names than to change the names of existing functions.
pioctlopcode and fixed related documentation (see http://rt.perl.org/rt3/Ticket/Display.html?id=48589).
FileHandlethat provides the same interface but to a string instead of a filehandle.
close() anddisconnect() method to the
readline(), etc). Internally, these methods should direct to similar functions in src/io/api.c.
Handleso that it can be inherited by
Socketcan inherit from (but not
SelectPMC, maybe have a look at libevent. (It's a dynpmc)
StreamDescriptorPMC to abstract away system-dependent I/O descriptors. This would allow
SocketPMC's to be subclassed more easily. (Mostly done as 'Handle' PMC)