Front page | perl.perl5.porters |
Postings from February 2013
From: Peter Martini
February 10, 2013 18:42
Message ID: CAFyW6MQndkA+-w1mFWVKk0uvvGDs4fEdE0Ogp_=3N78TzGDsXA@mail.gmail.com
For anyone interested, I have a rough first prototype of a signatures
API (and a signatures module to test it).
The modified perl core is at
the demo module is at https://github.com/PeterMartini/signatures.
The heart of the change to the core is two new typedefs:
typedef bool Perl_signature_parser(pTHX_ CV * cv, SV * signature);
typedef bool Perl_signature_init(pTHX_ CV * cv, SV ** argc, IV argcount);
To add a custom signature handler, a pointer to a function that
matches the Perl_signature_parser typedef is loaded into the hints
hash with a key of Perl_sig_parser. The bool values indicates whether
the function chose to handle the signature string or not; FALSE means
that it chose not to, and thus that the traditional prototype
definitions will be used instead. The Perl_signature_parser is
expected to use the new function CvSIGNATURE_FUNC_set to add a custom
function to call and CvSIGNATURE_DATA_set to attach a single SV with
relevant metadata. The bool return value is whether @_ should be
loaded or not. Note that it doesn't try to hide @_ or destroy it, it
just tells perl to ignore it - so if you're using a calling convention
that used an inherited @_, there's no change either way.
pp_entersub and pp_goto have been modified to check if a
CvSIGNATURE_FUNC is present and call it with the args from either the
stack or @_, depending on calling convention.
All comments and feedback welcome.
by Peter Martini