Skip to content

Commit

Permalink
reexport enum
Browse files Browse the repository at this point in the history
  • Loading branch information
burrbull committed Feb 24, 2024
1 parent 07a60bf commit 8bf2c56
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions src/generate/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -898,13 +898,25 @@ pub fn fields(
}
}
} else if let Some(EV::Derived(_, base)) = rwenum.read_enum() {
// TODO: fix fmt
let fmt = if rwenum.different_enums() {
"enum_read_name"
} else {
"enum_name"
};
let base_ident = ident(
&base.name,
config,
fmt,
span,
);
// only pub use enum when derived from another register.
// If field is in the same register it emits
// pub use enum from same module which is not expected
if base.register() != fpath.register() {
if base.register() != fpath.register() || base_ident != value_read_ty {
// use the same enum structure name
if !enum_derives.contains(&value_read_ty) {
let base_path = base_syn_path(base, &fpath, &value_read_ty, config)?;
let base_path = base_syn_path(base, &fpath, &base_ident, config)?;
mod_items.extend(quote! {
#[doc = #description]
pub use #base_path as #value_read_ty;
Expand Down Expand Up @@ -1146,12 +1158,25 @@ pub fn fields(
});
}
} else if let Some(EV::Derived(_, base)) = rwenum.write_enum() {
// TODO: fix fmt
let fmt = if rwenum.different_enums() {
"enum_write_name"
} else {
"enum_name"
};
let base_ident = ident(
&base.name,
config,
fmt,
span,
);

// If field is in the same register it emits pub use structure from same module.
if base.register() != fpath.register() {
if base.register() != fpath.register() || base_ident != value_write_ty {
if rwenum.generate_write_enum() {
// use the same enum structure name
if !writer_enum_derives.contains(&value_write_ty) {
let base_path = base_syn_path(base, &fpath, &value_write_ty, config)?;
let base_path = base_syn_path(base, &fpath, &base_ident, config)?;
mod_items.extend(quote! {
#[doc = #description]
pub use #base_path as #value_write_ty;
Expand Down

0 comments on commit 8bf2c56

Please sign in to comment.