Refactor close() method behavior on IO handle types
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 inherit from the abstract type Handle and provide their own close() methods. This needs to be fixed.
Steps to complete:
- Create a fork of parrot/parrot on github
- Move the close() METHOD from src/pmc/filehandle.pmc to src/pmc/handle.pmc, including documentation.
- In the file src/io/api.c, the function Parrot_io_close() needs to be updated to support Socket and StringHandle types
- Copy most of the internal logic from the close method in src/pmc/socket.pmc into a new if-branch in Parrot_io_close. A PMC is a socket if it's base_type is enum_class_Socket (See the enum_class_FileHandle example above for inspiration. pmc->vtable->base_type == enum_class_Socket, etc)
- Remove the close method from src/pmc/socket.pmc
- Copy most of the internal logic from the close method in src/pmc/stringhandle.pmc into a new if-branch in Parrot_io_close. A PMC is a StringHandle if it's base_type is enum_class_StringHandle
- remove the close method from src/pmc/stringhandle.pmc
- Build parrot and run all tests (make fulltest), fixing any errors that pop up
- You may occasionally have to run "make headerizer" when header definitions are changed
- open a pull request on github to get your changes merged in.