| 1 |
|
| #include "EXTERN.h" |
| 2 |
|
| #include "perl.h" |
| 3 |
|
| #include "XSUB.h" |
| 4 |
|
| |
| 5 |
|
| MODULE = Devel::FindBlessedRefs PACKAGE = Devel::FindBlessedRefs |
| 6 |
|
| |
| 7 |
|
| PROTOTYPES: DISABLE |
| 8 |
|
| |
| 9 |
|
| void |
| 10 |
|
| find_refs(package) |
| 11 |
|
| char *package |
| 12 |
|
| |
| 13 |
|
| PREINIT: |
| 14 |
|
| SV* sva; |
| 15 |
|
| SV* svend; |
| 16 |
|
| SV* sv; |
| 17 |
|
| |
| 18 |
|
| PPCODE: |
| 19 |
|
| // this stuff is mostly from perl-5.8.8/sv.c, but cleaned up to look like ordinary XS |
| 20 |
1140 |
▶ | for (sva = PL_sv_arenaroot; sva; sva = (SV*)SvANY(sva)) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (sva = PL_sv_arenaroot; sva; sva = (SV*)SvANY(sva)) { |
1137 |
3 |
1140 |
|
| 21 |
1137 |
| svend = &sva[SvREFCNT(sva)]; |
| 22 |
|
| |
| 23 |
193290 |
▶ | for (sv = sva + 1; sv < svend; ++sv) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (sv = sva + 1; sv < svend; ++sv) { |
192153 |
1137 |
193290 |
|
| 24 |
192153 |
▶ | if ( SvROK(sv) ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( SvROK(sv) ) { |
8102 |
184051 |
192153 |
|
| 25 |
|
| |
| 26 |
|
| // this part isn't from sv.c |
| 27 |
|
| // int sv_isa(SV* sv, const char* name) |
| 28 |
8102 |
▶ | if( sv_isa(sv, package) ) |
Branch: 1 branch
| Branch | True | False | Total |
| if( sv_isa(sv, package) ) |
4 |
8098 |
8102 |
|
| 29 |
4 |
▶ | XPUSHs(sv); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv); |
0 |
4 |
4 |
|
| 30 |
|
| } |
| 31 |
|
| } |
| 32 |
|
| } |
| 33 |
|
| |
| 34 |
|
| void |
| 35 |
|
| find_refs_with_coderef(code_ref) |
| 36 |
|
| SV* code_ref; |
| 37 |
|
| |
| 38 |
|
| PREINIT: |
| 39 |
|
| SV* sva; |
| 40 |
|
| SV* svend; |
| 41 |
|
| SV* sv; |
| 42 |
|
| svtype t; |
| 43 |
|
| U32 c; |
| 44 |
|
| |
| 45 |
|
| CODE: |
| 46 |
379 |
▶ | for (sva = PL_sv_arenaroot; sva; sva = (SV*)SvANY(sva)) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (sva = PL_sv_arenaroot; sva; sva = (SV*)SvANY(sva)) { |
378 |
1 |
379 |
|
| 47 |
378 |
| svend = &sva[SvREFCNT(sva)]; |
| 48 |
|
| |
| 49 |
64260 |
▶ | for (sv = sva + 1; sv < svend; ++sv) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (sv = sva + 1; sv < svend; ++sv) { |
63882 |
378 |
64260 |
|
| 50 |
63882 |
▶ | if( SvROK(sv) ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if( SvROK(sv) ) { |
2704 |
61178 |
63882 |
|
| 51 |
2704 |
| dSP; // make a new local stack |
| 52 |
|
| |
| 53 |
2704 |
▶ | PUSHMARK(SP); // start pushing |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP); // start pushing |
0 |
2704 |
2704 |
|
| 54 |
2704 |
▶ | XPUSHs(sv); // push the sv as a mortal |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv); // push the sv as a mortal |
0 |
2704 |
2704 |
|
| 55 |
2704 |
| PUTBACK; // end the stack |
| 56 |
|
| |
| 57 |
2704 |
| call_sv(code_ref, G_DISCARD); |
| 58 |
|
| } |
| 59 |
|
| } |
| 60 |
|
| } |