|
1 # This Source Code Form is subject to the terms of the Mozilla Public |
|
2 # License, v. 2.0. If a copy of the MPL was not distributed with this file, |
|
3 # You can obtain one at http://mozilla.org/MPL/2.0/. |
|
4 |
|
5 import sys |
|
6 import string |
|
7 |
|
8 propList = eval(sys.stdin.read()) |
|
9 props = "" |
|
10 for [prop, id, flags, pref] in propList: |
|
11 extendedAttrs = ["Throws", "TreatNullAs=EmptyString"] |
|
12 # To limit the overhead of Func= annotations, we only generate them when |
|
13 # necessary, which is when the |
|
14 # CSS_PROPERTY_ALWAYS_ENABLED_IN_CHROME_OR_CERTIFIED_APP flag is set. |
|
15 # Otherwise, we try to get by with just a Pref= annotation or no annotation |
|
16 # at all. |
|
17 if "CSS_PROPERTY_ALWAYS_ENABLED_IN_CHROME_OR_CERTIFIED_APP" in flags: |
|
18 extendedAttrs.append('Func="IsCSSPropertyExposedToJS<eCSSProperty_%s>"' % id) |
|
19 # The following is an 'elif' because it is the responsibility of |
|
20 # IsCSSPropertyExposedToJS to handle the pref if there is one. |
|
21 elif pref is not "": |
|
22 extendedAttrs.append('Pref="%s"' % pref) |
|
23 if not prop.startswith("Moz"): |
|
24 prop = prop[0].lower() + prop[1:] |
|
25 # Unfortunately, even some of the getters here are fallible |
|
26 # (e.g. on nsComputedDOMStyle). |
|
27 props += " [%s] attribute DOMString %s;\n" % (", ".join(extendedAttrs), |
|
28 prop) |
|
29 |
|
30 idlFile = open(sys.argv[1], "r"); |
|
31 idlTemplate = idlFile.read(); |
|
32 idlFile.close(); |
|
33 |
|
34 print ("/* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT */\n\n" + |
|
35 string.Template(idlTemplate).substitute({ "props": props })) |