forked from mirrors/gecko-dev
Bug 1896702 - Remove CSS2Properties.webidl.in and place the template directly in GenerateCSS2PropertiesWebIDL.py. r=webidl,emilio
This avoids needing to open a second file in the script, since the template was tiny to begin with. Differential Revision: https://phabricator.services.mozilla.com/D210335
This commit is contained in:
parent
3bf8e4eea0
commit
2e47654dad
3 changed files with 19 additions and 23 deletions
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
import argparse
|
||||
import runpy
|
||||
import string
|
||||
import sys
|
||||
|
||||
# Generates a line of WebIDL with the given spelling of the property name
|
||||
|
|
@ -19,9 +18,22 @@ def generateLine(propName, extendedAttrs):
|
|||
)
|
||||
|
||||
|
||||
def generate(output, idlFilename, dataFile):
|
||||
def generate(output, dataFile):
|
||||
propsData = runpy.run_path(dataFile)["data"]
|
||||
props = ""
|
||||
output.write(
|
||||
"""/* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT */
|
||||
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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 https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
[Exposed=Window]
|
||||
interface CSS2Properties : CSSStyleDeclaration {
|
||||
"""
|
||||
)
|
||||
|
||||
for p in propsData.values():
|
||||
# Skip properties which aren't valid in style rules.
|
||||
if "Style" not in p.rules:
|
||||
|
|
@ -99,27 +111,18 @@ def generate(output, idlFilename, dataFile):
|
|||
newProp = add_extra_accessors(propsData[a])
|
||||
extendedAttrs.append('BindingAlias="%s"' % newProp)
|
||||
|
||||
props += generateLine(prop, extendedAttrs)
|
||||
output.write(generateLine(prop, extendedAttrs))
|
||||
|
||||
idlFile = open(idlFilename, "r")
|
||||
idlTemplate = idlFile.read()
|
||||
idlFile.close()
|
||||
|
||||
output.write(
|
||||
"/* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT */\n\n"
|
||||
+ string.Template(idlTemplate).substitute({"props": props})
|
||||
+ "\n"
|
||||
)
|
||||
output.write("};")
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("idlFilename", help="IDL property file template")
|
||||
parser.add_argument(
|
||||
"preprocessorHeader", help="Header file to pass through the preprocessor"
|
||||
)
|
||||
args = parser.parse_args()
|
||||
generate(sys.stdout, args.idlFilename, args.preprocessorHeader)
|
||||
generate(sys.stdout, args.preprocessorHeader)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
|
|
@ -197,8 +197,5 @@ if CONFIG["COMPILE_ENVIRONMENT"]:
|
|||
"CSS2Properties.webidl",
|
||||
script="GenerateCSS2PropertiesWebIDL.py",
|
||||
entry_point="generate",
|
||||
inputs=[
|
||||
"/dom/webidl/CSS2Properties.webidl.in",
|
||||
"!/layout/style/ServoCSSPropList.py",
|
||||
],
|
||||
inputs=["!/layout/style/ServoCSSPropList.py"],
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,4 +0,0 @@
|
|||
[Exposed=Window]
|
||||
interface CSS2Properties : CSSStyleDeclaration {
|
||||
${props}
|
||||
};
|
||||
Loading…
Reference in a new issue