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
contextstruct is definedcop.has mentioned by @Dada in the comments:also the
blockstructures are defined incop.h.By inspecting the C implementation of the Perl
callerfunction inpp_ctl.c(line 1850), I think you can get the package name using the following code: