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