develooper Front page | perl.perl5.porters | Postings from May 2008

Re: [PATCH] ExtUtils::ParseXS - Error reporting problem with INTERFACE and ALIAS keywords

Thread Previous | Thread Next
From:
Robert May
Date:
May 22, 2008 03:59
Subject:
Re: [PATCH] ExtUtils::ParseXS - Error reporting problem with INTERFACE and ALIAS keywords
Message ID:
54bdc7510805220359x76476cf1lee36f01994c386b8@mail.gmail.com
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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About