Add C99 doc comment style

In modern C (post-C99) it's common to just use `// double-slash comments`, but currently cbindgen provides only `/* block-comment */` and `/// triple-slash comment` variants.
This commit is contained in:
Ingvar Stepanyan
2019-04-08 13:29:56 +01:00
committed by Emilio Cobos Álvarez
parent 19fd975b6f
commit 944ecb958e
9 changed files with 40 additions and 1 deletions
+1 -1
View File
@@ -106,7 +106,7 @@ language = "[C|C++]"
style = "[Both|Type|Tag]" style = "[Both|Type|Tag]"
# How the generated documentation should be commented. # How the generated documentation should be commented.
# C uses /* */; C++ uses //; Doxy is like C but with leading * per line. # C uses /* */; C++ uses //; Doxy is like C but with leading * per line.
documentation_style = "[C, C++, Doxy]" documentation_style = "[C, C99, C++, Doxy]"
[defines] [defines]
+2
View File
@@ -104,6 +104,7 @@ deserialize_enum_str!(Layout);
#[derive(Debug, Clone, PartialEq, Copy)] #[derive(Debug, Clone, PartialEq, Copy)]
pub enum DocumentationStyle { pub enum DocumentationStyle {
C, C,
C99,
Doxy, Doxy,
Cxx, Cxx,
Auto, Auto,
@@ -115,6 +116,7 @@ impl FromStr for DocumentationStyle {
fn from_str(s: &str) -> Result<DocumentationStyle, Self::Err> { fn from_str(s: &str) -> Result<DocumentationStyle, Self::Err> {
match s.to_lowercase().as_ref() { match s.to_lowercase().as_ref() {
"c" => Ok(DocumentationStyle::C), "c" => Ok(DocumentationStyle::C),
"c99" => Ok(DocumentationStyle::C99),
"cxx" => Ok(DocumentationStyle::Cxx), "cxx" => Ok(DocumentationStyle::Cxx),
"c++" => Ok(DocumentationStyle::Cxx), "c++" => Ok(DocumentationStyle::Cxx),
"doxy" => Ok(DocumentationStyle::Doxy), "doxy" => Ok(DocumentationStyle::Doxy),
+1
View File
@@ -67,6 +67,7 @@ impl Source for Documentation {
match style { match style {
DocumentationStyle::C => out.write(""), DocumentationStyle::C => out.write(""),
DocumentationStyle::Doxy => out.write(" *"), DocumentationStyle::Doxy => out.write(" *"),
DocumentationStyle::C99 => out.write("//"),
DocumentationStyle::Cxx => out.write("///"), DocumentationStyle::Cxx => out.write("///"),
DocumentationStyle::Auto => unreachable!(), // Auto case should always be covered DocumentationStyle::Auto => unreachable!(), // Auto case should always be covered
} }
+7
View File
@@ -0,0 +1,7 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
// The root of all evil.
void root(void);
+7
View File
@@ -0,0 +1,7 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
// The root of all evil.
void root(void);
+10
View File
@@ -0,0 +1,10 @@
#include <cstdarg>
#include <cstdint>
#include <cstdlib>
extern "C" {
// The root of all evil.
void root();
} // extern "C"
+7
View File
@@ -0,0 +1,7 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
// The root of all evil.
void root(void);
+4
View File
@@ -0,0 +1,4 @@
/// The root of all evil.
#[no_mangle]
pub extern "C" fn root() {
}
+1
View File
@@ -0,0 +1 @@
documentation_style = "c99"