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