![]() |
Ansel 0.0
A darktable fork - bloat + design vision
|
Functions | |
| count_mentions (path, name) | |
| layer_of (relpath) | |
| walk_sources () | |
| main () | |
Variables | |
| REPO = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | |
| SRC = os.path.join(REPO, "src") | |
| _ig_spec | |
| _ig = importlib.util.module_from_spec(_ig_spec) | |
| LAYERS = _ig.LAYERS | |
| LAYER = _ig.LAYER | |
| FWD = re.compile(r'^\s*(?:struct|union|enum)\s+([A-Za-z_]\w*)\s*;\s*$') | |
| DEF_CLOSE = re.compile(r'^\s*\}\s*([A-Za-z_]\w*)\s*;') | |
| DEF_OPEN = re.compile(r'^\s*(?:typedef\s+)?(?:struct|union|enum)\s+([A-Za-z_]\w*)\s*\{') | |
| COMMENT_BLOCK = re.compile(r'/\*.*?\*/', re.S) | |
| COMMENT_LINE = re.compile(r'//[^\n]*') | |
Find forward declarations that let a header reach a type from a HIGHER layer.
A forward declaration is normally a good thing: `struct dt_foo_t;` lets a header mention a
type without including the header that defines it, which is how include graphs stay small.
But it also silently defeats the layering check, because there is no #include to count.
`pixel/format.h` was the case that prompted this: it forward-declared `dt_iop_module_t`,
`dt_dev_pixelpipe_t` and `dt_dev_pixelpipe_iop_t` -- three develop/ types, two layers up --
purely so a layer-2 header could declare three functions over them. `tools/include_graph.py`
saw nothing, because nothing was included.
This reports every forward declaration whose type is really defined at a higher layer. Most
findings are legitimate opaque handles: passing a pointer through without touching its
fields costs nothing and creates no real dependency. The ones to look at are where the header
also *declares functions* over the type -- that is the shape that turned out to be an API in
the wrong place.
Usage:
tools/forward_decl_audit.py [--all] [--json]
--all also lists same-layer and downward forward declarations, which are never a problem.
| forward_decl_audit.count_mentions | ( | path, | |
| name | |||
| ) |
Lines mentioning `name` outside comments and outside its own forward declaration.
Definition at line 57 of file forward_decl_audit.py.
Referenced by main().
| forward_decl_audit.layer_of | ( | relpath | ) |
Definition at line 70 of file forward_decl_audit.py.
Referenced by main().
| forward_decl_audit.main | ( | void | ) |
Definition at line 88 of file forward_decl_audit.py.
References count_mentions(), layer_of(), main(), and walk_sources().
Referenced by main().
| forward_decl_audit.walk_sources | ( | ) |
Definition at line 79 of file forward_decl_audit.py.
Referenced by main().
|
protected |
Definition at line 42 of file forward_decl_audit.py.
|
protected |
Definition at line 40 of file forward_decl_audit.py.
| forward_decl_audit.COMMENT_BLOCK = re.compile(r'/\*.*?\*/', re.S) |
Definition at line 53 of file forward_decl_audit.py.
Definition at line 54 of file forward_decl_audit.py.
Definition at line 49 of file forward_decl_audit.py.
| forward_decl_audit.DEF_OPEN = re.compile(r'^\s*(?:typedef\s+)?(?:struct|union|enum)\s+([A-Za-z_]\w*)\s*\{') |
Definition at line 50 of file forward_decl_audit.py.
Definition at line 47 of file forward_decl_audit.py.
| forward_decl_audit.LAYER = _ig.LAYER |
Definition at line 45 of file forward_decl_audit.py.
| forward_decl_audit.LAYERS = _ig.LAYERS |
Definition at line 44 of file forward_decl_audit.py.
| forward_decl_audit.REPO = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
Definition at line 32 of file forward_decl_audit.py.
| forward_decl_audit.SRC = os.path.join(REPO, "src") |
Definition at line 33 of file forward_decl_audit.py.