Commit | Line | Data |
---|---|---|
954c1994 GS |
1 | =head1 NAME |
2 | ||
3 | perlapi - autogenerated documentation for the perl public API | |
4 | ||
5 | =head1 DESCRIPTION | |
6 | ||
1c846c1f NIS |
7 | This file contains the documentation of the perl public API generated by |
8 | embed.pl, specifically a listing of functions, macros, flags, and variables | |
9 | that may be used by extension writers. The interfaces of any functions that | |
954c1994 GS |
10 | are not listed here are subject to change without notice. For this reason, |
11 | blindly using functions listed in proto.h is to be avoided when writing | |
12 | extensions. | |
13 | ||
14 | Note that all Perl API global variables must be referenced with the C<PL_> | |
15 | prefix. Some macros are provided for compatibility with the older, | |
16 | unadorned names, but this support may be disabled in a future release. | |
17 | ||
18 | The listing is alphabetical, case insensitive. | |
19 | ||
94bdecf9 JH |
20 | |
21 | =head1 "Gimme" Values | |
22 | ||
23 | =over 8 | |
24 | ||
25 | =item GIMME | |
26 | ||
27 | A backward-compatible version of C<GIMME_V> which can only return | |
28 | C<G_SCALAR> or C<G_ARRAY>; in a void context, it returns C<G_SCALAR>. | |
29 | Deprecated. Use C<GIMME_V> instead. | |
30 | ||
31 | U32 GIMME | |
32 | ||
33 | =for hackers | |
34 | Found in file op.h | |
35 | ||
36 | =item GIMME_V | |
37 | ||
38 | The XSUB-writer's equivalent to Perl's C<wantarray>. Returns C<G_VOID>, | |
39 | C<G_SCALAR> or C<G_ARRAY> for void, scalar or list context, | |
40 | respectively. | |
41 | ||
42 | U32 GIMME_V | |
43 | ||
44 | =for hackers | |
45 | Found in file op.h | |
46 | ||
47 | =item G_ARRAY | |
48 | ||
49 | Used to indicate list context. See C<GIMME_V>, C<GIMME> and | |
50 | L<perlcall>. | |
51 | ||
52 | =for hackers | |
53 | Found in file cop.h | |
54 | ||
55 | =item G_DISCARD | |
56 | ||
57 | Indicates that arguments returned from a callback should be discarded. See | |
58 | L<perlcall>. | |
59 | ||
60 | =for hackers | |
61 | Found in file cop.h | |
62 | ||
63 | =item G_EVAL | |
64 | ||
65 | Used to force a Perl C<eval> wrapper around a callback. See | |
66 | L<perlcall>. | |
67 | ||
68 | =for hackers | |
69 | Found in file cop.h | |
70 | ||
71 | =item G_NOARGS | |
72 | ||
73 | Indicates that no arguments are being sent to a callback. See | |
74 | L<perlcall>. | |
75 | ||
76 | =for hackers | |
77 | Found in file cop.h | |
78 | ||
79 | =item G_SCALAR | |
80 | ||
81 | Used to indicate scalar context. See C<GIMME_V>, C<GIMME>, and | |
82 | L<perlcall>. | |
83 | ||
84 | =for hackers | |
85 | Found in file cop.h | |
86 | ||
87 | =item G_VOID | |
88 | ||
89 | Used to indicate void context. See C<GIMME_V> and L<perlcall>. | |
90 | ||
91 | =for hackers | |
92 | Found in file cop.h | |
93 | ||
94 | ||
95 | =back | |
96 | ||
97 | =head1 Array Manipulation Functions | |
98 | ||
954c1994 GS |
99 | =over 8 |
100 | ||
101 | =item AvFILL | |
102 | ||
103 | Same as C<av_len()>. Deprecated, use C<av_len()> instead. | |
104 | ||
105 | int AvFILL(AV* av) | |
106 | ||
497711e7 GS |
107 | =for hackers |
108 | Found in file av.h | |
109 | ||
954c1994 GS |
110 | =item av_clear |
111 | ||
112 | Clears an array, making it empty. Does not free the memory used by the | |
113 | array itself. | |
114 | ||
115 | void av_clear(AV* ar) | |
116 | ||
497711e7 GS |
117 | =for hackers |
118 | Found in file av.c | |
119 | ||
f3b76584 SC |
120 | =item av_delete |
121 | ||
122 | Deletes the element indexed by C<key> from the array. Returns the | |
123 | deleted element. C<flags> is currently ignored. | |
124 | ||
125 | SV* av_delete(AV* ar, I32 key, I32 flags) | |
126 | ||
127 | =for hackers | |
128 | Found in file av.c | |
129 | ||
130 | =item av_exists | |
131 | ||
132 | Returns true if the element indexed by C<key> has been initialized. | |
133 | ||
134 | This relies on the fact that uninitialized array elements are set to | |
135 | C<&PL_sv_undef>. | |
136 | ||
137 | bool av_exists(AV* ar, I32 key) | |
138 | ||
139 | =for hackers | |
140 | Found in file av.c | |
141 | ||
954c1994 GS |
142 | =item av_extend |
143 | ||
144 | Pre-extend an array. The C<key> is the index to which the array should be | |
145 | extended. | |
146 | ||
147 | void av_extend(AV* ar, I32 key) | |
148 | ||
497711e7 GS |
149 | =for hackers |
150 | Found in file av.c | |
151 | ||
954c1994 GS |
152 | =item av_fetch |
153 | ||
154 | Returns the SV at the specified index in the array. The C<key> is the | |
155 | index. If C<lval> is set then the fetch will be part of a store. Check | |
156 | that the return value is non-null before dereferencing it to a C<SV*>. | |
157 | ||
96f1132b GS |
158 | See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for |
159 | more information on how to use this function on tied arrays. | |
954c1994 GS |
160 | |
161 | SV** av_fetch(AV* ar, I32 key, I32 lval) | |
162 | ||
497711e7 GS |
163 | =for hackers |
164 | Found in file av.c | |
165 | ||
f3b76584 SC |
166 | =item av_fill |
167 | ||
168 | Ensure than an array has a given number of elements, equivalent to | |
169 | Perl's C<$#array = $fill;>. | |
170 | ||
171 | void av_fill(AV* ar, I32 fill) | |
172 | ||
173 | =for hackers | |
174 | Found in file av.c | |
175 | ||
954c1994 GS |
176 | =item av_len |
177 | ||
178 | Returns the highest index in the array. Returns -1 if the array is | |
179 | empty. | |
180 | ||
181 | I32 av_len(AV* ar) | |
182 | ||
497711e7 GS |
183 | =for hackers |
184 | Found in file av.c | |
185 | ||
954c1994 GS |
186 | =item av_make |
187 | ||
188 | Creates a new AV and populates it with a list of SVs. The SVs are copied | |
189 | into the array, so they may be freed after the call to av_make. The new AV | |
190 | will have a reference count of 1. | |
191 | ||
192 | AV* av_make(I32 size, SV** svp) | |
193 | ||
497711e7 GS |
194 | =for hackers |
195 | Found in file av.c | |
196 | ||
954c1994 GS |
197 | =item av_pop |
198 | ||
199 | Pops an SV off the end of the array. Returns C<&PL_sv_undef> if the array | |
200 | is empty. | |
201 | ||
202 | SV* av_pop(AV* ar) | |
203 | ||
497711e7 GS |
204 | =for hackers |
205 | Found in file av.c | |
206 | ||
954c1994 GS |
207 | =item av_push |
208 | ||
209 | Pushes an SV onto the end of the array. The array will grow automatically | |
210 | to accommodate the addition. | |
211 | ||
212 | void av_push(AV* ar, SV* val) | |
213 | ||
497711e7 GS |
214 | =for hackers |
215 | Found in file av.c | |
216 | ||
954c1994 GS |
217 | =item av_shift |
218 | ||
219 | Shifts an SV off the beginning of the array. | |
220 | ||
221 | SV* av_shift(AV* ar) | |
222 | ||
497711e7 GS |
223 | =for hackers |
224 | Found in file av.c | |
225 | ||
954c1994 GS |
226 | =item av_store |
227 | ||
228 | Stores an SV in an array. The array index is specified as C<key>. The | |
229 | return value will be NULL if the operation failed or if the value did not | |
230 | need to be actually stored within the array (as in the case of tied | |
231 | arrays). Otherwise it can be dereferenced to get the original C<SV*>. Note | |
232 | that the caller is responsible for suitably incrementing the reference | |
233 | count of C<val> before the call, and decrementing it if the function | |
234 | returned NULL. | |
235 | ||
96f1132b | 236 | See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for |
954c1994 GS |
237 | more information on how to use this function on tied arrays. |
238 | ||
239 | SV** av_store(AV* ar, I32 key, SV* val) | |
240 | ||
497711e7 GS |
241 | =for hackers |
242 | Found in file av.c | |
243 | ||
954c1994 GS |
244 | =item av_undef |
245 | ||
246 | Undefines the array. Frees the memory used by the array itself. | |
247 | ||
248 | void av_undef(AV* ar) | |
249 | ||
497711e7 GS |
250 | =for hackers |
251 | Found in file av.c | |
252 | ||
954c1994 GS |
253 | =item av_unshift |
254 | ||
255 | Unshift the given number of C<undef> values onto the beginning of the | |
256 | array. The array will grow automatically to accommodate the addition. You | |
257 | must then use C<av_store> to assign values to these new elements. | |
258 | ||
259 | void av_unshift(AV* ar, I32 num) | |
260 | ||
497711e7 GS |
261 | =for hackers |
262 | Found in file av.c | |
263 | ||
94bdecf9 | 264 | =item get_av |
9f2ea798 | 265 | |
94bdecf9 JH |
266 | Returns the AV of the specified Perl array. If C<create> is set and the |
267 | Perl variable does not exist then it will be created. If C<create> is not | |
268 | set and the variable does not exist then NULL is returned. | |
9f2ea798 | 269 | |
94bdecf9 JH |
270 | NOTE: the perl_ form of this function is deprecated. |
271 | ||
272 | AV* get_av(const char* name, I32 create) | |
9f2ea798 DM |
273 | |
274 | =for hackers | |
94bdecf9 | 275 | Found in file perl.c |
9f2ea798 | 276 | |
94bdecf9 | 277 | =item newAV |
f9a63242 | 278 | |
94bdecf9 | 279 | Creates a new AV. The reference count is set to 1. |
f9a63242 | 280 | |
94bdecf9 JH |
281 | AV* newAV() |
282 | ||
283 | =for hackers | |
284 | Found in file av.c | |
285 | ||
286 | =item Nullav | |
287 | ||
288 | Null AV pointer. | |
f9a63242 | 289 | |
f9a63242 JH |
290 | |
291 | =for hackers | |
94bdecf9 | 292 | Found in file av.h |
f9a63242 | 293 | |
94bdecf9 | 294 | =item sortsv |
497711e7 | 295 | |
94bdecf9 | 296 | Sort an array. Here is an example: |
497711e7 | 297 | |
94bdecf9 | 298 | sortsv(AvARRAY(av), av_len(av)+1, Perl_sv_cmp_locale); |
eebe1485 | 299 | |
94bdecf9 | 300 | void sortsv(SV ** array, size_t num_elts, SVCOMPARE_t cmp) |
497711e7 GS |
301 | |
302 | =for hackers | |
94bdecf9 JH |
303 | Found in file pp_sort.c |
304 | ||
305 | ||
306 | =back | |
307 | ||
308 | =head1 Callback Functions | |
309 | ||
310 | =over 8 | |
497711e7 | 311 | |
954c1994 GS |
312 | =item call_argv |
313 | ||
314 | Performs a callback to the specified Perl sub. See L<perlcall>. | |
315 | ||
316 | NOTE: the perl_ form of this function is deprecated. | |
317 | ||
318 | I32 call_argv(const char* sub_name, I32 flags, char** argv) | |
319 | ||
497711e7 GS |
320 | =for hackers |
321 | Found in file perl.c | |
322 | ||
954c1994 GS |
323 | =item call_method |
324 | ||
325 | Performs a callback to the specified Perl method. The blessed object must | |
326 | be on the stack. See L<perlcall>. | |
327 | ||
328 | NOTE: the perl_ form of this function is deprecated. | |
329 | ||
330 | I32 call_method(const char* methname, I32 flags) | |
331 | ||
497711e7 GS |
332 | =for hackers |
333 | Found in file perl.c | |
334 | ||
954c1994 GS |
335 | =item call_pv |
336 | ||
337 | Performs a callback to the specified Perl sub. See L<perlcall>. | |
338 | ||
339 | NOTE: the perl_ form of this function is deprecated. | |
340 | ||
341 | I32 call_pv(const char* sub_name, I32 flags) | |
342 | ||
497711e7 GS |
343 | =for hackers |
344 | Found in file perl.c | |
345 | ||
954c1994 GS |
346 | =item call_sv |
347 | ||
348 | Performs a callback to the Perl sub whose name is in the SV. See | |
349 | L<perlcall>. | |
350 | ||
351 | NOTE: the perl_ form of this function is deprecated. | |
352 | ||
353 | I32 call_sv(SV* sv, I32 flags) | |
354 | ||
497711e7 GS |
355 | =for hackers |
356 | Found in file perl.c | |
357 | ||
94bdecf9 | 358 | =item ENTER |
954c1994 | 359 | |
94bdecf9 | 360 | Opening bracket on a callback. See C<LEAVE> and L<perlcall>. |
954c1994 | 361 | |
94bdecf9 | 362 | ENTER; |
954c1994 | 363 | |
497711e7 | 364 | =for hackers |
94bdecf9 | 365 | Found in file scope.h |
497711e7 | 366 | |
94bdecf9 | 367 | =item eval_pv |
954c1994 | 368 | |
94bdecf9 | 369 | Tells Perl to C<eval> the given string and return an SV* result. |
954c1994 | 370 | |
94bdecf9 | 371 | NOTE: the perl_ form of this function is deprecated. |
954c1994 | 372 | |
94bdecf9 | 373 | SV* eval_pv(const char* p, I32 croak_on_error) |
497711e7 | 374 | |
94bdecf9 JH |
375 | =for hackers |
376 | Found in file perl.c | |
954c1994 | 377 | |
94bdecf9 | 378 | =item eval_sv |
c9d5ac95 | 379 | |
94bdecf9 | 380 | Tells Perl to C<eval> the string in the SV. |
c9d5ac95 | 381 | |
94bdecf9 | 382 | NOTE: the perl_ form of this function is deprecated. |
954c1994 | 383 | |
94bdecf9 | 384 | I32 eval_sv(SV* sv, I32 flags) |
954c1994 | 385 | |
497711e7 | 386 | =for hackers |
94bdecf9 | 387 | Found in file perl.c |
497711e7 | 388 | |
94bdecf9 | 389 | =item FREETMPS |
954c1994 | 390 | |
94bdecf9 JH |
391 | Closing bracket for temporaries on a callback. See C<SAVETMPS> and |
392 | L<perlcall>. | |
954c1994 | 393 | |
94bdecf9 | 394 | FREETMPS; |
954c1994 | 395 | |
497711e7 | 396 | =for hackers |
94bdecf9 | 397 | Found in file scope.h |
beab0874 | 398 | |
94bdecf9 | 399 | =item LEAVE |
beab0874 | 400 | |
94bdecf9 | 401 | Closing bracket on a callback. See C<ENTER> and L<perlcall>. |
beab0874 | 402 | |
94bdecf9 | 403 | LEAVE; |
beab0874 JT |
404 | |
405 | =for hackers | |
94bdecf9 | 406 | Found in file scope.h |
beab0874 | 407 | |
94bdecf9 | 408 | =item SAVETMPS |
9f2ea798 | 409 | |
94bdecf9 JH |
410 | Opening bracket for temporaries on a callback. See C<FREETMPS> and |
411 | L<perlcall>. | |
9f2ea798 | 412 | |
94bdecf9 | 413 | SAVETMPS; |
9f2ea798 DM |
414 | |
415 | =for hackers | |
94bdecf9 | 416 | Found in file scope.h |
9f2ea798 | 417 | |
9f2ea798 | 418 | |
94bdecf9 | 419 | =back |
9f2ea798 | 420 | |
94bdecf9 | 421 | =head1 Character classes |
9f2ea798 | 422 | |
94bdecf9 | 423 | =over 8 |
9f2ea798 | 424 | |
94bdecf9 | 425 | =item isALNUM |
954c1994 | 426 | |
94bdecf9 JH |
427 | Returns a boolean indicating whether the C C<char> is an ASCII alphanumeric |
428 | character (including underscore) or digit. | |
954c1994 | 429 | |
94bdecf9 | 430 | bool isALNUM(char ch) |
954c1994 | 431 | |
497711e7 | 432 | =for hackers |
94bdecf9 | 433 | Found in file handy.h |
497711e7 | 434 | |
94bdecf9 | 435 | =item isALPHA |
954c1994 | 436 | |
94bdecf9 JH |
437 | Returns a boolean indicating whether the C C<char> is an ASCII alphabetic |
438 | character. | |
954c1994 | 439 | |
94bdecf9 | 440 | bool isALPHA(char ch) |
954c1994 | 441 | |
497711e7 | 442 | =for hackers |
94bdecf9 | 443 | Found in file handy.h |
497711e7 | 444 | |
94bdecf9 | 445 | =item isDIGIT |
954c1994 | 446 | |
94bdecf9 JH |
447 | Returns a boolean indicating whether the C C<char> is an ASCII |
448 | digit. | |
954c1994 | 449 | |
94bdecf9 | 450 | bool isDIGIT(char ch) |
954c1994 | 451 | |
497711e7 | 452 | =for hackers |
94bdecf9 | 453 | Found in file handy.h |
497711e7 | 454 | |
94bdecf9 | 455 | =item isLOWER |
954c1994 | 456 | |
94bdecf9 JH |
457 | Returns a boolean indicating whether the C C<char> is a lowercase |
458 | character. | |
954c1994 | 459 | |
94bdecf9 | 460 | bool isLOWER(char ch) |
954c1994 | 461 | |
497711e7 | 462 | =for hackers |
94bdecf9 | 463 | Found in file handy.h |
497711e7 | 464 | |
94bdecf9 | 465 | =item isSPACE |
954c1994 | 466 | |
94bdecf9 | 467 | Returns a boolean indicating whether the C C<char> is whitespace. |
954c1994 | 468 | |
94bdecf9 | 469 | bool isSPACE(char ch) |
954c1994 | 470 | |
497711e7 | 471 | =for hackers |
94bdecf9 | 472 | Found in file handy.h |
497711e7 | 473 | |
94bdecf9 | 474 | =item isUPPER |
954c1994 | 475 | |
94bdecf9 JH |
476 | Returns a boolean indicating whether the C C<char> is an uppercase |
477 | character. | |
954c1994 | 478 | |
94bdecf9 | 479 | bool isUPPER(char ch) |
954c1994 | 480 | |
497711e7 | 481 | =for hackers |
94bdecf9 | 482 | Found in file handy.h |
497711e7 | 483 | |
94bdecf9 | 484 | =item toLOWER |
954c1994 | 485 | |
94bdecf9 | 486 | Converts the specified character to lowercase. |
954c1994 | 487 | |
94bdecf9 | 488 | char toLOWER(char ch) |
954c1994 | 489 | |
94bdecf9 JH |
490 | =for hackers |
491 | Found in file handy.h | |
492 | ||
493 | =item toUPPER | |
494 | ||
495 | Converts the specified character to uppercase. | |
496 | ||
497 | char toUPPER(char ch) | |
954c1994 | 498 | |
497711e7 | 499 | =for hackers |
94bdecf9 | 500 | Found in file handy.h |
497711e7 | 501 | |
954c1994 | 502 | |
94bdecf9 | 503 | =back |
954c1994 | 504 | |
94bdecf9 | 505 | =head1 Cloning an interpreter |
954c1994 | 506 | |
94bdecf9 JH |
507 | =over 8 |
508 | ||
509 | =item perl_clone | |
510 | ||
511 | Create and return a new interpreter by cloning the current one. | |
512 | ||
513 | PerlInterpreter* perl_clone(PerlInterpreter* interp, UV flags) | |
954c1994 | 514 | |
497711e7 | 515 | =for hackers |
94bdecf9 | 516 | Found in file sv.c |
497711e7 | 517 | |
954c1994 | 518 | |
94bdecf9 | 519 | =back |
954c1994 | 520 | |
94bdecf9 JH |
521 | =head1 CV Manipulation Functions |
522 | ||
523 | =over 8 | |
524 | ||
525 | =item CvSTASH | |
526 | ||
527 | Returns the stash of the CV. | |
528 | ||
529 | HV* CvSTASH(CV* cv) | |
954c1994 | 530 | |
497711e7 | 531 | =for hackers |
94bdecf9 | 532 | Found in file cv.h |
497711e7 | 533 | |
94bdecf9 | 534 | =item get_cv |
954c1994 | 535 | |
94bdecf9 JH |
536 | Returns the CV of the specified Perl subroutine. If C<create> is set and |
537 | the Perl subroutine does not exist then it will be declared (which has the | |
538 | same effect as saying C<sub name;>). If C<create> is not set and the | |
539 | subroutine does not exist then NULL is returned. | |
954c1994 | 540 | |
94bdecf9 JH |
541 | NOTE: the perl_ form of this function is deprecated. |
542 | ||
543 | CV* get_cv(const char* name, I32 create) | |
954c1994 | 544 | |
497711e7 | 545 | =for hackers |
94bdecf9 | 546 | Found in file perl.c |
497711e7 | 547 | |
94bdecf9 | 548 | =item Nullcv |
954c1994 | 549 | |
94bdecf9 | 550 | Null CV pointer. |
954c1994 | 551 | |
954c1994 | 552 | |
497711e7 | 553 | =for hackers |
94bdecf9 | 554 | Found in file cv.h |
497711e7 | 555 | |
7c9e965c | 556 | |
94bdecf9 | 557 | =back |
7c9e965c | 558 | |
94bdecf9 | 559 | =head1 Embedding Functions |
7c9e965c | 560 | |
94bdecf9 | 561 | =over 8 |
7c9e965c | 562 | |
94bdecf9 | 563 | =item load_module |
7c9e965c | 564 | |
94bdecf9 JH |
565 | Loads the module whose name is pointed to by the string part of name. |
566 | Note that the actual module name, not its filename, should be given. | |
567 | Eg, "Foo::Bar" instead of "Foo/Bar.pm". flags can be any of | |
568 | PERL_LOADMOD_DENY, PERL_LOADMOD_NOIMPORT, or PERL_LOADMOD_IMPORT_OPS | |
569 | (or 0 for no flags). ver, if specified, provides version semantics | |
570 | similar to C<use Foo::Bar VERSION>. The optional trailing SV* | |
571 | arguments can be used to specify arguments to the module's import() | |
572 | method, similar to C<use Foo::Bar VERSION LIST>. | |
7c9e965c | 573 | |
94bdecf9 | 574 | void load_module(U32 flags, SV* name, SV* ver, ...) |
7c9e965c JP |
575 | |
576 | =for hackers | |
94bdecf9 | 577 | Found in file op.c |
7c9e965c | 578 | |
94bdecf9 | 579 | =item perl_alloc |
954c1994 | 580 | |
94bdecf9 | 581 | Allocates a new Perl interpreter. See L<perlembed>. |
954c1994 | 582 | |
94bdecf9 | 583 | PerlInterpreter* perl_alloc() |
954c1994 | 584 | |
497711e7 | 585 | =for hackers |
94bdecf9 | 586 | Found in file perl.c |
497711e7 | 587 | |
94bdecf9 | 588 | =item perl_construct |
89423764 | 589 | |
94bdecf9 | 590 | Initializes a new Perl interpreter. See L<perlembed>. |
89423764 | 591 | |
94bdecf9 | 592 | void perl_construct(PerlInterpreter* interp) |
89423764 GS |
593 | |
594 | =for hackers | |
94bdecf9 | 595 | Found in file perl.c |
954c1994 | 596 | |
94bdecf9 | 597 | =item perl_destruct |
954c1994 | 598 | |
94bdecf9 | 599 | Shuts down a Perl interpreter. See L<perlembed>. |
954c1994 | 600 | |
94bdecf9 | 601 | int perl_destruct(PerlInterpreter* interp) |
954c1994 | 602 | |
497711e7 GS |
603 | =for hackers |
604 | Found in file perl.c | |
605 | ||
94bdecf9 | 606 | =item perl_free |
954c1994 | 607 | |
94bdecf9 | 608 | Releases a Perl interpreter. See L<perlembed>. |
954c1994 | 609 | |
94bdecf9 | 610 | void perl_free(PerlInterpreter* interp) |
954c1994 | 611 | |
497711e7 GS |
612 | =for hackers |
613 | Found in file perl.c | |
614 | ||
94bdecf9 | 615 | =item perl_parse |
954c1994 | 616 | |
94bdecf9 | 617 | Tells a Perl interpreter to parse a Perl script. See L<perlembed>. |
954c1994 | 618 | |
94bdecf9 | 619 | int perl_parse(PerlInterpreter* interp, XSINIT_t xsinit, int argc, char** argv, char** env) |
954c1994 | 620 | |
94bdecf9 JH |
621 | =for hackers |
622 | Found in file perl.c | |
623 | ||
624 | =item perl_run | |
625 | ||
626 | Tells a Perl interpreter to run. See L<perlembed>. | |
627 | ||
628 | int perl_run(PerlInterpreter* interp) | |
954c1994 | 629 | |
497711e7 GS |
630 | =for hackers |
631 | Found in file perl.c | |
632 | ||
94bdecf9 | 633 | =item require_pv |
954c1994 | 634 | |
94bdecf9 JH |
635 | Tells Perl to C<require> the file named by the string argument. It is |
636 | analogous to the Perl code C<eval "require '$file'">. It's even | |
637 | implemented that way; consider using Perl_load_module instead. | |
954c1994 GS |
638 | |
639 | NOTE: the perl_ form of this function is deprecated. | |
640 | ||
94bdecf9 | 641 | void require_pv(const char* pv) |
954c1994 | 642 | |
497711e7 GS |
643 | =for hackers |
644 | Found in file perl.c | |
645 | ||
954c1994 | 646 | |
94bdecf9 | 647 | =back |
954c1994 | 648 | |
94bdecf9 | 649 | =head1 Global Variables |
954c1994 | 650 | |
94bdecf9 | 651 | =over 8 |
497711e7 | 652 | |
94bdecf9 | 653 | =item PL_modglobal |
954c1994 | 654 | |
94bdecf9 JH |
655 | C<PL_modglobal> is a general purpose, interpreter global HV for use by |
656 | extensions that need to keep information on a per-interpreter basis. | |
657 | In a pinch, it can also be used as a symbol table for extensions | |
658 | to share data among each other. It is a good idea to use keys | |
659 | prefixed by the package name of the extension that owns the data. | |
954c1994 | 660 | |
94bdecf9 | 661 | HV* PL_modglobal |
954c1994 | 662 | |
497711e7 | 663 | =for hackers |
94bdecf9 | 664 | Found in file intrpvar.h |
497711e7 | 665 | |
94bdecf9 | 666 | =item PL_na |
6e9d1081 | 667 | |
94bdecf9 JH |
668 | A convenience variable which is typically used with C<SvPV> when one |
669 | doesn't care about the length of the string. It is usually more efficient | |
670 | to either declare a local variable and use that instead or to use the | |
671 | C<SvPV_nolen> macro. | |
6e9d1081 | 672 | |
94bdecf9 | 673 | STRLEN PL_na |
6e9d1081 | 674 | |
94bdecf9 JH |
675 | =for hackers |
676 | Found in file thrdvar.h | |
6e9d1081 | 677 | |
94bdecf9 | 678 | =item PL_sv_no |
6e9d1081 | 679 | |
94bdecf9 JH |
680 | This is the C<false> SV. See C<PL_sv_yes>. Always refer to this as |
681 | C<&PL_sv_no>. | |
682 | ||
683 | SV PL_sv_no | |
6e9d1081 NC |
684 | |
685 | =for hackers | |
94bdecf9 | 686 | Found in file intrpvar.h |
6e9d1081 | 687 | |
94bdecf9 | 688 | =item PL_sv_undef |
6e9d1081 | 689 | |
94bdecf9 | 690 | This is the C<undef> SV. Always refer to this as C<&PL_sv_undef>. |
6e9d1081 | 691 | |
94bdecf9 | 692 | SV PL_sv_undef |
6e9d1081 | 693 | |
94bdecf9 JH |
694 | =for hackers |
695 | Found in file intrpvar.h | |
6e9d1081 | 696 | |
94bdecf9 | 697 | =item PL_sv_yes |
6e9d1081 | 698 | |
94bdecf9 JH |
699 | This is the C<true> SV. See C<PL_sv_no>. Always refer to this as |
700 | C<&PL_sv_yes>. | |
701 | ||
702 | SV PL_sv_yes | |
6e9d1081 NC |
703 | |
704 | =for hackers | |
94bdecf9 | 705 | Found in file intrpvar.h |
6e9d1081 | 706 | |
6e9d1081 | 707 | |
94bdecf9 | 708 | =back |
6e9d1081 | 709 | |
94bdecf9 | 710 | =head1 GV Functions |
6e9d1081 | 711 | |
94bdecf9 | 712 | =over 8 |
6e9d1081 | 713 | |
954c1994 GS |
714 | =item GvSV |
715 | ||
716 | Return the SV from the GV. | |
717 | ||
718 | SV* GvSV(GV* gv) | |
719 | ||
497711e7 GS |
720 | =for hackers |
721 | Found in file gv.h | |
722 | ||
954c1994 GS |
723 | =item gv_fetchmeth |
724 | ||
725 | Returns the glob with the given C<name> and a defined subroutine or | |
726 | C<NULL>. The glob lives in the given C<stash>, or in the stashes | |
a453c169 | 727 | accessible via @ISA and UNIVERSAL::. |
954c1994 GS |
728 | |
729 | The argument C<level> should be either 0 or -1. If C<level==0>, as a | |
730 | side-effect creates a glob with the given C<name> in the given C<stash> | |
731 | which in the case of success contains an alias for the subroutine, and sets | |
1c846c1f | 732 | up caching info for this glob. Similarly for all the searched stashes. |
954c1994 GS |
733 | |
734 | This function grants C<"SUPER"> token as a postfix of the stash name. The | |
735 | GV returned from C<gv_fetchmeth> may be a method cache entry, which is not | |
4929bf7b | 736 | visible to Perl code. So when calling C<call_sv>, you should not use |
954c1994 | 737 | the GV directly; instead, you should use the method's CV, which can be |
1c846c1f | 738 | obtained from the GV with the C<GvCV> macro. |
954c1994 GS |
739 | |
740 | GV* gv_fetchmeth(HV* stash, const char* name, STRLEN len, I32 level) | |
741 | ||
497711e7 GS |
742 | =for hackers |
743 | Found in file gv.c | |
744 | ||
954c1994 GS |
745 | =item gv_fetchmethod |
746 | ||
6d0f518e | 747 | See L<gv_fetchmethod_autoload>. |
954c1994 GS |
748 | |
749 | GV* gv_fetchmethod(HV* stash, const char* name) | |
750 | ||
497711e7 GS |
751 | =for hackers |
752 | Found in file gv.c | |
753 | ||
954c1994 GS |
754 | =item gv_fetchmethod_autoload |
755 | ||
756 | Returns the glob which contains the subroutine to call to invoke the method | |
757 | on the C<stash>. In fact in the presence of autoloading this may be the | |
758 | glob for "AUTOLOAD". In this case the corresponding variable $AUTOLOAD is | |
1c846c1f | 759 | already setup. |
954c1994 GS |
760 | |
761 | The third parameter of C<gv_fetchmethod_autoload> determines whether | |
762 | AUTOLOAD lookup is performed if the given method is not present: non-zero | |
1c846c1f | 763 | means yes, look for AUTOLOAD; zero means no, don't look for AUTOLOAD. |
954c1994 | 764 | Calling C<gv_fetchmethod> is equivalent to calling C<gv_fetchmethod_autoload> |
1c846c1f | 765 | with a non-zero C<autoload> parameter. |
954c1994 GS |
766 | |
767 | These functions grant C<"SUPER"> token as a prefix of the method name. Note | |
768 | that if you want to keep the returned glob for a long time, you need to | |
769 | check for it being "AUTOLOAD", since at the later time the call may load a | |
770 | different subroutine due to $AUTOLOAD changing its value. Use the glob | |
1c846c1f | 771 | created via a side effect to do this. |
954c1994 GS |
772 | |
773 | These functions have the same side-effects and as C<gv_fetchmeth> with | |
774 | C<level==0>. C<name> should be writable if contains C<':'> or C<' | |
775 | ''>. The warning against passing the GV returned by C<gv_fetchmeth> to | |
1c846c1f | 776 | C<call_sv> apply equally to these functions. |
954c1994 GS |
777 | |
778 | GV* gv_fetchmethod_autoload(HV* stash, const char* name, I32 autoload) | |
779 | ||
497711e7 GS |
780 | =for hackers |
781 | Found in file gv.c | |
782 | ||
954c1994 GS |
783 | =item gv_stashpv |
784 | ||
386d01d6 GS |
785 | Returns a pointer to the stash for a specified package. C<name> should |
786 | be a valid UTF-8 string. If C<create> is set then the package will be | |
787 | created if it does not already exist. If C<create> is not set and the | |
788 | package does not exist then NULL is returned. | |
954c1994 GS |
789 | |
790 | HV* gv_stashpv(const char* name, I32 create) | |
791 | ||
497711e7 GS |
792 | =for hackers |
793 | Found in file gv.c | |
794 | ||
954c1994 GS |
795 | =item gv_stashsv |
796 | ||
386d01d6 GS |
797 | Returns a pointer to the stash for a specified package, which must be a |
798 | valid UTF-8 string. See C<gv_stashpv>. | |
954c1994 GS |
799 | |
800 | HV* gv_stashsv(SV* sv, I32 create) | |
801 | ||
497711e7 GS |
802 | =for hackers |
803 | Found in file gv.c | |
804 | ||
954c1994 | 805 | |
94bdecf9 | 806 | =back |
954c1994 | 807 | |
94bdecf9 | 808 | =head1 Handy Values |
497711e7 | 809 | |
94bdecf9 | 810 | =over 8 |
954c1994 | 811 | |
94bdecf9 | 812 | =item HEf_SVKEY |
954c1994 | 813 | |
94bdecf9 JH |
814 | This flag, used in the length slot of hash entries and magic structures, |
815 | specifies the structure contains an C<SV*> pointer where a C<char*> pointer | |
816 | is to be expected. (For information only--not to be used). | |
497711e7 | 817 | |
954c1994 | 818 | |
94bdecf9 JH |
819 | =for hackers |
820 | Found in file hv.h | |
954c1994 | 821 | |
94bdecf9 JH |
822 | =item Nullch |
823 | ||
824 | Null character pointer. | |
497711e7 | 825 | =for hackers |
94bdecf9 | 826 | Found in file handy.h |
497711e7 | 827 | |
94bdecf9 | 828 | =item Nullsv |
954c1994 | 829 | |
94bdecf9 | 830 | Null SV pointer. |
954c1994 | 831 | |
497711e7 | 832 | =for hackers |
94bdecf9 | 833 | Found in file handy.h |
497711e7 | 834 | |
954c1994 | 835 | |
94bdecf9 | 836 | =back |
954c1994 | 837 | |
94bdecf9 | 838 | =head1 Hash Manipulation Functions |
497711e7 | 839 | |
94bdecf9 | 840 | =over 8 |
954c1994 | 841 | |
94bdecf9 | 842 | =item get_hv |
954c1994 | 843 | |
94bdecf9 JH |
844 | Returns the HV of the specified Perl hash. If C<create> is set and the |
845 | Perl variable does not exist then it will be created. If C<create> is not | |
846 | set and the variable does not exist then NULL is returned. | |
497711e7 | 847 | |
94bdecf9 | 848 | NOTE: the perl_ form of this function is deprecated. |
954c1994 | 849 | |
94bdecf9 | 850 | HV* get_hv(const char* name, I32 create) |
954c1994 | 851 | |
497711e7 | 852 | =for hackers |
94bdecf9 | 853 | Found in file perl.c |
497711e7 | 854 | |
954c1994 GS |
855 | =item HeHASH |
856 | ||
857 | Returns the computed hash stored in the hash entry. | |
858 | ||
859 | U32 HeHASH(HE* he) | |
860 | ||
497711e7 GS |
861 | =for hackers |
862 | Found in file hv.h | |
863 | ||
954c1994 GS |
864 | =item HeKEY |
865 | ||
866 | Returns the actual pointer stored in the key slot of the hash entry. The | |
867 | pointer may be either C<char*> or C<SV*>, depending on the value of | |
868 | C<HeKLEN()>. Can be assigned to. The C<HePV()> or C<HeSVKEY()> macros are | |
869 | usually preferable for finding the value of a key. | |
870 | ||
871 | void* HeKEY(HE* he) | |
872 | ||
497711e7 GS |
873 | =for hackers |
874 | Found in file hv.h | |
875 | ||
954c1994 GS |
876 | =item HeKLEN |
877 | ||
878 | If this is negative, and amounts to C<HEf_SVKEY>, it indicates the entry | |
879 | holds an C<SV*> key. Otherwise, holds the actual length of the key. Can | |
880 | be assigned to. The C<HePV()> macro is usually preferable for finding key | |
881 | lengths. | |
882 | ||
883 | STRLEN HeKLEN(HE* he) | |
884 | ||
497711e7 GS |
885 | =for hackers |
886 | Found in file hv.h | |
887 | ||
954c1994 GS |
888 | =item HePV |
889 | ||
890 | Returns the key slot of the hash entry as a C<char*> value, doing any | |
891 | necessary dereferencing of possibly C<SV*> keys. The length of the string | |
892 | is placed in C<len> (this is a macro, so do I<not> use C<&len>). If you do | |
893 | not care about what the length of the key is, you may use the global | |
894 | variable C<PL_na>, though this is rather less efficient than using a local | |
895 | variable. Remember though, that hash keys in perl are free to contain | |
896 | embedded nulls, so using C<strlen()> or similar is not a good way to find | |
897 | the length of hash keys. This is very similar to the C<SvPV()> macro | |
898 | described elsewhere in this document. | |
899 | ||
900 | char* HePV(HE* he, STRLEN len) | |
901 | ||
497711e7 GS |
902 | =for hackers |
903 | Found in file hv.h | |
904 | ||
954c1994 GS |
905 | =item HeSVKEY |
906 | ||
907 | Returns the key as an C<SV*>, or C<Nullsv> if the hash entry does not | |
908 | contain an C<SV*> key. | |
909 | ||
910 | SV* HeSVKEY(HE* he) | |
911 | ||
497711e7 GS |
912 | =for hackers |
913 | Found in file hv.h | |
914 | ||
954c1994 GS |
915 | =item HeSVKEY_force |
916 | ||
917 | Returns the key as an C<SV*>. Will create and return a temporary mortal | |
918 | C<SV*> if the hash entry contains only a C<char*> key. | |
919 | ||
920 | SV* HeSVKEY_force(HE* he) | |
921 | ||
497711e7 GS |
922 | =for hackers |
923 | Found in file hv.h | |
924 | ||
954c1994 GS |
925 | =item HeSVKEY_set |
926 | ||
927 | Sets the key to a given C<SV*>, taking care to set the appropriate flags to | |
928 | indicate the presence of an C<SV*> key, and returns the same | |
929 | C<SV*>. | |
930 | ||
931 | SV* HeSVKEY_set(HE* he, SV* sv) | |
932 | ||
497711e7 GS |
933 | =for hackers |
934 | Found in file hv.h | |
935 | ||
954c1994 GS |
936 | =item HeVAL |
937 | ||
938 | Returns the value slot (type C<SV*>) stored in the hash entry. | |
939 | ||
940 | SV* HeVAL(HE* he) | |
941 | ||
497711e7 GS |
942 | =for hackers |
943 | Found in file hv.h | |
944 | ||
954c1994 GS |
945 | =item HvNAME |
946 | ||
947 | Returns the package name of a stash. See C<SvSTASH>, C<CvSTASH>. | |
948 | ||
949 | char* HvNAME(HV* stash) | |
950 | ||
497711e7 GS |
951 | =for hackers |
952 | Found in file hv.h | |
953 | ||
954c1994 GS |
954 | =item hv_clear |
955 | ||
956 | Clears a hash, making it empty. | |
957 | ||
958 | void hv_clear(HV* tb) | |
959 | ||
497711e7 GS |
960 | =for hackers |
961 | Found in file hv.c | |
962 | ||
954c1994 GS |
963 | =item hv_delete |
964 | ||
965 | Deletes a key/value pair in the hash. The value SV is removed from the | |
1c846c1f | 966 | hash and returned to the caller. The C<klen> is the length of the key. |
954c1994 GS |
967 | The C<flags> value will normally be zero; if set to G_DISCARD then NULL |
968 | will be returned. | |
969 | ||
da58a35d | 970 | SV* hv_delete(HV* tb, const char* key, I32 klen, I32 flags) |
954c1994 | 971 | |
497711e7 GS |
972 | =for hackers |
973 | Found in file hv.c | |
974 | ||
954c1994 GS |
975 | =item hv_delete_ent |
976 | ||
977 | Deletes a key/value pair in the hash. The value SV is removed from the | |
978 | hash and returned to the caller. The C<flags> value will normally be zero; | |
979 | if set to G_DISCARD then NULL will be returned. C<hash> can be a valid | |
980 | precomputed hash value, or 0 to ask for it to be computed. | |
981 | ||
982 | SV* hv_delete_ent(HV* tb, SV* key, I32 flags, U32 hash) | |
983 | ||
497711e7 GS |
984 | =for hackers |
985 | Found in file hv.c | |
986 | ||
954c1994 GS |
987 | =item hv_exists |
988 | ||
989 | Returns a boolean indicating whether the specified hash key exists. The | |
990 | C<klen> is the length of the key. | |
991 | ||
da58a35d | 992 | bool hv_exists(HV* tb, const char* key, I32 klen) |
954c1994 | 993 | |
497711e7 GS |
994 | =for hackers |
995 | Found in file hv.c | |
996 | ||
954c1994 GS |
997 | =item hv_exists_ent |
998 | ||
999 | Returns a boolean indicating whether the specified hash key exists. C<hash> | |
1000 | can be a valid precomputed hash value, or 0 to ask for it to be | |
1001 | computed. | |
1002 | ||
1003 | bool hv_exists_ent(HV* tb, SV* key, U32 hash) | |
1004 | ||
497711e7 GS |
1005 | =for hackers |
1006 | Found in file hv.c | |
1007 | ||
954c1994 GS |
1008 | =item hv_fetch |
1009 | ||
1010 | Returns the SV which corresponds to the specified key in the hash. The | |
1011 | C<klen> is the length of the key. If C<lval> is set then the fetch will be | |
1012 | part of a store. Check that the return value is non-null before | |
f4758303 | 1013 | dereferencing it to an C<SV*>. |
954c1994 | 1014 | |
96f1132b | 1015 | See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for more |
954c1994 GS |
1016 | information on how to use this function on tied hashes. |
1017 | ||
da58a35d | 1018 | SV** hv_fetch(HV* tb, const char* key, I32 klen, I32 lval) |
954c1994 | 1019 | |
497711e7 GS |
1020 | =for hackers |
1021 | Found in file hv.c | |
1022 | ||
954c1994 GS |
1023 | =item hv_fetch_ent |
1024 | ||
1025 | Returns the hash entry which corresponds to the specified key in the hash. | |
1026 | C<hash> must be a valid precomputed hash number for the given C<key>, or 0 | |
1027 | if you want the function to compute it. IF C<lval> is set then the fetch | |
1028 | will be part of a store. Make sure the return value is non-null before | |
1029 | accessing it. The return value when C<tb> is a tied hash is a pointer to a | |
1030 | static location, so be sure to make a copy of the structure if you need to | |
1c846c1f | 1031 | store it somewhere. |
954c1994 | 1032 | |
96f1132b | 1033 | See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for more |
954c1994 GS |
1034 | information on how to use this function on tied hashes. |
1035 | ||
1036 | HE* hv_fetch_ent(HV* tb, SV* key, I32 lval, U32 hash) | |
1037 | ||
497711e7 GS |
1038 | =for hackers |
1039 | Found in file hv.c | |
1040 | ||
954c1994 GS |
1041 | =item hv_iterinit |
1042 | ||
1043 | Prepares a starting point to traverse a hash table. Returns the number of | |
1044 | keys in the hash (i.e. the same as C<HvKEYS(tb)>). The return value is | |
1c846c1f | 1045 | currently only meaningful for hashes without tie magic. |
954c1994 GS |
1046 | |
1047 | NOTE: Before version 5.004_65, C<hv_iterinit> used to return the number of | |
1048 | hash buckets that happen to be in use. If you still need that esoteric | |
1049 | value, you can get it through the macro C<HvFILL(tb)>. | |
1050 | ||
1051 | I32 hv_iterinit(HV* tb) | |
1052 | ||
497711e7 GS |
1053 | =for hackers |
1054 | Found in file hv.c | |
1055 | ||
954c1994 GS |
1056 | =item hv_iterkey |
1057 | ||
1058 | Returns the key from the current position of the hash iterator. See | |
1059 | C<hv_iterinit>. | |
1060 | ||
1061 | char* hv_iterkey(HE* entry, I32* retlen) | |
1062 | ||
497711e7 GS |
1063 | =for hackers |
1064 | Found in file hv.c | |
1065 | ||
954c1994 GS |
1066 | =item hv_iterkeysv |
1067 | ||
1068 | Returns the key as an C<SV*> from the current position of the hash | |
1069 | iterator. The return value will always be a mortal copy of the key. Also | |
1070 | see C<hv_iterinit>. | |
1071 | ||
1072 | SV* hv_iterkeysv(HE* entry) | |
1073 | ||
497711e7 GS |
1074 | =for hackers |
1075 | Found in file hv.c | |
1076 | ||
954c1994 GS |
1077 | =item hv_iternext |
1078 | ||
1079 | Returns entries from a hash iterator. See C<hv_iterinit>. | |
1080 | ||
1081 | HE* hv_iternext(HV* tb) | |
1082 | ||
497711e7 GS |
1083 | =for hackers |
1084 | Found in file hv.c | |
1085 | ||
954c1994 GS |
1086 | =item hv_iternextsv |
1087 | ||
1088 | Performs an C<hv_iternext>, C<hv_iterkey>, and C<hv_iterval> in one | |
1089 | operation. | |
1090 | ||
1091 | SV* hv_iternextsv(HV* hv, char** key, I32* retlen) | |
1092 | ||
497711e7 GS |
1093 | =for hackers |
1094 | Found in file hv.c | |
1095 | ||
954c1994 GS |
1096 | =item hv_iterval |
1097 | ||
1098 | Returns the value from the current position of the hash iterator. See | |
1099 | C<hv_iterkey>. | |
1100 | ||
1101 | SV* hv_iterval(HV* tb, HE* entry) | |
1102 | ||
497711e7 GS |
1103 | =for hackers |
1104 | Found in file hv.c | |
1105 | ||
954c1994 GS |
1106 | =item hv_magic |
1107 | ||
1108 | Adds magic to a hash. See C<sv_magic>. | |
1109 | ||
1110 | void hv_magic(HV* hv, GV* gv, int how) | |
1111 | ||
497711e7 GS |
1112 | =for hackers |
1113 | Found in file hv.c | |
1114 | ||
954c1994 GS |
1115 | =item hv_store |
1116 | ||
1117 | Stores an SV in a hash. The hash key is specified as C<key> and C<klen> is | |
1118 | the length of the key. The C<hash> parameter is the precomputed hash | |
1119 | value; if it is zero then Perl will compute it. The return value will be | |
1120 | NULL if the operation failed or if the value did not need to be actually | |
1121 | stored within the hash (as in the case of tied hashes). Otherwise it can | |
1122 | be dereferenced to get the original C<SV*>. Note that the caller is | |
1123 | responsible for suitably incrementing the reference count of C<val> before | |
1c846c1f | 1124 | the call, and decrementing it if the function returned NULL. |
954c1994 | 1125 | |
96f1132b | 1126 | See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for more |
954c1994 GS |
1127 | information on how to use this function on tied hashes. |
1128 | ||
da58a35d | 1129 | SV** hv_store(HV* tb, const char* key, I32 klen, SV* val, U32 hash) |
954c1994 | 1130 | |
497711e7 GS |
1131 | =for hackers |
1132 | Found in file hv.c | |
1133 | ||
954c1994 GS |
1134 | =item hv_store_ent |
1135 | ||
1136 | Stores C<val> in a hash. The hash key is specified as C<key>. The C<hash> | |
1137 | parameter is the precomputed hash value; if it is zero then Perl will | |
1138 | compute it. The return value is the new hash entry so created. It will be | |
1139 | NULL if the operation failed or if the value did not need to be actually | |
1140 | stored within the hash (as in the case of tied hashes). Otherwise the | |
f22d8e4b | 1141 | contents of the return value can be accessed using the C<He?> macros |
954c1994 GS |
1142 | described here. Note that the caller is responsible for suitably |
1143 | incrementing the reference count of C<val> before the call, and | |
1c846c1f | 1144 | decrementing it if the function returned NULL. |
954c1994 | 1145 | |
96f1132b | 1146 | See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for more |
954c1994 GS |
1147 | information on how to use this function on tied hashes. |
1148 | ||
1149 | HE* hv_store_ent(HV* tb, SV* key, SV* val, U32 hash) | |
1150 | ||
497711e7 GS |
1151 | =for hackers |
1152 | Found in file hv.c | |
1153 | ||
954c1994 GS |
1154 | =item hv_undef |
1155 | ||
1156 | Undefines the hash. | |
1157 | ||
1158 | void hv_undef(HV* tb) | |
1159 | ||
497711e7 GS |
1160 | =for hackers |
1161 | Found in file hv.c | |
1162 | ||
94bdecf9 | 1163 | =item newHV |
d2cc3551 | 1164 | |
94bdecf9 | 1165 | Creates a new HV. The reference count is set to 1. |
d2cc3551 | 1166 | |
94bdecf9 | 1167 | HV* newHV() |
d2cc3551 JH |
1168 | |
1169 | =for hackers | |
94bdecf9 | 1170 | Found in file hv.c |
d2cc3551 | 1171 | |
94bdecf9 | 1172 | =item Nullhv |
954c1994 | 1173 | |
94bdecf9 | 1174 | Null HV pointer. |
954c1994 | 1175 | |
954c1994 | 1176 | |
497711e7 | 1177 | =for hackers |
94bdecf9 | 1178 | Found in file hv.h |
497711e7 | 1179 | |
954c1994 | 1180 | |
94bdecf9 | 1181 | =back |
954c1994 | 1182 | |
94bdecf9 | 1183 | =head1 Magical Functions |
954c1994 | 1184 | |
94bdecf9 | 1185 | =over 8 |
497711e7 | 1186 | |
94bdecf9 | 1187 | =item mg_clear |
954c1994 | 1188 | |
94bdecf9 | 1189 | Clear something magical that the SV represents. See C<sv_magic>. |
954c1994 | 1190 | |
94bdecf9 | 1191 | int mg_clear(SV* sv) |
954c1994 | 1192 | |
497711e7 | 1193 | =for hackers |
94bdecf9 | 1194 | Found in file mg.c |
497711e7 | 1195 | |
94bdecf9 | 1196 | =item mg_copy |
954c1994 | 1197 | |
94bdecf9 | 1198 | Copies the magic from one SV to another. See C<sv_magic>. |
954c1994 | 1199 | |
94bdecf9 | 1200 | int mg_copy(SV* sv, SV* nsv, const char* key, I32 klen) |
954c1994 | 1201 | |
497711e7 | 1202 | =for hackers |
94bdecf9 | 1203 | Found in file mg.c |
497711e7 | 1204 | |
94bdecf9 | 1205 | =item mg_find |
954c1994 | 1206 | |
94bdecf9 | 1207 | Finds the magic pointer for type matching the SV. See C<sv_magic>. |
954c1994 | 1208 | |
94bdecf9 | 1209 | MAGIC* mg_find(SV* sv, int type) |
954c1994 | 1210 | |
497711e7 | 1211 | =for hackers |
94bdecf9 | 1212 | Found in file mg.c |
497711e7 | 1213 | |
94bdecf9 | 1214 | =item mg_free |
954c1994 | 1215 | |
94bdecf9 | 1216 | Free any magic storage used by the SV. See C<sv_magic>. |
954c1994 | 1217 | |
94bdecf9 | 1218 | int mg_free(SV* sv) |
954c1994 | 1219 | |
497711e7 | 1220 | =for hackers |
94bdecf9 | 1221 | Found in file mg.c |
497711e7 | 1222 | |
94bdecf9 | 1223 | =item mg_get |
eebe1485 | 1224 | |
94bdecf9 | 1225 | Do magic after a value is retrieved from the SV. See C<sv_magic>. |
282f25c9 | 1226 | |
94bdecf9 | 1227 | int mg_get(SV* sv) |
eebe1485 SC |
1228 | |
1229 | =for hackers | |
94bdecf9 | 1230 | Found in file mg.c |
eebe1485 | 1231 | |
94bdecf9 | 1232 | =item mg_length |
eebe1485 | 1233 | |
94bdecf9 | 1234 | Report on the SV's length. See C<sv_magic>. |
eebe1485 | 1235 | |
94bdecf9 | 1236 | U32 mg_length(SV* sv) |
eebe1485 SC |
1237 | |
1238 | =for hackers | |
94bdecf9 | 1239 | Found in file mg.c |
eebe1485 | 1240 | |
94bdecf9 | 1241 | =item mg_magical |
954c1994 | 1242 | |
94bdecf9 | 1243 | Turns on the magical status of an SV. See C<sv_magic>. |
954c1994 | 1244 | |
94bdecf9 | 1245 | void mg_magical(SV* sv) |
954c1994 | 1246 | |
497711e7 | 1247 | =for hackers |
94bdecf9 | 1248 | Found in file mg.c |
497711e7 | 1249 | |
94bdecf9 | 1250 | =item mg_set |
954c1994 | 1251 | |
94bdecf9 | 1252 | Do magic after a value is assigned to the SV. See C<sv_magic>. |
954c1994 | 1253 | |
94bdecf9 | 1254 | int mg_set(SV* sv) |
954c1994 | 1255 | |
497711e7 | 1256 | =for hackers |
94bdecf9 | 1257 | Found in file mg.c |
497711e7 | 1258 | |
94bdecf9 | 1259 | =item SvGETMAGIC |
954c1994 | 1260 | |
94bdecf9 JH |
1261 | Invokes C<mg_get> on an SV if it has 'get' magic. This macro evaluates its |
1262 | argument more than once. | |
954c1994 | 1263 | |
94bdecf9 | 1264 | void SvGETMAGIC(SV* sv) |
954c1994 | 1265 | |
497711e7 | 1266 | =for hackers |
94bdecf9 | 1267 | Found in file sv.h |
497711e7 | 1268 | |
a4f1a029 NIS |
1269 | =item SvLOCK |
1270 | ||
1271 | Arranges for a mutual exclusion lock to be obtained on sv if a suitable module | |
1272 | has been loaded. | |
1273 | ||
1274 | void SvLOCK(SV* sv) | |
1275 | ||
1276 | =for hackers | |
1277 | Found in file sv.h | |
1278 | ||
94bdecf9 | 1279 | =item SvSETMAGIC |
7d3fb230 | 1280 | |
94bdecf9 JH |
1281 | Invokes C<mg_set> on an SV if it has 'set' magic. This macro evaluates its |
1282 | argument more than once. | |
7d3fb230 | 1283 | |
94bdecf9 | 1284 | void SvSETMAGIC(SV* sv) |
7d3fb230 BS |
1285 | |
1286 | =for hackers | |
94bdecf9 | 1287 | Found in file sv.h |
7d3fb230 | 1288 | |
94bdecf9 | 1289 | =item SvSetMagicSV |
954c1994 | 1290 | |
94bdecf9 | 1291 | Like C<SvSetSV>, but does any set magic required afterwards. |
954c1994 | 1292 | |
94bdecf9 | 1293 | void SvSetMagicSV(SV* dsb, SV* ssv) |
954c1994 | 1294 | |
497711e7 | 1295 | =for hackers |
94bdecf9 | 1296 | Found in file sv.h |
497711e7 | 1297 | |
a4f1a029 NIS |
1298 | =item SvSetMagicSV_nosteal |
1299 | ||
1300 | Like C<SvSetMagicSV>, but does any set magic required afterwards. | |
1301 | ||
1302 | void SvSetMagicSV_nosteal(SV* dsv, SV* ssv) | |
1303 | ||
1304 | =for hackers | |
1305 | Found in file sv.h | |
1306 | ||
94bdecf9 | 1307 | =item SvSetSV |
954c1994 | 1308 | |
94bdecf9 JH |
1309 | Calls C<sv_setsv> if dsv is not the same as ssv. May evaluate arguments |
1310 | more than once. | |
1311 | ||
1312 | void SvSetSV(SV* dsb, SV* ssv) | |
954c1994 | 1313 | |
497711e7 | 1314 | =for hackers |
94bdecf9 | 1315 | Found in file sv.h |
497711e7 | 1316 | |
94bdecf9 | 1317 | =item SvSetSV_nosteal |
954c1994 | 1318 | |
94bdecf9 JH |
1319 | Calls a non-destructive version of C<sv_setsv> if dsv is not the same as |
1320 | ssv. May evaluate arguments more than once. | |
954c1994 | 1321 | |
94bdecf9 | 1322 | void SvSetSV_nosteal(SV* dsv, SV* ssv) |
954c1994 | 1323 | |
497711e7 | 1324 | =for hackers |
94bdecf9 | 1325 | Found in file sv.h |
497711e7 | 1326 | |
a4f1a029 NIS |
1327 | =item SvSHARE |
1328 | ||
1329 | Arranges for sv to be shared between threads if a suitable module | |
1330 | has been loaded. | |
1331 | ||
1332 | void SvSHARE(SV* sv) | |
1333 | ||
1334 | =for hackers | |
1335 | Found in file sv.h | |
1336 | ||
954c1994 | 1337 | |
94bdecf9 | 1338 | =back |
954c1994 | 1339 | |
94bdecf9 | 1340 | =head1 Memory Management |
954c1994 | 1341 | |
94bdecf9 | 1342 | =over 8 |
497711e7 | 1343 | |
94bdecf9 | 1344 | =item Copy |
954c1994 | 1345 | |
94bdecf9 JH |
1346 | The XSUB-writer's interface to the C C<memcpy> function. The C<src> is the |
1347 | source, C<dest> is the destination, C<nitems> is the number of items, and C<type> is | |
1348 | the type. May fail on overlapping copies. See also C<Move>. | |
954c1994 | 1349 | |
94bdecf9 | 1350 | void Copy(void* src, void* dest, int nitems, type) |
954c1994 | 1351 | |
497711e7 | 1352 | =for hackers |
94bdecf9 | 1353 | Found in file handy.h |
497711e7 | 1354 | |
94bdecf9 | 1355 | =item Move |
954c1994 | 1356 | |
94bdecf9 JH |
1357 | The XSUB-writer's interface to the C C<memmove> function. The C<src> is the |
1358 | source, C<dest> is the destination, C<nitems> is the number of items, and C<type> is | |
1359 | the type. Can do overlapping moves. See also C<Copy>. | |
954c1994 | 1360 | |
94bdecf9 | 1361 | void Move(void* src, void* dest, int nitems, type) |
954c1994 | 1362 | |
497711e7 | 1363 | =for hackers |
94bdecf9 | 1364 | Found in file handy.h |
497711e7 | 1365 | |
94bdecf9 | 1366 | =item New |
954c1994 | 1367 | |
94bdecf9 | 1368 | The XSUB-writer's interface to the C C<malloc> function. |
954c1994 | 1369 | |
94bdecf9 | 1370 | void New(int id, void* ptr, int nitems, type) |
954c1994 | 1371 | |
497711e7 | 1372 | =for hackers |
94bdecf9 | 1373 | Found in file handy.h |
497711e7 | 1374 | |
94bdecf9 | 1375 | =item Newc |
954c1994 | 1376 | |
94bdecf9 JH |
1377 | The XSUB-writer's interface to the C C<malloc> function, with |
1378 | cast. | |
954c1994 | 1379 | |
94bdecf9 | 1380 | void Newc(int id, void* ptr, int nitems, type, cast) |
954c1994 | 1381 | |
497711e7 | 1382 | =for hackers |
94bdecf9 | 1383 | Found in file handy.h |
954c1994 | 1384 | |
94bdecf9 | 1385 | =item NEWSV |
497711e7 | 1386 | |
94bdecf9 JH |
1387 | Creates a new SV. A non-zero C<len> parameter indicates the number of |
1388 | bytes of preallocated string space the SV should have. An extra byte for a | |
1389 | tailing NUL is also reserved. (SvPOK is not set for the SV even if string | |
1390 | space is allocated.) The reference count for the new SV is set to 1. | |
1391 | C<id> is an integer id between 0 and 1299 (used to identify leaks). | |
954c1994 | 1392 | |
954c1994 | 1393 | |
94bdecf9 | 1394 | SV* NEWSV(int id, STRLEN len) |
954c1994 | 1395 | |
497711e7 | 1396 | =for hackers |
94bdecf9 | 1397 | Found in file handy.h |
497711e7 | 1398 | |
94bdecf9 | 1399 | =item Newz |
954c1994 | 1400 | |
94bdecf9 JH |
1401 | The XSUB-writer's interface to the C C<malloc> function. The allocated |
1402 | memory is zeroed with C<memzero>. | |
954c1994 | 1403 | |
94bdecf9 | 1404 | void Newz(int id, void* ptr, int nitems, type) |
954c1994 | 1405 | |
497711e7 GS |
1406 | =for hackers |
1407 | Found in file handy.h | |
1408 | ||
94bdecf9 | 1409 | =item Renew |
954c1994 | 1410 | |
94bdecf9 | 1411 | The XSUB-writer's interface to the C C<realloc> function. |
954c1994 | 1412 | |
94bdecf9 | 1413 | void Renew(void* ptr, int nitems, type) |
954c1994 | 1414 | |
497711e7 GS |
1415 | =for hackers |
1416 | Found in file handy.h | |
1417 | ||
94bdecf9 | 1418 | =item Renewc |
954c1994 | 1419 | |
94bdecf9 JH |
1420 | The XSUB-writer's interface to the C C<realloc> function, with |
1421 | cast. | |
954c1994 | 1422 | |
94bdecf9 | 1423 | void Renewc(void* ptr, int nitems, type, cast) |
954c1994 | 1424 | |
497711e7 | 1425 | =for hackers |
94bdecf9 | 1426 | Found in file handy.h |
497711e7 | 1427 | |
94bdecf9 | 1428 | =item Safefree |
954c1994 | 1429 | |
94bdecf9 | 1430 | The XSUB-writer's interface to the C C<free> function. |
954c1994 | 1431 | |
94bdecf9 | 1432 | void Safefree(void* ptr) |
954c1994 | 1433 | |
497711e7 GS |
1434 | =for hackers |
1435 | Found in file handy.h | |
1436 | ||
94bdecf9 | 1437 | =item savepv |
954c1994 | 1438 | |
94bdecf9 | 1439 | Copy a string to a safe spot. This does not use an SV. |
954c1994 | 1440 | |
94bdecf9 | 1441 | char* savepv(const char* sv) |
954c1994 | 1442 | |
497711e7 | 1443 | =for hackers |
94bdecf9 | 1444 | Found in file util.c |
497711e7 | 1445 | |
94bdecf9 | 1446 | =item savepvn |
954c1994 | 1447 | |
94bdecf9 | 1448 | Copy a string to a safe spot. The C<len> indicates number of bytes to |
a4f1a029 NIS |
1449 | copy. If pointer is NULL allocate space for a string of size specified. |
1450 | This does not use an SV. | |
954c1994 | 1451 | |
94bdecf9 | 1452 | char* savepvn(const char* sv, I32 len) |
954c1994 | 1453 | |
497711e7 | 1454 | =for hackers |
94bdecf9 | 1455 | Found in file util.c |
497711e7 | 1456 | |
a4f1a029 NIS |
1457 | =item savesharedpv |
1458 | ||
1459 | Copy a string to a safe spot in memory shared between threads. | |
1460 | This does not use an SV. | |
1461 | ||
1462 | char* savesharedpv(const char* sv) | |
1463 | ||
1464 | =for hackers | |
1465 | Found in file util.c | |
1466 | ||
94bdecf9 | 1467 | =item StructCopy |
954c1994 | 1468 | |
94bdecf9 | 1469 | This is an architecture-independent macro to copy one structure to another. |
954c1994 | 1470 | |
94bdecf9 | 1471 | void StructCopy(type src, type dest, type) |
954c1994 | 1472 | |
497711e7 | 1473 | =for hackers |
94bdecf9 | 1474 | Found in file handy.h |
497711e7 | 1475 | |
94bdecf9 | 1476 | =item Zero |
954c1994 | 1477 | |
94bdecf9 JH |
1478 | The XSUB-writer's interface to the C C<memzero> function. The C<dest> is the |
1479 | destination, C<nitems> is the number of items, and C<type> is the type. | |
954c1994 | 1480 | |
94bdecf9 | 1481 | void Zero(void* dest, int nitems, type) |
954c1994 | 1482 | |
497711e7 | 1483 | =for hackers |
94bdecf9 | 1484 | Found in file handy.h |
497711e7 | 1485 | |
954c1994 | 1486 | |
94bdecf9 | 1487 | =back |
954c1994 | 1488 | |
94bdecf9 | 1489 | =head1 Miscellaneous Functions |
954c1994 | 1490 | |
94bdecf9 | 1491 | =over 8 |
497711e7 | 1492 | |
94bdecf9 | 1493 | =item fbm_compile |
8b4ac5a4 | 1494 | |
94bdecf9 JH |
1495 | Analyses the string in order to make fast searches on it using fbm_instr() |
1496 | -- the Boyer-Moore algorithm. | |
8b4ac5a4 | 1497 | |
94bdecf9 | 1498 | void fbm_compile(SV* sv, U32 flags) |
8b4ac5a4 JH |
1499 | |
1500 | =for hackers | |
94bdecf9 | 1501 | Found in file util.c |
8b4ac5a4 | 1502 | |
94bdecf9 | 1503 | =item fbm_instr |
954c1994 | 1504 | |
94bdecf9 JH |
1505 | Returns the location of the SV in the string delimited by C<str> and |
1506 | C<strend>. It returns C<Nullch> if the string can't be found. The C<sv> | |
1507 | does not have to be fbm_compiled, but the search will not be as fast | |
1508 | then. | |
954c1994 | 1509 | |
94bdecf9 | 1510 | char* fbm_instr(unsigned char* big, unsigned char* bigend, SV* littlesv, U32 flags) |
954c1994 | 1511 | |
497711e7 | 1512 | =for hackers |
94bdecf9 | 1513 | Found in file util.c |
497711e7 | 1514 | |
94bdecf9 | 1515 | =item form |
954c1994 | 1516 | |
94bdecf9 JH |
1517 | Takes a sprintf-style format pattern and conventional |
1518 | (non-SV) arguments and returns the formatted string. | |
954c1994 | 1519 | |
94bdecf9 | 1520 | (char *) Perl_form(pTHX_ const char* pat, ...) |
954c1994 | 1521 | |
94bdecf9 | 1522 | can be used any place a string (char *) is required: |
497711e7 | 1523 | |
94bdecf9 | 1524 | char * s = Perl_form("%d.%d",major,minor); |
954c1994 | 1525 | |
94bdecf9 JH |
1526 | Uses a single private buffer so if you want to format several strings you |
1527 | must explicitly copy the earlier strings away (and free the copies when you | |
1528 | are done). | |
954c1994 | 1529 | |
94bdecf9 | 1530 | char* form(const char* pat, ...) |
954c1994 | 1531 | |
497711e7 | 1532 | =for hackers |
94bdecf9 | 1533 | Found in file util.c |
497711e7 | 1534 | |
94bdecf9 | 1535 | =item getcwd_sv |
954c1994 | 1536 | |
94bdecf9 | 1537 | Fill the sv with current working directory |
954c1994 | 1538 | |
94bdecf9 | 1539 | int getcwd_sv(SV* sv) |
954c1994 | 1540 | |
497711e7 | 1541 | =for hackers |
94bdecf9 | 1542 | Found in file util.c |
497711e7 | 1543 | |
94bdecf9 | 1544 | =item strEQ |
954c1994 | 1545 | |
94bdecf9 | 1546 | Test two strings to see if they are equal. Returns true or false. |
954c1994 | 1547 | |
94bdecf9 | 1548 | bool strEQ(char* s1, char* s2) |
954c1994 | 1549 | |
497711e7 | 1550 | =for hackers |
94bdecf9 | 1551 | Found in file handy.h |
497711e7 | 1552 | |
94bdecf9 | 1553 | =item strGE |
1c846c1f | 1554 | |
94bdecf9 JH |
1555 | Test two strings to see if the first, C<s1>, is greater than or equal to |
1556 | the second, C<s2>. Returns true or false. | |
1c846c1f | 1557 | |
94bdecf9 | 1558 | bool strGE(char* s1, char* s2) |
1c846c1f NIS |
1559 | |
1560 | =for hackers | |
94bdecf9 | 1561 | Found in file handy.h |
1c846c1f | 1562 | |
94bdecf9 | 1563 | =item strGT |
954c1994 | 1564 | |
94bdecf9 JH |
1565 | Test two strings to see if the first, C<s1>, is greater than the second, |
1566 | C<s2>. Returns true or false. | |
954c1994 | 1567 | |
94bdecf9 | 1568 | bool strGT(char* s1, char* s2) |
954c1994 | 1569 | |
497711e7 | 1570 | =for hackers |
94bdecf9 | 1571 | Found in file handy.h |
497711e7 | 1572 | |
94bdecf9 | 1573 | =item strLE |
954c1994 | 1574 | |
94bdecf9 JH |
1575 | Test two strings to see if the first, C<s1>, is less than or equal to the |
1576 | second, C<s2>. Returns true or false. | |
954c1994 | 1577 | |
94bdecf9 | 1578 | bool strLE(char* s1, char* s2) |
954c1994 | 1579 | |
497711e7 | 1580 | =for hackers |
94bdecf9 | 1581 | Found in file handy.h |
497711e7 | 1582 | |
94bdecf9 | 1583 | =item strLT |
1a3327fb | 1584 | |
94bdecf9 JH |
1585 | Test two strings to see if the first, C<s1>, is less than the second, |
1586 | C<s2>. Returns true or false. | |
1a3327fb | 1587 | |
94bdecf9 | 1588 | bool strLT(char* s1, char* s2) |
1a3327fb | 1589 | |
497711e7 | 1590 | =for hackers |
94bdecf9 | 1591 | Found in file handy.h |
497711e7 | 1592 | |
94bdecf9 | 1593 | =item strNE |
954c1994 | 1594 | |
94bdecf9 JH |
1595 | Test two strings to see if they are different. Returns true or |
1596 | false. | |
1597 | ||
1598 | bool strNE(char* s1, char* s2) | |
954c1994 | 1599 | |
497711e7 | 1600 | =for hackers |
94bdecf9 | 1601 | Found in file handy.h |
497711e7 | 1602 | |
94bdecf9 | 1603 | =item strnEQ |
954c1994 | 1604 | |
94bdecf9 JH |
1605 | Test two strings to see if they are equal. The C<len> parameter indicates |
1606 | the number of bytes to compare. Returns true or false. (A wrapper for | |
1607 | C<strncmp>). | |
1608 | ||
1609 | bool strnEQ(char* s1, char* s2, STRLEN len) | |
954c1994 | 1610 | |
497711e7 | 1611 | =for hackers |
94bdecf9 | 1612 | Found in file handy.h |
497711e7 | 1613 | |
94bdecf9 | 1614 | =item strnNE |
954c1994 | 1615 | |
94bdecf9 JH |
1616 | Test two strings to see if they are different. The C<len> parameter |
1617 | indicates the number of bytes to compare. Returns true or false. (A | |
1618 | wrapper for C<strncmp>). | |
954c1994 | 1619 | |
94bdecf9 | 1620 | bool strnNE(char* s1, char* s2, STRLEN len) |
954c1994 | 1621 | |
497711e7 GS |
1622 | =for hackers |
1623 | Found in file handy.h | |
1624 | ||
f4758303 | 1625 | |
94bdecf9 | 1626 | =back |
7207e29d | 1627 | |
94bdecf9 | 1628 | =head1 Numeric functions |
7207e29d | 1629 | |
94bdecf9 | 1630 | =over 8 |
f4758303 | 1631 | |
94bdecf9 | 1632 | =item grok_bin |
f4758303 | 1633 | |
94bdecf9 JH |
1634 | converts a string representing a binary number to numeric form. |
1635 | ||
1636 | On entry I<start> and I<*len> give the string to scan, I<*flags> gives | |
1637 | conversion flags, and I<result> should be NULL or a pointer to an NV. | |
1638 | The scan stops at the end of the string, or the first invalid character. | |
1639 | On return I<*len> is set to the length scanned string, and I<*flags> gives | |
1640 | output flags. | |
1641 | ||
1642 | If the value is <= UV_MAX it is returned as a UV, the output flags are clear, | |
1643 | and nothing is written to I<*result>. If the value is > UV_MAX C<grok_bin> | |
1644 | returns UV_MAX, sets C<PERL_SCAN_GREATER_THAN_UV_MAX> in the output flags, | |
1645 | and writes the value to I<*result> (or the value is discarded if I<result> | |
1646 | is NULL). | |
1647 | ||
1648 | The hex number may optionally be prefixed with "0b" or "b" unless | |
1649 | C<PERL_SCAN_DISALLOW_PREFIX> is set in I<*flags> on entry. If | |
1650 | C<PERL_SCAN_ALLOW_UNDERSCORES> is set in I<*flags> then the binary | |
1651 | number may use '_' characters to separate digits. | |
1652 | ||
1653 | UV grok_bin(char* start, STRLEN* len, I32* flags, NV *result) | |
f4758303 JP |
1654 | |
1655 | =for hackers | |
94bdecf9 | 1656 | Found in file numeric.c |
f4758303 | 1657 | |
94bdecf9 | 1658 | =item grok_hex |
954c1994 | 1659 | |
94bdecf9 JH |
1660 | converts a string representing a hex number to numeric form. |
1661 | ||
1662 | On entry I<start> and I<*len> give the string to scan, I<*flags> gives | |
1663 | conversion flags, and I<result> should be NULL or a pointer to an NV. | |
1664 | The scan stops at the end of the string, or the first non-hex-digit character. | |
1665 | On return I<*len> is set to the length scanned string, and I<*flags> gives | |
1666 | output flags. | |
1667 | ||
1668 | If the value is <= UV_MAX it is returned as a UV, the output flags are clear, | |
1669 | and nothing is written to I<*result>. If the value is > UV_MAX C<grok_hex> | |
1670 | returns UV_MAX, sets C<PERL_SCAN_GREATER_THAN_UV_MAX> in the output flags, | |
1671 | and writes the value to I<*result> (or the value is discarded if I<result> | |
1672 | is NULL). | |
1673 | ||
1674 | The hex number may optionally be prefixed with "0x" or "x" unless | |
1675 | C<PERL_SCAN_DISALLOW_PREFIX> is set in I<*flags> on entry. If | |
1676 | C<PERL_SCAN_ALLOW_UNDERSCORES> is set in I<*flags> then the hex | |
1677 | number may use '_' characters to separate digits. | |
1678 | ||
1679 | UV grok_hex(char* start, STRLEN* len, I32* flags, NV *result) | |
954c1994 | 1680 | |
497711e7 | 1681 | =for hackers |
94bdecf9 | 1682 | Found in file numeric.c |
497711e7 | 1683 | |
94bdecf9 | 1684 | =item grok_number |
954c1994 | 1685 | |
94bdecf9 JH |
1686 | Recognise (or not) a number. The type of the number is returned |
1687 | (0 if unrecognised), otherwise it is a bit-ORed combination of | |
1688 | IS_NUMBER_IN_UV, IS_NUMBER_GREATER_THAN_UV_MAX, IS_NUMBER_NOT_INT, | |
1689 | IS_NUMBER_NEG, IS_NUMBER_INFINITY, IS_NUMBER_NAN (defined in perl.h). | |
1690 | ||
1691 | If the value of the number can fit an in UV, it is returned in the *valuep | |
1692 | IS_NUMBER_IN_UV will be set to indicate that *valuep is valid, IS_NUMBER_IN_UV | |
1693 | will never be set unless *valuep is valid, but *valuep may have been assigned | |
1694 | to during processing even though IS_NUMBER_IN_UV is not set on return. | |
1695 | If valuep is NULL, IS_NUMBER_IN_UV will be set for the same cases as when | |
1696 | valuep is non-NULL, but no actual assignment (or SEGV) will occur. | |
1697 | ||
1698 | IS_NUMBER_NOT_INT will be set with IS_NUMBER_IN_UV if trailing decimals were | |
1699 | seen (in which case *valuep gives the true value truncated to an integer), and | |
1700 | IS_NUMBER_NEG if the number is negative (in which case *valuep holds the | |
1701 | absolute value). IS_NUMBER_IN_UV is not set if e notation was used or the | |
1702 | number is larger than a UV. | |
1703 | ||
1704 | int grok_number(const char *pv, STRLEN len, UV *valuep) | |
954c1994 | 1705 | |
497711e7 | 1706 | =for hackers |
94bdecf9 | 1707 | Found in file numeric.c |
497711e7 | 1708 | |
94bdecf9 | 1709 | =item grok_numeric_radix |
954c1994 | 1710 | |
94bdecf9 JH |
1711 | Scan and skip for a numeric decimal separator (radix). |
1712 | ||
1713 | bool grok_numeric_radix(const char **sp, const char *send) | |
954c1994 | 1714 | |
497711e7 | 1715 | =for hackers |
94bdecf9 | 1716 | Found in file numeric.c |
497711e7 | 1717 | |
94bdecf9 | 1718 | =item grok_oct |
954c1994 | 1719 | |
94bdecf9 JH |
1720 | |
1721 | UV grok_oct(char* start, STRLEN* len, I32* flags, NV *result) | |
954c1994 | 1722 | |
497711e7 | 1723 | =for hackers |
94bdecf9 | 1724 | Found in file numeric.c |
497711e7 | 1725 | |
94bdecf9 | 1726 | =item scan_bin |
954c1994 | 1727 | |
94bdecf9 JH |
1728 | For backwards compatibility. Use C<grok_bin> instead. |
1729 | ||
1730 | NV scan_bin(char* start, STRLEN len, STRLEN* retlen) | |
954c1994 | 1731 | |
497711e7 | 1732 | =for hackers |
94bdecf9 | 1733 | Found in file numeric.c |
497711e7 | 1734 | |
94bdecf9 | 1735 | =item scan_hex |
954c1994 | 1736 | |
94bdecf9 JH |
1737 | For backwards compatibility. Use C<grok_hex> instead. |
1738 | ||
1739 | NV scan_hex(char* start, STRLEN len, STRLEN* retlen) | |
954c1994 | 1740 | |
497711e7 | 1741 | =for hackers |
94bdecf9 | 1742 | Found in file numeric.c |
497711e7 | 1743 | |
94bdecf9 | 1744 | =item scan_oct |
954c1994 | 1745 | |
94bdecf9 | 1746 | For backwards compatibility. Use C<grok_oct> instead. |
954c1994 | 1747 | |
94bdecf9 | 1748 | NV scan_oct(char* start, STRLEN len, STRLEN* retlen) |
954c1994 | 1749 | |
497711e7 | 1750 | =for hackers |
94bdecf9 | 1751 | Found in file numeric.c |
497711e7 | 1752 | |
645c22ef | 1753 | |
94bdecf9 | 1754 | =back |
645c22ef | 1755 | |
94bdecf9 JH |
1756 | =head1 Optree Manipulation Functions |
1757 | ||
1758 | =over 8 | |
1759 | ||
1760 | =item cv_const_sv | |
1761 | ||
1762 | If C<cv> is a constant sub eligible for inlining. returns the constant | |
1763 | value returned by the sub. Otherwise, returns NULL. | |
1764 | ||
1765 | Constant subs can be created with C<newCONSTSUB> or as described in | |
1766 | L<perlsub/"Constant Functions">. | |
1767 | ||
1768 | SV* cv_const_sv(CV* cv) | |
645c22ef DM |
1769 | |
1770 | =for hackers | |
94bdecf9 | 1771 | Found in file op.c |
645c22ef | 1772 | |
94bdecf9 | 1773 | =item newCONSTSUB |
954c1994 | 1774 | |
94bdecf9 JH |
1775 | Creates a constant sub equivalent to Perl C<sub FOO () { 123 }> which is |
1776 | eligible for inlining at compile-time. | |
954c1994 | 1777 | |
94bdecf9 | 1778 | CV* newCONSTSUB(HV* stash, char* name, SV* sv) |
954c1994 | 1779 | |
497711e7 | 1780 | =for hackers |
94bdecf9 | 1781 | Found in file op.c |
497711e7 | 1782 | |
94bdecf9 | 1783 | =item newXS |
954c1994 | 1784 | |
94bdecf9 | 1785 | Used by C<xsubpp> to hook up XSUBs as Perl subs. |
954c1994 | 1786 | |
94bdecf9 JH |
1787 | =for hackers |
1788 | Found in file op.c | |
1789 | ||
1790 | ||
1791 | =back | |
1792 | ||
94bdecf9 JH |
1793 | =head1 Stack Manipulation Macros |
1794 | ||
1795 | =over 8 | |
1796 | ||
1797 | =item dMARK | |
954c1994 | 1798 | |
94bdecf9 JH |
1799 | Declare a stack marker variable, C<mark>, for the XSUB. See C<MARK> and |
1800 | C<dORIGMARK>. | |
954c1994 | 1801 | |
94bdecf9 | 1802 | dMARK; |
954c1994 | 1803 | |
497711e7 | 1804 | =for hackers |
94bdecf9 | 1805 | Found in file pp.h |
497711e7 | 1806 | |
94bdecf9 | 1807 | =item dORIGMARK |
954c1994 | 1808 | |
94bdecf9 | 1809 | Saves the original stack mark for the XSUB. See C<ORIGMARK>. |
954c1994 | 1810 | |
94bdecf9 | 1811 | dORIGMARK; |
954c1994 | 1812 | |
497711e7 | 1813 | =for hackers |
94bdecf9 | 1814 | Found in file pp.h |
497711e7 | 1815 | |
94bdecf9 | 1816 | =item dSP |
954c1994 | 1817 | |
94bdecf9 JH |
1818 | Declares a local copy of perl's stack pointer for the XSUB, available via |
1819 | the C<SP> macro. See C<SP>. | |
954c1994 | 1820 | |
94bdecf9 | 1821 | dSP; |
954c1994 | 1822 | |
497711e7 | 1823 | =for hackers |
94bdecf9 | 1824 | Found in file pp.h |
497711e7 | 1825 | |
94bdecf9 | 1826 | =item EXTEND |
954c1994 | 1827 | |
94bdecf9 JH |
1828 | Used to extend the argument stack for an XSUB's return values. Once |
1829 | used, guarantees that there is room for at least C<nitems> to be pushed | |
1830 | onto the stack. | |
954c1994 | 1831 | |
94bdecf9 | 1832 | void EXTEND(SP, int nitems) |
954c1994 | 1833 | |
497711e7 | 1834 | =for hackers |
94bdecf9 | 1835 | Found in file pp.h |
954c1994 | 1836 | |
94bdecf9 | 1837 | =item MARK |
954c1994 | 1838 | |
94bdecf9 | 1839 | Stack marker variable for the XSUB. See C<dMARK>. |
954c1994 | 1840 | |
497711e7 | 1841 | =for hackers |
94bdecf9 | 1842 | Found in file pp.h |
954c1994 | 1843 | |
94bdecf9 | 1844 | =item ORIGMARK |
954c1994 | 1845 | |
94bdecf9 | 1846 | The original stack mark for the XSUB. See C<dORIGMARK>. |
954c1994 | 1847 | |
497711e7 | 1848 | =for hackers |
94bdecf9 | 1849 | Found in file pp.h |
497711e7 | 1850 | |
954c1994 GS |
1851 | =item POPi |
1852 | ||
1853 | Pops an integer off the stack. | |
1854 | ||
1855 | IV POPi | |
1856 | ||
497711e7 GS |
1857 | =for hackers |
1858 | Found in file pp.h | |
1859 | ||
954c1994 GS |
1860 | =item POPl |
1861 | ||
1862 | Pops a long off the stack. | |
1863 | ||
1864 | long POPl | |
1865 | ||
497711e7 GS |
1866 | =for hackers |
1867 | Found in file pp.h | |
1868 | ||
954c1994 GS |
1869 | =item POPn |
1870 | ||
1871 | Pops a double off the stack. | |
1872 | ||
1873 | NV POPn | |
1874 | ||
497711e7 GS |
1875 | =for hackers |
1876 | Found in file pp.h | |
1877 | ||
954c1994 GS |
1878 | =item POPp |
1879 | ||
fa519979 JH |
1880 | Pops a string off the stack. Deprecated. New code should provide |
1881 | a STRLEN n_a and use POPpx. | |
954c1994 GS |
1882 | |
1883 | char* POPp | |
1884 | ||
497711e7 GS |
1885 | =for hackers |
1886 | Found in file pp.h | |
1887 | ||
fa519979 JH |
1888 | =item POPpbytex |
1889 | ||
1890 | Pops a string off the stack which must consist of bytes i.e. characters < 256. | |
1891 | Requires a variable STRLEN n_a in scope. | |
1892 | ||
1893 | char* POPpbytex | |
1894 | ||
1895 | =for hackers | |
1896 | Found in file pp.h | |
1897 | ||
1898 | =item POPpx | |
1899 | ||
1900 | Pops a string off the stack. | |
1901 | Requires a variable STRLEN n_a in scope. | |
1902 | ||
1903 | char* POPpx | |
1904 | ||
1905 | =for hackers | |
1906 | Found in file pp.h | |
1907 | ||
954c1994 GS |
1908 | =item POPs |
1909 | ||
1910 | Pops an SV off the stack. | |
1911 | ||
1912 | SV* POPs | |
1913 | ||
497711e7 GS |
1914 | =for hackers |
1915 | Found in file pp.h | |
1916 | ||
954c1994 GS |
1917 | =item PUSHi |
1918 | ||
1919 | Push an integer onto the stack. The stack must have room for this element. | |
1920 | Handles 'set' magic. See C<XPUSHi>. | |
1921 | ||
1922 | void PUSHi(IV iv) | |
1923 | ||
497711e7 GS |
1924 | =for hackers |
1925 | Found in file pp.h | |
1926 | ||
954c1994 GS |
1927 | =item PUSHMARK |
1928 | ||
1929 | Opening bracket for arguments on a callback. See C<PUTBACK> and | |
1930 | L<perlcall>. | |
1931 | ||
1932 | PUSHMARK; | |
1933 | ||
497711e7 GS |
1934 | =for hackers |
1935 | Found in file pp.h | |
1936 | ||
954c1994 GS |
1937 | =item PUSHn |
1938 | ||
1939 | Push a double onto the stack. The stack must have room for this element. | |
1940 | Handles 'set' magic. See C<XPUSHn>. | |
1941 | ||
1942 | void PUSHn(NV nv) | |
1943 | ||
497711e7 GS |
1944 | =for hackers |
1945 | Found in file pp.h | |
1946 | ||
954c1994 GS |
1947 | =item PUSHp |
1948 | ||
1949 | Push a string onto the stack. The stack must have room for this element. | |
1950 | The C<len> indicates the length of the string. Handles 'set' magic. See | |
1951 | C<XPUSHp>. | |
1952 | ||
1953 | void PUSHp(char* str, STRLEN len) | |
1954 | ||
497711e7 GS |
1955 | =for hackers |
1956 | Found in file pp.h | |
1957 | ||
954c1994 GS |
1958 | =item PUSHs |
1959 | ||
1c846c1f | 1960 | Push an SV onto the stack. The stack must have room for this element. |
954c1994 GS |
1961 | Does not handle 'set' magic. See C<XPUSHs>. |
1962 | ||
1963 | void PUSHs(SV* sv) | |
1964 | ||
497711e7 GS |
1965 | =for hackers |
1966 | Found in file pp.h | |
1967 | ||
954c1994 GS |
1968 | =item PUSHu |
1969 | ||
1970 | Push an unsigned integer onto the stack. The stack must have room for this | |
1971 | element. See C<XPUSHu>. | |
1972 | ||
1973 | void PUSHu(UV uv) | |
1974 | ||
497711e7 GS |
1975 | =for hackers |
1976 | Found in file pp.h | |
1977 | ||
954c1994 GS |
1978 | =item PUTBACK |
1979 | ||
1980 | Closing bracket for XSUB arguments. This is usually handled by C<xsubpp>. | |
1981 | See C<PUSHMARK> and L<perlcall> for other uses. | |
1982 | ||
1983 | PUTBACK; | |
1984 | ||
497711e7 GS |
1985 | =for hackers |
1986 | Found in file pp.h | |
1987 | ||
94bdecf9 | 1988 | =item SP |
d2cc3551 | 1989 | |
94bdecf9 JH |
1990 | Stack pointer. This is usually handled by C<xsubpp>. See C<dSP> and |
1991 | C<SPAGAIN>. | |
d2cc3551 | 1992 | |
94bdecf9 JH |
1993 | =for hackers |
1994 | Found in file pp.h | |
1995 | ||
1996 | =item SPAGAIN | |
1997 | ||
1998 | Refetch the stack pointer. Used after a callback. See L<perlcall>. | |
1999 | ||
2000 | SPAGAIN; | |
d2cc3551 JH |
2001 | |
2002 | =for hackers | |
94bdecf9 | 2003 | Found in file pp.h |
d2cc3551 | 2004 | |
94bdecf9 | 2005 | =item XPUSHi |
954c1994 | 2006 | |
94bdecf9 JH |
2007 | Push an integer onto the stack, extending the stack if necessary. Handles |
2008 | 'set' magic. See C<PUSHi>. | |
954c1994 | 2009 | |
94bdecf9 | 2010 | void XPUSHi(IV iv) |
954c1994 | 2011 | |
497711e7 | 2012 | =for hackers |
94bdecf9 | 2013 | Found in file pp.h |
497711e7 | 2014 | |
94bdecf9 | 2015 | =item XPUSHn |
954c1994 | 2016 | |
94bdecf9 JH |
2017 | Push a double onto the stack, extending the stack if necessary. Handles |
2018 | 'set' magic. See C<PUSHn>. | |
954c1994 | 2019 | |
94bdecf9 | 2020 | void XPUSHn(NV nv) |
954c1994 | 2021 | |
497711e7 | 2022 | =for hackers |
94bdecf9 | 2023 | Found in file pp.h |
497711e7 | 2024 | |
94bdecf9 | 2025 | =item XPUSHp |
954c1994 | 2026 | |
94bdecf9 JH |
2027 | Push a string onto the stack, extending the stack if necessary. The C<len> |
2028 | indicates the length of the string. Handles 'set' magic. See | |
2029 | C<PUSHp>. | |
954c1994 | 2030 | |
94bdecf9 | 2031 | void XPUSHp(char* str, STRLEN len) |
954c1994 | 2032 | |
94bdecf9 JH |
2033 | =for hackers |
2034 | Found in file pp.h | |
2035 | ||
2036 | =item XPUSHs | |
2037 | ||
2038 | Push an SV onto the stack, extending the stack if necessary. Does not | |
2039 | handle 'set' magic. See C<PUSHs>. | |
2040 | ||
2041 | void XPUSHs(SV* sv) | |
954c1994 | 2042 | |
497711e7 | 2043 | =for hackers |
94bdecf9 | 2044 | Found in file pp.h |
497711e7 | 2045 | |
94bdecf9 | 2046 | =item XPUSHu |
954c1994 | 2047 | |
94bdecf9 JH |
2048 | Push an unsigned integer onto the stack, extending the stack if necessary. |
2049 | See C<PUSHu>. | |
954c1994 | 2050 | |
94bdecf9 JH |
2051 | void XPUSHu(UV uv) |
2052 | ||
2053 | =for hackers | |
2054 | Found in file pp.h | |
2055 | ||
2056 | =item XSRETURN | |
2057 | ||
2058 | Return from XSUB, indicating number of items on the stack. This is usually | |
2059 | handled by C<xsubpp>. | |
2060 | ||
2061 | void XSRETURN(int nitems) | |
954c1994 | 2062 | |
497711e7 GS |
2063 | =for hackers |
2064 | Found in file XSUB.h | |
2065 | ||
94bdecf9 | 2066 | =item XSRETURN_IV |
954c1994 | 2067 | |
94bdecf9 | 2068 | Return an integer from an XSUB immediately. Uses C<XST_mIV>. |
954c1994 | 2069 | |
94bdecf9 | 2070 | void XSRETURN_IV(IV iv) |
954c1994 | 2071 | |
497711e7 | 2072 | =for hackers |
94bdecf9 | 2073 | Found in file XSUB.h |
497711e7 | 2074 | |
94bdecf9 | 2075 | =item XSRETURN_NO |
954c1994 | 2076 | |
94bdecf9 | 2077 | Return C<&PL_sv_no> from an XSUB immediately. Uses C<XST_mNO>. |
954c1994 | 2078 | |
94bdecf9 | 2079 | XSRETURN_NO; |
954c1994 | 2080 | |
497711e7 | 2081 | =for hackers |
94bdecf9 | 2082 | Found in file XSUB.h |
497711e7 | 2083 | |
94bdecf9 | 2084 | =item XSRETURN_NV |
954c1994 | 2085 | |
94bdecf9 | 2086 | Return a double from an XSUB immediately. Uses C<XST_mNV>. |
954c1994 | 2087 | |
94bdecf9 | 2088 | void XSRETURN_NV(NV nv) |
954c1994 | 2089 | |
497711e7 | 2090 | =for hackers |
94bdecf9 JH |
2091 | Found in file XSUB.h |
2092 | ||
2093 | =item XSRETURN_PV | |
2094 | ||
2095 | Return a copy of a string from an XSUB immediately. Uses C<XST_mPV>. | |
2096 | ||
2097 | void XSRETURN_PV(char* str) | |
2098 | ||
2099 | =for hackers | |
2100 | Found in file XSUB.h | |
2101 | ||
2102 | =item XSRETURN_UNDEF | |
2103 | ||
2104 | Return C<&PL_sv_undef> from an XSUB immediately. Uses C<XST_mUNDEF>. | |
2105 | ||
2106 | XSRETURN_UNDEF; | |
2107 | ||
2108 | =for hackers | |
2109 | Found in file XSUB.h | |
2110 | ||
2111 | =item XSRETURN_YES | |
2112 | ||
2113 | Return C<&PL_sv_yes> from an XSUB immediately. Uses C<XST_mYES>. | |
2114 | ||
2115 | XSRETURN_YES; | |
2116 | ||
2117 | =for hackers | |
2118 | Found in file XSUB.h | |
2119 | ||
2120 | =item XST_mIV | |
2121 | ||
2122 | Place an integer into the specified position C<pos> on the stack. The | |
2123 | value is stored in a new mortal SV. | |
2124 | ||
2125 | void XST_mIV(int pos, IV iv) | |
2126 | ||
2127 | =for hackers | |
2128 | Found in file XSUB.h | |
2129 | ||
2130 | =item XST_mNO | |
2131 | ||
2132 | Place C<&PL_sv_no> into the specified position C<pos> on the | |
2133 | stack. | |
2134 | ||
2135 | void XST_mNO(int pos) | |
2136 | ||
2137 | =for hackers | |
2138 | Found in file XSUB.h | |
2139 | ||
2140 | =item XST_mNV | |
2141 | ||
2142 | Place a double into the specified position C<pos> on the stack. The value | |
2143 | is stored in a new mortal SV. | |
2144 | ||
2145 | void XST_mNV(int pos, NV nv) | |
2146 | ||
2147 | =for hackers | |
2148 | Found in file XSUB.h | |
2149 | ||
2150 | =item XST_mPV | |
2151 | ||
2152 | Place a copy of a string into the specified position C<pos> on the stack. | |
2153 | The value is stored in a new mortal SV. | |
2154 | ||
2155 | void XST_mPV(int pos, char* str) | |
2156 | ||
2157 | =for hackers | |
2158 | Found in file XSUB.h | |
2159 | ||
2160 | =item XST_mUNDEF | |
2161 | ||
2162 | Place C<&PL_sv_undef> into the specified position C<pos> on the | |
2163 | stack. | |
2164 | ||
2165 | void XST_mUNDEF(int pos) | |
2166 | ||
2167 | =for hackers | |
2168 | Found in file XSUB.h | |
2169 | ||
2170 | =item XST_mYES | |
2171 | ||
2172 | Place C<&PL_sv_yes> into the specified position C<pos> on the | |
2173 | stack. | |
2174 | ||
2175 | void XST_mYES(int pos) | |
2176 | ||
2177 | =for hackers | |
2178 | Found in file XSUB.h | |
2179 | ||
2180 | ||
2181 | =back | |
2182 | ||
2183 | =head1 SV Flags | |
497711e7 | 2184 | |
94bdecf9 | 2185 | =over 8 |
954c1994 | 2186 | |
94bdecf9 | 2187 | =item svtype |
954c1994 | 2188 | |
94bdecf9 JH |
2189 | An enum of flags for Perl types. These are found in the file B<sv.h> |
2190 | in the C<svtype> enum. Test these flags with the C<SvTYPE> macro. | |
954c1994 | 2191 | |
497711e7 | 2192 | =for hackers |
94bdecf9 | 2193 | Found in file sv.h |
6e9d1081 | 2194 | |
94bdecf9 | 2195 | =item SVt_IV |
6e9d1081 | 2196 | |
94bdecf9 | 2197 | Integer type flag for scalars. See C<svtype>. |
6e9d1081 NC |
2198 | |
2199 | =for hackers | |
94bdecf9 | 2200 | Found in file sv.h |
6e9d1081 | 2201 | |
94bdecf9 | 2202 | =item SVt_NV |
6e9d1081 | 2203 | |
94bdecf9 | 2204 | Double type flag for scalars. See C<svtype>. |
6e9d1081 NC |
2205 | |
2206 | =for hackers | |
94bdecf9 | 2207 | Found in file sv.h |
6e9d1081 | 2208 | |
94bdecf9 | 2209 | =item SVt_PV |
6e9d1081 | 2210 | |
94bdecf9 | 2211 | Pointer type flag for scalars. See C<svtype>. |
6e9d1081 NC |
2212 | |
2213 | =for hackers | |
94bdecf9 | 2214 | Found in file sv.h |
cd1ee231 | 2215 | |
94bdecf9 | 2216 | =item SVt_PVAV |
cd1ee231 | 2217 | |
94bdecf9 | 2218 | Type flag for arrays. See C<svtype>. |
cd1ee231 JH |
2219 | |
2220 | =for hackers | |
94bdecf9 | 2221 | Found in file sv.h |
cd1ee231 | 2222 | |
94bdecf9 | 2223 | =item SVt_PVCV |
cd1ee231 | 2224 | |
94bdecf9 | 2225 | Type flag for code refs. See C<svtype>. |
cd1ee231 JH |
2226 | |
2227 | =for hackers | |
94bdecf9 | 2228 | Found in file sv.h |
cd1ee231 | 2229 | |
94bdecf9 | 2230 | =item SVt_PVHV |
cd1ee231 | 2231 | |
94bdecf9 | 2232 | Type flag for hashes. See C<svtype>. |
cd1ee231 JH |
2233 | |
2234 | =for hackers | |
94bdecf9 | 2235 | Found in file sv.h |
cd1ee231 | 2236 | |
94bdecf9 | 2237 | =item SVt_PVMG |
cd1ee231 | 2238 | |
94bdecf9 | 2239 | Type flag for blessed scalars. See C<svtype>. |
cd1ee231 JH |
2240 | |
2241 | =for hackers | |
94bdecf9 | 2242 | Found in file sv.h |
cd1ee231 | 2243 | |
cd1ee231 | 2244 | |
94bdecf9 | 2245 | =back |
cd1ee231 | 2246 | |
94bdecf9 | 2247 | =head1 SV Manipulation Functions |
cd1ee231 | 2248 | |
94bdecf9 | 2249 | =over 8 |
cd1ee231 | 2250 | |
94bdecf9 | 2251 | =item get_sv |
cd1ee231 | 2252 | |
94bdecf9 JH |
2253 | Returns the SV of the specified Perl scalar. If C<create> is set and the |
2254 | Perl variable does not exist then it will be created. If C<create> is not | |
2255 | set and the variable does not exist then NULL is returned. | |
2256 | ||
2257 | NOTE: the perl_ form of this function is deprecated. | |
2258 | ||
2259 | SV* get_sv(const char* name, I32 create) | |
cd1ee231 JH |
2260 | |
2261 | =for hackers | |
94bdecf9 | 2262 | Found in file perl.c |
cd1ee231 | 2263 | |
94bdecf9 | 2264 | =item looks_like_number |
cd1ee231 | 2265 | |
94bdecf9 JH |
2266 | Test if the content of an SV looks like a number (or is a number). |
2267 | C<Inf> and C<Infinity> are treated as numbers (so will not issue a | |
2268 | non-numeric warning), even if your atof() doesn't grok them. | |
cd1ee231 | 2269 | |
94bdecf9 | 2270 | I32 looks_like_number(SV* sv) |
cd1ee231 JH |
2271 | |
2272 | =for hackers | |
94bdecf9 | 2273 | Found in file sv.c |
2a5a0c38 | 2274 | |
94bdecf9 | 2275 | =item newRV_inc |
2a5a0c38 | 2276 | |
94bdecf9 JH |
2277 | Creates an RV wrapper for an SV. The reference count for the original SV is |
2278 | incremented. | |
2a5a0c38 | 2279 | |
94bdecf9 | 2280 | SV* newRV_inc(SV* sv) |
2a5a0c38 JH |
2281 | |
2282 | =for hackers | |
94bdecf9 | 2283 | Found in file sv.h |
2a5a0c38 | 2284 | |
94bdecf9 | 2285 | =item newRV_noinc |
954c1994 | 2286 | |
94bdecf9 JH |
2287 | Creates an RV wrapper for an SV. The reference count for the original |
2288 | SV is B<not> incremented. | |
2289 | ||
2290 | SV* newRV_noinc(SV *sv) | |
954c1994 | 2291 | |
497711e7 | 2292 | =for hackers |
94bdecf9 | 2293 | Found in file sv.c |
497711e7 | 2294 | |
94bdecf9 | 2295 | =item newSV |
954c1994 | 2296 | |
94bdecf9 JH |
2297 | Create a new null SV, or if len > 0, create a new empty SVt_PV type SV |
2298 | with an initial PV allocation of len+1. Normally accessed via the C<NEWSV> | |
2299 | macro. | |
954c1994 | 2300 | |
94bdecf9 | 2301 | SV* newSV(STRLEN len) |
954c1994 | 2302 | |
497711e7 | 2303 | =for hackers |
94bdecf9 | 2304 | Found in file sv.c |
497711e7 | 2305 | |
94bdecf9 | 2306 | =item newSViv |
954c1994 | 2307 | |
94bdecf9 JH |
2308 | Creates a new SV and copies an integer into it. The reference count for the |
2309 | SV is set to 1. | |
954c1994 | 2310 | |
94bdecf9 | 2311 | SV* newSViv(IV i) |
954c1994 | 2312 | |
497711e7 | 2313 | =for hackers |
94bdecf9 | 2314 | Found in file sv.c |
497711e7 | 2315 | |
94bdecf9 | 2316 | =item newSVnv |
954c1994 | 2317 | |
94bdecf9 JH |
2318 | Creates a new SV and copies a floating point value into it. |
2319 | The reference count for the SV is set to 1. | |
954c1994 | 2320 | |
94bdecf9 | 2321 | SV* newSVnv(NV n) |
954c1994 | 2322 | |
497711e7 | 2323 | =for hackers |
94bdecf9 | 2324 | Found in file sv.c |
497711e7 | 2325 | |
94bdecf9 | 2326 | =item newSVpv |
954c1994 | 2327 | |
94bdecf9 JH |
2328 | Creates a new SV and copies a string into it. The reference count for the |
2329 | SV is set to 1. If C<len> is zero, Perl will compute the length using | |
2330 | strlen(). For efficiency, consider using C<newSVpvn> instead. | |
954c1994 | 2331 | |
94bdecf9 | 2332 | SV* newSVpv(const char* s, STRLEN len) |
954c1994 | 2333 | |
497711e7 | 2334 | =for hackers |
94bdecf9 | 2335 | Found in file sv.c |
497711e7 | 2336 | |
94bdecf9 | 2337 | =item newSVpvf |
954c1994 | 2338 | |
94bdecf9 JH |
2339 | Creates a new SV and initializes it with the string formatted like |
2340 | C<sprintf>. | |
954c1994 | 2341 | |
94bdecf9 | 2342 | SV* newSVpvf(const char* pat, ...) |
954c1994 | 2343 | |
497711e7 | 2344 | =for hackers |
94bdecf9 | 2345 | Found in file sv.c |
497711e7 | 2346 | |
94bdecf9 | 2347 | =item newSVpvn |
954c1994 | 2348 | |
94bdecf9 JH |
2349 | Creates a new SV and copies a string into it. The reference count for the |
2350 | SV is set to 1. Note that if C<len> is zero, Perl will create a zero length | |
2351 | string. You are responsible for ensuring that the source string is at least | |
2352 | C<len> bytes long. | |
954c1994 | 2353 | |
94bdecf9 | 2354 | SV* newSVpvn(const char* s, STRLEN len) |
954c1994 | 2355 | |
497711e7 | 2356 | =for hackers |
94bdecf9 | 2357 | Found in file sv.c |
497711e7 | 2358 | |
94bdecf9 | 2359 | =item newSVpvn_share |
954c1994 | 2360 | |
94bdecf9 JH |
2361 | Creates a new SV with its SvPVX pointing to a shared string in the string |
2362 | table. If the string does not already exist in the table, it is created | |
2363 | first. Turns on READONLY and FAKE. The string's hash is stored in the UV | |
2364 | slot of the SV; if the C<hash> parameter is non-zero, that value is used; | |
2365 | otherwise the hash is computed. The idea here is that as the string table | |
2366 | is used for shared hash keys these strings will have SvPVX == HeKEY and | |
2367 | hash lookup will avoid string compare. | |
954c1994 | 2368 | |
94bdecf9 | 2369 | SV* newSVpvn_share(const char* s, I32 len, U32 hash) |
954c1994 | 2370 | |
497711e7 | 2371 | =for hackers |
94bdecf9 | 2372 | Found in file sv.c |
497711e7 | 2373 | |
94bdecf9 | 2374 | =item newSVrv |
954c1994 | 2375 | |
94bdecf9 JH |
2376 | Creates a new SV for the RV, C<rv>, to point to. If C<rv> is not an RV then |
2377 | it will be upgraded to one. If C<classname> is non-null then the new SV will | |
2378 | be blessed in the specified package. The new SV is returned and its | |
2379 | reference count is 1. | |
954c1994 | 2380 | |
94bdecf9 | 2381 | SV* newSVrv(SV* rv, const char* classname) |
954c1994 | 2382 | |
497711e7 | 2383 | =for hackers |
94bdecf9 | 2384 | Found in file sv.c |
497711e7 | 2385 | |
94bdecf9 | 2386 | =item newSVsv |
954c1994 | 2387 | |
94bdecf9 JH |
2388 | Creates a new SV which is an exact duplicate of the original SV. |
2389 | (Uses C<sv_setsv>). | |
954c1994 | 2390 | |
94bdecf9 | 2391 | SV* newSVsv(SV* old) |
954c1994 | 2392 | |
497711e7 | 2393 | =for hackers |
94bdecf9 | 2394 | Found in file sv.c |
497711e7 | 2395 | |
94bdecf9 | 2396 | =item newSVuv |
954c1994 | 2397 | |
94bdecf9 JH |
2398 | Creates a new SV and copies an unsigned integer into it. |
2399 | The reference count for the SV is set to 1. | |
954c1994 | 2400 | |
94bdecf9 | 2401 | SV* newSVuv(UV u) |
954c1994 | 2402 | |
497711e7 | 2403 | =for hackers |
94bdecf9 | 2404 | Found in file sv.c |
497711e7 | 2405 | |
94bdecf9 | 2406 | =item new_vstring |
954c1994 | 2407 | |
94bdecf9 JH |
2408 | Returns a pointer to the next character after the parsed |
2409 | vstring, as well as updating the passed in sv. | |
954c1994 | 2410 | |
94bdecf9 JH |
2411 | Function must be called like |
2412 | ||
2413 | sv = NEWSV(92,5); | |
2414 | s = new_vstring(s,sv); | |
2415 | ||
2416 | The sv must already be large enough to store the vstring | |
2417 | passed in. | |
2418 | ||
2419 | char* new_vstring(char *vstr, SV *sv) | |
954c1994 | 2420 | |
497711e7 | 2421 | =for hackers |
94bdecf9 | 2422 | Found in file util.c |
497711e7 | 2423 | |
954c1994 GS |
2424 | =item SvCUR |
2425 | ||
2426 | Returns the length of the string which is in the SV. See C<SvLEN>. | |
2427 | ||
2428 | STRLEN SvCUR(SV* sv) | |
2429 | ||
497711e7 GS |
2430 | =for hackers |
2431 | Found in file sv.h | |
2432 | ||
954c1994 GS |
2433 | =item SvCUR_set |
2434 | ||
2435 | Set the length of the string which is in the SV. See C<SvCUR>. | |
2436 | ||
2437 | void SvCUR_set(SV* sv, STRLEN len) | |
2438 | ||
497711e7 GS |
2439 | =for hackers |
2440 | Found in file sv.h | |
2441 | ||
94bdecf9 | 2442 | =item SvEND |
954c1994 | 2443 | |
94bdecf9 JH |
2444 | Returns a pointer to the last character in the string which is in the SV. |
2445 | See C<SvCUR>. Access the character as *(SvEND(sv)). | |
954c1994 | 2446 | |
94bdecf9 | 2447 | char* SvEND(SV* sv) |
954c1994 | 2448 | |
497711e7 GS |
2449 | =for hackers |
2450 | Found in file sv.h | |
2451 | ||
954c1994 GS |
2452 | =item SvGROW |
2453 | ||
2454 | Expands the character buffer in the SV so that it has room for the | |
2455 | indicated number of bytes (remember to reserve space for an extra trailing | |
8cf8f3d1 | 2456 | NUL character). Calls C<sv_grow> to perform the expansion if necessary. |
954c1994 GS |
2457 | Returns a pointer to the character buffer. |
2458 | ||
679ac26e | 2459 | char * SvGROW(SV* sv, STRLEN len) |
954c1994 | 2460 | |
497711e7 GS |
2461 | =for hackers |
2462 | Found in file sv.h | |
2463 | ||
954c1994 GS |
2464 | =item SvIOK |
2465 | ||
2466 | Returns a boolean indicating whether the SV contains an integer. | |
2467 | ||
2468 | bool SvIOK(SV* sv) | |
2469 | ||
497711e7 GS |
2470 | =for hackers |
2471 | Found in file sv.h | |
2472 | ||
954c1994 GS |
2473 | =item SvIOKp |
2474 | ||
2475 | Returns a boolean indicating whether the SV contains an integer. Checks | |
2476 | the B<private> setting. Use C<SvIOK>. | |
2477 | ||
2478 | bool SvIOKp(SV* sv) | |
2479 | ||
497711e7 GS |
2480 | =for hackers |
2481 | Found in file sv.h | |
2482 | ||
e331fc52 JH |
2483 | =item SvIOK_notUV |
2484 | ||
f4758303 | 2485 | Returns a boolean indicating whether the SV contains a signed integer. |
e331fc52 JH |
2486 | |
2487 | void SvIOK_notUV(SV* sv) | |
2488 | ||
2489 | =for hackers | |
2490 | Found in file sv.h | |
2491 | ||
954c1994 GS |
2492 | =item SvIOK_off |
2493 | ||
2494 | Unsets the IV status of an SV. | |
2495 | ||
2496 | void SvIOK_off(SV* sv) | |
2497 | ||
497711e7 GS |
2498 | =for hackers |
2499 | Found in file sv.h | |
2500 | ||
954c1994 GS |
2501 | =item SvIOK_on |
2502 | ||
2503 | Tells an SV that it is an integer. | |
2504 | ||
2505 | void SvIOK_on(SV* sv) | |
2506 | ||
497711e7 GS |
2507 | =for hackers |
2508 | Found in file sv.h | |
2509 | ||
954c1994 GS |
2510 | =item SvIOK_only |
2511 | ||
2512 | Tells an SV that it is an integer and disables all other OK bits. | |
2513 | ||
2514 | void SvIOK_only(SV* sv) | |
2515 | ||
497711e7 GS |
2516 | =for hackers |
2517 | Found in file sv.h | |
2518 | ||
e331fc52 JH |
2519 | =item SvIOK_only_UV |
2520 | ||
2521 | Tells and SV that it is an unsigned integer and disables all other OK bits. | |
2522 | ||
2523 | void SvIOK_only_UV(SV* sv) | |
2524 | ||
2525 | =for hackers | |
2526 | Found in file sv.h | |
2527 | ||
2528 | =item SvIOK_UV | |
2529 | ||
2530 | Returns a boolean indicating whether the SV contains an unsigned integer. | |
2531 | ||
2532 | void SvIOK_UV(SV* sv) | |
2533 | ||
2534 | =for hackers | |
2535 | Found in file sv.h | |
2536 | ||
954c1994 GS |
2537 | =item SvIV |
2538 | ||
645c22ef DM |
2539 | Coerces the given SV to an integer and returns it. See C<SvIVx> for a |
2540 | version which guarantees to evaluate sv only once. | |
954c1994 GS |
2541 | |
2542 | IV SvIV(SV* sv) | |
2543 | ||
497711e7 GS |
2544 | =for hackers |
2545 | Found in file sv.h | |
2546 | ||
12b7c5c7 | 2547 | =item SvIVX |
954c1994 | 2548 | |
12b7c5c7 JH |
2549 | Returns the raw value in the SV's IV slot, without checks or conversions. |
2550 | Only use when you are sure SvIOK is true. See also C<SvIV()>. | |
954c1994 | 2551 | |
12b7c5c7 | 2552 | IV SvIVX(SV* sv) |
954c1994 | 2553 | |
497711e7 GS |
2554 | =for hackers |
2555 | Found in file sv.h | |
2556 | ||
12b7c5c7 | 2557 | =item SvIVx |
645c22ef | 2558 | |
12b7c5c7 JH |
2559 | Coerces the given SV to an integer and returns it. Guarantees to evaluate |
2560 | sv only once. Use the more efficient C<SvIV> otherwise. | |
645c22ef | 2561 | |
12b7c5c7 | 2562 | IV SvIVx(SV* sv) |
645c22ef DM |
2563 | |
2564 | =for hackers | |
2565 | Found in file sv.h | |
2566 | ||
954c1994 GS |
2567 | =item SvLEN |
2568 | ||
91e74348 JH |
2569 | Returns the size of the string buffer in the SV, not including any part |
2570 | attributable to C<SvOOK>. See C<SvCUR>. | |
954c1994 GS |
2571 | |
2572 | STRLEN SvLEN(SV* sv) | |
2573 | ||
497711e7 GS |
2574 | =for hackers |
2575 | Found in file sv.h | |
2576 | ||
954c1994 GS |
2577 | =item SvNIOK |
2578 | ||
2579 | Returns a boolean indicating whether the SV contains a number, integer or | |
2580 | double. | |
2581 | ||
2582 | bool SvNIOK(SV* sv) | |
2583 | ||
497711e7 GS |
2584 | =for hackers |
2585 | Found in file sv.h | |
2586 | ||
954c1994 GS |
2587 | =item SvNIOKp |
2588 | ||
2589 | Returns a boolean indicating whether the SV contains a number, integer or | |
2590 | double. Checks the B<private> setting. Use C<SvNIOK>. | |
2591 | ||
2592 | bool SvNIOKp(SV* sv) | |
2593 | ||
497711e7 GS |
2594 | =for hackers |
2595 | Found in file sv.h | |
2596 | ||
954c1994 GS |
2597 | =item SvNIOK_off |
2598 | ||
2599 | Unsets the NV/IV status of an SV. | |
2600 | ||
2601 | void SvNIOK_off(SV* sv) | |
2602 | ||
497711e7 GS |
2603 | =for hackers |
2604 | Found in file sv.h | |
2605 | ||
954c1994 GS |
2606 | =item SvNOK |
2607 | ||
2608 | Returns a boolean indicating whether the SV contains a double. | |
2609 | ||
2610 | bool SvNOK(SV* sv) | |
2611 | ||
497711e7 GS |
2612 | =for hackers |
2613 | Found in file sv.h | |
2614 | ||
954c1994 GS |
2615 | =item SvNOKp |
2616 | ||
2617 | Returns a boolean indicating whether the SV contains a double. Checks the | |
2618 | B<private> setting. Use C<SvNOK>. | |
2619 | ||
2620 | bool SvNOKp(SV* sv) | |
2621 | ||
497711e7 GS |
2622 | =for hackers |
2623 | Found in file sv.h | |
2624 | ||
954c1994 GS |
2625 | =item SvNOK_off |
2626 | ||
2627 | Unsets the NV status of an SV. | |
2628 | ||
2629 | void SvNOK_off(SV* sv) | |
2630 | ||
497711e7 GS |
2631 | =for hackers |
2632 | Found in file sv.h | |
2633 | ||
954c1994 GS |
2634 | =item SvNOK_on |
2635 | ||
2636 | Tells an SV that it is a double. | |
2637 | ||
2638 | void SvNOK_on(SV* sv) | |
2639 | ||
497711e7 GS |
2640 | =for hackers |
2641 | Found in file sv.h | |
2642 | ||
954c1994 GS |
2643 | =item SvNOK_only |
2644 | ||
2645 | Tells an SV that it is a double and disables all other OK bits. | |
2646 | ||
2647 | void SvNOK_only(SV* sv) | |
2648 | ||
497711e7 GS |
2649 | =for hackers |
2650 | Found in file sv.h | |
2651 | ||
954c1994 GS |
2652 | =item SvNV |
2653 | ||
645c22ef DM |
2654 | Coerce the given SV to a double and return it. See C<SvNVx> for a version |
2655 | which guarantees to evaluate sv only once. | |
954c1994 GS |
2656 | |
2657 | NV SvNV(SV* sv) | |
2658 | ||
497711e7 GS |
2659 | =for hackers |
2660 | Found in file sv.h | |
2661 | ||
12b7c5c7 | 2662 | =item SvNVx |
645c22ef | 2663 | |
12b7c5c7 JH |
2664 | Coerces the given SV to a double and returns it. Guarantees to evaluate |
2665 | sv only once. Use the more efficient C<SvNV> otherwise. | |
645c22ef | 2666 | |
12b7c5c7 | 2667 | NV SvNVx(SV* sv) |
645c22ef DM |
2668 | |
2669 | =for hackers | |
2670 | Found in file sv.h | |
2671 | ||
12b7c5c7 | 2672 | =item SvNVX |
954c1994 | 2673 | |
12b7c5c7 JH |
2674 | Returns the raw value in the SV's NV slot, without checks or conversions. |
2675 | Only use when you are sure SvNOK is true. See also C<SvNV()>. | |
954c1994 | 2676 | |
12b7c5c7 | 2677 | NV SvNVX(SV* sv) |
954c1994 | 2678 | |
497711e7 GS |
2679 | =for hackers |
2680 | Found in file sv.h | |
2681 | ||
954c1994 GS |
2682 | =item SvOK |
2683 | ||
2684 | Returns a boolean indicating whether the value is an SV. | |
2685 | ||
2686 | bool SvOK(SV* sv) | |
2687 | ||
497711e7 GS |
2688 | =for hackers |
2689 | Found in file sv.h | |
2690 | ||
954c1994 GS |
2691 | =item SvOOK |
2692 | ||
2693 | Returns a boolean indicating whether the SvIVX is a valid offset value for | |
2694 | the SvPVX. This hack is used internally to speed up removal of characters | |
2695 | from the beginning of a SvPV. When SvOOK is true, then the start of the | |
2696 | allocated string buffer is really (SvPVX - SvIVX). | |
2697 | ||
2698 | bool SvOOK(SV* sv) | |
2699 | ||
497711e7 GS |
2700 | =for hackers |
2701 | Found in file sv.h | |
2702 | ||
954c1994 GS |
2703 | =item SvPOK |
2704 | ||
2705 | Returns a boolean indicating whether the SV contains a character | |
2706 | string. | |
2707 | ||
2708 | bool SvPOK(SV* sv) | |
2709 | ||
497711e7 GS |
2710 | =for hackers |
2711 | Found in file sv.h | |
2712 | ||
954c1994 GS |
2713 | =item SvPOKp |
2714 | ||
2715 | Returns a boolean indicating whether the SV contains a character string. | |
2716 | Checks the B<private> setting. Use C<SvPOK>. | |
2717 | ||
2718 | bool SvPOKp(SV* sv) | |
2719 | ||
497711e7 GS |
2720 | =for hackers |
2721 | Found in file sv.h | |
2722 | ||
954c1994 GS |
2723 | =item SvPOK_off |
2724 | ||
2725 | Unsets the PV status of an SV. | |
2726 | ||
2727 | void SvPOK_off(SV* sv) | |
2728 | ||
497711e7 GS |
2729 | =for hackers |
2730 | Found in file sv.h | |
2731 | ||
954c1994 GS |
2732 | =item SvPOK_on |
2733 | ||
2734 | Tells an SV that it is a string. | |
2735 | ||
2736 | void SvPOK_on(SV* sv) | |
2737 | ||
497711e7 GS |
2738 | =for hackers |
2739 | Found in file sv.h | |
2740 | ||
954c1994 GS |
2741 | =item SvPOK_only |
2742 | ||
2743 | Tells an SV that it is a string and disables all other OK bits. | |
d5ce4a7c | 2744 | Will also turn off the UTF8 status. |
954c1994 GS |
2745 | |
2746 | void SvPOK_only(SV* sv) | |
2747 | ||
497711e7 GS |
2748 | =for hackers |
2749 | Found in file sv.h | |
2750 | ||
914184e1 JH |
2751 | =item SvPOK_only_UTF8 |
2752 | ||
d5ce4a7c GA |
2753 | Tells an SV that it is a string and disables all other OK bits, |
2754 | and leaves the UTF8 status as it was. | |
f1a1024e | 2755 | |
914184e1 JH |
2756 | void SvPOK_only_UTF8(SV* sv) |
2757 | ||
2758 | =for hackers | |
2759 | Found in file sv.h | |
2760 | ||
954c1994 GS |
2761 | =item SvPV |
2762 | ||
12b7c5c7 JH |
2763 | Returns a pointer to the string in the SV, or a stringified form of |
2764 | the SV if the SV does not contain a string. The SV may cache the | |
2765 | stringified version becoming C<SvPOK>. Handles 'get' magic. See also | |
645c22ef | 2766 | C<SvPVx> for a version which guarantees to evaluate sv only once. |
954c1994 GS |
2767 | |
2768 | char* SvPV(SV* sv, STRLEN len) | |
2769 | ||
497711e7 GS |
2770 | =for hackers |
2771 | Found in file sv.h | |
2772 | ||
645c22ef DM |
2773 | =item SvPVbyte |
2774 | ||
2775 | Like C<SvPV>, but converts sv to byte representation first if necessary. | |
2776 | ||
2777 | char* SvPVbyte(SV* sv, STRLEN len) | |
2778 | ||
2779 | =for hackers | |
2780 | Found in file sv.h | |
2781 | ||
2782 | =item SvPVbytex | |
2783 | ||
2784 | Like C<SvPV>, but converts sv to byte representation first if necessary. | |
d1be9408 | 2785 | Guarantees to evaluate sv only once; use the more efficient C<SvPVbyte> |
645c22ef DM |
2786 | otherwise. |
2787 | ||
2788 | ||
2789 | char* SvPVbytex(SV* sv, STRLEN len) | |
2790 | ||
2791 | =for hackers | |
2792 | Found in file sv.h | |
2793 | ||
2794 | =item SvPVbytex_force | |
2795 | ||
2796 | Like C<SvPV_force>, but converts sv to byte representation first if necessary. | |
d1be9408 | 2797 | Guarantees to evaluate sv only once; use the more efficient C<SvPVbyte_force> |
645c22ef DM |
2798 | otherwise. |
2799 | ||
2800 | char* SvPVbytex_force(SV* sv, STRLEN len) | |
2801 | ||
2802 | =for hackers | |
2803 | Found in file sv.h | |
2804 | ||
2805 | =item SvPVbyte_force | |
2806 | ||
2807 | Like C<SvPV_force>, but converts sv to byte representation first if necessary. | |
2808 | ||
2809 | char* SvPVbyte_force(SV* sv, STRLEN len) | |
2810 | ||
2811 | =for hackers | |
2812 | Found in file sv.h | |
2813 | ||
2814 | =item SvPVbyte_nolen | |
2815 | ||
2816 | Like C<SvPV_nolen>, but converts sv to byte representation first if necessary. | |
2817 | ||
1fdc5aa6 | 2818 | char* SvPVbyte_nolen(SV* sv) |
645c22ef DM |
2819 | |
2820 | =for hackers | |
2821 | Found in file sv.h | |
2822 | ||
2823 | =item SvPVutf8 | |
2824 | ||
1fdc5aa6 | 2825 | Like C<SvPV>, but converts sv to utf8 first if necessary. |
645c22ef DM |
2826 | |
2827 | char* SvPVutf8(SV* sv, STRLEN len) | |
2828 | ||
2829 | =for hackers | |
2830 | Found in file sv.h | |
2831 | ||
2832 | =item SvPVutf8x | |
2833 | ||
1fdc5aa6 | 2834 | Like C<SvPV>, but converts sv to utf8 first if necessary. |
d1be9408 | 2835 | Guarantees to evaluate sv only once; use the more efficient C<SvPVutf8> |
645c22ef DM |
2836 | otherwise. |
2837 | ||
2838 | char* SvPVutf8x(SV* sv, STRLEN len) | |
2839 | ||
2840 | =for hackers | |
2841 | Found in file sv.h | |
2842 | ||
2843 | =item SvPVutf8x_force | |
2844 | ||
1fdc5aa6 | 2845 | Like C<SvPV_force>, but converts sv to utf8 first if necessary. |
d1be9408 | 2846 | Guarantees to evaluate sv only once; use the more efficient C<SvPVutf8_force> |
645c22ef DM |
2847 | otherwise. |
2848 | ||
2849 | char* SvPVutf8x_force(SV* sv, STRLEN len) | |
2850 | ||
2851 | =for hackers | |
2852 | Found in file sv.h | |
2853 | ||
2854 | =item SvPVutf8_force | |
2855 | ||
1fdc5aa6 | 2856 | Like C<SvPV_force>, but converts sv to utf8 first if necessary. |
645c22ef DM |
2857 | |
2858 | char* SvPVutf8_force(SV* sv, STRLEN len) | |
2859 | ||
2860 | =for hackers | |
2861 | Found in file sv.h | |
2862 | ||
2863 | =item SvPVutf8_nolen | |
2864 | ||
1fdc5aa6 | 2865 | Like C<SvPV_nolen>, but converts sv to utf8 first if necessary. |
645c22ef | 2866 | |
1fdc5aa6 | 2867 | char* SvPVutf8_nolen(SV* sv) |
645c22ef DM |
2868 | |
2869 | =for hackers | |
2870 | Found in file sv.h | |
2871 | ||
12b7c5c7 | 2872 | =item SvPVX |
645c22ef | 2873 | |
12b7c5c7 JH |
2874 | Returns a pointer to the physical string in the SV. The SV must contain a |
2875 | string. | |
645c22ef | 2876 | |
12b7c5c7 | 2877 | char* SvPVX(SV* sv) |
645c22ef DM |
2878 | |
2879 | =for hackers | |
2880 | Found in file sv.h | |
2881 | ||
12b7c5c7 | 2882 | =item SvPVx |
954c1994 | 2883 | |
12b7c5c7 | 2884 | A version of C<SvPV> which guarantees to evaluate sv only once. |
954c1994 | 2885 | |
12b7c5c7 | 2886 | char* SvPVx(SV* sv, STRLEN len) |
954c1994 | 2887 | |
497711e7 GS |
2888 | =for hackers |
2889 | Found in file sv.h | |
2890 | ||
954c1994 GS |
2891 | =item SvPV_force |
2892 | ||
12b7c5c7 JH |
2893 | Like C<SvPV> but will force the SV into containing just a string |
2894 | (C<SvPOK_only>). You want force if you are going to update the C<SvPVX> | |
2895 | directly. | |
954c1994 GS |
2896 | |
2897 | char* SvPV_force(SV* sv, STRLEN len) | |
2898 | ||
497711e7 GS |
2899 | =for hackers |
2900 | Found in file sv.h | |
2901 | ||
645c22ef DM |
2902 | =item SvPV_force_nomg |
2903 | ||
12b7c5c7 JH |
2904 | Like C<SvPV> but will force the SV into containing just a string |
2905 | (C<SvPOK_only>). You want force if you are going to update the C<SvPVX> | |
2906 | directly. Doesn't process magic. | |
645c22ef DM |
2907 | |
2908 | char* SvPV_force_nomg(SV* sv, STRLEN len) | |
2909 | ||
2910 | =for hackers | |
2911 | Found in file sv.h | |
2912 | ||
954c1994 GS |
2913 | =item SvPV_nolen |
2914 | ||
12b7c5c7 JH |
2915 | Returns a pointer to the string in the SV, or a stringified form of |
2916 | the SV if the SV does not contain a string. The SV may cache the | |
2917 | stringified form becoming C<SvPOK>. Handles 'get' magic. | |
954c1994 GS |
2918 | |
2919 | char* SvPV_nolen(SV* sv) | |
2920 | ||
497711e7 GS |
2921 | =for hackers |
2922 | Found in file sv.h | |
2923 | ||
954c1994 GS |
2924 | =item SvREFCNT |
2925 | ||
2926 | Returns the value of the object's reference count. | |
2927 | ||
2928 | U32 SvREFCNT(SV* sv) | |
2929 | ||
497711e7 GS |
2930 | =for hackers |
2931 | Found in file sv.h | |
2932 | ||
954c1994 GS |
2933 | =item SvREFCNT_dec |
2934 | ||
2935 | Decrements the reference count of the given SV. | |
2936 | ||
2937 | void SvREFCNT_dec(SV* sv) | |
2938 | ||
497711e7 GS |
2939 | =for hackers |
2940 | Found in file sv.h | |
2941 | ||
954c1994 GS |
2942 | =item SvREFCNT_inc |
2943 | ||
2944 | Increments the reference count of the given SV. | |
2945 | ||
2946 | SV* SvREFCNT_inc(SV* sv) | |
2947 | ||
497711e7 GS |
2948 | =for hackers |
2949 | Found in file sv.h | |
2950 | ||
954c1994 GS |
2951 | =item SvROK |
2952 | ||
2953 | Tests if the SV is an RV. | |
2954 | ||
2955 | bool SvROK(SV* sv) | |
2956 | ||
497711e7 GS |
2957 | =for hackers |
2958 | Found in file sv.h | |
2959 | ||
954c1994 GS |
2960 | =item SvROK_off |
2961 | ||
2962 | Unsets the RV status of an SV. | |
2963 | ||
2964 | void SvROK_off(SV* sv) | |
2965 | ||
497711e7 GS |
2966 | =for hackers |
2967 | Found in file sv.h | |
2968 | ||
954c1994 GS |
2969 | =item SvROK_on |
2970 | ||
2971 | Tells an SV that it is an RV. | |
2972 | ||
2973 | void SvROK_on(SV* sv) | |
2974 | ||
497711e7 GS |
2975 | =for hackers |
2976 | Found in file sv.h | |
2977 | ||
954c1994 GS |
2978 | =item SvRV |
2979 | ||
2980 | Dereferences an RV to return the SV. | |
2981 | ||
2982 | SV* SvRV(SV* sv) | |
2983 | ||
497711e7 GS |
2984 | =for hackers |
2985 | Found in file sv.h | |
2986 | ||
954c1994 GS |
2987 | =item SvSTASH |
2988 | ||
2989 | Returns the stash of the SV. | |
2990 | ||
2991 | HV* SvSTASH(SV* sv) | |
2992 | ||
497711e7 GS |
2993 | =for hackers |
2994 | Found in file sv.h | |
2995 | ||
954c1994 GS |
2996 | =item SvTAINT |
2997 | ||
2998 | Taints an SV if tainting is enabled | |
2999 | ||
3000 | void SvTAINT(SV* sv) | |
3001 | ||
497711e7 GS |
3002 | =for hackers |
3003 | Found in file sv.h | |
3004 | ||
954c1994 GS |
3005 | =item SvTAINTED |
3006 | ||
3007 | Checks to see if an SV is tainted. Returns TRUE if it is, FALSE if | |
3008 | not. | |
3009 | ||
3010 | bool SvTAINTED(SV* sv) | |
3011 | ||
497711e7 GS |
3012 | =for hackers |
3013 | Found in file sv.h | |
3014 | ||
954c1994 GS |
3015 | =item SvTAINTED_off |
3016 | ||
3017 | Untaints an SV. Be I<very> careful with this routine, as it short-circuits | |
3018 | some of Perl's fundamental security features. XS module authors should not | |
3019 | use this function unless they fully understand all the implications of | |
3020 | unconditionally untainting the value. Untainting should be done in the | |
3021 | standard perl fashion, via a carefully crafted regexp, rather than directly | |
3022 | untainting variables. | |
3023 | ||
3024 | void SvTAINTED_off(SV* sv) | |
3025 | ||
497711e7 GS |
3026 | =for hackers |
3027 | Found in file sv.h | |
3028 | ||
954c1994 GS |
3029 | =item SvTAINTED_on |
3030 | ||
3031 | Marks an SV as tainted. | |
3032 | ||
3033 | void SvTAINTED_on(SV* sv) | |
3034 | ||
497711e7 GS |
3035 | =for hackers |
3036 | Found in file sv.h | |
3037 | ||
954c1994 GS |
3038 | =item SvTRUE |
3039 | ||
3040 | Returns a boolean indicating whether Perl would evaluate the SV as true or | |
3041 | false, defined or undefined. Does not handle 'get' magic. | |
3042 | ||
3043 | bool SvTRUE(SV* sv) | |
3044 | ||
497711e7 GS |
3045 | =for hackers |
3046 | Found in file sv.h | |
3047 | ||
9f4817db | 3048 | =item SvTYPE |
af3c7592 | 3049 | |
9f4817db JH |
3050 | Returns the type of the SV. See C<svtype>. |
3051 | ||
3052 | svtype SvTYPE(SV* sv) | |
954c1994 | 3053 | |
497711e7 GS |
3054 | =for hackers |
3055 | Found in file sv.h | |
3056 | ||
a4f1a029 NIS |
3057 | =item SvUNLOCK |
3058 | ||
3059 | Releases a mutual exclusion lock on sv if a suitable module | |
3060 | has been loaded. | |
3061 | ||
3062 | ||
3063 | void SvUNLOCK(SV* sv) | |
3064 | ||
3065 | =for hackers | |
3066 | Found in file sv.h | |
3067 | ||
a8586c98 JH |
3068 | =item SvUOK |
3069 | ||
3070 | Returns a boolean indicating whether the SV contains an unsigned integer. | |
3071 | ||
3072 | void SvUOK(SV* sv) | |
3073 | ||
3074 | =for hackers | |
3075 | Found in file sv.h | |
3076 | ||
954c1994 GS |
3077 | =item SvUPGRADE |
3078 | ||
3079 | Used to upgrade an SV to a more complex form. Uses C<sv_upgrade> to | |
3080 | perform the upgrade if necessary. See C<svtype>. | |
3081 | ||
3082 | void SvUPGRADE(SV* sv, svtype type) | |
3083 | ||
497711e7 GS |
3084 | =for hackers |
3085 | Found in file sv.h | |
3086 | ||
914184e1 JH |
3087 | =item SvUTF8 |
3088 | ||
3089 | Returns a boolean indicating whether the SV contains UTF-8 encoded data. | |
3090 | ||
3091 | void SvUTF8(SV* sv) | |
3092 | ||
3093 | =for hackers | |
3094 | Found in file sv.h | |
3095 | ||
3096 | =item SvUTF8_off | |
3097 | ||
3098 | Unsets the UTF8 status of an SV. | |
3099 | ||
3100 | void SvUTF8_off(SV *sv) | |
3101 | ||
3102 | =for hackers | |
3103 | Found in file sv.h | |
3104 | ||
3105 | =item SvUTF8_on | |
3106 | ||
d5ce4a7c GA |
3107 | Turn on the UTF8 status of an SV (the data is not changed, just the flag). |
3108 | Do not use frivolously. | |
914184e1 JH |
3109 | |
3110 | void SvUTF8_on(SV *sv) | |
3111 | ||
3112 | =for hackers | |
3113 | Found in file sv.h | |
3114 | ||
954c1994 GS |
3115 | =item SvUV |
3116 | ||
645c22ef DM |
3117 | Coerces the given SV to an unsigned integer and returns it. See C<SvUVx> |
3118 | for a version which guarantees to evaluate sv only once. | |
954c1994 GS |
3119 | |
3120 | UV SvUV(SV* sv) | |
3121 | ||
497711e7 GS |
3122 | =for hackers |
3123 | Found in file sv.h | |
3124 | ||
a4f1a029 | 3125 | =item SvUVX |
954c1994 | 3126 | |
a4f1a029 NIS |
3127 | Returns the raw value in the SV's UV slot, without checks or conversions. |
3128 | Only use when you are sure SvIOK is true. See also C<SvUV()>. | |
954c1994 | 3129 | |
a4f1a029 | 3130 | UV SvUVX(SV* sv) |
954c1994 | 3131 | |
497711e7 GS |
3132 | =for hackers |
3133 | Found in file sv.h | |
3134 | ||
a4f1a029 | 3135 | =item SvUVx |
645c22ef | 3136 | |
a4f1a029 NIS |
3137 | Coerces the given SV to an unsigned integer and returns it. Guarantees to |
3138 | evaluate sv only once. Use the more efficient C<SvUV> otherwise. | |
645c22ef | 3139 | |
a4f1a029 | 3140 | UV SvUVx(SV* sv) |
645c22ef DM |
3141 | |
3142 | =for hackers | |
3143 | Found in file sv.h | |
3144 | ||
3145 | =item sv_2bool | |
3146 | ||
3147 | This function is only called on magical items, and is only used by | |
8cf8f3d1 | 3148 | sv_true() or its macro equivalent. |
645c22ef DM |
3149 | |
3150 | bool sv_2bool(SV* sv) | |
3151 | ||
3152 | =for hackers | |
3153 | Found in file sv.c | |
3154 | ||
3155 | =item sv_2cv | |
3156 | ||
3157 | Using various gambits, try to get a CV from an SV; in addition, try if | |
3158 | possible to set C<*st> and C<*gvp> to the stash and GV associated with it. | |
3159 | ||
3160 | CV* sv_2cv(SV* sv, HV** st, GV** gvp, I32 lref) | |
3161 | ||
3162 | =for hackers | |
3163 | Found in file sv.c | |
3164 | ||
3165 | =item sv_2io | |
3166 | ||
3167 | Using various gambits, try to get an IO from an SV: the IO slot if its a | |
3168 | GV; or the recursive result if we're an RV; or the IO slot of the symbol | |
3169 | named after the PV if we're a string. | |
3170 | ||
3171 | IO* sv_2io(SV* sv) | |
3172 | ||
3173 | =for hackers | |
3174 | Found in file sv.c | |
3175 | ||
3176 | =item sv_2iv | |
3177 | ||
3178 | Return the integer value of an SV, doing any necessary string conversion, | |
3179 | magic etc. Normally used via the C<SvIV(sv)> and C<SvIVx(sv)> macros. | |
3180 | ||
3181 | IV sv_2iv(SV* sv) | |
3182 | ||
3183 | =for hackers | |
3184 | Found in file sv.c | |
3185 | ||
954c1994 GS |
3186 | =item sv_2mortal |
3187 | ||
793edb8a JH |
3188 | Marks an existing SV as mortal. The SV will be destroyed "soon", either |
3189 | by an explicit call to FREETMPS, or by an implicit call at places such as | |
3190 | statement boundaries. See also C<sv_newmortal> and C<sv_mortalcopy>. | |
954c1994 GS |
3191 | |
3192 | SV* sv_2mortal(SV* sv) | |
3193 | ||
497711e7 GS |
3194 | =for hackers |
3195 | Found in file sv.c | |
3196 | ||
645c22ef DM |
3197 | =item sv_2nv |
3198 | ||
3199 | Return the num value of an SV, doing any necessary string or integer | |
3200 | conversion, magic etc. Normally used via the C<SvNV(sv)> and C<SvNVx(sv)> | |
3201 | macros. | |
3202 | ||
3203 | NV sv_2nv(SV* sv) | |
3204 | ||
3205 | =for hackers | |
3206 | Found in file sv.c | |
3207 | ||
451be7b1 DM |
3208 | =item sv_2pvbyte |
3209 | ||
3210 | Return a pointer to the byte-encoded representation of the SV, and set *lp | |
3211 | to its length. May cause the SV to be downgraded from UTF8 as a | |
3212 | side-effect. | |
3213 | ||
3214 | Usually accessed via the C<SvPVbyte> macro. | |
3215 | ||
3216 | char* sv_2pvbyte(SV* sv, STRLEN* lp) | |
3217 | ||
3218 | =for hackers | |
3219 | Found in file sv.c | |
3220 | ||
645c22ef DM |
3221 | =item sv_2pvbyte_nolen |
3222 | ||
3223 | Return a pointer to the byte-encoded representation of the SV. | |
3224 | May cause the SV to be downgraded from UTF8 as a side-effect. | |
3225 | ||
3226 | Usually accessed via the C<SvPVbyte_nolen> macro. | |
3227 | ||
3228 | char* sv_2pvbyte_nolen(SV* sv) | |
3229 | ||
3230 | =for hackers | |
3231 | Found in file sv.c | |
3232 | ||
451be7b1 DM |
3233 | =item sv_2pvutf8 |
3234 | ||
3235 | Return a pointer to the UTF8-encoded representation of the SV, and set *lp | |
3236 | to its length. May cause the SV to be upgraded to UTF8 as a side-effect. | |
3237 | ||
3238 | Usually accessed via the C<SvPVutf8> macro. | |
3239 | ||
3240 | char* sv_2pvutf8(SV* sv, STRLEN* lp) | |
3241 | ||
3242 | =for hackers | |
3243 | Found in file sv.c | |
3244 | ||
645c22ef DM |
3245 | =item sv_2pvutf8_nolen |
3246 | ||
3247 | Return a pointer to the UTF8-encoded representation of the SV. | |
3248 | May cause the SV to be upgraded to UTF8 as a side-effect. | |
3249 | ||
3250 | Usually accessed via the C<SvPVutf8_nolen> macro. | |
3251 | ||
3252 | char* sv_2pvutf8_nolen(SV* sv) | |
3253 | ||
3254 | =for hackers | |
3255 | Found in file sv.c | |
3256 | ||
3257 | =item sv_2pv_flags | |
3258 | ||
ff276b08 | 3259 | Returns a pointer to the string value of an SV, and sets *lp to its length. |
645c22ef DM |
3260 | If flags includes SV_GMAGIC, does an mg_get() first. Coerces sv to a string |
3261 | if necessary. | |
3262 | Normally invoked via the C<SvPV_flags> macro. C<sv_2pv()> and C<sv_2pv_nomg> | |
3263 | usually end up here too. | |
3264 | ||
3265 | char* sv_2pv_flags(SV* sv, STRLEN* lp, I32 flags) | |
3266 | ||
3267 | =for hackers | |
3268 | Found in file sv.c | |
3269 | ||
3270 | =item sv_2pv_nolen | |
3271 | ||
3272 | Like C<sv_2pv()>, but doesn't return the length too. You should usually | |
3273 | use the macro wrapper C<SvPV_nolen(sv)> instead. | |
3274 | char* sv_2pv_nolen(SV* sv) | |
3275 | ||
3276 | =for hackers | |
3277 | Found in file sv.c | |
3278 | ||
3279 | =item sv_2uv | |
3280 | ||
3281 | Return the unsigned integer value of an SV, doing any necessary string | |
3282 | conversion, magic etc. Normally used via the C<SvUV(sv)> and C<SvUVx(sv)> | |
3283 | macros. | |
3284 | ||
3285 | UV sv_2uv(SV* sv) | |
3286 | ||
3287 | =for hackers | |
3288 | Found in file sv.c | |
3289 | ||
3290 | =item sv_backoff | |
3291 | ||
3292 | Remove any string offset. You should normally use the C<SvOOK_off> macro | |
3293 | wrapper instead. | |
3294 | ||
3295 | int sv_backoff(SV* sv) | |
3296 | ||
3297 | =for hackers | |
3298 | Found in file sv.c | |
3299 | ||
954c1994 GS |
3300 | =item sv_bless |
3301 | ||
3302 | Blesses an SV into a specified package. The SV must be an RV. The package | |
3303 | must be designated by its stash (see C<gv_stashpv()>). The reference count | |
3304 | of the SV is unaffected. | |
3305 | ||
3306 | SV* sv_bless(SV* sv, HV* stash) | |
3307 | ||
497711e7 GS |
3308 | =for hackers |
3309 | Found in file sv.c | |
3310 | ||
954c1994 GS |
3311 | =item sv_catpv |
3312 | ||
3313 | Concatenates the string onto the end of the string which is in the SV. | |
d5ce4a7c GA |
3314 | If the SV has the UTF8 status set, then the bytes appended should be |
3315 | valid UTF8. Handles 'get' magic, but not 'set' magic. See C<sv_catpv_mg>. | |
954c1994 GS |
3316 | |
3317 | void sv_catpv(SV* sv, const char* ptr) | |
3318 | ||
497711e7 GS |
3319 | =for hackers |
3320 | Found in file sv.c | |
3321 | ||
954c1994 GS |
3322 | =item sv_catpvf |
3323 | ||
d5ce4a7c GA |
3324 | Processes its arguments like C<sprintf> and appends the formatted |
3325 | output to an SV. If the appended data contains "wide" characters | |
3326 | (including, but not limited to, SVs with a UTF-8 PV formatted with %s, | |
3327 | and characters >255 formatted with %c), the original SV might get | |
3328 | upgraded to UTF-8. Handles 'get' magic, but not 'set' magic. | |
3329 | C<SvSETMAGIC()> must typically be called after calling this function | |
3330 | to handle 'set' magic. | |
954c1994 GS |
3331 | |
3332 | void sv_catpvf(SV* sv, const char* pat, ...) | |
3333 | ||
497711e7 GS |
3334 | =for hackers |
3335 | Found in file sv.c | |
3336 | ||
954c1994 GS |
3337 | =item sv_catpvf_mg |
3338 | ||
3339 | Like C<sv_catpvf>, but also handles 'set' magic. | |
3340 | ||
3341 | void sv_catpvf_mg(SV *sv, const char* pat, ...) | |
3342 | ||
497711e7 GS |
3343 | =for hackers |
3344 | Found in file sv.c | |
3345 | ||
954c1994 GS |
3346 | =item sv_catpvn |
3347 | ||
3348 | Concatenates the string onto the end of the string which is in the SV. The | |
d5ce4a7c GA |
3349 | C<len> indicates number of bytes to copy. If the SV has the UTF8 |
3350 | status set, then the bytes appended should be valid UTF8. | |
3351 | Handles 'get' magic, but not 'set' magic. See C<sv_catpvn_mg>. | |
954c1994 GS |
3352 | |
3353 | void sv_catpvn(SV* sv, const char* ptr, STRLEN len) | |
3354 | ||
497711e7 GS |
3355 | =for hackers |
3356 | Found in file sv.c | |
3357 | ||
8d6d96c1 HS |
3358 | =item sv_catpvn_flags |
3359 | ||
3360 | Concatenates the string onto the end of the string which is in the SV. The | |
3361 | C<len> indicates number of bytes to copy. If the SV has the UTF8 | |
3362 | status set, then the bytes appended should be valid UTF8. | |
3363 | If C<flags> has C<SV_GMAGIC> bit set, will C<mg_get> on C<dsv> if | |
3364 | appropriate, else not. C<sv_catpvn> and C<sv_catpvn_nomg> are implemented | |
3365 | in terms of this function. | |
3366 | ||
3367 | void sv_catpvn_flags(SV* sv, const char* ptr, STRLEN len, I32 flags) | |
3368 | ||
3369 | =for hackers | |
3370 | Found in file sv.c | |
3371 | ||
954c1994 GS |
3372 | =item sv_catpvn_mg |
3373 | ||
3374 | Like C<sv_catpvn>, but also handles 'set' magic. | |
3375 | ||
3376 | void sv_catpvn_mg(SV *sv, const char *ptr, STRLEN len) | |
3377 | ||
497711e7 GS |
3378 | =for hackers |
3379 | Found in file sv.c | |
3380 | ||
954c1994 GS |
3381 | =item sv_catpv_mg |
3382 | ||
3383 | Like C<sv_catpv>, but also handles 'set' magic. | |
3384 | ||
3385 | void sv_catpv_mg(SV *sv, const char *ptr) | |
3386 | ||
497711e7 GS |
3387 | =for hackers |
3388 | Found in file sv.c | |
3389 | ||
954c1994 GS |
3390 | =item sv_catsv |
3391 | ||
1aa99e6b IH |
3392 | Concatenates the string from SV C<ssv> onto the end of the string in |
3393 | SV C<dsv>. Modifies C<dsv> but not C<ssv>. Handles 'get' magic, but | |
3394 | not 'set' magic. See C<sv_catsv_mg>. | |
954c1994 GS |
3395 | |
3396 | void sv_catsv(SV* dsv, SV* ssv) | |
3397 | ||
497711e7 GS |
3398 | =for hackers |
3399 | Found in file sv.c | |
3400 | ||
8d6d96c1 HS |
3401 | =item sv_catsv_flags |
3402 | ||
3403 | Concatenates the string from SV C<ssv> onto the end of the string in | |
3404 | SV C<dsv>. Modifies C<dsv> but not C<ssv>. If C<flags> has C<SV_GMAGIC> | |
3405 | bit set, will C<mg_get> on the SVs if appropriate, else not. C<sv_catsv> | |
3406 | and C<sv_catsv_nomg> are implemented in terms of this function. | |
3407 | ||
3408 | void sv_catsv_flags(SV* dsv, SV* ssv, I32 flags) | |
3409 | ||
3410 | =for hackers | |
3411 | Found in file sv.c | |
3412 | ||
954c1994 GS |
3413 | =item sv_catsv_mg |
3414 | ||
3415 | Like C<sv_catsv>, but also handles 'set' magic. | |
3416 | ||
3417 | void sv_catsv_mg(SV *dstr, SV *sstr) | |
3418 | ||
497711e7 GS |
3419 | =for hackers |
3420 | Found in file sv.c | |
3421 | ||
954c1994 GS |
3422 | =item sv_chop |
3423 | ||
1c846c1f | 3424 | Efficient removal of characters from the beginning of the string buffer. |
954c1994 GS |
3425 | SvPOK(sv) must be true and the C<ptr> must be a pointer to somewhere inside |
3426 | the string buffer. The C<ptr> becomes the first character of the adjusted | |
645c22ef | 3427 | string. Uses the "OOK hack". |
954c1994 GS |
3428 | |
3429 | void sv_chop(SV* sv, char* ptr) | |
3430 | ||
497711e7 GS |
3431 | =for hackers |
3432 | Found in file sv.c | |
3433 | ||
c461cf8f JH |
3434 | =item sv_clear |
3435 | ||
645c22ef DM |
3436 | Clear an SV: call any destructors, free up any memory used by the body, |
3437 | and free the body itself. The SV's head is I<not> freed, although | |
3438 | its type is set to all 1's so that it won't inadvertently be assumed | |
3439 | to be live during global destruction etc. | |
3440 | This function should only be called when REFCNT is zero. Most of the time | |
3441 | you'll want to call C<sv_free()> (or its macro wrapper C<SvREFCNT_dec>) | |
3442 | instead. | |
c461cf8f JH |
3443 | |
3444 | void sv_clear(SV* sv) | |
3445 | ||
3446 | =for hackers | |
3447 | Found in file sv.c | |
3448 | ||
954c1994 GS |
3449 | =item sv_cmp |
3450 | ||
3451 | Compares the strings in two SVs. Returns -1, 0, or 1 indicating whether the | |
3452 | string in C<sv1> is less than, equal to, or greater than the string in | |
645c22ef DM |
3453 | C<sv2>. Is UTF-8 and 'use bytes' aware, handles get magic, and will |
3454 | coerce its args to strings if necessary. See also C<sv_cmp_locale>. | |
954c1994 GS |
3455 | |
3456 | I32 sv_cmp(SV* sv1, SV* sv2) | |
3457 | ||
497711e7 GS |
3458 | =for hackers |
3459 | Found in file sv.c | |
3460 | ||
c461cf8f JH |
3461 | =item sv_cmp_locale |
3462 | ||
645c22ef DM |
3463 | Compares the strings in two SVs in a locale-aware manner. Is UTF-8 and |
3464 | 'use bytes' aware, handles get magic, and will coerce its args to strings | |
3465 | if necessary. See also C<sv_cmp_locale>. See also C<sv_cmp>. | |
c461cf8f JH |
3466 | |
3467 | I32 sv_cmp_locale(SV* sv1, SV* sv2) | |
3468 | ||
3469 | =for hackers | |
3470 | Found in file sv.c | |
3471 | ||
645c22ef DM |
3472 | =item sv_collxfrm |
3473 | ||
3474 | Add Collate Transform magic to an SV if it doesn't already have it. | |
3475 | ||
3476 | Any scalar variable may carry PERL_MAGIC_collxfrm magic that contains the | |
3477 | scalar data of the variable, but transformed to such a format that a normal | |
3478 | memory comparison can be used to compare the data according to the locale | |
3479 | settings. | |
3480 | ||
3481 | char* sv_collxfrm(SV* sv, STRLEN* nxp) | |