Add a set of comments to process_proto_function and reorganize the logic slightly; no functional change.
Showing the changes to scripts (1 of 1 file). Show all
Unified · Split
| @@ -1553,39 +1553,44 @@ class KernelDoc: · 1552 unmodified lines | ||
| 1553 | 1553 | """Ancillary routine to process a function prototype""" |
| 1554 | 1554 | |
| 1555 | 1555 | # strip C99-style comments to end of line |
| 1556 | − r = KernRe(r"\/\/.*$", re.S) | |
| 1557 | − line = r.sub('', line) | |
| 1558 | − | |
| 1556 | + line = KernRe(r"\/\/.*$", re.S).sub('', line) | |
| 1557 | + # | |
| 1558 | + # Soak up the line's worth of prototype text, stopping at { or ; if present. | |
| 1559 | + # | |
| 1559 | 1560 | if KernRe(r'\s*#\s*define').match(line): |
| 1560 | 1561 | self.entry.prototype = line |
| 1561 | − elif line.startswith('#'): | |
| 1562 | − # Strip other macros like #ifdef/#ifndef/#endif/... | |
| 1563 | − pass | |
| 1564 | − else: | |
| 1562 | + elif not line.startswith('#'): # skip other preprocessor stuff | |
| 1565 | 1563 | r = KernRe(r'([^\{]*)') |
| 1566 | 1564 | if r.match(line): |
| 1567 | 1565 | self.entry.prototype += r.group(1) + " " |
| 1568 | − | |
| 1566 | + # | |
| 1567 | + # If we now have the whole prototype, clean it up and declare victory. | |
| 1568 | + # | |
| 1569 | 1569 | if '{' in line or ';' in line or KernRe(r'\s*#\s*define').match(line): |
| 1570 | 1570 | # strip comments and surrounding spaces |
| 1571 | − r = KernRe(r'/\*.*\*/') | |
| 1572 | − self.entry.prototype = r.sub('', self.entry.prototype).strip() | |
| 1573 | − | |
| 1571 | + self.entry.prototype = KernRe(r'/\*.*\*/').sub('', self.entry.prototype).strip() | |
| 1572 | + # | |
| 1574 | 1573 | # Handle self.entry.prototypes for function pointers like: |
| 1575 | 1574 | # int (*pcs_config)(struct foo) |
| 1576 | − | |
| 1575 | + # by turning it into | |
| 1576 | + # int pcs_config(struct foo) | |
| 1577 | + # | |
| 1577 | 1578 | r = KernRe(r'^(\S+\s+)\(\s*\*(\S+)\)') |
| 1578 | 1579 | self.entry.prototype = r.sub(r'\1\2', self.entry.prototype) |
| 1579 | − | |
| 1580 | + # | |
| 1581 | + # Handle special declaration syntaxes | |
| 1582 | + # | |
| 1580 | 1583 | if 'SYSCALL_DEFINE' in self.entry.prototype: |
| 1581 | 1584 | self.entry.prototype = self.syscall_munge(ln, |
| 1582 | 1585 | self.entry.prototype) |
| 1583 | − | |
| 1584 | − r = KernRe(r'TRACE_EVENT|DEFINE_EVENT|DEFINE_SINGLE_EVENT') | |
| 1585 | − if r.search(self.entry.prototype): | |
| 1586 | − self.entry.prototype = self.tracepoint_munge(ln, | |
| 1587 | − self.entry.prototype) | |
| 1588 | − | |
| 1586 | + else: | |
| 1587 | + r = KernRe(r'TRACE_EVENT|DEFINE_EVENT|DEFINE_SINGLE_EVENT') | |
| 1588 | + if r.search(self.entry.prototype): | |
| 1589 | + self.entry.prototype = self.tracepoint_munge(ln, | |
| 1590 | + self.entry.prototype) | |
| 1591 | + # | |
| 1592 | + # ... and we're done | |
| 1593 | + # | |
| 1589 | 1594 | self.dump_function(ln, self.entry.prototype) |
| 1590 | 1595 | self.reset_state(ln) |
| 1591 | 1596 | |