From 049cb4115f5677ea81b63ce0025e2bc136637c77 Mon Sep 17 00:00:00 2001 From: Robin Barker Date: Tue, 4 Jan 2005 12:32:29 +0000 Subject: RE: [perl #32660] INT2PTR not mentioned in perlxs(1) Message-ID: <533D273D4014D411AB1D00062938C4D90849C553@hotel.npl.co.uk> p4raw-id: //depot/perl@23742 --- pod/perlxs.pod | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'pod') diff --git a/pod/perlxs.pod b/pod/perlxs.pod index c09947d65c..a8196975aa 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 -- cgit v1.2.1