xsubs/member.xs

filter: Statementstmt 100% 47 / 47 Branchbran 90.6% 58 / 64 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 94.5% 105 / 111 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« xsubs/pack.xs ↑ Summary xsubs/macro.xs »
1 ################################################################################
2 #
3 # Copyright (c) 2002-2020 Marcus Holland-Moritz. All rights reserved.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the same terms as Perl itself.
6 #
7 ################################################################################
8  
9  
10 ################################################################################
11 #
12 # METHOD: member
13 #
14 # WRITTEN BY: Marcus Holland-Moritz ON: Jan 2002
15 # CHANGED BY: ON:
16 #
17 ################################################################################
18  
19 void
20 CBC::member(type, offset = NULL)
21 const char *type
22 SV *offset
23  
24 PREINIT:
25 48702 ▶ CBC_METHOD(member);
Branch: 1 branch
BranchTrueFalseTotal
CBC_METHOD(member); 176 48526 48702
26 MemberInfo mi;
27 int have_offset, off;
28  
29 PPCODE:
30 48702 ▶ off = (have_offset = DEFINED(offset)) ? SvIV(offset) : 0;
Branch: 3 branches
BranchTrueFalseTotal
off = (have_offset = DEFINED(offset)) ? SvIV(offset) : 0; 48526 176 48702
off = (have_offset = DEFINED(offset)) ? SvIV(offset) : 0; 48526 0 48526
off = (have_offset = DEFINED(offset)) ? SvIV(offset) : 0; 48526 176 48702
31  
32 CT_DEBUG_METHOD2("'%s', %d", type, off);
33  
34 48702 ▶ CHECK_PARSE_DATA;
Branch: 1 branch
BranchTrueFalseTotal
CHECK_PARSE_DATA; 12 48690 48702
35 48690 ▶ CHECK_VOID_CONTEXT;
Branch: 2 branches
BranchTrueFalseTotal
CHECK_VOID_CONTEXT; 12 48678 48690
CHECK_VOID_CONTEXT; 8 4 12
36  
37 48678 ▶ NEED_PARSE_DATA;
Branch: 2 branches
BranchTrueFalseTotal
NEED_PARSE_DATA; 48678 0 48678
NEED_PARSE_DATA; 1 48677 48678
38  
39 48678 ▶ if (!get_member_info(aTHX_ THIS, type, &mi, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (!get_member_info(aTHX_ THIS, type, &mi, 0)) 24 48606 48630
40 24 Perl_croak(aTHX_ "Cannot find '%s'", type);
41  
42 48606 check_allowed_types(aTHX_ &mi, method, ALLOW_STRUCTS
43 | ALLOW_UNIONS
44 | ALLOW_ARRAYS);
45  
46 48522 ▶ if (mi.flags)
Branch: 1 branch
BranchTrueFalseTotal
if (mi.flags) 24 48498 48522
47 {
48 24 u_32 flags = mi.flags;
49  
50 /* bitfields are not a problem without offset given */
51 24 ▶ if (!have_offset)
Branch: 1 branch
BranchTrueFalseTotal
if (!have_offset) 12 12 24
52 12 flags &= ~T_HASBITFIELD;
53  
54 24 ▶ WARN_FLAGS(type, flags);
Branch: 2 branches
BranchTrueFalseTotal
WARN_FLAGS(type, flags); 12 12 24
WARN_FLAGS(type, flags); 8 4 12
55 }
56  
57 48522 ▶ if (have_offset)
Branch: 1 branch
BranchTrueFalseTotal
if (have_offset) 48430 92 48522
58 {
59 48430 ▶ if (off < 0 || off >= (int) mi.size)
Branch: 2 branches
BranchTrueFalseTotal
if (off < 0 || off >= (int) mi.size) 48424 6 48430
if (off < 0 || off >= (int) mi.size) 47 48377 48424
60 53 Perl_croak(aTHX_ "Offset %d out of range (0 <= offset < %d)", off, mi.size);
61  
62 48377 ▶ if (GIMME_V == G_ARRAY)
Branch: 1 branch
BranchTrueFalseTotal
if (GIMME_V == G_ARRAY) 23154 25223 48377
63 {
64 ListIterator li;
65 GMSInfo info;
66 SV *member;
67 int count;
68  
69 23154 info.hit = LL_new();
70 23154 info.off = LL_new();
71 23154 info.pad = LL_new();
72  
73 23154 (void) get_member_string(aTHX_ &mi, off, &info);
74  
75 23154 count = LL_count(info.hit)
76 23154 + LL_count(info.off)
77 23154 + LL_count(info.pad);
78  
79 23154 ▶ EXTEND(SP, count);
Branch: 2 branches
BranchTrueFalseTotal
EXTEND(SP, count); 23154 0 23154
EXTEND(SP, count); 0 23154 23154
80  
81 40233 ▶ LL_foreach(member, li, info.hit)
Branch: 2 branches
BranchTrueFalseTotal
LL_foreach(member, li, info.hit) 17079 23154 40233
LL_foreach(member, li, info.hit) 17079 23154 40233
82 17079 PUSHs(member);
83  
84 70596 ▶ LL_foreach(member, li, info.off)
Branch: 2 branches
BranchTrueFalseTotal
LL_foreach(member, li, info.off) 47442 23154 70596
LL_foreach(member, li, info.off) 47442 23154 70596
85 47442 PUSHs(member);
86  
87 27440 ▶ LL_foreach(member, li, info.pad)
Branch: 2 branches
BranchTrueFalseTotal
LL_foreach(member, li, info.pad) 4286 23154 27440
LL_foreach(member, li, info.pad) 4286 23154 27440
88 4286 PUSHs(member);
89  
90 23154 LL_destroy(info.hit, NULL);
91 23154 LL_destroy(info.off, NULL);
92 23154 LL_destroy(info.pad, NULL);
93  
94 23154 XSRETURN(count);
95 }
96 else
97 {
98 25223 SV *member = get_member_string(aTHX_ &mi, off, NULL);
99 25223 PUSHs(member);
100 25223 XSRETURN(1);
101 }
102 }
103 else
104 {
105 LinkedList list;
106 SV *member;
107 int count;
108  
109 92 ▶ list = GIMME_V == G_ARRAY ? LL_new() : NULL;
Branch: 1 branch
BranchTrueFalseTotal
list = GIMME_V == G_ARRAY ? LL_new() : NULL; 61 31 92
110 92 count = get_all_member_strings(aTHX_ &mi, list);
111  
112 92 ▶ if (GIMME_V == G_ARRAY)
Branch: 1 branch
BranchTrueFalseTotal
if (GIMME_V == G_ARRAY) 61 31 92
113 {
114 ListIterator li;
115  
116 61 ▶ EXTEND(SP, count);
Branch: 2 branches
BranchTrueFalseTotal
EXTEND(SP, count); 61 0 61
EXTEND(SP, count); 0 61 61
117  
118 17401 ▶ LL_foreach(member, li, list)
Branch: 2 branches
BranchTrueFalseTotal
LL_foreach(member, li, list) 17340 61 17401
LL_foreach(member, li, list) 17340 61 17401
119 17340 PUSHs(member);
120  
121 61 LL_destroy(list, NULL);
122  
123 61 XSRETURN(count);
124 }
125 else
126 31 XSRETURN_IV(count);
127 }
128  
« xsubs/pack.xs ↑ Summary xsubs/macro.xs »