1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>perlxstypemap - perldoc.perl.org</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Language" content="en-gb">
<link rel="search" type="application/opensearchdescription+xml" title="Search perldoc.perl.org" href="/static/search.xml"/>
<link href="static/css-20100830.css" rel="stylesheet" rev="stylesheet" type="text/css" media="screen">
<link href="static/exploreperl.css" rel="stylesheet" rev="stylesheet" type="text/css">
</head>
<body onLoad="perldoc.startup();" onPageShow="if (event.persisted) perldoc.startup();">
<div id="page">
<div id="header">
<div id="homepage_link">
<a href="index.html"></a>
</div>
<div id="strapline">
Perl Programming Documentation
</div>
<div id="download_link" class="download">
<a href="http://www.perl.org/get.html">Download Perl</a>
</div>
<div id="explore_link" class="download">
<a id="explore_anchor" href="#">Explore</a>
</div>
</div>
<div id="body">
<div id="left_column">
<div class="side_group">
<div class="side_panel doc_panel">
<p>Manual</p>
<ul>
<li><a href="index-overview.html">Overview</a>
<li><a href="index-tutorials.html">Tutorials</a>
<li><a href="index-faq.html">FAQs</a>
<li><a href="index-history.html">History / Changes</a>
<li><a href="index-licence.html">License</a>
</ul>
</div>
<div class="side_panel doc_panel">
<p>Reference</p>
<ul>
<li><a href="index-language.html">Language</a>
<li><a href="index-functions.html">Functions</a>
<li><a href="perlop.html">Operators</a>
<li><a href="perlvar.html">Special Variables</a>
<li><a href="index-pragmas.html">Pragmas</a>
<li><a href="index-utilities.html">Utilities</a>
<li><a href="index-internals.html">Internals</a>
<li><a href="index-platforms.html">Platform Specific</a>
</ul>
</div>
<div class="side_panel doc_panel">
<p>Modules</p>
<ul>
<li>
<a href="index-modules-A.html">A</a>
•
<a href="index-modules-B.html">B</a>
•
<a href="index-modules-C.html">C</a>
•
<a href="index-modules-D.html">D</a>
•
<a href="index-modules-E.html">E</a>
<li>
<a href="index-modules-F.html">F</a>
•
<a href="index-modules-G.html">G</a>
•
<a href="index-modules-H.html">H</a>
•
<a href="index-modules-I.html">I</a>
•
<a href="index-modules-L.html">L</a>
<li>
<a href="index-modules-M.html">M</a>
•
<a href="index-modules-N.html">N</a>
•
<a href="index-modules-O.html">O</a>
•
<a href="index-modules-P.html">P</a>
•
<a href="index-modules-S.html">S</a>
<li>
<a href="index-modules-T.html">T</a>
•
<a href="index-modules-U.html">U</a>
•
<a href="index-modules-X.html">X</a>
</ul>
</div>
<div class="side_panel doc_panel">
<p>Tools</p>
<ul>
<li><a href="preferences.html">Preferences</a>
</ul>
</div>
</div>
</div>
<div id="centre_column">
<div id="content_header">
<div id="title_bar">
<div id="page_name">
<h1>perlxstypemap</h1>
</div>
<div id="perl_version">
Perl 5 version 22.0 documentation
</div>
<div class="page_links" id="page_links_top">
<a href="#" onClick="toolbar.goToTop();return false;">Go to top</a>
</div>
<div class="page_links" id="page_links_bottom">
<a href="#" id="page_index_toggle">Show page index</a> •
<a href="#" id="recent_pages_toggle">Show recent pages</a>
</div>
<div id="search_form">
<form action="search.html" method="GET" id="search">
<input type="text" name="q" id="search_box" alt="Search">
</form>
</div>
</div>
<div id="breadcrumbs">
<a href="index.html">Home</a> >
<a href="index-internals.html">Internals and C language interface</a> >
perlxstypemap
</div>
</div>
<div id="content_body">
<!--[if lt IE 7]>
<div class="noscript">
<p>
<strong>It looks like you're using Internet Explorer 6. This is a very old
browser which does not offer full support for modern websites.</strong>
</p>
<p>
Unfortunately this means that this website will not work on
your computer.
</p>
<p>
Don't miss out though! To view the site (and get a better experience from
many other websites), simply upgrade to
<a href="http://www.microsoft.com/windows/Internet-explorer/default.aspx">Internet
Explorer 8</a>
or download an alternative browser such as
<a href="http://www.mozilla.com/en-US/firefox/firefox.html">Firefox</a>,
<a href="http://www.apple.com/safari/download/">Safari</a>, or
<a href="http://www.google.co.uk/chrome">Google Chrome</a>.
</p>
<p>
All of these browsers are free. If you're using a PC at work, you may
need to contact your IT administrator.
</p>
</div>
<![endif]-->
<noscript>
<div class="noscript">
<p>
<strong>Please note: Many features of this site require JavaScript. You appear to have JavaScript disabled,
or are running a non-JavaScript capable web browser.</strong>
</p>
<p>
To get the best experience, please enable JavaScript or download a modern web browser such as <a href="http://www.microsoft.com/windows/Internet-explorer/default.aspx">Internet Explorer 8</a>, <a href="http://www.mozilla.com/en-US/firefox/firefox.html">Firefox</a>, <a href="http://www.apple.com/safari/download/">Safari</a>, or <a href="http://www.google.co.uk/chrome">Google Chrome</a>.
</p>
</div>
</noscript>
<div id="recent_pages" class="hud_container">
<div id="recent_pages_header" class="hud_header">
<div id="recent_pages_close" class="hud_close"><a href="#" onClick="recentPages.hide();return false;"></a></div>
<div id="recent_pages_title" class="hud_title"><span class="hud_span_top">Recently read</span></div>
<div id="recent_pages_topright" class="hud_topright"></div>
</div>
<div id="recent_pages_content" class="hud_content">
</div>
<div id="recent_pages_footer" class="hud_footer">
<div id="recent_pages_bottomleft" class="hud_bottomleft"></div>
<div id="recent_pages_bottom" class="hud_bottom"><span class="hud_span_bottom"></span></div>
<div id="recent_pages_resize" class="hud_resize"></div>
</div>
</div>
<div id="from_search"></div>
<h1>perlxstypemap</h1>
<!-- -->
<ul><li><a href="#NAME">NAME</a><li><a href="#DESCRIPTION">DESCRIPTION</a><ul><li><a href="#Anatomy-of-a-typemap">Anatomy of a typemap</a><li><a href="#The-Role-of-the-typemap-File-in-Your-Distribution">The Role of the typemap File in Your Distribution</a><li><a href="#Sharing-typemaps-Between-CPAN-Distributions">Sharing typemaps Between CPAN Distributions</a><li><a href="#Writing-typemap-Entries">Writing typemap Entries</a><li><a href="#Full-Listing-of-Core-Typemaps">Full Listing of Core Typemaps</a></ul></ul><a name="NAME"></a><h1>NAME</h1>
<p>perlxstypemap - Perl XS C/Perl type mapping</p>
<a name="DESCRIPTION"></a><h1>DESCRIPTION</h1>
<p>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.</p>
<p>Perl XS' attempt at a solution to this is the concept of typemaps.
At an abstract level, a Perl XS 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, XS typemaps are represented by a unique identifier,
henceforth called an <b>XS type</b> in this document. You can then tell
the XS compiler that multiple C types are to be mapped with the same
XS typemap.</p>
<p>In your XS code, when you define an argument with a C type or when
you are using a <code class="inline"><span class="j">CODE:</span></code>
and an <code class="inline"><span class="j">OUTPUT:</span></code>
section together with a
C return type of your XSUB, it'll be the typemapping mechanism that
makes this easy.</p>
<a name="Anatomy-of-a-typemap"></a><h2>Anatomy of a typemap</h2>
<p>In more practical terms, the typemap is a collection of code
fragments which are used by the <b>xsubpp</b> compiler to map C function
parameters and values to Perl values. The typemap file may consist
of three sections labelled <code class="inline"><span class="w">TYPEMAP</span></code>
, <code class="inline"><span class="w">INPUT</span></code>
, and <code class="inline"><span class="w">OUTPUT</span></code>
.
An unlabelled initial section is assumed to be a <code class="inline"><span class="w">TYPEMAP</span></code>
section.
The INPUT section tells the compiler how to translate Perl values
into variables of certain C types. The OUTPUT section tells the
compiler how to translate the values from certain C types into values
Perl can understand. The TYPEMAP section tells the compiler which
of the INPUT and OUTPUT code fragments should be used to map a given
C type to a Perl value. The section labels <code class="inline"><span class="w">TYPEMAP</span></code>
, <code class="inline"><span class="w">INPUT</span></code>
, or
<code class="inline"><span class="w">OUTPUT</span></code>
must begin in the first column on a line by themselves,
and must be in uppercase.</p>
<p>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 <code class="inline"><span class="w">INPUT</span></code>
and <code class="inline"><span class="w">OUTPUT</span></code>
sections if all it needs to
do is associate additional C types with core XS types like T_PTROBJ.
Lines that start with a hash <code class="inline"><span class="c">#</span></code>
are considered comments and ignored
in the <code class="inline"><span class="w">TYPEMAP</span></code>
section, but are considered significant in <code class="inline"><span class="w">INPUT</span></code>
and <code class="inline"><span class="w">OUTPUT</span></code>
. Blank lines are generally ignored.</p>
<p>Traditionally, typemaps needed to be written to a separate file,
conventionally called <code class="inline"><span class="w">typemap</span></code>
in a CPAN distribution. With
ExtUtils::ParseXS (the XS compiler) version 3.12 or better which
comes with perl 5.16, typemaps can also be embedded directly into
XS code using a HERE-doc like syntax:</p>
<pre class="verbatim"><ol><li> <span class="j">TYPEMAP:</span> <span class="h"><<HERE</span></li><li><span class="hh"> ...</span></li><li><span class="hh"> HERE</span></li></ol></pre><p>where <code class="inline"><span class="w">HERE</span></code>
can be replaced by other identifiers like with normal
Perl HERE-docs. All details below about the typemap textual format
remain valid.</p>
<p>The <code class="inline"><span class="w">TYPEMAP</span></code>
section should contain one pair of C type and
XS type per line as follows. An example from the core typemap file:</p>
<pre class="verbatim"><ol><li> <span class="w">TYPEMAP</span></li><li> <span class="c"># all variants of char* is handled by the T_PV typemap</span></li><li> <span class="w">char</span> * <span class="w">T_PV</span></li><li> <span class="w">const</span> <span class="w">char</span> * <span class="w">T_PV</span></li><li> <span class="w">unsigned</span> <span class="w">char</span> * <span class="w">T_PV</span></li><li> ...</li></ol></pre><p>The <code class="inline"><span class="w">INPUT</span></code>
and <code class="inline"><span class="w">OUTPUT</span></code>
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 XS type to
map on a line by itself, followed by the code that implements it
indented on the following lines. Example:</p>
<pre class="verbatim"><ol><li> <span class="w">INPUT</span></li><li> <span class="w">T_PV</span></li><li> <span class="i">$var</span> = <span class="s">(</span><span class="i">$type</span><span class="s">)</span><span class="i">SvPV_nolen</span><span class="s">(</span><span class="i">$arg</span><span class="s">)</span></li><li> <span class="w">T_PTR</span></li><li> <span class="i">$var</span> = <span class="i">INT2PTR</span><span class="s">(</span><span class="i">$type</span><span class="cm">,</span><span class="i">SvIV</span><span class="s">(</span><span class="i">$arg</span><span class="s">)</span><span class="s">)</span></li></ol></pre><p>We'll get to the meaning of those Perlish-looking variables in a
little bit.</p>
<p>Finally, here's an example of the full typemap file for mapping C
strings of the <code class="inline"><span class="w">char</span> *</code>
type to Perl scalars/strings:</p>
<pre class="verbatim"><ol><li> <span class="w">TYPEMAP</span></li><li> <span class="w">char</span> * <span class="w">T_PV</span></li><li></li><li> <span class="w">INPUT</span></li><li> <span class="w">T_PV</span></li><li> <span class="i">$var</span> = <span class="s">(</span><span class="i">$type</span><span class="s">)</span><span class="i">SvPV_nolen</span><span class="s">(</span><span class="i">$arg</span><span class="s">)</span></li><li></li><li> <span class="w">OUTPUT</span></li><li> <span class="w">T_PV</span></li><li> <span class="i">sv_setpv</span><span class="s">(</span><span class="s">(</span><span class="w">SV</span>*<span class="s">)</span><span class="i">$arg</span><span class="cm">,</span> <span class="i">$var</span><span class="s">)</span><span class="sc">;</span></li></ol></pre><p>Here's a more complicated example: suppose that you wanted
<code class="inline"><span class="w">struct</span> <span class="w">netconfig</span></code>
to be blessed into the class <code class="inline"><span class="w">Net::Config</span></code>
.
One way to do this is to use underscores (_) to separate package
names, as follows:</p>
<pre class="verbatim"><ol><li> <span class="w">typedef</span> <span class="w">struct</span> <span class="w">netconfig</span> * <span class="w">Net_Config</span><span class="sc">;</span></li></ol></pre><p>And then provide a typemap entry <code class="inline"><span class="w">T_PTROBJ_SPECIAL</span></code>
that maps
underscores to double-colons (::), and declare <code class="inline"><span class="w">Net_Config</span></code>
to be of
that type:</p>
<pre class="verbatim"><ol><li> <span class="w">TYPEMAP</span></li><li> <span class="w">Net_Config</span> <span class="w">T_PTROBJ_SPECIAL</span></li><li></li><li> <span class="w">INPUT</span></li><li> <span class="w">T_PTROBJ_SPECIAL</span></li><li> <a class="l_k" href="functions/if.html">if</a> <span class="s">(</span><span class="i">sv_derived_from</span><span class="s">(</span><span class="i">$arg</span><span class="cm">,</span> \<span class="q">"${(my $ntt=$ntype)=~s/_/::/g;\$ntt}\")){</span></li><li> <span class="q"> IV tmp = SvIV((SV*)SvRV($arg));</span></li><li> <span class="q"> $var = INT2PTR($type, tmp);</span></li><li> <span class="q"> }</span></li><li> <span class="q"> else</span></li><li> <span class="q"> croak(\"$var is not of type ${(my $ntt=$ntype)=~s/_/::/g;\$ntt}\")</span></li><li></li><li> <span class="q"> OUTPUT</span></li><li> <span class="q"> T_PTROBJ_SPECIAL</span></li><li> <span class="q"> sv_setref_pv($arg, \"${(my $ntt=$ntype)=~s/_/::/g;\$ntt}\",</span></li><li> <span class="q"> (void*)$var);</span></li></ol></pre><p>The INPUT and OUTPUT 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.</p>
<p>The <code class="inline"><span class="w">INT2PTR</span></code>
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 <code class="inline"><span class="w">PTR2IV</span></code>
, <code class="inline"><span class="w">PTR2UV</span></code>
, <code class="inline"><span class="w">PTR2NV</span></code>
macros,
to map the other way, which may be useful in OUTPUT sections.</p>
<a name="The-Role-of-the-typemap-File-in-Your-Distribution"></a><h2>The Role of the typemap File in Your Distribution</h2>
<p>The default typemap in the <i>lib/ExtUtils</i> 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 INPUT and OUTPUT maps in the main
typemap. The <b>xsubpp</b> compiler will allow the extension's own typemap to
override any mappings which are in the default typemap. Instead of using
an additional <i>typemap</i> file, typemaps may be embedded verbatim in XS
with a heredoc-like syntax. See the documentation on the <code class="inline"><span class="j">TYPEMAP:</span></code>
XS
keyword.</p>
<p>For CPAN distributions, you can assume that the XS types defined by
the perl core are already available. Additionally, the core typemap
has default XS types for a large number of C types. For example, if
you simply return a <code class="inline"><span class="w">char</span> *</code>
from your XSUB, the core typemap will
have this C type associated with the T_PV XS type. That means your
C string will be copied into the PV (pointer value) slot of a new scalar
that will be returned from your XSUB to Perl.</p>
<p>If you're developing a CPAN distribution using XS, you may add your own
file called <i>typemap</i> 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.</p>
<a name="Sharing-typemaps-Between-CPAN-Distributions"></a><h2>Sharing typemaps Between CPAN Distributions</h2>
<p>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
CPAN distributions. The general idea is to share it as a module that
offers a certain API and have the dependent modules declare that as a
built-time requirement and import the typemap into the XS. An example
of such a typemap-sharing module on CPAN is
<code class="inline"><span class="w">ExtUtils::Typemaps::Basic</span></code>
. Two steps to getting that module's
typemaps available in your code:</p>
<ul>
<li>
<p>Declare <code class="inline"><span class="w">ExtUtils::Typemaps::Basic</span></code>
as a build-time dependency
in <code class="inline"><span class="w">Makefile</span>.<span class="w">PL</span></code>
(use <code class="inline"><span class="w">BUILD_REQUIRES</span></code>
), or in your <code class="inline"><span class="w">Build</span>.<span class="w">PL</span></code>
(use <code class="inline"><span class="w">build_requires</span></code>
).</p>
</li>
<li>
<p>Include the following line in the XS section of your XS file:
(don't break the line)</p>
<pre class="verbatim"><ol><li> <span class="j">INCLUDE_COMMAND:</span> <span class="i">$^X</span> -<span class="w">MExtUtils::Typemaps::Cmd</span></li><li> -e <span class="q">"print embeddable_typemap(q{Basic})"</span></li></ol></pre></li>
</ul>
<a name="Writing-typemap-Entries"></a><h2>Writing typemap Entries</h2>
<p>Each INPUT or OUTPUT 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.</p>
<p>This means that you can embed Perl code in your typemap (C) code using
constructs such as
<code class="inline"><span class="i">$</span>{ <span class="w">perl</span> <span class="w">code</span> <span class="w">that</span> <span class="w">evaluates</span> <span class="w">to</span> <a class="l_k" href="functions/scalar.html">scalar</a> <span class="w">reference</span> <span class="w">here</span> }</code>
. A common
use case is to generate error messages that refer to the true function
name even when using the ALIAS XS feature:</p>
<pre class="verbatim"><ol><li> <span class="i">$</span>{ <span class="i">$ALIAS</span> ? \<span class="q">q[GvNAME(CvGV(cv))]</span> <span class="co">:</span> \<span class="q">qq[\"$pname\"]</span> }</li></ol></pre><p>For many typemap examples, refer to the core typemap file that can be
found in the perl source tree at <i>lib/ExtUtils/typemap</i>.</p>
<p>The Perl variables that are available for interpolation into typemaps
are the following:</p>
<ul>
<li>
<p><i>$var</i> - the name of the input or output variable, eg. RETVAL for
return values.</p>
</li>
<li>
<p><i>$type</i> - the raw C type of the parameter, any <code class="inline"><span class="j">:</span></code>
replaced with
<code class="inline"><span class="w">_</span></code>
.
e.g. for a type of <code class="inline"><span class="w">Foo::Bar</span></code>
, <i>$type</i> is <code class="inline"><span class="w">Foo__Bar</span></code>
</p>
</li>
<li>
<p><i>$ntype</i> - the supplied type with <code class="inline"><span class="i">*</span></code>
replaced with <code class="inline"><span class="w">Ptr</span></code>
.
e.g. for a type of <code class="inline"><span class="w">Foo</span>*</code>
, <i>$ntype</i> is <code class="inline"><span class="w">FooPtr</span></code>
</p>
</li>
<li>
<p><i>$arg</i> - the stack entry, that the parameter is input from or output
to, e.g. <code class="inline"><span class="i">ST</span><span class="s">(</span><span class="n">0</span><span class="s">)</span></code>
</p>
</li>
<li>
<p><i>$argoff</i> - the argument stack offset of the argument. ie. 0 for the
first argument, etc.</p>
</li>
<li>
<p><i>$pname</i> - the full name of the XSUB, with including the <code class="inline"><span class="w">PACKAGE</span></code>
name, with any <code class="inline"><span class="w">PREFIX</span></code>
stripped. This is the non-ALIAS name.</p>
</li>
<li>
<p><i>$Package</i> - the package specified by the most recent <code class="inline"><span class="w">PACKAGE</span></code>
keyword.</p>
</li>
<li>
<p><i>$ALIAS</i> - non-zero if the current XSUB has any aliases declared with
<code class="inline"><span class="w">ALIAS</span></code>
.</p>
</li>
</ul>
<a name="Full-Listing-of-Core-Typemaps"></a><h2>Full Listing of Core Typemaps</h2>
<p>Each C type is represented by an entry in the typemap file that
is responsible for converting perl variables (SV, AV, HV, CV, etc.)
to and from that type. The following sections list all XS types
that come with perl by default.</p>
<ul>
<li><a name="T_SV"></a><b>T_SV</b>
<p>This simply passes the C representation of the Perl variable (an SV*)
in and out of the XS layer. This can be used if the C code wants
to deal directly with the Perl variable.</p>
</li>
<li><a name="T_SVREF"></a><b>T_SVREF</b>
<p>Used to pass in and return a reference to an SV.</p>
<p>Note that this typemap does not decrement the reference count
when returning the reference to an SV*.
See also: T_SVREF_REFCOUNT_FIXED</p>
</li>
<li><a name="T_SVREF_FIXED"></a><b>T_SVREF_FIXED</b>
<p>Used to pass in and return a reference to an SV.
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.</p>
</li>
<li><a name="T_AVREF"></a><b>T_AVREF</b>
<p>From the perl level this is a reference to a perl array.
From the C level this is a pointer to an AV.</p>
<p>Note that this typemap does not decrement the reference count
when returning an AV*. See also: T_AVREF_REFCOUNT_FIXED</p>
</li>
<li><a name="T_AVREF_REFCOUNT_FIXED"></a><b>T_AVREF_REFCOUNT_FIXED</b>
<p>From the perl level this is a reference to a perl array.
From the C level this is a pointer to an AV. This is a fixed
variant of T_AVREF that decrements the refcount appropriately
when returning an AV*. Introduced in perl 5.15.4.</p>
</li>
<li><a name="T_HVREF"></a><b>T_HVREF</b>
<p>From the perl level this is a reference to a perl hash.
From the C level this is a pointer to an HV.</p>
<p>Note that this typemap does not decrement the reference count
when returning an HV*. See also: T_HVREF_REFCOUNT_FIXED</p>
</li>
<li><a name="T_HVREF_REFCOUNT_FIXED"></a><b>T_HVREF_REFCOUNT_FIXED</b>
<p>From the perl level this is a reference to a perl hash.
From the C level this is a pointer to an HV. This is a fixed
variant of T_HVREF that decrements the refcount appropriately
when returning an HV*. Introduced in perl 5.15.4.</p>
</li>
<li><a name="T_CVREF"></a><b>T_CVREF</b>
<p>From the perl level this is a reference to a perl subroutine
(e.g. $sub = sub { 1 };). From the C level this is a pointer
to a CV.</p>
<p>Note that this typemap does not decrement the reference count
when returning an HV*. See also: T_HVREF_REFCOUNT_FIXED</p>
</li>
<li><a name="T_CVREF_REFCOUNT_FIXED"></a><b>T_CVREF_REFCOUNT_FIXED</b>
<p>From the perl level this is a reference to a perl subroutine
(e.g. $sub = sub { 1 };). From the C level this is a pointer
to a CV.</p>
<p>This is a fixed
variant of T_HVREF that decrements the refcount appropriately
when returning an HV*. Introduced in perl 5.15.4.</p>
</li>
<li><a name="T_SYSRET"></a><b>T_SYSRET</b>
<p>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).</p>
<p>System calls return -1 on error (setting ERRNO with the reason)
and (usually) 0 on success. If the return value is -1 this typemap
returns <code class="inline"><a class="l_k" href="functions/undef.html">undef</a></code>. If the return value is not -1, this typemap
translates a 0 (perl false) to "0 but true" (which
is perl true) or returns the value itself, to indicate that the
command succeeded.</p>
<p>The <a href="POSIX.html">POSIX</a> module makes extensive use of this type.</p>
</li>
<li><a name="T_UV"></a><b>T_UV</b>
<p>An unsigned integer.</p>
</li>
<li><a name="T_IV"></a><b>T_IV</b>
<p>A signed integer. This is cast to the required integer type when
passed to C and converted to an IV when passed back to Perl.</p>
</li>
<li><a name="T_INT"></a><b>T_INT</b>
<p>A signed integer. This typemap converts the Perl value to a native
integer type (the <code class="inline"><a class="l_k" href="functions/int.html">int</a></code> type on the current platform). When returning
the value to perl it is processed in the same way as for T_IV.</p>
<p>Its behaviour is identical to using an <code class="inline"><a class="l_k" href="functions/int.html">int</a></code> type in XS with T_IV.</p>
</li>
<li><a name="T_ENUM"></a><b>T_ENUM</b>
<p>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 IV inside perl.</p>
</li>
<li><a name="T_BOOL"></a><b>T_BOOL</b>
<p>A boolean type. This can be used to pass true and false values to and
from C.</p>
</li>
<li><a name="T_U_INT"></a><b>T_U_INT</b>
<p>This is for unsigned integers. It is equivalent to using T_UV
but explicitly casts the variable to type <code class="inline"><span class="w">unsigned</span> <a class="l_k" href="functions/int.html">int</a></code>
.
The default type for <code class="inline"><span class="w">unsigned</span> <a class="l_k" href="functions/int.html">int</a></code>
is T_UV.</p>
</li>
<li><a name="T_SHORT"></a><b>T_SHORT</b>
<p>Short integers. This is equivalent to T_IV but explicitly casts
the return to type <code class="inline"><span class="w">short</span></code>
. The default typemap for <code class="inline"><span class="w">short</span></code>
is T_IV.</p>
</li>
<li><a name="T_U_SHORT"></a><b>T_U_SHORT</b>
<p>Unsigned short integers. This is equivalent to T_UV but explicitly
casts the return to type <code class="inline"><span class="w">unsigned</span> <span class="w">short</span></code>
. The default typemap for
<code class="inline"><span class="w">unsigned</span> <span class="w">short</span></code>
is T_UV.</p>
<p>T_U_SHORT is used for type <code class="inline"><span class="w">U16</span></code>
in the standard typemap.</p>
</li>
<li><a name="T_LONG"></a><b>T_LONG</b>
<p>Long integers. This is equivalent to T_IV but explicitly casts
the return to type <code class="inline"><span class="w">long</span></code>
. The default typemap for <code class="inline"><span class="w">long</span></code>
is T_IV.</p>
</li>
<li><a name="T_U_LONG"></a><b>T_U_LONG</b>
<p>Unsigned long integers. This is equivalent to T_UV but explicitly
casts the return to type <code class="inline"><span class="w">unsigned</span> <span class="w">long</span></code>
. The default typemap for
<code class="inline"><span class="w">unsigned</span> <span class="w">long</span></code>
is T_UV.</p>
<p>T_U_LONG is used for type <code class="inline"><span class="w">U32</span></code>
in the standard typemap.</p>
</li>
<li><a name="T_CHAR"></a><b>T_CHAR</b>
<p>Single 8-bit characters.</p>
</li>
<li><a name="T_U_CHAR"></a><b>T_U_CHAR</b>
<p>An unsigned byte.</p>
</li>
<li><a name="T_FLOAT"></a><b>T_FLOAT</b>
<p>A floating point number. This typemap guarantees to return a variable
cast to a <code class="inline"><span class="w">float</span></code>
.</p>
</li>
<li><a name="T_NV"></a><b>T_NV</b>
<p>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.</p>
</li>
<li><a name="T_DOUBLE"></a><b>T_DOUBLE</b>
<p>A double precision floating point number. This typemap guarantees to
return a variable cast to a <code class="inline"><span class="w">double</span></code>
.</p>
</li>
<li><a name="T_PV"></a><b>T_PV</b>
<p>A string (char *).</p>
</li>
<li><a name="T_PTR"></a><b>T_PTR</b>
<p>A memory address (pointer). Typically associated with a <code class="inline"><span class="w">void</span> *</code>
type.</p>
</li>
<li><a name="T_PTRREF"></a><b>T_PTRREF</b>
<p>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.</p>
<p>The typemap checks that a scalar reference is passed from perl to XS.</p>
</li>
<li><a name="T_PTROBJ"></a><b>T_PTROBJ</b>
<p>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 XS routine is of the correct class (or part of a subclass).</p>
<p>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'.</p>
<p>For <code class="inline">DESTROY</code>
XSUBs only, a T_PTROBJ is optimized to a T_PTRREF. This means
the class check is skipped.</p>
</li>
<li><a name="T_REF_IV_REF"></a><b>T_REF_IV_REF</b>
<p>NOT YET</p>
</li>
<li><a name="T_REF_IV_PTR"></a><b>T_REF_IV_PTR</b>
<p>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 XS it must be
of the correct type (inheritance is not supported) while T_PTROBJ supports
inheritance.</p>
<p>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'.</p>
<p>For <code class="inline">DESTROY</code>
XSUBs only, a T_REF_IV_PTR is optimized to a T_PTRREF. This
means the class check is skipped.</p>
</li>
<li><a name="T_PTRDESC"></a><b>T_PTRDESC</b>
<p>NOT YET</p>
</li>
<li><a name="T_REFREF"></a><b>T_REFREF</b>
<p>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?</p>
<p>Only the INPUT part of this is implemented (Perl to XSUB) and there
are no known users in core or on CPAN.</p>
</li>
<li><a name="T_REFOBJ"></a><b>T_REFOBJ</b>
<p>Like T_REFREF, except it does strict type checking (inheritance is not
supported).</p>
<p>For <code class="inline">DESTROY</code>
XSUBs only, a T_REFOBJ is optimized to a T_REFREF. This means
the class check is skipped.</p>
</li>
<li><a name="T_OPAQUEPTR"></a><b>T_OPAQUEPTR</b>
<p>This can be used to store bytes in the string component of the
SV. Here the representation of the data is irrelevant to perl and the
bytes themselves are just stored in the SV. 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 SV (and
length() will report a value of 8). This entry is similar to T_OPAQUE.</p>
<p>In principle the unpack() command can be used to convert the bytes
back to a number (if the underlying type is known to be a number).</p>
<p>This entry can be used to store a C structure (the number
of bytes to be copied is calculated using the C <code class="inline"><span class="w">sizeof</span></code>
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 SV).</p>
</li>
<li><a name="T_OPAQUE"></a><b>T_OPAQUE</b>
<p>This can be used to store data from non-pointer types in the string
part of an SV. 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 SV but the actual integer value will
not be available. i.e. The data is opaque to perl.</p>
<p>The data may be retrieved using the <code class="inline"><a class="l_k" href="functions/unpack.html">unpack</a></code> function if the
underlying type of the byte stream is known.</p>
<p>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.</p>
</li>
<li><a name="Implicit-array"></a><b>Implicit array</b>
<p>xsubpp supports a special syntax for returning
packed C arrays to perl. If the XS return type is given as</p>
<pre class="verbatim"><ol><li> <span class="i">array</span><span class="s">(</span><span class="w">type</span><span class="cm">,</span> <span class="w">nelem</span><span class="s">)</span></li></ol></pre><p>xsubpp will copy the contents of <code class="inline"><span class="w">nelem</span> * <span class="i">sizeof</span><span class="s">(</span><span class="w">type</span><span class="s">)</span></code>
bytes from
RETVAL to an SV 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 SV. Use T_ARRAY to push a
variable number of arguments onto the return stack (they won't be
packed as a single string though).</p>
<p>This is similar to using T_OPAQUEPTR but can be used to process more
than one element.</p>
</li>
<li><a name="T_PACKED"></a><b>T_PACKED</b>
<p>Calls user-supplied functions for conversion. For <code class="inline"><span class="w">OUTPUT</span></code>
(XSUB to Perl), a function named <code class="inline"><span class="w">XS_pack_</span><span class="i">$ntype</span></code>
is called
with the output Perl scalar and the C variable to convert from.
<code class="inline"><span class="i">$ntype</span></code>
is the normalized C type that is to be mapped to
Perl. Normalized means that all <code class="inline"><span class="i">*</span></code>
are replaced by the
string <code class="inline"><span class="w">Ptr</span></code>
. The return value of the function is ignored.</p>
<p>Conversely for <code class="inline"><span class="w">INPUT</span></code>
(Perl to XSUB) mapping, the
function named <code class="inline"><span class="w">XS_unpack_</span><span class="i">$ntype</span></code>
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.</p>
<p>An example conversion function for a typemapped struct
<code class="inline"><span class="w">foo_t</span> *</code>
might be:</p>
<pre class="verbatim"><ol><li> <span class="w">static</span> <span class="w">void</span></li><li> <span class="i">XS_pack_foo_tPtr</span><span class="s">(</span><span class="w">SV</span> *<span class="w">out</span><span class="cm">,</span> <span class="w">foo_t</span> *<span class="w">in</span><span class="s">)</span></li><li> <span class="s">{</span></li><li> <span class="w">dTHX</span><span class="sc">;</span> <span class="q">/* alas, signature does not include pTHX_ */</span></li><li> <span class="w">HV</span>* <span class="w">hash</span> = <span class="i">newHV</span><span class="s">(</span><span class="s">)</span><span class="sc">;</span></li><li> <span class="i">hv_stores</span><span class="s">(</span><span class="w">hash</span><span class="cm">,</span> <span class="q">"int_member"</span><span class="cm">,</span> <span class="i">newSViv</span><span class="s">(</span><span class="w">in</span><span class="w">->int_member</span><span class="s">)</span><span class="s">)</span><span class="sc">;</span></li><li> <span class="i">hv_stores</span><span class="s">(</span><span class="w">hash</span><span class="cm">,</span> <span class="q">"float_member"</span><span class="cm">,</span> <span class="i">newSVnv</span><span class="s">(</span><span class="w">in</span><span class="w">->float_member</span><span class="s">)</span><span class="s">)</span><span class="sc">;</span></li><li> <span class="q">/* ... */</span></li><li></li><li> /<span class="i">* mortalize</span> <span class="w">as</span> <span class="w">thy</span> <span class="w">stack</span> <span class="w">is</span> <a class="l_k" href="functions/not.html">not</a> <span class="w">refcounted</span> *<span class="q">/</span></li><li> <span class="q"> sv_setsv(out, sv_2mortal(newRV_noinc((SV*)hash)));</span></li><li> <span class="q"> }</span></li></ol></pre><p>The conversion from Perl to C is left as an exercise to the reader,
but the prototype would be:</p>
<pre class="verbatim"><ol><li> <span class="w">static</span> <span class="w">foo_t</span> *</li><li> <span class="i">XS_unpack_foo_tPtr</span><span class="s">(</span><span class="w">SV</span> *<span class="w">in</span><span class="s">)</span><span class="sc">;</span></li></ol></pre><p>Instead of an actual C function that has to fetch the thread context
using <code class="inline"><span class="w">dTHX</span></code>
, you can define macros of the same name and avoid the
overhead. Also, keep in mind to possibly free the memory allocated by
<code class="inline"><span class="w">XS_unpack_foo_tPtr</span></code>
.</p>
</li>
<li><a name="T_PACKEDARRAY"></a><b>T_PACKEDARRAY</b>
<p>T_PACKEDARRAY is similar to T_PACKED. In fact, the <code class="inline"><span class="w">INPUT</span></code>
(Perl
to XSUB) typemap is identical, but the <code class="inline"><span class="w">OUTPUT</span></code>
typemap passes
an additional argument to the <code class="inline"><span class="w">XS_pack_</span><span class="i">$ntype</span></code>
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
<code class="inline"><span class="w">count_</span><span class="i">$ntype</span></code>
where <code class="inline"><span class="i">$ntype</span></code>
is the normalized C type name
as explained above. The signature of the function would be for
the example above and <code class="inline"><span class="w">foo_t</span> **</code>
:</p>
<pre class="verbatim"><ol><li> <span class="w">static</span> <span class="w">void</span></li><li> <span class="i">XS_pack_foo_tPtrPtr</span><span class="s">(</span><span class="w">SV</span> *<span class="w">out</span><span class="cm">,</span> <span class="w">foo_t</span> *<span class="w">in</span><span class="cm">,</span> <span class="w">UV</span> <span class="w">count_foo_tPtrPtr</span><span class="s">)</span><span class="sc">;</span></li></ol></pre><p>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.</p>
<p>Of course, unless you know the number of elements in the
<code class="inline"><span class="w">sometype</span> **</code>
C array, within your XSUB, the return value from
<code class="inline"><span class="w">foo_t</span> ** <span class="i">XS_unpack_foo_tPtrPtr</span><span class="s">(</span>...<span class="s">)</span></code>
will be hard to decipher.
Since the details are all up to the XS 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 <code class="inline"><span class="w">NULL</span></code>
to the (N+1)th to facilitate
iteration.</p>
<p>Alternatively, using a customized typemap for your purposes in
the first place is probably preferable.</p>
</li>
<li><a name="T_DATAUNIT"></a><b>T_DATAUNIT</b>
<p>NOT YET</p>
</li>
<li><a name="T_CALLBACK"></a><b>T_CALLBACK</b>
<p>NOT YET</p>
</li>
<li><a name="T_ARRAY"></a><b>T_ARRAY</b>
<p>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.</p>
<p>The usual calling signature is</p>
<pre class="verbatim"><ol><li> <span class="i">@out</span> = <span class="i">array_func</span><span class="s">(</span> <span class="i">@in</span> <span class="s">)</span><span class="sc">;</span></li></ol></pre><p>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.</p>
<p>When used to pass a perl list to C the XS 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 XS writer to free the memory on
exit from the function. The variable <code class="inline"><span class="w">ix_</span><span class="i">$var</span></code>
is set to the number
of elements in the new array.</p>
<p>When returning a C array to Perl the XS writer must provide an integer
variable called <code class="inline"><span class="w">size_</span><span class="i">$var</span></code>
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 <code class="inline"><span class="w">size_RETVAL</span></code>
.</p>
<p>Additionally, the type of each element is determined from the type of
the array. If the array uses type <code class="inline"><span class="w">intArray</span> *</code>
xsubpp will
automatically work out that it contains variables of type <code class="inline"><a class="l_k" href="functions/int.html">int</a></code> 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.</p>
</li>
<li><a name="T_STDIO"></a><b>T_STDIO</b>
<p>This is used for passing perl filehandles to and from C using
<code class="inline"><span class="w">FILE</span> *</code>
structures.</p>
</li>
<li><a name="T_INOUT"></a><b>T_INOUT</b>
<p>This is used for passing perl filehandles to and from C using
<code class="inline"><span class="w">PerlIO</span> *</code>
structures. The file handle can used for reading and
writing. This corresponds to the <code class="inline">+<</code>
mode, see also T_IN
and T_OUT.</p>
<p>See <a href="perliol.html">perliol</a> for more information on the Perl IO abstraction
layer. Perl must have been built with <code class="inline">-<span class="w">Duseperlio</span></code>
.</p>
<p>There is no check to assert that the filehandle passed from Perl
to C was created with the right <code class="inline"><a class="l_k" href="functions/open.html">open()</a></code> mode.</p>
<p>Hint: The <a href="perlxstut.html">perlxstut</a> tutorial covers the T_INOUT, T_IN, and T_OUT
XS types nicely.</p>
</li>
<li><a name="T_IN"></a><b>T_IN</b>
<p>Same as T_INOUT, but the filehandle that is returned from C to Perl
can only be used for reading (mode <code class="inline"><</code>
).</p>
</li>
<li><a name="T_OUT"></a><b>T_OUT</b>
<p>Same as T_INOUT, but the filehandle that is returned from C to Perl
is set to use the open mode <code class="inline">+></code>.</p>
</li>
</ul>
<div id="page_index" class="hud_container">
<div id="page_index_header" class="hud_header">
<div id="page_index_close" class="hud_close"><a href="#" onClick="pageIndex.hide();return false;"></a></div>
<div id="page_index_title" class="hud_title"><span class="hud_span_top">Page index</span></div>
<div id="page_index_topright" class="hud_topright"></div>
</div>
<div id="page_index_content" class="hud_content">
<ul><li><a href="#NAME">NAME</a><li><a href="#DESCRIPTION">DESCRIPTION</a><ul><li><a href="#Anatomy-of-a-typemap">Anatomy of a typemap</a><li><a href="#The-Role-of-the-typemap-File-in-Your-Distribution">The Role of the typemap File in Your Distribution</a><li><a href="#Sharing-typemaps-Between-CPAN-Distributions">Sharing typemaps Between CPAN Distributions</a><li><a href="#Writing-typemap-Entries">Writing typemap Entries</a><li><a href="#Full-Listing-of-Core-Typemaps">Full Listing of Core Typemaps</a></ul></ul>
</div>
<div id="page_index_footer" class="hud_footer">
<div id="page_index_bottomleft" class="hud_bottomleft"></div>
<div id="page_index_bottom" class="hud_bottom"><span class="hud_span_bottom"></span></div>
<div id="page_index_resize" class="hud_resize"></div>
</div>
</div>
</div>
<div id="content_footer">
</div>
</div>
<div class="clear"></div>
</div>
<div id="footer">
<div id="footer_content">
<div id="footer_strapline">
perldoc.perl.org - Official documentation for the Perl programming language
</div>
<div id="footer_links">
<div id="address">
<p class="name">Contact details</p>
<p class="address">
Site maintained by <a href="mailto:jj@jonallen.info">Jon Allen (JJ)</a><br>
</p>
<p class="contact">
Documentation maintained by the <a href="http://lists.cpan.org/showlist.cgi?name=perl5-porters">Perl 5 Porters</a>
</p>
</div>
<ul class="f1">
<li>Manual
<ul class="f2">
<li><a href="index-overview.html">Overview</a>
<li><a href="index-tutorials.html">Tutorials</a>
<li><a href="index-faq.html">FAQs</a>
<li><a href="index-history.html">Changes</a>
</ul>
<li>Reference
<ul class="f2">
<li><a href="index-language.html">Language</a>
<li><a href="index-functions.html">Functions</a>
<li><a href="perlop.html">Operators</a>
<li><a href="perlvar.html">Variables</a>
</ul>
<li>Modules
<ul class="f2">
<li><a href="index-modules-A.html">Modules</a>
<li><a href="index-pragmas.html">Pragmas</a>
<li><a href="index-utilities.html">Utilities</a>
</ul>
<li>Misc
<ul class="f2">
<li><a href="index-licence.html">License</a>
<li><a href="index-internals.html">Internals</a>
<li><a href="index-platforms.html">Platforms</a>
</ul> </ul>
<div class="clear"></div>
</div>
</div>
<div id="footer_end">
</div>
</div>
</div>
<script language="JavaScript" type="text/javascript" src="static/exploreperl.js"></script>
<script language="JavaScript" src="static/combined-20100403.js" type="text/javascript"></script>
<script language="JavaScript" type="text/javascript">
perldoc.setPath(0);
perldoc.pageName = 'perlxstypemap';
perldoc.pageAddress = 'perlxstypemap.html';
perldoc.contentPage = 1;
explorePerl.render();
explorePerl.addEvents('explore_anchor');
</script>
</body>
</html>
|