Skip to content

Commit

Permalink
literal struct & constants condition fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
kassane committed Sep 7, 2022
1 parent 6fee4b3 commit df94e7e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/bindgen/ir/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ impl Literal {
Language::C => write!(out, "({})", export_name),
Language::Cxx => write!(out, "{}", export_name),
Language::Cython => write!(out, "<{}>", export_name),
Language::Zig => write!(out, ":{} = ", export_name),
Language::Zig => write!(out, ":{} = .", export_name),
}

write!(out, "{{ ");
Expand Down Expand Up @@ -811,7 +811,11 @@ impl Constant {
Language::Zig => {
out.write(config.style.zig_def());
self.ty.write(config, out);
write!(out, "{} = ", name);
if let Literal::Struct { .. } = &self.value {
write!(out, "{} ", name);
} else {
write!(out, "{} = ", name);
}
value.write(config, out);
write!(out, ";");
}
Expand Down
4 changes: 2 additions & 2 deletions src/bindgen/ir/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ impl Source for Field {
cdecl::write_field(out, &self.ty, &self.name, config);
// Cython extern declarations don't manage layouts, layouts are defined entierly by the
// corresponding C code. So we can omit bitfield sizes which are not supported by Cython.
if config.language != Language::Cython || config.language != Language::Zig {
if config.language != Language::Cython && config.language != Language::Zig {
if let Some(bitfield) = self.annotations.atom("bitfield") {
write!(out, ": {}", bitfield.unwrap_or_default());
}
}

if config.language != Language::Cython || config.language != Language::Zig {
if config.language != Language::Cython && config.language != Language::Zig {
condition.write_after(config, out);
// FIXME(#634): `write_vertical_source_list` should support
// configuring list elements natively. For now we print a newline
Expand Down

0 comments on commit df94e7e

Please sign in to comment.