no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / accessible / base / RelationTypeGen.py
blob8d9a0f91bfa7d43c7e1c9c5c5b7658cb74346535
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(relH, relIdl):
11 input = open(relIdl, "rt").read()
12 relations = re.findall(
13 r"const unsigned long RELATION_([A-Z_]+) = ([x0-9a-f]+);", input
16 relH.write(
17 "/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */\n"
18 "/* Relations are defined in accessible/interfaces/nsIAccessibleRelation.idl */\n\n"
19 "#ifndef mozilla_a11y_relationtype_h_\n"
20 "#define mozilla_a11y_relationtype_h_\n\n"
21 "namespace mozilla {\n"
22 "namespace a11y {\n\n"
23 "enum class RelationType {\n"
25 for name, num in relations:
26 relH.write(f" {name} = {num},\n")
27 lastName = relations[-1][0]
28 relH.write(
29 f" LAST = {lastName}\n"
30 "};\n\n"
31 "} // namespace a11y\n"
32 "} // namespace mozilla\n\n"
33 "#endif\n"
37 # For debugging
38 if __name__ == "__main__":
39 import sys
41 generate(sys.stdout, "accessible/interfaces/nsIAccessibleRelation.idl")