-*- buffer-read-only: t -*-
!!!!!!! DO NOT EDIT THIS FILE !!!!!!!
This file is built by autodoc.pl extracting documentation from the C source
files.
=head1 NAME
perlapi - autogenerated documentation for the perl public API
=head1 DESCRIPTION
X X X
This file contains the documentation of the perl public API generated by
embed.pl, specifically a listing of functions, macros, flags, and variables
that may be used by extension writers. The interfaces of any functions that
are not listed here are subject to change without notice. For this reason,
blindly using functions listed in proto.h is to be avoided when writing
extensions.
Note that all Perl API global variables must be referenced with the C
prefix. Some macros are provided for compatibility with the older,
unadorned names, but this support may be disabled in a future release.
Perl was originally written to handle US-ASCII only (that is characters
whose ordinal numbers are in the range 0 - 127).
And documentation and comments may still use the term ASCII, when
sometimes in fact the entire range from 0 - 255 is meant.
Note that Perl can be compiled and run under EBCDIC (See L)
or ASCII. Most of the documentation (and even comments in the code)
ignore the EBCDIC possibility.
For almost all purposes the differences are transparent.
As an example, under EBCDIC,
instead of UTF-8, UTF-EBCDIC is used to encode Unicode strings, and so
whenever this documentation refers to C
(and variants of that name, including in function names),
it also (essentially transparently) means C.
But the ordinals of characters differ between ASCII, EBCDIC, and
the UTF- encodings, and a string encoded in UTF-EBCDIC may occupy more bytes
than in UTF-8.
Also, on some EBCDIC machines, functions that are documented as operating on
US-ASCII (or Basic Latin in Unicode terminology) may in fact operate on all
256 characters in the EBCDIC range, not just the subset corresponding to
US-ASCII.
The listing below is alphabetical, case insensitive.
=head1 "Gimme" Values
=over 8
=item GIMME
X
A backward-compatible version of C which can only return
C or C; in a void context, it returns C.
Deprecated. Use C instead.
U32 GIMME
=for hackers
Found in file op.h
=item GIMME_V
X
The XSUB-writer's equivalent to Perl's C. Returns C,
C or C for void, scalar or list context,
respectively.
U32 GIMME_V
=for hackers
Found in file op.h
=item G_ARRAY
X
Used to indicate list context. See C, C and
L.
=for hackers
Found in file cop.h
=item G_DISCARD
X
Indicates that arguments returned from a callback should be discarded. See
L.
=for hackers
Found in file cop.h
=item G_EVAL
X
Used to force a Perl C wrapper around a callback. See
L.
=for hackers
Found in file cop.h
=item G_NOARGS
X
Indicates that no arguments are being sent to a callback. See
L.
=for hackers
Found in file cop.h
=item G_SCALAR
X
Used to indicate scalar context. See C, C, and
L.
=for hackers
Found in file cop.h
=item G_VOID
X
Used to indicate void context. See C and L.
=for hackers
Found in file cop.h
=back
=head1 Array Manipulation Functions
=over 8
=item AvFILL
X
Same as C. Deprecated, use C instead.
int AvFILL(AV* av)
=for hackers
Found in file av.h
=item av_clear
X
Clears an array, making it empty. Does not free the memory used by the
array itself.
void av_clear(AV *av)
=for hackers
Found in file av.c
=item av_create_and_push
X
Push an SV onto the end of the array, creating the array if necessary.
A small internal helper function to remove a commonly duplicated idiom.
NOTE: this function is experimental and may change or be
removed without notice.
void av_create_and_push(AV **const avp, SV *const val)
=for hackers
Found in file av.c
=item av_create_and_unshift_one
X
Unshifts an SV onto the beginning of the array, creating the array if
necessary.
A small internal helper function to remove a commonly duplicated idiom.
NOTE: this function is experimental and may change or be
removed without notice.
SV** av_create_and_unshift_one(AV **const avp, SV *const val)
=for hackers
Found in file av.c
=item av_delete
X
Deletes the element indexed by C from the array. Returns the
deleted element. If C equals C, the element is freed
and null is returned.
SV* av_delete(AV *av, I32 key, I32 flags)
=for hackers
Found in file av.c
=item av_exists
X
Returns true if the element indexed by C has been initialized.
This relies on the fact that uninitialized array elements are set to
C<&PL_sv_undef>.
bool av_exists(AV *av, I32 key)
=for hackers
Found in file av.c
=item av_extend
X
Pre-extend an array. The C is the index to which the array should be
extended.
void av_extend(AV *av, I32 key)
=for hackers
Found in file av.c
=item av_fetch
X
Returns the SV at the specified index in the array. The C is the
index. If C is set then the fetch will be part of a store. Check
that the return value is non-null before dereferencing it to a C.
See L for
more information on how to use this function on tied arrays.
SV** av_fetch(AV *av, I32 key, I32 lval)
=for hackers
Found in file av.c
=item av_fill
X
Set the highest index in the array to the given number, equivalent to
Perl's C<$#array = $fill;>.
The number of elements in the an array will be C after
av_fill() returns. If the array was previously shorter then the
additional elements appended are set to C. If the array
was longer, then the excess elements are freed. C is
the same as C.
void av_fill(AV *av, I32 fill)
=for hackers
Found in file av.c
=item av_len
X
Returns the highest index in the array. The number of elements in the
array is C. Returns -1 if the array is empty.
I32 av_len(const AV *av)
=for hackers
Found in file av.c
=item av_make
X
Creates a new AV and populates it with a list of SVs. The SVs are copied
into the array, so they may be freed after the call to av_make. The new AV
will have a reference count of 1.
AV* av_make(I32 size, SV **strp)
=for hackers
Found in file av.c
=item av_pop
X
Pops an SV off the end of the array. Returns C<&PL_sv_undef> if the array
is empty.
SV* av_pop(AV *av)
=for hackers
Found in file av.c
=item av_push
X
Pushes an SV onto the end of the array. The array will grow automatically
to accommodate the addition. Like C, this takes ownership of one
reference count.
void av_push(AV *av, SV *val)
=for hackers
Found in file av.c
=item av_shift
X
Shifts an SV off the beginning of the array. Returns C<&PL_sv_undef> if the
array is empty.
SV* av_shift(AV *av)
=for hackers
Found in file av.c
=item av_store
X
Stores an SV in an array. The array index is specified as C. The
return value will be NULL if the operation failed or if the value did not
need to be actually stored within the array (as in the case of tied
arrays). Otherwise it can be dereferenced to get the original C. Note
that the caller is responsible for suitably incrementing the reference
count of C before the call, and decrementing it if the function
returned NULL.
See L for
more information on how to use this function on tied arrays.
SV** av_store(AV *av, I32 key, SV *val)
=for hackers
Found in file av.c
=item av_undef
X
Undefines the array. Frees the memory used by the array itself.
void av_undef(AV *av)
=for hackers
Found in file av.c
=item av_unshift
X
Unshift the given number of C values onto the beginning of the
array. The array will grow automatically to accommodate the addition. You
must then use C to assign values to these new elements.
void av_unshift(AV *av, I32 num)
=for hackers
Found in file av.c
=item get_av
X
Returns the AV of the specified Perl array. C are passed to
C. If C is set and the
Perl variable does not exist then it will be created. If C is zero
and the variable does not exist then NULL is returned.
NOTE: the perl_ form of this function is deprecated.
AV* get_av(const char *name, I32 flags)
=for hackers
Found in file perl.c
=item newAV
X
Creates a new AV. The reference count is set to 1.
AV* newAV()
=for hackers
Found in file av.h
=item sortsv
X
Sort an array. Here is an example:
sortsv(AvARRAY(av), av_len(av)+1, Perl_sv_cmp_locale);
Currently this always uses mergesort. See sortsv_flags for a more
flexible routine.
void sortsv(SV** array, size_t num_elts, SVCOMPARE_t cmp)
=for hackers
Found in file pp_sort.c
=item sortsv_flags
X
Sort an array, with various options.
void sortsv_flags(SV** array, size_t num_elts, SVCOMPARE_t cmp, U32 flags)
=for hackers
Found in file pp_sort.c
=back
=head1 Callback Functions
=over 8
=item call_argv
X
Performs a callback to the specified Perl sub. See L.
NOTE: the perl_ form of this function is deprecated.
I32 call_argv(const char* sub_name, I32 flags, char** argv)
=for hackers
Found in file perl.c
=item call_method
X
Performs a callback to the specified Perl method. The blessed object must
be on the stack. See L.
NOTE: the perl_ form of this function is deprecated.
I32 call_method(const char* methname, I32 flags)
=for hackers
Found in file perl.c
=item call_pv
X
Performs a callback to the specified Perl sub. See L.
NOTE: the perl_ form of this function is deprecated.
I32 call_pv(const char* sub_name, I32 flags)
=for hackers
Found in file perl.c
=item call_sv
X
Performs a callback to the Perl sub whose name is in the SV. See
L.
NOTE: the perl_ form of this function is deprecated.
I32 call_sv(SV* sv, VOL I32 flags)
=for hackers
Found in file perl.c
=item ENTER
X
Opening bracket on a callback. See C and L.
ENTER;
=for hackers
Found in file scope.h
=item eval_pv
X
Tells Perl to C the given string and return an SV* result.
NOTE: the perl_ form of this function is deprecated.
SV* eval_pv(const char* p, I32 croak_on_error)
=for hackers
Found in file perl.c
=item eval_sv
X
Tells Perl to C the string in the SV.
NOTE: the perl_ form of this function is deprecated.
I32 eval_sv(SV* sv, I32 flags)
=for hackers
Found in file perl.c
=item FREETMPS
X
Closing bracket for temporaries on a callback. See C and
L.
FREETMPS;
=for hackers
Found in file scope.h
=item LEAVE
X
Closing bracket on a callback. See C and L.
LEAVE;
=for hackers
Found in file scope.h
=item SAVETMPS
X
Opening bracket for temporaries on a callback. See C and
L.
SAVETMPS;
=for hackers
Found in file scope.h
=back
=head1 Character classes
=over 8
=item isALNUM
X
Returns a boolean indicating whether the C C is a US-ASCII (Basic Latin)
alphanumeric character (including underscore) or digit.
bool isALNUM(char ch)
=for hackers
Found in file handy.h
=item isALPHA
X
Returns a boolean indicating whether the C C is a US-ASCII (Basic Latin)
alphabetic character.
bool isALPHA(char ch)
=for hackers
Found in file handy.h
=item isDIGIT
X
Returns a boolean indicating whether the C C is a US-ASCII (Basic Latin)
digit.
bool isDIGIT(char ch)
=for hackers
Found in file handy.h
=item isLOWER
X
Returns a boolean indicating whether the C C is a US-ASCII (Basic Latin)
lowercase character.
bool isLOWER(char ch)
=for hackers
Found in file handy.h
=item isSPACE
X
Returns a boolean indicating whether the C C is a US-ASCII (Basic Latin)
whitespace.
bool isSPACE(char ch)
=for hackers
Found in file handy.h
=item isUPPER
X
Returns a boolean indicating whether the C C is a US-ASCII (Basic Latin)
uppercase character.
bool isUPPER(char ch)
=for hackers
Found in file handy.h
=item toLOWER
X
Converts the specified character to lowercase. Characters outside the
US-ASCII (Basic Latin) range are viewed as not having any case.
char toLOWER(char ch)
=for hackers
Found in file handy.h
=item toUPPER
X
Converts the specified character to uppercase. Characters outside the
US-ASCII (Basic Latin) range are viewed as not having any case.
char toUPPER(char ch)
=for hackers
Found in file handy.h
=back
=head1 Cloning an interpreter
=over 8
=item perl_clone
X
Create and return a new interpreter by cloning the current one.
perl_clone takes these flags as parameters:
CLONEf_COPY_STACKS - is used to, well, copy the stacks also,
without it we only clone the data and zero the stacks,
with it we copy the stacks and the new perl interpreter is
ready to run at the exact same point as the previous one.
The pseudo-fork code uses COPY_STACKS while the
threads->create doesn't.
CLONEf_KEEP_PTR_TABLE
perl_clone keeps a ptr_table with the pointer of the old
variable as a key and the new variable as a value,
this allows it to check if something has been cloned and not
clone it again but rather just use the value and increase the
refcount. If KEEP_PTR_TABLE is not set then perl_clone will kill
the ptr_table using the function
C,
reason to keep it around is if you want to dup some of your own
variable who are outside the graph perl scans, example of this
code is in threads.xs create
CLONEf_CLONE_HOST
This is a win32 thing, it is ignored on unix, it tells perls
win32host code (which is c++) to clone itself, this is needed on
win32 if you want to run two threads at the same time,
if you just want to do some stuff in a separate perl interpreter
and then throw it away and return to the original one,
you don't need to do anything.
PerlInterpreter* perl_clone(PerlInterpreter *proto_perl, UV flags)
=for hackers
Found in file sv.c
=back
=head1 CV Manipulation Functions
=over 8
=item CvSTASH
X
Returns the stash of the CV.
HV* CvSTASH(CV* cv)
=for hackers
Found in file cv.h
=item get_cv
X
Uses C to get the length of C, then calls C.
NOTE: the perl_ form of this function is deprecated.
CV* get_cv(const char* name, I32 flags)
=for hackers
Found in file perl.c
=item get_cvn_flags
X
Returns the CV of the specified Perl subroutine. C are passed to
C. If C is set and the Perl subroutine does not
exist then it will be declared (which has the same effect as saying
C). If C is not set and the subroutine does not exist
then NULL is returned.
NOTE: the perl_ form of this function is deprecated.
CV* get_cvn_flags(const char* name, STRLEN len, I32 flags)
=for hackers
Found in file perl.c
=back
=head1 Embedding Functions
=over 8
=item cv_undef
X
Clear out all the active components of a CV. This can happen either
by an explicit C, or by the reference count going to zero.
In the former case, we keep the CvOUTSIDE pointer, so that any anonymous
children can still follow the full lexical scope chain.
void cv_undef(CV* cv)
=for hackers
Found in file op.c
=item load_module
X
Loads the module whose name is pointed to by the string part of name.
Note that the actual module name, not its filename, should be given.
Eg, "Foo::Bar" instead of "Foo/Bar.pm". flags can be any of
PERL_LOADMOD_DENY, PERL_LOADMOD_NOIMPORT, or PERL_LOADMOD_IMPORT_OPS
(or 0 for no flags). ver, if specified, provides version semantics
similar to C