| 1 |
|
| #include "EXTERN.h" |
| 2 |
|
| #include "perl.h" |
| 3 |
|
| #include "XSUB.h" |
| 4 |
|
| |
| 5 |
|
| #include "ppport.h" |
| 6 |
|
| |
| 7 |
|
| static const char* const svclassnames[] = { |
| 8 |
|
| "undef", |
| 9 |
|
| #if PERL_VERSION >= 9 |
| 10 |
|
| "B::BIND", |
| 11 |
|
| #endif |
| 12 |
|
| "integer", |
| 13 |
|
| "double", |
| 14 |
|
| "REF", |
| 15 |
|
| "string", |
| 16 |
|
| "string/integer", |
| 17 |
|
| "string/double", |
| 18 |
|
| "scalar + misc magic", |
| 19 |
|
| #if PERL_VERSION <= 8 |
| 20 |
|
| "SCALAR: BM", |
| 21 |
|
| #endif |
| 22 |
|
| #if PERL_VERSION >= 9 |
| 23 |
|
| "GLOB", |
| 24 |
|
| #endif |
| 25 |
|
| "LVALUE", |
| 26 |
|
| "ARRAY", |
| 27 |
|
| "HASH", |
| 28 |
|
| "CODE", |
| 29 |
|
| #if PERL_VERSION <= 8 |
| 30 |
|
| "GLOB", |
| 31 |
|
| #endif |
| 32 |
|
| "FORMAT", |
| 33 |
|
| "IO::Handle", |
| 34 |
|
| }; |
| 35 |
|
| |
| 36 |
|
| MODULE = Internals::CountObjects PACKAGE = Internals::CountObjects |
| 37 |
|
| |
| 38 |
|
| HV* |
| 39 |
|
| objects() |
| 40 |
|
| PREINIT: |
| 41 |
|
| SV *sva, *sv, *svend; |
| 42 |
|
| char *reftype; |
| 43 |
|
| CODE: |
| 44 |
3 |
| RETVAL = newHV(); |
| 45 |
1624 |
▶ | 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)) { |
1621 |
3 |
1624 |
|
| 46 |
1621 |
| svend = &sva[SvREFCNT(sva)]; |
| 47 |
275570 |
▶ | for (sv = sva + 1; sv < svend; ++sv) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (sv = sva + 1; sv < svend; ++sv) { |
273949 |
1621 |
275570 |
|
| 48 |
273949 |
▶ | if (SvTYPE(sv) == SVTYPEMASK) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvTYPE(sv) == SVTYPEMASK) { |
361 |
273588 |
273949 |
|
| 49 |
361 |
| reftype = "undef"; |
| 50 |
|
| } |
| 51 |
|
| else { |
| 52 |
273588 |
| reftype = sv_reftype(sv, 1); |
| 53 |
273588 |
▶ | if (strEQ(reftype, "SCALAR")) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (strEQ(reftype, "SCALAR")) { |
197741 |
75847 |
273588 |
|
| 54 |
197741 |
| reftype = svclassnames[SvTYPE(sv)]; |
| 55 |
|
| } |
| 56 |
|
| } |
| 57 |
273949 |
| sv_inc(*hv_fetch(RETVAL, reftype, strlen(reftype), 1)); |
| 58 |
|
| } |
| 59 |
|
| } |
| 60 |
|
| OUTPUT: |
| 61 |
|
| RETVAL |