diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-11-07 19:52:24 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-07 19:52:24 -0600 |
commit | 6c0d065c63fc99e32557bf28cc268c39a6003866 (patch) | |
tree | 17068991eb0a27d652796b84d05eab35d2bdac03 /src/codegen/mod.rs | |
parent | 8c737ecacd67bf37a949e524b3844cf0d3ea09cc (diff) | |
parent | 1091a4274eb5c91b6279905688759105ab95bfb4 (diff) |
Auto merge of #221 - emilio:dont-override-float, r=fitzgen
Add an option to avoid converting to f32/f64 automatically float types.
This implements another feature that we need for parity with upstream bindgen.
r? @fitzgen
Diffstat (limited to 'src/codegen/mod.rs')
-rwxr-xr-x | src/codegen/mod.rs | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index 85ac13b5..bf6af82b 100755 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -1465,12 +1465,25 @@ impl ToRustTy for Type { } TypeKind::Float(fk) => { use ir::ty::FloatKind; - // TODO: we probably should just take the type layout into - // account? - match fk { - FloatKind::Float => aster::ty::TyBuilder::new().f32(), - FloatKind::Double | FloatKind::LongDouble => { - aster::ty::TyBuilder::new().f64() + if ctx.options().convert_floats { + // TODO: we probably should just take the type layout into + // account? + // + // Also, maybe this one shouldn't be the default? + match fk { + FloatKind::Float => aster::ty::TyBuilder::new().f32(), + FloatKind::Double | FloatKind::LongDouble => { + aster::ty::TyBuilder::new().f64() + } + } + } else { + // FIXME: `c_longdouble` doesn't seem to be defined in some + // systems, so we use `c_double` directly. + match fk { + FloatKind::Float => raw!(c_float), + FloatKind::Double | FloatKind::LongDouble => { + raw!(c_double) + } } } } |