Skip to content

Commit

Permalink
feat: skip if cfg! branch that panics on Cython
Browse files Browse the repository at this point in the history
  • Loading branch information
GrayJack committed Feb 9, 2025
1 parent c1104bd commit 093720b
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/bindgen/ir/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -841,12 +841,16 @@ impl Constant {
language_backend.write_literal(out, value);
}
Language::Cython => {
out.write("const ");
language_backend.write_type(out, &self.ty);
// For extern Cython declarations the initializer is ignored,
// but still useful as documentation, so we write it as a comment.
write!(out, " {} # = ", name);
language_backend.write_literal(out, value);
if matches!(self.value, Literal::PanicMacro(_)) {
// Cython don't have a equivalent to `#error` directive
} else {
out.write("const ");
language_backend.write_type(out, &self.ty);
// For extern Cython declarations the initializer is ignored,
// but still useful as documentation, so we write it as a comment.
write!(out, " {} # = ", name);
language_backend.write_literal(out, value);
}
}
}

Expand Down

0 comments on commit 093720b

Please sign in to comment.