Coverage for packages/pyswig/src/pyswig/types.py: 100%
19 statements
« prev ^ index » next coverage.py v7.14.3, created at 2026-06-26 21:05 +0000
« prev ^ index » next coverage.py v7.14.3, created at 2026-06-26 21:05 +0000
1# Copyright (c) 2015-2020 Michel Gillet
2# SPDX-License-Identifier: MIT
4from __future__ import annotations
6from typing import NamedTuple, Union
9class TagRecord(NamedTuple):
10 """Tags metadata parsed from one annotated header."""
12 file: str | None
13 tags: list[str] | None
16class DefineRecord(NamedTuple):
17 """Preprocessor define written into the main Swig interface file."""
19 name: str
20 value: str | None
23class ReplaceStringPair(NamedTuple):
24 """Search/replace pair applied to Swig-generated wrapper sources."""
26 orig: str
27 new: str
30class SourceFileSpec(NamedTuple):
31 """Normalized source header entry from a FileConfig source list."""
33 name: str
34 wrap: bool = False
37SourceFileEntry = Union[str, list[Union[str, bool]]]
40def normalize_source_entry(entry: SourceFileEntry) -> SourceFileSpec:
41 """Normalize legacy source list entries to a SourceFileSpec."""
42 if isinstance(entry, list):
43 return SourceFileSpec(str(entry[0]), bool(entry[1]))
44 return SourceFileSpec(str(entry))