Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upTest generation for Servo_* bindings in `components/style/gecko_bindings/bindings.rs` #13603
Conversation
highfive
commented
Oct 5, 2016
|
Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @SimonSapin (or someone else) soon. |
highfive
commented
Oct 5, 2016
|
Heads up! This PR modifies the following files:
|
highfive
commented
Oct 5, 2016
|
r? @wafflespeanut for the python bits. |
| tests.write("}\n") | ||
|
|
||
| bindings.close() | ||
| tests.close() |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| /* 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/. */ | ||
|
|
This comment has been minimized.
This comment has been minimized.
emilio
Oct 5, 2016
Member
You'll need to include this module somewhere, otherwise it wont be compiled. And you'll need to generate the relevant use statements too.
A line like:
mod test_bindings;in gecko_bindings/lib.rs would suffice for the first part.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Manishearth
Oct 6, 2016
Member
We don't want to include it in gecko_bindings, we want to include (include!(), not pub mod) it in tests/unit/stylo. The glue functions don't get defined till later. I plan on doing this myself later.
This comment has been minimized.
This comment has been minimized.
Rafagd
Oct 6, 2016
Author
Contributor
Should I move the script back to the same folder as 'bindings.rs`?
This comment has been minimized.
This comment has been minimized.
|
|
||
| tests.write("/* This Source Code Form is subject to the terms of the Mozilla Public\n") | ||
| tests.write(" * License, v. 2.0. If a copy of the MPL was not distributed with this\n") | ||
| tests.write(" * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n\n") |
This comment has been minimized.
This comment has been minimized.
emilio
Oct 5, 2016
Member
A warning about the file being an autogenerated file would be nice as well :)
This comment has been minimized.
This comment has been minimized.
emilio
Oct 5, 2016
Member
Probably also maybe making the destination file components/style/generated/check_bindings.rs would be helpful, in addition to that.
In that case, you'll need to do something like:
#[path = "path/to/generated/check_bindings.rs"]
mod check_bindings;Also, please hook this to the components/style/binding_tools/regen.py script, the same way that regen_atoms.py is hooked in, and ideally put this script in that directory too :)
Thanks for doing this!
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Manishearth
Oct 6, 2016
Member
You did the hooking up to regen correctly
As I said elsewhere, don't worry about including it as a mod just yet.
|
|
||
| def build(objdir, verbose=False): | ||
| with open(objdir + "/bindings.rs", "r") as bindings: | ||
| with open(objdir + "/check_bindings.rs", "w+") as tests: |
This comment has been minimized.
This comment has been minimized.
| import re | ||
|
|
||
| def build(objdir, verbose=False): | ||
| with open(objdir+"/bindings.rs", "r") as bindings: |
This comment has been minimized.
This comment has been minimized.
emilio
Oct 5, 2016
Member
You don't need the objdir here. you should be able to get the current script directory (with os.path.dirname(os.path.abspath(__file__)), or passing TOOLS_DIR as an argument), and arrive into the bindings.rs file.
I think you can test that with ./regen.py --target check_bindings /dummy/path/since/it/wont/be/used
This comment has been minimized.
This comment has been minimized.
| @@ -2,24 +2,5 @@ | |||
| * 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/. */ | |||
|
|
|||
This comment has been minimized.
This comment has been minimized.
Manishearth
Oct 6, 2016
Member
This file should be unchanged. check_bindings.rs is not actually going to be used in this crate, so you don't need a mod for it
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Rafagd
Oct 6, 2016
Author
Contributor
Moved the script back to the same folder bindings.rs is, added the generated file there, and removed the changes to files that should not have been changed.
|
|
||
|
|
||
| def build(objdir, verbose=False): | ||
| with open(objdir + "/bindings.rs", "r") as bindings: |
This comment has been minimized.
This comment has been minimized.
Manishearth
Oct 6, 2016
Member
You shouldn't be using the objdir here, you should be using local paths. The objdir is pointed to where gecko headers live.
This comment has been minimized.
This comment has been minimized.
Rafagd
Oct 6, 2016
Author
Contributor
When you say local paths, do you mean just open("bindings.rs", "r") as if they were in the same folder, or open("components/style/gecko_bindings/bindings.rs", "r")?
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Manishearth
Oct 6, 2016
Member
I think this should be ../gecko_bindings/bindings.rs?
I meant "Assume it is being run from the same dir that contains the script"
| /* 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/. */ | ||
|
|
This comment has been minimized.
This comment has been minimized.
Manishearth
Oct 6, 2016
Member
We don't want to include it in gecko_bindings, we want to include (include!(), not pub mod) it in tests/unit/stylo. The glue functions don't get defined till later. I plan on doing this myself later.
|
Sorry about the confusion wrt including the mod. |
|
As far as using this file, it should be used via a new module in
I didn't ask for this to be done in this PR because I suspect there will be some errors that need fixing and I didn't want to extend the scope of the issue to that. The changes I requested right now should be enough. |
| tests.write("/* This Source Code Form is subject to the terms of the Mozilla Public\n") | ||
| tests.write(" * License, v. 2.0. If a copy of the MPL was not distributed with this\n") | ||
| tests.write(" * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n\n") | ||
| tests.write("/* automatically generated by check_bindings.py. */\n\n") |
This comment has been minimized.
This comment has been minimized.
wafflespeanut
Oct 6, 2016
Member
This should be put into a global name (like, LICENSE) on the top of the file.
|
|
||
| def build(objdir, verbose=False): | ||
| with open(objdir + "/bindings.rs", "r") as bindings: | ||
| with open(objdir + "/check_bindings.rs", "w+") as tests: |
This comment has been minimized.
This comment has been minimized.
wafflespeanut
Oct 6, 2016
•
Member
Instead of nesting inside, this could be joined as
with open(...) as bindings, open(...) as tests:Also, as @aneeshusa said, it's a better idea to join the paths instead of hardcoding them, and put the paths in the top of the file, like BINDINGS_FILE, BINDINGS_CHECK_FILE, etc.
This comment has been minimized.
This comment has been minimized.
| if match: | ||
| tests.write(" [ Servo_" + match.group(1) + ", bindings::Servo_" + match.group(1) + " ];\n") | ||
|
|
||
| tests.write("}\n") |
This comment has been minimized.
This comment has been minimized.
wafflespeanut
Oct 6, 2016
Member
Instead, we could have a template for this above, like
TEMPLATE = '''
[ Servo_{name}, bindings::Servo_{name} ];
'''and format it every time we find a match.
|
|
||
| import re | ||
|
|
||
| LICENSE = """/* This Source Code Form is subject to the terms of the Mozilla Public |
This comment has been minimized.
This comment has been minimized.
aneeshusa
Oct 6, 2016
Member
Do
LICENSE = """\
/* This Source Code
...
"""
at the beginning instead, as it keeps the license block formatted as usual.
This comment has been minimized.
This comment has been minimized.
Rafagd
Oct 6, 2016
Author
Contributor
Wouldn't that add a \n at the start of the generated file? Or the \ removes the \n from the resulting string?
This comment has been minimized.
This comment has been minimized.
aneeshusa
Oct 6, 2016
Member
Yes, \ followed by a newline is an escape sequence that is ignored/skipped by Python, so the resulting string won't have a leading newline.
Try it out in a small test file!
| # 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/. | ||
|
|
This comment has been minimized.
This comment has been minimized.
Manishearth
Oct 6, 2016
Member
Uh, sorry for the confusion again.
To be clear: check_bindings.py belongs in binding_tools. The generated file belongs in gecko_bindings.
This comment has been minimized.
This comment has been minimized.
Manishearth
Oct 6, 2016
Member
Aside from this everything else looks good! r=me once this file is moved.
This comment has been minimized.
This comment has been minimized.
|
Once done, please squash your commits together. |
… to that fragment. Otherwise we might mix writing modes. Not totally sure this change is correct in the case we're mixing them, we might need to just not checking that operation.
…lement.rs
It can be retrieved through its init field.
This uses a (very simple) Win32 API call to enumerate font families available, and load them as byte buffers. The font rasterization itself is done by freetype. This gets Servo + WR + Windows working, but should be improved by adding a proper implementation that matches fonts correctly and also uses DirectWrite (or GDI) to handle font rasterization.
…istener
|
I'm closing this request and making a new one. |
|
You can just squash the commits via rebase and force-push to the same branch, no need to close the PR |
|
I did something wrong during the rebase and merged a bunch of unrelated stuff to this PR. |
Script-generated tests for Servo_* gecko bindings All changes done in #13603, but this time I understand why I should have created a branch instead of doing everything on master. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #13598 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because `they are tests`. <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13617) <!-- Reviewable:end -->
Script-generated tests for Servo_* gecko bindings All changes done in #13603, but this time I understand why I should have created a branch instead of doing everything on master. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #13598 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because `they are tests`. <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13617) <!-- Reviewable:end -->
Script-generated tests for Servo_* gecko bindings All changes done in #13603, but this time I understand why I should have created a branch instead of doing everything on master. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #13598 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because `they are tests`. <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13617) <!-- Reviewable:end -->
…gs (from Rafagd:my_changes); r=Manishearth All changes done in servo/servo#13603, but this time I understand why I should have created a branch instead of doing everything on master. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #13598 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because `they are tests`. <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 03cd936639905e4c980ee706f4ee8f0f35de5180
…gs (from Rafagd:my_changes); r=Manishearth All changes done in servo/servo#13603, but this time I understand why I should have created a branch instead of doing everything on master. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #13598 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because `they are tests`. <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 03cd936639905e4c980ee706f4ee8f0f35de5180 UltraBlame original commit: 1cf764acd99a05d75440bfa73b1a32b12c1cf4ee
…gs (from Rafagd:my_changes); r=Manishearth All changes done in servo/servo#13603, but this time I understand why I should have created a branch instead of doing everything on master. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #13598 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because `they are tests`. <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 03cd936639905e4c980ee706f4ee8f0f35de5180 UltraBlame original commit: 1cf764acd99a05d75440bfa73b1a32b12c1cf4ee
…gs (from Rafagd:my_changes); r=Manishearth All changes done in servo/servo#13603, but this time I understand why I should have created a branch instead of doing everything on master. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #13598 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because `they are tests`. <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 03cd936639905e4c980ee706f4ee8f0f35de5180 UltraBlame original commit: 1cf764acd99a05d75440bfa73b1a32b12c1cf4ee
Rafagd commentedOct 5, 2016
•
edited
Added a python script that takes all Servo_* bindings generated in
components/style/gecko_bindings/bindings.rsand generates a new test file that checks if they all have the same signature as the bindings onports/geckolib/glue.rs.Issue asks for both files to be created at the same folder
components/style/gecko_bindings/bindings.rsis located.#13598
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsthey are tests.This change is