On Wed, Aug 05, 2009 at 01:32:29PM -0700, Kyle Is a N00b wrote: > Using Parrot and the compiler tools, write a parser for C header files > that can generate Perl 5 NCI or Parrot NCI code. > It should let the developer write an SDL binding for either language > by running the parser against SDL.h and its friends. For output, it > would generate either or both Perl 5 and Parrot code that: > > * opens the appropriate library with NCI or Parrot NCI > * binds to the functions with the appropriate data types > * declares the defined structs appropriately
Note that this approach can simplify the SDL XS files immensely, both in maintenance and in code size. As so many SDL C functions have the same signatures (take four floats, return a pointer), the thunks which convert to and from Perl/Parrot calling conventions and C calling conventions can be the same code. To bind to a C function, you pass a pointer to that function to the thunk, let the thunk convert the arguments, call the function, and return. This does mean creating (effectively) closures around functions in shared libraries, but it's trivial to do from XS. -- c