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

Generate wrappers #623

Merged
merged 8 commits into from
Jun 15, 2021
Merged

Generate wrappers #623

merged 8 commits into from
Jun 15, 2021

Conversation

psychon
Copy link
Owner

@psychon psychon commented Jun 15, 2021

Right now the XID wrappers are mostly hand-written. The macro helps a lot, but this is still too much.

This PR moves them into the code generator. The code generator has all necessary information to also generate the "create" function (like create_window). This makes adding new types a lot easier.

Future work:

Somewhere on my todo list is to extend this to also cover all the extensions. However, that's a bit tedious, because the XML does not provide this information (see #589). I already went through the extensions and marked stuff as "this looks like it creates an object that should be freed", but since I do not know most extensions, I want to double check against the various specs that I got this right.

psychon added 7 commits June 13, 2021 16:42
RandR has its own Connection type, so the import had to be renamed. :-(

Signed-off-by: Uli Schlachter <[email protected]>
Signed-off-by: Uli Schlachter <[email protected]>
@psychon psychon force-pushed the generate-wrappers branch from e9f20c1 to 8f02c95 Compare June 15, 2021 14:58
error: unnecessary `if let` since only the `Some` variant of the iterator element is used
   --> generator/src/generator/namespace/resource_wrapper.rs:98:9
    |
98  |           for create_request in info.create_requests.iter() {
    |           ^                     --------------------------- help: try: `info.create_requests.iter().flatten()`
    |  _________|
    | |
99  | |             if let Some(request) = create_request {
100 | |                 generate_creator(
101 | |                     generator,
...   |
108 | |             }
109 | |         }
    | |_________^
    |
    = note: `-D clippy::manual-flatten` implied by `-D warnings`
help: ...and remove the `if let` statement in the for loop
   --> generator/src/generator/namespace/resource_wrapper.rs:99:13
    |
99  | /             if let Some(request) = create_request {
100 | |                 generate_creator(
101 | |                     generator,
102 | |                     out,
...   |
107 | |                 );
108 | |             }
    | |_____________^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_flatten

error: aborting due to previous error

Signed-off-by: Uli Schlachter <[email protected]>
@mergify mergify bot merged commit c487f7d into master Jun 15, 2021
@mergify mergify bot deleted the generate-wrappers branch June 15, 2021 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants