|
Packit Service |
f53c04 |
#include "EXTERN.h"
|
|
Packit Service |
f53c04 |
#include "perl.h"
|
|
Packit Service |
f53c04 |
#include "XSUB.h"
|
|
Packit Service |
f53c04 |
#include "ppport.h"
|
|
Packit Service |
f53c04 |
|
|
Packit Service |
f53c04 |
#ifndef CvISXSUB
|
|
Packit Service |
f53c04 |
# define CvISXSUB(cv) CvXSUB(cv)
|
|
Packit Service |
f53c04 |
#endif
|
|
Packit Service |
f53c04 |
|
|
Packit Service |
f53c04 |
/*
|
|
Packit Service |
f53c04 |
get_code_info:
|
|
Packit Service |
f53c04 |
Pass in a coderef, returns:
|
|
Packit Service |
f53c04 |
[ $pkg_name, $coderef_name ] ie:
|
|
Packit Service |
f53c04 |
[ 'Foo::Bar', 'new' ]
|
|
Packit Service |
f53c04 |
*/
|
|
Packit Service |
f53c04 |
|
|
Packit Service |
f53c04 |
MODULE = Sub::Identify PACKAGE = Sub::Identify
|
|
Packit Service |
f53c04 |
|
|
Packit Service |
f53c04 |
PROTOTYPES: ENABLE
|
|
Packit Service |
f53c04 |
|
|
Packit Service |
f53c04 |
void
|
|
Packit Service |
f53c04 |
get_code_info(coderef)
|
|
Packit Service |
f53c04 |
SV* coderef
|
|
Packit Service |
f53c04 |
PREINIT:
|
|
Packit Service |
f53c04 |
char* name;
|
|
Packit Service |
f53c04 |
char* pkg;
|
|
Packit Service |
f53c04 |
PPCODE:
|
|
Packit Service |
f53c04 |
if (SvOK(coderef) && SvROK(coderef) && SvTYPE(SvRV(coderef)) == SVt_PVCV) {
|
|
Packit Service |
f53c04 |
coderef = SvRV(coderef);
|
|
Packit Service |
f53c04 |
if (CvGV(coderef)) {
|
|
Packit Service |
f53c04 |
name = GvNAME( CvGV(coderef) );
|
|
Packit Service |
f53c04 |
pkg = HvNAME( GvSTASH(CvGV(coderef)) );
|
|
Packit Service |
f53c04 |
EXTEND(SP, 2);
|
|
Packit Service |
f53c04 |
PUSHs(sv_2mortal(newSVpvn(pkg, strlen(pkg))));
|
|
Packit Service |
f53c04 |
PUSHs(sv_2mortal(newSVpvn(name, strlen(name))));
|
|
Packit Service |
f53c04 |
}
|
|
Packit Service |
f53c04 |
else {
|
|
Packit Service |
f53c04 |
/* sub is being compiled: bail out and return nothing. */
|
|
Packit Service |
f53c04 |
}
|
|
Packit Service |
f53c04 |
}
|
|
Packit Service |
f53c04 |
|
|
Packit Service |
f53c04 |
void
|
|
Packit Service |
f53c04 |
get_code_location(coderef)
|
|
Packit Service |
f53c04 |
SV* coderef
|
|
Packit Service |
f53c04 |
PREINIT:
|
|
Packit Service |
f53c04 |
char* file;
|
|
Packit Service |
f53c04 |
line_t line;
|
|
Packit Service |
f53c04 |
PPCODE:
|
|
Packit Service |
f53c04 |
if (SvOK(coderef) && SvROK(coderef) && SvTYPE(SvRV(coderef)) == SVt_PVCV) {
|
|
Packit Service |
f53c04 |
coderef = SvRV(coderef);
|
|
Packit Service |
f53c04 |
if (CvSTART(coderef) && !CvISXSUB(coderef)) {
|
|
Packit Service |
f53c04 |
file = CvFILE(coderef);
|
|
Packit Service |
f53c04 |
line = CopLINE((const COP*)CvSTART(coderef));
|
|
Packit Service |
f53c04 |
EXTEND(SP, 2);
|
|
Packit Service |
f53c04 |
PUSHs(sv_2mortal(newSVpvn(file, strlen(file))));
|
|
Packit Service |
f53c04 |
PUSHs(sv_2mortal(newSViv(line)));
|
|
Packit Service |
f53c04 |
}
|
|
Packit Service |
f53c04 |
}
|
|
Packit Service |
f53c04 |
|
|
Packit Service |
f53c04 |
#if PERL_VERSION >= 16
|
|
Packit Service |
f53c04 |
|
|
Packit Service |
f53c04 |
bool
|
|
Packit Service |
f53c04 |
is_sub_constant(coderef)
|
|
Packit Service |
f53c04 |
SV* coderef
|
|
Packit Service |
f53c04 |
CODE:
|
|
Packit Service |
f53c04 |
if (SvOK(coderef) && SvROK(coderef) && SvTYPE(SvRV(coderef)) == SVt_PVCV) {
|
|
Packit Service |
f53c04 |
coderef = SvRV(coderef);
|
|
Packit Service |
f53c04 |
RETVAL = CvPROTO(coderef) && CvPROTOLEN(coderef) == 0 && CvCONST(coderef);
|
|
Packit Service |
f53c04 |
}
|
|
Packit Service |
f53c04 |
else
|
|
Packit Service |
f53c04 |
RETVAL = 0;
|
|
Packit Service |
f53c04 |
OUTPUT:
|
|
Packit Service |
f53c04 |
RETVAL
|
|
Packit Service |
f53c04 |
|
|
Packit Service |
f53c04 |
#endif
|