-
Notifications
You must be signed in to change notification settings - Fork 721
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
Provide an API to constify enum variants. #393
Conversation
d794345
to
8183e61
Compare
A question: may I do /// <div rustbindgen constant></div>
eCSSProperty_COUNT, rather than adding it after? I'm concerned about exceeding 80 chars limitation in Gecko code... Also, is it possible to apply |
I don't think you can do that because doxygen thinks that kind of comment is a comment for the whole enum and applies them to every following item. I've added a programmatic API that you could also use from the build script though (see the type_chooser API). |
Regarding |
I guess you can change |
Heh, was writing that right now :) What do you think about the last commit? |
Looking at the (previously) last commit, I wonder do we really need to try that hard to add enum variant? I don't see much usefulness from doing so. I think we can simply not add constified items to enum variants, which should simplify the code logic. |
Oh, ignore my last comment. I suddently realize that you have to add enum variant anyway, because otherwise that constant wouldn't be referring to an enum variant. |
@upsuper consider the following: enum Foo {
A = 1,
B = 10, /**< <div rustbindgen constant></div> */
}; If I do that (avoid adding constified items), two things happen. First, they wouldn't have same type (we'd need to make the const an integer or whatever). Second, rust's optimizations may kick in with disastrous consequences (a la #225). We could enforce |
Oh, didn't read your other comment (had my browser window open). |
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.
r=me with the nits addressed.
|
||
while iter.peek().is_some() || !constified_variants.is_empty() { | ||
let variant = iter.next() | ||
.unwrap_or_else(|| constified_variants.remove(0)); |
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.
You can probably use VecDeque
instead of Vec
for constified_variants
, and change the three lines above to something like
while let Some(variant) = iter.next().or_else(|| constified_variants.pop_front()) {
// ...
}
/// You can see the kind of comments that are accepted in the Doxygen | ||
/// documentation: | ||
/// | ||
/// http://www.stack.nl/~dimitri/doxygen/manual/docblocks.html |
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.
The last paragraph as well as the link doesn't seem to be something specific to this field. Probably this is comment which should be added to the Annotation
struct.
Also, hide
now supports enum variants in addition to types, which should be mentioned in the document of that field.
Signed-off-by: Emilio Cobos Álvarez <[email protected]>
cbbd9be
to
fee7e96
Compare
Nice catches :) @bors-servo r=upsuper |
📌 Commit fee7e96 has been approved by |
Provide an API to constify enum variants. r? @upsuper
☀️ Test successful - status-travis |
r? @upsuper