aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/codegen/CodegenRust.py
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2017-01-19 17:13:35 +0100
committerSimon Sapin <simon.sapin@exyr.org>2017-01-19 17:13:35 +0100
commit0b9ff576e0ad35c75440ea4953b28fef7f5af4df (patch)
tree5f8b52cb8d06a7f4b79e5417c2c2d0cde1491a3c /components/script/dom/bindings/codegen/CodegenRust.py
parent71fb02953c2acedf30bc2a09eab68a6c2f682e13 (diff)
downloadservo-0b9ff576e0ad35c75440ea4953b28fef7f5af4df.tar.gz
servo-0b9ff576e0ad35c75440ea4953b28fef7f5af4df.zip
script codegen: Avoid modifying in-place a generated file.
Diffstat (limited to 'components/script/dom/bindings/codegen/CodegenRust.py')
-rw-r--r--components/script/dom/bindings/codegen/CodegenRust.py25
1 files changed, 14 insertions, 11 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py
index f531937d05e..2994734751e 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -6815,6 +6815,15 @@ class GlobalGenRoots():
], "\n")), pre="pub flags Globals: u8 {\n", post="\n}")
globals_ = CGWrapper(CGIndenter(global_flags), pre="bitflags! {\n", post="\n}")
+ phf = CGGeneric("include!(concat!(env!(\"OUT_DIR\"), \"/InterfaceObjectMapPhf.rs\"));")
+
+ return CGList([
+ CGGeneric(AUTOGENERATED_WARNING_COMMENT),
+ CGList([imports, globals_, phf], "\n\n")
+ ])
+
+ @staticmethod
+ def InterfaceObjectMapData(config):
pairs = []
for d in config.getDescriptors(hasInterfaceObject=True, isInline=False):
binding = toBindingNamespace(d.name)
@@ -6823,19 +6832,13 @@ class GlobalGenRoots():
pairs.append((ctor.identifier.name, binding, binding))
pairs.sort(key=operator.itemgetter(0))
mappings = [
- CGGeneric('b"%s" => codegen::Bindings::%s::%s::DefineDOMInterface as unsafe fn(_, _),' % pair)
+ CGGeneric('"%s": "codegen::Bindings::%s::%s::DefineDOMInterface as unsafe fn(_, _)"' % pair)
for pair in pairs
]
- mapType = "phf::Map<&'static [u8], unsafe fn(*mut JSContext, HandleObject)>"
- phf = CGWrapper(
- CGIndenter(CGList(mappings, "\n")),
- pre="pub static MAP: %s = phf_map! {\n" % mapType,
- post="\n};\n")
-
- return CGList([
- CGGeneric(AUTOGENERATED_WARNING_COMMENT),
- CGList([imports, globals_, phf], "\n\n")
- ])
+ return CGWrapper(
+ CGList(mappings, ",\n"),
+ pre="{\n",
+ post="\n}\n")
@staticmethod
def PrototypeList(config):