Parrot-GMP: Even more tests and NCI work

Nothing too glamorous to report again - the test suite continues to grow. All functions are currently covered (and passing) except for functions related to random numbers. These functions are especially tricky because they rely on a special C-struct to both hold the seed and point to which pseudo-random number function we want to use. GMP is flexible in that there are multiple functions a user can choose from - some which favor speed and others which favor randomness - but the code is messy. Furthermore, to handle structs in NCI we need something called a StructView.

A StructView is really just a container that knows the layout of the struct. We have to know the layout because we need to initialize that space of memory. The struct that I need to initialize the random functions is a real pain - has another struct inside it (the GMP Integer), has a union and an enum. Furthermore, Whiteknight++ helped me realize that the real item I want isn't the struct but something that has been typedef'd to be an *array* of those structs.

Once you have a StructView, you can call .alloc() on it to allocate the memory that you need for it. It returns a PtrObj which can be passed in to an NCI function with the 'p' signature. A StructView also helps you access the individual items inside that struct if you ever need to. I don't need to do that as 1) there are C functions to do that for me and 2) most of those guts aren't really intelligible.

Since these random functions are not only for Integers but really just another part of the GMP library in general, I refactored out some common code into GMP::Common. NotFound++ was very helpful and the test suite let me know when I was done. I think the code is cleaner this way, it's extensible if and when we want to have both the Decimal and the Rational classes added, and it reduces code duplication. This week I'll work on getting these random functions all working.

In other news, pmichaud++ mentioned that there is general interest in my project in Rakudo land so I updated my README and TODO. The project, while completely functional, isn't very developer friendly. Sure, there are function-level docs but there are no real tutorials or examples. Before the end of the program I'd like to add some real narrative-type docs and NQP examples and maybe even see how it works in Rakudo.

Finally, I've been talking with plobsing++ (keeper of all things NCI) about the docs and a few upgrades. I'm currently working on TT #2130 reported by masak++ about some of the NCI bindings that come with parrot being broken. I'll be re-working some of the internal Parrot tools to update them to the new NCI definition style and also bringing them inline with Parrot calling conventions. Existing code *should* be unaffected but if there are still broken examples in Parrot I'll work on getting those fixed.