3 perlapi - autogenerated documentation for the perl public API
7 This file contains the documentation of the perl public API generated by
8 embed.pl, specifically a listing of functions, macros, flags, and variables
9 that may be used by extension writers. The interfaces of any functions that
10 are not listed here are subject to change without notice. For this reason,
11 blindly using functions listed in proto.h is to be avoided when writing
14 Note that all Perl API global variables must be referenced with the C<PL_>
15 prefix. Some macros are provided for compatibility with the older,
16 unadorned names, but this support may be disabled in a future release.
18 The listing is alphabetical, case insensitive.
24 Same as C<av_len()>. Deprecated, use C<av_len()> instead.
33 Clears an array, making it empty. Does not free the memory used by the
43 Deletes the element indexed by C<key> from the array. Returns the
44 deleted element. C<flags> is currently ignored.
46 SV* av_delete(AV* ar, I32 key, I32 flags)
53 Returns true if the element indexed by C<key> has been initialized.
55 This relies on the fact that uninitialized array elements are set to
58 bool av_exists(AV* ar, I32 key)
65 Pre-extend an array. The C<key> is the index to which the array should be
68 void av_extend(AV* ar, I32 key)
75 Returns the SV at the specified index in the array. The C<key> is the
76 index. If C<lval> is set then the fetch will be part of a store. Check
77 that the return value is non-null before dereferencing it to a C<SV*>.
79 See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for
80 more information on how to use this function on tied arrays.
82 SV** av_fetch(AV* ar, I32 key, I32 lval)
89 Ensure than an array has a given number of elements, equivalent to
90 Perl's C<$#array = $fill;>.
92 void av_fill(AV* ar, I32 fill)
99 Returns the highest index in the array. Returns -1 if the array is
109 Creates a new AV and populates it with a list of SVs. The SVs are copied
110 into the array, so they may be freed after the call to av_make. The new AV
111 will have a reference count of 1.
113 AV* av_make(I32 size, SV** svp)
120 Pops an SV off the end of the array. Returns C<&PL_sv_undef> if the array
130 Pushes an SV onto the end of the array. The array will grow automatically
131 to accommodate the addition.
133 void av_push(AV* ar, SV* val)
140 Shifts an SV off the beginning of the array.
149 Stores an SV in an array. The array index is specified as C<key>. The
150 return value will be NULL if the operation failed or if the value did not
151 need to be actually stored within the array (as in the case of tied
152 arrays). Otherwise it can be dereferenced to get the original C<SV*>. Note
153 that the caller is responsible for suitably incrementing the reference
154 count of C<val> before the call, and decrementing it if the function
157 See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for
158 more information on how to use this function on tied arrays.
160 SV** av_store(AV* ar, I32 key, SV* val)
167 Undefines the array. Frees the memory used by the array itself.
169 void av_undef(AV* ar)
176 Unshift the given number of C<undef> values onto the beginning of the
177 array. The array will grow automatically to accommodate the addition. You
178 must then use C<av_store> to assign values to these new elements.
180 void av_unshift(AV* ar, I32 num)
187 Converts a string C<s> of length C<len> from ASCII into UTF8 encoding.
188 Returns a pointer to the newly-created string, and sets C<len> to
189 reflect the new length.
191 NOTE: this function is experimental and may change or be
192 removed without notice.
194 U8* bytes_to_utf8(U8 *s, STRLEN *len)
201 Performs a callback to the specified Perl sub. See L<perlcall>.
203 NOTE: the perl_ form of this function is deprecated.
205 I32 call_argv(const char* sub_name, I32 flags, char** argv)
212 Performs a callback to the specified Perl method. The blessed object must
213 be on the stack. See L<perlcall>.
215 NOTE: the perl_ form of this function is deprecated.
217 I32 call_method(const char* methname, I32 flags)
224 Performs a callback to the specified Perl sub. See L<perlcall>.
226 NOTE: the perl_ form of this function is deprecated.
228 I32 call_pv(const char* sub_name, I32 flags)
235 Performs a callback to the Perl sub whose name is in the SV. See
238 NOTE: the perl_ form of this function is deprecated.
240 I32 call_sv(SV* sv, I32 flags)
247 Variable which is setup by C<xsubpp> to indicate the
248 class name for a C++ XS constructor. This is always a C<char*>. See C<THIS>.
257 The XSUB-writer's interface to the C C<memcpy> function. The C<src> is the
258 source, C<dest> is the destination, C<nitems> is the number of items, and C<type> is
259 the type. May fail on overlapping copies. See also C<Move>.
261 void Copy(void* src, void* dest, int nitems, type)
264 Found in file handy.h
268 This is the XSUB-writer's interface to Perl's C<die> function.
269 Normally use this function the same way you use the C C<printf>
270 function. See C<warn>.
272 If you want to throw an exception object, assign the object to
273 C<$@> and then pass C<Nullch> to croak():
275 errsv = get_sv("@", TRUE);
276 sv_setsv(errsv, exception_object);
279 void croak(const char* pat, ...)
286 Returns the stash of the CV.
295 If C<cv> is a constant sub eligible for inlining. returns the constant
296 value returned by the sub. Otherwise, returns NULL.
298 Constant subs can be created with C<newCONSTSUB> or as described in
299 L<perlsub/"Constant Functions">.
301 SV* cv_const_sv(CV* cv)
308 Declare a stack marker variable, C<mark>, for the XSUB. See C<MARK> and
318 Saves the original stack mark for the XSUB. See C<ORIGMARK>.
327 Declares a local copy of perl's stack pointer for the XSUB, available via
328 the C<SP> macro. See C<SP>.
337 Sets up stack and mark pointers for an XSUB, calling dSP and dMARK. This
338 is usually handled automatically by C<xsubpp>. Declares the C<items>
339 variable to indicate the number of items on the stack.
348 Sets up the C<ix> variable for an XSUB which has aliases. This is usually
349 handled automatically by C<xsubpp>.
358 Opening bracket on a callback. See C<LEAVE> and L<perlcall>.
363 Found in file scope.h
367 Tells Perl to C<eval> the given string and return an SV* result.
369 NOTE: the perl_ form of this function is deprecated.
371 SV* eval_pv(const char* p, I32 croak_on_error)
378 Tells Perl to C<eval> the string in the SV.
380 NOTE: the perl_ form of this function is deprecated.
382 I32 eval_sv(SV* sv, I32 flags)
389 Used to extend the argument stack for an XSUB's return values. Once
390 used, guarantees that there is room for at least C<nitems> to be pushed
393 void EXTEND(SP, int nitems)
400 Analyses the string in order to make fast searches on it using fbm_instr()
401 -- the Boyer-Moore algorithm.
403 void fbm_compile(SV* sv, U32 flags)
410 Returns the location of the SV in the string delimited by C<str> and
411 C<strend>. It returns C<Nullch> if the string can't be found. The C<sv>
412 does not have to be fbm_compiled, but the search will not be as fast
415 char* fbm_instr(unsigned char* big, unsigned char* bigend, SV* littlesv, U32 flags)
422 Closing bracket for temporaries on a callback. See C<SAVETMPS> and
428 Found in file scope.h
432 Returns the AV of the specified Perl array. If C<create> is set and the
433 Perl variable does not exist then it will be created. If C<create> is not
434 set and the variable does not exist then NULL is returned.
436 NOTE: the perl_ form of this function is deprecated.
438 AV* get_av(const char* name, I32 create)
445 Returns the CV of the specified Perl subroutine. If C<create> is set and
446 the Perl subroutine does not exist then it will be declared (which has the
447 same effect as saying C<sub name;>). If C<create> is not set and the
448 subroutine does not exist then NULL is returned.
450 NOTE: the perl_ form of this function is deprecated.
452 CV* get_cv(const char* name, I32 create)
459 Returns the HV of the specified Perl hash. If C<create> is set and the
460 Perl variable does not exist then it will be created. If C<create> is not
461 set and the variable does not exist then NULL is returned.
463 NOTE: the perl_ form of this function is deprecated.
465 HV* get_hv(const char* name, I32 create)
472 Returns the SV of the specified Perl scalar. If C<create> is set and the
473 Perl variable does not exist then it will be created. If C<create> is not
474 set and the variable does not exist then NULL is returned.
476 NOTE: the perl_ form of this function is deprecated.
478 SV* get_sv(const char* name, I32 create)
485 A backward-compatible version of C<GIMME_V> which can only return
486 C<G_SCALAR> or C<G_ARRAY>; in a void context, it returns C<G_SCALAR>.
487 Deprecated. Use C<GIMME_V> instead.
496 The XSUB-writer's equivalent to Perl's C<wantarray>. Returns C<G_VOID>,
497 C<G_SCALAR> or C<G_ARRAY> for void, scalar or list context,
507 Return the SV from the GV.
516 Returns the glob with the given C<name> and a defined subroutine or
517 C<NULL>. The glob lives in the given C<stash>, or in the stashes
518 accessible via @ISA and @UNIVERSAL.
520 The argument C<level> should be either 0 or -1. If C<level==0>, as a
521 side-effect creates a glob with the given C<name> in the given C<stash>
522 which in the case of success contains an alias for the subroutine, and sets
523 up caching info for this glob. Similarly for all the searched stashes.
525 This function grants C<"SUPER"> token as a postfix of the stash name. The
526 GV returned from C<gv_fetchmeth> may be a method cache entry, which is not
527 visible to Perl code. So when calling C<call_sv>, you should not use
528 the GV directly; instead, you should use the method's CV, which can be
529 obtained from the GV with the C<GvCV> macro.
531 GV* gv_fetchmeth(HV* stash, const char* name, STRLEN len, I32 level)
538 See L<gv_fetchmethod_autoload>.
540 GV* gv_fetchmethod(HV* stash, const char* name)
545 =item gv_fetchmethod_autoload
547 Returns the glob which contains the subroutine to call to invoke the method
548 on the C<stash>. In fact in the presence of autoloading this may be the
549 glob for "AUTOLOAD". In this case the corresponding variable $AUTOLOAD is
552 The third parameter of C<gv_fetchmethod_autoload> determines whether
553 AUTOLOAD lookup is performed if the given method is not present: non-zero
554 means yes, look for AUTOLOAD; zero means no, don't look for AUTOLOAD.
555 Calling C<gv_fetchmethod> is equivalent to calling C<gv_fetchmethod_autoload>
556 with a non-zero C<autoload> parameter.
558 These functions grant C<"SUPER"> token as a prefix of the method name. Note
559 that if you want to keep the returned glob for a long time, you need to
560 check for it being "AUTOLOAD", since at the later time the call may load a
561 different subroutine due to $AUTOLOAD changing its value. Use the glob
562 created via a side effect to do this.
564 These functions have the same side-effects and as C<gv_fetchmeth> with
565 C<level==0>. C<name> should be writable if contains C<':'> or C<'
566 ''>. The warning against passing the GV returned by C<gv_fetchmeth> to
567 C<call_sv> apply equally to these functions.
569 GV* gv_fetchmethod_autoload(HV* stash, const char* name, I32 autoload)
576 Returns a pointer to the stash for a specified package. C<name> should
577 be a valid UTF-8 string. If C<create> is set then the package will be
578 created if it does not already exist. If C<create> is not set and the
579 package does not exist then NULL is returned.
581 HV* gv_stashpv(const char* name, I32 create)
588 Returns a pointer to the stash for a specified package, which must be a
589 valid UTF-8 string. See C<gv_stashpv>.
591 HV* gv_stashsv(SV* sv, I32 create)
598 Used to indicate list context. See C<GIMME_V>, C<GIMME> and
606 Indicates that arguments returned from a callback should be discarded. See
614 Used to force a Perl C<eval> wrapper around a callback. See
622 Indicates that no arguments are being sent to a callback. See
630 Used to indicate scalar context. See C<GIMME_V>, C<GIMME>, and
638 Used to indicate void context. See C<GIMME_V> and L<perlcall>.
645 This flag, used in the length slot of hash entries and magic structures,
646 specifies the structure contains a C<SV*> pointer where a C<char*> pointer
647 is to be expected. (For information only--not to be used).
654 Returns the computed hash stored in the hash entry.
663 Returns the actual pointer stored in the key slot of the hash entry. The
664 pointer may be either C<char*> or C<SV*>, depending on the value of
665 C<HeKLEN()>. Can be assigned to. The C<HePV()> or C<HeSVKEY()> macros are
666 usually preferable for finding the value of a key.
675 If this is negative, and amounts to C<HEf_SVKEY>, it indicates the entry
676 holds an C<SV*> key. Otherwise, holds the actual length of the key. Can
677 be assigned to. The C<HePV()> macro is usually preferable for finding key
680 STRLEN HeKLEN(HE* he)
687 Returns the key slot of the hash entry as a C<char*> value, doing any
688 necessary dereferencing of possibly C<SV*> keys. The length of the string
689 is placed in C<len> (this is a macro, so do I<not> use C<&len>). If you do
690 not care about what the length of the key is, you may use the global
691 variable C<PL_na>, though this is rather less efficient than using a local
692 variable. Remember though, that hash keys in perl are free to contain
693 embedded nulls, so using C<strlen()> or similar is not a good way to find
694 the length of hash keys. This is very similar to the C<SvPV()> macro
695 described elsewhere in this document.
697 char* HePV(HE* he, STRLEN len)
704 Returns the key as an C<SV*>, or C<Nullsv> if the hash entry does not
705 contain an C<SV*> key.
714 Returns the key as an C<SV*>. Will create and return a temporary mortal
715 C<SV*> if the hash entry contains only a C<char*> key.
717 SV* HeSVKEY_force(HE* he)
724 Sets the key to a given C<SV*>, taking care to set the appropriate flags to
725 indicate the presence of an C<SV*> key, and returns the same
728 SV* HeSVKEY_set(HE* he, SV* sv)
735 Returns the value slot (type C<SV*>) stored in the hash entry.
744 Returns the package name of a stash. See C<SvSTASH>, C<CvSTASH>.
746 char* HvNAME(HV* stash)
753 Clears a hash, making it empty.
755 void hv_clear(HV* tb)
762 Deletes a key/value pair in the hash. The value SV is removed from the
763 hash and returned to the caller. The C<klen> is the length of the key.
764 The C<flags> value will normally be zero; if set to G_DISCARD then NULL
767 SV* hv_delete(HV* tb, const char* key, I32 klen, I32 flags)
774 Deletes a key/value pair in the hash. The value SV is removed from the
775 hash and returned to the caller. The C<flags> value will normally be zero;
776 if set to G_DISCARD then NULL will be returned. C<hash> can be a valid
777 precomputed hash value, or 0 to ask for it to be computed.
779 SV* hv_delete_ent(HV* tb, SV* key, I32 flags, U32 hash)
786 Returns a boolean indicating whether the specified hash key exists. The
787 C<klen> is the length of the key.
789 bool hv_exists(HV* tb, const char* key, I32 klen)
796 Returns a boolean indicating whether the specified hash key exists. C<hash>
797 can be a valid precomputed hash value, or 0 to ask for it to be
800 bool hv_exists_ent(HV* tb, SV* key, U32 hash)
807 Returns the SV which corresponds to the specified key in the hash. The
808 C<klen> is the length of the key. If C<lval> is set then the fetch will be
809 part of a store. Check that the return value is non-null before
810 dereferencing it to a C<SV*>.
812 See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for more
813 information on how to use this function on tied hashes.
815 SV** hv_fetch(HV* tb, const char* key, I32 klen, I32 lval)
822 Returns the hash entry which corresponds to the specified key in the hash.
823 C<hash> must be a valid precomputed hash number for the given C<key>, or 0
824 if you want the function to compute it. IF C<lval> is set then the fetch
825 will be part of a store. Make sure the return value is non-null before
826 accessing it. The return value when C<tb> is a tied hash is a pointer to a
827 static location, so be sure to make a copy of the structure if you need to
830 See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for more
831 information on how to use this function on tied hashes.
833 HE* hv_fetch_ent(HV* tb, SV* key, I32 lval, U32 hash)
840 Prepares a starting point to traverse a hash table. Returns the number of
841 keys in the hash (i.e. the same as C<HvKEYS(tb)>). The return value is
842 currently only meaningful for hashes without tie magic.
844 NOTE: Before version 5.004_65, C<hv_iterinit> used to return the number of
845 hash buckets that happen to be in use. If you still need that esoteric
846 value, you can get it through the macro C<HvFILL(tb)>.
848 I32 hv_iterinit(HV* tb)
855 Returns the key from the current position of the hash iterator. See
858 char* hv_iterkey(HE* entry, I32* retlen)
865 Returns the key as an C<SV*> from the current position of the hash
866 iterator. The return value will always be a mortal copy of the key. Also
869 SV* hv_iterkeysv(HE* entry)
876 Returns entries from a hash iterator. See C<hv_iterinit>.
878 HE* hv_iternext(HV* tb)
885 Performs an C<hv_iternext>, C<hv_iterkey>, and C<hv_iterval> in one
888 SV* hv_iternextsv(HV* hv, char** key, I32* retlen)
895 Returns the value from the current position of the hash iterator. See
898 SV* hv_iterval(HV* tb, HE* entry)
905 Adds magic to a hash. See C<sv_magic>.
907 void hv_magic(HV* hv, GV* gv, int how)
914 Stores an SV in a hash. The hash key is specified as C<key> and C<klen> is
915 the length of the key. The C<hash> parameter is the precomputed hash
916 value; if it is zero then Perl will compute it. The return value will be
917 NULL if the operation failed or if the value did not need to be actually
918 stored within the hash (as in the case of tied hashes). Otherwise it can
919 be dereferenced to get the original C<SV*>. Note that the caller is
920 responsible for suitably incrementing the reference count of C<val> before
921 the call, and decrementing it if the function returned NULL.
923 See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for more
924 information on how to use this function on tied hashes.
926 SV** hv_store(HV* tb, const char* key, I32 klen, SV* val, U32 hash)
933 Stores C<val> in a hash. The hash key is specified as C<key>. The C<hash>
934 parameter is the precomputed hash value; if it is zero then Perl will
935 compute it. The return value is the new hash entry so created. It will be
936 NULL if the operation failed or if the value did not need to be actually
937 stored within the hash (as in the case of tied hashes). Otherwise the
938 contents of the return value can be accessed using the C<He???> macros
939 described here. Note that the caller is responsible for suitably
940 incrementing the reference count of C<val> before the call, and
941 decrementing it if the function returned NULL.
943 See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for more
944 information on how to use this function on tied hashes.
946 HE* hv_store_ent(HV* tb, SV* key, SV* val, U32 hash)
955 void hv_undef(HV* tb)
962 Returns a boolean indicating whether the C C<char> is an ASCII alphanumeric
963 character (including underscore) or digit.
965 bool isALNUM(char ch)
968 Found in file handy.h
972 Returns a boolean indicating whether the C C<char> is an ASCII alphabetic
975 bool isALPHA(char ch)
978 Found in file handy.h
982 Returns a boolean indicating whether the C C<char> is an ASCII
985 bool isDIGIT(char ch)
988 Found in file handy.h
992 Returns a boolean indicating whether the C C<char> is a lowercase
995 bool isLOWER(char ch)
998 Found in file handy.h
1002 Returns a boolean indicating whether the C C<char> is whitespace.
1004 bool isSPACE(char ch)
1007 Found in file handy.h
1011 Returns a boolean indicating whether the C C<char> is an uppercase
1014 bool isUPPER(char ch)
1017 Found in file handy.h
1021 Tests if some arbitrary number of bytes begins in a valid UTF-8 character.
1022 The actual number of bytes in the UTF-8 character will be returned if it
1023 is valid, otherwise 0.
1025 STRLEN is_utf8_char(U8 *p)
1028 Found in file utf8.c
1030 =item is_utf8_string
1032 Returns true if first C<len> bytes of the given string form valid a UTF8
1033 string, false otherwise.
1035 bool is_utf8_string(U8 *s, STRLEN len)
1038 Found in file utf8.c
1042 Variable which is setup by C<xsubpp> to indicate the number of
1043 items on the stack. See L<perlxs/"Variable-length Parameter Lists">.
1048 Found in file XSUB.h
1052 Variable which is setup by C<xsubpp> to indicate which of an
1053 XSUB's aliases was used to invoke it. See L<perlxs/"The ALIAS: Keyword">.
1058 Found in file XSUB.h
1062 Closing bracket on a callback. See C<ENTER> and L<perlcall>.
1067 Found in file scope.h
1069 =item looks_like_number
1071 Test if an the content of an SV looks like a number (or is a
1072 number). C<Inf> and C<Infinity> are treated as numbers (so will not
1073 issue a non-numeric warning), even if your atof() doesn't grok them.
1075 I32 looks_like_number(SV* sv)
1082 Stack marker variable for the XSUB. See C<dMARK>.
1089 Clear something magical that the SV represents. See C<sv_magic>.
1091 int mg_clear(SV* sv)
1098 Copies the magic from one SV to another. See C<sv_magic>.
1100 int mg_copy(SV* sv, SV* nsv, const char* key, I32 klen)
1107 Finds the magic pointer for type matching the SV. See C<sv_magic>.
1109 MAGIC* mg_find(SV* sv, int type)
1116 Free any magic storage used by the SV. See C<sv_magic>.
1125 Do magic after a value is retrieved from the SV. See C<sv_magic>.
1134 Report on the SV's length. See C<sv_magic>.
1136 U32 mg_length(SV* sv)
1143 Turns on the magical status of an SV. See C<sv_magic>.
1145 void mg_magical(SV* sv)
1152 Do magic after a value is assigned to the SV. See C<sv_magic>.
1161 The XSUB-writer's interface to the C C<memmove> function. The C<src> is the
1162 source, C<dest> is the destination, C<nitems> is the number of items, and C<type> is
1163 the type. Can do overlapping moves. See also C<Copy>.
1165 void Move(void* src, void* dest, int nitems, type)
1168 Found in file handy.h
1172 The XSUB-writer's interface to the C C<malloc> function.
1174 void New(int id, void* ptr, int nitems, type)
1177 Found in file handy.h
1181 Creates a new AV. The reference count is set to 1.
1190 The XSUB-writer's interface to the C C<malloc> function, with
1193 void Newc(int id, void* ptr, int nitems, type, cast)
1196 Found in file handy.h
1200 Creates a constant sub equivalent to Perl C<sub FOO () { 123 }> which is
1201 eligible for inlining at compile-time.
1203 CV* newCONSTSUB(HV* stash, char* name, SV* sv)
1210 Creates a new HV. The reference count is set to 1.
1219 Creates an RV wrapper for an SV. The reference count for the original SV is
1222 SV* newRV_inc(SV* sv)
1229 Creates an RV wrapper for an SV. The reference count for the original
1230 SV is B<not> incremented.
1232 SV* newRV_noinc(SV *sv)
1239 Creates a new SV. A non-zero C<len> parameter indicates the number of
1240 bytes of preallocated string space the SV should have. An extra byte for a
1241 tailing NUL is also reserved. (SvPOK is not set for the SV even if string
1242 space is allocated.) The reference count for the new SV is set to 1.
1243 C<id> is an integer id between 0 and 1299 (used to identify leaks).
1245 SV* NEWSV(int id, STRLEN len)
1248 Found in file handy.h
1252 Creates a new SV and copies an integer into it. The reference count for the
1262 Creates a new SV and copies a floating point value into it.
1263 The reference count for the SV is set to 1.
1272 Creates a new SV and copies a string into it. The reference count for the
1273 SV is set to 1. If C<len> is zero, Perl will compute the length using
1274 strlen(). For efficiency, consider using C<newSVpvn> instead.
1276 SV* newSVpv(const char* s, STRLEN len)
1283 Creates a new SV an initialize it with the string formatted like
1286 SV* newSVpvf(const char* pat, ...)
1293 Creates a new SV and copies a string into it. The reference count for the
1294 SV is set to 1. Note that if C<len> is zero, Perl will create a zero length
1295 string. You are responsible for ensuring that the source string is at least
1298 SV* newSVpvn(const char* s, STRLEN len)
1303 =item newSVpvn_share
1305 Creates a new SV and populates it with a string from
1306 the string table. Turns on READONLY and FAKE.
1307 The idea here is that as string table is used for shared hash
1308 keys these strings will have SvPVX == HeKEY and hash lookup
1309 will avoid string compare.
1311 SV* newSVpvn_share(const char* s, I32 len, U32 hash)
1318 Creates a new SV for the RV, C<rv>, to point to. If C<rv> is not an RV then
1319 it will be upgraded to one. If C<classname> is non-null then the new SV will
1320 be blessed in the specified package. The new SV is returned and its
1321 reference count is 1.
1323 SV* newSVrv(SV* rv, const char* classname)
1330 Creates a new SV which is an exact duplicate of the original SV.
1332 SV* newSVsv(SV* old)
1339 Creates a new SV and copies an unsigned integer into it.
1340 The reference count for the SV is set to 1.
1349 Used by C<xsubpp> to hook up XSUBs as Perl subs.
1356 Used by C<xsubpp> to hook up XSUBs as Perl subs. Adds Perl prototypes to
1360 Found in file XSUB.h
1364 The XSUB-writer's interface to the C C<malloc> function. The allocated
1365 memory is zeroed with C<memzero>.
1367 void Newz(int id, void* ptr, int nitems, type)
1370 Found in file handy.h
1381 Null character pointer.
1384 Found in file handy.h
1405 Found in file handy.h
1409 The original stack mark for the XSUB. See C<dORIGMARK>.
1416 Allocates a new Perl interpreter. See L<perlembed>.
1418 PerlInterpreter* perl_alloc()
1421 Found in file perl.c
1423 =item perl_construct
1425 Initializes a new Perl interpreter. See L<perlembed>.
1427 void perl_construct(PerlInterpreter* interp)
1430 Found in file perl.c
1434 Shuts down a Perl interpreter. See L<perlembed>.
1436 void perl_destruct(PerlInterpreter* interp)
1439 Found in file perl.c
1443 Releases a Perl interpreter. See L<perlembed>.
1445 void perl_free(PerlInterpreter* interp)
1448 Found in file perl.c
1452 Tells a Perl interpreter to parse a Perl script. See L<perlembed>.
1454 int perl_parse(PerlInterpreter* interp, XSINIT_t xsinit, int argc, char** argv, char** env)
1457 Found in file perl.c
1461 Tells a Perl interpreter to run. See L<perlembed>.
1463 int perl_run(PerlInterpreter* interp)
1466 Found in file perl.c
1470 When Perl is run in debugging mode, with the B<-d> switch, this SV is a
1471 boolean which indicates whether subs are being single-stepped.
1472 Single-stepping is automatically turned on after every step. This is the C
1473 variable which corresponds to Perl's $DB::single variable. See
1479 Found in file intrpvar.h
1483 When Perl is run in debugging mode, with the B<-d> switch, this GV contains
1484 the SV which holds the name of the sub being debugged. This is the C
1485 variable which corresponds to Perl's $DB::sub variable. See
1491 Found in file intrpvar.h
1495 Trace variable used when Perl is run in debugging mode, with the B<-d>
1496 switch. This is the C variable which corresponds to Perl's $DB::trace
1497 variable. See C<PL_DBsingle>.
1502 Found in file intrpvar.h
1506 The C variable which corresponds to Perl's $^W warning variable.
1511 Found in file intrpvar.h
1515 The GV which was last used for a filehandle input operation. (C<< <FH> >>)
1520 Found in file thrdvar.h
1524 C<PL_modglobal> is a general purpose, interpreter global HV for use by
1525 extensions that need to keep information on a per-interpreter basis.
1526 In a pinch, it can also be used as a symbol table for extensions
1527 to share data among each other. It is a good idea to use keys
1528 prefixed by the package name of the extension that owns the data.
1533 Found in file intrpvar.h
1537 A convenience variable which is typically used with C<SvPV> when one
1538 doesn't care about the length of the string. It is usually more efficient
1539 to either declare a local variable and use that instead or to use the
1540 C<SvPV_nolen> macro.
1545 Found in file thrdvar.h
1549 The output field separator - C<$,> in Perl space.
1554 Found in file thrdvar.h
1558 The input record separator - C<$/> in Perl space.
1563 Found in file thrdvar.h
1567 This is the C<false> SV. See C<PL_sv_yes>. Always refer to this as
1573 Found in file intrpvar.h
1577 This is the C<undef> SV. Always refer to this as C<&PL_sv_undef>.
1582 Found in file intrpvar.h
1586 This is the C<true> SV. See C<PL_sv_no>. Always refer to this as
1592 Found in file intrpvar.h
1596 Pops an integer off the stack.
1605 Pops a long off the stack.
1614 Pops a double off the stack.
1623 Pops a string off the stack.
1632 Pops an SV off the stack.
1641 Push an integer onto the stack. The stack must have room for this element.
1642 Handles 'set' magic. See C<XPUSHi>.
1651 Opening bracket for arguments on a callback. See C<PUTBACK> and
1661 Push a double onto the stack. The stack must have room for this element.
1662 Handles 'set' magic. See C<XPUSHn>.
1671 Push a string onto the stack. The stack must have room for this element.
1672 The C<len> indicates the length of the string. Handles 'set' magic. See
1675 void PUSHp(char* str, STRLEN len)
1682 Push an SV onto the stack. The stack must have room for this element.
1683 Does not handle 'set' magic. See C<XPUSHs>.
1692 Push an unsigned integer onto the stack. The stack must have room for this
1693 element. See C<XPUSHu>.
1702 Closing bracket for XSUB arguments. This is usually handled by C<xsubpp>.
1703 See C<PUSHMARK> and L<perlcall> for other uses.
1712 The XSUB-writer's interface to the C C<realloc> function.
1714 void Renew(void* ptr, int nitems, type)
1717 Found in file handy.h
1721 The XSUB-writer's interface to the C C<realloc> function, with
1724 void Renewc(void* ptr, int nitems, type, cast)
1727 Found in file handy.h
1731 Tells Perl to C<require> a module.
1733 NOTE: the perl_ form of this function is deprecated.
1735 void require_pv(const char* pv)
1738 Found in file perl.c
1742 Variable which is setup by C<xsubpp> to hold the return value for an
1743 XSUB. This is always the proper type for the XSUB. See
1744 L<perlxs/"The RETVAL Variable">.
1749 Found in file XSUB.h
1753 The XSUB-writer's interface to the C C<free> function.
1755 void Safefree(void* ptr)
1758 Found in file handy.h
1762 Copy a string to a safe spot. This does not use an SV.
1764 char* savepv(const char* sv)
1767 Found in file util.c
1771 Copy a string to a safe spot. The C<len> indicates number of bytes to
1772 copy. This does not use an SV.
1774 char* savepvn(const char* sv, I32 len)
1777 Found in file util.c
1781 Opening bracket for temporaries on a callback. See C<FREETMPS> and
1787 Found in file scope.h
1791 Stack pointer. This is usually handled by C<xsubpp>. See C<dSP> and
1799 Refetch the stack pointer. Used after a callback. See L<perlcall>.
1808 Used to access elements on the XSUB's stack.
1813 Found in file XSUB.h
1817 Test two strings to see if they are equal. Returns true or false.
1819 bool strEQ(char* s1, char* s2)
1822 Found in file handy.h
1826 Test two strings to see if the first, C<s1>, is greater than or equal to
1827 the second, C<s2>. Returns true or false.
1829 bool strGE(char* s1, char* s2)
1832 Found in file handy.h
1836 Test two strings to see if the first, C<s1>, is greater than the second,
1837 C<s2>. Returns true or false.
1839 bool strGT(char* s1, char* s2)
1842 Found in file handy.h
1846 Test two strings to see if the first, C<s1>, is less than or equal to the
1847 second, C<s2>. Returns true or false.
1849 bool strLE(char* s1, char* s2)
1852 Found in file handy.h
1856 Test two strings to see if the first, C<s1>, is less than the second,
1857 C<s2>. Returns true or false.
1859 bool strLT(char* s1, char* s2)
1862 Found in file handy.h
1866 Test two strings to see if they are different. Returns true or
1869 bool strNE(char* s1, char* s2)
1872 Found in file handy.h
1876 Test two strings to see if they are equal. The C<len> parameter indicates
1877 the number of bytes to compare. Returns true or false. (A wrapper for
1880 bool strnEQ(char* s1, char* s2, STRLEN len)
1883 Found in file handy.h
1887 Test two strings to see if they are different. The C<len> parameter
1888 indicates the number of bytes to compare. Returns true or false. (A
1889 wrapper for C<strncmp>).
1891 bool strnNE(char* s1, char* s2, STRLEN len)
1894 Found in file handy.h
1898 This is an architecture-independent macro to copy one structure to another.
1900 void StructCopy(type src, type dest, type)
1903 Found in file handy.h
1907 Returns the length of the string which is in the SV. See C<SvLEN>.
1909 STRLEN SvCUR(SV* sv)
1916 Set the length of the string which is in the SV. See C<SvCUR>.
1918 void SvCUR_set(SV* sv, STRLEN len)
1925 Returns a pointer to the last character in the string which is in the SV.
1926 See C<SvCUR>. Access the character as *(SvEND(sv)).
1935 Invokes C<mg_get> on an SV if it has 'get' magic. This macro evaluates its
1936 argument more than once.
1938 void SvGETMAGIC(SV* sv)
1945 Expands the character buffer in the SV so that it has room for the
1946 indicated number of bytes (remember to reserve space for an extra trailing
1947 NUL character). Calls C<sv_grow> to perform the expansion if necessary.
1948 Returns a pointer to the character buffer.
1950 void SvGROW(SV* sv, STRLEN len)
1957 Returns a boolean indicating whether the SV contains an integer.
1966 Returns a boolean indicating whether the SV contains an integer. Checks
1967 the B<private> setting. Use C<SvIOK>.
1976 Returns a boolean indicating whether the SV contains an signed integer.
1978 void SvIOK_notUV(SV* sv)
1985 Unsets the IV status of an SV.
1987 void SvIOK_off(SV* sv)
1994 Tells an SV that it is an integer.
1996 void SvIOK_on(SV* sv)
2003 Tells an SV that it is an integer and disables all other OK bits.
2005 void SvIOK_only(SV* sv)
2012 Tells and SV that it is an unsigned integer and disables all other OK bits.
2014 void SvIOK_only_UV(SV* sv)
2021 Returns a boolean indicating whether the SV contains an unsigned integer.
2023 void SvIOK_UV(SV* sv)
2030 Coerces the given SV to an integer and returns it.
2039 Returns the integer which is stored in the SV, assuming SvIOK is
2049 Returns the size of the string buffer in the SV, not including any part
2050 attributable to C<SvOOK>. See C<SvCUR>.
2052 STRLEN SvLEN(SV* sv)
2059 Returns a boolean indicating whether the SV contains a number, integer or
2069 Returns a boolean indicating whether the SV contains a number, integer or
2070 double. Checks the B<private> setting. Use C<SvNIOK>.
2072 bool SvNIOKp(SV* sv)
2079 Unsets the NV/IV status of an SV.
2081 void SvNIOK_off(SV* sv)
2088 Returns a boolean indicating whether the SV contains a double.
2097 Returns a boolean indicating whether the SV contains a double. Checks the
2098 B<private> setting. Use C<SvNOK>.
2107 Unsets the NV status of an SV.
2109 void SvNOK_off(SV* sv)
2116 Tells an SV that it is a double.
2118 void SvNOK_on(SV* sv)
2125 Tells an SV that it is a double and disables all other OK bits.
2127 void SvNOK_only(SV* sv)
2134 Coerce the given SV to a double and return it.
2143 Returns the double which is stored in the SV, assuming SvNOK is
2153 Returns a boolean indicating whether the value is an SV.
2162 Returns a boolean indicating whether the SvIVX is a valid offset value for
2163 the SvPVX. This hack is used internally to speed up removal of characters
2164 from the beginning of a SvPV. When SvOOK is true, then the start of the
2165 allocated string buffer is really (SvPVX - SvIVX).
2174 Returns a boolean indicating whether the SV contains a character
2184 Returns a boolean indicating whether the SV contains a character string.
2185 Checks the B<private> setting. Use C<SvPOK>.
2194 Unsets the PV status of an SV.
2196 void SvPOK_off(SV* sv)
2203 Tells an SV that it is a string.
2205 void SvPOK_on(SV* sv)
2212 Tells an SV that it is a string and disables all other OK bits.
2214 void SvPOK_only(SV* sv)
2219 =item SvPOK_only_UTF8
2221 Tells an SV that it is a UTF8 string (do not use frivolously)
2222 and disables all other OK bits.
2224 void SvPOK_only_UTF8(SV* sv)
2231 Returns a pointer to the string in the SV, or a stringified form of the SV
2232 if the SV does not contain a string. Handles 'get' magic.
2234 char* SvPV(SV* sv, STRLEN len)
2241 Returns a pointer to the string in the SV. The SV must contain a
2251 Like <SvPV> but will force the SV into becoming a string (SvPOK). You want
2252 force if you are going to update the SvPVX directly.
2254 char* SvPV_force(SV* sv, STRLEN len)
2261 Returns a pointer to the string in the SV, or a stringified form of the SV
2262 if the SV does not contain a string. Handles 'get' magic.
2264 char* SvPV_nolen(SV* sv)
2271 Returns the value of the object's reference count.
2273 U32 SvREFCNT(SV* sv)
2280 Decrements the reference count of the given SV.
2282 void SvREFCNT_dec(SV* sv)
2289 Increments the reference count of the given SV.
2291 SV* SvREFCNT_inc(SV* sv)
2298 Tests if the SV is an RV.
2307 Unsets the RV status of an SV.
2309 void SvROK_off(SV* sv)
2316 Tells an SV that it is an RV.
2318 void SvROK_on(SV* sv)
2325 Dereferences an RV to return the SV.
2334 Invokes C<mg_set> on an SV if it has 'set' magic. This macro evaluates its
2335 argument more than once.
2337 void SvSETMAGIC(SV* sv)
2344 Calls C<sv_setsv> if dsv is not the same as ssv. May evaluate arguments
2347 void SvSetSV(SV* dsb, SV* ssv)
2352 =item SvSetSV_nosteal
2354 Calls a non-destructive version of C<sv_setsv> if dsv is not the same as
2355 ssv. May evaluate arguments more than once.
2357 void SvSetSV_nosteal(SV* dsv, SV* ssv)
2364 Returns the stash of the SV.
2373 Taints an SV if tainting is enabled
2375 void SvTAINT(SV* sv)
2382 Checks to see if an SV is tainted. Returns TRUE if it is, FALSE if
2385 bool SvTAINTED(SV* sv)
2392 Untaints an SV. Be I<very> careful with this routine, as it short-circuits
2393 some of Perl's fundamental security features. XS module authors should not
2394 use this function unless they fully understand all the implications of
2395 unconditionally untainting the value. Untainting should be done in the
2396 standard perl fashion, via a carefully crafted regexp, rather than directly
2397 untainting variables.
2399 void SvTAINTED_off(SV* sv)
2406 Marks an SV as tainted.
2408 void SvTAINTED_on(SV* sv)
2415 Returns a boolean indicating whether Perl would evaluate the SV as true or
2416 false, defined or undefined. Does not handle 'get' magic.
2425 Returns the type of the SV. See C<svtype>.
2427 svtype SvTYPE(SV* sv)
2434 An enum of flags for Perl types. These are found in the file B<sv.h>
2435 in the C<svtype> enum. Test these flags with the C<SvTYPE> macro.
2442 Integer type flag for scalars. See C<svtype>.
2449 Double type flag for scalars. See C<svtype>.
2456 Pointer type flag for scalars. See C<svtype>.
2463 Type flag for arrays. See C<svtype>.
2470 Type flag for code refs. See C<svtype>.
2477 Type flag for hashes. See C<svtype>.
2484 Type flag for blessed scalars. See C<svtype>.
2491 Returns a boolean indicating whether the SV contains an unsigned integer.
2500 Used to upgrade an SV to a more complex form. Uses C<sv_upgrade> to
2501 perform the upgrade if necessary. See C<svtype>.
2503 void SvUPGRADE(SV* sv, svtype type)
2510 Returns a boolean indicating whether the SV contains UTF-8 encoded data.
2519 Unsets the UTF8 status of an SV.
2521 void SvUTF8_off(SV *sv)
2528 Tells an SV that it is a string and encoded in UTF8. Do not use frivolously.
2530 void SvUTF8_on(SV *sv)
2537 Coerces the given SV to an unsigned integer and returns it.
2546 Returns the unsigned integer which is stored in the SV, assuming SvIOK is
2556 Marks an SV as mortal. The SV will be destroyed when the current context
2559 SV* sv_2mortal(SV* sv)
2566 Blesses an SV into a specified package. The SV must be an RV. The package
2567 must be designated by its stash (see C<gv_stashpv()>). The reference count
2568 of the SV is unaffected.
2570 SV* sv_bless(SV* sv, HV* stash)
2577 Concatenates the string onto the end of the string which is in the SV.
2578 Handles 'get' magic, but not 'set' magic. See C<sv_catpv_mg>.
2580 void sv_catpv(SV* sv, const char* ptr)
2587 Processes its arguments like C<sprintf> and appends the formatted output
2588 to an SV. Handles 'get' magic, but not 'set' magic. C<SvSETMAGIC()> must
2589 typically be called after calling this function to handle 'set' magic.
2591 void sv_catpvf(SV* sv, const char* pat, ...)
2598 Like C<sv_catpvf>, but also handles 'set' magic.
2600 void sv_catpvf_mg(SV *sv, const char* pat, ...)
2607 Concatenates the string onto the end of the string which is in the SV. The
2608 C<len> indicates number of bytes to copy. Handles 'get' magic, but not
2609 'set' magic. See C<sv_catpvn_mg>.
2611 void sv_catpvn(SV* sv, const char* ptr, STRLEN len)
2618 Like C<sv_catpvn>, but also handles 'set' magic.
2620 void sv_catpvn_mg(SV *sv, const char *ptr, STRLEN len)
2627 Like C<sv_catpv>, but also handles 'set' magic.
2629 void sv_catpv_mg(SV *sv, const char *ptr)
2636 Concatenates the string from SV C<ssv> onto the end of the string in
2637 SV C<dsv>. Modifies C<dsv> but not C<ssv>. Handles 'get' magic, but
2638 not 'set' magic. See C<sv_catsv_mg>.
2640 void sv_catsv(SV* dsv, SV* ssv)
2647 Like C<sv_catsv>, but also handles 'set' magic.
2649 void sv_catsv_mg(SV *dstr, SV *sstr)
2656 Efficient removal of characters from the beginning of the string buffer.
2657 SvPOK(sv) must be true and the C<ptr> must be a pointer to somewhere inside
2658 the string buffer. The C<ptr> becomes the first character of the adjusted
2661 void sv_chop(SV* sv, char* ptr)
2668 Clear an SV, making it empty. Does not free the memory used by the SV
2671 void sv_clear(SV* sv)
2678 Compares the strings in two SVs. Returns -1, 0, or 1 indicating whether the
2679 string in C<sv1> is less than, equal to, or greater than the string in
2682 I32 sv_cmp(SV* sv1, SV* sv2)
2689 Compares the strings in two SVs in a locale-aware manner. See
2692 I32 sv_cmp_locale(SV* sv1, SV* sv2)
2699 Auto-decrement of the value in the SV.
2706 =item sv_derived_from
2708 Returns a boolean indicating whether the SV is derived from the specified
2709 class. This is the function that implements C<UNIVERSAL::isa>. It works
2710 for class names as well as for objects.
2712 bool sv_derived_from(SV* sv, const char* name)
2715 Found in file universal.c
2719 Returns a boolean indicating whether the strings in the two SVs are
2722 I32 sv_eq(SV* sv1, SV* sv2)
2729 Free the memory used by an SV.
2731 void sv_free(SV* sv)
2738 Get a line from the filehandle and store it into the SV, optionally
2739 appending to the currently-stored string.
2741 char* sv_gets(SV* sv, PerlIO* fp, I32 append)
2748 Expands the character buffer in the SV. This will use C<sv_unref> and will
2749 upgrade the SV to C<SVt_PV>. Returns a pointer to the character buffer.
2752 char* sv_grow(SV* sv, STRLEN newlen)
2759 Auto-increment of the value in the SV.
2768 Inserts a string at the specified offset/length within the SV. Similar to
2769 the Perl substr() function.
2771 void sv_insert(SV* bigsv, STRLEN offset, STRLEN len, char* little, STRLEN littlelen)
2778 Returns a boolean indicating whether the SV is blessed into the specified
2779 class. This does not check for subtypes; use C<sv_derived_from> to verify
2780 an inheritance relationship.
2782 int sv_isa(SV* sv, const char* name)
2789 Returns a boolean indicating whether the SV is an RV pointing to a blessed
2790 object. If the SV is not an RV, or if the object is not blessed, then this
2793 int sv_isobject(SV* sv)
2800 Returns the length of the string in the SV. See also C<SvCUR>.
2802 STRLEN sv_len(SV* sv)
2809 Returns the number of characters in the string in an SV, counting wide
2810 UTF8 bytes as a single character.
2812 STRLEN sv_len_utf8(SV* sv)
2819 Adds magic to an SV.
2821 void sv_magic(SV* sv, SV* obj, int how, const char* name, I32 namlen)
2828 Creates a new SV which is a copy of the original SV. The new SV is marked
2831 SV* sv_mortalcopy(SV* oldsv)
2838 Creates a new SV which is mortal. The reference count of the SV is set to 1.
2847 Get a sensible string out of the SV somehow.
2849 char* sv_pvn_force(SV* sv, STRLEN* lp)
2854 =item sv_pvutf8n_force
2856 Get a sensible UTF8-encoded string out of the SV somehow. See
2859 char* sv_pvutf8n_force(SV* sv, STRLEN* lp)
2866 Returns a string describing what the SV is a reference to.
2868 char* sv_reftype(SV* sv, int ob)
2875 Make the first argument a copy of the second, then delete the original.
2877 void sv_replace(SV* sv, SV* nsv)
2886 SV* sv_rvweaken(SV *sv)
2893 Copies an integer into the given SV. Does not handle 'set' magic. See
2896 void sv_setiv(SV* sv, IV num)
2903 Like C<sv_setiv>, but also handles 'set' magic.
2905 void sv_setiv_mg(SV *sv, IV i)
2912 Copies a double into the given SV. Does not handle 'set' magic. See
2915 void sv_setnv(SV* sv, NV num)
2922 Like C<sv_setnv>, but also handles 'set' magic.
2924 void sv_setnv_mg(SV *sv, NV num)
2931 Copies a string into an SV. The string must be null-terminated. Does not
2932 handle 'set' magic. See C<sv_setpv_mg>.
2934 void sv_setpv(SV* sv, const char* ptr)
2941 Processes its arguments like C<sprintf> and sets an SV to the formatted
2942 output. Does not handle 'set' magic. See C<sv_setpvf_mg>.
2944 void sv_setpvf(SV* sv, const char* pat, ...)
2951 Like C<sv_setpvf>, but also handles 'set' magic.
2953 void sv_setpvf_mg(SV *sv, const char* pat, ...)
2960 Copies an integer into the given SV, also updating its string value.
2961 Does not handle 'set' magic. See C<sv_setpviv_mg>.
2963 void sv_setpviv(SV* sv, IV num)
2970 Like C<sv_setpviv>, but also handles 'set' magic.
2972 void sv_setpviv_mg(SV *sv, IV iv)
2979 Copies a string into an SV. The C<len> parameter indicates the number of
2980 bytes to be copied. Does not handle 'set' magic. See C<sv_setpvn_mg>.
2982 void sv_setpvn(SV* sv, const char* ptr, STRLEN len)
2989 Like C<sv_setpvn>, but also handles 'set' magic.
2991 void sv_setpvn_mg(SV *sv, const char *ptr, STRLEN len)
2998 Like C<sv_setpv>, but also handles 'set' magic.
3000 void sv_setpv_mg(SV *sv, const char *ptr)
3007 Copies an integer into a new SV, optionally blessing the SV. The C<rv>
3008 argument will be upgraded to an RV. That RV will be modified to point to
3009 the new SV. The C<classname> argument indicates the package for the
3010 blessing. Set C<classname> to C<Nullch> to avoid the blessing. The new SV
3011 will be returned and will have a reference count of 1.
3013 SV* sv_setref_iv(SV* rv, const char* classname, IV iv)
3020 Copies a double into a new SV, optionally blessing the SV. The C<rv>
3021 argument will be upgraded to an RV. That RV will be modified to point to
3022 the new SV. The C<classname> argument indicates the package for the
3023 blessing. Set C<classname> to C<Nullch> to avoid the blessing. The new SV
3024 will be returned and will have a reference count of 1.
3026 SV* sv_setref_nv(SV* rv, const char* classname, NV nv)
3033 Copies a pointer into a new SV, optionally blessing the SV. The C<rv>
3034 argument will be upgraded to an RV. That RV will be modified to point to
3035 the new SV. If the C<pv> argument is NULL then C<PL_sv_undef> will be placed
3036 into the SV. The C<classname> argument indicates the package for the
3037 blessing. Set C<classname> to C<Nullch> to avoid the blessing. The new SV
3038 will be returned and will have a reference count of 1.
3040 Do not use with other Perl types such as HV, AV, SV, CV, because those
3041 objects will become corrupted by the pointer copy process.
3043 Note that C<sv_setref_pvn> copies the string while this copies the pointer.
3045 SV* sv_setref_pv(SV* rv, const char* classname, void* pv)
3052 Copies a string into a new SV, optionally blessing the SV. The length of the
3053 string must be specified with C<n>. The C<rv> argument will be upgraded to
3054 an RV. That RV will be modified to point to the new SV. The C<classname>
3055 argument indicates the package for the blessing. Set C<classname> to
3056 C<Nullch> to avoid the blessing. The new SV will be returned and will have
3057 a reference count of 1.
3059 Note that C<sv_setref_pv> copies the pointer while this copies the string.
3061 SV* sv_setref_pvn(SV* rv, const char* classname, char* pv, STRLEN n)
3068 Copies the contents of the source SV C<ssv> into the destination SV C<dsv>.
3069 The source SV may be destroyed if it is mortal. Does not handle 'set'
3070 magic. See the macro forms C<SvSetSV>, C<SvSetSV_nosteal> and
3073 void sv_setsv(SV* dsv, SV* ssv)
3080 Like C<sv_setsv>, but also handles 'set' magic.
3082 void sv_setsv_mg(SV *dstr, SV *sstr)
3089 Copies an unsigned integer into the given SV. Does not handle 'set' magic.
3092 void sv_setuv(SV* sv, UV num)
3099 Like C<sv_setuv>, but also handles 'set' magic.
3101 void sv_setuv_mg(SV *sv, UV u)
3108 Returns true if the SV has a true value by Perl's rules.
3117 Removes magic from an SV.
3119 int sv_unmagic(SV* sv, int type)
3126 Unsets the RV status of the SV, and decrements the reference count of
3127 whatever was being referenced by the RV. This can almost be thought of
3128 as a reversal of C<newSVrv>. This is C<sv_unref_flags> with the C<flag>
3129 being zero. See C<SvROK_off>.
3131 void sv_unref(SV* sv)
3136 =item sv_unref_flags
3138 Unsets the RV status of the SV, and decrements the reference count of
3139 whatever was being referenced by the RV. This can almost be thought of
3140 as a reversal of C<newSVrv>. The C<cflags> argument can contain
3141 C<SV_IMMEDIATE_UNREF> to force the reference count to be decremented
3142 (otherwise the decrementing is conditional on the reference count being
3143 different from one or the reference being a readonly SV).
3146 void sv_unref_flags(SV* sv, U32 flags)
3153 Upgrade an SV to a more complex form. Use C<SvUPGRADE>. See
3156 bool sv_upgrade(SV* sv, U32 mt)
3163 Tells an SV to use C<ptr> to find its string value. Normally the string is
3164 stored inside the SV but sv_usepvn allows the SV to use an outside string.
3165 The C<ptr> should point to memory that was allocated by C<malloc>. The
3166 string length, C<len>, must be supplied. This function will realloc the
3167 memory pointed to by C<ptr>, so that pointer should not be freed or used by
3168 the programmer after giving it to sv_usepvn. Does not handle 'set' magic.
3169 See C<sv_usepvn_mg>.
3171 void sv_usepvn(SV* sv, char* ptr, STRLEN len)
3178 Like C<sv_usepvn>, but also handles 'set' magic.
3180 void sv_usepvn_mg(SV *sv, char *ptr, STRLEN len)
3185 =item sv_utf8_downgrade
3187 Attempt to convert the PV of an SV from UTF8-encoded to byte encoding.
3188 This may not be possible if the PV contains non-byte encoding characters;
3189 if this is the case, either returns false or, if C<fail_ok> is not
3192 NOTE: this function is experimental and may change or be
3193 removed without notice.
3195 bool sv_utf8_downgrade(SV *sv, bool fail_ok)
3200 =item sv_utf8_encode
3202 Convert the PV of an SV to UTF8-encoded, but then turn off the C<SvUTF8>
3203 flag so that it looks like bytes again. Nothing calls this.
3205 NOTE: this function is experimental and may change or be
3206 removed without notice.
3208 void sv_utf8_encode(SV *sv)
3213 =item sv_utf8_upgrade
3215 Convert the PV of an SV to its UTF8-encoded form.
3217 void sv_utf8_upgrade(SV *sv)
3224 Processes its arguments like C<vsprintf> and appends the formatted output
3225 to an SV. Uses an array of SVs if the C style variable argument list is
3226 missing (NULL). When running with taint checks enabled, indicates via
3227 C<maybe_tainted> if results are untrustworthy (often due to the use of
3230 void sv_vcatpvfn(SV* sv, const char* pat, STRLEN patlen, va_list* args, SV** svargs, I32 svmax, bool *maybe_tainted)
3237 Works like C<vcatpvfn> but copies the text into the SV instead of
3240 void sv_vsetpvfn(SV* sv, const char* pat, STRLEN patlen, va_list* args, SV** svargs, I32 svmax, bool *maybe_tainted)
3247 Variable which is setup by C<xsubpp> to designate the object in a C++
3248 XSUB. This is always the proper type for the C++ object. See C<CLASS> and
3249 L<perlxs/"Using XS With C++">.
3254 Found in file XSUB.h
3258 Converts the specified character to lowercase.
3260 char toLOWER(char ch)
3263 Found in file handy.h
3267 Converts the specified character to uppercase.
3269 char toUPPER(char ch)
3272 Found in file handy.h
3276 Returns the number of UTF8 characters between the UTF-8 pointers C<a>
3279 WARNING: use only if you *know* that the pointers point inside the
3282 IV utf8_distance(U8 *a, U8 *b)
3285 Found in file utf8.c
3289 Return the UTF-8 pointer C<s> displaced by C<off> characters, either
3290 forward or backward.
3292 WARNING: do not use the following unless you *know* C<off> is within
3293 the UTF-8 data pointed to by C<s> *and* that on entry C<s> is aligned
3294 on the first byte of character or just after the last byte of a character.
3296 U8* utf8_hop(U8 *s, I32 off)
3299 Found in file utf8.c
3303 Return the length of the UTF-8 char encoded string C<s> in characters.
3304 Stops at C<e> (inclusive). If C<e E<lt> s> or if the scan would end
3305 up past C<e>, croaks.
3307 STRLEN utf8_length(U8* s, U8 *e)
3310 Found in file utf8.c
3314 Converts a string C<s> of length C<len> from UTF8 into byte encoding.
3315 Unlike C<bytes_to_utf8>, this over-writes the original string, and
3316 updates len to contain the new length.
3317 Returns zero on failure, setting C<len> to -1.
3319 NOTE: this function is experimental and may change or be
3320 removed without notice.
3322 U8* utf8_to_bytes(U8 *s, STRLEN *len)
3325 Found in file utf8.c
3329 Returns the character value of the first character in the string C<s>
3330 which is assumed to be in UTF8 encoding and no longer than C<curlen>;
3331 C<retlen> will be set to the length, in bytes, of that character.
3333 If C<s> does not point to a well-formed UTF8 character, the behaviour
3334 is dependent on the value of C<flags>: if it contains UTF8_CHECK_ONLY,
3335 it is assumed that the caller will raise a warning, and this function
3336 will silently just set C<retlen> to C<-1> and return zero. If the
3337 C<flags> does not contain UTF8_CHECK_ONLY, warnings about
3338 malformations will be given, C<retlen> will be set to the expected
3339 length of the UTF-8 character in bytes, and zero will be returned.
3341 The C<flags> can also contain various flags to allow deviations from
3342 the strict UTF-8 encoding (see F<utf8.h>).
3344 UV utf8_to_uv(U8 *s, STRLEN curlen, STRLEN* retlen, U32 flags)
3347 Found in file utf8.c
3349 =item utf8_to_uv_simple
3351 Returns the character value of the first character in the string C<s>
3352 which is assumed to be in UTF8 encoding; C<retlen> will be set to the
3353 length, in bytes, of that character.
3355 If C<s> does not point to a well-formed UTF8 character, zero is
3356 returned and retlen is set, if possible, to -1.
3358 UV utf8_to_uv_simple(U8 *s, STRLEN* retlen)
3361 Found in file utf8.c
3365 Adds the UTF8 representation of the Unicode codepoint C<uv> to the end
3366 of the string C<d>; C<d> should be have at least C<UTF8_MAXLEN+1> free
3367 bytes available. The return value is the pointer to the byte after the
3368 end of the new character. In other words,
3370 d = uv_to_utf8(d, uv);
3372 is the recommended Unicode-aware way of saying
3376 U8* uv_to_utf8(U8 *d, UV uv)
3379 Found in file utf8.c
3383 This is the XSUB-writer's interface to Perl's C<warn> function. Use this
3384 function the same way you use the C C<printf> function. See
3387 void warn(const char* pat, ...)
3390 Found in file util.c
3394 Push an integer onto the stack, extending the stack if necessary. Handles
3395 'set' magic. See C<PUSHi>.
3404 Push a double onto the stack, extending the stack if necessary. Handles
3405 'set' magic. See C<PUSHn>.
3414 Push a string onto the stack, extending the stack if necessary. The C<len>
3415 indicates the length of the string. Handles 'set' magic. See
3418 void XPUSHp(char* str, STRLEN len)
3425 Push an SV onto the stack, extending the stack if necessary. Does not
3426 handle 'set' magic. See C<PUSHs>.
3435 Push an unsigned integer onto the stack, extending the stack if necessary.
3445 Macro to declare an XSUB and its C parameter list. This is handled by
3449 Found in file XSUB.h
3453 Return from XSUB, indicating number of items on the stack. This is usually
3454 handled by C<xsubpp>.
3456 void XSRETURN(int nitems)
3459 Found in file XSUB.h
3461 =item XSRETURN_EMPTY
3463 Return an empty list from an XSUB immediately.
3468 Found in file XSUB.h
3472 Return an integer from an XSUB immediately. Uses C<XST_mIV>.
3474 void XSRETURN_IV(IV iv)
3477 Found in file XSUB.h
3481 Return C<&PL_sv_no> from an XSUB immediately. Uses C<XST_mNO>.
3486 Found in file XSUB.h
3490 Return an double from an XSUB immediately. Uses C<XST_mNV>.
3492 void XSRETURN_NV(NV nv)
3495 Found in file XSUB.h
3499 Return a copy of a string from an XSUB immediately. Uses C<XST_mPV>.
3501 void XSRETURN_PV(char* str)
3504 Found in file XSUB.h
3506 =item XSRETURN_UNDEF
3508 Return C<&PL_sv_undef> from an XSUB immediately. Uses C<XST_mUNDEF>.
3513 Found in file XSUB.h
3517 Return C<&PL_sv_yes> from an XSUB immediately. Uses C<XST_mYES>.
3522 Found in file XSUB.h
3526 Place an integer into the specified position C<pos> on the stack. The
3527 value is stored in a new mortal SV.
3529 void XST_mIV(int pos, IV iv)
3532 Found in file XSUB.h
3536 Place C<&PL_sv_no> into the specified position C<pos> on the
3539 void XST_mNO(int pos)
3542 Found in file XSUB.h
3546 Place a double into the specified position C<pos> on the stack. The value
3547 is stored in a new mortal SV.
3549 void XST_mNV(int pos, NV nv)
3552 Found in file XSUB.h
3556 Place a copy of a string into the specified position C<pos> on the stack.
3557 The value is stored in a new mortal SV.
3559 void XST_mPV(int pos, char* str)
3562 Found in file XSUB.h
3566 Place C<&PL_sv_undef> into the specified position C<pos> on the
3569 void XST_mUNDEF(int pos)
3572 Found in file XSUB.h
3576 Place C<&PL_sv_yes> into the specified position C<pos> on the
3579 void XST_mYES(int pos)
3582 Found in file XSUB.h
3586 The version identifier for an XS module. This is usually
3587 handled automatically by C<ExtUtils::MakeMaker>. See C<XS_VERSION_BOOTCHECK>.
3590 Found in file XSUB.h
3592 =item XS_VERSION_BOOTCHECK
3594 Macro to verify that a PM module's $VERSION variable matches the XS
3595 module's C<XS_VERSION> variable. This is usually handled automatically by
3596 C<xsubpp>. See L<perlxs/"The VERSIONCHECK: Keyword">.
3598 XS_VERSION_BOOTCHECK;
3601 Found in file XSUB.h
3605 The XSUB-writer's interface to the C C<memzero> function. The C<dest> is the
3606 destination, C<nitems> is the number of items, and C<type> is the type.
3608 void Zero(void* dest, int nitems, type)
3611 Found in file handy.h
3617 Until May 1997, this document was maintained by Jeff Okamoto
3618 <okamoto@corp.hp.com>. It is now maintained as part of Perl itself.
3620 With lots of help and suggestions from Dean Roehrich, Malcolm Beattie,
3621 Andreas Koenig, Paul Hudson, Ilya Zakharevich, Paul Marquess, Neil
3622 Bowers, Matthew Green, Tim Bunce, Spider Boardman, Ulrich Pfeifer,
3623 Stephen McCamant, and Gurusamy Sarathy.
3625 API Listing originally by Dean Roehrich <roehrich@cray.com>.
3627 Updated to be autogenerated from comments in the source by Benjamin Stuhl.
3631 perlguts(1), perlxs(1), perlxstut(1), perlintern(1)