diff options
author | Rafael Gomes Dantas <rafagd@gmail.com> | 2016-10-06 16:18:54 +0100 |
---|---|---|
committer | Rafael Gomes Dantas <rafagd@gmail.com> | 2016-10-06 16:18:54 +0100 |
commit | 5be551e10ee322abca0e19dbe535a9ddbcfa488f (patch) | |
tree | 8835de068c43cddfa90a9f09a1e50291e5962251 /components/style/binding_tools | |
parent | 6bd898626fa65ad1382e101ed9af8a5fcfde19e2 (diff) | |
download | servo-5be551e10ee322abca0e19dbe535a9ddbcfa488f.tar.gz servo-5be551e10ee322abca0e19dbe535a9ddbcfa488f.zip |
Script-generated tests for Servo_* gecko bindings
Diffstat (limited to 'components/style/binding_tools')
-rw-r--r-- | components/style/binding_tools/check_bindings.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/components/style/binding_tools/check_bindings.py b/components/style/binding_tools/check_bindings.py new file mode 100644 index 00000000000..67a8f6de175 --- /dev/null +++ b/components/style/binding_tools/check_bindings.py @@ -0,0 +1,37 @@ +# 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/. + +import os +import re + +LICENSE = """\ +/* 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/. */ + +/* automatically generated by check_bindings.py. */ + +""" + +BINDINGS_PATH = os.path.join("..", "gecko_bindings") +INPUT_FILE = os.path.join(BINDINGS_PATH, "bindings.rs") +OUTPUT_FILE = os.path.join(BINDINGS_PATH, "check_bindings.rs") + +TEMPLATE = """\ + [ Servo_{name}, bindings::Servo_{name} ]; +""" + +with open(INPUT_FILE, "r") as bindings, open(OUTPUT_FILE, "w+") as tests: + tests.write(LICENSE) + tests.write("fn assert_types() {\n") + + pattern = re.compile("fn\s*Servo_([_a-zA-Z0-9]+)\s*\(") + + for line in bindings: + match = pattern.search(line) + + if match: + tests.write(TEMPLATE.format(name=match.group(1))) + + tests.write("}\n") |