From: Robin Barker Date: Tue, 4 Jan 2005 12:32:29 +0000 (+0000) Subject: RE: [perl #32660] INT2PTR not mentioned in perlxs(1) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=049cb4115f5677ea81b63ce0025e2bc136637c77;p=p5sagit%2Fp5-mst-13.2.git RE: [perl #32660] INT2PTR not mentioned in perlxs(1) Message-ID: <533D273D4014D411AB1D00062938C4D90849C553@hotel.npl.co.uk> p4raw-id: //depot/perl@23742 --- diff --git a/pod/perlxs.pod b/pod/perlxs.pod index c09947d..a819697 100644 --- a/pod/perlxs.pod +++ b/pod/perlxs.pod @@ -1833,7 +1833,7 @@ double-colons (::), and declare C to be of that type: T_PTROBJ_SPECIAL if (sv_derived_from($arg, \"${(my $ntt=$ntype)=~s/_/::/g;\$ntt}\")) { IV tmp = SvIV((SV*)SvRV($arg)); - $var = ($type) tmp; + $var = INT2PTR($type, tmp); } else croak(\"$var is not of type ${(my $ntt=$ntype)=~s/_/::/g;\$ntt}\") @@ -1847,6 +1847,11 @@ 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. +The INT2PTR 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 PTR2IV, PTR2UV, PTR2NV macros, +to map the other way, which may be useful in OUTPUT sections. + =head2 Safely Storing Static Data in XS Starting with Perl 5.8, a macro framework has been defined to allow