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
- Create a fork of parrot.git on github.com
- Add the new function Parrot_api_pmc_box_number, following formatting and documentation cues from the file
- run "make headerizer" to update header files with the new function name
- Clean up Parrot_api_pmc_box_integer
- 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.
- Build parrot and run it's test suite (make test) to verify that things still work
- Create a Github pull request (button on the upper right of your fork) to have your changes incorporated into the master repository
Benefits
- 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
- C Programming