Skip to content

Commit

Permalink
Use C-style comments in C mode
Browse files Browse the repository at this point in the history
This fixes mozilla#59
  • Loading branch information
mitsuhiko committed Oct 1, 2017
1 parent 57bfb90 commit f5dd5ad
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/bindgen/bindings.rs
Expand Up @@ -163,7 +163,11 @@ impl Bindings {
}
if let Some(ref f) = self.config.include_guard {
out.new_line_if_not_start();
out.write(&format!("#endif // {}", f));
if self.config.language == Language::C {
out.write(&format!("#endif /* {} */", f));
} else {
out.write(&format!("#endif // {}", f));
}
out.new_line();
}
if let Some(ref f) = self.config.trailer {
Expand Down
18 changes: 15 additions & 3 deletions src/bindgen/ir/documentation.rs
Expand Up @@ -6,7 +6,7 @@ use std::io::Write;

use syn;

use bindgen::config::Config;
use bindgen::config::{Config, Language};
use bindgen::writer::{Source, SourceWriter};

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -44,15 +44,27 @@ impl Documentation {
}

impl Source for Documentation {
fn write<F: Write>(&self,config: &Config, out: &mut SourceWriter<F>) {
fn write<F: Write>(&self, config: &Config, out: &mut SourceWriter<F>) {
if self.doc_comment.is_empty() || !config.documentation {
return;
}

if config.language == Language::C {
out.write("/*");
out.new_line();
}
for line in &self.doc_comment {
out.write("// ");
if config.language != Language::C {
out.write("// ");
} else {
out.write(" * ");
}
out.write(line);
out.new_line();
}
if config.language == Language::C {
out.write(" */");
out.new_line();
}
}
}

0 comments on commit f5dd5ad

Please sign in to comment.