|
perlapi - autogenerated documentation for the perl public API
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 PL_
prefix. Some macros are provided for compatibility with the older,
unadorned names, but this support may be disabled in a future release.
The listing is alphabetical, case insensitive.
- GIMME
-
A backward-compatible version of GIMME_V which can only return
G_SCALAR or G_ARRAY; in a void context, it returns G_SCALAR.
Deprecated. Use GIMME_V instead.
-
U32 GIMME
- GIMME_V
-
The XSUB-writer's equivalent to Perl's wantarray. Returns G_VOID,
G_SCALAR or G_ARRAY for void, scalar or list context,
respectively.
-
U32 GIMME_V
- G_ARRAY
-
Used to indicate list context. See GIMME_V, GIMME and
the perlcall manpage.
- G_DISCARD
-
Indicates that arguments returned from a callback should be discarded. See
the perlcall manpage.
- G_EVAL
-
Used to force a Perl eval wrapper around a callback. See
the perlcall manpage.
- G_NOARGS
-
Indicates that no arguments are being sent to a callback. See
the perlcall manpage.
- G_SCALAR
-
Used to indicate scalar context. See GIMME_V, GIMME, and
the perlcall manpage.
- G_VOID
-
Used to indicate void context. See GIMME_V and the perlcall manpage.
- AvFILL
-
Same as av_len(). Deprecated, use av_len() instead.
-
int AvFILL(AV* av)
- av_clear
-
Clears an array, making it empty. Does not free the memory used by the
array itself.
-
void av_clear(AV* ar)
- av_create_and_push
-
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)
- av_create_and_unshift_one
-
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)
- av_delete
-
Deletes the element indexed by key from the array. Returns the
deleted element. If flags equals G_DISCARD, the element is freed
and null is returned.
-
SV* av_delete(AV* ar, I32 key, I32 flags)
- av_exists
-
Returns true if the element indexed by key has been initialized.
-
This relies on the fact that uninitialized array elements are set to
&PL_sv_undef.
-
bool av_exists(AV* ar, I32 key)
- av_extend
-
Pre-extend an array. The key is the index to which the array should be
extended.
-
void av_extend(AV* ar, I32 key)
- av_fetch
-
Returns the SV at the specified index in the array. The key is the
index. If lval is set then the fetch will be part of a store. Check
that the return value is non-null before dereferencing it to a SV*.
-
See Understanding the Magic of Tied Hashes and Arrays in the perlguts manpage for
more information on how to use this function on tied arrays.
-
SV** av_fetch(AV* ar, I32 key, I32 lval)
- av_fill
-
Set the highest index in the array to the given number, equivalent to
Perl's $#array = $fill;.
-
The number of elements in the an array will be fill + 1 after
av_fill() returns. If the array was previously shorter then the
additional elements appended are set to PL_sv_undef. If the array
was longer, then the excess elements are freed. av_fill(av, -1) is
the same as av_clear(av).
-
void av_fill(AV* ar, I32 fill)
- av_len
-
Returns the highest index in the array. The number of elements in the
array is av_len(av) + 1. Returns -1 if the array is empty.
-
I32 av_len(AV* ar)
- av_make
-
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** svp)
- av_pop
-
Pops an SV off the end of the array. Returns &PL_sv_undef if the array
is empty.
-
SV* av_pop(AV* ar)
- av_push
-
Pushes an SV onto the end of the array. The array will grow automatically
to accommodate the addition.
-
void av_push(AV* ar, SV* val)
- av_shift
-
Shifts an SV off the beginning of the array.
-
SV* av_shift(AV* ar)
- av_store
-
Stores an SV in an array. The array index is specified as key. 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 SV*. Note
that the caller is responsible for suitably incrementing the reference
count of val before the call, and decrementing it if the function
returned NULL.
-
See Understanding the Magic of Tied Hashes and Arrays in the perlguts manpage for
more information on how to use this function on tied arrays.
-
SV** av_store(AV* ar, I32 key, SV* val)
- av_undef
-
Undefines the array. Frees the memory used by the array itself.
-
void av_undef(AV* ar)
- av_unshift
-
Unshift the given number of undef values onto the beginning of the
array. The array will grow automatically to accommodate the addition. You
must then use av_store to assign values to these new elements.
-
void av_unshift(AV* ar, I32 num)
- get_av
-
Returns the AV of the specified Perl array. If create is set and the
Perl variable does not exist then it will be created. If create is not
set 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 create)
- newAV
-
Creates a new AV. The reference count is set to 1.
-
AV* newAV()
- sortsv
-
Sort an array. Here is an example:
-
sortsv(AvARRAY(av), av_len(av)+1, Perl_sv_cmp_locale);
-
See lib/sort.pm for details about controlling the sorting algorithm.
-
void sortsv(SV** array, size_t num_elts, SVCOMPARE_t cmp)
- call_argv
-
Performs a callback to the specified Perl sub. See the perlcall manpage.
-
NOTE: the perl_ form of this function is deprecated.
-
I32 call_argv(const char* sub_name, I32 flags, char** argv)
- call_method
-
Performs a callback to the specified Perl method. The blessed object must
be on the stack. See the perlcall manpage.
-
NOTE: the perl_ form of this function is deprecated.
-
I32 call_method(const char* methname, I32 flags)
- call_pv
-
Performs a callback to the specified Perl sub. See the perlcall manpage.
-
NOTE: the perl_ form of this function is deprecated.
-
I32 call_pv(const char* sub_name, I32 flags)
- call_sv
-
Performs a callback to the Perl sub whose name is in the SV. See
the perlcall manpage.
-
NOTE: the perl_ form of this function is deprecated.
-
I32 call_sv(SV* sv, I32 flags)
- ENTER
-
Opening bracket on a callback. See LEAVE and the perlcall manpage.
-
ENTER;
- eval_pv
-
Tells Perl to eval 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)
- eval_sv
-
Tells Perl to eval the string in the SV.
-
NOTE: the perl_ form of this function is deprecated.
-
I32 eval_sv(SV* sv, I32 flags)
- FREETMPS
-
Closing bracket for temporaries on a callback. See SAVETMPS and
the perlcall manpage.
-
FREETMPS;
- LEAVE
-
Closing bracket on a callback. See ENTER and the perlcall manpage.
-
LEAVE;
- SAVETMPS
-
Opening bracket for temporaries on a callback. See FREETMPS and
the perlcall manpage.
-
SAVETMPS;
- isALNUM
-
Returns a boolean indicating whether the C char is an ASCII alphanumeric
character (including underscore) or digit.
-
bool isALNUM(char ch)
- isALPHA
-
Returns a boolean indicating whether the C char is an ASCII alphabetic
character.
-
bool isALPHA(char ch)
- isDIGIT
-
Returns a boolean indicating whether the C char is an ASCII
digit.
-
bool isDIGIT(char ch)
- isLOWER
-
Returns a boolean indicating whether the C char is a lowercase
character.
-
bool isLOWER(char ch)
- isSPACE
-
Returns a boolean indicating whether the C char is whitespace.
-
bool isSPACE(char ch)
- isUPPER
-
Returns a boolean indicating whether the C char is an uppercase
character.
-
bool isUPPER(char ch)
- toLOWER
-
Converts the specified character to lowercase.
-
char toLOWER(char ch)
- toUPPER
-
Converts the specified character to uppercase.
-
char toUPPER(char ch)
- perl_clone
-
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
ptr_table_free(PL_ptr_table); PL_ptr_table = NULL;,
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* interp, UV flags)
- CvSTASH
-
Returns the stash of the CV.
-
HV* CvSTASH(CV* cv)
- get_cv
-
Uses strlen to get the length of name, then calls get_cvn_flags.
-
NOTE: the perl_ form of this function is deprecated.
-
CV* get_cv(const char* name, I32 flags)
- get_cvn_flags
-
Returns the CV of the specified Perl subroutine. flags are passed to
gv_fetchpvn_flags. If GV_ADD is set and the Perl subroutine does not
exist then it will be declared (which has the same effect as saying
sub name;). If GV_ADD 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)
- cv_undef
-
Clear out all the active components of a CV. This can happen either
by an explicit undef &foo, 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)
- load_module
-
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 use Foo::Bar VERSION. The optional trailing SV*
arguments can be used to specify arguments to the module's import()
method, similar to use Foo::Bar VERSION LIST.
-
void load_module(U32 flags, SV* name, SV* ver, ...)
- nothreadhook
-
Stub that provides thread hook for perl_destruct when there are
no threads.
-
int nothreadhook()
- perl_alloc
-
Allocates a new Perl interpreter. See the perlembed manpage.
-
PerlInterpreter* perl_alloc()
- perl_construct
-
Initializes a new Perl interpreter. See the perlembed manpage.
-
void perl_construct(PerlInterpreter* interp)
- perl_destruct
-
Shuts down a Perl interpreter. See the perlembed manpage.
-
int perl_destruct(PerlInterpreter* interp)
- perl_free
-
Releases a Perl interpreter. See the perlembed manpage.
-
void perl_free(PerlInterpreter* interp)
- perl_parse
-
Tells a Perl interpreter to parse a Perl script. See the perlembed manpage.
-
int perl_parse(PerlInterpreter* interp, XSINIT_t xsinit, int argc, char** argv, char** env)
- perl_run
-
Tells a Perl interpreter to run. See the perlembed manpage.
-
int perl_run(PerlInterpreter* interp)
- require_pv
-
Tells Perl to require the file named by the string argument. It is
analogous to the Perl code eval "require '$file'". It's even
implemented that way; consider using load_module instead.
-
NOTE: the perl_ form of this function is deprecated.
-
void require_pv(const char* pv)
- pv_display
-
char *pv_display(SV *dsv, const char *pv, STRLEN cur, STRLEN len,
STRLEN pvlim, U32 flags)
-
Similar to
-
pv_escape(dsv,pv,cur,pvlim,PERL_PV_ESCAPE_QUOTE);
-
except that an additional "\0" will be appended to the string when
len > cur and pv[cur] is "\0".
-
Note that the final string may be up to 7 chars longer than pvlim.
-
char* pv_display(SV *dsv, char *pv, STRLEN cur, STRLEN len, STRLEN pvlim)
- pv_escape
-
|const STRLEN count|const STRLEN max
|STRLEN const *escaped, const U32 flags
-
Escapes at most the first "count" chars of pv and puts the results into
dsv such that the size of the escaped string will not exceed "max" chars
and will not contain any incomplete escape sequences.
-
If flags contains PERL_PV_ESCAPE_QUOTE then any double quotes in the string
will also be escaped.
-
Normally the SV will be cleared before the escaped string is prepared,
but when PERL_PV_ESCAPE_NOCLEAR is set this will not occur.
-
If PERL_PV_ESCAPE_UNI is set then the input string is treated as unicode,
if PERL_PV_ESCAPE_UNI_DETECT is set then the input string is scanned
using is_utf8_string() to determine if it is unicode.
-
If PERL_PV_ESCAPE_ALL is set then all input chars will be output
using \x01F1 style escapes, otherwise only chars above 255 will be
escaped using this style, other non printable chars will use octal or
common escaped patterns like \n. If PERL_PV_ESCAPE_NOBACKSLASH
then all chars below 255 will be treated as printable and
will be output as literals.
-
If PERL_PV_ESCAPE_FIRSTCHAR is set then only the first char of the
string will be escaped, regardles of max. If the string is utf8 and
the chars value is >255 then it will be returned as a plain hex
sequence. Thus the output will either be a single char,
an octal escape sequence, a special escape like \n or a 3 or
more digit hex value.
-
Returns a pointer to the escaped text as held by dsv.
-
NOTE: the perl_ form of this function is deprecated.
-
char* pv_escape(SV *dsv, char const * const str, const STRLEN count, const STRLEN max, STRLEN * const escaped, const U32 flags)
- pv_pretty
-
|const STRLEN count|const STRLEN max\
|const char const *start_color| const char const *end_color\
|const U32 flags
-
Converts a string into something presentable, handling escaping via
pv_escape() and supporting quoting and elipses.
-
If the PERL_PV_PRETTY_QUOTE flag is set then the result will be
double quoted with any double quotes in the string escaped. Otherwise
if the PERL_PV_PRETTY_LTGT flag is set then the result be wrapped in
angle brackets.
-
If the PERL_PV_PRETTY_ELIPSES flag is set and not all characters in
string were output then an elipses C<...> will be appended to the
string. Note that this happens AFTER it has been quoted.
-
If start_color is non-null then it will be inserted after the opening
quote (if there is one) but before the escaped text. If end_color
is non-null then it will be inserted after the escaped text but before
any quotes or elipses.
-
Returns a pointer to the prettified text as held by dsv.
-
NOTE: the perl_ form of this function is deprecated.
-
char* pv_pretty(SV *dsv, char const * const str, const STRLEN count, const STRLEN max, char const * const start_color, char const * const end_color, const U32 flags)
- gv_fetchmethod
-
See gv_fetchmethod_autoload.
-
GV* gv_fetchmethod(HV* stash, const char* name)
- pack_cat
-
The engine implementing pack() Perl function. Note: parameters next_in_list and
flags are not used. This call should not be used; use packlist instead.
-
void pack_cat(SV *cat, char *pat, char *patend, SV **beglist, SV **endlist, SV ***next_in_list, U32 flags)
- sv_2pvbyte_nolen
-
Return a pointer to the byte-encoded representation of the SV.
May cause the SV to be downgraded from UTF-8 as a side-effect.
-
Usually accessed via the SvPVbyte_nolen macro.
-
char* sv_2pvbyte_nolen(SV* sv)
- sv_2pvutf8_nolen
-
Return a pointer to the UTF-8-encoded representation of the SV.
May cause the SV to be upgraded to UTF-8 as a side-effect.
-
Usually accessed via the SvPVutf8_nolen macro.
-
char* sv_2pvutf8_nolen(SV* sv)
- sv_2pv_nolen
-
Like sv_2pv(), but doesn't return the length too. You should usually
use the macro wrapper SvPV_nolen(sv) instead.
char* sv_2pv_nolen(SV* sv)
- sv_catpvn_mg
-
Like sv_catpvn, but also handles 'set' magic.
-
void sv_catpvn_mg(SV *sv, const char *ptr, STRLEN len)
- sv_catsv_mg
-
Like sv_catsv, but also handles 'set' magic.
-
void sv_catsv_mg(SV *dstr, SV *sstr)
- sv_force_normal
-
Undo various types of fakery on an SV: if the PV is a shared string, make
a private copy; if we're a ref, stop refing; if we're a glob, downgrade to
an xpvmg. See also sv_force_normal_flags.
-
void sv_force_normal(SV *sv)
- sv_iv
-
A private implementation of the SvIVx macro for compilers which can't
cope with complex macro expressions. Always use the macro instead.
-
IV sv_iv(SV* sv)
- sv_nolocking
-
Dummy routine which "locks" an SV when there is no locking module present.
Exists to avoid test for a NULL function pointer and because it could
potentially warn under some level of strict-ness.
-
"Superseded" by sv_nosharing().
-
void sv_nolocking(SV *sv)
- sv_nounlocking
-
Dummy routine which "unlocks" an SV when there is no locking module present.
Exists to avoid test for a NULL function pointer and because it could
potentially warn under some level of strict-ness.
-
"Superseded" by sv_nosharing().
-
void sv_nounlocking(SV *sv)
- sv_nv
-
A private implementation of the SvNVx macro for compilers which can't
cope with complex macro expressions. Always use the macro instead.
-
NV sv_nv(SV* sv)
- sv_pv
-
Use the SvPV_nolen macro instead
-
char* sv_pv(SV *sv)
- sv_pvbyte
-
Use SvPVbyte_nolen instead.
-
char* sv_pvbyte(SV *sv)
- sv_pvbyten
-
A private implementation of the SvPVbyte macro for compilers
which can't cope with complex macro expressions. Always use the macro
instead.
-
char* sv_pvbyten(SV *sv, STRLEN *len)
- sv_pvn
-
A private implementation of the SvPV macro for compilers which can't
cope with complex macro expressions. Always use the macro instead.
-
char* sv_pvn(SV *sv, STRLEN *len)
- sv_pvutf8
-
Use the SvPVutf8_nolen macro instead
-
char* sv_pvutf8(SV *sv)
- sv_pvutf8n
-
A private implementation of the SvPVutf8 macro for compilers
which can't cope with complex macro expressions. Always use the macro
instead.
-
char* sv_pvutf8n(SV *sv, STRLEN *len)
- sv_taint
-
- sv_unref
-
Unsets the RV status of the SV, and decrements the reference count of
whatever was being referenced by the RV. This can almost be thought of
as a reversal of newSVrv. This is sv_unref_flags with the flag
being zero. See SvROK_off.
-
void sv_unref(SV* sv)
- sv_usepvn
-
Tells an SV to use ptr to find its string value. Implemented by
calling sv_usepvn_flags with flags of 0, hence does not handle 'set'
magic. See sv_usepvn_flags.
-
void sv_usepvn(SV* sv, char* ptr, STRLEN len)
- sv_usepvn_mg
-
Like sv_usepvn, but also handles 'set' magic.
-
void sv_usepvn_mg(SV *sv, char *ptr, STRLEN len)
- sv_uv
-
A private implementation of the SvUVx macro for compilers which can't
cope with complex macro expressions. Always use the macro instead.
-
UV sv_uv(SV* sv)
- unpack_str
-
The engine implementing unpack() Perl function. Note: parameters strbeg, new_s
and ocnt are not used. This call should not be used, use unpackstring instead.
-
I32 unpack_str(char *pat, char *patend, char *s, char *strbeg, char *strend, char **new_s, I32 ocnt, U32 flags)
- packlist
-
The engine implementing pack() Perl function.
-
void packlist(SV *cat, char *pat, char *patend, SV **beglist, SV **endlist)
- unpackstring
-
The engine implementing unpack() Perl function. unpackstring puts the
extracted list items on the stack and returns the number of elements.
Issue PUTBACK before and SPAGAIN after the call to this function.
-
I32 unpackstring(char *pat, char *patend, char *s, char *strend, U32 flags)
- PL_modglobal
-
PL_modglobal is a general purpose, interpreter global HV for use by
extensions that need to keep information on a per-interpreter basis.
In a pinch, it can also be used as a symbol table for extensions
to share data among each other. It is a good idea to use keys
prefixed by the package name of the extension that owns the data.
-
HV* PL_modglobal
- PL_na
-
A convenience variable which is typically used with SvPV when one
doesn't care about the length of the string. It is usually more efficient
to either declare a local variable and use that instead or to use the
SvPV_nolen macro.
-
STRLEN PL_na
|