diff options
author | Petr Viktorin <encukou@gmail.com> | 2022-04-06 14:50:45 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-06 14:50:45 (GMT) |
commit | d79f118d044e9b4244b5dfda35448d39202d7f56 (patch) | |
tree | 97361543a287b31bb1f9d5ed039c368c4a47b8ae /Tools | |
parent | 14a9b4895b61bcd46ed968c43c5eec27670a0aac (diff) | |
download | cpython-d79f118d044e9b4244b5dfda35448d39202d7f56.zip cpython-d79f118d044e9b4244b5dfda35448d39202d7f56.tar.gz cpython-d79f118d044e9b4244b5dfda35448d39202d7f56.tar.bz2 |
bpo-47115: Document which parts of structs are in limited API/stable ABI (GH-32196)
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
Diffstat (limited to 'Tools')
-rwxr-xr-x | Tools/scripts/stable_abi.py | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/Tools/scripts/stable_abi.py b/Tools/scripts/stable_abi.py index 2d95178..feca9a2 100755 --- a/Tools/scripts/stable_abi.py +++ b/Tools/scripts/stable_abi.py @@ -118,6 +118,8 @@ class ABIItem: contents: list = dataclasses.field(default_factory=list) abi_only: bool = False ifdef: str = None + struct_abi_kind: str = None + members: list = None KINDS = frozenset({ 'struct', 'function', 'macro', 'data', 'const', 'typedef', @@ -172,6 +174,15 @@ def parse_manifest(file): if parent.kind not in {'function', 'data'}: raise_error(f'{kind} cannot go in {parent.kind}') parent.abi_only = True + elif kind in {'members', 'full-abi', 'opaque'}: + if parent.kind not in {'struct'}: + raise_error(f'{kind} cannot go in {parent.kind}') + if prev := getattr(parent, 'struct_abi_kind', None): + raise_error( + f'{parent.name} already has {prev}, cannot add {kind}') + parent.struct_abi_kind = kind + if kind == 'members': + parent.members = content.split() else: raise_error(f"unknown kind {kind!r}") # When adding more, update the comment in stable_abi.txt. @@ -246,7 +257,9 @@ REST_ROLES = { def gen_doc_annotations(manifest, args, outfile): """Generate/check the stable ABI list for documentation annotations""" writer = csv.DictWriter( - outfile, ['role', 'name', 'added', 'ifdef_note'], lineterminator='\n') + outfile, + ['role', 'name', 'added', 'ifdef_note', 'struct_abi_kind'], + lineterminator='\n') writer.writeheader() for item in manifest.select(REST_ROLES.keys(), include_abi_only=False): if item.ifdef: @@ -257,7 +270,13 @@ def gen_doc_annotations(manifest, args, outfile): 'role': REST_ROLES[item.kind], 'name': item.name, 'added': item.added, - 'ifdef_note': ifdef_note}) + 'ifdef_note': ifdef_note, + 'struct_abi_kind': item.struct_abi_kind}) + for member_name in item.members or (): + writer.writerow({ + 'role': 'member', + 'name': f'{item.name}.{member_name}', + 'added': item.added}) @generator("ctypes_test", 'Lib/test/test_stable_abi_ctypes.py') def gen_ctypes_test(manifest, args, outfile): |