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

Get rid of unwrap() in the generated code #178

Open
psychon opened this issue Jan 18, 2020 · 0 comments
Open

Get rid of unwrap() in the generated code #178

psychon opened this issue Jan 18, 2020 · 0 comments
Labels
P5 Priority Nice-to-have stable API Things that might require API changes

Comments

@psychon
Copy link
Owner

psychon commented Jan 18, 2020

Most unwrap()s should be replaced with ParseErrors. The cases where this is not possible... need special treatment (at least except() would be better).

@psychon psychon added the P2 Priority Important label Mar 10, 2020
@psychon psychon added P5 Priority Nice-to-have and removed P2 Priority Important labels Mar 28, 2020
psychon added a commit that referenced this issue Jul 25, 2021
Thanks to the previous commits, switch_expr() no longer returns a too
large type. Thus, we can use From instead of TryFrom and remove an
unwrap().

Helps-with: #178
Signed-off-by: Uli Schlachter <psychon@znc.in>
psychon added a commit that referenced this issue Jul 25, 2021
This does the same thing as the previous commit (replacing TryFrom with
From), but in another place. This again saves some unwrap()s.

Note that the generated code most likely now uses From to convert from a
type T to the type T itself, aka a no-op. This is still done on purpose
to make sure that we end up with the correct type. Otherwise, it becomes
to easy to have the wrong type here and then serialise a too large / too
small field.

This commit also made the decision on what type to use a bit more
clever. The code now looks through unary and binary operations and still
picks a type other than u32 if all the sub-expressions have this type.
This is necessary to make XKB's SelectEvents work.

Also, there was a bug in expr_to_str() where it still used u32 for
unary/binary operations even when another type was requested. This
commit fixes that as well.

Helps-with: #178
Signed-off-by: Uli Schlachter <psychon@znc.in>
psychon added a commit that referenced this issue Dec 28, 2022
The only reason that <eventdef> exists in the XML is for xinput. The
generated code for this contained calls to unwrap(). This commit changes
that to pass possible ParseError instances to the caller.

This PR related to #178 ("Get rid of unwrap() in the generated code")
and #49 ("Do something about the results of 'git grep FIXME'").
psychon added a commit that referenced this issue Dec 28, 2022
The only reason that <eventdef> exists in the XML is for xinput. The
generated code for this contained calls to unwrap(). This commit changes
that to pass possible ParseError instances to the caller.

This PR related to #178 ("Get rid of unwrap() in the generated code")
and #49 ("Do something about the results of 'git grep FIXME'").
@psychon psychon added the stable API Things that might require API changes label May 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P5 Priority Nice-to-have stable API Things that might require API changes
Projects
None yet
Development

No branches or pull requests

1 participant