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