mirror of
https://github.com/servo/servo.git
synced 2025-09-23 05:10:09 +01:00
script_bindings(python): Handle WebIDL methods named with Rust keywords (#39343)
Some WebIDL methods, attributes and dictionary members are named with Rust keywords such as `type`, `use` and `continue`. Using those identifiers directly in the generated Rust code would cause compilation errors. The code generator already addresses this issue for attributes and dictionary members by adding a `_` suffix to the conflicting identifiers, but does not yet apply the same treatment to methods. This patch extends the handling to methods as well. Fixes: #39286 Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
This commit is contained in:
parent
8c50c44942
commit
e3818a33c0
1 changed files with 3 additions and 3 deletions
|
@ -3045,7 +3045,7 @@ class CGAbstractMethod(CGThing):
|
||||||
extra_decorators: list[str] = []) -> None:
|
extra_decorators: list[str] = []) -> None:
|
||||||
CGThing.__init__(self)
|
CGThing.__init__(self)
|
||||||
self.descriptor = descriptor
|
self.descriptor = descriptor
|
||||||
self.name = name
|
self.name = CGDictionary.makeMemberName(name)
|
||||||
self.returnType = returnType
|
self.returnType = returnType
|
||||||
self.args = args
|
self.args = args
|
||||||
self.alwaysInline = alwaysInline
|
self.alwaysInline = alwaysInline
|
||||||
|
@ -4805,7 +4805,7 @@ class CGMemberJITInfo(CGThing):
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
""",
|
""",
|
||||||
opValue=f"Some({opName}::<D>)",
|
opValue=f"Some({CGDictionary.makeMemberName(opName)}::<D>)",
|
||||||
name=self.descriptor.name,
|
name=self.descriptor.name,
|
||||||
depth=str(self.descriptor.interface.inheritanceDepth()),
|
depth=str(self.descriptor.interface.inheritanceDepth()),
|
||||||
opType=opType,
|
opType=opType,
|
||||||
|
@ -5137,7 +5137,7 @@ class CGStaticMethodJitinfo(CGGeneric):
|
||||||
pub(crate) fn init_{method.identifier.name}_methodinfo<D: DomTypes>() {{
|
pub(crate) fn init_{method.identifier.name}_methodinfo<D: DomTypes>() {{
|
||||||
{method.identifier.name}_methodinfo.set(JSJitInfo {{
|
{method.identifier.name}_methodinfo.set(JSJitInfo {{
|
||||||
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {{
|
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {{
|
||||||
staticMethod: Some({method.identifier.name}::<D>)
|
staticMethod: Some({CGDictionary.makeMemberName(method.identifier.name)}::<D>)
|
||||||
}},
|
}},
|
||||||
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {{
|
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {{
|
||||||
protoID: PrototypeList::ID::Last as u16,
|
protoID: PrototypeList::ID::Last as u16,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue