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/.
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
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]
29 f
" LAST = {lastName}\n"
31 "} // namespace a11y\n"
32 "} // namespace mozilla\n\n"
38 if __name__
== "__main__":
41 generate(sys
.stdout
, "accessible/interfaces/nsIAccessibleRelation.idl")