MagicExt.xs

filter: Statementstmt 0.0% 0 / 36 Branchbran 0.0% 0 / 32 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 68 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« t/test/inc/Module/Install/Base.pm ↑ Summary blib/lib/XS/MagicExt.pm »
1 #define PERL_NO_GET_CONTEXT
2 #include <EXTERN.h>
3 #include <perl.h>
4 #include <XSUB.h>
5  
6 #include "ppport.h"
7  
8 #include "magic_ext.h"
9  
10 MAGIC*
11 0 magic_ext_mgx_attach(pTHX_ SV* const sv, MGVTBL* const vtbl, SV* const obj, void* const ptr, I32 const len){
12 MAGIC* mg;
13  
14 assert(sv != NULL);
15 assert(vtbl != NULL);
16  
17 0 mg = sv_magicext(sv, obj, PERL_MAGIC_ext, vtbl, ptr, len);
18  
19 0 ▶ if(obj){
Branch: 1 branch
BranchTrueFalseTotal
if(obj){ 0 0 0
20 0 SvREFCNT_dec(obj);
21 }
22  
23 0 ▶ if(ptr && len == HEf_SVKEY){
Branch: 2 branches
BranchTrueFalseTotal
if(ptr && len == HEf_SVKEY){ 0 0 0
if(ptr && len == HEf_SVKEY){ 0 0 0
24 0 SvREFCNT_dec((SV*)ptr);
25 }
26  
27 0 return mg;
28 }
29  
30 MAGIC*
31 0 magic_ext_mgx_find(pTHX_ SV* const sv, const MGVTBL* const vtbl, I32 const flags){
32 MAGIC* mg;
33  
34 assert(sv != NULL);
35 assert(vtbl != NULL);
36  
37 0 ▶ for(mg = SvMAGIC(sv); mg; mg = mg->mg_moremagic){
Branch: 1 branch
BranchTrueFalseTotal
for(mg = SvMAGIC(sv); mg; mg = mg->mg_moremagic){ 0 0 0
38 0 ▶ if(mg->mg_virtual == vtbl){
Branch: 1 branch
BranchTrueFalseTotal
if(mg->mg_virtual == vtbl){ 0 0 0
39 assert(mg->mg_type == PERL_MAGIC_ext);
40 0 return mg;
41 }
42 }
43  
44 0 ▶ if(flags & MGXf_CROAK_IF_NOT_FOUND){
Branch: 1 branch
BranchTrueFalseTotal
if(flags & MGXf_CROAK_IF_NOT_FOUND){ 0 0 0
45 0 croak("MAGIC(0x%p) not found", vtbl);
46 }
47 0 return NULL;
48 }
49  
50 void
51 0 magic_ext_mgx_detach(pTHX_ SV* const sv, const MGVTBL* const vtbl){
52 MAGIC* mg;
53 MAGIC** mgp;
54  
55 assert(sv != NULL);
56 assert(vtbl != NULL);
57  
58 0 ▶ if (!SvMAGICAL(sv)){
Branch: 1 branch
BranchTrueFalseTotal
if (!SvMAGICAL(sv)){ 0 0 0
59 0 return;
60 }
61  
62 0 mgp = &SvMAGIC(sv);
63 0 ▶ for (mg = *mgp; mg; mg = *mgp) {
Branch: 1 branch
BranchTrueFalseTotal
for (mg = *mgp; mg; mg = *mgp) { 0 0 0
64 0 ▶ if (mg->mg_virtual == vtbl) {
Branch: 1 branch
BranchTrueFalseTotal
if (mg->mg_virtual == vtbl) { 0 0 0
65 0 const MGVTBL* const vtbl = mg->mg_virtual;
66 assert(mg->mg_type == PERL_MAGIC_ext);
67  
68 0 ▶ if (vtbl && vtbl->svt_free){
Branch: 2 branches
BranchTrueFalseTotal
if (vtbl && vtbl->svt_free){ 0 0 0
if (vtbl && vtbl->svt_free){ 0 0 0
69 0 CALL_FPTR(vtbl->svt_free)(aTHX_ sv, mg);
70 }
71  
72 0 ▶ if (mg->mg_ptr) {
Branch: 1 branch
BranchTrueFalseTotal
if (mg->mg_ptr) { 0 0 0
73 0 ▶ if (mg->mg_len > 0){
Branch: 1 branch
BranchTrueFalseTotal
if (mg->mg_len > 0){ 0 0 0
74 0 Safefree(mg->mg_ptr);
75 }
76 0 ▶ else if (mg->mg_len == HEf_SVKEY){
Branch: 1 branch
BranchTrueFalseTotal
else if (mg->mg_len == HEf_SVKEY){ 0 0 0
77 0 SvREFCNT_dec((SV*)mg->mg_ptr);
78 }
79 }
80 0 ▶ if (mg->mg_flags & MGf_REFCOUNTED)
Branch: 1 branch
BranchTrueFalseTotal
if (mg->mg_flags & MGf_REFCOUNTED) 0 0 0
81 0 SvREFCNT_dec(mg->mg_obj);
82  
83 0 *mgp = mg->mg_moremagic;
84 0 Safefree(mg);
85 }
86 else{
87 0 mgp = &mg->mg_moremagic;
88 }
89 }
90 0 ▶ if (!SvMAGIC(sv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (!SvMAGIC(sv)) { 0 0 0
91 0 SvMAGICAL_off(sv);
92 0 SvFLAGS(sv) |= (SvFLAGS(sv) & (SVp_IOK|SVp_NOK|SVp_POK)) >> PRIVSHIFT;
93 }
94 }
95  
96 MODULE = XS::MagicExt PACKAGE = XS::MagicExt
97  
98 PROTOTYPES: DISABLE
« t/test/inc/Module/Install/Base.pm ↑ Summary blib/lib/XS/MagicExt.pm »