`depth` layers of two headers; each includes both headers of the next layer.
(depth: number, guard: Guard)
| 23 | |
| 24 | /** `depth` layers of two headers; each includes both headers of the next layer. */ |
| 25 | function layeredHeaders(depth: number, guard: Guard): Record<string, string> { |
| 26 | const files: Record<string, string> = {}; |
| 27 | for (let d = 0; d < depth; d++) { |
| 28 | for (const side of ['a', 'b']) { |
| 29 | const g = `H_${d}_${side}`; |
| 30 | const open = |
| 31 | guard === 'value' ? `#ifndef ${g}\n#define ${g} 1\n` : |
| 32 | guard === 'bare' ? `#ifndef ${g}\n#define ${g}\n` : |
| 33 | `#ifdef USE_${d}\n`; |
| 34 | const next = d + 1 < depth ? `#include "h${d + 1}_a.h"\n#include "h${d + 1}_b.h"\n` : ''; |
| 35 | files[`h${d}_${side}.h`] = `${open}${next}#define M_${d}_${side}(x) (x)\nint f_${d}_${side}(int);\n#endif\n`; |
| 36 | } |
| 37 | } |
| 38 | return files; |
| 39 | } |
| 40 | |
| 41 | /** A context over in-memory files where every name is both a macro and a function. */ |
| 42 | function contextOver(files: Record<string, string>): ResolutionContext { |
no outgoing calls
no test coverage detected