Use rust-phf to map strings to property IDs

This commit is contained in:
Simon Sapin 2016-12-08 14:19:27 -10:00
parent 137e30b825
commit fdc40592de
7 changed files with 50 additions and 36 deletions

View file

@ -33,6 +33,7 @@ def main():
rust = render(template, product=product, data=properties, __file__=template)
if output == "style-crate":
write(os.environ["OUT_DIR"], "properties.rs", rust)
write(os.environ["OUT_DIR"], "static_ids.txt", static_ids(properties))
if product == "gecko":
template = os.path.join(BASE, "gecko.mako.rs")
rust = render(template, data=properties)
@ -69,6 +70,15 @@ def write(directory, filename, content):
open(os.path.join(directory, filename), "wb").write(content)
def static_ids(properties):
return '\n'.join(
"%s\tStaticId::%s(%sId::%s)" % (p.name, kind, kind, p.camel_case)
for kind, props in [("Longhand", properties.longhands),
("Shorthand", properties.shorthands)]
for p in props
)
def write_html(properties):
properties = dict(
(p.name, {