parser: fix `extension static inline` in bits/byteswap.h
[m6w6/ext-psi] / scripts / gen_calc_bool.php
1 <?php
2 include __DIR__."/_include.php";
3 ?>
4
5 static inline token_t psi_calc_bool_or(token_t t1, impl_val *v1, token_t t2, impl_val *v2, impl_val *res)
6 {
7 switch (t1) {<?php /*nobr */ ?>
8 <?php foreach ($types as $t1 => $v1) : ?>
9 <?php if (t_is_special($t1)) :?>
10
11 #if HAVE_<?=$t1?>
12 <?php endif; ?>
13
14 case PSI_T_<?=$t1?>:
15 if (v1-><?=$v1?>)
16 goto return_true;
17 break;<?php /*nobr */ ?>
18 <?php if (t_is_special($t1)) : ?>
19
20 #endif
21 <?php endif; ?>
22 <?php endforeach; ?>
23
24 default:
25 assert(0);
26 break;
27 }
28
29 switch (t2) {<?php /*nobr */ ?>
30 <?php foreach ($types as $t2 => $v2) : ?>
31 <?php if (t_is_special($t2)) :?>
32
33 #if HAVE_<?=$t2?>
34 <?php endif; ?>
35
36 case PSI_T_<?=$t2?>:
37 if (v2-><?=$v2?>)
38 goto return_true;
39 break;<?php /*nobr */ ?>
40 <?php if (t_is_special($t2)) : ?>
41
42 #endif
43 <?php endif; ?>
44 <?php endforeach; ?>
45
46 default:
47 assert(0);
48 break;
49 }
50
51 res->u8 = 0;
52 return PSI_T_UINT8;
53
54 return_true:
55 res->u8 = 1;
56 return PSI_T_UINT8;
57 }
58
59 static inline token_t psi_calc_bool_and(token_t t1, impl_val *v1, token_t t2, impl_val *v2, impl_val *res)
60 {
61 switch (t1) {<?php /*nobr */ ?>
62 <?php foreach ($types as $t1 => $v1) : ?>
63 <?php if (t_is_special($t1)) :?>
64
65 #if HAVE_<?=$t1?>
66 <?php endif; ?>
67
68 case PSI_T_<?=$t1?>:
69 if (!v1-><?=$v1?>)
70 goto return_false;
71 break;<?php /*nobr */ ?>
72 <?php if (t_is_special($t1)) : ?>
73
74 #endif
75 <?php endif; ?>
76 <?php endforeach; ?>
77
78 default:
79 assert(0);
80 break;
81 }
82
83 switch (t2) {<?php /*nobr */ ?>
84 <?php foreach ($types as $t2 => $v2) : ?>
85 <?php if (t_is_special($t2)) :?>
86
87 #if HAVE_<?=$t2?>
88 <?php endif; ?>
89
90 case PSI_T_<?=$t2?>:
91 if (!v2-><?=$v2?>)
92 goto return_false;
93 break;<?php /*nobr */ ?>
94 <?php if (t_is_special($t2)) : ?>
95
96 #endif
97 <?php endif; ?>
98 <?php endforeach; ?>
99
100 default:
101 assert(0);
102 break;
103 }
104
105 res->u8 = 1;
106 return PSI_T_UINT8;
107
108 return_false:
109 res->u8 = 0;
110 return PSI_T_UINT8;
111 }