Bug 1877642 - Disable browser_fullscreen-tab-close-race.js on apple_silicon !debug...
[gecko.git] / accessible / base / RoleHGen.py
blob374d2f66a90a61f87d61b84205e13214367bcaf4
1 #!/usr/bin/env python
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 import re
10 def generate(roleH, roleIdl):
11 input = open(roleIdl, "rt").read()
12 roles = re.findall(r"const unsigned long ROLE_([A-Z_]+) = (\d+);", input)
14 roleH.write(
15 "/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */\n"
16 "/* Roles are defined in accessible/interfaces/nsIAccessibleRole.idl */\n\n"
17 "#ifndef _role_h_\n"
18 "#define _role_h_\n\n"
19 "namespace mozilla {\n"
20 "namespace a11y {\n"
21 "namespace roles {\n\n"
22 "enum Role {\n"
24 for name, num in roles:
25 roleH.write(f" {name} = {num},\n")
26 lastName = roles[-1][0]
27 roleH.write(
28 f" LAST_ROLE = {lastName}\n"
29 "};\n\n"
30 "} // namespace roles\n\n"
31 "typedef enum mozilla::a11y::roles::Role role;\n\n"
32 "} // namespace a11y\n"
33 "} // namespace mozilla\n\n"
34 "#endif\n"
38 # For debugging
39 if __name__ == "__main__":
40 import sys
42 generate(sys.stdout, "accessible/interfaces/nsIAccessibleRole.idl")