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 14typedef 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 23static int 24constant_7 (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 FNV0_32 FNV0_64 FNV1_32 FNV1_64 */ 28 /* Offset 3 gives the best switch position. */ 29 switch (name[3]) { 30 case '0': 31 if (memEQ(name, "FNV0_32", 7)) { 32 /* ^ */ 33#ifdef FNV0_32 34 *iv_return = FNV0_32; 35 return PERL_constant_ISIV; 36#else 37 return PERL_constant_NOTDEF; 38#endif 39 } 40 if (memEQ(name, "FNV0_64", 7)) { 41 /* ^ */ 42#ifdef FNV0_64 43 *iv_return = FNV0_64; 44 return PERL_constant_ISIV; 45#else 46 return PERL_constant_NOTDEF; 47#endif 48 } 49 break; 50 case '1': 51 if (memEQ(name, "FNV1_32", 7)) { 52 /* ^ */ 53#ifdef FNV1_32 54 *iv_return = FNV1_32; 55 return PERL_constant_ISIV; 56#else 57 return PERL_constant_NOTDEF; 58#endif 59 } 60 if (memEQ(name, "FNV1_64", 7)) { 61 /* ^ */ 62#ifdef FNV1_64 63 *iv_return = FNV1_64; 64 return PERL_constant_ISIV; 65#else 66 return PERL_constant_NOTDEF; 67#endif 68 } 69 break; 70 } 71 return PERL_constant_NOTFOUND; 72} 73 74static int 75constant_8 (pTHX_ const char *name, IV *iv_return) { 76 /* When generated this function returned values for the list of names given 77 here. However, subsequent manual editing may have added or removed some. 78 FNV1a_32 FNV1a_64 FNV_NONE */ 79 /* Offset 7 gives the best switch position. */ 80 switch (name[7]) { 81 case '2': 82 if (memEQ(name, "FNV1a_3", 7)) { 83 /* 2 */ 84#ifdef FNV1a_32 85 *iv_return = FNV1a_32; 86 return PERL_constant_ISIV; 87#else 88 return PERL_constant_NOTDEF; 89#endif 90 } 91 break; 92 case '4': 93 if (memEQ(name, "FNV1a_6", 7)) { 94 /* 4 */ 95#ifdef FNV1a_64 96 *iv_return = FNV1a_64; 97 return PERL_constant_ISIV; 98#else 99 return PERL_constant_NOTDEF; 100#endif 101 } 102 break; 103 case 'E': 104 if (memEQ(name, "FNV_NON", 7)) { 105 /* E */ 106#ifdef FNV_NONE 107 *iv_return = FNV_NONE; 108 return PERL_constant_ISIV; 109#else 110 return PERL_constant_NOTDEF; 111#endif 112 } 113 break; 114 } 115 return PERL_constant_NOTFOUND; 116} 117 118static int 119constant_12 (pTHX_ const char *name, IV *iv_return) { 120 /* When generated this function returned values for the list of names given 121 here. However, subsequent manual editing may have added or removed some. 122 FNV0_32_INIT FNV0_64_INIT FNV1_32_INIT FNV1_64_INIT */ 123 /* Offset 3 gives the best switch position. */ 124 switch (name[3]) { 125 case '0': 126 if (memEQ(name, "FNV0_32_INIT", 12)) { 127 /* ^ */ 128#ifdef FNV0_32_INIT 129 *iv_return = FNV0_32_INIT; 130 return PERL_constant_ISIV; 131#else 132 return PERL_constant_NOTDEF; 133#endif 134 } 135 if (memEQ(name, "FNV0_64_INIT", 12)) { 136 /* ^ */ 137#ifdef FNV0_64_INIT 138 *iv_return = FNV0_64_INIT; 139 return PERL_constant_ISIV; 140#else 141 return PERL_constant_NOTDEF; 142#endif 143 } 144 break; 145 case '1': 146 if (memEQ(name, "FNV1_32_INIT", 12)) { 147 /* ^ */ 148#ifdef FNV1_32_INIT 149 *iv_return = FNV1_32_INIT; 150 return PERL_constant_ISIV; 151#else 152 return PERL_constant_NOTDEF; 153#endif 154 } 155 if (memEQ(name, "FNV1_64_INIT", 12)) { 156 /* ^ */ 157#ifdef FNV1_64_INIT 158 *iv_return = FNV1_64_INIT; 159 return PERL_constant_ISIV; 160#else 161 return PERL_constant_NOTDEF; 162#endif 163 } 164 break; 165 } 166 return PERL_constant_NOTFOUND; 167} 168 169static int 170constant (pTHX_ const char *name, STRLEN len, IV *iv_return) { 171 /* Initially switch on the length of the name. */ 172 /* When generated this function returned values for the list of names given 173 in this section of perl code. Rather than manually editing these functions 174 to add or remove constants, which would result in this comment and section 175 of code becoming inaccurate, we recommend that you edit this section of 176 code, and use it to regenerate a new set of constant functions which you 177 then use to replace the originals. 178 179 Regenerate these constant functions by feeding this entire source file to 180 perl -x 181 182#!/usr/bin/perl -w 183use ExtUtils::Constant qw (constant_types C_constant XS_constant); 184 185my $types = {map {($_, 1)} qw(IV)}; 186my @names = (qw(FNV0_32 FNV0_32_INIT FNV0_64 FNV0_64_INIT FNV1A_64_INIT FNV1_32 187 FNV1_32A_INIT FNV1_32_INIT FNV1_64 FNV1_64_INIT FNV1a_32 188 FNV1a_64 FNV_NONE)); 189 190print constant_types(), "\n"; # macro defs 191foreach (C_constant ("Digest::FNV", 'constant', 'IV', $types, undef, 3, @names) ) { 192 print $_, "\n"; # C constant subs 193} 194print "\n#### XS Section:\n"; 195print XS_constant ("Digest::FNV", $types); 196__END__ 197 */ 198 199 switch (len) { 200 case 7: 201 return constant_7 (aTHX_ name, iv_return); 202 break; 203 case 8: 204 return constant_8 (aTHX_ name, iv_return); 205 break; 206 case 12: 207 return constant_12 (aTHX_ name, iv_return); 208 break; 209 case 13: 210 /* Names all of length 13. */ 211 /* FNV1A_64_INIT FNV1_32A_INIT */ 212 /* Offset 6 gives the best switch position. */ 213 switch (name[6]) { 214 case '2': 215 if (memEQ(name, "FNV1_32A_INIT", 13)) { 216 /* ^ */ 217#ifdef FNV1_32A_INIT 218 *iv_return = FNV1_32A_INIT; 219 return PERL_constant_ISIV; 220#else 221 return PERL_constant_NOTDEF; 222#endif 223 } 224 break; 225 case '6': 226 if (memEQ(name, "FNV1A_64_INIT", 13)) { 227 /* ^ */ 228#ifdef FNV1A_64_INIT 229 *iv_return = FNV1A_64_INIT; 230 return PERL_constant_ISIV; 231#else 232 return PERL_constant_NOTDEF; 233#endif 234 } 235 break; 236 } 237 break; 238 } 239 return PERL_constant_NOTFOUND; 240} 241 242