MCPcopy Create free account
hub / github.com/URLab-Sim/UnrealRoboticsLab / _scan_hand_enums

Function _scan_hand_enums

Scripts/codegen/_codegen_checks.py:41–66  ·  view source on GitHub ↗

Walk ``public_root`` for every ``.h`` file declaring ``enum class EMj* : uint8 { ... }`` and return ``{enum_name: [members]}``. Members are stripped of inline initialisers, UMETA macros, and comments.

(public_root: str)

Source from the content-addressed store, hash-verified

39
40
41def _scan_hand_enums(public_root: str) -> Dict[str, List[str]]:
42 """Walk ``public_root`` for every ``.h`` file declaring
43 ``enum class EMj* : uint8 { ... }`` and return
44 ``{enum_name: [members]}``. Members are stripped of inline
45 initialisers, UMETA macros, and comments."""
46 out: Dict[str, List[str]] = {}
47 for root, _dirs, files in os.walk(public_root):
48 for name in files:
49 if not name.endswith(".h"):
50 continue
51 with open(os.path.join(root, name), "r", encoding="utf-8") as f:
52 text = f.read()
53 for m in _HAND_ENUM_RE.finditer(text):
54 enum_name = m.group(1)
55 body = m.group(2)
56 body = re.sub(r"UMETA\([^)]*\)", "", body)
57 body = re.sub(r"//[^\n]*", "", body)
58 body = re.sub(r"/\*.*?\*/", "", body, flags=re.DOTALL)
59 members: List[str] = []
60 for line in body.split(","):
61 mm = _HAND_ENUM_MEMBER_RE.match(line)
62 if mm:
63 members.append(mm.group(1))
64 if members:
65 out[enum_name] = members
66 return out
67
68
69def _hand_enums_from_snapshot(mjspec: Optional[Dict[str, Any]]) -> Dict[str, List[str]]:

Callers 1

_check_hand_enum_driftFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected