-
Notifications
You must be signed in to change notification settings - Fork 38
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
Labels
Comments
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'").
Open
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Most
unwrap()
s should be replaced withParseError
s. The cases where this is not possible... need special treatment (at leastexcept()
would be better).The text was updated successfully, but these errors were encountered: