Commit f819034
committed
Add ParseCallbacks::allow_or_block_item().
Like `allowlist_item` and `blocklist_item` options, add new methods to
`ParseCallbacks`, `ParseCallbacks::allow_item()` and
`ParseCallbacks::block_item()`, to be able to allow and block items from
being generated.
`allowlist_*` and `blocklist_*` options work with regexes and are
inserted in a RegexSet.
There are two issues with this approach:
1. In some cases, we want to have more flexibility than just using
regexes. If we want to have dynamic conditions to allow or block
items, using regexes can be limited.
2. RegexSet scales linearly with the number of elements inserted. This
means that if we have a huge number of items that we want to allow or
block, regexes and RegexSet are not necessarily the most appropriate
data structures.
Using a new method in `ParseCallbacks` solves these two issues.
We can manually decide the appropriate rules and data structure to match
the items.
This method takes precedences over the `allowlist_*` options.
If at least one of the parse callbacks returns `Block`, the generation
of the bindings for the item is blocked.
If all the parse callbacks that don't return `None` return `Allow`, the
bindings for the item are generated.
If all the parse callbacks return `None` (the default implementation),
the `allowlist_*` options are used instead.1 parent 74a5f30 commit f819034
10 files changed
Lines changed: 351 additions & 15 deletions
File tree
- bindgen-tests/tests
- expectations/tests
- headers
- parse_callbacks
- bindgen
- codegen
- ir
Lines changed: 65 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 52 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
163 | 189 | | |
164 | 190 | | |
165 | 191 | | |
| |||
169 | 195 | | |
170 | 196 | | |
171 | 197 | | |
| 198 | + | |
| 199 | + | |
172 | 200 | | |
173 | 201 | | |
174 | 202 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
22 | 32 | | |
23 | 33 | | |
24 | 34 | | |
| |||
206 | 216 | | |
207 | 217 | | |
208 | 218 | | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
209 | 239 | | |
210 | 240 | | |
211 | 241 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
5008 | 5009 | | |
5009 | 5010 | | |
5010 | 5011 | | |
5011 | | - | |
| 5012 | + | |
| 5013 | + | |
| 5014 | + | |
| 5015 | + | |
| 5016 | + | |
| 5017 | + | |
| 5018 | + | |
| 5019 | + | |
| 5020 | + | |
| 5021 | + | |
| 5022 | + | |
| 5023 | + | |
5012 | 5024 | | |
5013 | 5025 | | |
5014 | 5026 | | |
| |||
5325 | 5337 | | |
5326 | 5338 | | |
5327 | 5339 | | |
5328 | | - | |
| 5340 | + | |
| 5341 | + | |
| 5342 | + | |
5329 | 5343 | | |
5330 | 5344 | | |
5331 | 5345 | | |
| |||
5456 | 5470 | | |
5457 | 5471 | | |
5458 | 5472 | | |
5459 | | - | |
5460 | | - | |
| 5473 | + | |
| 5474 | + | |
| 5475 | + | |
| 5476 | + | |
| 5477 | + | |
| 5478 | + | |
| 5479 | + | |
| 5480 | + | |
| 5481 | + | |
| 5482 | + | |
| 5483 | + | |
| 5484 | + | |
5461 | 5485 | | |
| 5486 | + | |
5462 | 5487 | | |
5463 | 5488 | | |
5464 | 5489 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
2406 | 2407 | | |
2407 | 2408 | | |
2408 | 2409 | | |
| 2410 | + | |
| 2411 | + | |
| 2412 | + | |
| 2413 | + | |
| 2414 | + | |
| 2415 | + | |
| 2416 | + | |
| 2417 | + | |
| 2418 | + | |
| 2419 | + | |
| 2420 | + | |
| 2421 | + | |
2409 | 2422 | | |
2410 | 2423 | | |
2411 | 2424 | | |
| |||
0 commit comments