Commit | Line | Data |
---|---|---|
954c1994 GS |
1 | =head1 NAME |
2 | ||
3 | perlapi - autogenerated documentation for the perl public API | |
4 | ||
5 | =head1 DESCRIPTION | |
d8c40edc | 6 | X<Perl API> X<API> X<api> |
954c1994 | 7 | |
1c846c1f NIS |
8 | This file contains the documentation of the perl public API generated by |
9 | embed.pl, specifically a listing of functions, macros, flags, and variables | |
10 | that may be used by extension writers. The interfaces of any functions that | |
954c1994 GS |
11 | are not listed here are subject to change without notice. For this reason, |
12 | blindly using functions listed in proto.h is to be avoided when writing | |
13 | extensions. | |
14 | ||
15 | Note that all Perl API global variables must be referenced with the C<PL_> | |
16 | prefix. Some macros are provided for compatibility with the older, | |
17 | unadorned names, but this support may be disabled in a future release. | |
18 | ||
19 | The listing is alphabetical, case insensitive. | |
20 | ||
94bdecf9 JH |
21 | |
22 | =head1 "Gimme" Values | |
23 | ||
24 | =over 8 | |
25 | ||
26 | =item GIMME | |
d8c40edc | 27 | X<GIMME> |
94bdecf9 JH |
28 | |
29 | A backward-compatible version of C<GIMME_V> which can only return | |
30 | C<G_SCALAR> or C<G_ARRAY>; in a void context, it returns C<G_SCALAR>. | |
31 | Deprecated. Use C<GIMME_V> instead. | |
32 | ||
33 | U32 GIMME | |
34 | ||
35 | =for hackers | |
36 | Found in file op.h | |
37 | ||
38 | =item GIMME_V | |
d8c40edc | 39 | X<GIMME_V> |
94bdecf9 JH |
40 | |
41 | The XSUB-writer's equivalent to Perl's C<wantarray>. Returns C<G_VOID>, | |
42 | C<G_SCALAR> or C<G_ARRAY> for void, scalar or list context, | |
43 | respectively. | |
44 | ||
45 | U32 GIMME_V | |
46 | ||
47 | =for hackers | |
48 | Found in file op.h | |
49 | ||
50 | =item G_ARRAY | |
d8c40edc | 51 | X<G_ARRAY> |
94bdecf9 JH |
52 | |
53 | Used to indicate list context. See C<GIMME_V>, C<GIMME> and | |
54 | L<perlcall>. | |
55 | ||
56 | =for hackers | |
57 | Found in file cop.h | |
58 | ||
59 | =item G_DISCARD | |
d8c40edc | 60 | X<G_DISCARD> |
94bdecf9 JH |
61 | |
62 | Indicates that arguments returned from a callback should be discarded. See | |
63 | L<perlcall>. | |
64 | ||
65 | =for hackers | |
66 | Found in file cop.h | |
67 | ||
68 | =item G_EVAL | |
d8c40edc | 69 | X<G_EVAL> |
94bdecf9 JH |
70 | |
71 | Used to force a Perl C<eval> wrapper around a callback. See | |
72 | L<perlcall>. | |
73 | ||
74 | =for hackers | |
75 | Found in file cop.h | |
76 | ||
77 | =item G_NOARGS | |
d8c40edc | 78 | X<G_NOARGS> |
94bdecf9 JH |
79 | |
80 | Indicates that no arguments are being sent to a callback. See | |
81 | L<perlcall>. | |
82 | ||
83 | =for hackers | |
84 | Found in file cop.h | |
85 | ||
86 | =item G_SCALAR | |
d8c40edc | 87 | X<G_SCALAR> |
94bdecf9 JH |
88 | |
89 | Used to indicate scalar context. See C<GIMME_V>, C<GIMME>, and | |
90 | L<perlcall>. | |
91 | ||
92 | =for hackers | |
93 | Found in file cop.h | |
94 | ||
95 | =item G_VOID | |
d8c40edc | 96 | X<G_VOID> |
94bdecf9 JH |
97 | |
98 | Used to indicate void context. See C<GIMME_V> and L<perlcall>. | |
99 | ||
100 | =for hackers | |
101 | Found in file cop.h | |
102 | ||
103 | ||
104 | =back | |
105 | ||
106 | =head1 Array Manipulation Functions | |
107 | ||
954c1994 GS |
108 | =over 8 |
109 | ||
110 | =item AvFILL | |
d8c40edc | 111 | X<AvFILL> |
954c1994 GS |
112 | |
113 | Same as C<av_len()>. Deprecated, use C<av_len()> instead. | |
114 | ||
115 | int AvFILL(AV* av) | |
116 | ||
497711e7 GS |
117 | =for hackers |
118 | Found in file av.h | |
119 | ||
954c1994 | 120 | =item av_clear |
d8c40edc | 121 | X<av_clear> |
954c1994 GS |
122 | |
123 | Clears an array, making it empty. Does not free the memory used by the | |
124 | array itself. | |
125 | ||
126 | void av_clear(AV* ar) | |
127 | ||
497711e7 GS |
128 | =for hackers |
129 | Found in file av.c | |
130 | ||
f3b76584 | 131 | =item av_delete |
d8c40edc | 132 | X<av_delete> |
f3b76584 SC |
133 | |
134 | Deletes the element indexed by C<key> from the array. Returns the | |
b9381830 JP |
135 | deleted element. If C<flags> equals C<G_DISCARD>, the element is freed |
136 | and null is returned. | |
f3b76584 SC |
137 | |
138 | SV* av_delete(AV* ar, I32 key, I32 flags) | |
139 | ||
140 | =for hackers | |
141 | Found in file av.c | |
142 | ||
143 | =item av_exists | |
d8c40edc | 144 | X<av_exists> |
f3b76584 SC |
145 | |
146 | Returns true if the element indexed by C<key> has been initialized. | |
147 | ||
148 | This relies on the fact that uninitialized array elements are set to | |
149 | C<&PL_sv_undef>. | |
150 | ||
151 | bool av_exists(AV* ar, I32 key) | |
152 | ||
153 | =for hackers | |
154 | Found in file av.c | |
155 | ||
954c1994 | 156 | =item av_extend |
d8c40edc | 157 | X<av_extend> |
954c1994 GS |
158 | |
159 | Pre-extend an array. The C<key> is the index to which the array should be | |
160 | extended. | |
161 | ||
162 | void av_extend(AV* ar, I32 key) | |
163 | ||
497711e7 GS |
164 | =for hackers |
165 | Found in file av.c | |
166 | ||
954c1994 | 167 | =item av_fetch |
d8c40edc | 168 | X<av_fetch> |
954c1994 GS |
169 | |
170 | Returns the SV at the specified index in the array. The C<key> is the | |
171 | index. If C<lval> is set then the fetch will be part of a store. Check | |
172 | that the return value is non-null before dereferencing it to a C<SV*>. | |
173 | ||
96f1132b GS |
174 | See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for |
175 | more information on how to use this function on tied arrays. | |
954c1994 GS |
176 | |
177 | SV** av_fetch(AV* ar, I32 key, I32 lval) | |
178 | ||
497711e7 GS |
179 | =for hackers |
180 | Found in file av.c | |
181 | ||
f3b76584 | 182 | =item av_fill |
d8c40edc | 183 | X<av_fill> |
f3b76584 SC |
184 | |
185 | Ensure than an array has a given number of elements, equivalent to | |
186 | Perl's C<$#array = $fill;>. | |
187 | ||
188 | void av_fill(AV* ar, I32 fill) | |
189 | ||
190 | =for hackers | |
191 | Found in file av.c | |
192 | ||
954c1994 | 193 | =item av_len |
d8c40edc | 194 | X<av_len> |
954c1994 GS |
195 | |
196 | Returns the highest index in the array. Returns -1 if the array is | |
197 | empty. | |
198 | ||
35a4481c | 199 | I32 av_len(const AV* ar) |
954c1994 | 200 | |
497711e7 GS |
201 | =for hackers |
202 | Found in file av.c | |
203 | ||
954c1994 | 204 | =item av_make |
d8c40edc | 205 | X<av_make> |
954c1994 GS |
206 | |
207 | Creates a new AV and populates it with a list of SVs. The SVs are copied | |
208 | into the array, so they may be freed after the call to av_make. The new AV | |
209 | will have a reference count of 1. | |
210 | ||
211 | AV* av_make(I32 size, SV** svp) | |
212 | ||
497711e7 GS |
213 | =for hackers |
214 | Found in file av.c | |
215 | ||
954c1994 | 216 | =item av_pop |
d8c40edc | 217 | X<av_pop> |
954c1994 GS |
218 | |
219 | Pops an SV off the end of the array. Returns C<&PL_sv_undef> if the array | |
220 | is empty. | |
221 | ||
222 | SV* av_pop(AV* ar) | |
223 | ||
497711e7 GS |
224 | =for hackers |
225 | Found in file av.c | |
226 | ||
954c1994 | 227 | =item av_push |
d8c40edc | 228 | X<av_push> |
954c1994 GS |
229 | |
230 | Pushes an SV onto the end of the array. The array will grow automatically | |
231 | to accommodate the addition. | |
232 | ||
233 | void av_push(AV* ar, SV* val) | |
234 | ||
497711e7 GS |
235 | =for hackers |
236 | Found in file av.c | |
237 | ||
954c1994 | 238 | =item av_shift |
d8c40edc | 239 | X<av_shift> |
954c1994 GS |
240 | |
241 | Shifts an SV off the beginning of the array. | |
242 | ||
243 | SV* av_shift(AV* ar) | |
244 | ||
497711e7 GS |
245 | =for hackers |
246 | Found in file av.c | |
247 | ||
954c1994 | 248 | =item av_store |
d8c40edc | 249 | X<av_store> |
954c1994 GS |
250 | |
251 | Stores an SV in an array. The array index is specified as C<key>. The | |
252 | return value will be NULL if the operation failed or if the value did not | |
253 | need to be actually stored within the array (as in the case of tied | |
254 | arrays). Otherwise it can be dereferenced to get the original C<SV*>. Note | |
255 | that the caller is responsible for suitably incrementing the reference | |
256 | count of C<val> before the call, and decrementing it if the function | |
257 | returned NULL. | |
258 | ||
96f1132b | 259 | See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for |
954c1994 GS |
260 | more information on how to use this function on tied arrays. |
261 | ||
262 | SV** av_store(AV* ar, I32 key, SV* val) | |
263 | ||
497711e7 GS |
264 | =for hackers |
265 | Found in file av.c | |
266 | ||
954c1994 | 267 | =item av_undef |
d8c40edc | 268 | X<av_undef> |
954c1994 GS |
269 | |
270 | Undefines the array. Frees the memory used by the array itself. | |
271 | ||
272 | void av_undef(AV* ar) | |
273 | ||
497711e7 GS |
274 | =for hackers |
275 | Found in file av.c | |
276 | ||
954c1994 | 277 | =item av_unshift |
d8c40edc | 278 | X<av_unshift> |
954c1994 GS |
279 | |
280 | Unshift the given number of C<undef> values onto the beginning of the | |
281 | array. The array will grow automatically to accommodate the addition. You | |
282 | must then use C<av_store> to assign values to these new elements. | |
283 | ||
284 | void av_unshift(AV* ar, I32 num) | |
285 | ||
497711e7 GS |
286 | =for hackers |
287 | Found in file av.c | |
288 | ||
94bdecf9 | 289 | =item get_av |
d8c40edc | 290 | X<get_av> |
9f2ea798 | 291 | |
94bdecf9 JH |
292 | Returns the AV of the specified Perl array. If C<create> is set and the |
293 | Perl variable does not exist then it will be created. If C<create> is not | |
294 | set and the variable does not exist then NULL is returned. | |
9f2ea798 | 295 | |
94bdecf9 JH |
296 | NOTE: the perl_ form of this function is deprecated. |
297 | ||
298 | AV* get_av(const char* name, I32 create) | |
9f2ea798 DM |
299 | |
300 | =for hackers | |
94bdecf9 | 301 | Found in file perl.c |
9f2ea798 | 302 | |
94bdecf9 | 303 | =item newAV |
d8c40edc | 304 | X<newAV> |
f9a63242 | 305 | |
94bdecf9 | 306 | Creates a new AV. The reference count is set to 1. |
f9a63242 | 307 | |
94bdecf9 JH |
308 | AV* newAV() |
309 | ||
310 | =for hackers | |
311 | Found in file av.c | |
312 | ||
94bdecf9 | 313 | =item sortsv |
d8c40edc | 314 | X<sortsv> |
497711e7 | 315 | |
94bdecf9 | 316 | Sort an array. Here is an example: |
497711e7 | 317 | |
94bdecf9 | 318 | sortsv(AvARRAY(av), av_len(av)+1, Perl_sv_cmp_locale); |
eebe1485 | 319 | |
7b9ef140 RH |
320 | Currently this always uses mergesort. See sortsv_flags for a more |
321 | flexible routine. | |
641d4181 | 322 | |
aa924a5a | 323 | void sortsv(SV** array, size_t num_elts, SVCOMPARE_t cmp) |
497711e7 GS |
324 | |
325 | =for hackers | |
94bdecf9 JH |
326 | Found in file pp_sort.c |
327 | ||
7b9ef140 RH |
328 | =item sortsv_flags |
329 | X<sortsv_flags> | |
330 | ||
331 | Sort an array, with various options. | |
332 | ||
333 | void sortsv_flags(SV** array, size_t num_elts, SVCOMPARE_t cmp, U32 flags) | |
334 | ||
335 | =for hackers | |
336 | Found in file pp_sort.c | |
337 | ||
94bdecf9 JH |
338 | |
339 | =back | |
340 | ||
341 | =head1 Callback Functions | |
342 | ||
343 | =over 8 | |
497711e7 | 344 | |
954c1994 | 345 | =item call_argv |
d8c40edc | 346 | X<call_argv> |
954c1994 GS |
347 | |
348 | Performs a callback to the specified Perl sub. See L<perlcall>. | |
349 | ||
350 | NOTE: the perl_ form of this function is deprecated. | |
351 | ||
8f42b153 | 352 | I32 call_argv(const char* sub_name, I32 flags, char** argv) |
954c1994 | 353 | |
497711e7 GS |
354 | =for hackers |
355 | Found in file perl.c | |
356 | ||
954c1994 | 357 | =item call_method |
d8c40edc | 358 | X<call_method> |
954c1994 GS |
359 | |
360 | Performs a callback to the specified Perl method. The blessed object must | |
361 | be on the stack. See L<perlcall>. | |
362 | ||
363 | NOTE: the perl_ form of this function is deprecated. | |
364 | ||
365 | I32 call_method(const char* methname, I32 flags) | |
366 | ||
497711e7 GS |
367 | =for hackers |
368 | Found in file perl.c | |
369 | ||
954c1994 | 370 | =item call_pv |
d8c40edc | 371 | X<call_pv> |
954c1994 GS |
372 | |
373 | Performs a callback to the specified Perl sub. See L<perlcall>. | |
374 | ||
375 | NOTE: the perl_ form of this function is deprecated. | |
376 | ||
377 | I32 call_pv(const char* sub_name, I32 flags) | |
378 | ||
497711e7 GS |
379 | =for hackers |
380 | Found in file perl.c | |
381 | ||
954c1994 | 382 | =item call_sv |
d8c40edc | 383 | X<call_sv> |
954c1994 GS |
384 | |
385 | Performs a callback to the Perl sub whose name is in the SV. See | |
386 | L<perlcall>. | |
387 | ||
388 | NOTE: the perl_ form of this function is deprecated. | |
389 | ||
390 | I32 call_sv(SV* sv, I32 flags) | |
391 | ||
497711e7 GS |
392 | =for hackers |
393 | Found in file perl.c | |
394 | ||
94bdecf9 | 395 | =item ENTER |
d8c40edc | 396 | X<ENTER> |
954c1994 | 397 | |
94bdecf9 | 398 | Opening bracket on a callback. See C<LEAVE> and L<perlcall>. |
954c1994 | 399 | |
94bdecf9 | 400 | ENTER; |
954c1994 | 401 | |
497711e7 | 402 | =for hackers |
94bdecf9 | 403 | Found in file scope.h |
497711e7 | 404 | |
94bdecf9 | 405 | =item eval_pv |
d8c40edc | 406 | X<eval_pv> |
954c1994 | 407 | |
94bdecf9 | 408 | Tells Perl to C<eval> the given string and return an SV* result. |
954c1994 | 409 | |
94bdecf9 | 410 | NOTE: the perl_ form of this function is deprecated. |
954c1994 | 411 | |
94bdecf9 | 412 | SV* eval_pv(const char* p, I32 croak_on_error) |
497711e7 | 413 | |
94bdecf9 JH |
414 | =for hackers |
415 | Found in file perl.c | |
954c1994 | 416 | |
94bdecf9 | 417 | =item eval_sv |
d8c40edc | 418 | X<eval_sv> |
c9d5ac95 | 419 | |
94bdecf9 | 420 | Tells Perl to C<eval> the string in the SV. |
c9d5ac95 | 421 | |
94bdecf9 | 422 | NOTE: the perl_ form of this function is deprecated. |
954c1994 | 423 | |
94bdecf9 | 424 | I32 eval_sv(SV* sv, I32 flags) |
954c1994 | 425 | |
497711e7 | 426 | =for hackers |
94bdecf9 | 427 | Found in file perl.c |
497711e7 | 428 | |
94bdecf9 | 429 | =item FREETMPS |
d8c40edc | 430 | X<FREETMPS> |
954c1994 | 431 | |
94bdecf9 JH |
432 | Closing bracket for temporaries on a callback. See C<SAVETMPS> and |
433 | L<perlcall>. | |
954c1994 | 434 | |
94bdecf9 | 435 | FREETMPS; |
954c1994 | 436 | |
497711e7 | 437 | =for hackers |
94bdecf9 | 438 | Found in file scope.h |
beab0874 | 439 | |
94bdecf9 | 440 | =item LEAVE |
d8c40edc | 441 | X<LEAVE> |
beab0874 | 442 | |
94bdecf9 | 443 | Closing bracket on a callback. See C<ENTER> and L<perlcall>. |
beab0874 | 444 | |
94bdecf9 | 445 | LEAVE; |
beab0874 JT |
446 | |
447 | =for hackers | |
94bdecf9 | 448 | Found in file scope.h |
beab0874 | 449 | |
94bdecf9 | 450 | =item SAVETMPS |
d8c40edc | 451 | X<SAVETMPS> |
9f2ea798 | 452 | |
94bdecf9 JH |
453 | Opening bracket for temporaries on a callback. See C<FREETMPS> and |
454 | L<perlcall>. | |
9f2ea798 | 455 | |
94bdecf9 | 456 | SAVETMPS; |
9f2ea798 DM |
457 | |
458 | =for hackers | |
94bdecf9 | 459 | Found in file scope.h |
9f2ea798 | 460 | |
9f2ea798 | 461 | |
94bdecf9 | 462 | =back |
9f2ea798 | 463 | |
94bdecf9 | 464 | =head1 Character classes |
9f2ea798 | 465 | |
94bdecf9 | 466 | =over 8 |
9f2ea798 | 467 | |
94bdecf9 | 468 | =item isALNUM |
d8c40edc | 469 | X<isALNUM> |
954c1994 | 470 | |
94bdecf9 JH |
471 | Returns a boolean indicating whether the C C<char> is an ASCII alphanumeric |
472 | character (including underscore) or digit. | |
954c1994 | 473 | |
94bdecf9 | 474 | bool isALNUM(char ch) |
954c1994 | 475 | |
497711e7 | 476 | =for hackers |
94bdecf9 | 477 | Found in file handy.h |
497711e7 | 478 | |
94bdecf9 | 479 | =item isALPHA |
d8c40edc | 480 | X<isALPHA> |
954c1994 | 481 | |
94bdecf9 JH |
482 | Returns a boolean indicating whether the C C<char> is an ASCII alphabetic |
483 | character. | |
954c1994 | 484 | |
94bdecf9 | 485 | bool isALPHA(char ch) |
954c1994 | 486 | |
497711e7 | 487 | =for hackers |
94bdecf9 | 488 | Found in file handy.h |
497711e7 | 489 | |
94bdecf9 | 490 | =item isDIGIT |
d8c40edc | 491 | X<isDIGIT> |
954c1994 | 492 | |
94bdecf9 JH |
493 | Returns a boolean indicating whether the C C<char> is an ASCII |
494 | digit. | |
954c1994 | 495 | |
94bdecf9 | 496 | bool isDIGIT(char ch) |
954c1994 | 497 | |
497711e7 | 498 | =for hackers |
94bdecf9 | 499 | Found in file handy.h |
497711e7 | 500 | |
94bdecf9 | 501 | =item isLOWER |
d8c40edc | 502 | X<isLOWER> |
954c1994 | 503 | |
94bdecf9 JH |
504 | Returns a boolean indicating whether the C C<char> is a lowercase |
505 | character. | |
954c1994 | 506 | |
94bdecf9 | 507 | bool isLOWER(char ch) |
954c1994 | 508 | |
497711e7 | 509 | =for hackers |
94bdecf9 | 510 | Found in file handy.h |
497711e7 | 511 | |
94bdecf9 | 512 | =item isSPACE |
d8c40edc | 513 | X<isSPACE> |
954c1994 | 514 | |
94bdecf9 | 515 | Returns a boolean indicating whether the C C<char> is whitespace. |
954c1994 | 516 | |
94bdecf9 | 517 | bool isSPACE(char ch) |
954c1994 | 518 | |
497711e7 | 519 | =for hackers |
94bdecf9 | 520 | Found in file handy.h |
497711e7 | 521 | |
94bdecf9 | 522 | =item isUPPER |
d8c40edc | 523 | X<isUPPER> |
954c1994 | 524 | |
94bdecf9 JH |
525 | Returns a boolean indicating whether the C C<char> is an uppercase |
526 | character. | |
954c1994 | 527 | |
94bdecf9 | 528 | bool isUPPER(char ch) |
954c1994 | 529 | |
497711e7 | 530 | =for hackers |
94bdecf9 | 531 | Found in file handy.h |
497711e7 | 532 | |
94bdecf9 | 533 | =item toLOWER |
d8c40edc | 534 | X<toLOWER> |
954c1994 | 535 | |
94bdecf9 | 536 | Converts the specified character to lowercase. |
954c1994 | 537 | |
94bdecf9 | 538 | char toLOWER(char ch) |
954c1994 | 539 | |
94bdecf9 JH |
540 | =for hackers |
541 | Found in file handy.h | |
542 | ||
543 | =item toUPPER | |
d8c40edc | 544 | X<toUPPER> |
94bdecf9 JH |
545 | |
546 | Converts the specified character to uppercase. | |
547 | ||
548 | char toUPPER(char ch) | |
954c1994 | 549 | |
497711e7 | 550 | =for hackers |
94bdecf9 | 551 | Found in file handy.h |
497711e7 | 552 | |
954c1994 | 553 | |
94bdecf9 | 554 | =back |
954c1994 | 555 | |
94bdecf9 | 556 | =head1 Cloning an interpreter |
954c1994 | 557 | |
94bdecf9 JH |
558 | =over 8 |
559 | ||
560 | =item perl_clone | |
d8c40edc | 561 | X<perl_clone> |
94bdecf9 JH |
562 | |
563 | Create and return a new interpreter by cloning the current one. | |
564 | ||
4be49ee6 | 565 | perl_clone takes these flags as parameters: |
c78c2b74 | 566 | |
b0bc38e6 NC |
567 | CLONEf_COPY_STACKS - is used to, well, copy the stacks also, |
568 | without it we only clone the data and zero the stacks, | |
569 | with it we copy the stacks and the new perl interpreter is | |
570 | ready to run at the exact same point as the previous one. | |
571 | The pseudo-fork code uses COPY_STACKS while the | |
c78c2b74 HS |
572 | threads->new doesn't. |
573 | ||
574 | CLONEf_KEEP_PTR_TABLE | |
b0bc38e6 NC |
575 | perl_clone keeps a ptr_table with the pointer of the old |
576 | variable as a key and the new variable as a value, | |
577 | this allows it to check if something has been cloned and not | |
578 | clone it again but rather just use the value and increase the | |
579 | refcount. If KEEP_PTR_TABLE is not set then perl_clone will kill | |
580 | the ptr_table using the function | |
581 | C<ptr_table_free(PL_ptr_table); PL_ptr_table = NULL;>, | |
582 | reason to keep it around is if you want to dup some of your own | |
583 | variable who are outside the graph perl scans, example of this | |
c78c2b74 HS |
584 | code is in threads.xs create |
585 | ||
586 | CLONEf_CLONE_HOST | |
b0bc38e6 NC |
587 | This is a win32 thing, it is ignored on unix, it tells perls |
588 | win32host code (which is c++) to clone itself, this is needed on | |
589 | win32 if you want to run two threads at the same time, | |
590 | if you just want to do some stuff in a separate perl interpreter | |
591 | and then throw it away and return to the original one, | |
c78c2b74 HS |
592 | you don't need to do anything. |
593 | ||
94bdecf9 | 594 | PerlInterpreter* perl_clone(PerlInterpreter* interp, UV flags) |
954c1994 | 595 | |
497711e7 | 596 | =for hackers |
94bdecf9 | 597 | Found in file sv.c |
497711e7 | 598 | |
954c1994 | 599 | |
94bdecf9 | 600 | =back |
954c1994 | 601 | |
94bdecf9 JH |
602 | =head1 CV Manipulation Functions |
603 | ||
604 | =over 8 | |
605 | ||
606 | =item CvSTASH | |
d8c40edc | 607 | X<CvSTASH> |
94bdecf9 JH |
608 | |
609 | Returns the stash of the CV. | |
610 | ||
611 | HV* CvSTASH(CV* cv) | |
954c1994 | 612 | |
497711e7 | 613 | =for hackers |
94bdecf9 | 614 | Found in file cv.h |
497711e7 | 615 | |
94bdecf9 | 616 | =item get_cv |
d8c40edc | 617 | X<get_cv> |
954c1994 | 618 | |
94bdecf9 JH |
619 | Returns the CV of the specified Perl subroutine. If C<create> is set and |
620 | the Perl subroutine does not exist then it will be declared (which has the | |
621 | same effect as saying C<sub name;>). If C<create> is not set and the | |
622 | subroutine does not exist then NULL is returned. | |
954c1994 | 623 | |
94bdecf9 JH |
624 | NOTE: the perl_ form of this function is deprecated. |
625 | ||
626 | CV* get_cv(const char* name, I32 create) | |
954c1994 | 627 | |
497711e7 | 628 | =for hackers |
94bdecf9 | 629 | Found in file perl.c |
497711e7 | 630 | |
7c9e965c | 631 | |
94bdecf9 | 632 | =back |
7c9e965c | 633 | |
94bdecf9 | 634 | =head1 Embedding Functions |
7c9e965c | 635 | |
94bdecf9 | 636 | =over 8 |
7c9e965c | 637 | |
7dafbf52 | 638 | =item cv_undef |
d8c40edc | 639 | X<cv_undef> |
7dafbf52 DM |
640 | |
641 | Clear out all the active components of a CV. This can happen either | |
642 | by an explicit C<undef &foo>, or by the reference count going to zero. | |
643 | In the former case, we keep the CvOUTSIDE pointer, so that any anonymous | |
644 | children can still follow the full lexical scope chain. | |
645 | ||
646 | void cv_undef(CV* cv) | |
647 | ||
648 | =for hackers | |
649 | Found in file op.c | |
650 | ||
94bdecf9 | 651 | =item load_module |
d8c40edc | 652 | X<load_module> |
7c9e965c | 653 | |
94bdecf9 JH |
654 | Loads the module whose name is pointed to by the string part of name. |
655 | Note that the actual module name, not its filename, should be given. | |
656 | Eg, "Foo::Bar" instead of "Foo/Bar.pm". flags can be any of | |
657 | PERL_LOADMOD_DENY, PERL_LOADMOD_NOIMPORT, or PERL_LOADMOD_IMPORT_OPS | |
658 | (or 0 for no flags). ver, if specified, provides version semantics | |
659 | similar to C<use Foo::Bar VERSION>. The optional trailing SV* | |
660 | arguments can be used to specify arguments to the module's import() | |
661 | method, similar to C<use Foo::Bar VERSION LIST>. | |
7c9e965c | 662 | |
94bdecf9 | 663 | void load_module(U32 flags, SV* name, SV* ver, ...) |
7c9e965c JP |
664 | |
665 | =for hackers | |
94bdecf9 | 666 | Found in file op.c |
7c9e965c | 667 | |
62375a60 | 668 | =item nothreadhook |
d8c40edc | 669 | X<nothreadhook> |
62375a60 NIS |
670 | |
671 | Stub that provides thread hook for perl_destruct when there are | |
672 | no threads. | |
673 | ||
674 | int nothreadhook() | |
675 | ||
676 | =for hackers | |
677 | Found in file perl.c | |
678 | ||
94bdecf9 | 679 | =item perl_alloc |
d8c40edc | 680 | X<perl_alloc> |
954c1994 | 681 | |
94bdecf9 | 682 | Allocates a new Perl interpreter. See L<perlembed>. |
954c1994 | 683 | |
94bdecf9 | 684 | PerlInterpreter* perl_alloc() |
954c1994 | 685 | |
497711e7 | 686 | =for hackers |
94bdecf9 | 687 | Found in file perl.c |
497711e7 | 688 | |
94bdecf9 | 689 | =item perl_construct |
d8c40edc | 690 | X<perl_construct> |
89423764 | 691 | |
94bdecf9 | 692 | Initializes a new Perl interpreter. See L<perlembed>. |
89423764 | 693 | |
94bdecf9 | 694 | void perl_construct(PerlInterpreter* interp) |
89423764 GS |
695 | |
696 | =for hackers | |
94bdecf9 | 697 | Found in file perl.c |
954c1994 | 698 | |
94bdecf9 | 699 | =item perl_destruct |
d8c40edc | 700 | X<perl_destruct> |
954c1994 | 701 | |
94bdecf9 | 702 | Shuts down a Perl interpreter. See L<perlembed>. |
954c1994 | 703 | |
94bdecf9 | 704 | int perl_destruct(PerlInterpreter* interp) |
954c1994 | 705 | |
497711e7 GS |
706 | =for hackers |
707 | Found in file perl.c | |
708 | ||
94bdecf9 | 709 | =item perl_free |
d8c40edc | 710 | X<perl_free> |
954c1994 | 711 | |
94bdecf9 | 712 | Releases a Perl interpreter. See L<perlembed>. |
954c1994 | 713 | |
94bdecf9 | 714 | void perl_free(PerlInterpreter* interp) |
954c1994 | 715 | |
497711e7 GS |
716 | =for hackers |
717 | Found in file perl.c | |
718 | ||
94bdecf9 | 719 | =item perl_parse |
d8c40edc | 720 | X<perl_parse> |
954c1994 | 721 | |
94bdecf9 | 722 | Tells a Perl interpreter to parse a Perl script. See L<perlembed>. |
954c1994 | 723 | |
94bdecf9 | 724 | int perl_parse(PerlInterpreter* interp, XSINIT_t xsinit, int argc, char** argv, char** env) |
954c1994 | 725 | |
94bdecf9 JH |
726 | =for hackers |
727 | Found in file perl.c | |
728 | ||
729 | =item perl_run | |
d8c40edc | 730 | X<perl_run> |
94bdecf9 JH |
731 | |
732 | Tells a Perl interpreter to run. See L<perlembed>. | |
733 | ||
734 | int perl_run(PerlInterpreter* interp) | |
954c1994 | 735 | |
497711e7 GS |
736 | =for hackers |
737 | Found in file perl.c | |
738 | ||
94bdecf9 | 739 | =item require_pv |
d8c40edc | 740 | X<require_pv> |
954c1994 | 741 | |
94bdecf9 JH |
742 | Tells Perl to C<require> the file named by the string argument. It is |
743 | analogous to the Perl code C<eval "require '$file'">. It's even | |
2307c6d0 | 744 | implemented that way; consider using load_module instead. |
954c1994 GS |
745 | |
746 | NOTE: the perl_ form of this function is deprecated. | |
747 | ||
94bdecf9 | 748 | void require_pv(const char* pv) |
954c1994 | 749 | |
497711e7 GS |
750 | =for hackers |
751 | Found in file perl.c | |
752 | ||
954c1994 | 753 | |
94bdecf9 | 754 | =back |
954c1994 | 755 | |
9244d4ad RGS |
756 | =head1 Functions in file mathoms.c |
757 | ||
758 | ||
759 | =over 8 | |
760 | ||
761 | =item gv_fetchmethod | |
762 | X<gv_fetchmethod> | |
763 | ||
764 | See L<gv_fetchmethod_autoload>. | |
765 | ||
766 | GV* gv_fetchmethod(HV* stash, const char* name) | |
767 | ||
768 | =for hackers | |
769 | Found in file mathoms.c | |
770 | ||
771 | =item sv_2pvbyte_nolen | |
772 | X<sv_2pvbyte_nolen> | |
773 | ||
774 | Return a pointer to the byte-encoded representation of the SV. | |
775 | May cause the SV to be downgraded from UTF-8 as a side-effect. | |
776 | ||
777 | Usually accessed via the C<SvPVbyte_nolen> macro. | |
778 | ||
779 | char* sv_2pvbyte_nolen(SV* sv) | |
780 | ||
781 | =for hackers | |
782 | Found in file mathoms.c | |
783 | ||
784 | =item sv_2pvutf8_nolen | |
785 | X<sv_2pvutf8_nolen> | |
786 | ||
787 | Return a pointer to the UTF-8-encoded representation of the SV. | |
788 | May cause the SV to be upgraded to UTF-8 as a side-effect. | |
789 | ||
790 | Usually accessed via the C<SvPVutf8_nolen> macro. | |
791 | ||
792 | char* sv_2pvutf8_nolen(SV* sv) | |
793 | ||
794 | =for hackers | |
795 | Found in file mathoms.c | |
796 | ||
797 | =item sv_2pv_nolen | |
798 | X<sv_2pv_nolen> | |
799 | ||
800 | Like C<sv_2pv()>, but doesn't return the length too. You should usually | |
801 | use the macro wrapper C<SvPV_nolen(sv)> instead. | |
802 | char* sv_2pv_nolen(SV* sv) | |
803 | ||
804 | =for hackers | |
805 | Found in file mathoms.c | |
806 | ||
807 | =item sv_catpvn_mg | |
808 | X<sv_catpvn_mg> | |
809 | ||
810 | Like C<sv_catpvn>, but also handles 'set' magic. | |
811 | ||
812 | void sv_catpvn_mg(SV *sv, const char *ptr, STRLEN len) | |
813 | ||
814 | =for hackers | |
815 | Found in file mathoms.c | |
816 | ||
817 | =item sv_catsv_mg | |
818 | X<sv_catsv_mg> | |
819 | ||
820 | Like C<sv_catsv>, but also handles 'set' magic. | |
821 | ||
822 | void sv_catsv_mg(SV *dstr, SV *sstr) | |
823 | ||
824 | =for hackers | |
825 | Found in file mathoms.c | |
826 | ||
827 | =item sv_force_normal | |
828 | X<sv_force_normal> | |
829 | ||
830 | Undo various types of fakery on an SV: if the PV is a shared string, make | |
831 | a private copy; if we're a ref, stop refing; if we're a glob, downgrade to | |
832 | an xpvmg. See also C<sv_force_normal_flags>. | |
833 | ||
834 | void sv_force_normal(SV *sv) | |
835 | ||
836 | =for hackers | |
837 | Found in file mathoms.c | |
838 | ||
839 | =item sv_iv | |
840 | X<sv_iv> | |
841 | ||
842 | A private implementation of the C<SvIVx> macro for compilers which can't | |
843 | cope with complex macro expressions. Always use the macro instead. | |
844 | ||
845 | IV sv_iv(SV* sv) | |
846 | ||
847 | =for hackers | |
848 | Found in file mathoms.c | |
849 | ||
850 | =item sv_nolocking | |
851 | X<sv_nolocking> | |
852 | ||
853 | Dummy routine which "locks" an SV when there is no locking module present. | |
854 | Exists to avoid test for a NULL function pointer and because it could | |
855 | potentially warn under some level of strict-ness. | |
856 | ||
857 | "Superseded" by sv_nosharing(). | |
858 | ||
c48640ec | 859 | void sv_nolocking(SV *sv) |
9244d4ad RGS |
860 | |
861 | =for hackers | |
862 | Found in file mathoms.c | |
863 | ||
864 | =item sv_nounlocking | |
865 | X<sv_nounlocking> | |
866 | ||
867 | Dummy routine which "unlocks" an SV when there is no locking module present. | |
868 | Exists to avoid test for a NULL function pointer and because it could | |
869 | potentially warn under some level of strict-ness. | |
870 | ||
871 | "Superseded" by sv_nosharing(). | |
872 | ||
c48640ec | 873 | void sv_nounlocking(SV *sv) |
9244d4ad RGS |
874 | |
875 | =for hackers | |
876 | Found in file mathoms.c | |
877 | ||
878 | =item sv_nv | |
879 | X<sv_nv> | |
880 | ||
881 | A private implementation of the C<SvNVx> macro for compilers which can't | |
882 | cope with complex macro expressions. Always use the macro instead. | |
883 | ||
884 | NV sv_nv(SV* sv) | |
885 | ||
886 | =for hackers | |
887 | Found in file mathoms.c | |
888 | ||
889 | =item sv_pv | |
890 | X<sv_pv> | |
891 | ||
892 | Use the C<SvPV_nolen> macro instead | |
893 | ||
894 | char* sv_pv(SV *sv) | |
895 | ||
896 | =for hackers | |
897 | Found in file mathoms.c | |
898 | ||
899 | =item sv_pvbyte | |
900 | X<sv_pvbyte> | |
901 | ||
902 | Use C<SvPVbyte_nolen> instead. | |
903 | ||
904 | char* sv_pvbyte(SV *sv) | |
905 | ||
906 | =for hackers | |
907 | Found in file mathoms.c | |
908 | ||
909 | =item sv_pvbyten | |
910 | X<sv_pvbyten> | |
911 | ||
912 | A private implementation of the C<SvPVbyte> macro for compilers | |
913 | which can't cope with complex macro expressions. Always use the macro | |
914 | instead. | |
915 | ||
916 | char* sv_pvbyten(SV *sv, STRLEN *len) | |
917 | ||
918 | =for hackers | |
919 | Found in file mathoms.c | |
920 | ||
921 | =item sv_pvn | |
922 | X<sv_pvn> | |
923 | ||
924 | A private implementation of the C<SvPV> macro for compilers which can't | |
925 | cope with complex macro expressions. Always use the macro instead. | |
926 | ||
927 | char* sv_pvn(SV *sv, STRLEN *len) | |
928 | ||
929 | =for hackers | |
930 | Found in file mathoms.c | |
931 | ||
932 | =item sv_pvutf8 | |
933 | X<sv_pvutf8> | |
934 | ||
935 | Use the C<SvPVutf8_nolen> macro instead | |
936 | ||
937 | char* sv_pvutf8(SV *sv) | |
938 | ||
939 | =for hackers | |
940 | Found in file mathoms.c | |
941 | ||
942 | =item sv_pvutf8n | |
943 | X<sv_pvutf8n> | |
944 | ||
945 | A private implementation of the C<SvPVutf8> macro for compilers | |
946 | which can't cope with complex macro expressions. Always use the macro | |
947 | instead. | |
948 | ||
949 | char* sv_pvutf8n(SV *sv, STRLEN *len) | |
950 | ||
951 | =for hackers | |
952 | Found in file mathoms.c | |
953 | ||
954 | =item sv_taint | |
955 | X<sv_taint> | |
956 | ||
957 | Taint an SV. Use C<SvTAINTED_on> instead. | |
958 | void sv_taint(SV* sv) | |
959 | ||
960 | =for hackers | |
961 | Found in file mathoms.c | |
962 | ||
963 | =item sv_unref | |
964 | X<sv_unref> | |
965 | ||
966 | Unsets the RV status of the SV, and decrements the reference count of | |
967 | whatever was being referenced by the RV. This can almost be thought of | |
968 | as a reversal of C<newSVrv>. This is C<sv_unref_flags> with the C<flag> | |
969 | being zero. See C<SvROK_off>. | |
970 | ||
971 | void sv_unref(SV* sv) | |
972 | ||
973 | =for hackers | |
974 | Found in file mathoms.c | |
975 | ||
976 | =item sv_uv | |
977 | X<sv_uv> | |
978 | ||
979 | A private implementation of the C<SvUVx> macro for compilers which can't | |
980 | cope with complex macro expressions. Always use the macro instead. | |
981 | ||
982 | UV sv_uv(SV* sv) | |
983 | ||
984 | =for hackers | |
985 | Found in file mathoms.c | |
986 | ||
9244d4ad RGS |
987 | |
988 | =back | |
989 | ||
6050d10e JP |
990 | =head1 Functions in file pp_pack.c |
991 | ||
992 | ||
993 | =over 8 | |
994 | ||
7accc089 | 995 | =item packlist |
d8c40edc | 996 | X<packlist> |
6050d10e JP |
997 | |
998 | The engine implementing pack() Perl function. | |
999 | ||
f7fe979e | 1000 | void packlist(SV *cat, const char *pat, const char *patend, SV **beglist, SV **endlist) |
7accc089 JH |
1001 | |
1002 | =for hackers | |
1003 | Found in file pp_pack.c | |
1004 | ||
1005 | =item pack_cat | |
d8c40edc | 1006 | X<pack_cat> |
7accc089 JH |
1007 | |
1008 | The engine implementing pack() Perl function. Note: parameters next_in_list and | |
1009 | flags are not used. This call should not be used; use packlist instead. | |
1010 | ||
f7fe979e | 1011 | void pack_cat(SV *cat, const char *pat, const char *patend, SV **beglist, SV **endlist, SV ***next_in_list, U32 flags) |
6050d10e JP |
1012 | |
1013 | =for hackers | |
1014 | Found in file pp_pack.c | |
1015 | ||
7accc089 | 1016 | =item unpackstring |
d8c40edc | 1017 | X<unpackstring> |
6050d10e | 1018 | |
608d3aed WL |
1019 | The engine implementing unpack() Perl function. C<unpackstring> puts the |
1020 | extracted list items on the stack and returns the number of elements. | |
1021 | Issue C<PUTBACK> before and C<SPAGAIN> after the call to this function. | |
6050d10e | 1022 | |
f7fe979e | 1023 | I32 unpackstring(const char *pat, const char *patend, const char *s, const char *strend, U32 flags) |
7accc089 JH |
1024 | |
1025 | =for hackers | |
1026 | Found in file pp_pack.c | |
1027 | ||
1028 | =item unpack_str | |
d8c40edc | 1029 | X<unpack_str> |
7accc089 JH |
1030 | |
1031 | The engine implementing unpack() Perl function. Note: parameters strbeg, new_s | |
1032 | and ocnt are not used. This call should not be used, use unpackstring instead. | |
1033 | ||
f7fe979e | 1034 | I32 unpack_str(const char *pat, const char *patend, const char *s, const char *strbeg, const char *strend, char **new_s, I32 ocnt, U32 flags) |
6050d10e JP |
1035 | |
1036 | =for hackers | |
1037 | Found in file pp_pack.c | |
1038 | ||
1039 | ||
1040 | =back | |
1041 | ||
94bdecf9 | 1042 | =head1 Global Variables |
954c1994 | 1043 | |
94bdecf9 | 1044 | =over 8 |
497711e7 | 1045 | |
94bdecf9 | 1046 | =item PL_modglobal |
d8c40edc | 1047 | X<PL_modglobal> |
954c1994 | 1048 | |
94bdecf9 JH |
1049 | C<PL_modglobal> is a general purpose, interpreter global HV for use by |
1050 | extensions that need to keep information on a per-interpreter basis. | |
1051 | In a pinch, it can also be used as a symbol table for extensions | |
1052 | to share data among each other. It is a good idea to use keys | |
1053 | prefixed by the package name of the extension that owns the data. | |
954c1994 | 1054 | |
94bdecf9 | 1055 | HV* PL_modglobal |
954c1994 | 1056 | |
497711e7 | 1057 | =for hackers |
94bdecf9 | 1058 | Found in file intrpvar.h |
497711e7 | 1059 | |
94bdecf9 | 1060 | =item PL_na |
d8c40edc | 1061 | X<PL_na> |
6e9d1081 | 1062 | |
94bdecf9 JH |
1063 | A convenience variable which is typically used with C<SvPV> when one |
1064 | doesn't care about the length of the string. It is usually more efficient | |
1065 | to either declare a local variable and use that instead or to use the | |
1066 | C<SvPV_nolen> macro. | |
6e9d1081 | 1067 | |
94bdecf9 | 1068 | STRLEN PL_na |
6e9d1081 | 1069 | |
94bdecf9 JH |
1070 | =for hackers |
1071 | Found in file thrdvar.h | |
6e9d1081 | 1072 | |
94bdecf9 | 1073 | =item PL_sv_no |
d8c40edc | 1074 | X<PL_sv_no> |
6e9d1081 | 1075 | |
94bdecf9 JH |
1076 | This is the C<false> SV. See C<PL_sv_yes>. Always refer to this as |
1077 | C<&PL_sv_no>. | |
1078 | ||
1079 | SV PL_sv_no | |
6e9d1081 NC |
1080 | |
1081 | =for hackers | |
94bdecf9 | 1082 | Found in file intrpvar.h |
6e9d1081 | 1083 | |
94bdecf9 | 1084 | =item PL_sv_undef |
d8c40edc | 1085 | X<PL_sv_undef> |
6e9d1081 | 1086 | |
94bdecf9 | 1087 | This is the C<undef> SV. Always refer to this as C<&PL_sv_undef>. |
6e9d1081 | 1088 | |
94bdecf9 | 1089 | SV PL_sv_undef |
6e9d1081 | 1090 | |
94bdecf9 JH |
1091 | =for hackers |
1092 | Found in file intrpvar.h | |
6e9d1081 | 1093 | |
94bdecf9 | 1094 | =item PL_sv_yes |
d8c40edc | 1095 | X<PL_sv_yes> |
6e9d1081 | 1096 | |
94bdecf9 JH |
1097 | This is the C<true> SV. See C<PL_sv_no>. Always refer to this as |
1098 | C<&PL_sv_yes>. | |
1099 | ||
1100 | SV PL_sv_yes | |
6e9d1081 NC |
1101 | |
1102 | =for hackers | |
94bdecf9 | 1103 | Found in file intrpvar.h |
6e9d1081 | 1104 | |
6e9d1081 | 1105 | |
94bdecf9 | 1106 | =back |
6e9d1081 | 1107 | |
94bdecf9 | 1108 | =head1 GV Functions |
6e9d1081 | 1109 | |
94bdecf9 | 1110 | =over 8 |
6e9d1081 | 1111 | |
954c1994 | 1112 | =item GvSV |
d8c40edc | 1113 | X<GvSV> |
954c1994 GS |
1114 | |
1115 | Return the SV from the GV. | |
1116 | ||
1117 | SV* GvSV(GV* gv) | |
1118 | ||
497711e7 GS |
1119 | =for hackers |
1120 | Found in file gv.h | |
1121 | ||
9f435386 RGS |
1122 | =item gv_const_sv |
1123 | X<gv_const_sv> | |
1124 | ||
1125 | If C<gv> is a typeglob whose subroutine entry is a constant sub eligible for | |
1126 | inlining, or C<gv> is a placeholder reference that would be promoted to such | |
1127 | a typeglob, then returns the value returned by the sub. Otherwise, returns | |
1128 | NULL. | |
1129 | ||
1130 | SV* gv_const_sv(GV* gv) | |
1131 | ||
1132 | =for hackers | |
1133 | Found in file gv.c | |
1134 | ||
954c1994 | 1135 | =item gv_fetchmeth |
d8c40edc | 1136 | X<gv_fetchmeth> |
954c1994 GS |
1137 | |
1138 | Returns the glob with the given C<name> and a defined subroutine or | |
1139 | C<NULL>. The glob lives in the given C<stash>, or in the stashes | |
a453c169 | 1140 | accessible via @ISA and UNIVERSAL::. |
954c1994 GS |
1141 | |
1142 | The argument C<level> should be either 0 or -1. If C<level==0>, as a | |
1143 | side-effect creates a glob with the given C<name> in the given C<stash> | |
1144 | which in the case of success contains an alias for the subroutine, and sets | |
1c846c1f | 1145 | up caching info for this glob. Similarly for all the searched stashes. |
954c1994 GS |
1146 | |
1147 | This function grants C<"SUPER"> token as a postfix of the stash name. The | |
1148 | GV returned from C<gv_fetchmeth> may be a method cache entry, which is not | |
4929bf7b | 1149 | visible to Perl code. So when calling C<call_sv>, you should not use |
954c1994 | 1150 | the GV directly; instead, you should use the method's CV, which can be |
1c846c1f | 1151 | obtained from the GV with the C<GvCV> macro. |
954c1994 GS |
1152 | |
1153 | GV* gv_fetchmeth(HV* stash, const char* name, STRLEN len, I32 level) | |
1154 | ||
497711e7 GS |
1155 | =for hackers |
1156 | Found in file gv.c | |
1157 | ||
954c1994 | 1158 | =item gv_fetchmethod_autoload |
d8c40edc | 1159 | X<gv_fetchmethod_autoload> |
954c1994 GS |
1160 | |
1161 | Returns the glob which contains the subroutine to call to invoke the method | |
1162 | on the C<stash>. In fact in the presence of autoloading this may be the | |
1163 | glob for "AUTOLOAD". In this case the corresponding variable $AUTOLOAD is | |
1c846c1f | 1164 | already setup. |
954c1994 GS |
1165 | |
1166 | The third parameter of C<gv_fetchmethod_autoload> determines whether | |
1167 | AUTOLOAD lookup is performed if the given method is not present: non-zero | |
1c846c1f | 1168 | means yes, look for AUTOLOAD; zero means no, don't look for AUTOLOAD. |
954c1994 | 1169 | Calling C<gv_fetchmethod> is equivalent to calling C<gv_fetchmethod_autoload> |
1c846c1f | 1170 | with a non-zero C<autoload> parameter. |
954c1994 GS |
1171 | |
1172 | These functions grant C<"SUPER"> token as a prefix of the method name. Note | |
1173 | that if you want to keep the returned glob for a long time, you need to | |
1174 | check for it being "AUTOLOAD", since at the later time the call may load a | |
1175 | different subroutine due to $AUTOLOAD changing its value. Use the glob | |
1c846c1f | 1176 | created via a side effect to do this. |
954c1994 GS |
1177 | |
1178 | These functions have the same side-effects and as C<gv_fetchmeth> with | |
1179 | C<level==0>. C<name> should be writable if contains C<':'> or C<' | |
1180 | ''>. The warning against passing the GV returned by C<gv_fetchmeth> to | |
1c846c1f | 1181 | C<call_sv> apply equally to these functions. |
954c1994 GS |
1182 | |
1183 | GV* gv_fetchmethod_autoload(HV* stash, const char* name, I32 autoload) | |
1184 | ||
497711e7 GS |
1185 | =for hackers |
1186 | Found in file gv.c | |
1187 | ||
0c81b680 | 1188 | =item gv_fetchmeth_autoload |
d8c40edc | 1189 | X<gv_fetchmeth_autoload> |
0c81b680 JH |
1190 | |
1191 | Same as gv_fetchmeth(), but looks for autoloaded subroutines too. | |
1192 | Returns a glob for the subroutine. | |
1193 | ||
1194 | For an autoloaded subroutine without a GV, will create a GV even | |
1195 | if C<level < 0>. For an autoloaded subroutine without a stub, GvCV() | |
1196 | of the result may be zero. | |
1197 | ||
1198 | GV* gv_fetchmeth_autoload(HV* stash, const char* name, STRLEN len, I32 level) | |
1199 | ||
1200 | =for hackers | |
1201 | Found in file gv.c | |
1202 | ||
954c1994 | 1203 | =item gv_stashpv |
d8c40edc | 1204 | X<gv_stashpv> |
954c1994 | 1205 | |
386d01d6 | 1206 | Returns a pointer to the stash for a specified package. C<name> should |
bc96cb06 SH |
1207 | be a valid UTF-8 string and must be null-terminated. If C<create> is set |
1208 | then the package will be created if it does not already exist. If C<create> | |
1209 | is not set and the package does not exist then NULL is returned. | |
1210 | ||
1211 | HV* gv_stashpv(const char* name, I32 create) | |
1212 | ||
1213 | =for hackers | |
1214 | Found in file gv.c | |
1215 | ||
1216 | =item gv_stashpvn | |
d8c40edc | 1217 | X<gv_stashpvn> |
bc96cb06 SH |
1218 | |
1219 | Returns a pointer to the stash for a specified package. C<name> should | |
1220 | be a valid UTF-8 string. The C<namelen> parameter indicates the length of | |
1221 | the C<name>, in bytes. If C<create> is set then the package will be | |
386d01d6 GS |
1222 | created if it does not already exist. If C<create> is not set and the |
1223 | package does not exist then NULL is returned. | |
954c1994 | 1224 | |
bc96cb06 | 1225 | HV* gv_stashpvn(const char* name, U32 namelen, I32 create) |
954c1994 | 1226 | |
497711e7 GS |
1227 | =for hackers |
1228 | Found in file gv.c | |
1229 | ||
954c1994 | 1230 | =item gv_stashsv |
d8c40edc | 1231 | X<gv_stashsv> |
954c1994 | 1232 | |
386d01d6 GS |
1233 | Returns a pointer to the stash for a specified package, which must be a |
1234 | valid UTF-8 string. See C<gv_stashpv>. | |
954c1994 GS |
1235 | |
1236 | HV* gv_stashsv(SV* sv, I32 create) | |
1237 | ||
497711e7 GS |
1238 | =for hackers |
1239 | Found in file gv.c | |
1240 | ||
954c1994 | 1241 | |
94bdecf9 | 1242 | =back |
954c1994 | 1243 | |
94bdecf9 | 1244 | =head1 Handy Values |
497711e7 | 1245 | |
94bdecf9 | 1246 | =over 8 |
954c1994 | 1247 | |
e509e693 | 1248 | =item Nullav |
d8c40edc | 1249 | X<Nullav> |
497711e7 | 1250 | |
e509e693 | 1251 | Null AV pointer. |
954c1994 | 1252 | |
94bdecf9 | 1253 | =for hackers |
e509e693 | 1254 | Found in file av.h |
954c1994 | 1255 | |
dd2155a4 | 1256 | =item Nullch |
d8c40edc | 1257 | X<Nullch> |
94bdecf9 JH |
1258 | |
1259 | Null character pointer. | |
2307c6d0 | 1260 | |
497711e7 | 1261 | =for hackers |
94bdecf9 | 1262 | Found in file handy.h |
497711e7 | 1263 | |
e509e693 | 1264 | =item Nullcv |
d8c40edc | 1265 | X<Nullcv> |
e509e693 SH |
1266 | |
1267 | Null CV pointer. | |
1268 | ||
1269 | =for hackers | |
1270 | Found in file cv.h | |
1271 | ||
1272 | =item Nullhv | |
d8c40edc | 1273 | X<Nullhv> |
e509e693 SH |
1274 | |
1275 | Null HV pointer. | |
1276 | ||
1277 | =for hackers | |
1278 | Found in file hv.h | |
1279 | ||
94bdecf9 | 1280 | =item Nullsv |
d8c40edc | 1281 | X<Nullsv> |
954c1994 | 1282 | |
94bdecf9 | 1283 | Null SV pointer. |
954c1994 | 1284 | |
497711e7 | 1285 | =for hackers |
94bdecf9 | 1286 | Found in file handy.h |
497711e7 | 1287 | |
954c1994 | 1288 | |
94bdecf9 | 1289 | =back |
954c1994 | 1290 | |
94bdecf9 | 1291 | =head1 Hash Manipulation Functions |
497711e7 | 1292 | |
94bdecf9 | 1293 | =over 8 |
954c1994 | 1294 | |
94bdecf9 | 1295 | =item get_hv |
d8c40edc | 1296 | X<get_hv> |
954c1994 | 1297 | |
94bdecf9 JH |
1298 | Returns the HV of the specified Perl hash. If C<create> is set and the |
1299 | Perl variable does not exist then it will be created. If C<create> is not | |
1300 | set and the variable does not exist then NULL is returned. | |
497711e7 | 1301 | |
94bdecf9 | 1302 | NOTE: the perl_ form of this function is deprecated. |
954c1994 | 1303 | |
94bdecf9 | 1304 | HV* get_hv(const char* name, I32 create) |
954c1994 | 1305 | |
497711e7 | 1306 | =for hackers |
94bdecf9 | 1307 | Found in file perl.c |
497711e7 | 1308 | |
e509e693 | 1309 | =item HEf_SVKEY |
d8c40edc | 1310 | X<HEf_SVKEY> |
e509e693 SH |
1311 | |
1312 | This flag, used in the length slot of hash entries and magic structures, | |
1313 | specifies the structure contains an C<SV*> pointer where a C<char*> pointer | |
1314 | is to be expected. (For information only--not to be used). | |
1315 | ||
1316 | =for hackers | |
1317 | Found in file hv.h | |
1318 | ||
954c1994 | 1319 | =item HeHASH |
d8c40edc | 1320 | X<HeHASH> |
954c1994 GS |
1321 | |
1322 | Returns the computed hash stored in the hash entry. | |
1323 | ||
1324 | U32 HeHASH(HE* he) | |
1325 | ||
497711e7 GS |
1326 | =for hackers |
1327 | Found in file hv.h | |
1328 | ||
954c1994 | 1329 | =item HeKEY |
d8c40edc | 1330 | X<HeKEY> |
954c1994 GS |
1331 | |
1332 | Returns the actual pointer stored in the key slot of the hash entry. The | |
1333 | pointer may be either C<char*> or C<SV*>, depending on the value of | |
1334 | C<HeKLEN()>. Can be assigned to. The C<HePV()> or C<HeSVKEY()> macros are | |
1335 | usually preferable for finding the value of a key. | |
1336 | ||
1337 | void* HeKEY(HE* he) | |
1338 | ||
497711e7 GS |
1339 | =for hackers |
1340 | Found in file hv.h | |
1341 | ||
954c1994 | 1342 | =item HeKLEN |
d8c40edc | 1343 | X<HeKLEN> |
954c1994 GS |
1344 | |
1345 | If this is negative, and amounts to C<HEf_SVKEY>, it indicates the entry | |
1346 | holds an C<SV*> key. Otherwise, holds the actual length of the key. Can | |
1347 | be assigned to. The C<HePV()> macro is usually preferable for finding key | |
1348 | lengths. | |
1349 | ||
1350 | STRLEN HeKLEN(HE* he) | |
1351 | ||
497711e7 GS |
1352 | =for hackers |
1353 | Found in file hv.h | |
1354 | ||
954c1994 | 1355 | =item HePV |
d8c40edc | 1356 | X<HePV> |
954c1994 GS |
1357 | |
1358 | Returns the key slot of the hash entry as a C<char*> value, doing any | |
1359 | necessary dereferencing of possibly C<SV*> keys. The length of the string | |
1360 | is placed in C<len> (this is a macro, so do I<not> use C<&len>). If you do | |
1361 | not care about what the length of the key is, you may use the global | |
1362 | variable C<PL_na>, though this is rather less efficient than using a local | |
1363 | variable. Remember though, that hash keys in perl are free to contain | |
1364 | embedded nulls, so using C<strlen()> or similar is not a good way to find | |
1365 | the length of hash keys. This is very similar to the C<SvPV()> macro | |
1366 | described elsewhere in this document. | |
1367 | ||
1368 | char* HePV(HE* he, STRLEN len) | |
1369 | ||
497711e7 GS |
1370 | =for hackers |
1371 | Found in file hv.h | |
1372 | ||
954c1994 | 1373 | =item HeSVKEY |
d8c40edc | 1374 | X<HeSVKEY> |
954c1994 | 1375 | |
458cb9d2 | 1376 | Returns the key as an C<SV*>, or C<NULL> if the hash entry does not |
954c1994 GS |
1377 | contain an C<SV*> key. |
1378 | ||
1379 | SV* HeSVKEY(HE* he) | |
1380 | ||
497711e7 GS |
1381 | =for hackers |
1382 | Found in file hv.h | |
1383 | ||
954c1994 | 1384 | =item HeSVKEY_force |
d8c40edc | 1385 | X<HeSVKEY_force> |
954c1994 GS |
1386 | |
1387 | Returns the key as an C<SV*>. Will create and return a temporary mortal | |
1388 | C<SV*> if the hash entry contains only a C<char*> key. | |
1389 | ||
1390 | SV* HeSVKEY_force(HE* he) | |
1391 | ||
497711e7 GS |
1392 | =for hackers |
1393 | Found in file hv.h | |
1394 | ||
954c1994 | 1395 | =item HeSVKEY_set |
d8c40edc | 1396 | X<HeSVKEY_set> |
954c1994 GS |
1397 | |
1398 | Sets the key to a given C<SV*>, taking care to set the appropriate flags to | |
1399 | indicate the presence of an C<SV*> key, and returns the same | |
1400 | C<SV*>. | |
1401 | ||
1402 | SV* HeSVKEY_set(HE* he, SV* sv) | |
1403 | ||
497711e7 GS |
1404 | =for hackers |
1405 | Found in file hv.h | |
1406 | ||
954c1994 | 1407 | =item HeVAL |
d8c40edc | 1408 | X<HeVAL> |
954c1994 GS |
1409 | |
1410 | Returns the value slot (type C<SV*>) stored in the hash entry. | |
1411 | ||
1412 | SV* HeVAL(HE* he) | |
1413 | ||
497711e7 GS |
1414 | =for hackers |
1415 | Found in file hv.h | |
1416 | ||
954c1994 | 1417 | =item HvNAME |
d8c40edc | 1418 | X<HvNAME> |
954c1994 | 1419 | |
9282b5fd SH |
1420 | Returns the package name of a stash, or NULL if C<stash> isn't a stash. |
1421 | See C<SvSTASH>, C<CvSTASH>. | |
954c1994 GS |
1422 | |
1423 | char* HvNAME(HV* stash) | |
1424 | ||
497711e7 GS |
1425 | =for hackers |
1426 | Found in file hv.h | |
1427 | ||
ecae49c0 | 1428 | =item hv_assert |
d8c40edc | 1429 | X<hv_assert> |
ecae49c0 NC |
1430 | |
1431 | Check that a hash is in an internally consistent state. | |
1432 | ||
1433 | void hv_assert(HV* tb) | |
1434 | ||
1435 | =for hackers | |
1436 | Found in file hv.c | |
1437 | ||
954c1994 | 1438 | =item hv_clear |
d8c40edc | 1439 | X<hv_clear> |
954c1994 GS |
1440 | |
1441 | Clears a hash, making it empty. | |
1442 | ||
1443 | void hv_clear(HV* tb) | |
1444 | ||
497711e7 GS |
1445 | =for hackers |
1446 | Found in file hv.c | |
1447 | ||
3540d4ce | 1448 | =item hv_clear_placeholders |
d8c40edc | 1449 | X<hv_clear_placeholders> |
3540d4ce AB |
1450 | |
1451 | Clears any placeholders from a hash. If a restricted hash has any of its keys | |
1452 | marked as readonly and the key is subsequently deleted, the key is not actually | |
1453 | deleted but is marked by assigning it a value of &PL_sv_placeholder. This tags | |
1454 | it so it will be ignored by future operations such as iterating over the hash, | |
fa11829f | 1455 | but will still allow the hash to have a value reassigned to the key at some |
3540d4ce AB |
1456 | future point. This function clears any such placeholder keys from the hash. |
1457 | See Hash::Util::lock_keys() for an example of its use. | |
1458 | ||
1459 | void hv_clear_placeholders(HV* hb) | |
1460 | ||
1461 | =for hackers | |
1462 | Found in file hv.c | |
1463 | ||
954c1994 | 1464 | =item hv_delete |
d8c40edc | 1465 | X<hv_delete> |
954c1994 GS |
1466 | |
1467 | Deletes a key/value pair in the hash. The value SV is removed from the | |
1c846c1f | 1468 | hash and returned to the caller. The C<klen> is the length of the key. |
954c1994 GS |
1469 | The C<flags> value will normally be zero; if set to G_DISCARD then NULL |
1470 | will be returned. | |
1471 | ||
da58a35d | 1472 | SV* hv_delete(HV* tb, const char* key, I32 klen, I32 flags) |
954c1994 | 1473 | |
497711e7 GS |
1474 | =for hackers |
1475 | Found in file hv.c | |
1476 | ||
954c1994 | 1477 | =item hv_delete_ent |
d8c40edc | 1478 | X<hv_delete_ent> |
954c1994 GS |
1479 | |
1480 | Deletes a key/value pair in the hash. The value SV is removed from the | |
1481 | hash and returned to the caller. The C<flags> value will normally be zero; | |
1482 | if set to G_DISCARD then NULL will be returned. C<hash> can be a valid | |
1483 | precomputed hash value, or 0 to ask for it to be computed. | |
1484 | ||
1485 | SV* hv_delete_ent(HV* tb, SV* key, I32 flags, U32 hash) | |
1486 | ||
497711e7 GS |
1487 | =for hackers |
1488 | Found in file hv.c | |
1489 | ||
954c1994 | 1490 | =item hv_exists |
d8c40edc | 1491 | X<hv_exists> |
954c1994 GS |
1492 | |
1493 | Returns a boolean indicating whether the specified hash key exists. The | |
1494 | C<klen> is the length of the key. | |
1495 | ||
da58a35d | 1496 | bool hv_exists(HV* tb, const char* key, I32 klen) |
954c1994 | 1497 | |
497711e7 GS |
1498 | =for hackers |
1499 | Found in file hv.c | |
1500 | ||
954c1994 | 1501 | =item hv_exists_ent |
d8c40edc | 1502 | X<hv_exists_ent> |
954c1994 GS |
1503 | |
1504 | Returns a boolean indicating whether the specified hash key exists. C<hash> | |
1505 | can be a valid precomputed hash value, or 0 to ask for it to be | |
1506 | computed. | |
1507 | ||
1508 | bool hv_exists_ent(HV* tb, SV* key, U32 hash) | |
1509 | ||
497711e7 GS |
1510 | =for hackers |
1511 | Found in file hv.c | |
1512 | ||
954c1994 | 1513 | =item hv_fetch |
d8c40edc | 1514 | X<hv_fetch> |
954c1994 GS |
1515 | |
1516 | Returns the SV which corresponds to the specified key in the hash. The | |
1517 | C<klen> is the length of the key. If C<lval> is set then the fetch will be | |
1518 | part of a store. Check that the return value is non-null before | |
f4758303 | 1519 | dereferencing it to an C<SV*>. |
954c1994 | 1520 | |
96f1132b | 1521 | See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for more |
954c1994 GS |
1522 | information on how to use this function on tied hashes. |
1523 | ||
da58a35d | 1524 | SV** hv_fetch(HV* tb, const char* key, I32 klen, I32 lval) |
954c1994 | 1525 | |
497711e7 GS |
1526 | =for hackers |
1527 | Found in file hv.c | |
1528 | ||
954c1994 | 1529 | =item hv_fetch_ent |
d8c40edc | 1530 | X<hv_fetch_ent> |
954c1994 GS |
1531 | |
1532 | Returns the hash entry which corresponds to the specified key in the hash. | |
1533 | C<hash> must be a valid precomputed hash number for the given C<key>, or 0 | |
1534 | if you want the function to compute it. IF C<lval> is set then the fetch | |
1535 | will be part of a store. Make sure the return value is non-null before | |
1536 | accessing it. The return value when C<tb> is a tied hash is a pointer to a | |
1537 | static location, so be sure to make a copy of the structure if you need to | |
1c846c1f | 1538 | store it somewhere. |
954c1994 | 1539 | |
96f1132b | 1540 | See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for more |
954c1994 GS |
1541 | information on how to use this function on tied hashes. |
1542 | ||
1543 | HE* hv_fetch_ent(HV* tb, SV* key, I32 lval, U32 hash) | |
1544 | ||
497711e7 GS |
1545 | =for hackers |
1546 | Found in file hv.c | |
1547 | ||
954c1994 | 1548 | =item hv_iterinit |
d8c40edc | 1549 | X<hv_iterinit> |
954c1994 GS |
1550 | |
1551 | Prepares a starting point to traverse a hash table. Returns the number of | |
1552 | keys in the hash (i.e. the same as C<HvKEYS(tb)>). The return value is | |
1c846c1f | 1553 | currently only meaningful for hashes without tie magic. |
954c1994 GS |
1554 | |
1555 | NOTE: Before version 5.004_65, C<hv_iterinit> used to return the number of | |
1556 | hash buckets that happen to be in use. If you still need that esoteric | |
1557 | value, you can get it through the macro C<HvFILL(tb)>. | |
1558 | ||
641d4181 | 1559 | |
954c1994 GS |
1560 | I32 hv_iterinit(HV* tb) |
1561 | ||
497711e7 GS |
1562 | =for hackers |
1563 | Found in file hv.c | |
1564 | ||
954c1994 | 1565 | =item hv_iterkey |
d8c40edc | 1566 | X<hv_iterkey> |
954c1994 GS |
1567 | |
1568 | Returns the key from the current position of the hash iterator. See | |
1569 | C<hv_iterinit>. | |
1570 | ||
1571 | char* hv_iterkey(HE* entry, I32* retlen) | |
1572 | ||
497711e7 GS |
1573 | =for hackers |
1574 | Found in file hv.c | |
1575 | ||
954c1994 | 1576 | =item hv_iterkeysv |
d8c40edc | 1577 | X<hv_iterkeysv> |
954c1994 GS |
1578 | |
1579 | Returns the key as an C<SV*> from the current position of the hash | |
1580 | iterator. The return value will always be a mortal copy of the key. Also | |
1581 | see C<hv_iterinit>. | |
1582 | ||
1583 | SV* hv_iterkeysv(HE* entry) | |
1584 | ||
497711e7 GS |
1585 | =for hackers |
1586 | Found in file hv.c | |
1587 | ||
954c1994 | 1588 | =item hv_iternext |
d8c40edc | 1589 | X<hv_iternext> |
954c1994 GS |
1590 | |
1591 | Returns entries from a hash iterator. See C<hv_iterinit>. | |
1592 | ||
641d4181 JH |
1593 | You may call C<hv_delete> or C<hv_delete_ent> on the hash entry that the |
1594 | iterator currently points to, without losing your place or invalidating your | |
1595 | iterator. Note that in this case the current entry is deleted from the hash | |
1596 | with your iterator holding the last reference to it. Your iterator is flagged | |
1597 | to free the entry on the next call to C<hv_iternext>, so you must not discard | |
1598 | your iterator immediately else the entry will leak - call C<hv_iternext> to | |
1599 | trigger the resource deallocation. | |
1600 | ||
954c1994 GS |
1601 | HE* hv_iternext(HV* tb) |
1602 | ||
497711e7 GS |
1603 | =for hackers |
1604 | Found in file hv.c | |
1605 | ||
954c1994 | 1606 | =item hv_iternextsv |
d8c40edc | 1607 | X<hv_iternextsv> |
954c1994 GS |
1608 | |
1609 | Performs an C<hv_iternext>, C<hv_iterkey>, and C<hv_iterval> in one | |
1610 | operation. | |
1611 | ||
1612 | SV* hv_iternextsv(HV* hv, char** key, I32* retlen) | |
1613 | ||
497711e7 GS |
1614 | =for hackers |
1615 | Found in file hv.c | |
1616 | ||
641d4181 | 1617 | =item hv_iternext_flags |
d8c40edc | 1618 | X<hv_iternext_flags> |
641d4181 JH |
1619 | |
1620 | Returns entries from a hash iterator. See C<hv_iterinit> and C<hv_iternext>. | |
1621 | The C<flags> value will normally be zero; if HV_ITERNEXT_WANTPLACEHOLDERS is | |
1622 | set the placeholders keys (for restricted hashes) will be returned in addition | |
1623 | to normal keys. By default placeholders are automatically skipped over. | |
384679aa RGS |
1624 | Currently a placeholder is implemented with a value that is |
1625 | C<&Perl_sv_placeholder>. Note that the implementation of placeholders and | |
641d4181 JH |
1626 | restricted hashes may change, and the implementation currently is |
1627 | insufficiently abstracted for any change to be tidy. | |
1628 | ||
1629 | NOTE: this function is experimental and may change or be | |
1630 | removed without notice. | |
1631 | ||
1632 | HE* hv_iternext_flags(HV* tb, I32 flags) | |
1633 | ||
1634 | =for hackers | |
1635 | Found in file hv.c | |
1636 | ||
954c1994 | 1637 | =item hv_iterval |
d8c40edc | 1638 | X<hv_iterval> |
954c1994 GS |
1639 | |
1640 | Returns the value from the current position of the hash iterator. See | |
1641 | C<hv_iterkey>. | |
1642 | ||
1643 | SV* hv_iterval(HV* tb, HE* entry) | |
1644 | ||
497711e7 GS |
1645 | =for hackers |
1646 | Found in file hv.c | |
1647 | ||
954c1994 | 1648 | =item hv_magic |
d8c40edc | 1649 | X<hv_magic> |
954c1994 GS |
1650 | |
1651 | Adds magic to a hash. See C<sv_magic>. | |
1652 | ||
1653 | void hv_magic(HV* hv, GV* gv, int how) | |
1654 | ||
497711e7 GS |
1655 | =for hackers |
1656 | Found in file hv.c | |
1657 | ||
a3bcc51e | 1658 | =item hv_scalar |
d8c40edc | 1659 | X<hv_scalar> |
a3bcc51e TP |
1660 | |
1661 | Evaluates the hash in scalar context and returns the result. Handles magic when the hash is tied. | |
1662 | ||
1663 | SV* hv_scalar(HV* hv) | |
1664 | ||
1665 | =for hackers | |
1666 | Found in file hv.c | |
1667 | ||
954c1994 | 1668 | =item hv_store |
d8c40edc | 1669 | X<hv_store> |
954c1994 GS |
1670 | |
1671 | Stores an SV in a hash. The hash key is specified as C<key> and C<klen> is | |
1672 | the length of the key. The C<hash> parameter is the precomputed hash | |
1673 | value; if it is zero then Perl will compute it. The return value will be | |
1674 | NULL if the operation failed or if the value did not need to be actually | |
1675 | stored within the hash (as in the case of tied hashes). Otherwise it can | |
1676 | be dereferenced to get the original C<SV*>. Note that the caller is | |
1677 | responsible for suitably incrementing the reference count of C<val> before | |
7e8c5dac HS |
1678 | the call, and decrementing it if the function returned NULL. Effectively |
1679 | a successful hv_store takes ownership of one reference to C<val>. This is | |
1680 | usually what you want; a newly created SV has a reference count of one, so | |
1681 | if all your code does is create SVs then store them in a hash, hv_store | |
1682 | will own the only reference to the new SV, and your code doesn't need to do | |
1683 | anything further to tidy up. hv_store is not implemented as a call to | |
1684 | hv_store_ent, and does not create a temporary SV for the key, so if your | |
1685 | key data is not already in SV form then use hv_store in preference to | |
1686 | hv_store_ent. | |
954c1994 | 1687 | |
96f1132b | 1688 | See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for more |
954c1994 GS |
1689 | information on how to use this function on tied hashes. |
1690 | ||
da58a35d | 1691 | SV** hv_store(HV* tb, const char* key, I32 klen, SV* val, U32 hash) |
954c1994 | 1692 | |
497711e7 GS |
1693 | =for hackers |
1694 | Found in file hv.c | |
1695 | ||
954c1994 | 1696 | =item hv_store_ent |
d8c40edc | 1697 | X<hv_store_ent> |
954c1994 GS |
1698 | |
1699 | Stores C<val> in a hash. The hash key is specified as C<key>. The C<hash> | |
1700 | parameter is the precomputed hash value; if it is zero then Perl will | |
1701 | compute it. The return value is the new hash entry so created. It will be | |
1702 | NULL if the operation failed or if the value did not need to be actually | |
1703 | stored within the hash (as in the case of tied hashes). Otherwise the | |
f22d8e4b | 1704 | contents of the return value can be accessed using the C<He?> macros |
954c1994 GS |
1705 | described here. Note that the caller is responsible for suitably |
1706 | incrementing the reference count of C<val> before the call, and | |
7e8c5dac HS |
1707 | decrementing it if the function returned NULL. Effectively a successful |
1708 | hv_store_ent takes ownership of one reference to C<val>. This is | |
1709 | usually what you want; a newly created SV has a reference count of one, so | |
1710 | if all your code does is create SVs then store them in a hash, hv_store | |
1711 | will own the only reference to the new SV, and your code doesn't need to do | |
1712 | anything further to tidy up. Note that hv_store_ent only reads the C<key>; | |
1713 | unlike C<val> it does not take ownership of it, so maintaining the correct | |
1714 | reference count on C<key> is entirely the caller's responsibility. hv_store | |
1715 | is not implemented as a call to hv_store_ent, and does not create a temporary | |
1716 | SV for the key, so if your key data is not already in SV form then use | |
1717 | hv_store in preference to hv_store_ent. | |
954c1994 | 1718 | |
96f1132b | 1719 | See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for more |
954c1994 GS |
1720 | information on how to use this function on tied hashes. |
1721 | ||
1722 | HE* hv_store_ent(HV* tb, SV* key, SV* val, U32 hash) | |
1723 | ||
497711e7 GS |
1724 | =for hackers |
1725 | Found in file hv.c | |
1726 | ||
954c1994 | 1727 | =item hv_undef |
d8c40edc | 1728 | X<hv_undef> |
954c1994 GS |
1729 | |
1730 | Undefines the hash. | |
1731 | ||
1732 | void hv_undef(HV* tb) | |
1733 | ||
497711e7 GS |
1734 | =for hackers |
1735 | Found in file hv.c | |
1736 | ||
94bdecf9 | 1737 | =item newHV |
d8c40edc | 1738 | X<newHV> |
d2cc3551 | 1739 | |
94bdecf9 | 1740 | Creates a new HV. The reference count is set to 1. |
d2cc3551 | 1741 | |
94bdecf9 | 1742 | HV* newHV() |
d2cc3551 JH |
1743 | |
1744 | =for hackers | |
94bdecf9 | 1745 | Found in file hv.c |
d2cc3551 | 1746 | |
954c1994 | 1747 | |
94bdecf9 | 1748 | =back |
954c1994 | 1749 | |
94bdecf9 | 1750 | =head1 Magical Functions |
954c1994 | 1751 | |
94bdecf9 | 1752 | =over 8 |
497711e7 | 1753 | |
94bdecf9 | 1754 | =item mg_clear |
d8c40edc | 1755 | X<mg_clear> |
954c1994 | 1756 | |
94bdecf9 | 1757 | Clear something magical that the SV represents. See C<sv_magic>. |
954c1994 | 1758 | |
94bdecf9 | 1759 | int mg_clear(SV* sv) |
954c1994 | 1760 | |
497711e7 | 1761 | =for hackers |
94bdecf9 | 1762 | Found in file mg.c |
497711e7 | 1763 | |
94bdecf9 | 1764 | =item mg_copy |
d8c40edc | 1765 | X<mg_copy> |
954c1994 | 1766 | |
94bdecf9 | 1767 | Copies the magic from one SV to another. See C<sv_magic>. |
954c1994 | 1768 | |
94bdecf9 | 1769 | int mg_copy(SV* sv, SV* nsv, const char* key, I32 klen) |
954c1994 | 1770 | |
497711e7 | 1771 | =for hackers |
94bdecf9 | 1772 | Found in file mg.c |
497711e7 | 1773 | |
94bdecf9 | 1774 | =item mg_find |
d8c40edc | 1775 | X<mg_find> |
954c1994 | 1776 | |
94bdecf9 | 1777 | Finds the magic pointer for type matching the SV. See C<sv_magic>. |
954c1994 | 1778 | |
35a4481c | 1779 | MAGIC* mg_find(const SV* sv, int type) |
954c1994 | 1780 | |
497711e7 | 1781 | =for hackers |
94bdecf9 | 1782 | Found in file mg.c |
497711e7 | 1783 | |
94bdecf9 | 1784 | =item mg_free |
d8c40edc | 1785 | X<mg_free> |
954c1994 | 1786 | |
94bdecf9 | 1787 | Free any magic storage used by the SV. See C<sv_magic>. |
954c1994 | 1788 | |
94bdecf9 | 1789 | int mg_free(SV* sv) |
954c1994 | 1790 | |
497711e7 | 1791 | =for hackers |
94bdecf9 | 1792 | Found in file mg.c |
497711e7 | 1793 | |
94bdecf9 | 1794 | =item mg_get |
d8c40edc | 1795 | X<mg_get> |
eebe1485 | 1796 | |
94bdecf9 | 1797 | Do magic after a value is retrieved from the SV. See C<sv_magic>. |
282f25c9 | 1798 | |
94bdecf9 | 1799 | int mg_get(SV* sv) |
eebe1485 SC |
1800 | |
1801 | =for hackers | |
94bdecf9 | 1802 | Found in file mg.c |
eebe1485 | 1803 | |
94bdecf9 | 1804 | =item mg_length |
d8c40edc | 1805 | X<mg_length> |
eebe1485 | 1806 | |
94bdecf9 | 1807 | Report on the SV's length. See C<sv_magic>. |
eebe1485 | 1808 | |
94bdecf9 | 1809 | U32 mg_length(SV* sv) |
eebe1485 SC |
1810 | |
1811 | =for hackers | |
94bdecf9 | 1812 | Found in file mg.c |
eebe1485 | 1813 | |
94bdecf9 | 1814 | =item mg_magical |
d8c40edc | 1815 | X<mg_magical> |
954c1994 | 1816 | |
94bdecf9 | 1817 | Turns on the magical status of an SV. See C<sv_magic>. |
954c1994 | 1818 | |
94bdecf9 | 1819 | void mg_magical(SV* sv) |
954c1994 | 1820 | |
497711e7 | 1821 | =for hackers |
94bdecf9 | 1822 | Found in file mg.c |
497711e7 | 1823 | |
94bdecf9 | 1824 | =item mg_set |
d8c40edc | 1825 | X<mg_set> |
954c1994 | 1826 | |
94bdecf9 | 1827 | Do magic after a value is assigned to the SV. See C<sv_magic>. |
954c1994 | 1828 | |
94bdecf9 | 1829 | int mg_set(SV* sv) |
954c1994 | 1830 | |
497711e7 | 1831 | =for hackers |
94bdecf9 | 1832 | Found in file mg.c |
497711e7 | 1833 | |
94bdecf9 | 1834 | =item SvGETMAGIC |
d8c40edc | 1835 | X<SvGETMAGIC> |
954c1994 | 1836 | |
94bdecf9 JH |
1837 | Invokes C<mg_get> on an SV if it has 'get' magic. This macro evaluates its |
1838 | argument more than once. | |
954c1994 | 1839 | |
94bdecf9 | 1840 | void SvGETMAGIC(SV* sv) |
954c1994 | 1841 | |
497711e7 | 1842 | =for hackers |
94bdecf9 | 1843 | Found in file sv.h |
497711e7 | 1844 | |
a4f1a029 | 1845 | =item SvLOCK |
d8c40edc | 1846 | X<SvLOCK> |
a4f1a029 NIS |
1847 | |
1848 | Arranges for a mutual exclusion lock to be obtained on sv if a suitable module | |
1849 | has been loaded. | |
1850 | ||
1851 | void SvLOCK(SV* sv) | |
1852 | ||
1853 | =for hackers | |
1854 | Found in file sv.h | |
1855 | ||
94bdecf9 | 1856 | =item SvSETMAGIC |
d8c40edc | 1857 | X<SvSETMAGIC> |
7d3fb230 | 1858 | |
94bdecf9 JH |
1859 | Invokes C<mg_set> on an SV if it has 'set' magic. This macro evaluates its |
1860 | argument more than once. | |
7d3fb230 | 1861 | |
94bdecf9 | 1862 | void SvSETMAGIC(SV* sv) |
7d3fb230 BS |
1863 | |
1864 | =for hackers | |
94bdecf9 | 1865 | Found in file sv.h |
7d3fb230 | 1866 | |
94bdecf9 | 1867 | =item SvSetMagicSV |
d8c40edc | 1868 | X<SvSetMagicSV> |
954c1994 | 1869 | |
94bdecf9 | 1870 | Like C<SvSetSV>, but does any set magic required afterwards. |
954c1994 | 1871 | |
94bdecf9 | 1872 | void SvSetMagicSV(SV* dsb, SV* ssv) |
954c1994 | 1873 | |
497711e7 | 1874 | =for hackers |
94bdecf9 | 1875 | Found in file sv.h |
497711e7 | 1876 | |
a4f1a029 | 1877 | =item SvSetMagicSV_nosteal |
d8c40edc | 1878 | X<SvSetMagicSV_nosteal> |
a4f1a029 | 1879 | |
80663158 | 1880 | Like C<SvSetSV_nosteal>, but does any set magic required afterwards. |
a4f1a029 NIS |
1881 | |
1882 | void SvSetMagicSV_nosteal(SV* dsv, SV* ssv) | |
1883 | ||
1884 | =for hackers | |
1885 | Found in file sv.h | |
1886 | ||
94bdecf9 | 1887 | =item SvSetSV |
d8c40edc | 1888 | X<SvSetSV> |
954c1994 | 1889 | |
94bdecf9 JH |
1890 | Calls C<sv_setsv> if dsv is not the same as ssv. May evaluate arguments |
1891 | more than once. | |
1892 | ||
1893 | void SvSetSV(SV* dsb, SV* ssv) | |
954c1994 | 1894 | |
497711e7 | 1895 | =for hackers |
94bdecf9 | 1896 | Found in file sv.h |
497711e7 | 1897 | |
94bdecf9 | 1898 | =item SvSetSV_nosteal |
d8c40edc | 1899 | X<SvSetSV_nosteal> |
954c1994 | 1900 | |
94bdecf9 JH |
1901 | Calls a non-destructive version of C<sv_setsv> if dsv is not the same as |
1902 | ssv. May evaluate arguments more than once. | |
954c1994 | 1903 | |
94bdecf9 | 1904 | void SvSetSV_nosteal(SV* dsv, SV* ssv) |
954c1994 | 1905 | |
497711e7 | 1906 | =for hackers |
94bdecf9 | 1907 | Found in file sv.h |
497711e7 | 1908 | |
a4f1a029 | 1909 | =item SvSHARE |
d8c40edc | 1910 | X<SvSHARE> |
a4f1a029 NIS |
1911 | |
1912 | Arranges for sv to be shared between threads if a suitable module | |
1913 | has been loaded. | |
1914 | ||
1915 | void SvSHARE(SV* sv) | |
1916 | ||
1917 | =for hackers | |
1918 | Found in file sv.h | |
1919 | ||
e509e693 | 1920 | =item SvUNLOCK |
d8c40edc | 1921 | X<SvUNLOCK> |
e509e693 SH |
1922 | |
1923 | Releases a mutual exclusion lock on sv if a suitable module | |
1924 | has been loaded. | |
1925 | ||
1926 | void SvUNLOCK(SV* sv) | |
1927 | ||
1928 | =for hackers | |
1929 | Found in file sv.h | |
1930 | ||
954c1994 | 1931 | |
94bdecf9 | 1932 | =back |
954c1994 | 1933 | |
94bdecf9 | 1934 | =head1 Memory Management |
954c1994 | 1935 | |
94bdecf9 | 1936 | =over 8 |
497711e7 | 1937 | |
94bdecf9 | 1938 | =item Copy |
d8c40edc | 1939 | X<Copy> |
954c1994 | 1940 | |
94bdecf9 JH |
1941 | The XSUB-writer's interface to the C C<memcpy> function. The C<src> is the |
1942 | source, C<dest> is the destination, C<nitems> is the number of items, and C<type> is | |
1943 | the type. May fail on overlapping copies. See also C<Move>. | |
954c1994 | 1944 | |
94bdecf9 | 1945 | void Copy(void* src, void* dest, int nitems, type) |
954c1994 | 1946 | |
497711e7 | 1947 | =for hackers |
94bdecf9 | 1948 | Found in file handy.h |
497711e7 | 1949 | |
e90e2364 | 1950 | =item CopyD |
d8c40edc | 1951 | X<CopyD> |
e90e2364 NC |
1952 | |
1953 | Like C<Copy> but returns dest. Useful for encouraging compilers to tail-call | |
1954 | optimise. | |
1955 | ||
1956 | void * CopyD(void* src, void* dest, int nitems, type) | |
1957 | ||
1958 | =for hackers | |
1959 | Found in file handy.h | |
1960 | ||
94bdecf9 | 1961 | =item Move |
d8c40edc | 1962 | X<Move> |
954c1994 | 1963 | |
94bdecf9 JH |
1964 | The XSUB-writer's interface to the C C<memmove> function. The C<src> is the |
1965 | source, C<dest> is the destination, C<nitems> is the number of items, and C<type> is | |
1966 | the type. Can do overlapping moves. See also C<Copy>. | |
954c1994 | 1967 | |
94bdecf9 | 1968 | void Move(void* src, void* dest, int nitems, type) |
954c1994 | 1969 | |
497711e7 | 1970 | =for hackers |
94bdecf9 | 1971 | Found in file handy.h |
497711e7 | 1972 | |
e90e2364 | 1973 | =item MoveD |
d8c40edc | 1974 | X<MoveD> |
e90e2364 NC |
1975 | |
1976 | Like C<Move> but returns dest. Useful for encouraging compilers to tail-call | |
1977 | optimise. | |
1978 | ||
1979 | void * MoveD(void* src, void* dest, int nitems, type) | |
1980 | ||
1981 | =for hackers | |
1982 | Found in file handy.h | |
1983 | ||
a02a5408 | 1984 | =item Newx |
d8c40edc | 1985 | X<Newx> |
954c1994 | 1986 | |
94bdecf9 | 1987 | The XSUB-writer's interface to the C C<malloc> function. |
954c1994 | 1988 | |
c5008215 JC |
1989 | In 5.9.3, Newx() and friends replace the older New() API, and drops |
1990 | the first parameter, I<x>, a debug aid which allowed callers to identify | |
37b8b4c9 | 1991 | themselves. This aid has been superseded by a new build option, |
c5008215 JC |
1992 | PERL_MEM_LOG (see L<perlhack/PERL_MEM_LOG>). The older API is still |
1993 | there for use in XS modules supporting older perls. | |
1994 | ||
a02a5408 | 1995 | void Newx(void* ptr, int nitems, type) |
954c1994 | 1996 | |
497711e7 | 1997 | =for hackers |
94bdecf9 | 1998 | Found in file handy.h |
497711e7 | 1999 | |
a02a5408 | 2000 | =item Newxc |
d8c40edc | 2001 | X<Newxc> |
954c1994 | 2002 | |
94bdecf9 | 2003 | The XSUB-writer's interface to the C C<malloc> function, with |
c5008215 | 2004 | cast. See also C<Newx>. |
954c1994 | 2005 | |
a02a5408 | 2006 | void Newxc(void* ptr, int nitems, type, cast) |
954c1994 | 2007 | |
497711e7 | 2008 | =for hackers |
94bdecf9 | 2009 | Found in file handy.h |
954c1994 | 2010 | |
a02a5408 | 2011 | =item Newxz |
d8c40edc | 2012 | X<Newxz> |
954c1994 | 2013 | |
94bdecf9 | 2014 | The XSUB-writer's interface to the C C<malloc> function. The allocated |
c5008215 | 2015 | memory is zeroed with C<memzero>. See also C<Newx>. |
a02a5408 JC |
2016 | |
2017 | void Newxz(void* ptr, int nitems, type) | |
954c1994 | 2018 | |
497711e7 GS |
2019 | =for hackers |
2020 | Found in file handy.h | |
2021 | ||
9965345d | 2022 | =item Poison |
d8c40edc | 2023 | X<Poison> |
9965345d | 2024 | |
7e337ee0 | 2025 | PoisonWith(0xEF) for catching access to freed memory. |
9965345d JH |
2026 | |
2027 | void Poison(void* dest, int nitems, type) | |
2028 | ||
2029 | =for hackers | |
2030 | Found in file handy.h | |
2031 | ||
7e337ee0 JH |
2032 | =item PoisonNew |
2033 | X<PoisonNew> | |
2034 | ||
2035 | PoisonWith(0xAB) for catching access to allocated but uninitialized memory. | |
2036 | ||
2037 | void PoisonNew(void* dest, int nitems, type) | |
2038 | ||
2039 | =for hackers | |
2040 | Found in file handy.h | |
2041 | ||
2042 | =item PoisonWith | |
2043 | X<PoisonWith> | |
2044 | ||
2045 | Fill up memory with a byte pattern (a byte repeated over and over | |
2046 | again) that hopefully catches attempts to access uninitialized memory. | |
2047 | ||
2048 | void PoisonWith(void* dest, int nitems, type, U8 byte) | |
2049 | ||
2050 | =for hackers | |
2051 | Found in file handy.h | |
2052 | ||
94bdecf9 | 2053 | =item Renew |
d8c40edc | 2054 | X<Renew> |
954c1994 | 2055 | |
94bdecf9 | 2056 | The XSUB-writer's interface to the C C<realloc> function. |
954c1994 | 2057 | |
94bdecf9 | 2058 | void Renew(void* ptr, int nitems, type) |
954c1994 | 2059 | |
497711e7 GS |
2060 | =for hackers |
2061 | Found in file handy.h | |
2062 | ||
94bdecf9 | 2063 | =item Renewc |
d8c40edc | 2064 | X<Renewc> |
954c1994 | 2065 | |
94bdecf9 JH |
2066 | The XSUB-writer's interface to the C C<realloc> function, with |
2067 | cast. | |
954c1994 | 2068 | |
94bdecf9 | 2069 | void Renewc(void* ptr, int nitems, type, cast) |
954c1994 | 2070 | |
497711e7 | 2071 | =for hackers |
94bdecf9 | 2072 | Found in file handy.h |
497711e7 | 2073 | |
94bdecf9 | 2074 | =item Safefree |
d8c40edc | 2075 | X<Safefree> |
954c1994 | 2076 | |
94bdecf9 | 2077 | The XSUB-writer's interface to the C C<free> function. |
954c1994 | 2078 | |
94bdecf9 | 2079 | void Safefree(void* ptr) |
954c1994 | 2080 | |
497711e7 GS |
2081 | =for hackers |
2082 | Found in file handy.h | |
2083 | ||
94bdecf9 | 2084 | =item savepv |
d8c40edc | 2085 | X<savepv> |
954c1994 | 2086 | |
641d4181 JH |
2087 | Perl's version of C<strdup()>. Returns a pointer to a newly allocated |
2088 | string which is a duplicate of C<pv>. The size of the string is | |
2089 | determined by C<strlen()>. The memory allocated for the new string can | |
2090 | be freed with the C<Safefree()> function. | |
954c1994 | 2091 | |
641d4181 | 2092 | char* savepv(const char* pv) |
954c1994 | 2093 | |
497711e7 | 2094 | =for hackers |
94bdecf9 | 2095 | Found in file util.c |
497711e7 | 2096 | |
94bdecf9 | 2097 | =item savepvn |
d8c40edc | 2098 | X<savepvn> |
954c1994 | 2099 | |
641d4181 JH |
2100 | Perl's version of what C<strndup()> would be if it existed. Returns a |
2101 | pointer to a newly allocated string which is a duplicate of the first | |
2102 | C<len> bytes from C<pv>. The memory allocated for the new string can be | |
2103 | freed with the C<Safefree()> function. | |
954c1994 | 2104 | |
641d4181 | 2105 | char* savepvn(const char* pv, I32 len) |
954c1994 | 2106 | |
497711e7 | 2107 | =for hackers |
94bdecf9 | 2108 | Found in file util.c |
497711e7 | 2109 | |
a4f1a029 | 2110 | =item savesharedpv |
d8c40edc | 2111 | X<savesharedpv> |
a4f1a029 | 2112 | |
641d4181 JH |
2113 | A version of C<savepv()> which allocates the duplicate string in memory |
2114 | which is shared between threads. | |
a4f1a029 | 2115 | |
641d4181 | 2116 | char* savesharedpv(const char* pv) |
a4f1a029 NIS |
2117 | |
2118 | =for hackers | |
2119 | Found in file util.c | |
2120 | ||
766f8916 | 2121 | =item savesvpv |
d8c40edc | 2122 | X<savesvpv> |
766f8916 | 2123 | |
9c2fe30c | 2124 | A version of C<savepv()>/C<savepvn()> which gets the string to duplicate from |
766f8916 MHM |
2125 | the passed in SV using C<SvPV()> |
2126 | ||
2127 | char* savesvpv(SV* sv) | |
2128 | ||
2129 | =for hackers | |
2130 | Found in file util.c | |
2131 | ||
94bdecf9 | 2132 | =item StructCopy |
d8c40edc | 2133 | X<StructCopy> |
954c1994 | 2134 | |
94bdecf9 | 2135 | This is an architecture-independent macro to copy one structure to another. |
954c1994 | 2136 | |
94bdecf9 | 2137 | void StructCopy(type src, type dest, type) |
954c1994 | 2138 | |
497711e7 | 2139 | =for hackers |
94bdecf9 | 2140 | Found in file handy.h |
497711e7 | 2141 | |
94bdecf9 | 2142 | =item Zero |
d8c40edc | 2143 | X<Zero> |
954c1994 | 2144 | |
94bdecf9 JH |
2145 | The XSUB-writer's interface to the C C<memzero> function. The C<dest> is the |
2146 | destination, C<nitems> is the number of items, and C<type> is the type. | |
954c1994 | 2147 | |
94bdecf9 | 2148 | void Zero(void* dest, int nitems, type) |
954c1994 | 2149 | |
497711e7 | 2150 | =for hackers |
94bdecf9 | 2151 | Found in file handy.h |
497711e7 | 2152 | |
e90e2364 | 2153 | =item ZeroD |
d8c40edc | 2154 | X<ZeroD> |
e90e2364 NC |
2155 | |
2156 | Like C<Zero> but returns dest. Useful for encouraging compilers to tail-call | |
2157 | optimise. | |
2158 | ||
2159 | void * ZeroD(void* dest, int nitems, type) | |
2160 | ||
2161 | =for hackers | |
2162 | Found in file handy.h | |
2163 | ||
954c1994 | 2164 | |
94bdecf9 | 2165 | =back |
954c1994 | 2166 | |
94bdecf9 | 2167 | =head1 Miscellaneous Functions |
954c1994 | 2168 | |
94bdecf9 | 2169 | =over 8 |
497711e7 | 2170 | |
94bdecf9 | 2171 | =item fbm_compile |
d8c40edc | 2172 | X<fbm_compile> |
8b4ac5a4 | 2173 | |
94bdecf9 JH |
2174 | Analyses the string in order to make fast searches on it using fbm_instr() |
2175 | -- the Boyer-Moore algorithm. | |
8b4ac5a4 | 2176 | |
94bdecf9 | 2177 | void fbm_compile(SV* sv, U32 flags) |
8b4ac5a4 JH |
2178 | |
2179 | =for hackers | |
94bdecf9 | 2180 | Found in file util.c |
8b4ac5a4 | 2181 | |
94bdecf9 | 2182 | =item fbm_instr |
d8c40edc | 2183 | X<fbm_instr> |
954c1994 | 2184 | |
94bdecf9 | 2185 | Returns the location of the SV in the string delimited by C<str> and |
bd61b366 | 2186 | C<strend>. It returns C<NULL> if the string can't be found. The C<sv> |
94bdecf9 JH |
2187 | does not have to be fbm_compiled, but the search will not be as fast |
2188 | then. | |
954c1994 | 2189 | |
94bdecf9 | 2190 | char* fbm_instr(unsigned char* big, unsigned char* bigend, SV* littlesv, U32 flags) |
954c1994 | 2191 | |
497711e7 | 2192 | =for hackers |
94bdecf9 | 2193 | Found in file util.c |
497711e7 | 2194 | |
94bdecf9 | 2195 | =item form |
d8c40edc | 2196 | X<form> |
954c1994 | 2197 | |
94bdecf9 JH |
2198 | Takes a sprintf-style format pattern and conventional |
2199 | (non-SV) arguments and returns the formatted string. | |
954c1994 | 2200 | |
94bdecf9 | 2201 | (char *) Perl_form(pTHX_ const char* pat, ...) |
954c1994 | 2202 | |
94bdecf9 | 2203 | can be used any place a string (char *) is required: |
497711e7 | 2204 | |
94bdecf9 | 2205 | char * s = Perl_form("%d.%d",major,minor); |
954c1994 | 2206 | |
94bdecf9 JH |
2207 | Uses a single private buffer so if you want to format several strings you |
2208 | must explicitly copy the earlier strings away (and free the copies when you | |
2209 | are done). | |
954c1994 | 2210 | |
94bdecf9 | 2211 | char* form(const char* pat, ...) |
954c1994 | 2212 | |
497711e7 | 2213 | =for hackers |
94bdecf9 | 2214 | Found in file util.c |
497711e7 | 2215 | |
94bdecf9 | 2216 | =item getcwd_sv |
d8c40edc | 2217 | X<getcwd_sv> |
954c1994 | 2218 | |
94bdecf9 | 2219 | Fill the sv with current working directory |
954c1994 | 2220 | |
94bdecf9 | 2221 | int getcwd_sv(SV* sv) |
954c1994 | 2222 | |
497711e7 | 2223 | =for hackers |
94bdecf9 | 2224 | Found in file util.c |
497711e7 | 2225 | |
9244d4ad RGS |
2226 | =item my_sprintf |
2227 | X<my_sprintf> | |
2228 | ||
2229 | The C library C<sprintf>, wrapped if necessary, to ensure that it will return | |
2230 | the length of the string written to the buffer. Only rare pre-ANSI systems | |
2231 | need the wrapper function - usually this is a direct call to C<sprintf>. | |
2232 | ||
2233 | int my_sprintf(char *buffer, const char *pat, ...) | |
2234 | ||
2235 | =for hackers | |
2236 | Found in file util.c | |
2237 | ||
f333445c | 2238 | =item new_version |
d8c40edc | 2239 | X<new_version> |
f333445c JP |
2240 | |
2241 | Returns a new version object based on the passed in SV: | |
2242 | ||
2243 | SV *sv = new_version(SV *ver); | |
2244 | ||
2245 | Does not alter the passed in ver SV. See "upg_version" if you | |
2246 | want to upgrade the SV. | |
2247 | ||
2248 | SV* new_version(SV *ver) | |
2249 | ||
2250 | =for hackers | |
2251 | Found in file util.c | |
2252 | ||
2253 | =item scan_version | |
d8c40edc | 2254 | X<scan_version> |
f333445c JP |
2255 | |
2256 | Returns a pointer to the next character after the parsed | |
2257 | version string, as well as upgrading the passed in SV to | |
2258 | an RV. | |
2259 | ||
2260 | Function must be called with an already existing SV like | |
2261 | ||
137d6fc0 JP |
2262 | sv = newSV(0); |
2263 | s = scan_version(s,SV *sv, bool qv); | |
f333445c JP |
2264 | |
2265 | Performs some preprocessing to the string to ensure that | |
2266 | it has the correct characteristics of a version. Flags the | |
2267 | object if it contains an underscore (which denotes this | |
137d6fc0 JP |
2268 | is a alpha version). The boolean qv denotes that the version |
2269 | should be interpreted as if it had multiple decimals, even if | |
2270 | it doesn't. | |
f333445c | 2271 | |
9137345a | 2272 | const char* scan_version(const char *vstr, SV *sv, bool qv) |
f333445c JP |
2273 | |
2274 | =for hackers | |
2275 | Found in file util.c | |
2276 | ||
94bdecf9 | 2277 | =item strEQ |
d8c40edc | 2278 | X<strEQ> |
954c1994 | 2279 | |
94bdecf9 | 2280 | Test two strings to see if they are equal. Returns true or false. |
954c1994 | 2281 | |
94bdecf9 | 2282 | bool strEQ(char* s1, char* s2) |
954c1994 | 2283 | |
497711e7 | 2284 | =for hackers |
94bdecf9 | 2285 | Found in file handy.h |
497711e7 | 2286 | |
94bdecf9 | 2287 | =item strGE |
d8c40edc | 2288 | X<strGE> |
1c846c1f | 2289 | |
94bdecf9 JH |
2290 | Test two strings to see if the first, C<s1>, is greater than or equal to |
2291 | the second, C<s2>. Returns true or false. | |
1c846c1f | 2292 | |
94bdecf9 | 2293 | bool strGE(char* s1, char* s2) |
1c846c1f NIS |
2294 | |
2295 | =for hackers | |
94bdecf9 | 2296 | Found in file handy.h |
1c846c1f | 2297 | |
94bdecf9 | 2298 | =item strGT |
d8c40edc | 2299 | X<strGT> |
954c1994 | 2300 | |
94bdecf9 JH |
2301 | Test two strings to see if the first, C<s1>, is greater than the second, |
2302 | C<s2>. Returns true or false. | |
954c1994 | 2303 | |
94bdecf9 | 2304 | bool strGT(char* s1, char* s2) |
954c1994 | 2305 | |
497711e7 | 2306 | =for hackers |
94bdecf9 | 2307 | Found in file handy.h |
497711e7 | 2308 | |
94bdecf9 | 2309 | =item strLE |
d8c40edc | 2310 | X<strLE> |
954c1994 | 2311 | |
94bdecf9 JH |
2312 | Test two strings to see if the first, C<s1>, is less than or equal to the |
2313 | second, C<s2>. Returns true or false. | |
954c1994 | 2314 | |
94bdecf9 | 2315 | bool strLE(char* s1, char* s2) |
954c1994 | 2316 | |
497711e7 | 2317 | =for hackers |
94bdecf9 | 2318 | Found in file handy.h |
497711e7 | 2319 | |
94bdecf9 | 2320 | =item strLT |
d8c40edc | 2321 | X<strLT> |
1a3327fb | 2322 | |
94bdecf9 JH |
2323 | Test two strings to see if the first, C<s1>, is less than the second, |
2324 | C<s2>. Returns true or false. | |
1a3327fb | 2325 | |
94bdecf9 | 2326 | bool strLT(char* s1, char* s2) |
1a3327fb | 2327 | |
497711e7 | 2328 | =for hackers |
94bdecf9 | 2329 | Found in file handy.h |
497711e7 | 2330 | |
94bdecf9 | 2331 | =item strNE |
d8c40edc | 2332 | X<strNE> |
954c1994 | 2333 | |
94bdecf9 JH |
2334 | Test two strings to see if they are different. Returns true or |
2335 | false. | |
2336 | ||
2337 | bool strNE(char* s1, char* s2) | |
954c1994 | 2338 | |
497711e7 | 2339 | =for hackers |
94bdecf9 | 2340 | Found in file handy.h |
497711e7 | 2341 | |
94bdecf9 | 2342 | =item strnEQ |
d8c40edc | 2343 | X<strnEQ> |
954c1994 | 2344 | |
94bdecf9 JH |
2345 | Test two strings to see if they are equal. The C<len> parameter indicates |
2346 | the number of bytes to compare. Returns true or false. (A wrapper for | |
2347 | C<strncmp>). | |
2348 | ||
2349 | bool strnEQ(char* s1, char* s2, STRLEN len) | |
954c1994 | 2350 | |
497711e7 | 2351 | =for hackers |
94bdecf9 | 2352 | Found in file handy.h |
497711e7 | 2353 | |
94bdecf9 | 2354 | =item strnNE |
d8c40edc | 2355 | X<strnNE> |
954c1994 | 2356 | |
94bdecf9 JH |
2357 | Test two strings to see if they are different. The C<len> parameter |
2358 | indicates the number of bytes to compare. Returns true or false. (A | |
2359 | wrapper for C<strncmp>). | |
954c1994 | 2360 | |
94bdecf9 | 2361 | bool strnNE(char* s1, char* s2, STRLEN len) |
954c1994 | 2362 | |
497711e7 GS |
2363 | =for hackers |
2364 | Found in file handy.h | |
2365 | ||
f333445c | 2366 | =item sv_nosharing |
d8c40edc | 2367 | X<sv_nosharing> |
f333445c JP |
2368 | |
2369 | Dummy routine which "shares" an SV when there is no sharing module present. | |
9244d4ad RGS |
2370 | Or "locks" it. Or "unlocks" it. In other words, ignores its single SV argument. |
2371 | Exists to avoid test for a NULL function pointer and because it could | |
2372 | potentially warn under some level of strict-ness. | |
f333445c | 2373 | |
c48640ec | 2374 | void sv_nosharing(SV *sv) |
f333445c JP |
2375 | |
2376 | =for hackers | |
2377 | Found in file util.c | |
2378 | ||
f333445c | 2379 | =item upg_version |
d8c40edc | 2380 | X<upg_version> |
f333445c JP |
2381 | |
2382 | In-place upgrade of the supplied SV to a version object. | |
2383 | ||
2384 | SV *sv = upg_version(SV *sv); | |
2385 | ||
2386 | Returns a pointer to the upgraded SV. | |
2387 | ||
2388 | SV* upg_version(SV *ver) | |
2389 | ||
2390 | =for hackers | |
2391 | Found in file util.c | |
2392 | ||
2393 | =item vcmp | |
d8c40edc | 2394 | X<vcmp> |
f333445c JP |
2395 | |
2396 | Version object aware cmp. Both operands must already have been | |
2397 | converted into version objects. | |
2398 | ||
2399 | int vcmp(SV *lvs, SV *rvs) | |
2400 | ||
2401 | =for hackers | |
2402 | Found in file util.c | |
2403 | ||
b9381830 | 2404 | =item vnormal |
d8c40edc | 2405 | X<vnormal> |
b9381830 JP |
2406 | |
2407 | Accepts a version object and returns the normalized string | |
2408 | representation. Call like: | |
2409 | ||
2410 | sv = vnormal(rv); | |
2411 | ||
2412 | NOTE: you can pass either the object directly or the SV | |
2413 | contained within the RV. | |
2414 | ||
2415 | SV* vnormal(SV *vs) | |
2416 | ||
2417 | =for hackers | |
2418 | Found in file util.c | |
2419 | ||
f333445c | 2420 | =item vnumify |
d8c40edc | 2421 | X<vnumify> |
f333445c JP |
2422 | |
2423 | Accepts a version object and returns the normalized floating | |
2424 | point representation. Call like: | |
2425 | ||
2426 | sv = vnumify(rv); | |
2427 | ||
2428 | NOTE: you can pass either the object directly or the SV | |
2429 | contained within the RV. | |
2430 | ||
2431 | SV* vnumify(SV *vs) | |
2432 | ||
2433 | =for hackers | |
2434 | Found in file util.c | |
2435 | ||
2436 | =item vstringify | |
d8c40edc | 2437 | X<vstringify> |
f333445c | 2438 | |
b9381830 JP |
2439 | In order to maintain maximum compatibility with earlier versions |
2440 | of Perl, this function will return either the floating point | |
2441 | notation or the multiple dotted notation, depending on whether | |
2442 | the original version contained 1 or more dots, respectively | |
f333445c JP |
2443 | |
2444 | SV* vstringify(SV *vs) | |
2445 | ||
2446 | =for hackers | |
2447 | Found in file util.c | |
2448 | ||
e0218a61 | 2449 | =item vverify |
d8c40edc | 2450 | X<vverify> |
e0218a61 JP |
2451 | |
2452 | Validates that the SV contains a valid version object. | |
2453 | ||
2454 | bool vverify(SV *vobj); | |
2455 | ||
2456 | Note that it only confirms the bare minimum structure (so as not to get | |
2457 | confused by derived classes which may contain additional hash entries): | |
2458 | ||
2459 | bool vverify(SV *vs) | |
2460 | ||
2461 | =for hackers | |
2462 | Found in file util.c | |
2463 | ||
f4758303 | 2464 | |
94bdecf9 | 2465 | =back |
7207e29d | 2466 | |
cd299c6e RGS |
2467 | =head1 Multicall Functions |
2468 | ||
2469 | =over 8 | |
2470 | ||
2471 | =item dMULTICALL | |
2472 | X<dMULTICALL> | |
2473 | ||
2474 | Declare local variables for a multicall. See L<perlcall/Lightweight Callbacks>. | |
2475 | ||
2476 | dMULTICALL; | |
2477 | ||
2478 | =for hackers | |
2479 | Found in file cop.h | |
2480 | ||
2481 | =item MULTICALL | |
2482 | X<MULTICALL> | |
2483 | ||
2484 | Make a lightweight callback. See L<perlcall/Lightweight Callbacks>. | |
2485 | ||
2486 | MULTICALL; | |
2487 | ||
2488 | =for hackers | |
2489 | Found in file cop.h | |
2490 | ||
2491 | =item POP_MULTICALL | |
2492 | X<POP_MULTICALL> | |
2493 | ||
2494 | Closing bracket for a lightweight callback. | |
2495 | See L<perlcall/Lightweight Callbacks>. | |
2496 | ||
2497 | POP_MULTICALL; | |
2498 | ||
2499 | =for hackers | |
2500 | Found in file cop.h | |
2501 | ||
2502 | =item PUSH_MULTICALL | |
2503 | X<PUSH_MULTICALL> | |
2504 | ||
2505 | Opening bracket for a lightweight callback. | |
2506 | See L<perlcall/Lightweight Callbacks>. | |
2507 | ||
2508 | PUSH_MULTICALL; | |
2509 | ||
2510 | =for hackers | |
2511 | Found in file cop.h | |
2512 | ||
2513 | ||
2514 | =back | |
2515 | ||
94bdecf9 | 2516 | =head1 Numeric functions |
7207e29d | 2517 | |
94bdecf9 | 2518 | =over 8 |
f4758303 | 2519 | |
94bdecf9 | 2520 | =item grok_bin |
d8c40edc | 2521 | X<grok_bin> |
f4758303 | 2522 | |
94bdecf9 JH |
2523 | converts a string representing a binary number to numeric form. |
2524 | ||
2525 | On entry I<start> and I<*len> give the string to scan, I<*flags> gives | |
2526 | conversion flags, and I<result> should be NULL or a pointer to an NV. | |
2527 | The scan stops at the end of the string, or the first invalid character. | |
7b667b5f MHM |
2528 | Unless C<PERL_SCAN_SILENT_ILLDIGIT> is set in I<*flags>, encountering an |
2529 | invalid character will also trigger a warning. | |
2530 | On return I<*len> is set to the length of the scanned string, | |
2531 | and I<*flags> gives output flags. | |
94bdecf9 | 2532 | |
7fc63493 | 2533 | If the value is <= C<UV_MAX> it is returned as a UV, the output flags are clear, |
94bdecf9 JH |
2534 | and nothing is written to I<*result>. If the value is > UV_MAX C<grok_bin> |
2535 | returns UV_MAX, sets C<PERL_SCAN_GREATER_THAN_UV_MAX> in the output flags, | |
2536 | and writes the value to I<*result> (or the value is discarded if I<result> | |
2537 | is NULL). | |
2538 | ||
7b667b5f | 2539 | The binary number may optionally be prefixed with "0b" or "b" unless |
94bdecf9 JH |
2540 | C<PERL_SCAN_DISALLOW_PREFIX> is set in I<*flags> on entry. If |
2541 | C<PERL_SCAN_ALLOW_UNDERSCORES> is set in I<*flags> then the binary | |
2542 | number may use '_' characters to separate digits. | |
2543 | ||
a3b680e6 | 2544 | UV grok_bin(const char* start, STRLEN* len_p, I32* flags, NV *result) |
f4758303 JP |
2545 | |
2546 | =for hackers | |
94bdecf9 | 2547 | Found in file numeric.c |
f4758303 | 2548 | |
94bdecf9 | 2549 | =item grok_hex |
d8c40edc | 2550 | X<grok_hex> |
954c1994 | 2551 | |
94bdecf9 JH |
2552 | converts a string representing a hex number to numeric form. |
2553 | ||
2554 | On entry I<start> and I<*len> give the string to scan, I<*flags> gives | |
2555 | conversion flags, and I<result> should be NULL or a pointer to an NV. | |
7b667b5f MHM |
2556 | The scan stops at the end of the string, or the first invalid character. |
2557 | Unless C<PERL_SCAN_SILENT_ILLDIGIT> is set in I<*flags>, encountering an | |
2558 | invalid character will also trigger a warning. | |
2559 | On return I<*len> is set to the length of the scanned string, | |
2560 | and I<*flags> gives output flags. | |
94bdecf9 JH |
2561 | |
2562 | If the value is <= UV_MAX it is returned as a UV, the output flags are clear, | |
2563 | and nothing is written to I<*result>. If the value is > UV_MAX C<grok_hex> | |
2564 | returns UV_MAX, sets C<PERL_SCAN_GREATER_THAN_UV_MAX> in the output flags, | |
2565 | and writes the value to I<*result> (or the value is discarded if I<result> | |
2566 | is NULL). | |
2567 | ||
2568 | The hex number may optionally be prefixed with "0x" or "x" unless | |
2569 | C<PERL_SCAN_DISALLOW_PREFIX> is set in I<*flags> on entry. If | |
2570 | C<PERL_SCAN_ALLOW_UNDERSCORES> is set in I<*flags> then the hex | |
2571 | number may use '_' characters to separate digits. | |
2572 | ||
a3b680e6 | 2573 | UV grok_hex(const char* start, STRLEN* len_p, I32* flags, NV *result) |
954c1994 | 2574 | |
497711e7 | 2575 | =for hackers |
94bdecf9 | 2576 | Found in file numeric.c |
497711e7 | 2577 | |
94bdecf9 | 2578 | =item grok_number |
d8c40edc | 2579 | X<grok_number> |
954c1994 | 2580 | |
94bdecf9 JH |
2581 | Recognise (or not) a number. The type of the number is returned |
2582 | (0 if unrecognised), otherwise it is a bit-ORed combination of | |
2583 | IS_NUMBER_IN_UV, IS_NUMBER_GREATER_THAN_UV_MAX, IS_NUMBER_NOT_INT, | |
2584 | IS_NUMBER_NEG, IS_NUMBER_INFINITY, IS_NUMBER_NAN (defined in perl.h). | |
2585 | ||
2586 | If the value of the number can fit an in UV, it is returned in the *valuep | |
2587 | IS_NUMBER_IN_UV will be set to indicate that *valuep is valid, IS_NUMBER_IN_UV | |
2588 | will never be set unless *valuep is valid, but *valuep may have been assigned | |
2589 | to during processing even though IS_NUMBER_IN_UV is not set on return. | |
2590 | If valuep is NULL, IS_NUMBER_IN_UV will be set for the same cases as when | |
2591 | valuep is non-NULL, but no actual assignment (or SEGV) will occur. | |
2592 | ||
2593 | IS_NUMBER_NOT_INT will be set with IS_NUMBER_IN_UV if trailing decimals were | |
2594 | seen (in which case *valuep gives the true value truncated to an integer), and | |
2595 | IS_NUMBER_NEG if the number is negative (in which case *valuep holds the | |
2596 | absolute value). IS_NUMBER_IN_UV is not set if e notation was used or the | |
2597 | number is larger than a UV. | |
2598 | ||
2599 | int grok_number(const char *pv, STRLEN len, UV *valuep) | |
954c1994 | 2600 | |
497711e7 | 2601 | =for hackers |
94bdecf9 | 2602 | Found in file numeric.c |
497711e7 | 2603 | |
94bdecf9 | 2604 | =item grok_numeric_radix |
d8c40edc | 2605 | X<grok_numeric_radix> |
954c1994 | 2606 | |
94bdecf9 JH |
2607 | Scan and skip for a numeric decimal separator (radix). |
2608 | ||
2609 | bool grok_numeric_radix(const char **sp, const char *send) | |
954c1994 | 2610 | |
497711e7 | 2611 | =for hackers |
94bdecf9 | 2612 | Found in file numeric.c |
497711e7 | 2613 | |
94bdecf9 | 2614 | =item grok_oct |
d8c40edc | 2615 | X<grok_oct> |
954c1994 | 2616 | |
7b667b5f MHM |
2617 | converts a string representing an octal number to numeric form. |
2618 | ||
2619 | On entry I<start> and I<*len> give the string to scan, I<*flags> gives | |
2620 | conversion flags, and I<result> should be NULL or a pointer to an NV. | |
2621 | The scan stops at the end of the string, or the first invalid character. | |
2622 | Unless C<PERL_SCAN_SILENT_ILLDIGIT> is set in I<*flags>, encountering an | |
2623 | invalid character will also trigger a warning. | |
2624 | On return I<*len> is set to the length of the scanned string, | |
2625 | and I<*flags> gives output flags. | |
2626 | ||
2627 | If the value is <= UV_MAX it is returned as a UV, the output flags are clear, | |
2628 | and nothing is written to I<*result>. If the value is > UV_MAX C<grok_oct> | |
2629 | returns UV_MAX, sets C<PERL_SCAN_GREATER_THAN_UV_MAX> in the output flags, | |
2630 | and writes the value to I<*result> (or the value is discarded if I<result> | |
2631 | is NULL). | |
2632 | ||
2633 | If C<PERL_SCAN_ALLOW_UNDERSCORES> is set in I<*flags> then the octal | |
2634 | number may use '_' characters to separate digits. | |
94bdecf9 | 2635 | |
a3b680e6 | 2636 | UV grok_oct(const char* start, STRLEN* len_p, I32* flags, NV *result) |
954c1994 | 2637 | |
497711e7 | 2638 | =for hackers |
94bdecf9 | 2639 | Found in file numeric.c |
497711e7 | 2640 | |
94bdecf9 | 2641 | =item scan_bin |
d8c40edc | 2642 | X<scan_bin> |
954c1994 | 2643 | |
94bdecf9 JH |
2644 | For backwards compatibility. Use C<grok_bin> instead. |
2645 | ||
73d840c0 | 2646 | NV scan_bin(const char* start, STRLEN len, STRLEN* retlen) |
954c1994 | 2647 | |
497711e7 | 2648 | =for hackers |
94bdecf9 | 2649 | Found in file numeric.c |
497711e7 | 2650 | |
94bdecf9 | 2651 | =item scan_hex |
d8c40edc | 2652 | X<scan_hex> |
954c1994 | 2653 | |
94bdecf9 JH |
2654 | For backwards compatibility. Use C<grok_hex> instead. |
2655 | ||
73d840c0 | 2656 | NV scan_hex(const char* start, STRLEN len, STRLEN* retlen) |
954c1994 | 2657 | |
497711e7 | 2658 | =for hackers |
94bdecf9 | 2659 | Found in file numeric.c |
497711e7 | 2660 | |
94bdecf9 | 2661 | =item scan_oct |
d8c40edc | 2662 | X<scan_oct> |
954c1994 | 2663 | |
94bdecf9 | 2664 | For backwards compatibility. Use C<grok_oct> instead. |
954c1994 | 2665 | |
73d840c0 | 2666 | NV scan_oct(const char* start, STRLEN len, STRLEN* retlen) |
954c1994 | 2667 | |
497711e7 | 2668 | =for hackers |
94bdecf9 | 2669 | Found in file numeric.c |
497711e7 | 2670 | |
645c22ef | 2671 | |
94bdecf9 | 2672 | =back |
645c22ef | 2673 | |
94bdecf9 JH |
2674 | =head1 Optree Manipulation Functions |
2675 | ||
2676 | =over 8 | |
2677 | ||
2678 | =item cv_const_sv | |
d8c40edc | 2679 | X<cv_const_sv> |
94bdecf9 JH |
2680 | |
2681 | If C<cv> is a constant sub eligible for inlining. returns the constant | |
2682 | value returned by the sub. Otherwise, returns NULL. | |
2683 | ||
2684 | Constant subs can be created with C<newCONSTSUB> or as described in | |
2685 | L<perlsub/"Constant Functions">. | |
2686 | ||
2687 | SV* cv_const_sv(CV* cv) | |
645c22ef DM |
2688 | |
2689 | =for hackers | |
94bdecf9 | 2690 | Found in file op.c |
645c22ef | 2691 | |
94bdecf9 | 2692 | =item newCONSTSUB |
d8c40edc | 2693 | X<newCONSTSUB> |
954c1994 | 2694 | |
94bdecf9 JH |
2695 | Creates a constant sub equivalent to Perl C<sub FOO () { 123 }> which is |
2696 | eligible for inlining at compile-time. | |
954c1994 | 2697 | |
e1ec3a88 | 2698 | CV* newCONSTSUB(HV* stash, const char* name, SV* sv) |
954c1994 | 2699 | |
497711e7 | 2700 | =for hackers |
94bdecf9 | 2701 | Found in file op.c |
497711e7 | 2702 | |
94bdecf9 | 2703 | =item newXS |
d8c40edc | 2704 | X<newXS> |
954c1994 | 2705 | |
94bdecf9 | 2706 | Used by C<xsubpp> to hook up XSUBs as Perl subs. |
954c1994 | 2707 | |
94bdecf9 JH |
2708 | =for hackers |
2709 | Found in file op.c | |
2710 | ||
2711 | ||
2712 | =back | |
2713 | ||
dd2155a4 DM |
2714 | =head1 Pad Data Structures |
2715 | ||
2716 | =over 8 | |
2717 | ||
2718 | =item pad_sv | |
d8c40edc | 2719 | X<pad_sv> |
dd2155a4 DM |
2720 | |
2721 | Get the value at offset po in the current pad. | |
2722 | Use macro PAD_SV instead of calling this function directly. | |
2723 | ||
2724 | SV* pad_sv(PADOFFSET po) | |
2725 | ||
2726 | =for hackers | |
2727 | Found in file pad.c | |
2728 | ||
2729 | ||
2730 | =back | |
2731 | ||
59887a99 MHM |
2732 | =head1 Simple Exception Handling Macros |
2733 | ||
2734 | =over 8 | |
2735 | ||
2736 | =item dXCPT | |
d8c40edc | 2737 | X<dXCPT> |
59887a99 | 2738 | |
2dfe1b17 | 2739 | Set up necessary local variables for exception handling. |
59887a99 MHM |
2740 | See L<perlguts/"Exception Handling">. |
2741 | ||
2742 | dXCPT; | |
2743 | ||
2744 | =for hackers | |
2745 | Found in file XSUB.h | |
2746 | ||
2747 | =item XCPT_CATCH | |
d8c40edc | 2748 | X<XCPT_CATCH> |
59887a99 MHM |
2749 | |
2750 | Introduces a catch block. See L<perlguts/"Exception Handling">. | |
2751 | ||
2752 | =for hackers | |
2753 | Found in file XSUB.h | |
2754 | ||
2755 | =item XCPT_RETHROW | |
d8c40edc | 2756 | X<XCPT_RETHROW> |
59887a99 MHM |
2757 | |
2758 | Rethrows a previously caught exception. See L<perlguts/"Exception Handling">. | |
2759 | ||
2760 | XCPT_RETHROW; | |
2761 | ||
2762 | =for hackers | |
2763 | Found in file XSUB.h | |
2764 | ||
2765 | =item XCPT_TRY_END | |
d8c40edc | 2766 | X<XCPT_TRY_END> |
59887a99 MHM |
2767 | |
2768 | Ends a try block. See L<perlguts/"Exception Handling">. | |
2769 | ||
2770 | =for hackers | |
2771 | Found in file XSUB.h | |
2772 | ||
2773 | =item XCPT_TRY_START | |
d8c40edc | 2774 | X<XCPT_TRY_START> |
59887a99 MHM |
2775 | |
2776 | Starts a try block. See L<perlguts/"Exception Handling">. | |
2777 | ||
2778 | =for hackers | |
2779 | Found in file XSUB.h | |
2780 | ||
2781 | ||
2782 | =back | |
2783 | ||
94bdecf9 JH |
2784 | =head1 Stack Manipulation Macros |
2785 | ||
2786 | =over 8 | |
2787 | ||
2788 | =item dMARK | |
d8c40edc | 2789 | X<dMARK> |
954c1994 | 2790 | |
94bdecf9 JH |
2791 | Declare a stack marker variable, C<mark>, for the XSUB. See C<MARK> and |
2792 | C<dORIGMARK>. | |
954c1994 | 2793 | |
94bdecf9 | 2794 | dMARK; |
954c1994 | 2795 | |
497711e7 | 2796 | =for hackers |
94bdecf9 | 2797 | Found in file pp.h |
497711e7 | 2798 | |
94bdecf9 | 2799 | =item dORIGMARK |
d8c40edc | 2800 | X<dORIGMARK> |
954c1994 | 2801 | |
94bdecf9 | 2802 | Saves the original stack mark for the XSUB. See C<ORIGMARK>. |
954c1994 | 2803 | |
94bdecf9 | 2804 | dORIGMARK; |
954c1994 | 2805 | |
497711e7 | 2806 | =for hackers |
94bdecf9 | 2807 | Found in file pp.h |
497711e7 | 2808 | |
94bdecf9 | 2809 | =item dSP |
d8c40edc | 2810 | X<dSP> |
954c1994 | 2811 | |
94bdecf9 JH |
2812 | Declares a local copy of perl's stack pointer for the XSUB, available via |
2813 | the C<SP> macro. See C<SP>. | |
954c1994 | 2814 | |
94bdecf9 | 2815 | dSP; |
954c1994 | 2816 | |
497711e7 | 2817 | =for hackers |
94bdecf9 | 2818 | Found in file pp.h |
497711e7 | 2819 | |
94bdecf9 | 2820 | =item EXTEND |
d8c40edc | 2821 | X<EXTEND> |
954c1994 | 2822 | |
94bdecf9 JH |
2823 | Used to extend the argument stack for an XSUB's return values. Once |
2824 | used, guarantees that there is room for at least C<nitems> to be pushed | |
2825 | onto the stack. | |
954c1994 | 2826 | |
94bdecf9 | 2827 | void EXTEND(SP, int nitems) |
954c1994 | 2828 | |
497711e7 | 2829 | =for hackers |
94bdecf9 | 2830 | Found in file pp.h |
954c1994 | 2831 | |
94bdecf9 | 2832 | =item MARK |
d8c40edc | 2833 | X<MARK> |
954c1994 | 2834 | |
94bdecf9 | 2835 | Stack marker variable for the XSUB. See C<dMARK>. |
954c1994 | 2836 | |
497711e7 | 2837 | =for hackers |
94bdecf9 | 2838 | Found in file pp.h |
954c1994 | 2839 | |
d82b684c | 2840 | =item mPUSHi |
d8c40edc | 2841 | X<mPUSHi> |
d82b684c SH |
2842 | |
2843 | Push an integer onto the stack. The stack must have room for this element. | |
de4f2208 RGS |
2844 | Handles 'set' magic. Does not use C<TARG>. See also C<PUSHi>, C<mXPUSHi> |
2845 | and C<XPUSHi>. | |
d82b684c SH |
2846 | |
2847 | void mPUSHi(IV iv) | |
2848 | ||
2849 | =for hackers | |
2850 | Found in file pp.h | |
2851 | ||
2852 | =item mPUSHn | |
d8c40edc | 2853 | X<mPUSHn> |
d82b684c SH |
2854 | |
2855 | Push a double onto the stack. The stack must have room for this element. | |
de4f2208 RGS |
2856 | Handles 'set' magic. Does not use C<TARG>. See also C<PUSHn>, C<mXPUSHn> |
2857 | and C<XPUSHn>. | |
d82b684c SH |
2858 | |
2859 | void mPUSHn(NV nv) | |
2860 | ||
2861 | =for hackers | |
2862 | Found in file pp.h | |
2863 | ||
2864 | =item mPUSHp | |
d8c40edc | 2865 | X<mPUSHp> |
d82b684c SH |
2866 | |
2867 | Push a string onto the stack. The stack must have room for this element. | |
de4f2208 RGS |
2868 | The C<len> indicates the length of the string. Handles 'set' magic. Does |
2869 | not use C<TARG>. See also C<PUSHp>, C<mXPUSHp> and C<XPUSHp>. | |
d82b684c SH |
2870 | |
2871 | void mPUSHp(char* str, STRLEN len) | |
2872 | ||
2873 | =for hackers | |
2874 | Found in file pp.h | |
2875 | ||
2876 | =item mPUSHu | |
d8c40edc | 2877 | X<mPUSHu> |
d82b684c SH |
2878 | |
2879 | Push an unsigned integer onto the stack. The stack must have room for this | |
de4f2208 RGS |
2880 | element. Handles 'set' magic. Does not use C<TARG>. See also C<PUSHu>, |
2881 | C<mXPUSHu> and C<XPUSHu>. | |
d82b684c SH |
2882 | |
2883 | void mPUSHu(UV uv) | |
2884 | ||
2885 | =for hackers | |
2886 | Found in file pp.h | |
2887 | ||
2888 | =item mXPUSHi | |
d8c40edc | 2889 | X<mXPUSHi> |
d82b684c | 2890 | |
de4f2208 RGS |
2891 | Push an integer onto the stack, extending the stack if necessary. Handles |
2892 | 'set' magic. Does not use C<TARG>. See also C<XPUSHi>, C<mPUSHi> and | |
2893 | C<PUSHi>. | |
d82b684c SH |
2894 | |
2895 | void mXPUSHi(IV iv) | |
2896 | ||
2897 | =for hackers | |
2898 | Found in file pp.h | |
2899 | ||
2900 | =item mXPUSHn | |
d8c40edc | 2901 | X<mXPUSHn> |
d82b684c | 2902 | |
de4f2208 RGS |
2903 | Push a double onto the stack, extending the stack if necessary. Handles |
2904 | 'set' magic. Does not use C<TARG>. See also C<XPUSHn>, C<mPUSHn> and | |
2905 | C<PUSHn>. | |
d82b684c SH |
2906 | |
2907 | void mXPUSHn(NV nv) | |
2908 | ||
2909 | =for hackers | |
2910 | Found in file pp.h | |
2911 | ||
2912 | =item mXPUSHp | |
d8c40edc | 2913 | X<mXPUSHp> |
d82b684c SH |
2914 | |
2915 | Push a string onto the stack, extending the stack if necessary. The C<len> | |
de4f2208 RGS |
2916 | indicates the length of the string. Handles 'set' magic. Does not use |
2917 | C<TARG>. See also C<XPUSHp>, C<mPUSHp> and C<PUSHp>. | |
d82b684c SH |
2918 | |
2919 | void mXPUSHp(char* str, STRLEN len) | |
2920 | ||
2921 | =for hackers | |
2922 | Found in file pp.h | |
2923 | ||
2924 | =item mXPUSHu | |
d8c40edc | 2925 | X<mXPUSHu> |
d82b684c SH |
2926 | |
2927 | Push an unsigned integer onto the stack, extending the stack if necessary. | |
de4f2208 RGS |
2928 | Handles 'set' magic. Does not use C<TARG>. See also C<XPUSHu>, C<mPUSHu> |
2929 | and C<PUSHu>. | |
d82b684c SH |
2930 | |
2931 | void mXPUSHu(UV uv) | |
2932 | ||
2933 | =for hackers | |
2934 | Found in file pp.h | |
2935 | ||
94bdecf9 | 2936 | =item ORIGMARK |
d8c40edc | 2937 | X<ORIGMARK> |
954c1994 | 2938 | |
94bdecf9 | 2939 | The original stack mark for the XSUB. See C<dORIGMARK>. |
954c1994 | 2940 | |
497711e7 | 2941 | =for hackers |
94bdecf9 | 2942 | Found in file pp.h |
497711e7 | 2943 | |
954c1994 | 2944 | =item POPi |
d8c40edc | 2945 | X<POPi> |
954c1994 GS |
2946 | |
2947 | Pops an integer off the stack. | |
2948 | ||
2949 | IV POPi | |
2950 | ||
497711e7 GS |
2951 | =for hackers |
2952 | Found in file pp.h | |
2953 | ||
954c1994 | 2954 | =item POPl |
d8c40edc | 2955 | X<POPl> |
954c1994 GS |
2956 | |
2957 | Pops a long off the stack. | |
2958 | ||
2959 | long POPl | |
2960 | ||
497711e7 GS |
2961 | =for hackers |
2962 | Found in file pp.h | |
2963 | ||
954c1994 | 2964 | =item POPn |
d8c40edc | 2965 | X<POPn> |
954c1994 GS |
2966 | |
2967 | Pops a double off the stack. | |
2968 | ||
2969 | NV POPn | |
2970 | ||
497711e7 GS |
2971 | =for hackers |
2972 | Found in file pp.h | |
2973 | ||
954c1994 | 2974 | =item POPp |
d8c40edc | 2975 | X<POPp> |
954c1994 | 2976 | |
184499a4 | 2977 | Pops a string off the stack. Deprecated. New code should use POPpx. |
954c1994 GS |
2978 | |
2979 | char* POPp | |
2980 | ||
497711e7 GS |
2981 | =for hackers |
2982 | Found in file pp.h | |
2983 | ||
fa519979 | 2984 | =item POPpbytex |
d8c40edc | 2985 | X<POPpbytex> |
fa519979 JH |
2986 | |
2987 | Pops a string off the stack which must consist of bytes i.e. characters < 256. | |
fa519979 JH |
2988 | |
2989 | char* POPpbytex | |
2990 | ||
2991 | =for hackers | |
2992 | Found in file pp.h | |
2993 | ||
2994 | =item POPpx | |
d8c40edc | 2995 | X<POPpx> |
fa519979 JH |
2996 | |
2997 | Pops a string off the stack. | |
fa519979 JH |
2998 | |
2999 | char* POPpx | |
3000 | ||
3001 | =for hackers | |
3002 | Found in file pp.h | |
3003 | ||
954c1994 | 3004 | =item POPs |
d8c40edc | 3005 | X<POPs> |
954c1994 GS |
3006 | |
3007 | Pops an SV off the stack. | |
3008 | ||
3009 | SV* POPs | |
3010 | ||
497711e7 GS |
3011 | =for hackers |
3012 | Found in file pp.h | |
3013 | ||
954c1994 | 3014 | =item PUSHi |
d8c40edc | 3015 | X<PUSHi> |
954c1994 GS |
3016 | |
3017 | Push an integer onto the stack. The stack must have room for this element. | |
d82b684c SH |
3018 | Handles 'set' magic. Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be |
3019 | called to declare it. Do not call multiple C<TARG>-oriented macros to | |
3020 | return lists from XSUB's - see C<mPUSHi> instead. See also C<XPUSHi> and | |
3021 | C<mXPUSHi>. | |
954c1994 GS |
3022 | |
3023 | void PUSHi(IV iv) | |
3024 | ||
497711e7 GS |
3025 | =for hackers |
3026 | Found in file pp.h | |
3027 | ||
954c1994 | 3028 | =item PUSHMARK |
d8c40edc | 3029 | X<PUSHMARK> |
954c1994 GS |
3030 | |
3031 | Opening bracket for arguments on a callback. See C<PUTBACK> and | |
3032 | L<perlcall>. | |
3033 | ||
c578083c | 3034 | void PUSHMARK(SP) |
954c1994 | 3035 | |
497711e7 GS |
3036 | =for hackers |
3037 | Found in file pp.h | |
3038 | ||
d82b684c | 3039 | =item PUSHmortal |
d8c40edc | 3040 | X<PUSHmortal> |
d82b684c SH |
3041 | |
3042 | Push a new mortal SV onto the stack. The stack must have room for this | |
3043 | element. Does not handle 'set' magic. Does not use C<TARG>. See also | |
3044 | C<PUSHs>, C<XPUSHmortal> and C<XPUSHs>. | |
3045 | ||
3046 | void PUSHmortal() | |
3047 | ||
3048 | =for hackers | |
3049 | Found in file pp.h | |
3050 | ||
954c1994 | 3051 | =item PUSHn |
d8c40edc | 3052 | X<PUSHn> |
954c1994 GS |
3053 | |
3054 | Push a double onto the stack. The stack must have room for this element. | |
d82b684c SH |
3055 | Handles 'set' magic. Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be |
3056 | called to declare it. Do not call multiple C<TARG>-oriented macros to | |
3057 | return lists from XSUB's - see C<mPUSHn> instead. See also C<XPUSHn> and | |
3058 | C<mXPUSHn>. | |
954c1994 GS |
3059 | |
3060 | void PUSHn(NV nv) | |
3061 | ||
497711e7 GS |
3062 | =for hackers |
3063 | Found in file pp.h | |
3064 | ||
954c1994 | 3065 | =item PUSHp |
d8c40edc | 3066 | X<PUSHp> |
954c1994 GS |
3067 | |
3068 | Push a string onto the stack. The stack must have room for this element. | |
d82b684c SH |
3069 | The C<len> indicates the length of the string. Handles 'set' magic. Uses |
3070 | C<TARG>, so C<dTARGET> or C<dXSTARG> should be called to declare it. Do not | |
3071 | call multiple C<TARG>-oriented macros to return lists from XSUB's - see | |
3072 | C<mPUSHp> instead. See also C<XPUSHp> and C<mXPUSHp>. | |
954c1994 GS |
3073 | |
3074 | void PUSHp(char* str, STRLEN len) | |
3075 | ||
497711e7 GS |
3076 | =for hackers |
3077 | Found in file pp.h | |
3078 | ||
954c1994 | 3079 | =item PUSHs |
d8c40edc | 3080 | X<PUSHs> |
954c1994 | 3081 | |
1c846c1f | 3082 | Push an SV onto the stack. The stack must have room for this element. |
d82b684c SH |
3083 | Does not handle 'set' magic. Does not use C<TARG>. See also C<PUSHmortal>, |
3084 | C<XPUSHs> and C<XPUSHmortal>. | |
954c1994 GS |
3085 | |
3086 | void PUSHs(SV* sv) | |
3087 | ||
497711e7 GS |
3088 | =for hackers |
3089 | Found in file pp.h | |
3090 | ||
954c1994 | 3091 | =item PUSHu |
d8c40edc | 3092 | X<PUSHu> |
954c1994 GS |
3093 | |
3094 | Push an unsigned integer onto the stack. The stack must have room for this | |
d82b684c SH |
3095 | element. Handles 'set' magic. Uses C<TARG>, so C<dTARGET> or C<dXSTARG> |
3096 | should be called to declare it. Do not call multiple C<TARG>-oriented | |
3097 | macros to return lists from XSUB's - see C<mPUSHu> instead. See also | |
3098 | C<XPUSHu> and C<mXPUSHu>. | |
954c1994 GS |
3099 | |
3100 | void PUSHu(UV uv) | |
3101 | ||
497711e7 GS |
3102 | =for hackers |
3103 | Found in file pp.h | |
3104 | ||
954c1994 | 3105 | =item PUTBACK |
d8c40edc | 3106 | X<PUTBACK> |
954c1994 GS |
3107 | |
3108 | Closing bracket for XSUB arguments. This is usually handled by C<xsubpp>. | |
3109 | See C<PUSHMARK> and L<perlcall> for other uses. | |
3110 | ||
3111 | PUTBACK; | |
3112 | ||
497711e7 GS |
3113 | =for hackers |
3114 | Found in file pp.h | |
3115 | ||
94bdecf9 | 3116 | =item SP |
d8c40edc | 3117 | X<SP> |
d2cc3551 | 3118 | |
94bdecf9 JH |
3119 | Stack pointer. This is usually handled by C<xsubpp>. See C<dSP> and |
3120 | C<SPAGAIN>. | |
d2cc3551 | 3121 | |
94bdecf9 JH |
3122 | =for hackers |
3123 | Found in file pp.h | |
3124 | ||
3125 | =item SPAGAIN | |
d8c40edc | 3126 | X<SPAGAIN> |
94bdecf9 JH |
3127 | |
3128 | Refetch the stack pointer. Used after a callback. See L<perlcall>. | |
3129 | ||
3130 | SPAGAIN; | |
d2cc3551 JH |
3131 | |
3132 | =for hackers | |
94bdecf9 | 3133 | Found in file pp.h |
d2cc3551 | 3134 | |
94bdecf9 | 3135 | =item XPUSHi |
d8c40edc | 3136 | X<XPUSHi> |
954c1994 | 3137 | |
94bdecf9 | 3138 | Push an integer onto the stack, extending the stack if necessary. Handles |
d82b684c SH |
3139 | 'set' magic. Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be called to |
3140 | declare it. Do not call multiple C<TARG>-oriented macros to return lists | |
3141 | from XSUB's - see C<mXPUSHi> instead. See also C<PUSHi> and C<mPUSHi>. | |
954c1994 | 3142 | |
94bdecf9 | 3143 | void XPUSHi(IV iv) |
954c1994 | 3144 | |
497711e7 | 3145 | =for hackers |
94bdecf9 | 3146 | Found in file pp.h |
497711e7 | 3147 | |
d82b684c | 3148 | =item XPUSHmortal |
d8c40edc | 3149 | X<XPUSHmortal> |
d82b684c SH |
3150 | |
3151 | Push a new mortal SV onto the stack, extending the stack if necessary. Does | |
3152 | not handle 'set' magic. Does not use C<TARG>. See also C<XPUSHs>, | |
3153 | C<PUSHmortal> and C<PUSHs>. | |
3154 | ||
3155 | void XPUSHmortal() | |
3156 | ||
3157 | =for hackers | |
3158 | Found in file pp.h | |
3159 | ||
94bdecf9 | 3160 | =item XPUSHn |
d8c40edc | 3161 | X<XPUSHn> |
954c1994 | 3162 | |
94bdecf9 | 3163 | Push a double onto the stack, extending the stack if necessary. Handles |
d82b684c SH |
3164 | 'set' magic. Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be called to |
3165 | declare it. Do not call multiple C<TARG>-oriented macros to return lists | |
3166 | from XSUB's - see C<mXPUSHn> instead. See also C<PUSHn> and C<mPUSHn>. | |
954c1994 | 3167 | |
94bdecf9 | 3168 | void XPUSHn(NV nv) |
954c1994 | 3169 | |
497711e7 | 3170 | =for hackers |
94bdecf9 | 3171 | Found in file pp.h |
497711e7 | 3172 | |
94bdecf9 | 3173 | =item XPUSHp |
d8c40edc | 3174 | X<XPUSHp> |
954c1994 | 3175 | |
94bdecf9 | 3176 | Push a string onto the stack, extending the stack if necessary. The C<len> |
d82b684c SH |
3177 | indicates the length of the string. Handles 'set' magic. Uses C<TARG>, so |
3178 | C<dTARGET> or C<dXSTARG> should be called to declare it. Do not call | |
3179 | multiple C<TARG>-oriented macros to return lists from XSUB's - see | |
3180 | C<mXPUSHp> instead. See also C<PUSHp> and C<mPUSHp>. | |
954c1994 | 3181 | |
94bdecf9 | 3182 | void XPUSHp(char* str, STRLEN len) |
954c1994 | 3183 | |
94bdecf9 JH |
3184 | =for hackers |
3185 | Found in file pp.h | |
3186 | ||
3187 | =item XPUSHs | |
d8c40edc | 3188 | X<XPUSHs> |
94bdecf9 JH |
3189 | |
3190 | Push an SV onto the stack, extending the stack if necessary. Does not | |
d82b684c SH |
3191 | handle 'set' magic. Does not use C<TARG>. See also C<XPUSHmortal>, |
3192 | C<PUSHs> and C<PUSHmortal>. | |
94bdecf9 JH |
3193 | |
3194 | void XPUSHs(SV* sv) | |
954c1994 | 3195 | |
497711e7 | 3196 | =for hackers |
94bdecf9 | 3197 | Found in file pp.h |
497711e7 | 3198 | |
94bdecf9 | 3199 | =item XPUSHu |
d8c40edc | 3200 | X<XPUSHu> |
954c1994 | 3201 | |
94bdecf9 | 3202 | Push an unsigned integer onto the stack, extending the stack if necessary. |
d82b684c SH |
3203 | Handles 'set' magic. Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be |
3204 | called to declare it. Do not call multiple C<TARG>-oriented macros to | |
3205 | return lists from XSUB's - see C<mXPUSHu> instead. See also C<PUSHu> and | |
3206 | C<mPUSHu>. | |
954c1994 | 3207 | |
94bdecf9 JH |
3208 | void XPUSHu(UV uv) |
3209 | ||
3210 | =for hackers | |
3211 | Found in file pp.h | |
3212 | ||
3213 | =item XSRETURN | |
d8c40edc | 3214 | X<XSRETURN> |
94bdecf9 JH |
3215 | |
3216 | Return from XSUB, indicating number of items on the stack. This is usually | |
3217 | handled by C<xsubpp>. | |
3218 | ||
3219 | void XSRETURN(int nitems) | |
954c1994 | 3220 | |
497711e7 GS |
3221 | =for hackers |
3222 | Found in file XSUB.h | |
3223 | ||
e509e693 | 3224 | =item XSRETURN_EMPTY |
d8c40edc | 3225 | X<XSRETURN_EMPTY> |
e509e693 SH |
3226 | |
3227 | Return an empty list from an XSUB immediately. | |
3228 | ||
3229 | XSRETURN_EMPTY; | |
3230 | ||
3231 | =for hackers | |
3232 | Found in file XSUB.h | |
3233 | ||
94bdecf9 | 3234 | =item XSRETURN_IV |
d8c40edc | 3235 | X<XSRETURN_IV> |
954c1994 | 3236 | |
94bdecf9 | 3237 | Return an integer from an XSUB immediately. Uses C<XST_mIV>. |
954c1994 | 3238 | |
94bdecf9 | 3239 | void XSRETURN_IV(IV iv) |
954c1994 | 3240 | |
497711e7 | 3241 | =for hackers |
94bdecf9 | 3242 | Found in file XSUB.h |
497711e7 | 3243 | |
94bdecf9 | 3244 | =item XSRETURN_NO |
d8c40edc | 3245 | X<XSRETURN_NO> |
954c1994 | 3246 | |
94bdecf9 | 3247 | Return C<&PL_sv_no> from an XSUB immediately. Uses C<XST_mNO>. |
954c1994 | 3248 | |
94bdecf9 | 3249 | XSRETURN_NO; |
954c1994 | 3250 | |
497711e7 | 3251 | =for hackers |
94bdecf9 | 3252 | Found in file XSUB.h |
497711e7 | 3253 | |
94bdecf9 | 3254 | =item XSRETURN_NV |
d8c40edc | 3255 | X<XSRETURN_NV> |
954c1994 | 3256 | |
94bdecf9 | 3257 | Return a double from an XSUB immediately. Uses C<XST_mNV>. |
954c1994 | 3258 | |
94bdecf9 | 3259 | void XSRETURN_NV(NV nv) |
954c1994 | 3260 | |
497711e7 | 3261 | =for hackers |
94bdecf9 JH |
3262 | Found in file XSUB.h |
3263 | ||
3264 | =item XSRETURN_PV | |
d8c40edc | 3265 | X<XSRETURN_PV> |
94bdecf9 JH |
3266 | |
3267 | Return a copy of a string from an XSUB immediately. Uses C<XST_mPV>. | |
3268 | ||
3269 | void XSRETURN_PV(char* str) | |
3270 | ||
3271 | =for hackers | |
3272 | Found in file XSUB.h | |
3273 | ||
3274 | =item XSRETURN_UNDEF | |
d8c40edc | 3275 | X<XSRETURN_UNDEF> |
94bdecf9 JH |
3276 | |
3277 | Return C<&PL_sv_undef> from an XSUB immediately. Uses C<XST_mUNDEF>. | |
3278 | ||
3279 | XSRETURN_UNDEF; | |
3280 | ||
3281 | =for hackers | |
3282 | Found in file XSUB.h | |
3283 | ||
0ee80f49 | 3284 | =item XSRETURN_UV |
d8c40edc | 3285 | X<XSRETURN_UV> |
0ee80f49 JH |
3286 | |
3287 | Return an integer from an XSUB immediately. Uses C<XST_mUV>. | |
3288 | ||
3289 | void XSRETURN_UV(IV uv) | |
3290 | ||
3291 | =for hackers | |
3292 | Found in file XSUB.h | |
3293 | ||
94bdecf9 | 3294 | =item XSRETURN_YES |
d8c40edc | 3295 | X<XSRETURN_YES> |
94bdecf9 JH |
3296 | |
3297 | Return C<&PL_sv_yes> from an XSUB immediately. Uses C<XST_mYES>. | |
3298 | ||
3299 | XSRETURN_YES; | |
3300 | ||
3301 | =for hackers | |
3302 | Found in file XSUB.h | |
3303 | ||
3304 | =item XST_mIV | |
d8c40edc | 3305 | X<XST_mIV> |
94bdecf9 JH |
3306 | |
3307 | Place an integer into the specified position C<pos> on the stack. The | |
3308 | value is stored in a new mortal SV. | |
3309 | ||
3310 | void XST_mIV(int pos, IV iv) | |
3311 | ||
3312 | =for hackers | |
3313 | Found in file XSUB.h | |
3314 | ||
3315 | =item XST_mNO | |
d8c40edc | 3316 | X<XST_mNO> |
94bdecf9 JH |
3317 | |
3318 | Place C<&PL_sv_no> into the specified position C<pos> on the | |
3319 | stack. | |
3320 | ||
3321 | void XST_mNO(int pos) | |
3322 | ||
3323 | =for hackers | |
3324 | Found in file XSUB.h | |
3325 | ||
3326 | =item XST_mNV | |
d8c40edc | 3327 | X<XST_mNV> |
94bdecf9 JH |
3328 | |
3329 | Place a double into the specified position C<pos> on the stack. The value | |
3330 | is stored in a new mortal SV. | |
3331 | ||
3332 | void XST_mNV(int pos, NV nv) | |
3333 | ||
3334 | =for hackers | |
3335 | Found in file XSUB.h | |
3336 | ||
3337 | =item XST_mPV | |
d8c40edc | 3338 | X<XST_mPV> |
94bdecf9 JH |
3339 | |
3340 | Place a copy of a string into the specified position C<pos> on the stack. | |
3341 | The value is stored in a new mortal SV. | |
3342 | ||
3343 | void XST_mPV(int pos, char* str) | |
3344 | ||
3345 | =for hackers | |
3346 | Found in file XSUB.h | |
3347 | ||
3348 | =item XST_mUNDEF | |
d8c40edc | 3349 | X<XST_mUNDEF> |
94bdecf9 JH |
3350 | |
3351 | Place C<&PL_sv_undef> into the specified position C<pos> on the | |
3352 | stack. | |
3353 | ||
3354 | void XST_mUNDEF(int pos) | |
3355 | ||
3356 | =for hackers | |
3357 | Found in file XSUB.h | |
3358 | ||
3359 | =item XST_mYES | |
d8c40edc | 3360 | X<XST_mYES> |
94bdecf9 JH |
3361 | |
3362 | Place C<&PL_sv_yes> into the specified position C<pos> on the | |
3363 | stack. | |
3364 | ||
3365 | void XST_mYES(int pos) | |
3366 | ||
3367 | =for hackers | |
3368 | Found in file XSUB.h | |
3369 | ||
3370 | ||
3371 | =back | |
3372 | ||
3373 | =head1 SV Flags | |
497711e7 | 3374 | |
94bdecf9 | 3375 | =over 8 |
954c1994 | 3376 | |
94bdecf9 | 3377 | =item svtype |
d8c40edc | 3378 | X<svtype> |
954c1994 | 3379 | |
94bdecf9 JH |
3380 | An enum of flags for Perl types. These are found in the file B<sv.h> |
3381 | in the C<svtype> enum. Test these flags with the C<SvTYPE> macro. | |
954c1994 | 3382 | |
497711e7 | 3383 | =for hackers |
94bdecf9 | 3384 | Found in file sv.h |
6e9d1081 | 3385 | |
94bdecf9 | 3386 | =item SVt_IV |
d8c40edc | 3387 | X<SVt_IV> |
6e9d1081 | 3388 | |
94bdecf9 | 3389 | Integer type flag for scalars. See C<svtype>. |
6e9d1081 NC |
3390 | |
3391 | =for hackers | |
94bdecf9 | 3392 | Found in file sv.h |
6e9d1081 | 3393 | |
94bdecf9 | 3394 | =item SVt_NV |
d8c40edc | 3395 | X<SVt_NV> |
6e9d1081 | 3396 | |
94bdecf9 | 3397 | Double type flag for scalars. See C<svtype>. |
6e9d1081 NC |
3398 | |
3399 | =for hackers | |
94bdecf9 | 3400 | Found in file sv.h |
6e9d1081 | 3401 | |
94bdecf9 | 3402 | =item SVt_PV |
d8c40edc | 3403 | X<SVt_PV> |
6e9d1081 | 3404 | |
94bdecf9 | 3405 | Pointer type flag for scalars. See C<svtype>. |
6e9d1081 NC |
3406 | |
3407 | =for hackers | |
94bdecf9 | 3408 | Found in file sv.h |
cd1ee231 | 3409 | |
94bdecf9 | 3410 | =item SVt_PVAV |
d8c40edc | 3411 | X<SVt_PVAV> |
cd1ee231 | 3412 | |
94bdecf9 | 3413 | Type flag for arrays. See C<svtype>. |
cd1ee231 JH |
3414 | |
3415 | =for hackers | |
94bdecf9 | 3416 | Found in file sv.h |
cd1ee231 | 3417 | |
94bdecf9 | 3418 | =item SVt_PVCV |
d8c40edc | 3419 | X<SVt_PVCV> |
cd1ee231 | 3420 | |
94bdecf9 | 3421 | Type flag for code refs. See C<svtype>. |
cd1ee231 JH |
3422 | |
3423 | =for hackers | |
94bdecf9 | 3424 | Found in file sv.h |
cd1ee231 | 3425 | |
94bdecf9 | 3426 | =item SVt_PVHV |
d8c40edc | 3427 | X<SVt_PVHV> |
cd1ee231 | 3428 | |
94bdecf9 | 3429 | Type flag for hashes. See C<svtype>. |
cd1ee231 JH |
3430 | |
3431 | =for hackers | |
94bdecf9 | 3432 | Found in file sv.h |
cd1ee231 | 3433 | |
94bdecf9 | 3434 | =item SVt_PVMG |
d8c40edc | 3435 | X<SVt_PVMG> |
cd1ee231 | 3436 | |
94bdecf9 | 3437 | Type flag for blessed scalars. See C<svtype>. |
cd1ee231 JH |
3438 | |
3439 | =for hackers | |
94bdecf9 | 3440 | Found in file sv.h |
cd1ee231 | 3441 | |
cd1ee231 | 3442 | |
94bdecf9 | 3443 | =back |
cd1ee231 | 3444 | |
94bdecf9 | 3445 | =head1 SV Manipulation Functions |
cd1ee231 | 3446 | |
94bdecf9 | 3447 | =over 8 |
cd1ee231 | 3448 | |
94bdecf9 | 3449 | =item get_sv |
d8c40edc | 3450 | X<get_sv> |
cd1ee231 | 3451 | |
94bdecf9 JH |
3452 | Returns the SV of the specified Perl scalar. If C<create> is set and the |
3453 | Perl variable does not exist then it will be created. If C<create> is not | |
3454 | set and the variable does not exist then NULL is returned. | |
3455 | ||
3456 | NOTE: the perl_ form of this function is deprecated. | |
3457 | ||
3458 | SV* get_sv(const char* name, I32 create) | |
cd1ee231 JH |
3459 | |
3460 | =for hackers | |
94bdecf9 | 3461 | Found in file perl.c |
cd1ee231 | 3462 | |
94bdecf9 | 3463 | =item newRV_inc |
d8c40edc | 3464 | X<newRV_inc> |
2a5a0c38 | 3465 | |
94bdecf9 JH |
3466 | Creates an RV wrapper for an SV. The reference count for the original SV is |
3467 | incremented. | |
2a5a0c38 | 3468 | |
94bdecf9 | 3469 | SV* newRV_inc(SV* sv) |
2a5a0c38 JH |
3470 | |
3471 | =for hackers | |
94bdecf9 | 3472 | Found in file sv.h |
2a5a0c38 | 3473 | |
954c1994 | 3474 | =item SvCUR |
d8c40edc | 3475 | X<SvCUR> |
954c1994 GS |
3476 | |
3477 | Returns the length of the string which is in the SV. See C<SvLEN>. | |
3478 | ||
3479 | STRLEN SvCUR(SV* sv) | |
3480 | ||
497711e7 GS |
3481 | =for hackers |
3482 | Found in file sv.h | |
3483 | ||
954c1994 | 3484 | =item SvCUR_set |
d8c40edc | 3485 | X<SvCUR_set> |
954c1994 | 3486 | |
20799e15 SP |
3487 | Set the current length of the string which is in the SV. See C<SvCUR> |
3488 | and C<SvIV_set>. | |
954c1994 GS |
3489 | |
3490 | void SvCUR_set(SV* sv, STRLEN len) | |
3491 | ||
497711e7 GS |
3492 | =for hackers |
3493 | Found in file sv.h | |
3494 | ||
94bdecf9 | 3495 | =item SvEND |
d8c40edc | 3496 | X<SvEND> |
954c1994 | 3497 | |
94bdecf9 JH |
3498 | Returns a pointer to the last character in the string which is in the SV. |
3499 | See C<SvCUR>. Access the character as *(SvEND(sv)). | |
954c1994 | 3500 | |
94bdecf9 | 3501 | char* SvEND(SV* sv) |
954c1994 | 3502 | |
497711e7 GS |
3503 | =for hackers |
3504 | Found in file sv.h | |
3505 | ||
954c1994 | 3506 | =item SvGROW |
d8c40edc | 3507 | X<SvGROW> |
954c1994 GS |
3508 | |
3509 | Expands the character buffer in the SV so that it has room for the | |
3510 | indicated number of bytes (remember to reserve space for an extra trailing | |
8cf8f3d1 | 3511 | NUL character). Calls C<sv_grow> to perform the expansion if necessary. |
954c1994 GS |
3512 | Returns a pointer to the character buffer. |
3513 | ||
679ac26e | 3514 | char * SvGROW(SV* sv, STRLEN len) |
954c1994 | 3515 | |
497711e7 GS |
3516 | =for hackers |
3517 | Found in file sv.h | |
3518 | ||
954c1994 | 3519 | =item SvIOK |
d8c40edc | 3520 | X<SvIOK> |
954c1994 GS |
3521 | |
3522 | Returns a boolean indicating whether the SV contains an integer. | |
3523 | ||
3524 | bool SvIOK(SV* sv) | |
3525 | ||
497711e7 GS |
3526 | =for hackers |
3527 | Found in file sv.h | |
3528 | ||
954c1994 | 3529 | =item SvIOKp |
d8c40edc | 3530 | X<SvIOKp> |
954c1994 GS |
3531 | |
3532 | Returns a boolean indicating whether the SV contains an integer. Checks | |
3533 | the B<private> setting. Use C<SvIOK>. | |
3534 | ||
3535 | bool SvIOKp(SV* sv) | |
3536 | ||
497711e7 GS |
3537 | =for hackers |
3538 | Found in file sv.h | |
3539 | ||
e331fc52 | 3540 | =item SvIOK_notUV |
d8c40edc | 3541 | X<SvIOK_notUV> |
e331fc52 | 3542 | |
f4758303 | 3543 | Returns a boolean indicating whether the SV contains a signed integer. |
e331fc52 | 3544 | |
12fa07df | 3545 | bool SvIOK_notUV(SV* sv) |
e331fc52 JH |
3546 | |
3547 | =for hackers | |
3548 | Found in file sv.h | |
3549 | ||
954c1994 | 3550 | =item SvIOK_off |
d8c40edc | 3551 | X<SvIOK_off> |
954c1994 GS |
3552 | |
3553 | Unsets the IV status of an SV. | |
3554 | ||
3555 | void SvIOK_off(SV* sv) | |
3556 | ||
497711e7 GS |
3557 | =for hackers |
3558 | Found in file sv.h | |
3559 | ||
954c1994 | 3560 | =item SvIOK_on |
d8c40edc | 3561 | X<SvIOK_on> |
954c1994 GS |
3562 | |
3563 | Tells an SV that it is an integer. | |
3564 | ||
3565 | void SvIOK_on(SV* sv) | |
3566 | ||
497711e7 GS |
3567 | =for hackers |
3568 | Found in file sv.h | |
3569 | ||
954c1994 | 3570 | =item SvIOK_only |
d8c40edc | 3571 | X<SvIOK_only> |
954c1994 GS |
3572 | |
3573 | Tells an SV that it is an integer and disables all other OK bits. | |
3574 | ||
3575 | void SvIOK_only(SV* sv) | |
3576 | ||
497711e7 GS |
3577 | =for hackers |
3578 | Found in file sv.h | |
3579 | ||
e331fc52 | 3580 | =item SvIOK_only_UV |
d8c40edc | 3581 | X<SvIOK_only_UV> |
e331fc52 JH |
3582 | |
3583 | Tells and SV that it is an unsigned integer and disables all other OK bits. | |
3584 | ||
3585 | void SvIOK_only_UV(SV* sv) | |
3586 | ||
3587 | =for hackers | |
3588 | Found in file sv.h | |
3589 | ||
3590 | =item SvIOK_UV | |
d8c40edc | 3591 | X<SvIOK_UV> |
e331fc52 JH |
3592 | |
3593 | Returns a boolean indicating whether the SV contains an unsigned integer. | |
3594 | ||
12fa07df | 3595 | bool SvIOK_UV(SV* sv) |
e331fc52 JH |
3596 | |
3597 | =for hackers | |
3598 | Found in file sv.h | |
3599 | ||
19dbb8f1 | 3600 | =item SvIsCOW |
d8c40edc | 3601 | X<SvIsCOW> |
19dbb8f1 NC |
3602 | |
3603 | Returns a boolean indicating whether the SV is Copy-On-Write. (either shared | |
3604 | hash key scalars, or full Copy On Write scalars if 5.9.0 is configured for | |
3605 | COW) | |
3606 | ||
3607 | bool SvIsCOW(SV* sv) | |
3608 | ||
3609 | =for hackers | |
3610 | Found in file sv.h | |
3611 | ||
3612 | =item SvIsCOW_shared_hash | |
d8c40edc | 3613 | X<SvIsCOW_shared_hash> |
19dbb8f1 NC |
3614 | |
3615 | Returns a boolean indicating whether the SV is Copy-On-Write shared hash key | |
3616 | scalar. | |
3617 | ||
3618 | bool SvIsCOW_shared_hash(SV* sv) | |
3619 | ||
3620 | =for hackers | |
3621 | Found in file sv.h | |
3622 | ||
954c1994 | 3623 | =item SvIV |
d8c40edc | 3624 | X<SvIV> |
954c1994 | 3625 | |
645c22ef DM |
3626 | Coerces the given SV to an integer and returns it. See C<SvIVx> for a |
3627 | version which guarantees to evaluate sv only once. | |
954c1994 GS |
3628 | |
3629 | IV SvIV(SV* sv) | |
3630 | ||
497711e7 GS |
3631 | =for hackers |
3632 | Found in file sv.h | |
3633 | ||
df344c0f | 3634 | =item SvIVX |
d8c40edc | 3635 | X<SvIVX> |
954c1994 | 3636 | |
df344c0f NC |
3637 | Returns the raw value in the SV's IV slot, without checks or conversions. |
3638 | Only use when you are sure SvIOK is true. See also C<SvIV()>. | |
954c1994 | 3639 | |
df344c0f | 3640 | IV SvIVX(SV* sv) |
954c1994 | 3641 | |
497711e7 GS |
3642 | =for hackers |
3643 | Found in file sv.h | |
3644 | ||
df344c0f | 3645 | =item SvIVx |
d8c40edc | 3646 | X<SvIVx> |
645c22ef | 3647 | |
df344c0f NC |
3648 | Coerces the given SV to an integer and returns it. Guarantees to evaluate |
3649 | sv only once. Use the more efficient C<SvIV> otherwise. | |
645c22ef | 3650 | |
df344c0f | 3651 | IV SvIVx(SV* sv) |
645c22ef DM |
3652 | |
3653 | =for hackers | |
3654 | Found in file sv.h | |
3655 | ||
891f9566 | 3656 | =item SvIV_nomg |
d8c40edc | 3657 | X<SvIV_nomg> |
891f9566 YST |
3658 | |
3659 | Like C<SvIV> but doesn't process magic. | |
3660 | ||
3661 | IV SvIV_nomg(SV* sv) | |
3662 | ||
3663 | =for hackers | |
3664 | Found in file sv.h | |
3665 | ||
672994ce | 3666 | =item SvIV_set |
d8c40edc | 3667 | X<SvIV_set> |
672994ce | 3668 | |
20799e15 SP |
3669 | Set the value of the IV pointer in sv to val. It is possible to perform |
3670 | the same function of this macro with an lvalue assignment to C<SvIVX>. | |
3671 | With future Perls, however, it will be more efficient to use | |
3672 | C<SvIV_set> instead of the lvalue assignment to C<SvIVX>. | |
672994ce SP |
3673 | |
3674 | void SvIV_set(SV* sv, IV val) | |
3675 | ||
3676 | =for hackers | |
3677 | Found in file sv.h | |
3678 | ||
954c1994 | 3679 | =item SvLEN |
d8c40edc | 3680 | X<SvLEN> |
954c1994 | 3681 | |
91e74348 JH |
3682 | Returns the size of the string buffer in the SV, not including any part |
3683 | attributable to C<SvOOK>. See C<SvCUR>. | |
954c1994 GS |
3684 | |
3685 | STRLEN SvLEN(SV* sv) | |
3686 | ||
497711e7 GS |
3687 | =for hackers |
3688 | Found in file sv.h | |
3689 | ||
672994ce | 3690 | =item SvLEN_set |
d8c40edc | 3691 | X<SvLEN_set> |
672994ce | 3692 | |
20799e15 | 3693 | Set the actual length of the string which is in the SV. See C<SvIV_set>. |
672994ce SP |
3694 | |
3695 | void SvLEN_set(SV* sv, STRLEN len) | |
3696 | ||
3697 | =for hackers | |
3698 | Found in file sv.h | |
3699 | ||
3700 | =item SvMAGIC_set | |
d8c40edc | 3701 | X<SvMAGIC_set> |
672994ce | 3702 | |
20799e15 | 3703 | Set the value of the MAGIC pointer in sv to val. See C<SvIV_set>. |
672994ce SP |
3704 | |
3705 | void SvMAGIC_set(SV* sv, MAGIC* val) | |
3706 | ||
3707 | =for hackers | |
3708 | Found in file sv.h | |
3709 | ||
954c1994 | 3710 | =item SvNIOK |
d8c40edc | 3711 | X<SvNIOK> |
954c1994 GS |
3712 | |
3713 | Returns a boolean indicating whether the SV contains a number, integer or | |
3714 | double. | |
3715 | ||
3716 | bool SvNIOK(SV* sv) | |
3717 | ||
497711e7 GS |
3718 | =for hackers |
3719 | Found in file sv.h | |
3720 | ||
954c1994 | 3721 | =item SvNIOKp |
d8c40edc | 3722 | X<SvNIOKp> |
954c1994 GS |
3723 | |
3724 | Returns a boolean indicating whether the SV contains a number, integer or | |
3725 | double. Checks the B<private> setting. Use C<SvNIOK>. | |
3726 | ||
3727 | bool SvNIOKp(SV* sv) | |
3728 | ||
497711e7 GS |
3729 | =for hackers |
3730 | Found in file sv.h | |
3731 | ||
954c1994 | 3732 | =item SvNIOK_off |
d8c40edc | 3733 | X<SvNIOK_off> |
954c1994 GS |
3734 | |
3735 | Unsets the NV/IV status of an SV. | |
3736 | ||
3737 | void SvNIOK_off(SV* sv) | |
3738 | ||
497711e7 GS |
3739 | =for hackers |
3740 | Found in file sv.h | |
3741 | ||
954c1994 | 3742 | =item SvNOK |
d8c40edc | 3743 | X<SvNOK> |
954c1994 GS |
3744 | |
3745 | Returns a boolean indicating whether the SV contains a double. | |
3746 | ||
3747 | bool SvNOK(SV* sv) | |
3748 | ||
497711e7 GS |
3749 | =for hackers |
3750 | Found in file sv.h | |
3751 | ||
954c1994 | 3752 | =item SvNOKp |
d8c40edc | 3753 | X<SvNOKp> |
954c1994 GS |
3754 | |
3755 | Returns a boolean indicating whether the SV contains a double. Checks the | |
3756 | B<private> setting. Use C<SvNOK>. | |
3757 | ||
3758 | bool SvNOKp(SV* sv) | |
3759 | ||
497711e7 GS |
3760 | =for hackers |
3761 | Found in file sv.h | |
3762 | ||
954c1994 | 3763 | =item SvNOK_off |
d8c40edc | 3764 | X<SvNOK_off> |
954c1994 GS |
3765 | |
3766 | Unsets the NV status of an SV. | |
3767 | ||
3768 | void SvNOK_off(SV* sv) | |
3769 | ||
497711e7 GS |
3770 | =for hackers |
3771 | Found in file sv.h | |
3772 | ||
954c1994 | 3773 | =item SvNOK_on |
d8c40edc | 3774 | X<SvNOK_on> |
954c1994 GS |
3775 | |
3776 | Tells an SV that it is a double. | |
3777 | ||
3778 | void SvNOK_on(SV* sv) | |
3779 | ||
497711e7 GS |
3780 | =for hackers |
3781 | Found in file sv.h | |
3782 | ||
954c1994 | 3783 | =item SvNOK_only |
d8c40edc | 3784 | X<SvNOK_only> |
954c1994 GS |
3785 | |
3786 | Tells an SV that it is a double and disables all other OK bits. | |
3787 | ||
3788 | void SvNOK_only(SV* sv) | |
3789 | ||
497711e7 GS |
3790 | =for hackers |
3791 | Found in file sv.h | |
3792 | ||
954c1994 | 3793 | =item SvNV |
d8c40edc | 3794 | X<SvNV> |
954c1994 | 3795 | |
645c22ef DM |
3796 | Coerce the given SV to a double and return it. See C<SvNVx> for a version |
3797 | which guarantees to evaluate sv only once. | |
954c1994 GS |
3798 | |
3799 | NV SvNV(SV* sv) | |
3800 | ||
497711e7 GS |
3801 | =for hackers |
3802 | Found in file sv.h | |
3803 | ||
b9381830 | 3804 | =item SvNVX |
d8c40edc | 3805 | X<SvNVX> |
645c22ef | 3806 | |
b9381830 JP |
3807 | Returns the raw value in the SV's NV slot, without checks or conversions. |
3808 | Only use when you are sure SvNOK is true. See also C<SvNV()>. | |
645c22ef | 3809 | |
b9381830 | 3810 | NV SvNVX(SV* sv) |
645c22ef DM |
3811 | |
3812 | =for hackers | |
3813 | Found in file sv.h | |
3814 | ||
b9381830 | 3815 | =item SvNVx |
d8c40edc | 3816 | X<SvNVx> |
954c1994 | 3817 | |
b9381830 JP |
3818 | Coerces the given SV to a double and returns it. Guarantees to evaluate |
3819 | sv only once. Use the more efficient C<SvNV> otherwise. | |
954c1994 | 3820 | |
b9381830 | 3821 | NV SvNVx(SV* sv) |
954c1994 | 3822 | |
497711e7 GS |
3823 | =for hackers |
3824 | Found in file sv.h | |
3825 | ||
672994ce | 3826 | =item SvNV_set |
d8c40edc | 3827 | X<SvNV_set> |
672994ce | 3828 | |
20799e15 | 3829 | Set the value of the NV pointer in sv to val. See C<SvIV_set>. |
672994ce SP |
3830 | |
3831 | void SvNV_set(SV* sv, NV val) | |
3832 | ||
3833 | =for hackers | |
3834 | Found in file sv.h | |
3835 | ||
954c1994 | 3836 | =item SvOK |
d8c40edc | 3837 | X<SvOK> |
954c1994 | 3838 | |
9adebda4 SB |
3839 | Returns a boolean indicating whether the value is an SV. It also tells |
3840 | whether the value is defined or not. | |
954c1994 GS |
3841 | |
3842 | bool SvOK(SV* sv) | |
3843 | ||
497711e7 GS |
3844 | =for hackers |
3845 | Found in file sv.h | |
3846 | ||
954c1994 | 3847 | =item SvOOK |
d8c40edc | 3848 | X<SvOOK> |
954c1994 GS |
3849 | |
3850 | Returns a boolean indicating whether the SvIVX is a valid offset value for | |
3851 | the SvPVX. This hack is used internally to speed up removal of characters | |
3852 | from the beginning of a SvPV. When SvOOK is true, then the start of the | |
3853 | allocated string buffer is really (SvPVX - SvIVX). | |
3854 | ||
3855 | bool SvOOK(SV* sv) | |
3856 | ||
497711e7 GS |
3857 | =for hackers |
3858 | Found in file sv.h | |
3859 | ||
954c1994 | 3860 | =item SvPOK |
d8c40edc | 3861 | X<SvPOK> |
954c1994 GS |
3862 | |
3863 | Returns a boolean indicating whether the SV contains a character | |
3864 | string. | |
3865 | ||
3866 | bool SvPOK(SV* sv) | |
3867 | ||
497711e7 GS |
3868 | =for hackers |
3869 | Found in file sv.h | |
3870 | ||
954c1994 | 3871 | =item SvPOKp |
d8c40edc | 3872 | X<SvPOKp> |
954c1994 GS |
3873 | |
3874 | Returns a boolean indicating whether the SV contains a character string. | |
3875 | Checks the B<private> setting. Use C<SvPOK>. | |
3876 | ||
3877 | bool SvPOKp(SV* sv) | |
3878 | ||
497711e7 GS |
3879 | =for hackers |
3880 | Found in file sv.h | |
3881 | ||
954c1994 | 3882 | =item SvPOK_off |
d8c40edc | 3883 | X<SvPOK_off> |
954c1994 GS |
3884 | |
3885 | Unsets the PV status of an SV. | |
3886 | ||
3887 | void SvPOK_off(SV* sv) | |
3888 | ||
497711e7 GS |
3889 | =for hackers |
3890 | Found in file sv.h | |
3891 | ||
954c1994 | 3892 | =item SvPOK_on |
d8c40edc | 3893 | X<SvPOK_on> |
954c1994 GS |
3894 | |
3895 | Tells an SV that it is a string. | |
3896 | ||
3897 | void SvPOK_on(SV* sv) | |
3898 | ||
497711e7 GS |
3899 | =for hackers |
3900 | Found in file sv.h | |
3901 | ||
954c1994 | 3902 | =item SvPOK_only |
d8c40edc | 3903 | X<SvPOK_only> |
954c1994 GS |
3904 | |
3905 | Tells an SV that it is a string and disables all other OK bits. | |
1e54db1a | 3906 | Will also turn off the UTF-8 status. |
954c1994 GS |
3907 | |
3908 | void SvPOK_only(SV* sv) | |
3909 | ||
497711e7 GS |
3910 | =for hackers |
3911 | Found in file sv.h | |
3912 | ||
914184e1 | 3913 | =item SvPOK_only_UTF8 |
d8c40edc | 3914 | X<SvPOK_only_UTF8> |
914184e1 | 3915 | |
d5ce4a7c | 3916 | Tells an SV that it is a string and disables all other OK bits, |
1e54db1a | 3917 | and leaves the UTF-8 status as it was. |
f1a1024e | 3918 | |
914184e1 JH |
3919 | void SvPOK_only_UTF8(SV* sv) |
3920 | ||
3921 | =for hackers | |
3922 | Found in file sv.h | |
3923 | ||
954c1994 | 3924 | =item SvPV |
d8c40edc | 3925 | X<SvPV> |
954c1994 | 3926 | |
12b7c5c7 JH |
3927 | Returns a pointer to the string in the SV, or a stringified form of |
3928 | the SV if the SV does not contain a string. The SV may cache the | |
3929 | stringified version becoming C<SvPOK>. Handles 'get' magic. See also | |
645c22ef | 3930 | C<SvPVx> for a version which guarantees to evaluate sv only once. |
954c1994 GS |
3931 | |
3932 | char* SvPV(SV* sv, STRLEN len) | |
3933 | ||
497711e7 GS |
3934 | =for hackers |
3935 | Found in file sv.h | |
3936 | ||
645c22ef | 3937 | =item SvPVbyte |
d8c40edc | 3938 | X<SvPVbyte> |
645c22ef DM |
3939 | |
3940 | Like C<SvPV>, but converts sv to byte representation first if necessary. | |
3941 | ||
3942 | char* SvPVbyte(SV* sv, STRLEN len) | |
3943 | ||
3944 | =for hackers | |
3945 | Found in file sv.h | |
3946 | ||
3947 | =item SvPVbytex | |
d8c40edc | 3948 | X<SvPVbytex> |
645c22ef DM |
3949 | |
3950 | Like C<SvPV>, but converts sv to byte representation first if necessary. | |
d1be9408 | 3951 | Guarantees to evaluate sv only once; use the more efficient C<SvPVbyte> |
645c22ef DM |
3952 | otherwise. |
3953 | ||
645c22ef DM |
3954 | char* SvPVbytex(SV* sv, STRLEN len) |
3955 | ||
3956 | =for hackers | |
3957 | Found in file sv.h | |
3958 | ||
3959 | =item SvPVbytex_force | |
d8c40edc | 3960 | X<SvPVbytex_force> |
645c22ef DM |
3961 | |
3962 | Like C<SvPV_force>, but converts sv to byte representation first if necessary. | |
d1be9408 | 3963 | Guarantees to evaluate sv only once; use the more efficient C<SvPVbyte_force> |
645c22ef DM |
3964 | otherwise. |
3965 | ||
3966 | char* SvPVbytex_force(SV* sv, STRLEN len) | |
3967 | ||
3968 | =for hackers | |
3969 | Found in file sv.h | |
3970 | ||
3971 | =item SvPVbyte_force | |
d8c40edc | 3972 | X<SvPVbyte_force> |
645c22ef DM |
3973 | |
3974 | Like C<SvPV_force>, but converts sv to byte representation first if necessary. | |
3975 | ||
3976 | char* SvPVbyte_force(SV* sv, STRLEN len) | |
3977 | ||
3978 | =for hackers | |
3979 | Found in file sv.h | |
3980 | ||
3981 | =item SvPVbyte_nolen | |
d8c40edc | 3982 | X<SvPVbyte_nolen> |
645c22ef DM |
3983 | |
3984 | Like C<SvPV_nolen>, but converts sv to byte representation first if necessary. | |
3985 | ||
1fdc5aa6 | 3986 | char* SvPVbyte_nolen(SV* sv) |
645c22ef DM |
3987 | |
3988 | =for hackers | |
3989 | Found in file sv.h | |
3990 | ||
3991 | =item SvPVutf8 | |
d8c40edc | 3992 | X<SvPVutf8> |
645c22ef | 3993 | |
1fdc5aa6 | 3994 | Like C<SvPV>, but converts sv to utf8 first if necessary. |
645c22ef DM |
3995 | |
3996 | char* SvPVutf8(SV* sv, STRLEN len) | |
3997 | ||
3998 | =for hackers | |
3999 | Found in file sv.h | |
4000 | ||
4001 | =item SvPVutf8x | |
d8c40edc | 4002 | X<SvPVutf8x> |
645c22ef | 4003 | |
1fdc5aa6 | 4004 | Like C<SvPV>, but converts sv to utf8 first if necessary. |
d1be9408 | 4005 | Guarantees to evaluate sv only once; use the more efficient C<SvPVutf8> |
645c22ef DM |
4006 | otherwise. |
4007 | ||
4008 | char* SvPVutf8x(SV* sv, STRLEN len) | |
4009 | ||
4010 | =for hackers | |
4011 | Found in file sv.h | |
4012 | ||
4013 | =item SvPVutf8x_force | |
d8c40edc | 4014 | X<SvPVutf8x_force> |
645c22ef | 4015 | |
1fdc5aa6 | 4016 | Like C<SvPV_force>, but converts sv to utf8 first if necessary. |
d1be9408 | 4017 | Guarantees to evaluate sv only once; use the more efficient C<SvPVutf8_force> |
645c22ef DM |
4018 | otherwise. |
4019 | ||
4020 | char* SvPVutf8x_force(SV* sv, STRLEN len) | |
4021 | ||
4022 | =for hackers | |
4023 | Found in file sv.h | |
4024 | ||
4025 | =item SvPVutf8_force | |
d8c40edc | 4026 | X<SvPVutf8_force> |
645c22ef | 4027 | |
1fdc5aa6 | 4028 | Like C<SvPV_force>, but converts sv to utf8 first if necessary. |
645c22ef DM |
4029 | |
4030 | char* SvPVutf8_force(SV* sv, STRLEN len) | |
4031 | ||
4032 | =for hackers | |
4033 | Found in file sv.h | |
4034 | ||
4035 | =item SvPVutf8_nolen | |
d8c40edc | 4036 | X<SvPVutf8_nolen> |
645c22ef | 4037 | |
1fdc5aa6 | 4038 | Like C<SvPV_nolen>, but converts sv to utf8 first if necessary. |
645c22ef | 4039 | |
1fdc5aa6 | 4040 | char* SvPVutf8_nolen(SV* sv) |
645c22ef DM |
4041 | |
4042 | =for hackers | |
4043 | Found in file sv.h | |
4044 | ||
df344c0f | 4045 | =item SvPVX |
d8c40edc | 4046 | X<SvPVX> |
645c22ef | 4047 | |
df344c0f NC |
4048 | Returns a pointer to the physical string in the SV. The SV must contain a |
4049 | string. | |
645c22ef | 4050 | |
df344c0f | 4051 | char* SvPVX(SV* sv) |
645c22ef DM |
4052 | |
4053 | =for hackers | |
4054 | Found in file sv.h | |
4055 | ||
df344c0f | 4056 | =item SvPVx |
d8c40edc | 4057 | X<SvPVx> |
954c1994 | 4058 | |
df344c0f | 4059 | A version of C<SvPV> which guarantees to evaluate sv only once. |
954c1994 | 4060 | |
df344c0f | 4061 | char* SvPVx(SV* sv, STRLEN len) |
954c1994 | 4062 | |
497711e7 GS |
4063 | =for hackers |
4064 | Found in file sv.h | |
4065 | ||
954c1994 | 4066 | =item SvPV_force |
d8c40edc | 4067 | X<SvPV_force> |
954c1994 | 4068 | |
12b7c5c7 JH |
4069 | Like C<SvPV> but will force the SV into containing just a string |
4070 | (C<SvPOK_only>). You want force if you are going to update the C<SvPVX> | |
4071 | directly. | |
954c1994 GS |
4072 | |
4073 | char* SvPV_force(SV* sv, STRLEN len) | |
4074 | ||
497711e7 GS |
4075 | =for hackers |
4076 | Found in file sv.h | |
4077 | ||
645c22ef | 4078 | =item SvPV_force_nomg |
d8c40edc | 4079 | X<SvPV_force_nomg> |
645c22ef | 4080 | |
12b7c5c7 JH |
4081 | Like C<SvPV> but will force the SV into containing just a string |
4082 | (C<SvPOK_only>). You want force if you are going to update the C<SvPVX> | |
4083 | directly. Doesn't process magic. | |
645c22ef DM |
4084 | |
4085 | char* SvPV_force_nomg(SV* sv, STRLEN len) | |
4086 | ||
4087 | =for hackers | |
4088 | Found in file sv.h | |
4089 | ||
954c1994 | 4090 | =item SvPV_nolen |
d8c40edc | 4091 | X<SvPV_nolen> |
954c1994 | 4092 | |
12b7c5c7 JH |
4093 | Returns a pointer to the string in the SV, or a stringified form of |
4094 | the SV if the SV does not contain a string. The SV may cache the | |
4095 | stringified form becoming C<SvPOK>. Handles 'get' magic. | |
954c1994 GS |
4096 | |
4097 | char* SvPV_nolen(SV* sv) | |
4098 | ||
497711e7 GS |
4099 | =for hackers |
4100 | Found in file sv.h | |
4101 | ||
891f9566 | 4102 | =item SvPV_nomg |
d8c40edc | 4103 | X<SvPV_nomg> |
891f9566 YST |
4104 | |
4105 | Like C<SvPV> but doesn't process magic. | |
4106 | ||
4107 | char* SvPV_nomg(SV* sv, STRLEN len) | |
4108 | ||
4109 | =for hackers | |
4110 | Found in file sv.h | |
4111 | ||
672994ce | 4112 | =item SvPV_set |
d8c40edc | 4113 | X<SvPV_set> |
672994ce | 4114 | |
20799e15 | 4115 | Set the value of the PV pointer in sv to val. See C<SvIV_set>. |
672994ce SP |
4116 | |
4117 | void SvPV_set(SV* sv, char* val) | |
4118 | ||
4119 | =for hackers | |
4120 | Found in file sv.h | |
4121 | ||
954c1994 | 4122 | =item SvREFCNT |
d8c40edc | 4123 | X<SvREFCNT> |
954c1994 GS |
4124 | |
4125 | Returns the value of the object's reference count. | |
4126 | ||
4127 | U32 SvREFCNT(SV* sv) | |
4128 | ||
497711e7 GS |
4129 | =for hackers |
4130 | Found in file sv.h | |
4131 | ||
954c1994 | 4132 | =item SvREFCNT_dec |
d8c40edc | 4133 | X<SvREFCNT_dec> |
954c1994 GS |
4134 | |
4135 | Decrements the reference count of the given SV. | |
4136 | ||
4137 | void SvREFCNT_dec(SV* sv) | |
4138 | ||
497711e7 GS |
4139 | =for hackers |
4140 | Found in file sv.h | |
4141 | ||
954c1994 | 4142 | =item SvREFCNT_inc |
d8c40edc | 4143 | X<SvREFCNT_inc> |
954c1994 GS |
4144 | |
4145 | Increments the reference count of the given SV. | |
4146 | ||
4147 | SV* SvREFCNT_inc(SV* sv) | |
4148 | ||
497711e7 GS |
4149 | =for hackers |
4150 | Found in file sv.h | |
4151 | ||
b37c2d43 AL |
4152 | =item SvREFCNT_inc_NN |
4153 | X<SvREFCNT_inc_NN> | |
4154 | ||
4155 | Same as SvREFCNT_inc, but can only be used if you know I<sv> | |
4156 | is not NULL. Since we don't have to check the NULLness, it's faster | |
4157 | and smaller. | |
4158 | ||
4159 | SV* SvREFCNT_inc_NN(SV* sv) | |
4160 | ||
4161 | =for hackers | |
4162 | Found in file sv.h | |
4163 | ||
4164 | =item SvREFCNT_inc_simple | |
4165 | X<SvREFCNT_inc_simple> | |
4166 | ||
4167 | Same as SvREFCNT_inc, but can only be used with simple variables, not | |
4168 | expressions or pointer dereferences. Since we don't have to store a | |
4169 | temporary value, it's faster. | |
4170 | ||
4171 | SV* SvREFCNT_inc_simple(SV* sv) | |
4172 | ||
4173 | =for hackers | |
4174 | Found in file sv.h | |
4175 | ||
4176 | =item SvREFCNT_inc_simple_NN | |
4177 | X<SvREFCNT_inc_simple_NN> | |
4178 | ||
4179 | Same as SvREFCNT_inc_simple, but can only be used if you know I<sv> | |
4180 | is not NULL. Since we don't have to check the NULLness, it's faster | |
4181 | and smaller. | |
4182 | ||
4183 | SV* SvREFCNT_inc_simple_NN(SV* sv) | |
4184 | ||
4185 | =for hackers | |
4186 | Found in file sv.h | |
4187 | ||
4188 | =item SvREFCNT_inc_simple_void | |
4189 | X<SvREFCNT_inc_simple_void> | |
4190 | ||
4191 | Same as SvREFCNT_inc_simple, but can only be used if you don't need the | |
4192 | return value. The macro doesn't need to return a meaningful value. | |
4193 | ||
4194 | SV* SvREFCNT_inc_simple_void(SV* sv) | |
4195 | ||
4196 | =for hackers | |
4197 | Found in file sv.h | |
4198 | ||
4199 | =item SvREFCNT_inc_void | |
4200 | X<SvREFCNT_inc_void> | |
4201 | ||
4202 | Same as SvREFCNT_inc, but can only be used if you don't need the | |
4203 | return value. The macro doesn't need to return a meaningful value. | |
4204 | ||
4205 | SV* SvREFCNT_inc_void(SV* sv) | |
4206 | ||
4207 | =for hackers | |
4208 | Found in file sv.h | |
4209 | ||
4210 | =item SvREFCNT_inc_void_NN | |
4211 | X<SvREFCNT_inc_void_NN> | |
4212 | ||
4213 | Same as SvREFCNT_inc, but can only be used if you don't need the return | |
4214 | value, and you know that I<sv> is not NULL. The macro doesn't need | |
4215 | to return a meaningful value, or check for NULLness, so it's smaller | |
4216 | and faster. | |
4217 | ||
4218 | SV* SvREFCNT_inc_void_NN(SV* sv) | |
4219 | ||
4220 | =for hackers | |
4221 | Found in file sv.h | |
4222 | ||
954c1994 | 4223 | =item SvROK |
d8c40edc | 4224 | X<SvROK> |
954c1994 GS |
4225 | |
4226 | Tests if the SV is an RV. | |
4227 | ||
4228 | bool SvROK(SV* sv) | |
4229 | ||
497711e7 GS |
4230 | =for hackers |
4231 | Found in file sv.h | |
4232 | ||
954c1994 | 4233 | =item SvROK_off |
d8c40edc | 4234 | X<SvROK_off> |
954c1994 GS |
4235 | |
4236 | Unsets the RV status of an SV. | |
4237 | ||
4238 | void SvROK_off(SV* sv) | |
4239 | ||
497711e7 GS |
4240 | =for hackers |
4241 | Found in file sv.h | |
4242 | ||
954c1994 | 4243 | =item SvROK_on |
d8c40edc | 4244 | X<SvROK_on> |
954c1994 GS |
4245 | |
4246 | Tells an SV that it is an RV. | |
4247 | ||
4248 | void SvROK_on(SV* sv) | |
4249 | ||
497711e7 GS |
4250 | =for hackers |
4251 | Found in file sv.h | |
4252 | ||
954c1994 | 4253 | =item SvRV |
d8c40edc | 4254 | X<SvRV> |
954c1994 GS |
4255 | |
4256 | Dereferences an RV to return the SV. | |
4257 | ||
4258 | SV* SvRV(SV* sv) | |
4259 | ||
497711e7 GS |
4260 | =for hackers |
4261 | Found in file sv.h | |
4262 | ||
672994ce | 4263 | =item SvRV_set |
d8c40edc | 4264 | X<SvRV_set> |
672994ce | 4265 | |
20799e15 | 4266 | Set the value of the RV pointer in sv to val. See C<SvIV_set>. |
672994ce SP |
4267 | |
4268 | void SvRV_set(SV* sv, SV* val) | |
4269 | ||
4270 | =for hackers | |
4271 | Found in file sv.h | |
4272 | ||
954c1994 | 4273 | =item SvSTASH |
d8c40edc | 4274 | X<SvSTASH> |
954c1994 GS |
4275 | |
4276 | Returns the stash of the SV. | |
4277 | ||
4278 | HV* SvSTASH(SV* sv) | |
4279 | ||
497711e7 GS |
4280 | =for hackers |
4281 | Found in file sv.h | |
4282 | ||
672994ce | 4283 | =item SvSTASH_set |
d8c40edc | 4284 | X<SvSTASH_set> |
672994ce | 4285 | |
20799e15 | 4286 | Set the value of the STASH pointer in sv to val. See C<SvIV_set>. |
672994ce SP |
4287 | |
4288 | void SvSTASH_set(SV* sv, STASH* val) | |
4289 | ||
4290 | =for hackers | |
4291 | Found in file sv.h | |
4292 | ||
954c1994 | 4293 | =item SvTAINT |
d8c40edc | 4294 | X<SvTAINT> |
954c1994 | 4295 | |
c55831ac | 4296 | Taints an SV if tainting is enabled. |
954c1994 GS |
4297 | |
4298 | void SvTAINT(SV* sv) | |
4299 | ||
497711e7 GS |
4300 | =for hackers |
4301 | Found in file sv.h | |
4302 | ||
954c1994 | 4303 | =item SvTAINTED |
d8c40edc | 4304 | X<SvTAINTED> |
954c1994 GS |
4305 | |
4306 | Checks to see if an SV is tainted. Returns TRUE if it is, FALSE if | |
4307 | not. | |
4308 | ||
4309 | bool SvTAINTED(SV* sv) | |
4310 | ||
497711e7 GS |
4311 | =for hackers |
4312 | Found in file sv.h | |
4313 | ||
954c1994 | 4314 | =item SvTAINTED_off |
d8c40edc | 4315 | X<SvTAINTED_off> |
954c1994 GS |
4316 | |
4317 | Untaints an SV. Be I<very> careful with this routine, as it short-circuits | |
4318 | some of Perl's fundamental security features. XS module authors should not | |
4319 | use this function unless they fully understand all the implications of | |
4320 | unconditionally untainting the value. Untainting should be done in the | |
4321 | standard perl fashion, via a carefully crafted regexp, rather than directly | |
4322 | untainting variables. | |
4323 | ||
4324 | void SvTAINTED_off(SV* sv) | |
4325 | ||
497711e7 GS |
4326 | =for hackers |
4327 | Found in file sv.h | |
4328 | ||
954c1994 | 4329 | =item SvTAINTED_on |
d8c40edc | 4330 | X<SvTAINTED_on> |
954c1994 | 4331 | |
c55831ac | 4332 | Marks an SV as tainted if tainting is enabled. |
954c1994 GS |
4333 | |
4334 | void SvTAINTED_on(SV* sv) | |
4335 | ||
497711e7 GS |
4336 | =for hackers |
4337 | Found in file sv.h | |
4338 | ||
954c1994 | 4339 | =item SvTRUE |
d8c40edc | 4340 | X<SvTRUE> |
954c1994 GS |
4341 | |
4342 | Returns a boolean indicating whether Perl would evaluate the SV as true or | |
4343 | false, defined or undefined. Does not handle 'get' magic. | |
4344 | ||
4345 | bool SvTRUE(SV* sv) | |
4346 | ||
497711e7 GS |
4347 | =for hackers |
4348 | Found in file sv.h | |
4349 | ||
9f4817db | 4350 | =item SvTYPE |
d8c40edc | 4351 | X<SvTYPE> |
af3c7592 | 4352 | |
9f4817db JH |
4353 | Returns the type of the SV. See C<svtype>. |
4354 | ||
4355 | svtype SvTYPE(SV* sv) | |
954c1994 | 4356 | |
497711e7 GS |
4357 | =for hackers |
4358 | Found in file sv.h | |
4359 | ||
a8586c98 | 4360 | =item SvUOK |
d8c40edc | 4361 | X<SvUOK> |
a8586c98 JH |
4362 | |
4363 | Returns a boolean indicating whether the SV contains an unsigned integer. | |
4364 | ||
4365 | void SvUOK(SV* sv) | |
4366 | ||
4367 | =for hackers | |
4368 | Found in file sv.h | |
4369 | ||
954c1994 | 4370 | =item SvUPGRADE |
d8c40edc | 4371 | X<SvUPGRADE> |
954c1994 GS |
4372 | |
4373 | Used to upgrade an SV to a more complex form. Uses C<sv_upgrade> to | |
4374 | perform the upgrade if necessary. See C<svtype>. | |
4375 | ||
4376 | void SvUPGRADE(SV* sv, svtype type) | |
4377 | ||
497711e7 GS |
4378 | =for hackers |
4379 | Found in file sv.h | |
4380 | ||
914184e1 | 4381 | =item SvUTF8 |
d8c40edc | 4382 | X<SvUTF8> |
914184e1 JH |
4383 | |
4384 | Returns a boolean indicating whether the SV contains UTF-8 encoded data. | |
4385 | ||
12fa07df | 4386 | bool SvUTF8(SV* sv) |
914184e1 JH |
4387 | |
4388 | =for hackers | |
4389 | Found in file sv.h | |
4390 | ||
4391 | =item SvUTF8_off | |
d8c40edc | 4392 | X<SvUTF8_off> |
914184e1 | 4393 | |
1e54db1a | 4394 | Unsets the UTF-8 status of an SV. |
914184e1 JH |
4395 | |
4396 | void SvUTF8_off(SV *sv) | |
4397 | ||
4398 | =for hackers | |
4399 | Found in file sv.h | |
4400 | ||
4401 | =item SvUTF8_on | |
d8c40edc | 4402 | X<SvUTF8_on> |
914184e1 | 4403 | |
1e54db1a | 4404 | Turn on the UTF-8 status of an SV (the data is not changed, just the flag). |
d5ce4a7c | 4405 | Do not use frivolously. |
914184e1 JH |
4406 | |
4407 | void SvUTF8_on(SV *sv) | |
4408 | ||
4409 | =for hackers | |
4410 | Found in file sv.h | |
4411 | ||
954c1994 | 4412 | =item SvUV |
d8c40edc | 4413 | X<SvUV> |
954c1994 | 4414 | |
645c22ef DM |
4415 | Coerces the given SV to an unsigned integer and returns it. See C<SvUVx> |
4416 | for a version which guarantees to evaluate sv only once. | |
954c1994 GS |
4417 | |
4418 | UV SvUV(SV* sv) | |
4419 | ||
497711e7 GS |
4420 | =for hackers |
4421 | Found in file sv.h | |
4422 | ||
b9381830 | 4423 | =item SvUVX |
d8c40edc | 4424 | X<SvUVX> |
891f9566 | 4425 | |
b9381830 JP |
4426 | Returns the raw value in the SV's UV slot, without checks or conversions. |
4427 | Only use when you are sure SvIOK is true. See also C<SvUV()>. | |
891f9566 | 4428 | |
b9381830 | 4429 | UV SvUVX(SV* sv) |
891f9566 YST |
4430 | |
4431 | =for hackers | |
4432 | Found in file sv.h | |
4433 | ||
b9381830 | 4434 | =item SvUVx |
d8c40edc | 4435 | X<SvUVx> |
b0f01acb | 4436 | |
b9381830 JP |
4437 | Coerces the given SV to an unsigned integer and returns it. Guarantees to |
4438 | evaluate sv only once. Use the more efficient C<SvUV> otherwise. | |
b0f01acb | 4439 | |
b9381830 | 4440 | UV SvUVx(SV* sv) |
b0f01acb JP |
4441 | |
4442 | =for hackers | |
4443 | Found in file sv.h | |
4444 | ||
891f9566 | 4445 | =item SvUV_nomg |
d8c40edc | 4446 | X<SvUV_nomg> |
954c1994 | 4447 | |
891f9566 | 4448 | Like C<SvUV> but doesn't process magic. |
954c1994 | 4449 | |
891f9566 | 4450 | UV SvUV_nomg(SV* sv) |
954c1994 | 4451 | |
497711e7 GS |
4452 | =for hackers |
4453 | Found in file sv.h | |
4454 | ||
672994ce | 4455 | =item SvUV_set |
d8c40edc | 4456 | X<SvUV_set> |
672994ce | 4457 | |
20799e15 | 4458 | Set the value of the UV pointer in sv to val. See C<SvIV_set>. |
672994ce SP |
4459 | |
4460 | void SvUV_set(SV* sv, UV val) | |
4461 | ||
4462 | =for hackers | |
4463 | Found in file sv.h | |
4464 | ||
b0f01acb | 4465 | =item SvVOK |
d8c40edc | 4466 | X<SvVOK> |
645c22ef | 4467 | |
b0f01acb | 4468 | Returns a boolean indicating whether the SV contains a v-string. |
645c22ef | 4469 | |
b0f01acb | 4470 | bool SvVOK(SV* sv) |
645c22ef DM |
4471 | |
4472 | =for hackers | |
4473 | Found in file sv.h | |
4474 | ||
d2a0f284 JC |
4475 | =item sv_catpvn_nomg |
4476 | X<sv_catpvn_nomg> | |
4477 | ||
4478 | Like C<sv_catpvn> but doesn't process magic. | |
4479 | ||
4480 | void sv_catpvn_nomg(SV* sv, const char* ptr, STRLEN len) | |
4481 | ||
4482 | =for hackers | |
4483 | Found in file sv.h | |
4484 | ||
4485 | =item sv_catsv_nomg | |
4486 | X<sv_catsv_nomg> | |
4487 | ||
4488 | Like C<sv_catsv> but doesn't process magic. | |
4489 | ||
4490 | void sv_catsv_nomg(SV* dsv, SV* ssv) | |
4491 | ||
4492 | =for hackers | |
4493 | Found in file sv.h | |
4494 | ||
4495 | =item sv_derived_from | |
4496 | X<sv_derived_from> | |
4497 | ||
4498 | Returns a boolean indicating whether the SV is derived from the specified | |
4499 | class. This is the function that implements C<UNIVERSAL::isa>. It works | |
4500 | for class names as well as for objects. | |
4501 | ||
4502 | bool sv_derived_from(SV* sv, const char* name) | |
4503 | ||
4504 | =for hackers | |
4505 | Found in file universal.c | |
4506 | ||
4507 | =item sv_report_used | |
4508 | X<sv_report_used> | |
4509 | ||
4510 | Dump the contents of all SVs not yet freed. (Debugging aid). | |
4511 | ||
4512 | void sv_report_used() | |
4513 | ||
4514 | =for hackers | |
4515 | Found in file sv.c | |
4516 | ||
4517 | =item sv_setsv_nomg | |
4518 | X<sv_setsv_nomg> | |
4519 | ||
4520 | Like C<sv_setsv> but doesn't process magic. | |
4521 | ||
4522 | void sv_setsv_nomg(SV* dsv, SV* ssv) | |
4523 | ||
4524 | =for hackers | |
4525 | Found in file sv.h | |
4526 | ||
4527 | ||
4528 | =back | |
4529 | ||
4530 | =head1 SV-Body Allocation | |
4531 | ||
4532 | =over 8 | |
4533 | ||
4534 | =item looks_like_number | |
4535 | X<looks_like_number> | |
4536 | ||
4537 | Test if the content of an SV looks like a number (or is a number). | |
4538 | C<Inf> and C<Infinity> are treated as numbers (so will not issue a | |
4539 | non-numeric warning), even if your atof() doesn't grok them. | |
4540 | ||
4541 | I32 looks_like_number(SV* sv) | |
4542 | ||
4543 | =for hackers | |
4544 | Found in file sv.c | |
4545 | ||
4546 | =item newRV_noinc | |
4547 | X<newRV_noinc> | |
4548 | ||
4549 | Creates an RV wrapper for an SV. The reference count for the original | |
4550 | SV is B<not> incremented. | |
4551 | ||
7f466ec7 | 4552 | SV* newRV_noinc(SV* sv) |
d2a0f284 JC |
4553 | |
4554 | =for hackers | |
4555 | Found in file sv.c | |
4556 | ||
4557 | =item newSV | |
4558 | X<newSV> | |
4559 | ||
4560 | Creates a new SV. A non-zero C<len> parameter indicates the number of | |
4561 | bytes of preallocated string space the SV should have. An extra byte for a | |
4562 | trailing NUL is also reserved. (SvPOK is not set for the SV even if string | |
4563 | space is allocated.) The reference count for the new SV is set to 1. | |
4564 | ||
4565 | In 5.9.3, newSV() replaces the older NEWSV() API, and drops the first | |
4566 | parameter, I<x>, a debug aid which allowed callers to identify themselves. | |
4567 | This aid has been superseded by a new build option, PERL_MEM_LOG (see | |
4568 | L<perlhack/PERL_MEM_LOG>). The older API is still there for use in XS | |
4569 | modules supporting older perls. | |
4570 | ||
4571 | SV* newSV(STRLEN len) | |
4572 | ||
4573 | =for hackers | |
4574 | Found in file sv.c | |
4575 | ||
4576 | =item newSVhek | |
4577 | X<newSVhek> | |
4578 | ||
4579 | Creates a new SV from the hash key structure. It will generate scalars that | |
4580 | point to the shared string table where possible. Returns a new (undefined) | |
4581 | SV if the hek is NULL. | |
4582 | ||
4583 | SV* newSVhek(const HEK *hek) | |
4584 | ||
4585 | =for hackers | |
4586 | Found in file sv.c | |
4587 | ||
4588 | =item newSViv | |
4589 | X<newSViv> | |
4590 | ||
4591 | Creates a new SV and copies an integer into it. The reference count for the | |
4592 | SV is set to 1. | |
4593 | ||
4594 | SV* newSViv(IV i) | |
4595 | ||
4596 | =for hackers | |
4597 | Found in file sv.c | |
4598 | ||
4599 | =item newSVnv | |
4600 | X<newSVnv> | |
4601 | ||
4602 | Creates a new SV and copies a floating point value into it. | |
4603 | The reference count for the SV is set to 1. | |
4604 | ||
4605 | SV* newSVnv(NV n) | |
4606 | ||
4607 | =for hackers | |
4608 | Found in file sv.c | |
4609 | ||
4610 | =item newSVpv | |
4611 | X<newSVpv> | |
4612 | ||
4613 | Creates a new SV and copies a string into it. The reference count for the | |
4614 | SV is set to 1. If C<len> is zero, Perl will compute the length using | |
4615 | strlen(). For efficiency, consider using C<newSVpvn> instead. | |
4616 | ||
4617 | SV* newSVpv(const char* s, STRLEN len) | |
4618 | ||
4619 | =for hackers | |
4620 | Found in file sv.c | |
4621 | ||
4622 | =item newSVpvf | |
4623 | X<newSVpvf> | |
4624 | ||
4625 | Creates a new SV and initializes it with the string formatted like | |
4626 | C<sprintf>. | |
4627 | ||
4628 | SV* newSVpvf(const char* pat, ...) | |
4629 | ||
4630 | =for hackers | |
4631 | Found in file sv.c | |
4632 | ||
4633 | =item newSVpvn | |
4634 | X<newSVpvn> | |
4635 | ||
4636 | Creates a new SV and copies a string into it. The reference count for the | |
4637 | SV is set to 1. Note that if C<len> is zero, Perl will create a zero length | |
4638 | string. You are responsible for ensuring that the source string is at least | |
4639 | C<len> bytes long. If the C<s> argument is NULL the new SV will be undefined. | |
4640 | ||
4641 | SV* newSVpvn(const char* s, STRLEN len) | |
4642 | ||
4643 | =for hackers | |
4644 | Found in file sv.c | |
4645 | ||
4646 | =item newSVpvn_share | |
4647 | X<newSVpvn_share> | |
4648 | ||
4649 | Creates a new SV with its SvPVX_const pointing to a shared string in the string | |
4650 | table. If the string does not already exist in the table, it is created | |
4651 | first. Turns on READONLY and FAKE. The string's hash is stored in the UV | |
4652 | slot of the SV; if the C<hash> parameter is non-zero, that value is used; | |
4653 | otherwise the hash is computed. The idea here is that as the string table | |
4654 | is used for shared hash keys these strings will have SvPVX_const == HeKEY and | |
4655 | hash lookup will avoid string compare. | |
4656 | ||
4657 | SV* newSVpvn_share(const char* s, I32 len, U32 hash) | |
4658 | ||
4659 | =for hackers | |
4660 | Found in file sv.c | |
4661 | ||
4662 | =item newSVrv | |
4663 | X<newSVrv> | |
4664 | ||
4665 | Creates a new SV for the RV, C<rv>, to point to. If C<rv> is not an RV then | |
4666 | it will be upgraded to one. If C<classname> is non-null then the new SV will | |
4667 | be blessed in the specified package. The new SV is returned and its | |
4668 | reference count is 1. | |
4669 | ||
4670 | SV* newSVrv(SV* rv, const char* classname) | |
4671 | ||
4672 | =for hackers | |
4673 | Found in file sv.c | |
4674 | ||
4675 | =item newSVsv | |
4676 | X<newSVsv> | |
4677 | ||
4678 | Creates a new SV which is an exact duplicate of the original SV. | |
4679 | (Uses C<sv_setsv>). | |
4680 | ||
4681 | SV* newSVsv(SV* old) | |
4682 | ||
4683 | =for hackers | |
4684 | Found in file sv.c | |
4685 | ||
4686 | =item newSVuv | |
4687 | X<newSVuv> | |
4688 | ||
4689 | Creates a new SV and copies an unsigned integer into it. | |
4690 | The reference count for the SV is set to 1. | |
4691 | ||
4692 | SV* newSVuv(UV u) | |
4693 | ||
4694 | =for hackers | |
4695 | Found in file sv.c | |
4696 | ||
645c22ef | 4697 | =item sv_2bool |
d8c40edc | 4698 | X<sv_2bool> |
645c22ef DM |
4699 | |
4700 | This function is only called on magical items, and is only used by | |
8cf8f3d1 | 4701 | sv_true() or its macro equivalent. |
645c22ef DM |
4702 | |
4703 | bool sv_2bool(SV* sv) | |
4704 | ||
4705 | =for hackers | |
4706 | Found in file sv.c | |
4707 | ||
4708 | =item sv_2cv | |
d8c40edc | 4709 | X<sv_2cv> |
645c22ef DM |
4710 | |
4711 | Using various gambits, try to get a CV from an SV; in addition, try if | |
4712 | possible to set C<*st> and C<*gvp> to the stash and GV associated with it. | |
9f435386 | 4713 | The flags in C<lref> are passed to sv_fetchsv. |
645c22ef DM |
4714 | |
4715 | CV* sv_2cv(SV* sv, HV** st, GV** gvp, I32 lref) | |
4716 | ||
4717 | =for hackers | |
4718 | Found in file sv.c | |
4719 | ||
4720 | =item sv_2io | |
d8c40edc | 4721 | X<sv_2io> |
645c22ef DM |
4722 | |
4723 | Using various gambits, try to get an IO from an SV: the IO slot if its a | |
4724 | GV; or the recursive result if we're an RV; or the IO slot of the symbol | |
4725 | named after the PV if we're a string. | |
4726 | ||
4727 | IO* sv_2io(SV* sv) | |
4728 | ||
4729 | =for hackers | |
4730 | Found in file sv.c | |
4731 | ||
891f9566 | 4732 | =item sv_2iv_flags |
d8c40edc | 4733 | X<sv_2iv_flags> |
645c22ef | 4734 | |
891f9566 YST |
4735 | Return the integer value of an SV, doing any necessary string |
4736 | conversion. If flags includes SV_GMAGIC, does an mg_get() first. | |
4737 | Normally used via the C<SvIV(sv)> and C<SvIVx(sv)> macros. | |
645c22ef | 4738 | |
891f9566 | 4739 | IV sv_2iv_flags(SV* sv, I32 flags) |
645c22ef DM |
4740 | |
4741 | =for hackers | |
4742 | Found in file sv.c | |
4743 | ||
954c1994 | 4744 | =item sv_2mortal |
d8c40edc | 4745 | X<sv_2mortal> |
954c1994 | 4746 | |
793edb8a JH |
4747 | Marks an existing SV as mortal. The SV will be destroyed "soon", either |
4748 | by an explicit call to FREETMPS, or by an implicit call at places such as | |
b0bc38e6 NC |
4749 | statement boundaries. SvTEMP() is turned on which means that the SV's |
4750 | string buffer can be "stolen" if this SV is copied. See also C<sv_newmortal> | |
4751 | and C<sv_mortalcopy>. | |
954c1994 GS |
4752 | |
4753 | SV* sv_2mortal(SV* sv) | |
4754 | ||
497711e7 GS |
4755 | =for hackers |
4756 | Found in file sv.c | |
4757 | ||
645c22ef | 4758 | =item sv_2nv |
d8c40edc | 4759 | X<sv_2nv> |
645c22ef DM |
4760 | |
4761 | Return the num value of an SV, doing any necessary string or integer | |
4762 | conversion, magic etc. Normally used via the C<SvNV(sv)> and C<SvNVx(sv)> | |
4763 | macros. | |
4764 | ||
4765 | NV sv_2nv(SV* sv) | |
4766 | ||
4767 | =for hackers | |
4768 | Found in file sv.c | |
4769 | ||
451be7b1 | 4770 | =item sv_2pvbyte |
d8c40edc | 4771 | X<sv_2pvbyte> |
451be7b1 DM |
4772 | |
4773 | Return a pointer to the byte-encoded representation of the SV, and set *lp | |
1e54db1a | 4774 | to its length. May cause the SV to be downgraded from UTF-8 as a |
451be7b1 DM |
4775 | side-effect. |
4776 | ||
4777 | Usually accessed via the C<SvPVbyte> macro. | |
4778 | ||
4779 | char* sv_2pvbyte(SV* sv, STRLEN* lp) | |
4780 | ||
4781 | =for hackers | |
4782 | Found in file sv.c | |
4783 | ||
035cbb0e RGS |
4784 | =item sv_2pvutf8 |
4785 | X<sv_2pvutf8> | |
4786 | ||
4787 | Return a pointer to the UTF-8-encoded representation of the SV, and set *lp | |
4788 | to its length. May cause the SV to be upgraded to UTF-8 as a side-effect. | |
4789 | ||
4790 | Usually accessed via the C<SvPVutf8> macro. | |
4791 | ||
4792 | char* sv_2pvutf8(SV* sv, STRLEN* lp) | |
4793 | ||
4794 | =for hackers | |
4795 | Found in file sv.c | |
4796 | ||
645c22ef | 4797 | =item sv_2pv_flags |
d8c40edc | 4798 | X<sv_2pv_flags> |
645c22ef | 4799 | |
ff276b08 | 4800 | Returns a pointer to the string value of an SV, and sets *lp to its length. |
645c22ef DM |
4801 | If flags includes SV_GMAGIC, does an mg_get() first. Coerces sv to a string |
4802 | if necessary. | |
4803 | Normally invoked via the C<SvPV_flags> macro. C<sv_2pv()> and C<sv_2pv_nomg> | |
4804 | usually end up here too. | |
4805 | ||
4806 | char* sv_2pv_flags(SV* sv, STRLEN* lp, I32 flags) | |
4807 | ||
4808 | =for hackers | |
4809 | Found in file sv.c | |
4810 | ||
891f9566 | 4811 | =item sv_2uv_flags |
d8c40edc | 4812 | X<sv_2uv_flags> |
645c22ef DM |
4813 | |
4814 | Return the unsigned integer value of an SV, doing any necessary string | |
891f9566 YST |
4815 | conversion. If flags includes SV_GMAGIC, does an mg_get() first. |
4816 | Normally used via the C<SvUV(sv)> and C<SvUVx(sv)> macros. | |
645c22ef | 4817 | |
891f9566 | 4818 | UV sv_2uv_flags(SV* sv, I32 flags) |
645c22ef DM |
4819 | |
4820 | =for hackers | |
4821 | Found in file sv.c | |
4822 | ||
4823 | =item sv_backoff | |
d8c40edc | 4824 | X<sv_backoff> |
645c22ef DM |
4825 | |
4826 | Remove any string offset. You should normally use the C<SvOOK_off> macro | |
4827 | wrapper instead. | |
4828 | ||
4829 | int sv_backoff(SV* sv) | |
4830 | ||
4831 | =for hackers | |
4832 | Found in file sv.c | |
4833 | ||
954c1994 | 4834 | =item sv_bless |
d8c40edc | 4835 | X<sv_bless> |
954c1994 GS |
4836 | |
4837 | Blesses an SV into a specified package. The SV must be an RV. The package | |
4838 | must be designated by its stash (see C<gv_stashpv()>). The reference count | |
4839 | of the SV is unaffected. | |
4840 | ||
4841 | SV* sv_bless(SV* sv, HV* stash) | |
4842 | ||
497711e7 GS |
4843 | =for hackers |
4844 | Found in file sv.c | |
4845 | ||
954c1994 | 4846 | =item sv_catpv |
d8c40edc | 4847 | X<sv_catpv> |
954c1994 GS |
4848 | |
4849 | Concatenates the string onto the end of the string which is in the SV. | |
1e54db1a JH |
4850 | If the SV has the UTF-8 status set, then the bytes appended should be |
4851 | valid UTF-8. Handles 'get' magic, but not 'set' magic. See C<sv_catpv_mg>. | |
954c1994 GS |
4852 | |
4853 | void sv_catpv(SV* sv, const char* ptr) | |
4854 | ||
497711e7 GS |
4855 | =for hackers |
4856 | Found in file sv.c | |
4857 | ||
954c1994 | 4858 | =item sv_catpvf |
d8c40edc | 4859 | X<sv_catpvf> |
954c1994 | 4860 | |
d5ce4a7c GA |
4861 | Processes its arguments like C<sprintf> and appends the formatted |
4862 | output to an SV. If the appended data contains "wide" characters | |
4863 | (including, but not limited to, SVs with a UTF-8 PV formatted with %s, | |
4864 | and characters >255 formatted with %c), the original SV might get | |
bffc3d17 | 4865 | upgraded to UTF-8. Handles 'get' magic, but not 'set' magic. See |
cdd94ca7 NC |
4866 | C<sv_catpvf_mg>. If the original SV was UTF-8, the pattern should be |
4867 | valid UTF-8; if the original SV was bytes, the pattern should be too. | |
954c1994 GS |
4868 | |
4869 | void sv_catpvf(SV* sv, const char* pat, ...) | |
4870 | ||
497711e7 GS |
4871 | =for hackers |
4872 | Found in file sv.c | |
4873 | ||
954c1994 | 4874 | =item sv_catpvf_mg |
d8c40edc | 4875 | X<sv_catpvf_mg> |
954c1994 GS |
4876 | |
4877 | Like C<sv_catpvf>, but also handles 'set' magic. | |
4878 | ||
4879 | void sv_catpvf_mg(SV *sv, const char* pat, ...) | |
4880 | ||
497711e7 GS |
4881 | =for hackers |
4882 | Found in file sv.c | |
4883 | ||
954c1994 | 4884 | =item sv_catpvn |
d8c40edc | 4885 | X<sv_catpvn> |
954c1994 GS |
4886 | |
4887 | Concatenates the string onto the end of the string which is in the SV. The | |
1e54db1a JH |
4888 | C<len> indicates number of bytes to copy. If the SV has the UTF-8 |
4889 | status set, then the bytes appended should be valid UTF-8. | |
d5ce4a7c | 4890 | Handles 'get' magic, but not 'set' magic. See C<sv_catpvn_mg>. |
954c1994 GS |
4891 | |
4892 | void sv_catpvn(SV* sv, const char* ptr, STRLEN len) | |
4893 | ||
497711e7 GS |
4894 | =for hackers |
4895 | Found in file sv.c | |
4896 | ||
8d6d96c1 | 4897 | =item sv_catpvn_flags |
d8c40edc | 4898 | X<sv_catpvn_flags> |
8d6d96c1 HS |
4899 | |
4900 | Concatenates the string onto the end of the string which is in the SV. The | |
1e54db1a JH |
4901 | C<len> indicates number of bytes to copy. If the SV has the UTF-8 |
4902 | status set, then the bytes appended should be valid UTF-8. | |
8d6d96c1 HS |
4903 | If C<flags> has C<SV_GMAGIC> bit set, will C<mg_get> on C<dsv> if |
4904 | appropriate, else not. C<sv_catpvn> and C<sv_catpvn_nomg> are implemented | |
4905 | in terms of this function. | |
4906 | ||
4907 | void sv_catpvn_flags(SV* sv, const char* ptr, STRLEN len, I32 flags) | |
4908 | ||
4909 | =for hackers | |
4910 | Found in file sv.c | |
4911 | ||
954c1994 | 4912 | =item sv_catpv_mg |
d8c40edc | 4913 | X<sv_catpv_mg> |
954c1994 GS |
4914 | |
4915 | Like C<sv_catpv>, but also handles 'set' magic. | |
4916 | ||
4917 | void sv_catpv_mg(SV *sv, const char *ptr) | |
4918 | ||
497711e7 GS |
4919 | =for hackers |
4920 | Found in file sv.c | |
4921 | ||
954c1994 | 4922 | =item sv_catsv |
d8c40edc | 4923 | X<sv_catsv> |
954c1994 | 4924 | |
1aa99e6b IH |
4925 | Concatenates the string from SV C<ssv> onto the end of the string in |
4926 | SV C<dsv>. Modifies C<dsv> but not C<ssv>. Handles 'get' magic, but | |
4927 | not 'set' magic. See C<sv_catsv_mg>. | |
954c1994 GS |
4928 | |
4929 | void sv_catsv(SV* dsv, SV* ssv) | |
4930 | ||
497711e7 GS |
4931 | =for hackers |
4932 | Found in file sv.c | |
4933 | ||
8d6d96c1 | 4934 | =item sv_catsv_flags |
d8c40edc | 4935 | X<sv_catsv_flags> |
8d6d96c1 HS |
4936 | |
4937 | Concatenates the string from SV C<ssv> onto the end of the string in | |
4938 | SV C<dsv>. Modifies C<dsv> but not C<ssv>. If C<flags> has C<SV_GMAGIC> | |
4939 | bit set, will C<mg_get> on the SVs if appropriate, else not. C<sv_catsv> | |
4940 | and C<sv_catsv_nomg> are implemented in terms of this function. | |
4941 | ||
4942 | void sv_catsv_flags(SV* dsv, SV* ssv, I32 flags) | |
4943 | ||
4944 | =for hackers | |
4945 | Found in file sv.c | |
4946 | ||
954c1994 | 4947 | =item sv_chop |
d8c40edc | 4948 | X<sv_chop> |
954c1994 | 4949 | |
1c846c1f | 4950 | Efficient removal of characters from the beginning of the string buffer. |
954c1994 GS |
4951 | SvPOK(sv) must be true and the C<ptr> must be a pointer to somewhere inside |
4952 | the string buffer. The C<ptr> becomes the first character of the adjusted | |
645c22ef | 4953 | string. Uses the "OOK hack". |
3f7c398e | 4954 | Beware: after this function returns, C<ptr> and SvPVX_const(sv) may no longer |
5c3943b6 | 4955 | refer to the same chunk of data. |
954c1994 | 4956 | |
f54cb97a | 4957 | void sv_chop(SV* sv, const char* ptr) |
954c1994 | 4958 | |
497711e7 GS |
4959 | =for hackers |
4960 | Found in file sv.c | |
4961 | ||
c461cf8f | 4962 | =item sv_clear |
d8c40edc | 4963 | X<sv_clear> |
c461cf8f | 4964 | |
645c22ef DM |
4965 | Clear an SV: call any destructors, free up any memory used by the body, |
4966 | and free the body itself. The SV's head is I<not> freed, although | |
4967 | its type is set to all 1's so that it won't inadvertently be assumed | |
4968 | to be live during global destruction etc. | |
4969 | This function should only be called when REFCNT is zero. Most of the time | |
4970 | you'll want to call C<sv_free()> (or its macro wrapper C<SvREFCNT_dec>) | |
4971 | instead. | |
c461cf8f JH |
4972 | |
4973 | void sv_clear(SV* sv) | |
4974 | ||
4975 | =for hackers | |
4976 | Found in file sv.c | |
4977 | ||
954c1994 | 4978 | =item sv_cmp |
d8c40edc | 4979 | X<sv_cmp> |
954c1994 GS |
4980 | |
4981 | Compares the strings in two SVs. Returns -1, 0, or 1 indicating whether the | |
4982 | string in C<sv1> is less than, equal to, or greater than the string in | |
645c22ef DM |
4983 | C<sv2>. Is UTF-8 and 'use bytes' aware, handles get magic, and will |
4984 | coerce its args to strings if necessary. See also C<sv_cmp_locale>. | |
954c1994 GS |
4985 | |
4986 | I32 sv_cmp(SV* sv1, SV* sv2) | |
4987 | ||
497711e7 GS |
4988 | =for hackers |
4989 | Found in file sv.c | |
4990 | ||
c461cf8f | 4991 | =item sv_cmp_locale |
d8c40edc | 4992 | X<sv_cmp_locale> |
c461cf8f | 4993 | |
645c22ef DM |
4994 | Compares the strings in two SVs in a locale-aware manner. Is UTF-8 and |
4995 | 'use bytes' aware, handles get magic, and will coerce its args to strings | |
4996 | if necessary. See also C<sv_cmp_locale>. See also C<sv_cmp>. | |
c461cf8f JH |
4997 | |
4998 | I32 sv_cmp_locale(SV* sv1, SV* sv2) | |
4999 | ||
5000 | =for hackers | |
5001 | Found in file sv.c | |
5002 | ||
645c22ef | 5003 | =item sv_collxfrm |
d8c40edc | 5004 | X<sv_collxfrm> |
645c22ef DM |
5005 | |
5006 | Add Collate Transform magic to an SV if it doesn't already have it. | |
5007 | ||
5008 | Any scalar variable may carry PERL_MAGIC_collxfrm magic that contains the | |
5009 | scalar data of the variable, but transformed to such a format that a normal | |
5010 | memory comparison can be used to compare the data according to the locale | |
5011 | settings. | |
5012 | ||
5013 | char* sv_collxfrm(SV* sv, STRLEN* nxp) | |
5014 | ||
5015 | =for hackers | |
5016 | Found in file sv.c | |
5017 | ||
6050d10e | 5018 | =item sv_copypv |
d8c40edc | 5019 | X<sv_copypv> |
6050d10e JP |
5020 | |
5021 | Copies a stringified representation of the source SV into the | |
5022 | destination SV. Automatically performs any necessary mg_get and | |
9ede5bc8 | 5023 | coercion of numeric values into strings. Guaranteed to preserve |
6050d10e | 5024 | UTF-8 flag even from overloaded objects. Similar in nature to |
9ede5bc8 DM |
5025 | sv_2pv[_flags] but operates directly on an SV instead of just the |
5026 | string. Mostly uses sv_2pv_flags to do its work, except when that | |
6050d10e JP |
5027 | would lose the UTF-8'ness of the PV. |
5028 | ||
5029 | void sv_copypv(SV* dsv, SV* ssv) | |
5030 | ||
5031 | =for hackers | |
5032 | Found in file sv.c | |
5033 | ||
954c1994 | 5034 | =item sv_dec |
d8c40edc | 5035 | X<sv_dec> |
954c1994 | 5036 | |
645c22ef DM |
5037 | Auto-decrement of the value in the SV, doing string to numeric conversion |
5038 | if necessary. Handles 'get' magic. | |
954c1994 GS |
5039 | |
5040 | void sv_dec(SV* sv) | |
5041 | ||
497711e7 GS |
5042 | =for hackers |
5043 | Found in file sv.c | |
5044 | ||
954c1994 | 5045 | =item sv_eq |
d8c40edc | 5046 | X<sv_eq> |
954c1994 GS |
5047 | |
5048 | Returns a boolean indicating whether the strings in the two SVs are | |
645c22ef DM |
5049 | identical. Is UTF-8 and 'use bytes' aware, handles get magic, and will |
5050 | coerce its args to strings if necessary. | |
954c1994 GS |
5051 | |
5052 | I32 sv_eq(SV* sv1, SV* sv2) | |
5053 | ||
497711e7 GS |
5054 | =for hackers |
5055 | Found in file sv.c | |
5056 | ||
645c22ef | 5057 | =item sv_force_normal_flags |
d8c40edc | 5058 | X<sv_force_normal_flags> |
645c22ef DM |
5059 | |
5060 | Undo various types of fakery on an SV: if the PV is a shared string, make | |
5061 | a private copy; if we're a ref, stop refing; if we're a glob, downgrade to | |
765f542d NC |
5062 | an xpvmg; if we're a copy-on-write scalar, this is the on-write time when |
5063 | we do the copy, and is also used locally. If C<SV_COW_DROP_PV> is set | |
5064 | then a copy-on-write scalar drops its PV buffer (if any) and becomes | |
5065 | SvPOK_off rather than making a copy. (Used where this scalar is about to be | |
d3050d9d | 5066 | set to some other value.) In addition, the C<flags> parameter gets passed to |
765f542d NC |
5067 | C<sv_unref_flags()> when unrefing. C<sv_force_normal> calls this function |
5068 | with flags set to 0. | |
645c22ef DM |
5069 | |
5070 | void sv_force_normal_flags(SV *sv, U32 flags) | |
5071 | ||
5072 | =for hackers | |
5073 | Found in file sv.c | |
5074 | ||
c461cf8f | 5075 | =item sv_free |
d8c40edc | 5076 | X<sv_free> |
c461cf8f | 5077 | |
645c22ef DM |
5078 | Decrement an SV's reference count, and if it drops to zero, call |
5079 | C<sv_clear> to invoke destructors and free up any memory used by | |
5080 | the body; finally, deallocate the SV's head itself. | |
5081 | Normally called via a wrapper macro C<SvREFCNT_dec>. | |
c461cf8f JH |
5082 | |
5083 | void sv_free(SV* sv) | |
5084 | ||
5085 | =for hackers | |
5086 | Found in file sv.c | |
5087 | ||
5088 | =item sv_gets | |
d8c40edc | 5089 | X<sv_gets> |
c461cf8f JH |
5090 | |
5091 | Get a line from the filehandle and store it into the SV, optionally | |
5092 | appending to the currently-stored string. | |
5093 | ||
5094 | char* sv_gets(SV* sv, PerlIO* fp, I32 append) | |
5095 | ||
5096 | =for hackers | |
5097 | Found in file sv.c | |
5098 | ||
954c1994 | 5099 | =item sv_grow |
d8c40edc | 5100 | X<sv_grow> |
954c1994 | 5101 | |
645c22ef DM |
5102 | Expands the character buffer in the SV. If necessary, uses C<sv_unref> and |
5103 | upgrades the SV to C<SVt_PV>. Returns a pointer to the character buffer. | |
5104 | Use the C<SvGROW> wrapper instead. | |
954c1994 GS |
5105 | |
5106 | char* sv_grow(SV* sv, STRLEN newlen) | |
5107 | ||
497711e7 GS |
5108 | =for hackers |
5109 | Found in file sv.c | |
5110 | ||
954c1994 | 5111 | =item sv_inc |
d8c40edc | 5112 | X<sv_inc> |
954c1994 | 5113 | |
645c22ef DM |
5114 | Auto-increment of the value in the SV, doing string to numeric conversion |
5115 | if necessary. Handles 'get' magic. | |
954c1994 GS |
5116 | |
5117 | void sv_inc(SV* sv) | |
5118 | ||
497711e7 GS |
5119 | =for hackers |
5120 | Found in file sv.c | |
5121 | ||
954c1994 | 5122 | =item sv_insert |
d8c40edc | 5123 | X<sv_insert> |
954c1994 GS |
5124 | |
5125 | Inserts a string at the specified offset/length within the SV. Similar to | |
5126 | the Perl substr() function. | |
5127 | ||
e1ec3a88 | 5128 | void sv_insert(SV* bigsv, STRLEN offset, STRLEN len, const char* little, STRLEN littlelen) |
954c1994 | 5129 | |
497711e7 GS |
5130 | =for hackers |
5131 | Found in file sv.c | |
5132 | ||
954c1994 | 5133 | =item sv_isa |
d8c40edc | 5134 | X<sv_isa> |
954c1994 GS |
5135 | |
5136 | Returns a boolean indicating whether the SV is blessed into the specified | |
5137 | class. This does not check for subtypes; use C<sv_derived_from> to verify | |
5138 | an inheritance relationship. | |
5139 | ||
5140 | int sv_isa(SV* sv, const char* name) | |
5141 | ||
497711e7 GS |
5142 | =for hackers |
5143 | Found in file sv.c | |
5144 | ||
954c1994 | 5145 | =item sv_isobject |
d8c40edc | 5146 | X<sv_isobject> |
954c1994 GS |
5147 | |
5148 | Returns a boolean indicating whether the SV is an RV pointing to a blessed | |
5149 | object. If the SV is not an RV, or if the object is not blessed, then this | |
5150 | will return false. | |
5151 | ||
5152 | int sv_isobject(SV* sv) | |
5153 | ||
497711e7 GS |
5154 | =for hackers |
5155 | Found in file sv.c | |
5156 | ||
954c1994 | 5157 | =item sv_len |
d8c40edc | 5158 | X<sv_len> |
954c1994 | 5159 | |
645c22ef DM |
5160 | Returns the length of the string in the SV. Handles magic and type |
5161 | coercion. See also C<SvCUR>, which gives raw access to the xpv_cur slot. | |
954c1994 GS |
5162 | |
5163 | STRLEN sv_len(SV* sv) | |
5164 | ||
497711e7 GS |
5165 | =for hackers |
5166 | Found in file sv.c | |
5167 | ||
c461cf8f | 5168 | =item sv_len_utf8 |
d8c40edc | 5169 | X<sv_len_utf8> |
c461cf8f JH |
5170 | |
5171 | Returns the number of characters in the string in an SV, counting wide | |
1e54db1a | 5172 | UTF-8 bytes as a single character. Handles magic and type coercion. |
c461cf8f JH |
5173 | |
5174 | STRLEN sv_len_utf8(SV* sv) | |
5175 | ||
5176 | =for hackers | |
5177 | Found in file sv.c | |
5178 | ||
954c1994 | 5179 | =item sv_magic |
d8c40edc | 5180 | X<sv_magic> |
954c1994 | 5181 | |
645c22ef DM |
5182 | Adds magic to an SV. First upgrades C<sv> to type C<SVt_PVMG> if necessary, |
5183 | then adds a new magic item of type C<how> to the head of the magic list. | |
5184 | ||
2d8d5d5a SH |
5185 | See C<sv_magicext> (which C<sv_magic> now calls) for a description of the |
5186 | handling of the C<name> and C<namlen> arguments. | |
5187 | ||
4509d3fb SB |
5188 | You need to use C<sv_magicext> to add magic to SvREADONLY SVs and also |
5189 | to add more than one instance of the same 'how'. | |
5190 | ||
954c1994 GS |
5191 | void sv_magic(SV* sv, SV* obj, int how, const char* name, I32 namlen) |
5192 | ||
497711e7 GS |
5193 | =for hackers |
5194 | Found in file sv.c | |
5195 | ||
a4f1a029 | 5196 | =item sv_magicext |
d8c40edc | 5197 | X<sv_magicext> |
a4f1a029 NIS |
5198 | |
5199 | Adds magic to an SV, upgrading it if necessary. Applies the | |
2d8d5d5a | 5200 | supplied vtable and returns a pointer to the magic added. |
a4f1a029 | 5201 | |
2d8d5d5a SH |
5202 | Note that C<sv_magicext> will allow things that C<sv_magic> will not. |
5203 | In particular, you can add magic to SvREADONLY SVs, and add more than | |
5204 | one instance of the same 'how'. | |
a4f1a029 | 5205 | |
2d8d5d5a SH |
5206 | If C<namlen> is greater than zero then a C<savepvn> I<copy> of C<name> is |
5207 | stored, if C<namlen> is zero then C<name> is stored as-is and - as another | |
5208 | special case - if C<(name && namlen == HEf_SVKEY)> then C<name> is assumed | |
5209 | to contain an C<SV*> and is stored as-is with its REFCNT incremented. | |
a4f1a029 | 5210 | |
2d8d5d5a | 5211 | (This is now used as a subroutine by C<sv_magic>.) |
a4f1a029 | 5212 | |
92e67595 | 5213 | MAGIC * sv_magicext(SV* sv, SV* obj, int how, MGVTBL *vtbl, const char* name, I32 namlen) |
a4f1a029 NIS |
5214 | |
5215 | =for hackers | |
5216 | Found in file sv.c | |
5217 | ||
954c1994 | 5218 | =item sv_mortalcopy |
d8c40edc | 5219 | X<sv_mortalcopy> |
954c1994 | 5220 | |
645c22ef | 5221 | Creates a new SV which is a copy of the original SV (using C<sv_setsv>). |
793edb8a JH |
5222 | The new SV is marked as mortal. It will be destroyed "soon", either by an |
5223 | explicit call to FREETMPS, or by an implicit call at places such as | |
5224 | statement boundaries. See also C<sv_newmortal> and C<sv_2mortal>. | |
954c1994 GS |
5225 | |
5226 | SV* sv_mortalcopy(SV* oldsv) | |
5227 | ||
497711e7 GS |
5228 | =for hackers |
5229 | Found in file sv.c | |
5230 | ||
954c1994 | 5231 | =item sv_newmortal |
d8c40edc | 5232 | X<sv_newmortal> |
954c1994 | 5233 | |
645c22ef | 5234 | Creates a new null SV which is mortal. The reference count of the SV is |
793edb8a JH |
5235 | set to 1. It will be destroyed "soon", either by an explicit call to |
5236 | FREETMPS, or by an implicit call at places such as statement boundaries. | |
5237 | See also C<sv_mortalcopy> and C<sv_2mortal>. | |
954c1994 GS |
5238 | |
5239 | SV* sv_newmortal() | |
5240 | ||
497711e7 GS |
5241 | =for hackers |
5242 | Found in file sv.c | |
5243 | ||
645c22ef | 5244 | =item sv_newref |
d8c40edc | 5245 | X<sv_newref> |
645c22ef DM |
5246 | |
5247 | Increment an SV's reference count. Use the C<SvREFCNT_inc()> wrapper | |
5248 | instead. | |
5249 | ||
5250 | SV* sv_newref(SV* sv) | |
5251 | ||
5252 | =for hackers | |
5253 | Found in file sv.c | |
5254 | ||
645c22ef | 5255 | =item sv_pos_b2u |
d8c40edc | 5256 | X<sv_pos_b2u> |
645c22ef DM |
5257 | |
5258 | Converts the value pointed to by offsetp from a count of bytes from the | |
1e54db1a | 5259 | start of the string, to a count of the equivalent number of UTF-8 chars. |
645c22ef DM |
5260 | Handles magic and type coercion. |
5261 | ||
5262 | void sv_pos_b2u(SV* sv, I32* offsetp) | |
5263 | ||
5264 | =for hackers | |
5265 | Found in file sv.c | |
5266 | ||
5267 | =item sv_pos_u2b | |
d8c40edc | 5268 | X<sv_pos_u2b> |
645c22ef | 5269 | |
1e54db1a | 5270 | Converts the value pointed to by offsetp from a count of UTF-8 chars from |
645c22ef DM |
5271 | the start of the string, to a count of the equivalent number of bytes; if |
5272 | lenp is non-zero, it does the same to lenp, but this time starting from | |
5273 | the offset, rather than from the start of the string. Handles magic and | |
5274 | type coercion. | |
5275 | ||
5276 | void sv_pos_u2b(SV* sv, I32* offsetp, I32* lenp) | |
5277 | ||
5278 | =for hackers | |
5279 | Found in file sv.c | |
5280 | ||
645c22ef | 5281 | =item sv_pvbyten_force |
d8c40edc | 5282 | X<sv_pvbyten_force> |
645c22ef | 5283 | |
9244d4ad | 5284 | The backend for the C<SvPVbytex_force> macro. Always use the macro instead. |
645c22ef DM |
5285 | |
5286 | char* sv_pvbyten_force(SV* sv, STRLEN* lp) | |
5287 | ||
5288 | =for hackers | |
5289 | Found in file sv.c | |
5290 | ||
c461cf8f | 5291 | =item sv_pvn_force |
d8c40edc | 5292 | X<sv_pvn_force> |
c461cf8f JH |
5293 | |
5294 | Get a sensible string out of the SV somehow. | |
645c22ef DM |
5295 | A private implementation of the C<SvPV_force> macro for compilers which |
5296 | can't cope with complex macro expressions. Always use the macro instead. | |
c461cf8f JH |
5297 | |
5298 | char* sv_pvn_force(SV* sv, STRLEN* lp) | |
5299 | ||
5300 | =for hackers | |
5301 | Found in file sv.c | |
5302 | ||
8d6d96c1 | 5303 | =item sv_pvn_force_flags |
d8c40edc | 5304 | X<sv_pvn_force_flags> |
8d6d96c1 HS |
5305 | |
5306 | Get a sensible string out of the SV somehow. | |
5307 | If C<flags> has C<SV_GMAGIC> bit set, will C<mg_get> on C<sv> if | |
5308 | appropriate, else not. C<sv_pvn_force> and C<sv_pvn_force_nomg> are | |
5309 | implemented in terms of this function. | |
645c22ef DM |
5310 | You normally want to use the various wrapper macros instead: see |
5311 | C<SvPV_force> and C<SvPV_force_nomg> | |
8d6d96c1 HS |
5312 | |
5313 | char* sv_pvn_force_flags(SV* sv, STRLEN* lp, I32 flags) | |
5314 | ||
5315 | =for hackers | |
5316 | Found in file sv.c | |
5317 | ||
c461cf8f | 5318 | =item sv_pvutf8n_force |
d8c40edc | 5319 | X<sv_pvutf8n_force> |
c461cf8f | 5320 | |
9244d4ad | 5321 | The backend for the C<SvPVutf8x_force> macro. Always use the macro instead. |
c461cf8f JH |
5322 | |
5323 | char* sv_pvutf8n_force(SV* sv, STRLEN* lp) | |
5324 | ||
5325 | =for hackers | |
5326 | Found in file sv.c | |
5327 | ||
5328 | =item sv_reftype | |
d8c40edc | 5329 | X<sv_reftype> |
c461cf8f JH |
5330 | |
5331 | Returns a string describing what the SV is a reference to. | |
5332 | ||
1cb0ed9b | 5333 | char* sv_reftype(const SV* sv, int ob) |
c461cf8f JH |
5334 | |
5335 | =for hackers | |
5336 | Found in file sv.c | |
5337 | ||
5338 | =item sv_replace | |
d8c40edc | 5339 | X<sv_replace> |
c461cf8f JH |
5340 | |
5341 | Make the first argument a copy of the second, then delete the original. | |
645c22ef DM |
5342 | The target SV physically takes over ownership of the body of the source SV |
5343 | and inherits its flags; however, the target keeps any magic it owns, | |
5344 | and any magic in the source is discarded. | |
ff276b08 | 5345 | Note that this is a rather specialist SV copying operation; most of the |
645c22ef | 5346 | time you'll want to use C<sv_setsv> or one of its many macro front-ends. |
c461cf8f JH |
5347 | |
5348 | void sv_replace(SV* sv, SV* nsv) | |
5349 | ||
5350 | =for hackers | |
5351 | Found in file sv.c | |
5352 | ||
451be7b1 | 5353 | =item sv_reset |
d8c40edc | 5354 | X<sv_reset> |
451be7b1 DM |
5355 | |
5356 | Underlying implementation for the C<reset> Perl function. | |
5357 | Note that the perl-level function is vaguely deprecated. | |
5358 | ||
e1ec3a88 | 5359 | void sv_reset(const char* s, HV* stash) |
451be7b1 DM |
5360 | |
5361 | =for hackers | |
5362 | Found in file sv.c | |
5363 | ||
c461cf8f | 5364 | =item sv_rvweaken |
d8c40edc | 5365 | X<sv_rvweaken> |
c461cf8f | 5366 | |
645c22ef DM |
5367 | Weaken a reference: set the C<SvWEAKREF> flag on this RV; give the |
5368 | referred-to SV C<PERL_MAGIC_backref> magic if it hasn't already; and | |
5369 | push a back-reference to this RV onto the array of backreferences | |
5370 | associated with that magic. | |
c461cf8f JH |
5371 | |
5372 | SV* sv_rvweaken(SV *sv) | |
5373 | ||
5374 | =for hackers | |
5375 | Found in file sv.c | |
5376 | ||
954c1994 | 5377 | =item sv_setiv |
d8c40edc | 5378 | X<sv_setiv> |
954c1994 | 5379 | |
645c22ef DM |
5380 | Copies an integer into the given SV, upgrading first if necessary. |
5381 | Does not handle 'set' magic. See also C<sv_setiv_mg>. | |
954c1994 GS |
5382 | |
5383 | void sv_setiv(SV* sv, IV num) | |
5384 | ||
497711e7 GS |
5385 | =for hackers |
5386 | Found in file sv.c | |
5387 | ||
954c1994 | 5388 | =item sv_setiv_mg |
d8c40edc | 5389 | X<sv_setiv_mg> |
954c1994 GS |
5390 | |
5391 | Like C<sv_setiv>, but also handles 'set' magic. | |
5392 | ||
5393 | void sv_setiv_mg(SV *sv, IV i) | |
5394 | ||
497711e7 GS |
5395 | =for hackers |
5396 | Found in file sv.c | |
5397 | ||
954c1994 | 5398 | =item sv_setnv |
d8c40edc | 5399 | X<sv_setnv> |
954c1994 | 5400 | |
645c22ef DM |
5401 | Copies a double into the given SV, upgrading first if necessary. |
5402 | Does not handle 'set' magic. See also C<sv_setnv_mg>. | |
954c1994 GS |
5403 | |
5404 | void sv_setnv(SV* sv, NV num) | |
5405 | ||
497711e7 GS |
5406 | =for hackers |
5407 | Found in file sv.c | |
5408 | ||
954c1994 | 5409 | =item sv_setnv_mg |
d8c40edc | 5410 | X<sv_setnv_mg> |
954c1994 GS |
5411 | |
5412 | Like C<sv_setnv>, but also handles 'set' magic. | |
5413 | ||
5414 | void sv_setnv_mg(SV *sv, NV num) | |
5415 | ||
497711e7 GS |
5416 | =for hackers |
5417 | Found in file sv.c | |
5418 | ||
954c1994 | 5419 | =item sv_setpv |
d8c40edc | 5420 | X<sv_setpv> |
954c1994 GS |
5421 | |
5422 | Copies a string into an SV. The string must be null-terminated. Does not | |
5423 | handle 'set' magic. See C<sv_setpv_mg>. | |
5424 | ||
5425 | void sv_setpv(SV* sv, const char* ptr) | |
5426 | ||
497711e7 GS |
5427 | =for hackers |
5428 | Found in file sv.c | |
5429 | ||
954c1994 | 5430 | =item sv_setpvf |
d8c40edc | 5431 | X<sv_setpvf> |
954c1994 | 5432 | |
bffc3d17 SH |
5433 | Works like C<sv_catpvf> but copies the text into the SV instead of |
5434 | appending it. Does not handle 'set' magic. See C<sv_setpvf_mg>. | |
954c1994 GS |
5435 | |
5436 | void sv_setpvf(SV* sv, const char* pat, ...) | |
5437 | ||
497711e7 GS |
5438 | =for hackers |
5439 | Found in file sv.c | |
5440 | ||
954c1994 | 5441 | =item sv_setpvf_mg |
d8c40edc | 5442 | X<sv_setpvf_mg> |
954c1994 GS |
5443 | |
5444 | Like C<sv_setpvf>, but also handles 'set' magic. | |
5445 | ||
5446 | void sv_setpvf_mg(SV *sv, const char* pat, ...) | |
5447 | ||
497711e7 GS |
5448 | =for hackers |
5449 | Found in file sv.c | |
5450 | ||
2307c6d0 | 5451 | =item sv_setpviv |
d8c40edc | 5452 | X<sv_setpviv> |
2307c6d0 SB |
5453 | |
5454 | Copies an integer into the given SV, also updating its string value. | |
5455 | Does not handle 'set' magic. See C<sv_setpviv_mg>. | |
5456 | ||
5457 | void sv_setpviv(SV* sv, IV num) | |
5458 | ||
5459 | =for hackers | |
5460 | Found in file sv.c | |
5461 | ||
5462 | =item sv_setpviv_mg | |
d8c40edc | 5463 | X<sv_setpviv_mg> |
2307c6d0 SB |
5464 | |
5465 | Like C<sv_setpviv>, but also handles 'set' magic. | |
5466 | ||
5467 | void sv_setpviv_mg(SV *sv, IV iv) | |
5468 | ||
5469 | =for hackers | |
5470 | Found in file sv.c | |
5471 | ||
954c1994 | 5472 | =item sv_setpvn |
d8c40edc | 5473 | X<sv_setpvn> |
954c1994 GS |
5474 | |
5475 | Copies a string into an SV. The C<len> parameter indicates the number of | |
9e09f5f2 MHM |
5476 | bytes to be copied. If the C<ptr> argument is NULL the SV will become |
5477 | undefined. Does not handle 'set' magic. See C<sv_setpvn_mg>. | |
954c1994 GS |
5478 | |
5479 | void sv_setpvn(SV* sv, const char* ptr, STRLEN len) | |
5480 | ||
497711e7 GS |
5481 | =for hackers |
5482 | Found in file sv.c | |
5483 | ||
954c1994 | 5484 | =item sv_setpvn_mg |
d8c40edc | 5485 | X<sv_setpvn_mg> |
954c1994 GS |
5486 | |
5487 | Like C<sv_setpvn>, but also handles 'set' magic. | |
5488 | ||
5489 | void sv_setpvn_mg(SV *sv, const char *ptr, STRLEN len) | |
5490 | ||
497711e7 GS |
5491 | =for hackers |
5492 | Found in file sv.c | |
5493 | ||
954c1994 | 5494 | =item sv_setpv_mg |
d8c40edc | 5495 | X<sv_setpv_mg> |
954c1994 GS |
5496 | |
5497 | Like C<sv_setpv>, but also handles 'set' magic. | |
5498 | ||
5499 | void sv_setpv_mg(SV *sv, const char *ptr) | |
5500 | ||
497711e7 GS |
5501 | =for hackers |
5502 | Found in file sv.c | |
5503 | ||
954c1994 | 5504 | =item sv_setref_iv |
d8c40edc | 5505 | X<sv_setref_iv> |
954c1994 GS |
5506 | |
5507 | Copies an integer into a new SV, optionally blessing the SV. The C<rv> | |
5508 | argument will be upgraded to an RV. That RV will be modified to point to | |
5509 | the new SV. The C<classname> argument indicates the package for the | |
bd61b366 | 5510 | blessing. Set C<classname> to C<NULL> to avoid the blessing. The new SV |
d34c2299 | 5511 | will have a reference count of 1, and the RV will be returned. |
954c1994 GS |
5512 | |
5513 | SV* sv_setref_iv(SV* rv, const char* classname, IV iv) | |
5514 | ||
497711e7 GS |
5515 | =for hackers |
5516 | Found in file sv.c | |
5517 | ||
954c1994 | 5518 | =item sv_setref_nv |
d8c40edc | 5519 | X<sv_setref_nv> |
954c1994 GS |
5520 | |
5521 | Copies a double into a new SV, optionally blessing the SV. The C<rv> | |
5522 | argument will be upgraded to an RV. That RV will be modified to point to | |
5523 | the new SV. The C<classname> argument indicates the package for the | |
bd61b366 | 5524 | blessing. Set C<classname> to C<NULL> to avoid the blessing. The new SV |
d34c2299 | 5525 | will have a reference count of 1, and the RV will be returned. |
954c1994 GS |
5526 | |
5527 | SV* sv_setref_nv(SV* rv, const char* classname, NV nv) | |
5528 | ||
497711e7 GS |
5529 | =for hackers |
5530 | Found in file sv.c | |
5531 | ||
954c1994 | 5532 | =item sv_setref_pv |
d8c40edc | 5533 | X<sv_setref_pv> |
954c1994 GS |
5534 | |
5535 | Copies a pointer into a new SV, optionally blessing the SV. The C<rv> | |
5536 | argument will be upgraded to an RV. That RV will be modified to point to | |
5537 | the new SV. If the C<pv> argument is NULL then C<PL_sv_undef> will be placed | |
5538 | into the SV. The C<classname> argument indicates the package for the | |
bd61b366 | 5539 | blessing. Set C<classname> to C<NULL> to avoid the blessing. The new SV |
d34c2299 | 5540 | will have a reference count of 1, and the RV will be returned. |
954c1994 GS |
5541 | |
5542 | Do not use with other Perl types such as HV, AV, SV, CV, because those | |
5543 | objects will become corrupted by the pointer copy process. | |
5544 | ||
5545 | Note that C<sv_setref_pvn> copies the string while this copies the pointer. | |
5546 | ||
5547 | SV* sv_setref_pv(SV* rv, const char* classname, void* pv) | |
5548 | ||
497711e7 GS |
5549 | =for hackers |
5550 | Found in file sv.c | |
5551 | ||
954c1994 | 5552 | =item sv_setref_pvn |
d8c40edc | 5553 | X<sv_setref_pvn> |
954c1994 GS |
5554 | |
5555 | Copies a string into a new SV, optionally blessing the SV. The length of the | |
5556 | string must be specified with C<n>. The C<rv> argument will be upgraded to | |
5557 | an RV. That RV will be modified to point to the new SV. The C<classname> | |
5558 | argument indicates the package for the blessing. Set C<classname> to | |
bd61b366 | 5559 | C<NULL> to avoid the blessing. The new SV will have a reference count |
d34c2299 | 5560 | of 1, and the RV will be returned. |
954c1994 GS |
5561 | |
5562 | Note that C<sv_setref_pv> copies the pointer while this copies the string. | |
5563 | ||
1b6737cc | 5564 | SV* sv_setref_pvn(SV* rv, const char* classname, const char* pv, STRLEN n) |
954c1994 | 5565 | |
497711e7 GS |
5566 | =for hackers |
5567 | Found in file sv.c | |
5568 | ||
e1c57cef | 5569 | =item sv_setref_uv |
d8c40edc | 5570 | X<sv_setref_uv> |
e1c57cef JH |
5571 | |
5572 | Copies an unsigned integer into a new SV, optionally blessing the SV. The C<rv> | |
5573 | argument will be upgraded to an RV. That RV will be modified to point to | |
5574 | the new SV. The C<classname> argument indicates the package for the | |
bd61b366 | 5575 | blessing. Set C<classname> to C<NULL> to avoid the blessing. The new SV |
d34c2299 | 5576 | will have a reference count of 1, and the RV will be returned. |
e1c57cef JH |
5577 | |
5578 | SV* sv_setref_uv(SV* rv, const char* classname, UV uv) | |
5579 | ||
5580 | =for hackers | |
5581 | Found in file sv.c | |
5582 | ||
954c1994 | 5583 | =item sv_setsv |
d8c40edc | 5584 | X<sv_setsv> |
954c1994 | 5585 | |
645c22ef DM |
5586 | Copies the contents of the source SV C<ssv> into the destination SV |
5587 | C<dsv>. The source SV may be destroyed if it is mortal, so don't use this | |
5588 | function if the source SV needs to be reused. Does not handle 'set' magic. | |
5589 | Loosely speaking, it performs a copy-by-value, obliterating any previous | |
5590 | content of the destination. | |
5591 | ||
5592 | You probably want to use one of the assortment of wrappers, such as | |
5593 | C<SvSetSV>, C<SvSetSV_nosteal>, C<SvSetMagicSV> and | |
5594 | C<SvSetMagicSV_nosteal>. | |
5595 | ||
954c1994 GS |
5596 | void sv_setsv(SV* dsv, SV* ssv) |
5597 | ||
497711e7 GS |
5598 | =for hackers |
5599 | Found in file sv.c | |
5600 | ||
8d6d96c1 | 5601 | =item sv_setsv_flags |
d8c40edc | 5602 | X<sv_setsv_flags> |
8d6d96c1 | 5603 | |
645c22ef DM |
5604 | Copies the contents of the source SV C<ssv> into the destination SV |
5605 | C<dsv>. The source SV may be destroyed if it is mortal, so don't use this | |
5606 | function if the source SV needs to be reused. Does not handle 'set' magic. | |
5607 | Loosely speaking, it performs a copy-by-value, obliterating any previous | |
5608 | content of the destination. | |
5609 | If the C<flags> parameter has the C<SV_GMAGIC> bit set, will C<mg_get> on | |
2d8d5d5a SH |
5610 | C<ssv> if appropriate, else not. If the C<flags> parameter has the |
5611 | C<NOSTEAL> bit set then the buffers of temps will not be stolen. <sv_setsv> | |
5612 | and C<sv_setsv_nomg> are implemented in terms of this function. | |
645c22ef DM |
5613 | |
5614 | You probably want to use one of the assortment of wrappers, such as | |
5615 | C<SvSetSV>, C<SvSetSV_nosteal>, C<SvSetMagicSV> and | |
5616 | C<SvSetMagicSV_nosteal>. | |
5617 | ||
5618 | This is the primary function for copying scalars, and most other | |
5619 | copy-ish functions and macros use this underneath. | |
8d6d96c1 HS |
5620 | |
5621 | void sv_setsv_flags(SV* dsv, SV* ssv, I32 flags) | |
5622 | ||
5623 | =for hackers | |
5624 | Found in file sv.c | |
5625 | ||
954c1994 | 5626 | =item sv_setsv_mg |
d8c40edc | 5627 | X<sv_setsv_mg> |
954c1994 GS |
5628 | |
5629 | Like C<sv_setsv>, but also handles 'set' magic. | |
5630 | ||
5631 | void sv_setsv_mg(SV *dstr, SV *sstr) | |
5632 | ||
497711e7 GS |
5633 | =for hackers |
5634 | Found in file sv.c | |
5635 | ||
954c1994 | 5636 | =item sv_setuv |
d8c40edc | 5637 | X<sv_setuv> |
954c1994 | 5638 | |
645c22ef DM |
5639 | Copies an unsigned integer into the given SV, upgrading first if necessary. |
5640 | Does not handle 'set' magic. See also C<sv_setuv_mg>. | |
954c1994 GS |
5641 | |
5642 | void sv_setuv(SV* sv, UV num) | |
5643 | ||
497711e7 GS |
5644 | =for hackers |
5645 | Found in file sv.c | |
5646 | ||
954c1994 | 5647 | =item sv_setuv_mg |
d8c40edc | 5648 | X<sv_setuv_mg> |
954c1994 GS |
5649 | |
5650 | Like C<sv_setuv>, but also handles 'set' magic. | |
5651 | ||
5652 | void sv_setuv_mg(SV *sv, UV u) | |
5653 | ||
497711e7 GS |
5654 | =for hackers |
5655 | Found in file sv.c | |
5656 | ||
451be7b1 | 5657 | =item sv_tainted |
d8c40edc | 5658 | X<sv_tainted> |
451be7b1 DM |
5659 | |
5660 | Test an SV for taintedness. Use C<SvTAINTED> instead. | |
5661 | bool sv_tainted(SV* sv) | |
5662 | ||
5663 | =for hackers | |
5664 | Found in file sv.c | |
5665 | ||
c461cf8f | 5666 | =item sv_true |
d8c40edc | 5667 | X<sv_true> |
c461cf8f JH |
5668 | |
5669 | Returns true if the SV has a true value by Perl's rules. | |
645c22ef DM |
5670 | Use the C<SvTRUE> macro instead, which may call C<sv_true()> or may |
5671 | instead use an in-line version. | |
c461cf8f JH |
5672 | |
5673 | I32 sv_true(SV *sv) | |
5674 | ||
5675 | =for hackers | |
5676 | Found in file sv.c | |
5677 | ||
5678 | =item sv_unmagic | |
d8c40edc | 5679 | X<sv_unmagic> |
c461cf8f | 5680 | |
645c22ef | 5681 | Removes all magic of type C<type> from an SV. |
c461cf8f JH |
5682 | |
5683 | int sv_unmagic(SV* sv, int type) | |
5684 | ||
5685 | =for hackers | |
5686 | Found in file sv.c | |
5687 | ||
840a7b70 | 5688 | =item sv_unref_flags |
d8c40edc | 5689 | X<sv_unref_flags> |
840a7b70 IZ |
5690 | |
5691 | Unsets the RV status of the SV, and decrements the reference count of | |
5692 | whatever was being referenced by the RV. This can almost be thought of | |
5693 | as a reversal of C<newSVrv>. The C<cflags> argument can contain | |
5694 | C<SV_IMMEDIATE_UNREF> to force the reference count to be decremented | |
5695 | (otherwise the decrementing is conditional on the reference count being | |
5696 | different from one or the reference being a readonly SV). | |
ae154d6d | 5697 | See C<SvROK_off>. |
840a7b70 IZ |
5698 | |
5699 | void sv_unref_flags(SV* sv, U32 flags) | |
5700 | ||
5701 | =for hackers | |
5702 | Found in file sv.c | |
5703 | ||
451be7b1 | 5704 | =item sv_untaint |
d8c40edc | 5705 | X<sv_untaint> |
451be7b1 DM |
5706 | |
5707 | Untaint an SV. Use C<SvTAINTED_off> instead. | |
5708 | void sv_untaint(SV* sv) | |
5709 | ||
5710 | =for hackers | |
5711 | Found in file sv.c | |
5712 | ||
954c1994 | 5713 | =item sv_upgrade |
d8c40edc | 5714 | X<sv_upgrade> |
954c1994 | 5715 | |
ff276b08 | 5716 | Upgrade an SV to a more complex form. Generally adds a new body type to the |
645c22ef | 5717 | SV, then copies across as much information as possible from the old body. |
ff276b08 | 5718 | You generally want to use the C<SvUPGRADE> macro wrapper. See also C<svtype>. |
954c1994 | 5719 | |
63f97190 | 5720 | void sv_upgrade(SV* sv, U32 mt) |
954c1994 | 5721 | |
497711e7 GS |
5722 | =for hackers |
5723 | Found in file sv.c | |
5724 | ||
954c1994 | 5725 | =item sv_usepvn |
d8c40edc | 5726 | X<sv_usepvn> |
954c1994 GS |
5727 | |
5728 | Tells an SV to use C<ptr> to find its string value. Normally the string is | |
1c846c1f | 5729 | stored inside the SV but sv_usepvn allows the SV to use an outside string. |
954c1994 GS |
5730 | The C<ptr> should point to memory that was allocated by C<malloc>. The |
5731 | string length, C<len>, must be supplied. This function will realloc the | |
5732 | memory pointed to by C<ptr>, so that pointer should not be freed or used by | |
5733 | the programmer after giving it to sv_usepvn. Does not handle 'set' magic. | |
5734 | See C<sv_usepvn_mg>. | |
5735 | ||
5736 | void sv_usepvn(SV* sv, char* ptr, STRLEN len) | |
5737 | ||
497711e7 GS |
5738 | =for hackers |
5739 | Found in file sv.c | |
5740 | ||
954c1994 | 5741 | =item sv_usepvn_mg |
d8c40edc | 5742 | X<sv_usepvn_mg> |
954c1994 GS |
5743 | |
5744 | Like C<sv_usepvn>, but also handles 'set' magic. | |
5745 | ||
5746 | void sv_usepvn_mg(SV *sv, char *ptr, STRLEN len) | |
5747 | ||
497711e7 GS |
5748 | =for hackers |
5749 | Found in file sv.c | |
5750 | ||
2457d041 | 5751 | =item sv_utf8_decode |
d8c40edc | 5752 | X<sv_utf8_decode> |
2457d041 | 5753 | |
78ea37eb TS |
5754 | If the PV of the SV is an octet sequence in UTF-8 |
5755 | and contains a multiple-byte character, the C<SvUTF8> flag is turned on | |
5756 | so that it looks like a character. If the PV contains only single-byte | |
5757 | characters, the C<SvUTF8> flag stays being off. | |
5758 | Scans PV for validity and returns false if the PV is invalid UTF-8. | |
2457d041 JH |
5759 | |
5760 | NOTE: this function is experimental and may change or be | |
5761 | removed without notice. | |
5762 | ||
5763 | bool sv_utf8_decode(SV *sv) | |
5764 | ||
5765 | =for hackers | |
5766 | Found in file sv.c | |
5767 | ||
c461cf8f | 5768 | =item sv_utf8_downgrade |
d8c40edc | 5769 | X<sv_utf8_downgrade> |
c461cf8f | 5770 | |
78ea37eb TS |
5771 | Attempts to convert the PV of an SV from characters to bytes. |
5772 | If the PV contains a character beyond byte, this conversion will fail; | |
5773 | in this case, either returns false or, if C<fail_ok> is not | |
c461cf8f JH |
5774 | true, croaks. |
5775 | ||
9ede5bc8 DM |
5776 | This is not as a general purpose Unicode to byte encoding interface: |
5777 | use the Encode extension for that. | |
5778 | ||
c461cf8f JH |
5779 | NOTE: this function is experimental and may change or be |
5780 | removed without notice. | |
5781 | ||
5782 | bool sv_utf8_downgrade(SV *sv, bool fail_ok) | |
5783 | ||
5784 | =for hackers | |
5785 | Found in file sv.c | |
5786 | ||
5787 | =item sv_utf8_encode | |
d8c40edc | 5788 | X<sv_utf8_encode> |
c461cf8f | 5789 | |
78ea37eb TS |
5790 | Converts the PV of an SV to UTF-8, but then turns the C<SvUTF8> |
5791 | flag off so that it looks like octets again. | |
c461cf8f JH |
5792 | |
5793 | void sv_utf8_encode(SV *sv) | |
5794 | ||
5795 | =for hackers | |
5796 | Found in file sv.c | |
5797 | ||
5798 | =item sv_utf8_upgrade | |
d8c40edc | 5799 | X<sv_utf8_upgrade> |
c461cf8f | 5800 | |
78ea37eb | 5801 | Converts the PV of an SV to its UTF-8-encoded form. |
645c22ef | 5802 | Forces the SV to string form if it is not already. |
2457d041 JH |
5803 | Always sets the SvUTF8 flag to avoid future validity checks even |
5804 | if all the bytes have hibit clear. | |
c461cf8f | 5805 | |
9ede5bc8 DM |
5806 | This is not as a general purpose byte encoding to Unicode interface: |
5807 | use the Encode extension for that. | |
5808 | ||
2457d041 | 5809 | STRLEN sv_utf8_upgrade(SV *sv) |
c461cf8f JH |
5810 | |
5811 | =for hackers | |
5812 | Found in file sv.c | |
5813 | ||
8d6d96c1 | 5814 | =item sv_utf8_upgrade_flags |
d8c40edc | 5815 | X<sv_utf8_upgrade_flags> |
8d6d96c1 | 5816 | |
78ea37eb | 5817 | Converts the PV of an SV to its UTF-8-encoded form. |
645c22ef | 5818 | Forces the SV to string form if it is not already. |
8d6d96c1 HS |
5819 | Always sets the SvUTF8 flag to avoid future validity checks even |
5820 | if all the bytes have hibit clear. If C<flags> has C<SV_GMAGIC> bit set, | |
5821 | will C<mg_get> on C<sv> if appropriate, else not. C<sv_utf8_upgrade> and | |
5822 | C<sv_utf8_upgrade_nomg> are implemented in terms of this function. | |
5823 | ||
9ede5bc8 DM |
5824 | This is not as a general purpose byte encoding to Unicode interface: |
5825 | use the Encode extension for that. | |
5826 | ||
8d6d96c1 HS |
5827 | STRLEN sv_utf8_upgrade_flags(SV *sv, I32 flags) |
5828 | ||
5829 | =for hackers | |
5830 | Found in file sv.c | |
5831 | ||
bffc3d17 | 5832 | =item sv_vcatpvf |
d8c40edc | 5833 | X<sv_vcatpvf> |
bffc3d17 SH |
5834 | |
5835 | Processes its arguments like C<vsprintf> and appends the formatted output | |
5836 | to an SV. Does not handle 'set' magic. See C<sv_vcatpvf_mg>. | |
5837 | ||
5838 | Usually used via its frontend C<sv_catpvf>. | |
5839 | ||
5840 | void sv_vcatpvf(SV* sv, const char* pat, va_list* args) | |
5841 | ||
5842 | =for hackers | |
5843 | Found in file sv.c | |
5844 | ||
954c1994 | 5845 | =item sv_vcatpvfn |
d8c40edc | 5846 | X<sv_vcatpvfn> |
954c1994 GS |
5847 | |
5848 | Processes its arguments like C<vsprintf> and appends the formatted output | |
5849 | to an SV. Uses an array of SVs if the C style variable argument list is | |
5850 | missing (NULL). When running with taint checks enabled, indicates via | |
5851 | C<maybe_tainted> if results are untrustworthy (often due to the use of | |
5852 | locales). | |
5853 | ||
bffc3d17 | 5854 | Usually used via one of its frontends C<sv_vcatpvf> and C<sv_vcatpvf_mg>. |
645c22ef | 5855 | |
954c1994 GS |
5856 | void sv_vcatpvfn(SV* sv, const char* pat, STRLEN patlen, va_list* args, SV** svargs, I32 svmax, bool *maybe_tainted) |
5857 | ||
497711e7 GS |
5858 | =for hackers |
5859 | Found in file sv.c | |
5860 | ||
bffc3d17 | 5861 | =item sv_vcatpvf_mg |
d8c40edc | 5862 | X<sv_vcatpvf_mg> |
bffc3d17 SH |
5863 | |
5864 | Like C<sv_vcatpvf>, but also handles 'set' magic. | |
5865 | ||
5866 | Usually used via its frontend C<sv_catpvf_mg>. | |
5867 | ||
5868 | void sv_vcatpvf_mg(SV* sv, const char* pat, va_list* args) | |
5869 | ||
5870 | =for hackers | |
5871 | Found in file sv.c | |
5872 | ||
5873 | =item sv_vsetpvf | |
d8c40edc | 5874 | X<sv_vsetpvf> |
bffc3d17 SH |
5875 | |
5876 | Works like C<sv_vcatpvf> but copies the text into the SV instead of | |
5877 | appending it. Does not handle 'set' magic. See C<sv_vsetpvf_mg>. | |
5878 | ||
5879 | Usually used via its frontend C<sv_setpvf>. | |
5880 | ||
5881 | void sv_vsetpvf(SV* sv, const char* pat, va_list* args) | |
5882 | ||
5883 | =for hackers | |
5884 | Found in file sv.c | |
5885 | ||
954c1994 | 5886 | =item sv_vsetpvfn |
d8c40edc | 5887 | X<sv_vsetpvfn> |
954c1994 | 5888 | |
bffc3d17 | 5889 | Works like C<sv_vcatpvfn> but copies the text into the SV instead of |
954c1994 GS |
5890 | appending it. |
5891 | ||
bffc3d17 | 5892 | Usually used via one of its frontends C<sv_vsetpvf> and C<sv_vsetpvf_mg>. |
645c22ef | 5893 | |
954c1994 GS |
5894 | void sv_vsetpvfn(SV* sv, const char* pat, STRLEN patlen, va_list* args, SV** svargs, I32 svmax, bool *maybe_tainted) |
5895 | ||
497711e7 | 5896 | =for hackers |
94bdecf9 JH |
5897 | Found in file sv.c |
5898 | ||
bffc3d17 | 5899 | =item sv_vsetpvf_mg |
d8c40edc | 5900 | X<sv_vsetpvf_mg> |
bffc3d17 SH |
5901 | |
5902 | Like C<sv_vsetpvf>, but also handles 'set' magic. | |
5903 | ||
5904 | Usually used via its frontend C<sv_setpvf_mg>. | |
5905 | ||
5906 | void sv_vsetpvf_mg(SV* sv, const char* pat, va_list* args) | |
5907 | ||
5908 | =for hackers | |
5909 | Found in file sv.c | |
5910 | ||
94bdecf9 JH |
5911 | |
5912 | =back | |
5913 | ||
5914 | =head1 Unicode Support | |
5915 | ||
5916 | =over 8 | |
5917 | ||
5918 | =item bytes_from_utf8 | |
d8c40edc | 5919 | X<bytes_from_utf8> |
94bdecf9 | 5920 | |
1e54db1a | 5921 | Converts a string C<s> of length C<len> from UTF-8 into byte encoding. |
35a4481c | 5922 | Unlike C<utf8_to_bytes> but like C<bytes_to_utf8>, returns a pointer to |
94bdecf9 JH |
5923 | the newly-created string, and updates C<len> to contain the new |
5924 | length. Returns the original string if no conversion occurs, C<len> | |
5925 | is unchanged. Do nothing if C<is_utf8> points to 0. Sets C<is_utf8> to | |
5926 | 0 if C<s> is converted or contains all 7bit characters. | |
5927 | ||
5928 | NOTE: this function is experimental and may change or be | |
5929 | removed without notice. | |
5930 | ||
e1ec3a88 | 5931 | U8* bytes_from_utf8(const U8 *s, STRLEN *len, bool *is_utf8) |
94bdecf9 JH |
5932 | |
5933 | =for hackers | |
5934 | Found in file utf8.c | |
5935 | ||
5936 | =item bytes_to_utf8 | |
d8c40edc | 5937 | X<bytes_to_utf8> |
94bdecf9 | 5938 | |
1e54db1a | 5939 | Converts a string C<s> of length C<len> from ASCII into UTF-8 encoding. |
94bdecf9 JH |
5940 | Returns a pointer to the newly-created string, and sets C<len> to |
5941 | reflect the new length. | |
5942 | ||
1e54db1a | 5943 | If you want to convert to UTF-8 from other encodings than ASCII, |
bd5cf849 HS |
5944 | see sv_recode_to_utf8(). |
5945 | ||
94bdecf9 JH |
5946 | NOTE: this function is experimental and may change or be |
5947 | removed without notice. | |
5948 | ||
35a4481c | 5949 | U8* bytes_to_utf8(const U8 *s, STRLEN *len) |
94bdecf9 JH |
5950 | |
5951 | =for hackers | |
5952 | Found in file utf8.c | |
5953 | ||
5954 | =item ibcmp_utf8 | |
d8c40edc | 5955 | X<ibcmp_utf8> |
94bdecf9 JH |
5956 | |
5957 | Return true if the strings s1 and s2 differ case-insensitively, false | |
5958 | if not (if they are equal case-insensitively). If u1 is true, the | |
5959 | string s1 is assumed to be in UTF-8-encoded Unicode. If u2 is true, | |
5960 | the string s2 is assumed to be in UTF-8-encoded Unicode. If u1 or u2 | |
5961 | are false, the respective string is assumed to be in native 8-bit | |
5962 | encoding. | |
5963 | ||
5964 | If the pe1 and pe2 are non-NULL, the scanning pointers will be copied | |
5965 | in there (they will point at the beginning of the I<next> character). | |
5966 | If the pointers behind pe1 or pe2 are non-NULL, they are the end | |
5967 | pointers beyond which scanning will not continue under any | |
fa11829f | 5968 | circumstances. If the byte lengths l1 and l2 are non-zero, s1+l1 and |
94bdecf9 JH |
5969 | s2+l2 will be used as goal end pointers that will also stop the scan, |
5970 | and which qualify towards defining a successful match: all the scans | |
5971 | that define an explicit length must reach their goal pointers for | |
5972 | a match to succeed). | |
5973 | ||
5974 | For case-insensitiveness, the "casefolding" of Unicode is used | |
5975 | instead of upper/lowercasing both the characters, see | |
5976 | http://www.unicode.org/unicode/reports/tr21/ (Case Mappings). | |
5977 | ||
5978 | I32 ibcmp_utf8(const char* a, char **pe1, UV l1, bool u1, const char* b, char **pe2, UV l2, bool u2) | |
5979 | ||
5980 | =for hackers | |
5981 | Found in file utf8.c | |
5982 | ||
5983 | =item is_utf8_char | |
d8c40edc | 5984 | X<is_utf8_char> |
94bdecf9 JH |
5985 | |
5986 | Tests if some arbitrary number of bytes begins in a valid UTF-8 | |
641d4181 JH |
5987 | character. Note that an INVARIANT (i.e. ASCII) character is a valid |
5988 | UTF-8 character. The actual number of bytes in the UTF-8 character | |
5989 | will be returned if it is valid, otherwise 0. | |
94bdecf9 | 5990 | |
7fc63493 | 5991 | STRLEN is_utf8_char(const U8 *p) |
94bdecf9 JH |
5992 | |
5993 | =for hackers | |
5994 | Found in file utf8.c | |
5995 | ||
5996 | =item is_utf8_string | |
d8c40edc | 5997 | X<is_utf8_string> |
94bdecf9 | 5998 | |
bd5cf849 | 5999 | Returns true if first C<len> bytes of the given string form a valid |
1e54db1a JH |
6000 | UTF-8 string, false otherwise. Note that 'a valid UTF-8 string' does |
6001 | not mean 'a string that contains code points above 0x7F encoded in UTF-8' | |
6002 | because a valid ASCII string is a valid UTF-8 string. | |
94bdecf9 | 6003 | |
768c67ee JH |
6004 | See also is_utf8_string_loclen() and is_utf8_string_loc(). |
6005 | ||
7fc63493 | 6006 | bool is_utf8_string(const U8 *s, STRLEN len) |
94bdecf9 JH |
6007 | |
6008 | =for hackers | |
6009 | Found in file utf8.c | |
497711e7 | 6010 | |
72d6ef7d | 6011 | =item is_utf8_string_loc |
d8c40edc | 6012 | X<is_utf8_string_loc> |
72d6ef7d | 6013 | |
9244d4ad | 6014 | Like is_utf8_string() but stores the location of the failure (in the |
768c67ee JH |
6015 | case of "utf8ness failure") or the location s+len (in the case of |
6016 | "utf8ness success") in the C<ep>. | |
6017 | ||
6018 | See also is_utf8_string_loclen() and is_utf8_string(). | |
72d6ef7d | 6019 | |
7fc63493 | 6020 | bool is_utf8_string_loc(const U8 *s, STRLEN len, const U8 **p) |
72d6ef7d JH |
6021 | |
6022 | =for hackers | |
6023 | Found in file utf8.c | |
6024 | ||
768c67ee | 6025 | =item is_utf8_string_loclen |
d8c40edc | 6026 | X<is_utf8_string_loclen> |
768c67ee | 6027 | |
9244d4ad | 6028 | Like is_utf8_string() but stores the location of the failure (in the |
768c67ee JH |
6029 | case of "utf8ness failure") or the location s+len (in the case of |
6030 | "utf8ness success") in the C<ep>, and the number of UTF-8 | |
6031 | encoded characters in the C<el>. | |
6032 | ||
6033 | See also is_utf8_string_loc() and is_utf8_string(). | |
6034 | ||
6035 | bool is_utf8_string_loclen(const U8 *s, STRLEN len, const U8 **ep, STRLEN *el) | |
6036 | ||
6037 | =for hackers | |
6038 | Found in file utf8.c | |
6039 | ||
94bdecf9 | 6040 | =item pv_uni_display |
d8c40edc | 6041 | X<pv_uni_display> |
954c1994 | 6042 | |
94bdecf9 JH |
6043 | Build to the scalar dsv a displayable version of the string spv, |
6044 | length len, the displayable version being at most pvlim bytes long | |
6045 | (if longer, the rest is truncated and "..." will be appended). | |
0a2ef054 JH |
6046 | |
6047 | The flags argument can have UNI_DISPLAY_ISPRINT set to display | |
a4f1a029 | 6048 | isPRINT()able characters as themselves, UNI_DISPLAY_BACKSLASH |
0a2ef054 JH |
6049 | to display the \\[nrfta\\] as the backslashed versions (like '\n') |
6050 | (UNI_DISPLAY_BACKSLASH is preferred over UNI_DISPLAY_ISPRINT for \\). | |
6051 | UNI_DISPLAY_QQ (and its alias UNI_DISPLAY_REGEX) have both | |
6052 | UNI_DISPLAY_BACKSLASH and UNI_DISPLAY_ISPRINT turned on. | |
6053 | ||
94bdecf9 | 6054 | The pointer to the PV of the dsv is returned. |
954c1994 | 6055 | |
e1ec3a88 | 6056 | char* pv_uni_display(SV *dsv, const U8 *spv, STRLEN len, STRLEN pvlim, UV flags) |
954c1994 | 6057 | |
497711e7 | 6058 | =for hackers |
94bdecf9 | 6059 | Found in file utf8.c |
497711e7 | 6060 | |
220e2d4e | 6061 | =item sv_cat_decode |
d8c40edc | 6062 | X<sv_cat_decode> |
220e2d4e IH |
6063 | |
6064 | The encoding is assumed to be an Encode object, the PV of the ssv is | |
6065 | assumed to be octets in that encoding and decoding the input starts | |
6066 | from the position which (PV + *offset) pointed to. The dsv will be | |
6067 | concatenated the decoded UTF-8 string from ssv. Decoding will terminate | |
6068 | when the string tstr appears in decoding output or the input ends on | |
6069 | the PV of the ssv. The value which the offset points will be modified | |
6070 | to the last input position on the ssv. | |
6071 | ||
6072 | Returns TRUE if the terminator was found, else returns FALSE. | |
6073 | ||
6074 | bool sv_cat_decode(SV* dsv, SV *encoding, SV *ssv, int *offset, char* tstr, int tlen) | |
6075 | ||
6076 | =for hackers | |
6077 | Found in file sv.c | |
6078 | ||
94bdecf9 | 6079 | =item sv_recode_to_utf8 |
d8c40edc | 6080 | X<sv_recode_to_utf8> |
954c1994 | 6081 | |
94bdecf9 JH |
6082 | The encoding is assumed to be an Encode object, on entry the PV |
6083 | of the sv is assumed to be octets in that encoding, and the sv | |
6084 | will be converted into Unicode (and UTF-8). | |
954c1994 | 6085 | |
94bdecf9 JH |
6086 | If the sv already is UTF-8 (or if it is not POK), or if the encoding |
6087 | is not a reference, nothing is done to the sv. If the encoding is not | |
6088 | an C<Encode::XS> Encoding object, bad things will happen. | |
6089 | (See F<lib/encoding.pm> and L<Encode>). | |
6090 | ||
6091 | The PV of the sv is returned. | |
6092 | ||
6093 | char* sv_recode_to_utf8(SV* sv, SV *encoding) | |
954c1994 | 6094 | |
497711e7 | 6095 | =for hackers |
94bdecf9 | 6096 | Found in file sv.c |
497711e7 | 6097 | |
94bdecf9 | 6098 | =item sv_uni_display |
d8c40edc | 6099 | X<sv_uni_display> |
954c1994 | 6100 | |
94bdecf9 | 6101 | Build to the scalar dsv a displayable version of the scalar sv, |
0a2ef054 | 6102 | the displayable version being at most pvlim bytes long |
94bdecf9 | 6103 | (if longer, the rest is truncated and "..." will be appended). |
0a2ef054 JH |
6104 | |
6105 | The flags argument is as in pv_uni_display(). | |
6106 | ||
94bdecf9 | 6107 | The pointer to the PV of the dsv is returned. |
954c1994 | 6108 | |
94bdecf9 | 6109 | char* sv_uni_display(SV *dsv, SV *ssv, STRLEN pvlim, UV flags) |
954c1994 | 6110 | |
497711e7 | 6111 | =for hackers |
94bdecf9 | 6112 | Found in file utf8.c |
497711e7 | 6113 | |
6b5c0936 | 6114 | =item to_utf8_case |
d8c40edc | 6115 | X<to_utf8_case> |
6b5c0936 JH |
6116 | |
6117 | The "p" contains the pointer to the UTF-8 string encoding | |
6118 | the character that is being converted. | |
6119 | ||
6120 | The "ustrp" is a pointer to the character buffer to put the | |
6121 | conversion result to. The "lenp" is a pointer to the length | |
6122 | of the result. | |
6123 | ||
12b7c5c7 | 6124 | The "swashp" is a pointer to the swash to use. |
6b5c0936 | 6125 | |
12b7c5c7 | 6126 | Both the special and normal mappings are stored lib/unicore/To/Foo.pl, |
979f2922 | 6127 | and loaded by SWASHNEW, using lib/utf8_heavy.pl. The special (usually, |
12b7c5c7 JH |
6128 | but not always, a multicharacter mapping), is tried first. |
6129 | ||
6130 | The "special" is a string like "utf8::ToSpecLower", which means the | |
6131 | hash %utf8::ToSpecLower. The access to the hash is through | |
6132 | Perl_to_utf8_case(). | |
6b5c0936 | 6133 | |
12b7c5c7 JH |
6134 | The "normal" is a string like "ToLower" which means the swash |
6135 | %utf8::ToLower. | |
6b5c0936 | 6136 | |
9a957fbc | 6137 | UV to_utf8_case(const U8 *p, U8* ustrp, STRLEN *lenp, SV **swashp, const char *normal, const char *special) |
6b5c0936 JH |
6138 | |
6139 | =for hackers | |
6140 | Found in file utf8.c | |
6141 | ||
d3e79532 | 6142 | =item to_utf8_fold |
d8c40edc | 6143 | X<to_utf8_fold> |
d3e79532 JH |
6144 | |
6145 | Convert the UTF-8 encoded character at p to its foldcase version and | |
6146 | store that in UTF-8 in ustrp and its length in bytes in lenp. Note | |
59887a99 | 6147 | that the ustrp needs to be at least UTF8_MAXBYTES_CASE+1 bytes since the |
d3e79532 JH |
6148 | foldcase version may be longer than the original character (up to |
6149 | three characters). | |
6150 | ||
6151 | The first character of the foldcased version is returned | |
6152 | (but note, as explained above, that there may be more.) | |
6153 | ||
7fc63493 | 6154 | UV to_utf8_fold(const U8 *p, U8* ustrp, STRLEN *lenp) |
d3e79532 JH |
6155 | |
6156 | =for hackers | |
6157 | Found in file utf8.c | |
6158 | ||
6159 | =item to_utf8_lower | |
d8c40edc | 6160 | X<to_utf8_lower> |
d3e79532 JH |
6161 | |
6162 | Convert the UTF-8 encoded character at p to its lowercase version and | |
6163 | store that in UTF-8 in ustrp and its length in bytes in lenp. Note | |
59887a99 MHM |
6164 | that the ustrp needs to be at least UTF8_MAXBYTES_CASE+1 bytes since the |
6165 | lowercase version may be longer than the original character. | |
d3e79532 JH |
6166 | |
6167 | The first character of the lowercased version is returned | |
6168 | (but note, as explained above, that there may be more.) | |
6169 | ||
7fc63493 | 6170 | UV to_utf8_lower(const U8 *p, U8* ustrp, STRLEN *lenp) |
d3e79532 JH |
6171 | |
6172 | =for hackers | |
6173 | Found in file utf8.c | |
6174 | ||
6175 | =item to_utf8_title | |
d8c40edc | 6176 | X<to_utf8_title> |
d3e79532 JH |
6177 | |
6178 | Convert the UTF-8 encoded character at p to its titlecase version and | |
6179 | store that in UTF-8 in ustrp and its length in bytes in lenp. Note | |
59887a99 MHM |
6180 | that the ustrp needs to be at least UTF8_MAXBYTES_CASE+1 bytes since the |
6181 | titlecase version may be longer than the original character. | |
d3e79532 JH |
6182 | |
6183 | The first character of the titlecased version is returned | |
6184 | (but note, as explained above, that there may be more.) | |
6185 | ||
7fc63493 | 6186 | UV to_utf8_title(const U8 *p, U8* ustrp, STRLEN *lenp) |
d3e79532 JH |
6187 | |
6188 | =for hackers | |
6189 | Found in file utf8.c | |
6190 | ||
6191 | =item to_utf8_upper | |
d8c40edc | 6192 | X<to_utf8_upper> |
d3e79532 JH |
6193 | |
6194 | Convert the UTF-8 encoded character at p to its uppercase version and | |
6195 | store that in UTF-8 in ustrp and its length in bytes in lenp. Note | |
59887a99 MHM |
6196 | that the ustrp needs to be at least UTF8_MAXBYTES_CASE+1 bytes since |
6197 | the uppercase version may be longer than the original character. | |
d3e79532 JH |
6198 | |
6199 | The first character of the uppercased version is returned | |
6200 | (but note, as explained above, that there may be more.) | |
6201 | ||
7fc63493 | 6202 | UV to_utf8_upper(const U8 *p, U8* ustrp, STRLEN *lenp) |
d3e79532 JH |
6203 | |
6204 | =for hackers | |
6205 | Found in file utf8.c | |
6206 | ||
cd299c6e RGS |
6207 | =item utf8n_to_uvchr |
6208 | X<utf8n_to_uvchr> | |
6209 | ||
6210 | flags | |
6211 | ||
6212 | Returns the native character value of the first character in the string | |
6213 | C<s> | |
6214 | which is assumed to be in UTF-8 encoding; C<retlen> will be set to the | |
6215 | length, in bytes, of that character. | |
6216 | ||
6217 | Allows length and flags to be passed to low level routine. | |
6218 | ||
6219 | UV utf8n_to_uvchr(const U8 *s, STRLEN curlen, STRLEN *retlen, U32 flags) | |
6220 | ||
6221 | =for hackers | |
6222 | Found in file utf8.c | |
6223 | ||
282f25c9 | 6224 | =item utf8n_to_uvuni |
d8c40edc | 6225 | X<utf8n_to_uvuni> |
282f25c9 JH |
6226 | |
6227 | Bottom level UTF-8 decode routine. | |
6228 | Returns the unicode code point value of the first character in the string C<s> | |
1e54db1a | 6229 | which is assumed to be in UTF-8 encoding and no longer than C<curlen>; |
282f25c9 JH |
6230 | C<retlen> will be set to the length, in bytes, of that character. |
6231 | ||
1e54db1a | 6232 | If C<s> does not point to a well-formed UTF-8 character, the behaviour |
282f25c9 JH |
6233 | is dependent on the value of C<flags>: if it contains UTF8_CHECK_ONLY, |
6234 | it is assumed that the caller will raise a warning, and this function | |
6235 | will silently just set C<retlen> to C<-1> and return zero. If the | |
6236 | C<flags> does not contain UTF8_CHECK_ONLY, warnings about | |
6237 | malformations will be given, C<retlen> will be set to the expected | |
6238 | length of the UTF-8 character in bytes, and zero will be returned. | |
6239 | ||
6240 | The C<flags> can also contain various flags to allow deviations from | |
6241 | the strict UTF-8 encoding (see F<utf8.h>). | |
6242 | ||
6243 | Most code should use utf8_to_uvchr() rather than call this directly. | |
6244 | ||
9a957fbc | 6245 | UV utf8n_to_uvuni(const U8 *s, STRLEN curlen, STRLEN *retlen, U32 flags) |
282f25c9 JH |
6246 | |
6247 | =for hackers | |
6248 | Found in file utf8.c | |
6249 | ||
b06226ff | 6250 | =item utf8_distance |
d8c40edc | 6251 | X<utf8_distance> |
b06226ff | 6252 | |
1e54db1a | 6253 | Returns the number of UTF-8 characters between the UTF-8 pointers C<a> |
b06226ff JH |
6254 | and C<b>. |
6255 | ||
6256 | WARNING: use only if you *know* that the pointers point inside the | |
6257 | same UTF-8 buffer. | |
6258 | ||
35a4481c | 6259 | IV utf8_distance(const U8 *a, const U8 *b) |
b06226ff JH |
6260 | |
6261 | =for hackers | |
6262 | Found in file utf8.c | |
6263 | ||
6264 | =item utf8_hop | |
d8c40edc | 6265 | X<utf8_hop> |
b06226ff | 6266 | |
8850bf83 JH |
6267 | Return the UTF-8 pointer C<s> displaced by C<off> characters, either |
6268 | forward or backward. | |
b06226ff JH |
6269 | |
6270 | WARNING: do not use the following unless you *know* C<off> is within | |
8850bf83 JH |
6271 | the UTF-8 data pointed to by C<s> *and* that on entry C<s> is aligned |
6272 | on the first byte of character or just after the last byte of a character. | |
b06226ff | 6273 | |
4373e329 | 6274 | U8* utf8_hop(const U8 *s, I32 off) |
b06226ff JH |
6275 | |
6276 | =for hackers | |
6277 | Found in file utf8.c | |
6278 | ||
6279 | =item utf8_length | |
d8c40edc | 6280 | X<utf8_length> |
b06226ff JH |
6281 | |
6282 | Return the length of the UTF-8 char encoded string C<s> in characters. | |
6283 | Stops at C<e> (inclusive). If C<e E<lt> s> or if the scan would end | |
6284 | up past C<e>, croaks. | |
6285 | ||
35a4481c | 6286 | STRLEN utf8_length(const U8* s, const U8 *e) |
b06226ff JH |
6287 | |
6288 | =for hackers | |
6289 | Found in file utf8.c | |
6290 | ||
497711e7 | 6291 | =item utf8_to_bytes |
d8c40edc | 6292 | X<utf8_to_bytes> |
497711e7 | 6293 | |
1e54db1a | 6294 | Converts a string C<s> of length C<len> from UTF-8 into byte encoding. |
246fae53 MG |
6295 | Unlike C<bytes_to_utf8>, this over-writes the original string, and |
6296 | updates len to contain the new length. | |
67e989fb | 6297 | Returns zero on failure, setting C<len> to -1. |
497711e7 | 6298 | |
eebe1485 SC |
6299 | NOTE: this function is experimental and may change or be |
6300 | removed without notice. | |
6301 | ||
6302 | U8* utf8_to_bytes(U8 *s, STRLEN *len) | |
497711e7 GS |
6303 | |
6304 | =for hackers | |
6305 | Found in file utf8.c | |
6306 | ||
282f25c9 | 6307 | =item utf8_to_uvchr |
d8c40edc | 6308 | X<utf8_to_uvchr> |
b6b716fe | 6309 | |
282f25c9 | 6310 | Returns the native character value of the first character in the string C<s> |
1e54db1a | 6311 | which is assumed to be in UTF-8 encoding; C<retlen> will be set to the |
282f25c9 | 6312 | length, in bytes, of that character. |
28d3d195 | 6313 | |
1e54db1a | 6314 | If C<s> does not point to a well-formed UTF-8 character, zero is |
282f25c9 | 6315 | returned and retlen is set, if possible, to -1. |
444155da | 6316 | |
9a957fbc | 6317 | UV utf8_to_uvchr(const U8 *s, STRLEN *retlen) |
444155da JH |
6318 | |
6319 | =for hackers | |
6320 | Found in file utf8.c | |
6321 | ||
282f25c9 | 6322 | =item utf8_to_uvuni |
d8c40edc | 6323 | X<utf8_to_uvuni> |
444155da | 6324 | |
282f25c9 | 6325 | Returns the Unicode code point of the first character in the string C<s> |
1e54db1a | 6326 | which is assumed to be in UTF-8 encoding; C<retlen> will be set to the |
1aa99e6b | 6327 | length, in bytes, of that character. |
444155da | 6328 | |
282f25c9 JH |
6329 | This function should only be used when returned UV is considered |
6330 | an index into the Unicode semantic tables (e.g. swashes). | |
6331 | ||
1e54db1a | 6332 | If C<s> does not point to a well-formed UTF-8 character, zero is |
dcad2880 | 6333 | returned and retlen is set, if possible, to -1. |
b6b716fe | 6334 | |
9a957fbc | 6335 | UV utf8_to_uvuni(const U8 *s, STRLEN *retlen) |
282f25c9 JH |
6336 | |
6337 | =for hackers | |
6338 | Found in file utf8.c | |
6339 | ||
cd299c6e RGS |
6340 | =item uvchr_to_utf8 |
6341 | X<uvchr_to_utf8> | |
6342 | ||
6343 | Adds the UTF-8 representation of the Native codepoint C<uv> to the end | |
6344 | of the string C<d>; C<d> should be have at least C<UTF8_MAXBYTES+1> free | |
6345 | bytes available. The return value is the pointer to the byte after the | |
6346 | end of the new character. In other words, | |
6347 | ||
6348 | d = uvchr_to_utf8(d, uv); | |
6349 | ||
6350 | is the recommended wide native character-aware way of saying | |
6351 | ||
6352 | *(d++) = uv; | |
6353 | ||
6354 | U8* uvchr_to_utf8(U8 *d, UV uv) | |
6355 | ||
6356 | =for hackers | |
6357 | Found in file utf8.c | |
6358 | ||
b851fbc1 | 6359 | =item uvuni_to_utf8_flags |
d8c40edc | 6360 | X<uvuni_to_utf8_flags> |
eebe1485 | 6361 | |
1e54db1a | 6362 | Adds the UTF-8 representation of the Unicode codepoint C<uv> to the end |
59887a99 | 6363 | of the string C<d>; C<d> should be have at least C<UTF8_MAXBYTES+1> free |
eebe1485 | 6364 | bytes available. The return value is the pointer to the byte after the |
282f25c9 | 6365 | end of the new character. In other words, |
eebe1485 | 6366 | |
b851fbc1 JH |
6367 | d = uvuni_to_utf8_flags(d, uv, flags); |
6368 | ||
6369 | or, in most cases, | |
6370 | ||
282f25c9 | 6371 | d = uvuni_to_utf8(d, uv); |
eebe1485 | 6372 | |
b851fbc1 JH |
6373 | (which is equivalent to) |
6374 | ||
6375 | d = uvuni_to_utf8_flags(d, uv, 0); | |
6376 | ||
eebe1485 SC |
6377 | is the recommended Unicode-aware way of saying |
6378 | ||
6379 | *(d++) = uv; | |
6380 | ||
b851fbc1 | 6381 | U8* uvuni_to_utf8_flags(U8 *d, UV uv, UV flags) |
b6b716fe SC |
6382 | |
6383 | =for hackers | |
6384 | Found in file utf8.c | |
6385 | ||
497711e7 | 6386 | |
94bdecf9 | 6387 | =back |
954c1994 | 6388 | |
94bdecf9 | 6389 | =head1 Variables created by C<xsubpp> and C<xsubpp> internal functions |
954c1994 | 6390 | |
94bdecf9 | 6391 | =over 8 |
954c1994 | 6392 | |
94bdecf9 | 6393 | =item ax |
d8c40edc | 6394 | X<ax> |
497711e7 | 6395 | |
94bdecf9 JH |
6396 | Variable which is setup by C<xsubpp> to indicate the stack base offset, |
6397 | used by the C<ST>, C<XSprePUSH> and C<XSRETURN> macros. The C<dMARK> macro | |
6398 | must be called prior to setup the C<MARK> variable. | |
954c1994 | 6399 | |
94bdecf9 | 6400 | I32 ax |
954c1994 | 6401 | |
497711e7 GS |
6402 | =for hackers |
6403 | Found in file XSUB.h | |
6404 | ||
94bdecf9 | 6405 | =item CLASS |
d8c40edc | 6406 | X<CLASS> |
954c1994 | 6407 | |
94bdecf9 JH |
6408 | Variable which is setup by C<xsubpp> to indicate the |
6409 | class name for a C++ XS constructor. This is always a C<char*>. See C<THIS>. | |
954c1994 | 6410 | |
94bdecf9 | 6411 | char* CLASS |
954c1994 | 6412 | |
497711e7 GS |
6413 | =for hackers |
6414 | Found in file XSUB.h | |
6415 | ||
94bdecf9 | 6416 | =item dAX |
d8c40edc | 6417 | X<dAX> |
954c1994 | 6418 | |
94bdecf9 JH |
6419 | Sets up the C<ax> variable. |
6420 | This is usually handled automatically by C<xsubpp> by calling C<dXSARGS>. | |
954c1994 | 6421 | |
94bdecf9 | 6422 | dAX; |
954c1994 | 6423 | |
497711e7 GS |
6424 | =for hackers |
6425 | Found in file XSUB.h | |
6426 | ||
557b887a | 6427 | =item dAXMARK |
d8c40edc | 6428 | X<dAXMARK> |
557b887a SS |
6429 | |
6430 | Sets up the C<ax> variable and stack marker variable C<mark>. | |
6431 | This is usually handled automatically by C<xsubpp> by calling C<dXSARGS>. | |
6432 | ||
6433 | dAXMARK; | |
6434 | ||
6435 | =for hackers | |
6436 | Found in file XSUB.h | |
6437 | ||
94bdecf9 | 6438 | =item dITEMS |
d8c40edc | 6439 | X<dITEMS> |
954c1994 | 6440 | |
94bdecf9 JH |
6441 | Sets up the C<items> variable. |
6442 | This is usually handled automatically by C<xsubpp> by calling C<dXSARGS>. | |
954c1994 | 6443 | |
94bdecf9 | 6444 | dITEMS; |
954c1994 | 6445 | |
497711e7 GS |
6446 | =for hackers |
6447 | Found in file XSUB.h | |
6448 | ||
88037a85 | 6449 | =item dUNDERBAR |
d8c40edc | 6450 | X<dUNDERBAR> |
88037a85 RGS |
6451 | |
6452 | Sets up the C<padoff_du> variable for an XSUB that wishes to use | |
6453 | C<UNDERBAR>. | |
6454 | ||
6455 | dUNDERBAR; | |
6456 | ||
6457 | =for hackers | |
6458 | Found in file XSUB.h | |
6459 | ||
94bdecf9 | 6460 | =item dXSARGS |
d8c40edc | 6461 | X<dXSARGS> |
954c1994 | 6462 | |
94bdecf9 JH |
6463 | Sets up stack and mark pointers for an XSUB, calling dSP and dMARK. |
6464 | Sets up the C<ax> and C<items> variables by calling C<dAX> and C<dITEMS>. | |
6465 | This is usually handled automatically by C<xsubpp>. | |
954c1994 | 6466 | |
94bdecf9 | 6467 | dXSARGS; |
954c1994 | 6468 | |
497711e7 GS |
6469 | =for hackers |
6470 | Found in file XSUB.h | |
6471 | ||
94bdecf9 | 6472 | =item dXSI32 |
d8c40edc | 6473 | X<dXSI32> |
954c1994 | 6474 | |
94bdecf9 JH |
6475 | Sets up the C<ix> variable for an XSUB which has aliases. This is usually |
6476 | handled automatically by C<xsubpp>. | |
954c1994 | 6477 | |
94bdecf9 | 6478 | dXSI32; |
954c1994 | 6479 | |
497711e7 GS |
6480 | =for hackers |
6481 | Found in file XSUB.h | |
6482 | ||
94bdecf9 | 6483 | =item items |
d8c40edc | 6484 | X<items> |
954c1994 | 6485 | |
94bdecf9 JH |
6486 | Variable which is setup by C<xsubpp> to indicate the number of |
6487 | items on the stack. See L<perlxs/"Variable-length Parameter Lists">. | |
954c1994 | 6488 | |
94bdecf9 | 6489 | I32 items |
954c1994 | 6490 | |
497711e7 GS |
6491 | =for hackers |
6492 | Found in file XSUB.h | |
6493 | ||
94bdecf9 | 6494 | =item ix |
d8c40edc | 6495 | X<ix> |
954c1994 | 6496 | |
94bdecf9 JH |
6497 | Variable which is setup by C<xsubpp> to indicate which of an |
6498 | XSUB's aliases was used to invoke it. See L<perlxs/"The ALIAS: Keyword">. | |
954c1994 | 6499 | |
94bdecf9 | 6500 | I32 ix |
954c1994 | 6501 | |
497711e7 GS |
6502 | =for hackers |
6503 | Found in file XSUB.h | |
6504 | ||
94bdecf9 | 6505 | =item newXSproto |
d8c40edc | 6506 | X<newXSproto> |
954c1994 | 6507 | |
94bdecf9 JH |
6508 | Used by C<xsubpp> to hook up XSUBs as Perl subs. Adds Perl prototypes to |
6509 | the subs. | |
954c1994 | 6510 | |
497711e7 GS |
6511 | =for hackers |
6512 | Found in file XSUB.h | |
6513 | ||
94bdecf9 | 6514 | =item RETVAL |
d8c40edc | 6515 | X<RETVAL> |
954c1994 | 6516 | |
94bdecf9 JH |
6517 | Variable which is setup by C<xsubpp> to hold the return value for an |
6518 | XSUB. This is always the proper type for the XSUB. See | |
6519 | L<perlxs/"The RETVAL Variable">. | |
954c1994 | 6520 | |
94bdecf9 | 6521 | (whatever) RETVAL |
954c1994 | 6522 | |
497711e7 GS |
6523 | =for hackers |
6524 | Found in file XSUB.h | |
6525 | ||
94bdecf9 | 6526 | =item ST |
d8c40edc | 6527 | X<ST> |
954c1994 | 6528 | |
94bdecf9 | 6529 | Used to access elements on the XSUB's stack. |
954c1994 | 6530 | |
94bdecf9 | 6531 | SV* ST(int ix) |
954c1994 | 6532 | |
497711e7 GS |
6533 | =for hackers |
6534 | Found in file XSUB.h | |
6535 | ||
94bdecf9 | 6536 | =item THIS |
d8c40edc | 6537 | X<THIS> |
954c1994 | 6538 | |
94bdecf9 JH |
6539 | Variable which is setup by C<xsubpp> to designate the object in a C++ |
6540 | XSUB. This is always the proper type for the C++ object. See C<CLASS> and | |
6541 | L<perlxs/"Using XS With C++">. | |
954c1994 | 6542 | |
94bdecf9 | 6543 | (whatever) THIS |
954c1994 | 6544 | |
497711e7 GS |
6545 | =for hackers |
6546 | Found in file XSUB.h | |
6547 | ||
88037a85 | 6548 | =item UNDERBAR |
d8c40edc | 6549 | X<UNDERBAR> |
88037a85 RGS |
6550 | |
6551 | The SV* corresponding to the $_ variable. Works even if there | |
6552 | is a lexical $_ in scope. | |
6553 | ||
6554 | =for hackers | |
6555 | Found in file XSUB.h | |
6556 | ||
94bdecf9 | 6557 | =item XS |
d8c40edc | 6558 | X<XS> |
954c1994 | 6559 | |
94bdecf9 JH |
6560 | Macro to declare an XSUB and its C parameter list. This is handled by |
6561 | C<xsubpp>. | |
954c1994 | 6562 | |
497711e7 GS |
6563 | =for hackers |
6564 | Found in file XSUB.h | |
6565 | ||
954c1994 | 6566 | =item XS_VERSION |
d8c40edc | 6567 | X<XS_VERSION> |
954c1994 GS |
6568 | |
6569 | The version identifier for an XS module. This is usually | |
6570 | handled automatically by C<ExtUtils::MakeMaker>. See C<XS_VERSION_BOOTCHECK>. | |
6571 | ||
497711e7 GS |
6572 | =for hackers |
6573 | Found in file XSUB.h | |
6574 | ||
954c1994 | 6575 | =item XS_VERSION_BOOTCHECK |
d8c40edc | 6576 | X<XS_VERSION_BOOTCHECK> |
954c1994 GS |
6577 | |
6578 | Macro to verify that a PM module's $VERSION variable matches the XS | |
6579 | module's C<XS_VERSION> variable. This is usually handled automatically by | |
6580 | C<xsubpp>. See L<perlxs/"The VERSIONCHECK: Keyword">. | |
6581 | ||
6582 | XS_VERSION_BOOTCHECK; | |
6583 | ||
497711e7 GS |
6584 | =for hackers |
6585 | Found in file XSUB.h | |
6586 | ||
954c1994 | 6587 | |
94bdecf9 | 6588 | =back |
954c1994 | 6589 | |
94bdecf9 JH |
6590 | =head1 Warning and Dieing |
6591 | ||
6592 | =over 8 | |
6593 | ||
6594 | =item croak | |
d8c40edc | 6595 | X<croak> |
94bdecf9 JH |
6596 | |
6597 | This is the XSUB-writer's interface to Perl's C<die> function. | |
966353fd MF |
6598 | Normally call this function the same way you call the C C<printf> |
6599 | function. Calling C<croak> returns control directly to Perl, | |
6600 | sidestepping the normal C order of execution. See C<warn>. | |
94bdecf9 JH |
6601 | |
6602 | If you want to throw an exception object, assign the object to | |
bd61b366 | 6603 | C<$@> and then pass C<NULL> to croak(): |
94bdecf9 JH |
6604 | |
6605 | errsv = get_sv("@", TRUE); | |
6606 | sv_setsv(errsv, exception_object); | |
bd61b366 | 6607 | croak(NULL); |
94bdecf9 JH |
6608 | |
6609 | void croak(const char* pat, ...) | |
954c1994 | 6610 | |
497711e7 | 6611 | =for hackers |
94bdecf9 JH |
6612 | Found in file util.c |
6613 | ||
6614 | =item warn | |
d8c40edc | 6615 | X<warn> |
94bdecf9 | 6616 | |
966353fd MF |
6617 | This is the XSUB-writer's interface to Perl's C<warn> function. Call this |
6618 | function the same way you call the C C<printf> function. See C<croak>. | |
94bdecf9 JH |
6619 | |
6620 | void warn(const char* pat, ...) | |
6621 | ||
6622 | =for hackers | |
6623 | Found in file util.c | |
6624 | ||
497711e7 | 6625 | |
954c1994 GS |
6626 | =back |
6627 | ||
6628 | =head1 AUTHORS | |
6629 | ||
6630 | Until May 1997, this document was maintained by Jeff Okamoto | |
6631 | <okamoto@corp.hp.com>. It is now maintained as part of Perl itself. | |
6632 | ||
6633 | With lots of help and suggestions from Dean Roehrich, Malcolm Beattie, | |
6634 | Andreas Koenig, Paul Hudson, Ilya Zakharevich, Paul Marquess, Neil | |
6635 | Bowers, Matthew Green, Tim Bunce, Spider Boardman, Ulrich Pfeifer, | |
6636 | Stephen McCamant, and Gurusamy Sarathy. | |
6637 | ||
6638 | API Listing originally by Dean Roehrich <roehrich@cray.com>. | |
6639 | ||
6640 | Updated to be autogenerated from comments in the source by Benjamin Stuhl. | |
6641 | ||
6642 | =head1 SEE ALSO | |
6643 | ||
6644 | perlguts(1), perlxs(1), perlxstut(1), perlintern(1) | |
6645 |