Add Read and Readline methods to Socket PMC
completed by: Fernando Brito
Task Description: Parrot's IO system has several major improvements scheduled in the coming months. Before those can happen, the existing system needs to be cleaned up significantly. Code files in src/io/ directory implement much of the low-level IO logic, while special "Handle" object types in src/pmc/ directory provide specific implementations that the user will interact with. These include "FileHandle" (for interacting with files on disk), Socket (for communicating over a network) and StringHandle (for interacting with a string as if it were a file). All three of these PMC types inherit from the Handle type, and should have read and readline methods.
Steps to complete:
- Create a fork of parrot/parrot on github
- Move the read and readline methods from src/pmc/filehandle.pmc to src/pmc/handle.pmc
- Add a new branch to src/io/api.c:Parrot_io_reads() to handle the case of enum_class_Socket. Move the guts of the recv method in src/pmc/socket.pmc into the new branch
- Add a branch to src/io/api.c:Parrot_io_readline to handle the case of enum_class_Socket. We aren't ready to implement this, so throw an EXCEPTION_PIO_ERROR exception. Parrot_ex_throw_from_c_args, etc
- Change the recv method in src/pmc/socket.pmc to call Parrot_io_reads
- Delete the read and readline methods from FileHandle and StringHandle. They should be inherited from Handle
- Build parrot and run all tests (make fulltest), fixing any errors that pop up
- Add a new test to t/pmc/socket.t to show that it has the read and readline methods. The read method should work the same as recv (feel free to copy the test). the readline method should throw an exception.
- open a pull request on github to get your changes merged in.