tagEntry_to_HV.c

filter: Statementstmt 77.1% 27 / 35 Branchbran 53.1% 17 / 32 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 65.6% 44 / 67 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« readtags.c ↑ Summary ExuberantCTags.xs »
1 #ifdef __cplusplus
2 extern "C" {
3 #endif
4 #include "EXTERN.h"
5 #include "perl.h"
6 #include "XSUB.h"
7 #include "ppport.h"
8 #include "readtags.h"
9 #include "tagEntry_to_HV.h"
10 #ifdef __cplusplus
11 }
12 #endif
13  
14  
15 /* Will convert a C tagEntry* to a Perl HV* */
16 HV*
17 12 tagEntry_to_HV(tagEntry* theEntry)
18 {
19 12 HV* hv = newHV();
20 HV* extHash;
21 SV* sv;
22 unsigned int i;
23  
24 /* put tag 'name' into hash */
25 12 ▶ if (theEntry->name != NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if (theEntry->name != NULL) { 12 0 12
26 12 sv = newSVpv( theEntry->name, 0 );
27 12 ▶ if ( hv_stores( hv, "name", sv ) == NULL )
Branch: 1 branch
BranchTrueFalseTotal
if ( hv_stores( hv, "name", sv ) == NULL ) 0 12 12
28 0 warn("tagEntry_to_HV: failed to store name elem");
29 }
30  
31 /* put tag 'file' into hash */
32 12 ▶ if (theEntry->file != NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if (theEntry->file != NULL) { 12 0 12
33 12 sv = newSVpv( theEntry->file, 0 );
34 12 ▶ if ( hv_stores( hv, "file", sv ) == NULL )
Branch: 1 branch
BranchTrueFalseTotal
if ( hv_stores( hv, "file", sv ) == NULL ) 0 12 12
35 0 warn("tagEntry_to_HV: failed to store file elem");
36 }
37  
38 /* put tag 'addressPattern' into hash */
39 12 ▶ if (theEntry->address.pattern != NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if (theEntry->address.pattern != NULL) { 12 0 12
40 12 sv = newSVpv( theEntry->address.pattern, 0 );
41 12 ▶ if ( hv_stores( hv, "addressPattern", sv ) == NULL )
Branch: 1 branch
BranchTrueFalseTotal
if ( hv_stores( hv, "addressPattern", sv ) == NULL ) 0 12 12
42 0 warn("tagEntry_to_HV: failed to store address/pattern elem");
43 }
44  
45 /* put tag 'addressLineNumber' into hash */
46 12 ▶ if (theEntry->address.lineNumber != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (theEntry->address.lineNumber != 0) { 12 0 12
47 12 sv = newSViv( theEntry->address.lineNumber );
48 12 ▶ if ( hv_stores( hv, "addressLineNumber", sv ) == NULL )
Branch: 1 branch
BranchTrueFalseTotal
if ( hv_stores( hv, "addressLineNumber", sv ) == NULL ) 0 12 12
49 0 warn("tagEntry_to_HV: failed to store lineNumber elem");
50 }
51  
52 /* put tag 'kind' into hash */
53 12 ▶ if (theEntry->kind != NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if (theEntry->kind != NULL) { 12 0 12
54 12 sv = newSVpv( theEntry->kind, 0 );
55 12 ▶ if ( hv_stores( hv, "kind", sv ) == NULL )
Branch: 1 branch
BranchTrueFalseTotal
if ( hv_stores( hv, "kind", sv ) == NULL ) 0 12 12
56 0 warn("tagEntry_to_HV: failed to store kind elem");
57 }
58  
59 /* put tag 'fileScope' into hash */
60 12 sv = newSViv( theEntry->fileScope );
61 12 ▶ if ( hv_stores( hv, "fileScope", sv ) == NULL )
Branch: 1 branch
BranchTrueFalseTotal
if ( hv_stores( hv, "fileScope", sv ) == NULL ) 0 12 12
62 0 warn("tagEntry_to_HV: failed to store filescope elem");
63  
64 /* create 'extension' sub-hash */
65 12 extHash = (HV*)sv_2mortal((SV*)newHV());
66 12 ▶ if ( hv_stores( hv, "extension", newRV((SV*)extHash) ) == NULL )
Branch: 1 branch
BranchTrueFalseTotal
if ( hv_stores( hv, "extension", newRV((SV*)extHash) ) == NULL ) 0 12 12
67 0 warn("tagEntry_to_HV: failed to store extension elem");
68  
69 24 ▶ for (i = 0; i < theEntry->fields.count; ++i) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < theEntry->fields.count; ++i) { 12 12 24
70 12 ▶ if (theEntry->fields.list[i].key != NULL
Branch: 1 branch
BranchTrueFalseTotal
if (theEntry->fields.list[i].key != NULL 12 0 12
71 12 ▶ && theEntry->fields.list[i].value != NULL)
Branch: 1 branch
BranchTrueFalseTotal
&& theEntry->fields.list[i].value != NULL) 12 0 12
72 {
73 12 sv = newSVpv( theEntry->fields.list[i].value, 0 );
74 12 ▶ if ( hv_store( extHash, theEntry->fields.list[i].key, strlen(theEntry->fields.list[i].key), sv, 0 ) == NULL )
Branch: 1 branch
BranchTrueFalseTotal
if ( hv_store( extHash, theEntry->fields.list[i].key, strlen(theEntry->fields.list[i].key), sv, 0 ) == NULL ) 0 12 12
75 0 warn("tagEntry_to_HV: failed to store kind elem");
76 }
77 }
78
79  
80 12 return hv;
81 }
82  
« readtags.c ↑ Summary ExuberantCTags.xs »