test tweaks
[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 PROTOTYPES: ENABLE
21
22 SV*
23 check_package_cache_flag(pkg)
24   SV* pkg
25   CODE:
26     RETVAL = newSViv(PL_sub_generation);
27   OUTPUT:
28     RETVAL
29
30 void
31 get_code_info(coderef)
32   SV* coderef
33   PREINIT:
34     char* name;
35     char* pkg;
36   PPCODE:
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