To get current context I find caller_cx
function in perlapi
. But there is no description for structure. In perl source code perl.h
I can find only this typedef
:
typedef struct context PERL_CONTEXT;
Is there examples how to use this struct returned by caller_cx
to find current package from XS?
The
context
struct is definedcop.h
as mentioned by @Dada in the comments:also the
block
structures are defined incop.h
.By inspecting the C implementation of the Perl
caller
function inpp_ctl.c
(line 1850), I think you can get the package name using the following code: