-
Notifications
You must be signed in to change notification settings - Fork 124
[ur][common] pretty printing for props #411
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
Author
|
Example output for |
igchor
reviewed
Apr 4, 2023
Many UR functions use enum tags alongside opaque (typically void *) pointers to construct an algebraic data type. This is useful because it allows for creating function arguments that can be one of several types of values. However, this approach, at least in C, is not very typesafe. It's fairly easy to make a mistake that can't be easily caught at compile time (and even at runtime). To help with that a little bit, at least on the spec side of things, this patch introduces optional 'typed_etor' and 'typename' qualifiers. An enum with typed etor requires that all its values have specify a type in their 'desc' field. The typename can be used to tag opaque pointers with a tag field name. Typed_etors are checked by codegen scripts, whereas correctness of typenames is indirectly enforced by the code itself (won't compile if it's wrong).
d6aa9bf to
66f1757
Compare
This patch uses the typed etors and typename information to pretty print `*_info_t` prop names, which otherwise are opaque pointers.
66f1757 to
9b7e2b2
Compare
Contributor
Author
|
This is annoying to rebase and breaks with almost every UR change, so I'd appreciate a prompt review. |
igchor
approved these changes
Apr 13, 2023
Contributor
Author
|
@kbenzie I'm changing the spec format a little bit (described in YAML.md), can you take a look at those changes? |
kbenzie
approved these changes
Apr 18, 2023
Contributor
kbenzie
left a comment
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.
LGTM
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[ur] introduce enum associated types and use it for props
Many UR functions use enum tags alongside opaque (typically void *)
pointers to construct an algebraic data type. This is useful because
it allows for creating function arguments that can be one of
several types of values. However, this approach, at least in C,
is not very typesafe. It's fairly easy to make a mistake that
can't be easily caught at compile time (and even at runtime).
To help with that a little bit, at least on the spec side of things,
this patch introduces optional 'typed_etor' and 'typename' qualifiers.
An enum with typed etor requires that all its values have specify
a type in their 'desc' field. The typename can be used to tag
opaque pointers with a tag field name.
Typed_etors are checked by codegen scripts, whereas correctness
of typenames is indirectly enforced by the code itself (won't compile
if it's wrong).
[common] use associated type information to serialize info_t types
This patch uses the typed etors and typename information to pretty
print
*_info_tprop names, which otherwise are opaque pointers.