This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
remove prehistoric XFree() gunk
[perl5.git] / lib / ExtUtils / typemap
CommitLineData
56431972 1# $Header: /home/rmb1/misc/CVS/perl5.005_61/lib/ExtUtils/typemap,v 1.3 1999/09/13 09:46:43 rmb1 Exp $
93a17b20 2# basic C types
85e6fe83 3int T_IV
3aa35033
GS
4unsigned T_UV
5unsigned int T_UV
a0d0e21e 6long T_IV
3aa35033 7unsigned long T_UV
85e6fe83 8short T_IV
3aa35033 9unsigned short T_UV
93a17b20 10char T_CHAR
85e6fe83 11unsigned char T_U_CHAR
a0d0e21e
LW
12char * T_PV
13unsigned char * T_PV
14caddr_t T_PV
15wchar_t * T_PV
16wchar_t T_IV
17bool_t T_IV
18size_t T_IV
19ssize_t T_IV
20time_t T_NV
93a17b20
LW
21unsigned long * T_OPAQUEPTR
22char ** T_PACKED
23void * T_PTR
a0d0e21e 24Time_t * T_PV
2304df62 25SV * T_SV
a0d0e21e
LW
26SVREF T_SVREF
27AV * T_AVREF
28HV * T_HVREF
29CV * T_CVREF
93a17b20 30
a0d0e21e 31IV T_IV
0ca04487 32UV T_UV
85e6fe83
LW
33I32 T_IV
34I16 T_IV
35I8 T_IV
93a17b20
LW
36U32 T_U_LONG
37U16 T_U_SHORT
3aa35033 38U8 T_UV
93a17b20 39Result T_U_CHAR
a0d0e21e 40Boolean T_IV
93a17b20 41double T_DOUBLE
2304df62 42SysRet T_SYSRET
a0d0e21e
LW
43SysRetLong T_SYSRET
44FILE * T_IN
45FileHandle T_PTROBJ
46InputStream T_IN
47InOutStream T_INOUT
48OutputStream T_OUT
1cc23d7f 49bool T_BOOL
93a17b20 50
8990e307
LW
51#############################################################################
52INPUT
2304df62 53T_SV
a0d0e21e
LW
54 $var = $arg
55T_SVREF
2304df62 56 if (sv_isa($arg, \"${ntype}\"))
a0d0e21e 57 $var = (SV*)SvRV($arg);
2304df62
AD
58 else
59 croak(\"$var is not of type ${ntype}\")
a0d0e21e 60T_AVREF
2304df62
AD
61 if (sv_isa($arg, \"${ntype}\"))
62 $var = (AV*)SvRV($arg);
63 else
64 croak(\"$var is not of type ${ntype}\")
a0d0e21e 65T_HVREF
2304df62
AD
66 if (sv_isa($arg, \"${ntype}\"))
67 $var = (HV*)SvRV($arg);
68 else
69 croak(\"$var is not of type ${ntype}\")
a0d0e21e 70T_CVREF
2304df62
AD
71 if (sv_isa($arg, \"${ntype}\"))
72 $var = (CV*)SvRV($arg);
73 else
74 croak(\"$var is not of type ${ntype}\")
75T_SYSRET
76 $var NOT IMPLEMENTED
3aa35033
GS
77T_UV
78 $var = ($type)SvUV($arg)
85e6fe83
LW
79T_IV
80 $var = ($type)SvIV($arg)
8990e307
LW
81T_INT
82 $var = (int)SvIV($arg)
83T_ENUM
84 $var = ($type)SvIV($arg)
1cc23d7f
IZ
85T_BOOL
86 $var = (int)SvIV($arg)
8990e307 87T_U_INT
3aa35033 88 $var = (unsigned int)SvUV($arg)
8990e307
LW
89T_SHORT
90 $var = (short)SvIV($arg)
91T_U_SHORT
3aa35033 92 $var = (unsigned short)SvUV($arg)
8990e307
LW
93T_LONG
94 $var = (long)SvIV($arg)
95T_U_LONG
3aa35033 96 $var = (unsigned long)SvUV($arg)
8990e307 97T_CHAR
3280af22 98 $var = (char)*SvPV($arg,PL_na)
8990e307 99T_U_CHAR
3aa35033 100 $var = (unsigned char)SvUV($arg)
8990e307
LW
101T_FLOAT
102 $var = (float)SvNV($arg)
85e6fe83
LW
103T_NV
104 $var = ($type)SvNV($arg)
8990e307 105T_DOUBLE
85e6fe83 106 $var = (double)SvNV($arg)
a0d0e21e 107T_PV
3280af22 108 $var = ($type)SvPV($arg,PL_na)
8990e307 109T_PTR
56431972 110 $var = INT2PTR($type,SvIV($arg))
8990e307 111T_PTRREF
85e6fe83 112 if (SvROK($arg)) {
a0d0e21e 113 IV tmp = SvIV((SV*)SvRV($arg));
56431972 114 $var = INT2PTR($type,tmp);
85e6fe83 115 }
8990e307
LW
116 else
117 croak(\"$var is not a reference\")
a0d0e21e
LW
118T_REF_IV_REF
119 if (sv_isa($arg, \"${type}\")) {
120 IV tmp = SvIV((SV*)SvRV($arg));
121 $var = *($type *) tmp;
122 }
123 else
124 croak(\"$var is not of type ${ntype}\")
125T_REF_IV_PTR
126 if (sv_isa($arg, \"${type}\")) {
127 IV tmp = SvIV((SV*)SvRV($arg));
128 $var = ($type) tmp;
129 }
130 else
131 croak(\"$var is not of type ${ntype}\")
8990e307 132T_PTROBJ
55497cff 133 if (sv_derived_from($arg, \"${ntype}\")) {
a0d0e21e 134 IV tmp = SvIV((SV*)SvRV($arg));
56431972 135 $var = INT2PTR($type,tmp);
85e6fe83 136 }
8990e307
LW
137 else
138 croak(\"$var is not of type ${ntype}\")
139T_PTRDESC
140 if (sv_isa($arg, \"${ntype}\")) {
a0d0e21e 141 IV tmp = SvIV((SV*)SvRV($arg));
85e6fe83 142 ${type}_desc = (\U${type}_DESC\E*) tmp;
8990e307
LW
143 $var = ${type}_desc->ptr;
144 }
145 else
146 croak(\"$var is not of type ${ntype}\")
147T_REFREF
85e6fe83 148 if (SvROK($arg)) {
a0d0e21e 149 IV tmp = SvIV((SV*)SvRV($arg));
56431972 150 $var = *INT2PTR($type,tmp);
85e6fe83 151 }
8990e307
LW
152 else
153 croak(\"$var is not a reference\")
154T_REFOBJ
85e6fe83 155 if (sv_isa($arg, \"${ntype}\")) {
a0d0e21e 156 IV tmp = SvIV((SV*)SvRV($arg));
56431972 157 $var = *INT2PTR($type,tmp);
85e6fe83 158 }
8990e307
LW
159 else
160 croak(\"$var is not of type ${ntype}\")
161T_OPAQUE
162 $var NOT IMPLEMENTED
163T_OPAQUEPTR
3280af22 164 $var = ($type)SvPV($arg,PL_na)
8990e307
LW
165T_PACKED
166 $var = XS_unpack_$ntype($arg)
167T_PACKEDARRAY
168 $var = XS_unpack_$ntype($arg)
169T_CALLBACK
170 $var = make_perl_cb_$type($arg)
171T_ARRAY
172 $var = $ntype(items -= $argoff);
173 U32 ix_$var = $argoff;
174 while (items--) {
175 DO_ARRAY_ELEM;
176 }
a0d0e21e
LW
177T_IN
178 $var = IoIFP(sv_2io($arg))
179T_INOUT
180 $var = IoIFP(sv_2io($arg))
181T_OUT
182 $var = IoOFP(sv_2io($arg))
8990e307
LW
183#############################################################################
184OUTPUT
2304df62
AD
185T_SV
186 $arg = $var;
a0d0e21e 187T_SVREF
2304df62 188 $arg = newRV((SV*)$var);
a0d0e21e 189T_AVREF
2304df62 190 $arg = newRV((SV*)$var);
a0d0e21e 191T_HVREF
2304df62 192 $arg = newRV((SV*)$var);
a0d0e21e 193T_CVREF
2304df62 194 $arg = newRV((SV*)$var);
85e6fe83 195T_IV
ef50df4b 196 sv_setiv($arg, (IV)$var);
3aa35033
GS
197T_UV
198 sv_setuv($arg, (UV)$var);
8990e307 199T_INT
ef50df4b 200 sv_setiv($arg, (IV)$var);
2304df62
AD
201T_SYSRET
202 if ($var != -1) {
203 if ($var == 0)
ef50df4b 204 sv_setpvn($arg, "0 but true", 10);
2304df62 205 else
ef50df4b 206 sv_setiv($arg, (IV)$var);
2304df62 207 }
8990e307 208T_ENUM
ef50df4b 209 sv_setiv($arg, (IV)$var);
1cc23d7f 210T_BOOL
54310121 211 $arg = boolSV($var);
8990e307 212T_U_INT
3aa35033 213 sv_setuv($arg, (UV)$var);
8990e307 214T_SHORT
ef50df4b 215 sv_setiv($arg, (IV)$var);
8990e307 216T_U_SHORT
3aa35033 217 sv_setuv($arg, (UV)$var);
8990e307 218T_LONG
ef50df4b 219 sv_setiv($arg, (IV)$var);
8990e307 220T_U_LONG
3aa35033 221 sv_setuv($arg, (UV)$var);
8990e307 222T_CHAR
ef50df4b 223 sv_setpvn($arg, (char *)&$var, 1);
8990e307 224T_U_CHAR
3aa35033 225 sv_setuv($arg, (UV)$var);
8990e307 226T_FLOAT
ef50df4b 227 sv_setnv($arg, (double)$var);
85e6fe83 228T_NV
ef50df4b 229 sv_setnv($arg, (double)$var);
8990e307 230T_DOUBLE
ef50df4b 231 sv_setnv($arg, (double)$var);
a0d0e21e 232T_PV
ef50df4b 233 sv_setpv((SV*)$arg, $var);
8990e307 234T_PTR
ef50df4b 235 sv_setiv($arg, (IV)$var);
8990e307 236T_PTRREF
a0d0e21e
LW
237 sv_setref_pv($arg, Nullch, (void*)$var);
238T_REF_IV_REF
239 sv_setref_pv($arg, \"${ntype}\", (void*)new $ntype($var));
240T_REF_IV_PTR
241 sv_setref_pv($arg, \"${ntype}\", (void*)$var);
8990e307 242T_PTROBJ
a0d0e21e 243 sv_setref_pv($arg, \"${ntype}\", (void*)$var);
8990e307 244T_PTRDESC
a0d0e21e 245 sv_setref_pv($arg, \"${ntype}\", (void*)new\U${type}_DESC\E($var));
8990e307
LW
246T_REFREF
247 sv_setrefref($arg, \"${ntype}\", XS_service_$ntype,
248 ($var ? (void*)new $ntype($var) : 0));
249T_REFOBJ
250 NOT IMPLEMENTED
251T_OPAQUE
ef50df4b 252 sv_setpvn($arg, (char *)&$var, sizeof($var));
8990e307 253T_OPAQUEPTR
4bd3d083 254 sv_setpvn($arg, (char *)$var, sizeof(*$var));
8990e307
LW
255T_PACKED
256 XS_pack_$ntype($arg, $var);
257T_PACKEDARRAY
258 XS_pack_$ntype($arg, $var, count_$ntype);
259T_DATAUNIT
ef50df4b 260 sv_setpvn($arg, $var.chp(), $var.size());
8990e307 261T_CALLBACK
ef50df4b 262 sv_setpvn($arg, $var.context.value().chp(),
8990e307
LW
263 $var.context.value().size());
264T_ARRAY
265 ST_EXTEND($var.size);
266 for (U32 ix_$var = 0; ix_$var < $var.size; ix_$var++) {
267 ST(ix_$var) = sv_newmortal();
268 DO_ARRAY_ELEM
269 }
50892819 270 SP += $var.size - 1;
a0d0e21e
LW
271T_IN
272 {
273 GV *gv = newGVgen("$Package");
c07a80fd 274 if ( do_open(gv, "<&", 2, FALSE, 0, 0, $var) )
ef50df4b 275 sv_setsv($arg, sv_bless(newRV((SV*)gv), gv_stashpv("$Package",1)));
a0d0e21e 276 else
6b88bc9c 277 $arg = &PL_sv_undef;
a0d0e21e
LW
278 }
279T_INOUT
280 {
281 GV *gv = newGVgen("$Package");
c07a80fd 282 if ( do_open(gv, "+<&", 3, FALSE, 0, 0, $var) )
ef50df4b 283 sv_setsv($arg, sv_bless(newRV((SV*)gv), gv_stashpv("$Package",1)));
a0d0e21e 284 else
6b88bc9c 285 $arg = &PL_sv_undef;
a0d0e21e
LW
286 }
287T_OUT
288 {
289 GV *gv = newGVgen("$Package");
c07a80fd 290 if ( do_open(gv, "+>&", 3, FALSE, 0, 0, $var) )
ef50df4b 291 sv_setsv($arg, sv_bless(newRV((SV*)gv), gv_stashpv("$Package",1)));
a0d0e21e 292 else
6b88bc9c 293 $arg = &PL_sv_undef;
a0d0e21e 294 }