dom/bindings/GenerateCSS2PropertiesWebIDL.py

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/bindings/GenerateCSS2PropertiesWebIDL.py	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,35 @@
     1.4 +# This Source Code Form is subject to the terms of the Mozilla Public
     1.5 +# License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.6 +# You can obtain one at http://mozilla.org/MPL/2.0/.
     1.7 +
     1.8 +import sys
     1.9 +import string
    1.10 +
    1.11 +propList = eval(sys.stdin.read())
    1.12 +props = ""
    1.13 +for [prop, id, flags, pref] in propList:
    1.14 +    extendedAttrs = ["Throws", "TreatNullAs=EmptyString"]
    1.15 +    # To limit the overhead of Func= annotations, we only generate them when
    1.16 +    # necessary, which is when the
    1.17 +    # CSS_PROPERTY_ALWAYS_ENABLED_IN_CHROME_OR_CERTIFIED_APP flag is set.
    1.18 +    # Otherwise, we try to get by with just a Pref= annotation or no annotation
    1.19 +    # at all.
    1.20 +    if "CSS_PROPERTY_ALWAYS_ENABLED_IN_CHROME_OR_CERTIFIED_APP" in flags:
    1.21 +        extendedAttrs.append('Func="IsCSSPropertyExposedToJS<eCSSProperty_%s>"' % id)
    1.22 +    # The following is an 'elif' because it is the responsibility of
    1.23 +    # IsCSSPropertyExposedToJS to handle the pref if there is one.
    1.24 +    elif pref is not "":
    1.25 +        extendedAttrs.append('Pref="%s"' % pref)
    1.26 +    if not prop.startswith("Moz"):
    1.27 +        prop = prop[0].lower() + prop[1:]
    1.28 +    # Unfortunately, even some of the getters here are fallible
    1.29 +    # (e.g. on nsComputedDOMStyle).
    1.30 +    props += "  [%s] attribute DOMString %s;\n" % (", ".join(extendedAttrs),
    1.31 +                                                   prop)
    1.32 +
    1.33 +idlFile = open(sys.argv[1], "r");
    1.34 +idlTemplate = idlFile.read();
    1.35 +idlFile.close();
    1.36 +
    1.37 +print ("/* THIS IS AN AUTOGENERATED FILE.  DO NOT EDIT */\n\n" +
    1.38 +       string.Template(idlTemplate).substitute({ "props": props }))

mercurial