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