As NestedMatch now has a sub method and a declaration close to what KernRe does, we can move the rules to xforms_lists and simplify kdoc_parser a little bit. No functional changes.
Showing the changes to tools/lib/python (2 of 2 files). Show all
Unified · Split
| @@ -69,25 +69,6 @@ doc_begin_func = KernRe(str(doc_com) + # initial " * ' · 68 unmodified lines | ||
| 69 | 69 | r'(?:[-:].*)?$', # description (not captured) |
| 70 | 70 | cache = False) |
| 71 | 71 | |
| 72 | −# | |
| 73 | −# Regexes here are guaranteed to have the end delimiter matching | |
| 74 | −# the start delimiter. Yet, right now, only one replace group | |
| 75 | −# is allowed. | |
| 76 | −# | |
| 77 | −struct_nested_prefixes = [ | |
| 78 | − (NestedMatch(r"__cond_acquires\s*\("), ""), | |
| 79 | − (NestedMatch(r"__cond_releases\s*\("), ""), | |
| 80 | − (NestedMatch(r"__acquires\s*\("), ""), | |
| 81 | − (NestedMatch(r"__releases\s*\("), ""), | |
| 82 | − (NestedMatch(r"__must_hold\s*\("), ""), | |
| 83 | − (NestedMatch(r"__must_not_hold\s*\("), ""), | |
| 84 | − (NestedMatch(r"__must_hold_shared\s*\("), ""), | |
| 85 | − (NestedMatch(r"__cond_acquires_shared\s*\("), ""), | |
| 86 | − (NestedMatch(r"__acquires_shared\s*\("), ""), | |
| 87 | − (NestedMatch(r"__releases_shared\s*\("), ""), | |
| 88 | − (NestedMatch(r'\bSTRUCT_GROUP\('), r'\0'), | |
| 89 | −] | |
| 90 | − | |
| 91 | 72 | # |
| 92 | 73 | # Ancillary functions |
| 93 | 74 | # |
| @@ -761,8 +742,6 @@ class KernelDoc: · 667 unmodified lines | ||
| 761 | 742 | members = trim_private_members(members) |
| 762 | 743 | members = self.xforms.apply("struct", members) |
| 763 | 744 | |
| 764 | − for search, sub in struct_nested_prefixes: | |
| 765 | − members = search.sub(search, sub, members) | |
| 766 | 745 | # |
| 767 | 746 | # Deal with embedded struct and union members, and drop enums entirely. |
| 768 | 747 | # |
| @@ -4,7 +4,7 @@ · 3 unmodified lines | ||
| 4 | 4 | |
| 5 | 5 | import re |
| 6 | 6 | |
| 7 | −from kdoc.kdoc_re import KernRe | |
| 7 | +from kdoc.kdoc_re import KernRe, NestedMatch | |
| 8 | 8 | |
| 9 | 9 | struct_args_pattern = r'([^,)]+)' |
| 10 | 10 | |
| @@ -94,6 +94,18 @@ class CTransforms: · 83 unmodified lines | ||
| 94 | 94 | (KernRe(r'DEFINE_DMA_UNMAP_ADDR\s*\(' + struct_args_pattern + r'\)', re.S), r'dma_addr_t \1'), |
| 95 | 95 | (KernRe(r'DEFINE_DMA_UNMAP_LEN\s*\(' + struct_args_pattern + r'\)', re.S), r'__u32 \1'), |
| 96 | 96 | (KernRe(r'VIRTIO_DECLARE_FEATURES\(([\w_]+)\)'), r'union { u64 \1; u64 \1_array[VIRTIO_FEATURES_U64S]; }'), |
| 97 | + | |
| 98 | + (NestedMatch(r"__cond_acquires\s*\("), ""), | |
| 99 | + (NestedMatch(r"__cond_releases\s*\("), ""), | |
| 100 | + (NestedMatch(r"__acquires\s*\("), ""), | |
| 101 | + (NestedMatch(r"__releases\s*\("), ""), | |
| 102 | + (NestedMatch(r"__must_hold\s*\("), ""), | |
| 103 | + (NestedMatch(r"__must_not_hold\s*\("), ""), | |
| 104 | + (NestedMatch(r"__must_hold_shared\s*\("), ""), | |
| 105 | + (NestedMatch(r"__cond_acquires_shared\s*\("), ""), | |
| 106 | + (NestedMatch(r"__acquires_shared\s*\("), ""), | |
| 107 | + (NestedMatch(r"__releases_shared\s*\("), ""), | |
| 108 | + (NestedMatch(r'\bSTRUCT_GROUP\('), r'\0'), | |
| 97 | 109 | ] |
| 98 | 110 | |
| 99 | 111 | #: Transforms for function prototypes. |