config root man

Current Path : /usr/opt/perl530/man/man1/

FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64
Upload File :
Current File : //usr/opt/perl530/man/man1/perlxstypemap.1

.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings.  \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote.  \*(C+ will
.\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
.\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
.    ds -- \(*W-
.    ds PI pi
.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
.    ds L" ""
.    ds R" ""
.    ds C` ""
.    ds C' ""
'br\}
.el\{\
.    ds -- \|\(em\|
.    ds PI \(*p
.    ds L" ``
.    ds R" ''
.    ds C`
.    ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD.  Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
.    if \nF \{\
.        de IX
.        tm Index:\\$1\t\\n%\t"\\$2"
..
.        if !\nF==2 \{\
.            nr % 0
.            nr F 2
.        \}
.    \}
.\}
.rr rF
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear.  Run.  Save yourself.  No user-serviceable parts.
.    \" fudge factors for nroff and troff
.if n \{\
.    ds #H 0
.    ds #V .8m
.    ds #F .3m
.    ds #[ \f1
.    ds #] \fP
.\}
.if t \{\
.    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
.    ds #V .6m
.    ds #F 0
.    ds #[ \&
.    ds #] \&
.\}
.    \" simple accents for nroff and troff
.if n \{\
.    ds ' \&
.    ds ` \&
.    ds ^ \&
.    ds , \&
.    ds ~ ~
.    ds /
.\}
.if t \{\
.    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
.    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
.    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
.    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
.    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
.    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
.    \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
.    \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
.    \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
.    ds : e
.    ds 8 ss
.    ds o a
.    ds d- d\h'-1'\(ga
.    ds D- D\h'-1'\(hy
.    ds th \o'bp'
.    ds Th \o'LP'
.    ds ae ae
.    ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "PERLXSTYPEMAP 1"
.TH PERLXSTYPEMAP 1 "2019-10-24" "perl v5.30.2" "Perl Programmers Reference Guide"
.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
perlxstypemap \- Perl XS C/Perl type mapping
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
The more you think about interfacing between two languages, the more
you'll realize that the majority of programmer effort has to go into
converting between the data structures that are native to either of
the languages involved.  This trumps other matter such as differing
calling conventions because the problem space is so much greater.
There are simply more ways to shove data into memory than there are
ways to implement a function call.
.PP
Perl \s-1XS\s0' attempt at a solution to this is the concept of typemaps.
At an abstract level, a Perl \s-1XS\s0 typemap is nothing but a recipe for
converting from a certain Perl data structure to a certain C
data structure and vice versa.  Since there can be C types that
are sufficiently similar to one another to warrant converting with
the same logic, \s-1XS\s0 typemaps are represented by a unique identifier,
henceforth called an \fB\s-1XS\s0 type\fR in this document.  You can then tell
the \s-1XS\s0 compiler that multiple C types are to be mapped with the same
\&\s-1XS\s0 typemap.
.PP
In your \s-1XS\s0 code, when you define an argument with a C type or when
you are using a \f(CW\*(C`CODE:\*(C'\fR and an \f(CW\*(C`OUTPUT:\*(C'\fR section together with a
C return type of your \s-1XSUB,\s0 it'll be the typemapping mechanism that
makes this easy.
.SS "Anatomy of a typemap"
.IX Subsection "Anatomy of a typemap"
In more practical terms, the typemap is a collection of code
fragments which are used by the \fBxsubpp\fR compiler to map C function
parameters and values to Perl values.  The typemap file may consist
of three sections labelled \f(CW\*(C`TYPEMAP\*(C'\fR, \f(CW\*(C`INPUT\*(C'\fR, and \f(CW\*(C`OUTPUT\*(C'\fR.
An unlabelled initial section is assumed to be a \f(CW\*(C`TYPEMAP\*(C'\fR section.
The \s-1INPUT\s0 section tells the compiler how to translate Perl values
into variables of certain C types.  The \s-1OUTPUT\s0 section tells the
compiler how to translate the values from certain C types into values
Perl can understand.  The \s-1TYPEMAP\s0 section tells the compiler which
of the \s-1INPUT\s0 and \s-1OUTPUT\s0 code fragments should be used to map a given
C type to a Perl value.  The section labels \f(CW\*(C`TYPEMAP\*(C'\fR, \f(CW\*(C`INPUT\*(C'\fR, or
\&\f(CW\*(C`OUTPUT\*(C'\fR must begin in the first column on a line by themselves,
and must be in uppercase.
.PP
Each type of section can appear an arbitrary number of times
and does not have to appear at all.  For example, a typemap may
commonly lack \f(CW\*(C`INPUT\*(C'\fR and \f(CW\*(C`OUTPUT\*(C'\fR sections if all it needs to
do is associate additional C types with core \s-1XS\s0 types like T_PTROBJ.
Lines that start with a hash \f(CW\*(C`#\*(C'\fR are considered comments and ignored
in the \f(CW\*(C`TYPEMAP\*(C'\fR section, but are considered significant in \f(CW\*(C`INPUT\*(C'\fR
and \f(CW\*(C`OUTPUT\*(C'\fR. Blank lines are generally ignored.
.PP
Traditionally, typemaps needed to be written to a separate file,
conventionally called \f(CW\*(C`typemap\*(C'\fR in a \s-1CPAN\s0 distribution.  With
ExtUtils::ParseXS (the \s-1XS\s0 compiler) version 3.12 or better which
comes with perl 5.16, typemaps can also be embedded directly into
\&\s-1XS\s0 code using a HERE-doc like syntax:
.PP
.Vb 3
\&  TYPEMAP: <<HERE
\&  ...
\&  HERE
.Ve
.PP
where \f(CW\*(C`HERE\*(C'\fR can be replaced by other identifiers like with normal
Perl HERE-docs.  All details below about the typemap textual format
remain valid.
.PP
The \f(CW\*(C`TYPEMAP\*(C'\fR section should contain one pair of C type and
\&\s-1XS\s0 type per line as follows.  An example from the core typemap file:
.PP
.Vb 6
\&  TYPEMAP
\&  # all variants of char* is handled by the T_PV typemap
\&  char *          T_PV
\&  const char *    T_PV
\&  unsigned char * T_PV
\&  ...
.Ve
.PP
The \f(CW\*(C`INPUT\*(C'\fR and \f(CW\*(C`OUTPUT\*(C'\fR sections have identical formats, that is,
each unindented line starts a new in\- or output map respectively.
A new in\- or output map must start with the name of the \s-1XS\s0 type to
map on a line by itself, followed by the code that implements it
indented on the following lines. Example:
.PP
.Vb 5
\&  INPUT
\&  T_PV
\&    $var = ($type)SvPV_nolen($arg)
\&  T_PTR
\&    $var = INT2PTR($type,SvIV($arg))
.Ve
.PP
We'll get to the meaning of those Perlish-looking variables in a
little bit.
.PP
Finally, here's an example of the full typemap file for mapping C
strings of the \f(CW\*(C`char *\*(C'\fR type to Perl scalars/strings:
.PP
.Vb 2
\&  TYPEMAP
\&  char *  T_PV
\&
\&  INPUT
\&  T_PV
\&    $var = ($type)SvPV_nolen($arg)
\&
\&  OUTPUT
\&  T_PV
\&    sv_setpv((SV*)$arg, $var);
.Ve
.PP
Here's a more complicated example: suppose that you wanted
\&\f(CW\*(C`struct netconfig\*(C'\fR to be blessed into the class \f(CW\*(C`Net::Config\*(C'\fR.
One way to do this is to use underscores (_) to separate package
names, as follows:
.PP
.Vb 1
\&  typedef struct netconfig * Net_Config;
.Ve
.PP
And then provide a typemap entry \f(CW\*(C`T_PTROBJ_SPECIAL\*(C'\fR that maps
underscores to double-colons (::), and declare \f(CW\*(C`Net_Config\*(C'\fR to be of
that type:
.PP
.Vb 2
\&  TYPEMAP
\&  Net_Config      T_PTROBJ_SPECIAL
\&
\&  INPUT
\&  T_PTROBJ_SPECIAL
\&    if (sv_derived_from($arg, \e"${(my $ntt=$ntype)=~s/_/::/g;\e$ntt}\e")){
\&      IV tmp = SvIV((SV*)SvRV($arg));
\&      $var = INT2PTR($type, tmp);
\&    }
\&    else
\&      croak(\e"$var is not of type ${(my $ntt=$ntype)=~s/_/::/g;\e$ntt}\e")
\&
\&  OUTPUT
\&  T_PTROBJ_SPECIAL
\&    sv_setref_pv($arg, \e"${(my $ntt=$ntype)=~s/_/::/g;\e$ntt}\e",
\&                 (void*)$var);
.Ve
.PP
The \s-1INPUT\s0 and \s-1OUTPUT\s0 sections substitute underscores for double-colons
on the fly, giving the desired effect.  This example demonstrates some
of the power and versatility of the typemap facility.
.PP
The \f(CW\*(C`INT2PTR\*(C'\fR macro (defined in perl.h) casts an integer to a pointer
of a given type, taking care of the possible different size of integers
and pointers.  There are also \f(CW\*(C`PTR2IV\*(C'\fR, \f(CW\*(C`PTR2UV\*(C'\fR, \f(CW\*(C`PTR2NV\*(C'\fR macros,
to map the other way, which may be useful in \s-1OUTPUT\s0 sections.
.SS "The Role of the typemap File in Your Distribution"
.IX Subsection "The Role of the typemap File in Your Distribution"
The default typemap in the \fIlib/ExtUtils\fR directory of the Perl source
contains many useful types which can be used by Perl extensions.  Some
extensions define additional typemaps which they keep in their own directory.
These additional typemaps may reference \s-1INPUT\s0 and \s-1OUTPUT\s0 maps in the main
typemap.  The \fBxsubpp\fR compiler will allow the extension's own typemap to
override any mappings which are in the default typemap.  Instead of using
an additional \fItypemap\fR file, typemaps may be embedded verbatim in \s-1XS\s0
with a heredoc-like syntax.  See the documentation on the \f(CW\*(C`TYPEMAP:\*(C'\fR \s-1XS\s0
keyword.
.PP
For \s-1CPAN\s0 distributions, you can assume that the \s-1XS\s0 types defined by
the perl core are already available. Additionally, the core typemap
has default \s-1XS\s0 types for a large number of C types.  For example, if
you simply return a \f(CW\*(C`char *\*(C'\fR from your \s-1XSUB,\s0 the core typemap will
have this C type associated with the T_PV \s-1XS\s0 type.  That means your
C string will be copied into the \s-1PV\s0 (pointer value) slot of a new scalar
that will be returned from your \s-1XSUB\s0 to Perl.
.PP
If you're developing a \s-1CPAN\s0 distribution using \s-1XS,\s0 you may add your own
file called \fItypemap\fR to the distribution.  That file may contain
typemaps that either map types that are specific to your code or that
override the core typemap file's mappings for common C types.
.SS "Sharing typemaps Between \s-1CPAN\s0 Distributions"
.IX Subsection "Sharing typemaps Between CPAN Distributions"
Starting with ExtUtils::ParseXS version 3.13_01 (comes with perl 5.16
and better), it is rather easy to share typemap code between multiple
\&\s-1CPAN\s0 distributions. The general idea is to share it as a module that
offers a certain \s-1API\s0 and have the dependent modules declare that as a
built-time requirement and import the typemap into the \s-1XS.\s0 An example
of such a typemap-sharing module on \s-1CPAN\s0 is
\&\f(CW\*(C`ExtUtils::Typemaps::Basic\*(C'\fR. Two steps to getting that module's
typemaps available in your code:
.IP "\(bu" 4
Declare \f(CW\*(C`ExtUtils::Typemaps::Basic\*(C'\fR as a build-time dependency
in \f(CW\*(C`Makefile.PL\*(C'\fR (use \f(CW\*(C`BUILD_REQUIRES\*(C'\fR), or in your \f(CW\*(C`Build.PL\*(C'\fR
(use \f(CW\*(C`build_requires\*(C'\fR).
.IP "\(bu" 4
Include the following line in the \s-1XS\s0 section of your \s-1XS\s0 file:
(don't break the line)
.Sp
.Vb 2
\&  INCLUDE_COMMAND: $^X \-MExtUtils::Typemaps::Cmd
\&                   \-e "print embeddable_typemap(q{Basic})"
.Ve
.SS "Writing typemap Entries"
.IX Subsection "Writing typemap Entries"
Each \s-1INPUT\s0 or \s-1OUTPUT\s0 typemap entry is a double-quoted Perl string that
will be evaluated in the presence of certain variables to get the
final C code for mapping a certain C type.
.PP
This means that you can embed Perl code in your typemap (C) code using
constructs such as
\&\f(CW\*(C`${ perl code that evaluates to scalar reference here }\*(C'\fR. A common
use case is to generate error messages that refer to the true function
name even when using the \s-1ALIAS XS\s0 feature:
.PP
.Vb 1
\&  ${ $ALIAS ? \eq[GvNAME(CvGV(cv))] : \eqq[\e"$pname\e"] }
.Ve
.PP
For many typemap examples, refer to the core typemap file that can be
found in the perl source tree at \fIlib/ExtUtils/typemap\fR.
.PP
The Perl variables that are available for interpolation into typemaps
are the following:
.IP "\(bu" 4
\&\fI\f(CI$var\fI\fR \- the name of the input or output variable, eg. \s-1RETVAL\s0 for
return values.
.IP "\(bu" 4
\&\fI\f(CI$type\fI\fR \- the raw C type of the parameter, any \f(CW\*(C`:\*(C'\fR replaced with
\&\f(CW\*(C`_\*(C'\fR.
e.g. for a type of \f(CW\*(C`Foo::Bar\*(C'\fR, \fI\f(CI$type\fI\fR is \f(CW\*(C`Foo_\|_Bar\*(C'\fR
.IP "\(bu" 4
\&\fI\f(CI$ntype\fI\fR \- the supplied type with \f(CW\*(C`*\*(C'\fR replaced with \f(CW\*(C`Ptr\*(C'\fR.
e.g. for a type of \f(CW\*(C`Foo*\*(C'\fR, \fI\f(CI$ntype\fI\fR is \f(CW\*(C`FooPtr\*(C'\fR
.IP "\(bu" 4
\&\fI\f(CI$arg\fI\fR \- the stack entry, that the parameter is input from or output
to, e.g. \f(CWST(0)\fR
.IP "\(bu" 4
\&\fI\f(CI$argoff\fI\fR \- the argument stack offset of the argument.  ie. 0 for the
first argument, etc.
.IP "\(bu" 4
\&\fI\f(CI$pname\fI\fR \- the full name of the \s-1XSUB,\s0 with including the \f(CW\*(C`PACKAGE\*(C'\fR
name, with any \f(CW\*(C`PREFIX\*(C'\fR stripped.  This is the non-ALIAS name.
.IP "\(bu" 4
\&\fI\f(CI$Package\fI\fR \- the package specified by the most recent \f(CW\*(C`PACKAGE\*(C'\fR
keyword.
.IP "\(bu" 4
\&\fI\f(CI$ALIAS\fI\fR \- non-zero if the current \s-1XSUB\s0 has any aliases declared with
\&\f(CW\*(C`ALIAS\*(C'\fR.
.SS "Full Listing of Core Typemaps"
.IX Subsection "Full Listing of Core Typemaps"
Each C type is represented by an entry in the typemap file that
is responsible for converting perl variables (\s-1SV, AV, HV, CV,\s0 etc.)
to and from that type. The following sections list all \s-1XS\s0 types
that come with perl by default.
.IP "T_SV" 4
.IX Item "T_SV"
This simply passes the C representation of the Perl variable (an SV*)
in and out of the \s-1XS\s0 layer. This can be used if the C code wants
to deal directly with the Perl variable.
.IP "T_SVREF" 4
.IX Item "T_SVREF"
Used to pass in and return a reference to an \s-1SV.\s0
.Sp
Note that this typemap does not decrement the reference count
when returning the reference to an SV*.
See also: T_SVREF_REFCOUNT_FIXED
.IP "T_SVREF_FIXED" 4
.IX Item "T_SVREF_FIXED"
Used to pass in and return a reference to an \s-1SV.\s0
This is a fixed
variant of T_SVREF that decrements the refcount appropriately
when returning a reference to an SV*. Introduced in perl 5.15.4.
.IP "T_AVREF" 4
.IX Item "T_AVREF"
From the perl level this is a reference to a perl array.
From the C level this is a pointer to an \s-1AV.\s0
.Sp
Note that this typemap does not decrement the reference count
when returning an AV*. See also: T_AVREF_REFCOUNT_FIXED
.IP "T_AVREF_REFCOUNT_FIXED" 4
.IX Item "T_AVREF_REFCOUNT_FIXED"
From the perl level this is a reference to a perl array.
From the C level this is a pointer to an \s-1AV.\s0 This is a fixed
variant of T_AVREF that decrements the refcount appropriately
when returning an AV*. Introduced in perl 5.15.4.
.IP "T_HVREF" 4
.IX Item "T_HVREF"
From the perl level this is a reference to a perl hash.
From the C level this is a pointer to an \s-1HV.\s0
.Sp
Note that this typemap does not decrement the reference count
when returning an HV*. See also: T_HVREF_REFCOUNT_FIXED
.IP "T_HVREF_REFCOUNT_FIXED" 4
.IX Item "T_HVREF_REFCOUNT_FIXED"
From the perl level this is a reference to a perl hash.
From the C level this is a pointer to an \s-1HV.\s0 This is a fixed
variant of T_HVREF that decrements the refcount appropriately
when returning an HV*. Introduced in perl 5.15.4.
.IP "T_CVREF" 4
.IX Item "T_CVREF"
From the perl level this is a reference to a perl subroutine
(e.g. \f(CW$sub\fR = sub { 1 };). From the C level this is a pointer
to a \s-1CV.\s0
.Sp
Note that this typemap does not decrement the reference count
when returning an HV*. See also: T_HVREF_REFCOUNT_FIXED
.IP "T_CVREF_REFCOUNT_FIXED" 4
.IX Item "T_CVREF_REFCOUNT_FIXED"
From the perl level this is a reference to a perl subroutine
(e.g. \f(CW$sub\fR = sub { 1 };). From the C level this is a pointer
to a \s-1CV.\s0
.Sp
This is a fixed
variant of T_HVREF that decrements the refcount appropriately
when returning an HV*. Introduced in perl 5.15.4.
.IP "T_SYSRET" 4
.IX Item "T_SYSRET"
The T_SYSRET typemap is used to process return values from system calls.
It is only meaningful when passing values from C to perl (there is
no concept of passing a system return value from Perl to C).
.Sp
System calls return \-1 on error (setting \s-1ERRNO\s0 with the reason)
and (usually) 0 on success. If the return value is \-1 this typemap
returns \f(CW\*(C`undef\*(C'\fR. If the return value is not \-1, this typemap
translates a 0 (perl false) to \*(L"0 but true\*(R" (which
is perl true) or returns the value itself, to indicate that the
command succeeded.
.Sp
The \s-1POSIX\s0 module makes extensive use of this type.
.IP "T_UV" 4
.IX Item "T_UV"
An unsigned integer.
.IP "T_IV" 4
.IX Item "T_IV"
A signed integer. This is cast to the required integer type when
passed to C and converted to an \s-1IV\s0 when passed back to Perl.
.IP "T_INT" 4
.IX Item "T_INT"
A signed integer. This typemap converts the Perl value to a native
integer type (the \f(CW\*(C`int\*(C'\fR type on the current platform). When returning
the value to perl it is processed in the same way as for T_IV.
.Sp
Its behaviour is identical to using an \f(CW\*(C`int\*(C'\fR type in \s-1XS\s0 with T_IV.
.IP "T_ENUM" 4
.IX Item "T_ENUM"
An enum value. Used to transfer an enum component
from C. There is no reason to pass an enum value to C since
it is stored as an \s-1IV\s0 inside perl.
.IP "T_BOOL" 4
.IX Item "T_BOOL"
A boolean type. This can be used to pass true and false values to and
from C.
.IP "T_U_INT" 4
.IX Item "T_U_INT"
This is for unsigned integers. It is equivalent to using T_UV
but explicitly casts the variable to type \f(CW\*(C`unsigned int\*(C'\fR.
The default type for \f(CW\*(C`unsigned int\*(C'\fR is T_UV.
.IP "T_SHORT" 4
.IX Item "T_SHORT"
Short integers. This is equivalent to T_IV but explicitly casts
the return to type \f(CW\*(C`short\*(C'\fR. The default typemap for \f(CW\*(C`short\*(C'\fR
is T_IV.
.IP "T_U_SHORT" 4
.IX Item "T_U_SHORT"
Unsigned short integers. This is equivalent to T_UV but explicitly
casts the return to type \f(CW\*(C`unsigned short\*(C'\fR. The default typemap for
\&\f(CW\*(C`unsigned short\*(C'\fR is T_UV.
.Sp
T_U_SHORT is used for type \f(CW\*(C`U16\*(C'\fR in the standard typemap.
.IP "T_LONG" 4
.IX Item "T_LONG"
Long integers. This is equivalent to T_IV but explicitly casts
the return to type \f(CW\*(C`long\*(C'\fR. The default typemap for \f(CW\*(C`long\*(C'\fR
is T_IV.
.IP "T_U_LONG" 4
.IX Item "T_U_LONG"
Unsigned long integers. This is equivalent to T_UV but explicitly
casts the return to type \f(CW\*(C`unsigned long\*(C'\fR. The default typemap for
\&\f(CW\*(C`unsigned long\*(C'\fR is T_UV.
.Sp
T_U_LONG is used for type \f(CW\*(C`U32\*(C'\fR in the standard typemap.
.IP "T_CHAR" 4
.IX Item "T_CHAR"
Single 8\-bit characters.
.IP "T_U_CHAR" 4
.IX Item "T_U_CHAR"
An unsigned byte.
.IP "T_FLOAT" 4
.IX Item "T_FLOAT"
A floating point number. This typemap guarantees to return a variable
cast to a \f(CW\*(C`float\*(C'\fR.
.IP "T_NV" 4
.IX Item "T_NV"
A Perl floating point number. Similar to T_IV and T_UV in that the
return type is cast to the requested numeric type rather than
to a specific type.
.IP "T_DOUBLE" 4
.IX Item "T_DOUBLE"
A double precision floating point number. This typemap guarantees to
return a variable cast to a \f(CW\*(C`double\*(C'\fR.
.IP "T_PV" 4
.IX Item "T_PV"
A string (char *).
.IP "T_PTR" 4
.IX Item "T_PTR"
A memory address (pointer). Typically associated with a \f(CW\*(C`void *\*(C'\fR
type.
.IP "T_PTRREF" 4
.IX Item "T_PTRREF"
Similar to T_PTR except that the pointer is stored in a scalar and the
reference to that scalar is returned to the caller. This can be used
to hide the actual pointer value from the programmer since it is usually
not required directly from within perl.
.Sp
The typemap checks that a scalar reference is passed from perl to \s-1XS.\s0
.IP "T_PTROBJ" 4
.IX Item "T_PTROBJ"
Similar to T_PTRREF except that the reference is blessed into a class.
This allows the pointer to be used as an object. Most commonly used to
deal with C structs. The typemap checks that the perl object passed
into the \s-1XS\s0 routine is of the correct class (or part of a subclass).
.Sp
The pointer is blessed into a class that is derived from the name
of type of the pointer but with all '*' in the name replaced with
\&'Ptr'.
.Sp
For \f(CW\*(C`DESTROY\*(C'\fR XSUBs only, a T_PTROBJ is optimized to a T_PTRREF. This means
the class check is skipped.
.IP "T_REF_IV_REF" 4
.IX Item "T_REF_IV_REF"
\&\s-1NOT YET\s0
.IP "T_REF_IV_PTR" 4
.IX Item "T_REF_IV_PTR"
Similar to T_PTROBJ in that the pointer is blessed into a scalar object.
The difference is that when the object is passed back into \s-1XS\s0 it must be
of the correct type (inheritance is not supported) while T_PTROBJ supports
inheritance.
.Sp
The pointer is blessed into a class that is derived from the name
of type of the pointer but with all '*' in the name replaced with
\&'Ptr'.
.Sp
For \f(CW\*(C`DESTROY\*(C'\fR XSUBs only, a T_REF_IV_PTR is optimized to a T_PTRREF. This
means the class check is skipped.
.IP "T_PTRDESC" 4
.IX Item "T_PTRDESC"
\&\s-1NOT YET\s0
.IP "T_REFREF" 4
.IX Item "T_REFREF"
Similar to T_PTRREF, except the pointer stored in the referenced scalar
is dereferenced and copied to the output variable. This means that
T_REFREF is to T_PTRREF as T_OPAQUE is to T_OPAQUEPTR. All clear?
.Sp
Only the \s-1INPUT\s0 part of this is implemented (Perl to \s-1XSUB\s0) and there
are no known users in core or on \s-1CPAN.\s0
.IP "T_REFOBJ" 4
.IX Item "T_REFOBJ"
Like T_REFREF, except it does strict type checking (inheritance is not
supported).
.Sp
For \f(CW\*(C`DESTROY\*(C'\fR XSUBs only, a T_REFOBJ is optimized to a T_REFREF. This means
the class check is skipped.
.IP "T_OPAQUEPTR" 4
.IX Item "T_OPAQUEPTR"
This can be used to store bytes in the string component of the
\&\s-1SV.\s0 Here the representation of the data is irrelevant to perl and the
bytes themselves are just stored in the \s-1SV.\s0 It is assumed that the C
variable is a pointer (the bytes are copied from that memory
location).  If the pointer is pointing to something that is
represented by 8 bytes then those 8 bytes are stored in the \s-1SV\s0 (and
\&\fBlength()\fR will report a value of 8). This entry is similar to T_OPAQUE.
.Sp
In principle the \fBunpack()\fR command can be used to convert the bytes
back to a number (if the underlying type is known to be a number).
.Sp
This entry can be used to store a C structure (the number
of bytes to be copied is calculated using the C \f(CW\*(C`sizeof\*(C'\fR function)
and can be used as an alternative to T_PTRREF without having to worry
about a memory leak (since Perl will clean up the \s-1SV\s0).
.IP "T_OPAQUE" 4
.IX Item "T_OPAQUE"
This can be used to store data from non-pointer types in the string
part of an \s-1SV.\s0 It is similar to T_OPAQUEPTR except that the
typemap retrieves the pointer directly rather than assuming it
is being supplied. For example, if an integer is imported into
Perl using T_OPAQUE rather than T_IV the underlying bytes representing
the integer will be stored in the \s-1SV\s0 but the actual integer value will
not be available. i.e. The data is opaque to perl.
.Sp
The data may be retrieved using the \f(CW\*(C`unpack\*(C'\fR function if the
underlying type of the byte stream is known.
.Sp
T_OPAQUE supports input and output of simple types.
T_OPAQUEPTR can be used to pass these bytes back into C if a pointer
is acceptable.
.IP "Implicit array" 4
.IX Item "Implicit array"
xsubpp supports a special syntax for returning
packed C arrays to perl. If the \s-1XS\s0 return type is given as
.Sp
.Vb 1
\&  array(type, nelem)
.Ve
.Sp
xsubpp will copy the contents of \f(CW\*(C`nelem * sizeof(type)\*(C'\fR bytes from
\&\s-1RETVAL\s0 to an \s-1SV\s0 and push it onto the stack. This is only really useful
if the number of items to be returned is known at compile time and you
don't mind having a string of bytes in your \s-1SV.\s0  Use T_ARRAY to push a
variable number of arguments onto the return stack (they won't be
packed as a single string though).
.Sp
This is similar to using T_OPAQUEPTR but can be used to process more
than one element.
.IP "T_PACKED" 4
.IX Item "T_PACKED"
Calls user-supplied functions for conversion. For \f(CW\*(C`OUTPUT\*(C'\fR
(\s-1XSUB\s0 to Perl), a function named \f(CW\*(C`XS_pack_$ntype\*(C'\fR is called
with the output Perl scalar and the C variable to convert from.
\&\f(CW$ntype\fR is the normalized C type that is to be mapped to
Perl. Normalized means that all \f(CW\*(C`*\*(C'\fR are replaced by the
string \f(CW\*(C`Ptr\*(C'\fR. The return value of the function is ignored.
.Sp
Conversely for \f(CW\*(C`INPUT\*(C'\fR (Perl to \s-1XSUB\s0) mapping, the
function named \f(CW\*(C`XS_unpack_$ntype\*(C'\fR is called with the input Perl
scalar as argument and the return value is cast to the mapped
C type and assigned to the output C variable.
.Sp
An example conversion function for a typemapped struct
\&\f(CW\*(C`foo_t *\*(C'\fR might be:
.Sp
.Vb 8
\&  static void
\&  XS_pack_foo_tPtr(SV *out, foo_t *in)
\&  {
\&    dTHX; /* alas, signature does not include pTHX_ */
\&    HV* hash = newHV();
\&    hv_stores(hash, "int_member", newSViv(in\->int_member));
\&    hv_stores(hash, "float_member", newSVnv(in\->float_member));
\&    /* ... */
\&
\&    /* mortalize as thy stack is not refcounted */
\&    sv_setsv(out, sv_2mortal(newRV_noinc((SV*)hash)));
\&  }
.Ve
.Sp
The conversion from Perl to C is left as an exercise to the reader,
but the prototype would be:
.Sp
.Vb 2
\&  static foo_t *
\&  XS_unpack_foo_tPtr(SV *in);
.Ve
.Sp
Instead of an actual C function that has to fetch the thread context
using \f(CW\*(C`dTHX\*(C'\fR, you can define macros of the same name and avoid the
overhead. Also, keep in mind to possibly free the memory allocated by
\&\f(CW\*(C`XS_unpack_foo_tPtr\*(C'\fR.
.IP "T_PACKEDARRAY" 4
.IX Item "T_PACKEDARRAY"
T_PACKEDARRAY is similar to T_PACKED. In fact, the \f(CW\*(C`INPUT\*(C'\fR (Perl
to \s-1XSUB\s0) typemap is identical, but the \f(CW\*(C`OUTPUT\*(C'\fR typemap passes
an additional argument to the \f(CW\*(C`XS_pack_$ntype\*(C'\fR function. This
third parameter indicates the number of elements in the output
so that the function can handle C arrays sanely. The variable
needs to be declared by the user and must have the name
\&\f(CW\*(C`count_$ntype\*(C'\fR where \f(CW$ntype\fR is the normalized C type name
as explained above. The signature of the function would be for
the example above and \f(CW\*(C`foo_t **\*(C'\fR:
.Sp
.Vb 2
\&  static void
\&  XS_pack_foo_tPtrPtr(SV *out, foo_t *in, UV count_foo_tPtrPtr);
.Ve
.Sp
The type of the third parameter is arbitrary as far as the typemap
is concerned. It just has to be in line with the declared variable.
.Sp
Of course, unless you know the number of elements in the
\&\f(CW\*(C`sometype **\*(C'\fR C array, within your \s-1XSUB,\s0 the return value from
\&\f(CW\*(C`foo_t ** XS_unpack_foo_tPtrPtr(...)\*(C'\fR will be hard to decipher.
Since the details are all up to the \s-1XS\s0 author (the typemap user),
there are several solutions, none of which particularly elegant.
The most commonly seen solution has been to allocate memory for
N+1 pointers and assign \f(CW\*(C`NULL\*(C'\fR to the (N+1)th to facilitate
iteration.
.Sp
Alternatively, using a customized typemap for your purposes in
the first place is probably preferable.
.IP "T_DATAUNIT" 4
.IX Item "T_DATAUNIT"
\&\s-1NOT YET\s0
.IP "T_CALLBACK" 4
.IX Item "T_CALLBACK"
\&\s-1NOT YET\s0
.IP "T_ARRAY" 4
.IX Item "T_ARRAY"
This is used to convert the perl argument list to a C array
and for pushing the contents of a C array onto the perl
argument stack.
.Sp
The usual calling signature is
.Sp
.Vb 1
\&  @out = array_func( @in );
.Ve
.Sp
Any number of arguments can occur in the list before the array but
the input and output arrays must be the last elements in the list.
.Sp
When used to pass a perl list to C the \s-1XS\s0 writer must provide a
function (named after the array type but with 'Ptr' substituted for
\&'*') to allocate the memory required to hold the list. A pointer
should be returned. It is up to the \s-1XS\s0 writer to free the memory on
exit from the function. The variable \f(CW\*(C`ix_$var\*(C'\fR is set to the number
of elements in the new array.
.Sp
When returning a C array to Perl the \s-1XS\s0 writer must provide an integer
variable called \f(CW\*(C`size_$var\*(C'\fR containing the number of elements in the
array. This is used to determine how many elements should be pushed
onto the return argument stack. This is not required on input since
Perl knows how many arguments are on the stack when the routine is
called. Ordinarily this variable would be called \f(CW\*(C`size_RETVAL\*(C'\fR.
.Sp
Additionally, the type of each element is determined from the type of
the array. If the array uses type \f(CW\*(C`intArray *\*(C'\fR xsubpp will
automatically work out that it contains variables of type \f(CW\*(C`int\*(C'\fR and
use that typemap entry to perform the copy of each element. All
pointer '*' and 'Array' tags are removed from the name to determine
the subtype.
.IP "T_STDIO" 4
.IX Item "T_STDIO"
This is used for passing perl filehandles to and from C using
\&\f(CW\*(C`FILE *\*(C'\fR structures.
.IP "T_INOUT" 4
.IX Item "T_INOUT"
This is used for passing perl filehandles to and from C using
\&\f(CW\*(C`PerlIO *\*(C'\fR structures. The file handle can used for reading and
writing. This corresponds to the \f(CW\*(C`+<\*(C'\fR mode, see also T_IN
and T_OUT.
.Sp
See perliol for more information on the Perl \s-1IO\s0 abstraction
layer. Perl must have been built with \f(CW\*(C`\-Duseperlio\*(C'\fR.
.Sp
There is no check to assert that the filehandle passed from Perl
to C was created with the right \f(CW\*(C`open()\*(C'\fR mode.
.Sp
Hint: The perlxstut tutorial covers the T_INOUT, T_IN, and T_OUT
\&\s-1XS\s0 types nicely.
.IP "T_IN" 4
.IX Item "T_IN"
Same as T_INOUT, but the filehandle that is returned from C to Perl
can only be used for reading (mode \f(CW\*(C`<\*(C'\fR).
.IP "T_OUT" 4
.IX Item "T_OUT"
Same as T_INOUT, but the filehandle that is returned from C to Perl
is set to use the open mode \f(CW\*(C`+>\*(C'\fR.

Man Man