| 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: enum_names |
| 13 |
|
| # |
| 14 |
|
| # WRITTEN BY: Marcus Holland-Moritz ON: Jan 2002 |
| 15 |
|
| # CHANGED BY: ON: |
| 16 |
|
| # |
| 17 |
|
| ################################################################################ |
| 18 |
|
| |
| 19 |
|
| void |
| 20 |
|
| CBC::enum_names() |
| 21 |
|
| PREINIT: |
| 22 |
58 |
| CBC_METHOD(enum_names); |
| 23 |
|
| ListIterator li; |
| 24 |
|
| EnumSpecifier *pEnumSpec; |
| 25 |
58 |
| int count = 0; |
| 26 |
|
| U32 context; |
| 27 |
|
| |
| 28 |
|
| PPCODE: |
| 29 |
|
| CT_DEBUG_METHOD; |
| 30 |
|
| |
| 31 |
58 |
▶ | CHECK_PARSE_DATA; |
Branch: 1 branch
| Branch | True | False | Total |
| CHECK_PARSE_DATA; |
6 |
52 |
58 |
|
| 32 |
52 |
▶ | CHECK_VOID_CONTEXT; |
Branch: 2 branches
| Branch | True | False | Total |
| CHECK_VOID_CONTEXT; |
6 |
46 |
52 |
| CHECK_VOID_CONTEXT; |
4 |
2 |
6 |
|
| 33 |
|
| |
| 34 |
46 |
| context = GIMME_V; |
| 35 |
|
| |
| 36 |
292 |
▶ | LL_foreach(pEnumSpec, li, THIS->cpi.enums) |
Branch: 2 branches
| Branch | True | False | Total |
| LL_foreach(pEnumSpec, li, THIS->cpi.enums) |
246 |
46 |
292 |
| LL_foreach(pEnumSpec, li, THIS->cpi.enums) |
246 |
46 |
292 |
|
| 37 |
246 |
▶ | if (pEnumSpec->identifier[0] && pEnumSpec->enumerators) |
Branch: 2 branches
| Branch | True | False | Total |
| if (pEnumSpec->identifier[0] && pEnumSpec->enumerators) |
48 |
198 |
246 |
| if (pEnumSpec->identifier[0] && pEnumSpec->enumerators) |
34 |
14 |
48 |
|
| 38 |
|
| { |
| 39 |
34 |
▶ | if (context == G_ARRAY) |
Branch: 1 branch
| Branch | True | False | Total |
| if (context == G_ARRAY) |
27 |
7 |
34 |
|
| 40 |
27 |
▶ | XPUSHs(sv_2mortal(newSVpv(pEnumSpec->identifier, 0))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpv(pEnumSpec->identifier, 0))); |
0 |
27 |
27 |
|
| 41 |
34 |
| count++; |
| 42 |
|
| } |
| 43 |
|
| |
| 44 |
46 |
▶ | if (context == G_ARRAY) |
Branch: 1 branch
| Branch | True | False | Total |
| if (context == G_ARRAY) |
39 |
7 |
46 |
|
| 45 |
39 |
| XSRETURN(count); |
| 46 |
|
| else |
| 47 |
7 |
| XSRETURN_IV(count); |
| 48 |
|
| |
| 49 |
|
| |
| 50 |
|
| ################################################################################ |
| 51 |
|
| # |
| 52 |
|
| # METHOD: enum |
| 53 |
|
| # |
| 54 |
|
| # WRITTEN BY: Marcus Holland-Moritz ON: Jan 2002 |
| 55 |
|
| # CHANGED BY: ON: |
| 56 |
|
| # |
| 57 |
|
| ################################################################################ |
| 58 |
|
| |
| 59 |
|
| void |
| 60 |
|
| CBC::enum(...) |
| 61 |
|
| PREINIT: |
| 62 |
88 |
| CBC_METHOD(enum); |
| 63 |
|
| EnumSpecifier *pEnumSpec; |
| 64 |
|
| U32 context; |
| 65 |
|
| |
| 66 |
|
| PPCODE: |
| 67 |
|
| CT_DEBUG_METHOD; |
| 68 |
|
| |
| 69 |
88 |
▶ | CHECK_PARSE_DATA; |
Branch: 1 branch
| Branch | True | False | Total |
| CHECK_PARSE_DATA; |
6 |
82 |
88 |
|
| 70 |
82 |
▶ | CHECK_VOID_CONTEXT; |
Branch: 2 branches
| Branch | True | False | Total |
| CHECK_VOID_CONTEXT; |
6 |
76 |
82 |
| CHECK_VOID_CONTEXT; |
4 |
2 |
6 |
|
| 71 |
|
| |
| 72 |
76 |
| context = GIMME_V; |
| 73 |
|
| |
| 74 |
76 |
▶ | if (context == G_SCALAR && items != 2) |
Branch: 2 branches
| Branch | True | False | Total |
| if (context == G_SCALAR && items != 2) |
28 |
48 |
76 |
| if (context == G_SCALAR && items != 2) |
7 |
21 |
28 |
|
| 75 |
7 |
▶ | XSRETURN_IV(items > 1 ? items-1 : LL_count(THIS->cpi.enums)); |
Branch: 1 branch
| Branch | True | False | Total |
| XSRETURN_IV(items > 1 ? items-1 : LL_count(THIS->cpi.enums)); |
0 |
7 |
7 |
|
| 76 |
|
| |
| 77 |
69 |
▶ | if (items > 1) |
Branch: 1 branch
| Branch | True | False | Total |
| if (items > 1) |
36 |
33 |
69 |
|
| 78 |
|
| { |
| 79 |
|
| int i; |
| 80 |
|
| |
| 81 |
80 |
▶ | for (i = 1; i < items; i++) |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 1; i < items; i++) |
44 |
36 |
80 |
|
| 82 |
|
| { |
| 83 |
44 |
| const char *name = SvPV_nolen(ST(i)); |
| 84 |
|
| |
| 85 |
|
| /* skip optional enum */ |
| 86 |
44 |
▶ | if (name[0] == 'e' && |
Branch: 1 branch
| Branch | True | False | Total |
| if (name[0] == 'e' && |
20 |
24 |
44 |
|
| 87 |
20 |
▶ | name[1] == 'n' && |
Branch: 1 branch
| Branch | True | False | Total |
| name[1] == 'n' && |
20 |
0 |
20 |
|
| 88 |
20 |
▶ | name[2] == 'u' && |
Branch: 1 branch
| Branch | True | False | Total |
| name[2] == 'u' && |
20 |
0 |
20 |
|
| 89 |
20 |
▶ | name[3] == 'm' && |
Branch: 1 branch
| Branch | True | False | Total |
| name[3] == 'm' && |
13 |
7 |
20 |
|
| 90 |
13 |
▶ | isSPACE(name[4])) |
Branch: 1 branch
| Branch | True | False | Total |
| isSPACE(name[4])) |
13 |
0 |
13 |
|
| 91 |
13 |
| name += 5; |
| 92 |
|
| |
| 93 |
49 |
▶ | while (isSPACE(*name)) |
Branch: 1 branch
| Branch | True | False | Total |
| while (isSPACE(*name)) |
5 |
44 |
49 |
|
| 94 |
5 |
| name++; |
| 95 |
|
| |
| 96 |
44 |
| pEnumSpec = HT_get(THIS->cpi.htEnums, name, 0, 0); |
| 97 |
|
| |
| 98 |
44 |
▶ | if (pEnumSpec) |
Branch: 1 branch
| Branch | True | False | Total |
| if (pEnumSpec) |
24 |
20 |
44 |
|
| 99 |
24 |
| PUSHs(sv_2mortal(get_enum_spec_def(aTHX_ &THIS->cfg, pEnumSpec))); |
| 100 |
|
| else |
| 101 |
20 |
| PUSHs(&PL_sv_undef); |
| 102 |
|
| } |
| 103 |
|
| |
| 104 |
36 |
| XSRETURN(items-1); |
| 105 |
|
| } |
| 106 |
|
| else |
| 107 |
|
| { |
| 108 |
|
| ListIterator li; |
| 109 |
33 |
| int size = LL_count(THIS->cpi.enums); |
| 110 |
|
| |
| 111 |
33 |
▶ | if (size <= 0) |
Branch: 1 branch
| Branch | True | False | Total |
| if (size <= 0) |
12 |
21 |
33 |
|
| 112 |
12 |
| XSRETURN_EMPTY; |
| 113 |
|
| |
| 114 |
21 |
▶ | EXTEND(SP, size); |
Branch: 2 branches
| Branch | True | False | Total |
| EXTEND(SP, size); |
21 |
0 |
21 |
| EXTEND(SP, size); |
0 |
21 |
21 |
|
| 115 |
|
| |
| 116 |
86 |
▶ | LL_foreach(pEnumSpec, li, THIS->cpi.enums) |
Branch: 2 branches
| Branch | True | False | Total |
| LL_foreach(pEnumSpec, li, THIS->cpi.enums) |
65 |
21 |
86 |
| LL_foreach(pEnumSpec, li, THIS->cpi.enums) |
65 |
21 |
86 |
|
| 117 |
65 |
| PUSHs(sv_2mortal(get_enum_spec_def(aTHX_ &THIS->cfg, pEnumSpec))); |
| 118 |
|
| |
| 119 |
21 |
| XSRETURN(size); |
| 120 |
|
| } |
| 121 |
|
| |