rebless instance now returns the instance too
[gitmo/Class-MOP.git] / MOP.xs
CommitLineData
e0e4674a 1
2#include "EXTERN.h"
3#include "perl.h"
4#include "XSUB.h"
b0e94057 5#include "ppport.h"
e0e4674a 6
7/*
8check_method_cache_flag:
9 check the PL_sub_generation
10 ISA/method cache thing
11
12get_code_info:
13 Pass in a coderef, returns:
14 [ $pkg_name, $coderef_name ] ie:
15 [ 'Foo::Bar', 'new' ]
16*/
17
18MODULE = Class::MOP PACKAGE = Class::MOP
19
d7bf3478 20PROTOTYPES: ENABLE
21
e0e4674a 22SV*
b1f5f41d 23check_package_cache_flag(pkg)
24 SV* pkg
e0e4674a 25 CODE:
26 RETVAL = newSViv(PL_sub_generation);
27 OUTPUT:
28 RETVAL
29
30void
31get_code_info(coderef)
32 SV* coderef
33 PREINIT:
34 char* name;
35 char* pkg;
36 PPCODE:
e0e4674a 37 if( SvOK(coderef) && SvROK(coderef) && SvTYPE(SvRV(coderef)) == SVt_PVCV){
38 coderef = SvRV(coderef);
39 name = GvNAME( CvGV(coderef) );
40 pkg = HvNAME( GvSTASH(CvGV(coderef)) );
41
42 EXTEND(SP, 2);
43 PUSHs(newSVpvn(pkg, strlen(pkg)));
44 PUSHs(newSVpvn(name, strlen(name)));
45 }
46