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:
Paul Marquess
Date:
October 29, 2001 04:01
Subject:
RE: [PATCH h2xs] Use of static data in XS modules
Message ID:
AIEAJICLCBDNAAOLLOKLOEIHDDAA.Paul_Marquess@Yahoo.co.uk
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".

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