GSoC/GCI Archive
Google Code-in 2010 Parrot Foundation and The Perl Foundation

Move method get_fd() from FileHandle to Handle

completed by: Fernando Brito

mentors: whiteknight

Task Description: The FileHandle PMC type allows the Parrot virtual machine to access files on the hard disk. This type inherits from the Handle type, which is an abstract parent class of all IO types. There are other types which inherit from Handle, including StringHandle and Socket. All of these types should behave similarly.

The FileHandle type has a method called get_fd(), which returns the system-dependent file descriptor. This is typically an integer, or can be converted to an integer. This method should be moved to the Handle class, and inherited by all Handle types (StringHandle and Socket).

Steps to complete:

  1. Fork the parrot/parrot repository on Github
  2. Move the get_fd() method from src/pmc/filehandle.pmc to src/pmc/handle.pmc, including all documentation.
  3. Override get_fd in src/pmc/stringhandle.pmc to always return -1 unconditionally
  4. Add a test for the method to t/pmc/stringhandle.pmc, to show that it always returns -1
  5. Add a test for the method in t/pmc/socket.pmc to show that the socket identifier is returned (and is NOT -1)
  6. Build parrot and run all tests to ensure that nothing has broken.
  7. Open a pull request on github to have your changes merged back in to Parrot

Benefits: Many changes are planned in the near- and medium-term future for Parrots IO system. Creating a common interface for all IO types to share will help to simplify logic and make future development tasks much easier