2008/5/21 Nicholas Clark <nick@ccl4.org>: > I've just added this function to blead: > > void > Perl_croak_xs_usage(pTHX_ const CV *const cv, const char *const params) > { [snip] > } > > Assuming we think it's sane, That looks OK. I suspect it's rather more than is really needed, as when I originally looked at this I couldn't see any way that the cv passed into an XSUB could ever not have a package or a name - although I was assuming that the only way to register an XSUB is via newXS(). > I'd assume that it will appear in 5.8.9 and > 5.10.1, at which point ExtUtils::ParseXS could call it as is. For everything > else, I think it would be viable to patch ExtUtils::ParseXS to see if it > needs it, and if so emit it as a static function. > > (I think all it needs is an array to stack the output of print in the loop > starting > > PARAGRAPH: > while (fetch_para()) { > > and a variable to track if any $cond is non-zero. If any are, spit out that > function above as a static function. Then, whatever, spit out all the array > of lines.) > > Does this seem viable? Is it really that simple? My memory of EU:PXS is that it prints stuff all over the place. Assuming that Perl_croak_xs_usage is exported and visible from an XS extension in newer perls, then EU::PXS can be modified to always call it, as you suggest. EU::PXS can be modified to always spit out a static version of the function, and put it inside a #ifndef block, that checks on some #define that only exists in perl versions that have the new function (e.g. We'll add a #define HAS_PERL_CROAK_XS_USAGE to XSUB.h). Is it necessary to avoid spitting out the static function if it's not going to be called? The only time the "cond" check is not made is if the XSUB's prototype uses ellipses and there is no minimum number of arguments. How often does an XS extension have all its prototypes look like that? The downside of this approach is that as we discover bugs in Perl_croak_xs_usage() we'll need to fix them in EU::PXS too. An alternative approach would be to get EU::PXS to spit out a #ifdef/#else/#endif block with the current code for perls without Perl_croak_xs_usage and the new code when it exists. I could put together a patch for either, but probably not until sometime next week. Regards, Rob.Thread Previous | Thread Next