Quelle GenerateCSSPropsGenerated.py
Sprache: Python
# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this file, # You can obtain one at http://mozilla.org/MPL/2.0/.
def generate(output, dataFile):
output.write( """/* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT */
/* processed file that defines CSS property tables that can't be generated with the pre-processor, designed to be #included in nsCSSProps.cpp */
"""
)
raw_properties = runpy.run_path(dataFile)["data"]
properties = [
PropertyWrapper(i, p) for i, p in enumerate(raw_properties.values()) if p.type() != "alias"
]
# Generate kIDLNameTable
output.write( "const char* const nsCSSProps::""kIDLNameTable[eCSSProperty_COUNT] = {\n"
) for p in properties: if p.idlname isNone:
output.write(" nullptr, // {}\n".format(p.name)) else:
output.write(' "{}",\n'.format(p.idlname))
output.write("};\n\n")
# Generate kIDLNameSortPositionTable
ps = sorted(properties, key=lambda p: p.idlname if p.idlname else"")
ps = [(p, position) for position, p in enumerate(ps)]
ps.sort(key=lambda item: item[0].index)
output.write( "const int32_t nsCSSProps::" "kIDLNameSortPositionTable[eCSSProperty_COUNT] = {\n"
) for p, position in ps:
output.write(" {},\n".format(position))
output.write("};\n\n")
# Generate shorthand subprop tables
names = [] for p in properties: if p.type() != "shorthand": continue
name = "g{}SubpropTable".format(p.method)
names.append(name)
output.write("static const nsCSSPropertyID {}[] = {{\n".format(name)) for subprop in p.subprops:
output.write(" eCSSProperty_{},\n".format(subprop))
output.write(" eCSSProperty_UNKNOWN\n")
output.write("};\n\n")
output.write("const nsCSSPropertyID* const\n")
output.write( "nsCSSProps::kSubpropertyTable[" "eCSSProperty_COUNT - eCSSProperty_COUNT_no_shorthands" "] = {\n"
) for name in names:
output.write(" {},\n".format(name))
output.write("};\n\n")
# Generate assertions
msg = ( "GenerateCSSPropsGenerated.py did not list properties " "in nsCSSPropertyID order"
) for p in properties:
output.write( 'static_assert(eCSSProperty_{} == {}, "{}");\n'.format(p.id, p.index, msg)
)
Messung V0.5
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.