Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace common python-generated Rust code with equivalent hand-written code #31570

Open
1 task
jdm opened this issue Mar 7, 2024 · 1 comment
Open
1 task
Labels
A-content/bindings The DOM bindings B-meta This issue tracks the status of multiple, related pieces of work I-refactor No impact; the issue is one of maintainability or tidiness. Proposed solution requires refactoring.

Comments

@jdm
Copy link
Member

jdm commented Mar 7, 2024

We have a lot of Rust code that is generated at build time for each DOM interface. The code that generates it lives in https://github.com/servo/servo/blob/main/components/script/dom/bindings/codegen/CodegenRust.py. This file is very large and complicated to follow, so the tasks linked in this meta issue are designed to remove unnecessary complexity.

There are many methods in the generated Rust code that are virtually identical for many DOM interfaces. Rather than making the compiler parse and compile all that duplicated code, we should extract the code into generic functions that are called by the generated code instead.

#31569 is a model of how this extraction can be performed. It's recommended to find sample generated code under target/debug/build/script-[whatever]/out/Bindings/ so it's easier to understand the actual types of arguments in the functions being rewritten.

Tasks:

@jdm jdm added A-content/bindings The DOM bindings I-refactor No impact; the issue is one of maintainability or tidiness. Proposed solution requires refactoring. B-meta This issue tracks the status of multiple, related pieces of work labels Mar 7, 2024
@Taym95
Copy link
Contributor

Taym95 commented Mar 8, 2024

This is really helpful especially on what we are doing in #30862

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-content/bindings The DOM bindings B-meta This issue tracks the status of multiple, related pieces of work I-refactor No impact; the issue is one of maintainability or tidiness. Proposed solution requires refactoring.
Projects
None yet
Development

No branches or pull requests

2 participants