summaryrefslogtreecommitdiff
path: root/src/codegen/mod.rs
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <emilio@crisal.io>2017-01-26 17:09:28 +0100
committerEmilio Cobos Álvarez <emilio@crisal.io>2017-01-26 20:34:51 +0100
commit7d7c49aaa3b9b5c01d2afac70660575f1bb562b2 (patch)
treec7f0116fc39a1741a4abc0385d1c5fcb6d34b113 /src/codegen/mod.rs
parent5cc25067b27af15ba67be645235f9c90573d6313 (diff)
codegen: Add an option to skip comment generation.
This is mostly a work around https://github.com/servo/rust-bindgen/issues/426, until we implement the proper fix.
Diffstat (limited to 'src/codegen/mod.rs')
-rw-r--r--src/codegen/mod.rs30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs
index c92e95fa..b4ef8606 100644
--- a/src/codegen/mod.rs
+++ b/src/codegen/mod.rs
@@ -534,8 +534,10 @@ impl CodeGenerator for Type {
let rust_name = ctx.rust_ident(&name);
let mut typedef = aster::AstBuilder::new().item().pub_();
- if let Some(comment) = item.comment() {
- typedef = typedef.attr().doc(comment);
+ if ctx.options().generate_comments {
+ if let Some(comment) = item.comment() {
+ typedef = typedef.attr().doc(comment);
+ }
}
// We prefer using `pub use` over `pub type` because of:
@@ -808,8 +810,10 @@ impl CodeGenerator for CompInfo {
let mut attributes = vec![];
let mut needs_clone_impl = false;
- if let Some(comment) = item.comment() {
- attributes.push(attributes::doc(comment));
+ if ctx.options().generate_comments {
+ if let Some(comment) = item.comment() {
+ attributes.push(attributes::doc(comment));
+ }
}
if self.packed() {
attributes.push(attributes::repr_list(&["C", "packed"]));
@@ -1007,8 +1011,10 @@ impl CodeGenerator for CompInfo {
};
let mut attrs = vec![];
- if let Some(comment) = field.comment() {
- attrs.push(attributes::doc(comment));
+ if ctx.options().generate_comments {
+ if let Some(comment) = field.comment() {
+ attrs.push(attributes::doc(comment));
+ }
}
let field_name = match field.name() {
Some(name) => ctx.rust_mangle(name).into_owned(),
@@ -1705,8 +1711,10 @@ impl CodeGenerator for Enum {
builder = builder.with_attr(attributes::repr("C"));
}
- if let Some(comment) = item.comment() {
- builder = builder.with_attr(attributes::doc(comment));
+ if ctx.options().generate_comments {
+ if let Some(comment) = item.comment() {
+ builder = builder.with_attr(attributes::doc(comment));
+ }
}
if !is_constified_enum {
@@ -2166,8 +2174,10 @@ impl CodeGenerator for Function {
let mut attributes = vec![];
- if let Some(comment) = item.comment() {
- attributes.push(attributes::doc(comment));
+ if ctx.options().generate_comments {
+ if let Some(comment) = item.comment() {
+ attributes.push(attributes::doc(comment));
+ }
}
if let Some(mangled) = mangled_name {