develooper Front page | perl.perl5.porters | Postings from October 2001

Re: [PATCH h2xs] Use of static data in XS modules

Thread Previous | Thread Next
From:
Tim Bunce
Date:
October 29, 2001 14:38
Subject:
Re: [PATCH h2xs] Use of static data in XS modules
Message ID:
20011029223810.J15404@dansat.data-plan.com
On Mon, Oct 29, 2001 at 12:04:10PM -0000, Paul Marquess wrote:
> From: Gurusamy Sarathy [mailto:gsar@ActiveState.com]
> 
> > On Sun, 28 Oct 2001 22:02:52 GMT, Tim Bunce wrote:
> > >I think it needs some more words of explanation (or pointers) in
> > >the docs and/or generated code as to why it's needed and how the fields
> > >in the struct are accessed.
> >
> > Yes, ideally, there would be documentation and examples in perlxs.pod.
> > Paul said he might look into that.  Right now, perl.h has the following
> > by way of comments, which should be enough for someone to write the
> > perlxs.pod additions:
> 
> Yep, I was intending to add a few words to perlxs.pod at the weekend, but
> life got in the way. I have a few sentences cobbled together, but I need to
> find some the time to add a few more.
> 
> The next change I need to make for h2xs is to add a chunk of
> "backward-compatibility" code to allow older Perl's to make use of this
> facility. I'm tempted just to get h2xs to spit out an extra file called,
> say, "compat.h".

I think I'd prefer it if this was all added to Devel::PPPort since that'll
more readily help more people (including the DBI :)

And h2xs could usefully have an option to include Devel::PPPort.

Tim.

> It would just contain all the CXT* code from perl.h modified to work older
> Perl's, and the whole thing surrounded by a #if perl < 5.8
> 
> Then the .xs file just gets this:
> 
>     #include "EXTERN.h"
>     #include "perl.h"
>     #include "XSUB.h"
>     #include "compat.h"
> 
> I think this is cleaner than dumping all the CXT* code straight into the .xs
> file.
> 
> The "compat.h" file could then be used as the place for h2xs to put other
> backward compatibility code in the future.
> 
> Here's a candidate for inclusion that I have in all of my modules.
> 
> #ifndef PERL_VERSION
> #    include "patchlevel.h"
> #    define PERL_REVISION	5
> #    define PERL_VERSION	PATCHLEVEL
> #    define PERL_SUBVERSION	SUBVERSION
> #endif
> 
> Another possibility is mapping of pre-PL_* names to the PL_* equivalent
> 
> #if PERL_REVISION == 5 && (PERL_VERSION < 4 || \
>     (PERL_VERSION == 4 && PERL_SUBVERSION <= 75 ))
> 
> #    define PL_sv_undef		sv_undef
> #    define PL_na		na
> 
> #endif
> 
> 
> Paul
> 
> 
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
> 

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