michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: # You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: import sys michael@0: import string michael@0: michael@0: propList = eval(sys.stdin.read()) michael@0: props = "" michael@0: for [prop, id, flags, pref] in propList: michael@0: extendedAttrs = ["Throws", "TreatNullAs=EmptyString"] michael@0: # To limit the overhead of Func= annotations, we only generate them when michael@0: # necessary, which is when the michael@0: # CSS_PROPERTY_ALWAYS_ENABLED_IN_CHROME_OR_CERTIFIED_APP flag is set. michael@0: # Otherwise, we try to get by with just a Pref= annotation or no annotation michael@0: # at all. michael@0: if "CSS_PROPERTY_ALWAYS_ENABLED_IN_CHROME_OR_CERTIFIED_APP" in flags: michael@0: extendedAttrs.append('Func="IsCSSPropertyExposedToJS"' % id) michael@0: # The following is an 'elif' because it is the responsibility of michael@0: # IsCSSPropertyExposedToJS to handle the pref if there is one. michael@0: elif pref is not "": michael@0: extendedAttrs.append('Pref="%s"' % pref) michael@0: if not prop.startswith("Moz"): michael@0: prop = prop[0].lower() + prop[1:] michael@0: # Unfortunately, even some of the getters here are fallible michael@0: # (e.g. on nsComputedDOMStyle). michael@0: props += " [%s] attribute DOMString %s;\n" % (", ".join(extendedAttrs), michael@0: prop) michael@0: michael@0: idlFile = open(sys.argv[1], "r"); michael@0: idlTemplate = idlFile.read(); michael@0: idlFile.close(); michael@0: michael@0: print ("/* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT */\n\n" + michael@0: string.Template(idlTemplate).substitute({ "props": props }))