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

Generate impl blocks for associated enum functions #991

Merged
merged 26 commits into from
Dec 7, 2020
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
bfb0a2d
Fix clippy::search_is_some
MarijnS95 Nov 25, 2020
a639364
Fix clippy::unnecessary_wraps
MarijnS95 Nov 25, 2020
e54e73f
env: Remove unnecessary `if` from main_sys_crate_name
MarijnS95 Nov 22, 2020
18d4a54
special_functions: Perform argument and ret validation on to_string
MarijnS95 Nov 30, 2020
68e4c73
special_functions: Rename ToString after the trait it impls: Display
MarijnS95 Nov 30, 2020
0f554d7
codegen/parameter: Do not pass ByRef::None as reference
MarijnS95 Nov 15, 2020
354c580
Remove unnecessary main_sys_crate_name imports
MarijnS95 Dec 5, 2020
ef8c22b
Generate associated functions for enums
MarijnS95 Aug 29, 2020
9bc5f6e
enum: all imports should go to one Imports as it's one file
MarijnS95 Aug 30, 2020
841582f
Only generate enum functions if >=1 function
MarijnS95 Sep 11, 2020
6e89f56
imports: Add support for multiple, lazily added declared symbols
MarijnS95 Nov 14, 2020
50cee9e
enums: Move rejection and glib imports from codegen to analysis
MarijnS95 Nov 14, 2020
70eab37
codegen/enums: Add missing trait_impls::generate call
MarijnS95 Nov 15, 2020
3023445
analysis/enums: Treat first function parameter as instance
MarijnS95 Nov 15, 2020
7123280
codegen: Add version condition on special function traits
MarijnS95 Nov 15, 2020
c3e827f
enums: Generate special to_str for static functions
MarijnS95 Nov 18, 2020
37366a2
enums: Do not inherit InfoBase to get rid of unused imports
MarijnS95 Nov 21, 2020
6a43595
analysis: Move enum discovery out of generic analyze() function
MarijnS95 Nov 21, 2020
e549975
Copypaste enum analysis and function generation to bitfield
MarijnS95 Nov 21, 2020
518d277
codegen/flags: Add missing display trait generation
MarijnS95 Nov 30, 2020
68760c0
codegen: Don't emit Rust Display impl when C function is available
MarijnS95 Nov 30, 2020
a1cfe65
special_functions: Add version condition to imports as well
MarijnS95 Dec 2, 2020
bf7dd09
special_functions: Only override to_string nullability if not trusted
MarijnS95 Dec 5, 2020
18c12a5
Separate special functions from traits
MarijnS95 Dec 6, 2020
5b32e69
Give more string-returning functions on flags/enums a static lifetime
MarijnS95 Dec 6, 2020
2915bde
Cargo update
MarijnS95 Dec 6, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
codegen/flags: Add missing display trait generation
Analysis was copied from enums which adds an std::fmt when
generate_display_trait is true, but the codegen for it was missing.
Instead of removing the import, provide a simple Display trait that
forwards to bitflags' Debug implementation.
MarijnS95 committed Dec 6, 2020
commit 518d2772b262704cd6f0307d3879ad59ea377a55
14 changes: 14 additions & 0 deletions src/codegen/flags.rs
Original file line number Diff line number Diff line change
@@ -125,6 +125,20 @@ fn generate_flags(

writeln!(w)?;

if config.generate_display_trait {
// Generate Display trait implementation.
version_condition(w, env, flags.version, false, 0)?;
writeln!(
w,
"impl fmt::Display for {0} {{\n\
\tfn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {{\n\
\t\t<Self as fmt::Debug>::fmt(self, f)\n\
\t}}\n\
}}\n",
flags.name
)?;
}

version_condition(w, env, flags.version, false, 0)?;
writeln!(
w,