|
14 | 14 | from __future__ import annotations |
15 | 15 |
|
16 | 16 | import re |
| 17 | +from dataclasses import dataclass |
17 | 18 |
|
18 | 19 | from doxmlparser import compound |
19 | 20 |
|
|
43 | 44 | from .utils.argument_parsing import _find_matching_angle, _split_arguments |
44 | 45 |
|
45 | 46 |
|
| 47 | +@dataclass |
| 48 | +class ParsedSectionKind: |
| 49 | + """Parsed representation of a Doxygen section kind string (e.g. 'public-static-func').""" |
| 50 | + |
| 51 | + visibility: str |
| 52 | + is_static: bool |
| 53 | + member_type: str |
| 54 | + |
| 55 | + @classmethod |
| 56 | + def parse(cls, kind: str) -> ParsedSectionKind: |
| 57 | + parts = kind.split("-") |
| 58 | + return cls( |
| 59 | + visibility=parts[0], |
| 60 | + is_static="static" in parts, |
| 61 | + member_type=parts[-1], |
| 62 | + ) |
| 63 | + |
| 64 | + |
46 | 65 | ###################### |
47 | 66 | # Base class fixups |
48 | 67 | ###################### |
@@ -536,11 +555,10 @@ def _process_objc_sections( |
536 | 555 | members into the base interface XML output. |
537 | 556 | """ |
538 | 557 | for section_def in section_defs: |
539 | | - kind = section_def.kind |
540 | | - parts = kind.split("-") |
541 | | - visibility = parts[0] |
542 | | - is_static = "static" in parts |
543 | | - member_type = parts[-1] |
| 558 | + section = ParsedSectionKind.parse(section_def.kind) |
| 559 | + visibility = section.visibility |
| 560 | + is_static = section.is_static |
| 561 | + member_type = section.member_type |
544 | 562 |
|
545 | 563 | if visibility == "private": |
546 | 564 | if member_type == "type": |
@@ -577,7 +595,9 @@ def _process_objc_sections( |
577 | 595 | f"Unknown section member kind: {member_def.kind} in {location_file}" |
578 | 596 | ) |
579 | 597 | else: |
580 | | - print(f"Unknown {scope_type} section kind: {kind} in {location_file}") |
| 598 | + print( |
| 599 | + f"Unknown {scope_type} section kind: {section_def.kind} in {location_file}" |
| 600 | + ) |
581 | 601 | elif visibility == "property": |
582 | 602 | for member_def in section_def.memberdef: |
583 | 603 | if member_def.kind == "property": |
@@ -693,11 +713,10 @@ def create_class_scope( |
693 | 713 | class_scope.location = compound_object.location.file |
694 | 714 |
|
695 | 715 | for section_def in compound_object.sectiondef: |
696 | | - kind = section_def.kind |
697 | | - parts = kind.split("-") |
698 | | - visibility = parts[0] |
699 | | - is_static = "static" in parts |
700 | | - member_type = parts[-1] |
| 716 | + section = ParsedSectionKind.parse(section_def.kind) |
| 717 | + visibility = section.visibility |
| 718 | + is_static = section.is_static |
| 719 | + member_type = section.member_type |
701 | 720 |
|
702 | 721 | if visibility == "private": |
703 | 722 | if member_type == "type": |
@@ -746,7 +765,7 @@ def create_class_scope( |
746 | 765 | ) |
747 | 766 | else: |
748 | 767 | print( |
749 | | - f"Unknown class section kind: {kind} in {compound_object.location.file}" |
| 768 | + f"Unknown class section kind: {section_def.kind} in {compound_object.location.file}" |
750 | 769 | ) |
751 | 770 | elif visibility == "friend": |
752 | 771 | pass |
|
0 commit comments