C/C++ source pre-processing before tree-sitter: recover macro-annotated class * definitions, macro-prefixed function definitions, macro-prefixed members, and * macro-decorated members (Unreal-Engine reflection markup) — plus the non-C++ * surface of the dialects parsed with the C++ grammar: `.met
(source: string, filePath?: string)
| 795 | * or by content, for CUDA living in `.h`/`.hpp` headers). Offset-preserving; |
| 796 | * directive lines are restored at the end (see restoreDirectiveLines). */ |
| 797 | function preParseCppSource(source: string, filePath?: string): string { |
| 798 | // blankCLeadingAttrMacros runs AFTER the api-prefix blank so a stacked |
| 799 | // `FMT_NORETURN FMT_API void f(…)` reduces to the `MACRO Ret name(` shape |
| 800 | // it matches (the _API token is already spaces by then). |
| 801 | let blanked = blankLoneMacroLines( |
| 802 | blankCLeadingAttrMacros( |
| 803 | blankCppAnnotationMacroCalls( |
| 804 | blankCppInlineAnnotationMacros( |
| 805 | blankCppApiPrefixMacros(blankCppInlineMacros(blankCppExportMacros(source))) |
| 806 | ) |
| 807 | ) |
| 808 | ) |
| 809 | ); |
| 810 | const lower = filePath ? filePath.toLowerCase() : ''; |
| 811 | if (lower.endsWith('.metal')) { |
| 812 | blanked = blankMetalAttributes(blanked); |
| 813 | } else if (lower.endsWith('.cu') || lower.endsWith('.cuh') || looksLikeCudaSource(source)) { |
| 814 | blanked = blankCudaConstructs(blanked); |
| 815 | } |
| 816 | return restoreDirectiveLines(source, blanked); |
| 817 | } |
| 818 | |
| 819 | /** |
| 820 | * Blank an unknown attribute macro sitting in front of a C function |
nothing calls this directly
no test coverage detected