-
Notifications
You must be signed in to change notification settings - Fork 314
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
hex: Add from_hex<T> for user types #649
Conversation
98570a9
to
a66d6d5
Compare
include/evmc/hex.hpp
Outdated
|
||
/// Decodes hex-encoded string into custom type T with .bytes array of uint8_t. | ||
/// | ||
/// The decoded bytes are right aligned in case the input is smaller than the result type. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not left aligned?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because they imitate BE numbers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So by right aligned do you mean padded with zeroes on the left?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but left/right does not have clear meaning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the input is smaller than the result type, the result is padded with zeros on the left (the result bytes of lowest indices are filled with zeros).
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a flag for alignment?
Coming from Solidity would prefer left aligned if we are writing into a "bytes" type. But this opinion is not too strong if you only have use cases for right aligned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, an option can be added if needed, but so far this is only used for literals and loading storage values from JSON.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps add // TODO: support left alignment too with a flag
.
4048132
to
508475b
Compare
c0337b9
to
5cec7bd
Compare
Codecov Report
@@ Coverage Diff @@
## master #649 +/- ##
=======================================
Coverage 92.99% 92.99%
=======================================
Files 25 25
Lines 3626 3626
Branches 377 377
=======================================
Hits 3372 3372
Misses 144 144
Partials 110 110 |
9471c85
to
95805a2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps add // TODO: support left alignment too with a flag
.
Depends on #648.