GSoC/GCI Archive
Google Code-in 2011 Parrot Foundation

Add new function Parrot_api_pmc_box_number

completed by: Pawel Nowak

mentors: Andrew Whitworth

Task Description

In the file src/embed/pmc.c there is a note "TODO: box float". In Parrot, "boxing" is where a native type like an integer or a floating point number is wrapped up in an object. In Parrot, objects are called "PMC". The file src/embed/pmc.c is part of Parrot's embedding API. Functions here are used by other programs that link to Parrot.

Add in a new embedding function Parrot_api_pmc_box_number to mirror what happens in Parrot_api_pmc_box_integer, but with FLOATVAL instead of INTVAL. Use the function Parrot_pmc_box_number from src/pmc.c to implement the bulk of the logic.

Add a test for the new function in t/src/embed/pmc.t

Also, Parrot_api_pmc_box_integer does not use Parrot_pmc_box_integer, but instead duplicates some logic from src/pmc.c:Parrot_pmc_box_integer. De-duplicate the logic and call Parrot_pmc_box_integer from Parrot_api_pmc_box_integer.

Steps To Complete This Task

  1. Create a fork of parrot.git on github.com
  2. Add the new function Parrot_api_pmc_box_number, following formatting and documentation cues from the file
  3. run "make headerizer" to update header files with the new function name
  4. Clean up Parrot_api_pmc_box_integer
  5. Add a test for the new Parrot_api_pmc_box_number function in t/src/embed/pmc.c. Feel free to copy code from other tests in the same file.
  6. Build parrot and run it's test suite (make test) to verify that things still work
  7. Create a Github pull request (button on the upper right of your fork) to have your changes incorporated into the master repository

Benefits

  1. Parrot's embedding API is the set of routines that other programs use to embed libparrot. The more complete and rich this interface is, the easier it will be to use Parrot in a variety of places.

Requirements

  1. C Programming

Additional Links