File Coverage

const-c-object.inc
Criterion Covered Total %
statement 24 33 72.7
branch 9 18 50.0
condition n/a
subroutine n/a
pod n/a
total 33 51 64.7


line stmt bran cond sub pod time code
1             #define PERL_constant_NOTFOUND 1
2             #define PERL_constant_NOTDEF 2
3             #define PERL_constant_ISIV 3
4             #define PERL_constant_ISNO 4
5             #define PERL_constant_ISNV 5
6             #define PERL_constant_ISPV 6
7             #define PERL_constant_ISPVN 7
8             #define PERL_constant_ISSV 8
9             #define PERL_constant_ISUNDEF 9
10             #define PERL_constant_ISUV 10
11             #define PERL_constant_ISYES 11
12              
13             #ifndef NVTYPE
14             typedef double NV; /* 5.6 and later define NVTYPE, and typedef NV to it. */
15             #endif
16             #ifndef aTHX_
17             #define aTHX_ /* 5.6 or later define this for threading support. */
18             #endif
19             #ifndef pTHX_
20             #define pTHX_ /* 5.6 or later define this for threading support. */
21             #endif
22              
23             static int
24 3           _object_constant_3 (pTHX_ const char *name, IV *iv_return) {
25             /* When generated this function returned values for the list of names given
26             here. However, subsequent manual editing may have added or removed some.
27             ANY BAD TAG */
28             /* Offset 0 gives the best switch position. */
29 3           switch (*name++) {
30             case 'A':
31 1 50         if (name[0] == 'N' && name[1] == 'Y') {
    50          
32             #ifdef ANY
33 1           *iv_return = ANY;
34 1           return PERL_constant_ISIV;
35             #else
36             return PERL_constant_NOTDEF;
37             #endif
38             }
39 0           break;
40             case 'B':
41 1 50         if (name[0] == 'A' && name[1] == 'D') {
    50          
42             #ifdef BAD
43 1           *iv_return = BAD;
44 1           return PERL_constant_ISIV;
45             #else
46             return PERL_constant_NOTDEF;
47             #endif
48             }
49 0           break;
50             case 'T':
51 1 50         if (name[0] == 'A' && name[1] == 'G') {
    50          
52             #ifdef TAG
53 1           *iv_return = TAG;
54 1           return PERL_constant_ISIV;
55             #else
56             return PERL_constant_NOTDEF;
57             #endif
58             }
59 0           break;
60             }
61 0           return PERL_constant_NOTFOUND;
62             }
63              
64             static int
65 10           _object_constant (pTHX_ const char *name, STRLEN len, IV *iv_return) {
66             /* Initially switch on the length of the name. */
67             /* When generated this function returned values for the list of names given
68             in this section of perl code. Rather than manually editing these functions
69             to add or remove constants, which would result in this comment and section
70             of code becoming inaccurate, we recommend that you edit this section of
71             code, and use it to regenerate a new set of constant functions which you
72             then use to replace the originals.
73              
74             Regenerate these constant functions by feeding this entire source file to
75             perl -x
76              
77             #!/usr/local/bin/perl -w
78             use ExtUtils::Constant qw (constant_types C_constant XS_constant);
79              
80             my $types = {map {($_, 1)} qw(IV)};
81             my @names = (qw(ANY BAD BLOB COMMIT TAG TREE));
82              
83             print constant_types(), "\n"; # macro defs
84             foreach (C_constant ("Git::Raw::Object", '_object_constant', 'IV', $types, undef, 3, @names) ) {
85             print $_, "\n"; # C constant subs
86             }
87             print "\n#### XS Section:\n";
88             print XS_constant ("Git::Raw::Object", $types);
89             __END__