Whether a `.h` file is C++ rather than plain C (#1547). Mirrors `_is_objc_header`: sniffs for a C++-only token. Used only to reroute a `.h` from extract_c to extract_cpp when no ObjC marker is present (ObjC has priority). Conservative by construction — a plain C header matches nothing
(path: Path, head: bytes | None = None)
| 12499 | |
| 12500 | |
| 12501 | def _is_cpp_header(path: Path, head: bytes | None = None) -> bool: |
| 12502 | """Whether a `.h` file is C++ rather than plain C (#1547). |
| 12503 | |
| 12504 | Mirrors `_is_objc_header`: sniffs for a C++-only token. Used only to reroute |
| 12505 | a `.h` from extract_c to extract_cpp when no ObjC marker is present (ObjC has |
| 12506 | priority). Conservative by construction — a plain C header matches nothing |
| 12507 | here and keeps its existing extract_c routing. |
| 12508 | """ |
| 12509 | data = _sniff_head(path, head) |
| 12510 | return any(marker in data for marker in _CPP_HEADER_MARKERS) |
| 12511 | |
| 12512 | |
| 12513 | def _get_extractor(path: Path, *, sniff_headers: bool = True) -> Any | None: |