mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-91271: Document which parts of structs are in limited API/stable ABI (GH-32196) (GH-95711)
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
This commit is contained in:
parent
57446f9e33
commit
b66b6e1cc0
5 changed files with 982 additions and 871 deletions
|
|
@ -119,6 +119,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',
|
||||
|
|
@ -173,6 +175,15 @@ def raise_error(msg):
|
|||
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}")
|
||||
levels.append((entry, level))
|
||||
|
|
@ -246,7 +257,9 @@ def sort_key(item):
|
|||
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})
|
||||
|
||||
def generate_or_check(manifest, args, path, func):
|
||||
"""Generate/check a file with a single generator
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue