I
Ivan Shmakov
Is there an easy way to make a bunch of C constants (as in:
#define) available as Perl subroutines (just like, e. g., POSIX
does for the errno.h constants)?
I've looked at POSIX.xs, POSIX.pm [1, 2], but don't seem to get
it. (Somehow, there do not seem to be any references to, say,
ENOENT, other than that in the export list.)
Surely, I can follow the example at SQLite.xs [3]:
static int
OK()
CODE:
RETVAL = SQLITE_OK;
OUTPUT:
RETVAL
But that seems overly repetitive and error-prone. (Given that I
need to handle some 156 such constants, anyway.)
TIA.
[1] http://cpansearch.perl.org/src/RJBS/perl-5.18.0/ext/POSIX/POSIX.xs
[2] http://cpansearch.perl.org/src/RJBS/perl-5.18.0/ext/POSIX/lib/POSIX.pm
[3] http://cpansearch.perl.org/src/ISHIGAKI/DBD-SQLite-1.39/SQLite.xs
#define) available as Perl subroutines (just like, e. g., POSIX
does for the errno.h constants)?
I've looked at POSIX.xs, POSIX.pm [1, 2], but don't seem to get
it. (Somehow, there do not seem to be any references to, say,
ENOENT, other than that in the export list.)
Surely, I can follow the example at SQLite.xs [3]:
static int
OK()
CODE:
RETVAL = SQLITE_OK;
OUTPUT:
RETVAL
But that seems overly repetitive and error-prone. (Given that I
need to handle some 156 such constants, anyway.)
TIA.
[1] http://cpansearch.perl.org/src/RJBS/perl-5.18.0/ext/POSIX/POSIX.xs
[2] http://cpansearch.perl.org/src/RJBS/perl-5.18.0/ext/POSIX/lib/POSIX.pm
[3] http://cpansearch.perl.org/src/ISHIGAKI/DBD-SQLite-1.39/SQLite.xs