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