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