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(roleH
, roleIdl
):
11 input = open(roleIdl
, "rt").read()
12 roles
= re
.findall(r
"const unsigned long ROLE_([A-Z_]+) = (\d+);", input)
15 "/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */\n"
16 "/* Roles are defined in accessible/interfaces/nsIAccessibleRole.idl */\n\n"
18 "#define _role_h_\n\n"
19 "namespace mozilla {\n"
21 "namespace roles {\n\n"
24 for name
, num
in roles
:
25 roleH
.write(f
" {name} = {num},\n")
26 lastName
= roles
[-1][0]
28 f
" LAST_ROLE = {lastName}\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"
39 if __name__
== "__main__":
42 generate(sys
.stdout
, "accessible/interfaces/nsIAccessibleRole.idl")