summaryrefslogtreecommitdiff
path: root/libbindgen/src/codegen
diff options
context:
space:
mode:
Diffstat (limited to 'libbindgen/src/codegen')
-rw-r--r--libbindgen/src/codegen/helpers.rs4
-rw-r--r--libbindgen/src/codegen/mod.rs4
2 files changed, 8 insertions, 0 deletions
diff --git a/libbindgen/src/codegen/helpers.rs b/libbindgen/src/codegen/helpers.rs
index 8c3d3cea..7284ab80 100644
--- a/libbindgen/src/codegen/helpers.rs
+++ b/libbindgen/src/codegen/helpers.rs
@@ -133,6 +133,10 @@ pub mod ast_ty {
}
}
+ pub fn bool_expr(val: bool) -> P<ast::Expr> {
+ aster::AstBuilder::new().expr().bool(val)
+ }
+
pub fn byte_array_expr(bytes: &[u8]) -> P<ast::Expr> {
let mut vec = Vec::with_capacity(bytes.len() + 1);
for byte in bytes {
diff --git a/libbindgen/src/codegen/mod.rs b/libbindgen/src/codegen/mod.rs
index ceb023f7..f15b92d1 100644
--- a/libbindgen/src/codegen/mod.rs
+++ b/libbindgen/src/codegen/mod.rs
@@ -323,6 +323,10 @@ impl CodeGenerator for Var {
.const_(canonical_name)
.expr();
let item = match *val {
+ VarType::Bool(val) => {
+ const_item.build(helpers::ast_ty::bool_expr(val))
+ .build(ty)
+ }
VarType::Int(val) => {
const_item.build(helpers::ast_ty::int_expr(val))
.build(ty)