merrilymeredith/p5-FFI-Sweet — pull request #4 by plicease (2013-11-15 12:24:39+00:00)
Title: allow for renaming functions, or defining wrappers

Experience in writing Archive::Libarchive::FFI has shown me that sometimes functions should work in slightly different ways in Perl, but should retain the same name, a function that takes a buffer and a size in C, for example can take a scalar (which knows its size) instead.

The way I did this was create a separate Archive::Libarchive::FFI::functions namespace and then implemented my wrapper in Archive::Libarchive::FFI, which is awkward.

This modification changes attach_function to take an optional forth argument which is either a different function name or a coderef wrapper.

Another way to do this would be to have a FFI::Sweet function that returns a coderef, which you could then install yourself, but I like the way FFI::Sweet installs the subroutines without my having to muck about with the symbol table.