xsubs/offsetof.xs

filter: Statementstmt 100% 17 / 17 Branchbran 96.4% 27 / 28 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 97.7% 44 / 45 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« xsubs/parse.xs ↑ Summary xsubs/include.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: offsetof
13 #
14 # WRITTEN BY: Marcus Holland-Moritz ON: Mar 2002
15 # CHANGED BY: ON:
16 #
17 ################################################################################
18  
19 SV *
20 CBC::offsetof(type, member)
21 const char *type
22 const char *member
23  
24 PREINIT:
25 80439 CBC_METHOD(offsetof);
26 MemberInfo mi, mi2;
27 80439 const char *m = member;
28  
29 CODE:
30 CT_DEBUG_METHOD2("'%s', '%s'", type, member);
31  
32 80439 ▶ CHECK_PARSE_DATA;
Branch: 1 branch
BranchTrueFalseTotal
CHECK_PARSE_DATA; 6 80433 80439
33 80433 ▶ CHECK_VOID_CONTEXT;
Branch: 2 branches
BranchTrueFalseTotal
CHECK_VOID_CONTEXT; 6 80427 80433
CHECK_VOID_CONTEXT; 4 2 6
34  
35 80439 ▶ while (isSPACE(*m))
Branch: 1 branch
BranchTrueFalseTotal
while (isSPACE(*m)) 12 80427 80439
36 12 m++;
37  
38 80427 ▶ if (*m == '\0')
Branch: 1 branch
BranchTrueFalseTotal
if (*m == '\0') 14 80413 80427
39 14 ▶ WARN((aTHX_ "Empty string passed as member expression"));
Branch: 1 branch
BranchTrueFalseTotal
WARN((aTHX_ "Empty string passed as member expression")); 10 4 14
40  
41 80427 ▶ NEED_PARSE_DATA;
Branch: 2 branches
BranchTrueFalseTotal
NEED_PARSE_DATA; 80427 0 80427
NEED_PARSE_DATA; 8 80419 80427
42  
43 80427 ▶ if (!get_member_info(aTHX_ THIS, type, &mi, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (!get_member_info(aTHX_ THIS, type, &mi, 0)) 12 80391 80403
44 12 Perl_croak(aTHX_ "Cannot find '%s'", type);
45  
46 80391 (void) get_member(aTHX_ &mi, member, &mi2, CBC_GM_ACCEPT_DOTLESS_MEMBER);
47  
48 80169 ▶ if (mi2.pDecl && mi2.pDecl->bitfield_flag)
Branch: 2 branches
BranchTrueFalseTotal
if (mi2.pDecl && mi2.pDecl->bitfield_flag) 80162 7 80169
if (mi2.pDecl && mi2.pDecl->bitfield_flag) 6 80156 80162
49 6 Perl_croak(aTHX_ "Cannot use %s on bitfields", method);
50  
51 80163 ▶ if (mi.flags)
Branch: 1 branch
BranchTrueFalseTotal
if (mi.flags) 18 80145 80163
52 18 ▶ WARN_FLAGS(type, mi.flags);
Branch: 2 branches
BranchTrueFalseTotal
WARN_FLAGS(type, mi.flags); 6 12 18
WARN_FLAGS(type, mi.flags); 4 2 6
53  
54 80163 RETVAL = newSViv(mi2.offset);
55  
56 OUTPUT:
57 RETVAL
58  
« xsubs/parse.xs ↑ Summary xsubs/include.xs »