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