mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
script codegen: Avoid modifying in-place a generated file.
This commit is contained in:
parent
71fb02953c
commit
0b9ff576e0
5 changed files with 29 additions and 34 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue