Parrot-GMP aims to provide low-level bindings to the GMP library. Currently all Integer functions and the associated random number functions are covered. Eventually there will be full coverage of the library.
Currently examples/basic.winxed shows a very basic usage of GMP inside Parrot.
There is inline function-level documentation (straight from the GMP manual) included, use
perldoc src/GMP/Integer.winxed to read it.
Using the PIR functions will allow you to shoot yourself in the foot while segfaulting because that is fast. The PIR functions do no type checking and match the internal naming style of GMP ('__gmpz_add_ui'). The Winxed convenience class does basic type checking and matches the documentation naming style of the GMP functions ('mpz_add_ui').
Building and installing the library will generate bytecode under the GMP/ directory, such as GMP/Integer.pbc.
For more in-depth information, please see docs/tutorial.md.
- The GMP library, at least version 4.2 (and ideally 5.0.x)
- Parrot, at least version 3.2.0
- Winxed (bundled with Parrot version 3.5.0)
- NQP (bundled with Parrot)
- Rosella (for the test library, available via plumage)
The bare minimum requirements are checked in setup.winxed.
- The script
bin/gmph2ncidef.plreads gmp.h and outputs an NCI definition. Appending that output to src/GMP/Raw.nci.template gives us the NCI definition file at src/GMP/Raw.nci and it is included with the distribution.
- A script included with parrot in
tools/dev/ncidef2pir.plreads this NCI definition file and generate low-level PIR functions to call the corresponding GMP calls. This is src/GMP/Raw.pir and included with the distrubtion.
- The script
bin/gmpdoc2winxed.plreads the GMP documentation (as a single HTML file) and outputs Winxed function calls. Appending that output to src/GMP/Integer.winxed.template gives us the Winxed file at src/GMP/Integer.winxed and it is included with the distribution. src/GMP/Random.winxed is generated in the same way.
winxed setup.winxed build
winxed setup.winxed test
To run individual test files:
winxed setup.winxed install
Depending on your permissions you may need to use
- Examples will be plentiful and useful
- Bindings will also cover Rational and Decimal functions