[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]
Re: New way to do XS constants
On Fri, Jan 07, 2000 at 12:34:01AM -0600, Tye McQueen wrote:
> It looks like the makemaker e-mail list may have become defunct so
> I'm writing to p5p and CCing makemaker. Since the only example module
> is Win32-specific, I'm also CCing Perl-Win32-Porters.
>
> I've written a new way to deal with constants in XS modules. The
> major advantages:
>
> * No autoloading required [but could be used if you had a truely
> huge list of constants and most users need few of them].
> * No doing lots of strcmp()s at module run time when you have lots
> of constants.
> * The most efficient method [at module run time] if not tons of
> unused constants
> * No modifying big complex C case statements when you decide to
> add more constants to your module. To change which constants
> you support, you simply update your @EXPORT, @EXPORT_OK, and/or
> %EXPORT_TAGS entries and possibly make minor changes to your
> Makefile.PL.
> * Still uses C code to determine constant values -- not a
> throw-back to h2ph.
FYI: All those advantages also apply to this very simple method:
I32
constant()
PROTOTYPE:
ALIAS:
CONST_NAME_1 = 1
CONST_NAME_2 = 2
CONST_NAME_3 = 3
CONST_NAME_4 = 4
CODE:
RETVAL = ix;
OUTPUT:
RETVAL
(The 1, 2, 3, 4 can be #defined values.)
Using a single XS sub and multiple XS aliases instead of multiple perl
subs uses very little memory (far less than multiple perl subs).
It also has a very low start-up overhead (just one newXS() call each).
Tim.
- Follow-Ups from:
-
Graham Barr <gbarr@pobox.com>
- References to:
-
Tye McQueen <tye@metronet.com>
[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]