diff --git a/src/bindgen/builder.rs b/src/bindgen/builder.rs index d47919b9..1064935b 100644 --- a/src/bindgen/builder.rs +++ b/src/bindgen/builder.rs @@ -37,7 +37,7 @@ impl Builder { #[allow(unused)] pub fn with_header>(mut self, header: S) -> Builder { - self.config.header = Some(String::from(header.as_ref())); + self.config.header = String::from(header.as_ref()).into(); self } @@ -63,13 +63,13 @@ impl Builder { #[allow(unused)] pub fn with_after_include>(mut self, line: S) -> Builder { - self.config.after_includes = Some(String::from(line.as_ref())); + self.config.after_includes = String::from(line.as_ref()).into(); self } #[allow(unused)] pub fn with_trailer>(mut self, trailer: S) -> Builder { - self.config.trailer = Some(String::from(trailer.as_ref())); + self.config.trailer = String::from(trailer.as_ref()).into(); self } diff --git a/src/bindgen/config.rs b/src/bindgen/config.rs index 31316503..55eac9c3 100644 --- a/src/bindgen/config.rs +++ b/src/bindgen/config.rs @@ -894,6 +894,78 @@ pub struct CythonConfig { pub cimports: BTreeMap>, } +/// A line field can be a single line `field = "line"` or a struct `field = { language = "C", line = "struct" }`. +#[derive(Debug, Clone, Deserialize)] +#[serde(untagged)] +pub enum Line { + AnyBackend(String), + WithBackend { language: Language, line: String }, +} +impl Line { + pub fn line_for(&self, target: Language) -> Option<&str> { + match *self { + Line::AnyBackend(ref line) => Some(line.as_str()), + Line::WithBackend { language, ref line } if language == target => Some(line.as_str()), + _ => None, + } + } +} +impl From for Line { + fn from(value: String) -> Self { + Self::AnyBackend(value) + } +} + +/// A text field can be a line field or a sequence of lines or structs: +/// ```toml +/// field = [ +/// "sequence of lines", +/// { language = "C", line = "or structs" }, +/// ] +/// ``` +#[derive(Debug, Clone, Deserialize)] +#[serde(untagged)] +pub enum Text { + Line(Line), + Lines(Vec), +} +impl Text { + pub fn is_empty(&self) -> bool { + match *self { + Text::Line(_) => false, + Text::Lines(ref lines) => lines.is_empty(), + } + } + pub fn text_for(&self, target: Language) -> Vec<&str> { + let mut text = Vec::new(); + match self { + Text::Line(line) => { + if let Some(s) = line.line_for(target) { + text.push(s); + } + } + Text::Lines(lines) => { + for line in lines.iter() { + if let Some(s) = line.line_for(target) { + text.push(s); + } + } + } + } + text + } +} +impl From for Text { + fn from(value: String) -> Self { + Self::Line(value.into()) + } +} +impl Default for Text { + fn default() -> Self { + Self::Lines(Vec::new()) + } +} + /// A collection of settings to customize the generated bindings. #[derive(Debug, Clone, Deserialize)] #[serde(rename_all = "snake_case")] @@ -901,15 +973,15 @@ pub struct CythonConfig { #[serde(default)] pub struct Config { /// Optional text to output at the beginning of the file - pub header: Option, + pub header: Text, /// A list of additional includes to put at the beginning of the generated header pub includes: Vec, /// A list of additional system includes to put at the beginning of the generated header pub sys_includes: Vec, /// Optional verbatim code added after the include blocks - pub after_includes: Option, + pub after_includes: Text, /// Optional text to output at the end of the file - pub trailer: Option, + pub trailer: Text, /// Optional name to use for an include guard pub include_guard: Option, /// Add a `#pragma once` guard @@ -1032,11 +1104,11 @@ pub struct Config { impl Default for Config { fn default() -> Config { Config { - header: None, + header: Text::default(), includes: Vec::new(), sys_includes: Vec::new(), - after_includes: None, - trailer: None, + after_includes: Text::default(), + trailer: Text::default(), include_guard: None, pragma_once: false, autogen_warning: None, diff --git a/src/bindgen/language_backend/clike.rs b/src/bindgen/language_backend/clike.rs index 5da079c3..2efcb19f 100644 --- a/src/bindgen/language_backend/clike.rs +++ b/src/bindgen/language_backend/clike.rs @@ -344,9 +344,9 @@ impl LanguageBackend for CLikeLanguageBackend<'_> { write!(out, "/* Package version: {} */", package_version); out.new_line(); } - if let Some(ref f) = self.config.header { + for line in self.config.header.text_for(self.config.language) { out.new_line_if_not_start(); - write!(out, "{}", f); + write!(out, "{}", line); out.new_line(); } if let Some(f) = self.config.include_guard() { @@ -379,7 +379,7 @@ impl LanguageBackend for CLikeLanguageBackend<'_> { if self.config.no_includes && self.config.sys_includes().is_empty() && self.config.includes().is_empty() - && self.config.after_includes.is_none() + && self.config.after_includes.is_empty() { return; } @@ -439,7 +439,7 @@ impl LanguageBackend for CLikeLanguageBackend<'_> { out.new_line(); } - if let Some(ref line) = self.config.after_includes { + for line in self.config.after_includes.text_for(self.config.language) { write!(out, "{}", line); out.new_line(); } diff --git a/src/bindgen/language_backend/cython.rs b/src/bindgen/language_backend/cython.rs index 5c85b2d0..cda768c3 100644 --- a/src/bindgen/language_backend/cython.rs +++ b/src/bindgen/language_backend/cython.rs @@ -47,9 +47,9 @@ impl LanguageBackend for CythonLanguageBackend<'_> { write!(out, "''' Package version: {} '''", package_version); out.new_line(); } - if let Some(ref f) = self.config.header { + for line in self.config.header.text_for(self.config.language) { out.new_line_if_not_start(); - write!(out, "{}", f); + write!(out, "{}", line); out.new_line(); } @@ -72,7 +72,7 @@ impl LanguageBackend for CythonLanguageBackend<'_> { && self.config.sys_includes().is_empty() && self.config.includes().is_empty() && (self.config.cython.cimports.is_empty()) - && self.config.after_includes.is_none() + && self.config.after_includes.is_empty() { return; } @@ -98,7 +98,7 @@ impl LanguageBackend for CythonLanguageBackend<'_> { out.new_line(); } - if let Some(ref line) = &self.config.after_includes { + for line in self.config.after_includes.text_for(self.config.language) { write!(out, "{}", line); out.new_line(); } diff --git a/src/bindgen/language_backend/mod.rs b/src/bindgen/language_backend/mod.rs index adb7d850..d4ae1856 100644 --- a/src/bindgen/language_backend/mod.rs +++ b/src/bindgen/language_backend/mod.rs @@ -199,10 +199,10 @@ pub trait LanguageBackend: Sized { } fn write_trailer(&mut self, out: &mut SourceWriter, b: &Bindings) { - if let Some(ref f) = b.config.trailer { + for line in b.config.trailer.text_for(b.config.language) { out.new_line_if_not_start(); - write!(out, "{}", f); - if !f.ends_with('\n') { + write!(out, "{}", line); + if !line.ends_with('\n') { out.new_line(); } } diff --git a/tests/expectations/box.c b/tests/expectations/box.c index 384632b5..230492a4 100644 --- a/tests/expectations/box.c +++ b/tests/expectations/box.c @@ -1,17 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using Box = T*; -#endif - -#if 0 -' ''' -#endif - - #include #include #include diff --git a/tests/expectations/box.compat.c b/tests/expectations/box.compat.c index 686d2a38..f56320ef 100644 --- a/tests/expectations/box.compat.c +++ b/tests/expectations/box.compat.c @@ -1,17 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using Box = T*; -#endif - -#if 0 -' ''' -#endif - - #include #include #include diff --git a/tests/expectations/box.cpp b/tests/expectations/box.cpp index 76a5ef77..16944d34 100644 --- a/tests/expectations/box.cpp +++ b/tests/expectations/box.cpp @@ -1,15 +1,5 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus template using Box = T*; -#endif - -#if 0 -' ''' -#endif #include diff --git a/tests/expectations/box.pyx b/tests/expectations/box.pyx index 366dafee..a6b4ef9c 100644 --- a/tests/expectations/box.pyx +++ b/tests/expectations/box.pyx @@ -1,17 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using Box = T*; -#endif - -#if 0 -' ''' -#endif - - from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t cdef extern from *: diff --git a/tests/expectations/box_both.c b/tests/expectations/box_both.c index 3a9f76ae..c0816864 100644 --- a/tests/expectations/box_both.c +++ b/tests/expectations/box_both.c @@ -1,17 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using Box = T*; -#endif - -#if 0 -' ''' -#endif - - #include #include #include diff --git a/tests/expectations/box_both.compat.c b/tests/expectations/box_both.compat.c index dc8c3cba..1a18e6dc 100644 --- a/tests/expectations/box_both.compat.c +++ b/tests/expectations/box_both.compat.c @@ -1,17 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using Box = T*; -#endif - -#if 0 -' ''' -#endif - - #include #include #include diff --git a/tests/expectations/box_tag.c b/tests/expectations/box_tag.c index da0eb4a0..bf4c2f6f 100644 --- a/tests/expectations/box_tag.c +++ b/tests/expectations/box_tag.c @@ -1,17 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using Box = T*; -#endif - -#if 0 -' ''' -#endif - - #include #include #include diff --git a/tests/expectations/box_tag.compat.c b/tests/expectations/box_tag.compat.c index 2290dc3b..e3b67a55 100644 --- a/tests/expectations/box_tag.compat.c +++ b/tests/expectations/box_tag.compat.c @@ -1,17 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using Box = T*; -#endif - -#if 0 -' ''' -#endif - - #include #include #include diff --git a/tests/expectations/box_tag.pyx b/tests/expectations/box_tag.pyx index e50f19e3..25cb0e39 100644 --- a/tests/expectations/box_tag.pyx +++ b/tests/expectations/box_tag.pyx @@ -1,17 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using Box = T*; -#endif - -#if 0 -' ''' -#endif - - from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t cdef extern from *: diff --git a/tests/expectations/enum.c b/tests/expectations/enum.c index 0562a56a..4884fdac 100644 --- a/tests/expectations/enum.c +++ b/tests/expectations/enum.c @@ -1,17 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using Box = T*; -#endif - -#if 0 -' ''' -#endif - - #include #include #include @@ -245,17 +231,9 @@ void root(Opaque *opaque, Q q, R r); -#if 0 -''' ' -#endif - #include #include "testing-helpers.h" static_assert(offsetof(CBINDGEN_STRUCT(P), tag) == 0, "unexpected offset for tag"); static_assert(offsetof(CBINDGEN_STRUCT(P), p0) == 1, "unexpected offset for p0"); static_assert(offsetof(CBINDGEN_STRUCT(P), p0) == 1, "unexpected offset for p1"); static_assert(sizeof(CBINDGEN_STRUCT(P)) == 4, "unexpected size for P"); - -#if 0 -' ''' -#endif diff --git a/tests/expectations/enum.compat.c b/tests/expectations/enum.compat.c index 86cedb9f..fd5e2e96 100644 --- a/tests/expectations/enum.compat.c +++ b/tests/expectations/enum.compat.c @@ -1,17 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using Box = T*; -#endif - -#if 0 -' ''' -#endif - - #include #include #include @@ -319,17 +305,9 @@ void root(Opaque *opaque, } // extern "C" #endif // __cplusplus -#if 0 -''' ' -#endif - #include #include "testing-helpers.h" static_assert(offsetof(CBINDGEN_STRUCT(P), tag) == 0, "unexpected offset for tag"); static_assert(offsetof(CBINDGEN_STRUCT(P), p0) == 1, "unexpected offset for p0"); static_assert(offsetof(CBINDGEN_STRUCT(P), p0) == 1, "unexpected offset for p1"); static_assert(sizeof(CBINDGEN_STRUCT(P)) == 4, "unexpected size for P"); - -#if 0 -' ''' -#endif diff --git a/tests/expectations/enum.cpp b/tests/expectations/enum.cpp index 66d9209b..0e3972c5 100644 --- a/tests/expectations/enum.cpp +++ b/tests/expectations/enum.cpp @@ -1,15 +1,5 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus template using Box = T*; -#endif - -#if 0 -' ''' -#endif #include @@ -255,17 +245,9 @@ void root(Opaque *opaque, } // extern "C" -#if 0 -''' ' -#endif - #include #include "testing-helpers.h" static_assert(offsetof(CBINDGEN_STRUCT(P), tag) == 0, "unexpected offset for tag"); static_assert(offsetof(CBINDGEN_STRUCT(P), p0) == 1, "unexpected offset for p0"); static_assert(offsetof(CBINDGEN_STRUCT(P), p0) == 1, "unexpected offset for p1"); static_assert(sizeof(CBINDGEN_STRUCT(P)) == 4, "unexpected size for P"); - -#if 0 -' ''' -#endif diff --git a/tests/expectations/enum.pyx b/tests/expectations/enum.pyx index 03570f2c..38868803 100644 --- a/tests/expectations/enum.pyx +++ b/tests/expectations/enum.pyx @@ -1,17 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using Box = T*; -#endif - -#if 0 -' ''' -#endif - - from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t cdef extern from *: @@ -199,9 +185,7 @@ cdef extern from *: Q q, R r); -#if 0 ''' ' -#endif #include #include "testing-helpers.h" @@ -210,6 +194,4 @@ static_assert(offsetof(CBINDGEN_STRUCT(P), p0) == 1, "unexpected offset for p0") static_assert(offsetof(CBINDGEN_STRUCT(P), p0) == 1, "unexpected offset for p1"); static_assert(sizeof(CBINDGEN_STRUCT(P)) == 4, "unexpected size for P"); -#if 0 ' ''' -#endif diff --git a/tests/expectations/enum_both.c b/tests/expectations/enum_both.c index a0f88c13..5a28949a 100644 --- a/tests/expectations/enum_both.c +++ b/tests/expectations/enum_both.c @@ -1,17 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using Box = T*; -#endif - -#if 0 -' ''' -#endif - - #include #include #include @@ -245,17 +231,9 @@ void root(struct Opaque *opaque, struct Q q, struct R r); -#if 0 -''' ' -#endif - #include #include "testing-helpers.h" static_assert(offsetof(CBINDGEN_STRUCT(P), tag) == 0, "unexpected offset for tag"); static_assert(offsetof(CBINDGEN_STRUCT(P), p0) == 1, "unexpected offset for p0"); static_assert(offsetof(CBINDGEN_STRUCT(P), p0) == 1, "unexpected offset for p1"); static_assert(sizeof(CBINDGEN_STRUCT(P)) == 4, "unexpected size for P"); - -#if 0 -' ''' -#endif diff --git a/tests/expectations/enum_both.compat.c b/tests/expectations/enum_both.compat.c index 35488252..9ea0e236 100644 --- a/tests/expectations/enum_both.compat.c +++ b/tests/expectations/enum_both.compat.c @@ -1,17 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using Box = T*; -#endif - -#if 0 -' ''' -#endif - - #include #include #include @@ -319,17 +305,9 @@ void root(struct Opaque *opaque, } // extern "C" #endif // __cplusplus -#if 0 -''' ' -#endif - #include #include "testing-helpers.h" static_assert(offsetof(CBINDGEN_STRUCT(P), tag) == 0, "unexpected offset for tag"); static_assert(offsetof(CBINDGEN_STRUCT(P), p0) == 1, "unexpected offset for p0"); static_assert(offsetof(CBINDGEN_STRUCT(P), p0) == 1, "unexpected offset for p1"); static_assert(sizeof(CBINDGEN_STRUCT(P)) == 4, "unexpected size for P"); - -#if 0 -' ''' -#endif diff --git a/tests/expectations/enum_tag.c b/tests/expectations/enum_tag.c index a7f10468..8851f799 100644 --- a/tests/expectations/enum_tag.c +++ b/tests/expectations/enum_tag.c @@ -1,17 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using Box = T*; -#endif - -#if 0 -' ''' -#endif - - #include #include #include @@ -245,17 +231,9 @@ void root(struct Opaque *opaque, struct Q q, struct R r); -#if 0 -''' ' -#endif - #include #include "testing-helpers.h" static_assert(offsetof(CBINDGEN_STRUCT(P), tag) == 0, "unexpected offset for tag"); static_assert(offsetof(CBINDGEN_STRUCT(P), p0) == 1, "unexpected offset for p0"); static_assert(offsetof(CBINDGEN_STRUCT(P), p0) == 1, "unexpected offset for p1"); static_assert(sizeof(CBINDGEN_STRUCT(P)) == 4, "unexpected size for P"); - -#if 0 -' ''' -#endif diff --git a/tests/expectations/enum_tag.compat.c b/tests/expectations/enum_tag.compat.c index 9662a652..1942cf1b 100644 --- a/tests/expectations/enum_tag.compat.c +++ b/tests/expectations/enum_tag.compat.c @@ -1,17 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using Box = T*; -#endif - -#if 0 -' ''' -#endif - - #include #include #include @@ -319,17 +305,9 @@ void root(struct Opaque *opaque, } // extern "C" #endif // __cplusplus -#if 0 -''' ' -#endif - #include #include "testing-helpers.h" static_assert(offsetof(CBINDGEN_STRUCT(P), tag) == 0, "unexpected offset for tag"); static_assert(offsetof(CBINDGEN_STRUCT(P), p0) == 1, "unexpected offset for p0"); static_assert(offsetof(CBINDGEN_STRUCT(P), p0) == 1, "unexpected offset for p1"); static_assert(sizeof(CBINDGEN_STRUCT(P)) == 4, "unexpected size for P"); - -#if 0 -' ''' -#endif diff --git a/tests/expectations/enum_tag.pyx b/tests/expectations/enum_tag.pyx index a0c9ef08..b5c8b8ec 100644 --- a/tests/expectations/enum_tag.pyx +++ b/tests/expectations/enum_tag.pyx @@ -1,17 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using Box = T*; -#endif - -#if 0 -' ''' -#endif - - from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t cdef extern from *: @@ -199,9 +185,7 @@ cdef extern from *: Q q, R r); -#if 0 ''' ' -#endif #include #include "testing-helpers.h" @@ -210,6 +194,4 @@ static_assert(offsetof(CBINDGEN_STRUCT(P), p0) == 1, "unexpected offset for p0") static_assert(offsetof(CBINDGEN_STRUCT(P), p0) == 1, "unexpected offset for p1"); static_assert(sizeof(CBINDGEN_STRUCT(P)) == 4, "unexpected size for P"); -#if 0 ' ''' -#endif diff --git a/tests/expectations/exclude_generic_monomorph.c b/tests/expectations/exclude_generic_monomorph.c index a593dd7a..e7178367 100644 --- a/tests/expectations/exclude_generic_monomorph.c +++ b/tests/expectations/exclude_generic_monomorph.c @@ -1,20 +1,7 @@ #include -#if 0 -''' ' -#endif - typedef uint64_t Option_Foo; -#if 0 -' ''' -#endif - -#if 0 -from libc.stdint cimport uint64_t -ctypedef uint64_t Option_Foo -#endif - #include #include diff --git a/tests/expectations/exclude_generic_monomorph.compat.c b/tests/expectations/exclude_generic_monomorph.compat.c index a0263220..3bc818e4 100644 --- a/tests/expectations/exclude_generic_monomorph.compat.c +++ b/tests/expectations/exclude_generic_monomorph.compat.c @@ -1,20 +1,7 @@ #include -#if 0 -''' ' -#endif - typedef uint64_t Option_Foo; -#if 0 -' ''' -#endif - -#if 0 -from libc.stdint cimport uint64_t -ctypedef uint64_t Option_Foo -#endif - #include #include diff --git a/tests/expectations/exclude_generic_monomorph.cpp b/tests/expectations/exclude_generic_monomorph.cpp index 09b5455d..e5157486 100644 --- a/tests/expectations/exclude_generic_monomorph.cpp +++ b/tests/expectations/exclude_generic_monomorph.cpp @@ -1,20 +1,7 @@ #include -#if 0 -''' ' -#endif - typedef uint64_t Option_Foo; -#if 0 -' ''' -#endif - -#if 0 -from libc.stdint cimport uint64_t -ctypedef uint64_t Option_Foo -#endif - #include #include diff --git a/tests/expectations/exclude_generic_monomorph.pyx b/tests/expectations/exclude_generic_monomorph.pyx index 48cd1e24..f1a72d4c 100644 --- a/tests/expectations/exclude_generic_monomorph.pyx +++ b/tests/expectations/exclude_generic_monomorph.pyx @@ -1,19 +1,13 @@ -#include - -#if 0 ''' ' -#endif + +#include typedef uint64_t Option_Foo; -#if 0 -' ''' -#endif -#if 0 +' ''' from libc.stdint cimport uint64_t ctypedef uint64_t Option_Foo -#endif from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t diff --git a/tests/expectations/exclude_generic_monomorph_both.c b/tests/expectations/exclude_generic_monomorph_both.c index 09b5455d..e5157486 100644 --- a/tests/expectations/exclude_generic_monomorph_both.c +++ b/tests/expectations/exclude_generic_monomorph_both.c @@ -1,20 +1,7 @@ #include -#if 0 -''' ' -#endif - typedef uint64_t Option_Foo; -#if 0 -' ''' -#endif - -#if 0 -from libc.stdint cimport uint64_t -ctypedef uint64_t Option_Foo -#endif - #include #include diff --git a/tests/expectations/exclude_generic_monomorph_both.compat.c b/tests/expectations/exclude_generic_monomorph_both.compat.c index 2447ac44..1a97f376 100644 --- a/tests/expectations/exclude_generic_monomorph_both.compat.c +++ b/tests/expectations/exclude_generic_monomorph_both.compat.c @@ -1,20 +1,7 @@ #include -#if 0 -''' ' -#endif - typedef uint64_t Option_Foo; -#if 0 -' ''' -#endif - -#if 0 -from libc.stdint cimport uint64_t -ctypedef uint64_t Option_Foo -#endif - #include #include diff --git a/tests/expectations/exclude_generic_monomorph_tag.c b/tests/expectations/exclude_generic_monomorph_tag.c index 116a170f..32686ad9 100644 --- a/tests/expectations/exclude_generic_monomorph_tag.c +++ b/tests/expectations/exclude_generic_monomorph_tag.c @@ -1,20 +1,7 @@ #include -#if 0 -''' ' -#endif - typedef uint64_t Option_Foo; -#if 0 -' ''' -#endif - -#if 0 -from libc.stdint cimport uint64_t -ctypedef uint64_t Option_Foo -#endif - #include #include diff --git a/tests/expectations/exclude_generic_monomorph_tag.compat.c b/tests/expectations/exclude_generic_monomorph_tag.compat.c index 73d9650f..397993be 100644 --- a/tests/expectations/exclude_generic_monomorph_tag.compat.c +++ b/tests/expectations/exclude_generic_monomorph_tag.compat.c @@ -1,20 +1,7 @@ #include -#if 0 -''' ' -#endif - typedef uint64_t Option_Foo; -#if 0 -' ''' -#endif - -#if 0 -from libc.stdint cimport uint64_t -ctypedef uint64_t Option_Foo -#endif - #include #include diff --git a/tests/expectations/exclude_generic_monomorph_tag.pyx b/tests/expectations/exclude_generic_monomorph_tag.pyx index 934536f4..61ef37e1 100644 --- a/tests/expectations/exclude_generic_monomorph_tag.pyx +++ b/tests/expectations/exclude_generic_monomorph_tag.pyx @@ -1,19 +1,13 @@ -#include - -#if 0 ''' ' -#endif + +#include typedef uint64_t Option_Foo; -#if 0 -' ''' -#endif -#if 0 +' ''' from libc.stdint cimport uint64_t ctypedef uint64_t Option_Foo -#endif from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t diff --git a/tests/expectations/forward_declaration.c b/tests/expectations/forward_declaration.c index f77076dd..3bbf38de 100644 --- a/tests/expectations/forward_declaration.c +++ b/tests/expectations/forward_declaration.c @@ -1,12 +1,6 @@ -#if 0 -''' ' -#endif #if defined(CBINDGEN_STYLE_TYPE) /* ANONYMOUS STRUCTS DO NOT SUPPORT FORWARD DECLARATIONS! #endif -#if 0 -' ''' -#endif #include @@ -39,12 +33,6 @@ typedef struct { void root(TypeInfo x); -#if 0 -''' ' -#endif #if defined(CBINDGEN_STYLE_TYPE) */ #endif -#if 0 -' ''' -#endif diff --git a/tests/expectations/forward_declaration.compat.c b/tests/expectations/forward_declaration.compat.c index 375fc8dc..27afb7e6 100644 --- a/tests/expectations/forward_declaration.compat.c +++ b/tests/expectations/forward_declaration.compat.c @@ -1,12 +1,6 @@ -#if 0 -''' ' -#endif #if defined(CBINDGEN_STYLE_TYPE) /* ANONYMOUS STRUCTS DO NOT SUPPORT FORWARD DECLARATIONS! #endif -#if 0 -' ''' -#endif #include @@ -47,12 +41,6 @@ void root(TypeInfo x); } // extern "C" #endif // __cplusplus -#if 0 -''' ' -#endif #if defined(CBINDGEN_STYLE_TYPE) */ #endif -#if 0 -' ''' -#endif diff --git a/tests/expectations/forward_declaration.cpp b/tests/expectations/forward_declaration.cpp index 766b7994..a7a22a91 100644 --- a/tests/expectations/forward_declaration.cpp +++ b/tests/expectations/forward_declaration.cpp @@ -1,12 +1,6 @@ -#if 0 -''' ' -#endif #if defined(CBINDGEN_STYLE_TYPE) /* ANONYMOUS STRUCTS DO NOT SUPPORT FORWARD DECLARATIONS! #endif -#if 0 -' ''' -#endif #include @@ -46,12 +40,6 @@ void root(TypeInfo x); } // extern "C" -#if 0 -''' ' -#endif #if defined(CBINDGEN_STYLE_TYPE) */ #endif -#if 0 -' ''' -#endif diff --git a/tests/expectations/forward_declaration.pyx b/tests/expectations/forward_declaration.pyx index 451852e6..6ae63c4b 100644 --- a/tests/expectations/forward_declaration.pyx +++ b/tests/expectations/forward_declaration.pyx @@ -1,14 +1,12 @@ -#if 0 ''' ' -#endif + #if defined(CBINDGEN_STYLE_TYPE) /* ANONYMOUS STRUCTS DO NOT SUPPORT FORWARD DECLARATIONS! #endif -#if 0 -' ''' -#endif +' ''' + from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t cdef extern from *: @@ -34,12 +32,10 @@ cdef extern from *: void root(TypeInfo x); -#if 0 ''' ' -#endif + #if defined(CBINDGEN_STYLE_TYPE) */ #endif -#if 0 + ' ''' -#endif diff --git a/tests/expectations/forward_declaration_both.c b/tests/expectations/forward_declaration_both.c index 9e88bab2..94c3f279 100644 --- a/tests/expectations/forward_declaration_both.c +++ b/tests/expectations/forward_declaration_both.c @@ -1,12 +1,6 @@ -#if 0 -''' ' -#endif #if defined(CBINDGEN_STYLE_TYPE) /* ANONYMOUS STRUCTS DO NOT SUPPORT FORWARD DECLARATIONS! #endif -#if 0 -' ''' -#endif #include @@ -39,12 +33,6 @@ typedef struct TypeInfo { void root(struct TypeInfo x); -#if 0 -''' ' -#endif #if defined(CBINDGEN_STYLE_TYPE) */ #endif -#if 0 -' ''' -#endif diff --git a/tests/expectations/forward_declaration_both.compat.c b/tests/expectations/forward_declaration_both.compat.c index 031e40c0..f510662a 100644 --- a/tests/expectations/forward_declaration_both.compat.c +++ b/tests/expectations/forward_declaration_both.compat.c @@ -1,12 +1,6 @@ -#if 0 -''' ' -#endif #if defined(CBINDGEN_STYLE_TYPE) /* ANONYMOUS STRUCTS DO NOT SUPPORT FORWARD DECLARATIONS! #endif -#if 0 -' ''' -#endif #include @@ -47,12 +41,6 @@ void root(struct TypeInfo x); } // extern "C" #endif // __cplusplus -#if 0 -''' ' -#endif #if defined(CBINDGEN_STYLE_TYPE) */ #endif -#if 0 -' ''' -#endif diff --git a/tests/expectations/forward_declaration_tag.c b/tests/expectations/forward_declaration_tag.c index acd82042..813fcbe6 100644 --- a/tests/expectations/forward_declaration_tag.c +++ b/tests/expectations/forward_declaration_tag.c @@ -1,12 +1,6 @@ -#if 0 -''' ' -#endif #if defined(CBINDGEN_STYLE_TYPE) /* ANONYMOUS STRUCTS DO NOT SUPPORT FORWARD DECLARATIONS! #endif -#if 0 -' ''' -#endif #include @@ -39,12 +33,6 @@ struct TypeInfo { void root(struct TypeInfo x); -#if 0 -''' ' -#endif #if defined(CBINDGEN_STYLE_TYPE) */ #endif -#if 0 -' ''' -#endif diff --git a/tests/expectations/forward_declaration_tag.compat.c b/tests/expectations/forward_declaration_tag.compat.c index 1a61c5e2..48fd3c9a 100644 --- a/tests/expectations/forward_declaration_tag.compat.c +++ b/tests/expectations/forward_declaration_tag.compat.c @@ -1,12 +1,6 @@ -#if 0 -''' ' -#endif #if defined(CBINDGEN_STYLE_TYPE) /* ANONYMOUS STRUCTS DO NOT SUPPORT FORWARD DECLARATIONS! #endif -#if 0 -' ''' -#endif #include @@ -47,12 +41,6 @@ void root(struct TypeInfo x); } // extern "C" #endif // __cplusplus -#if 0 -''' ' -#endif #if defined(CBINDGEN_STYLE_TYPE) */ #endif -#if 0 -' ''' -#endif diff --git a/tests/expectations/forward_declaration_tag.pyx b/tests/expectations/forward_declaration_tag.pyx index af110c23..0dff71db 100644 --- a/tests/expectations/forward_declaration_tag.pyx +++ b/tests/expectations/forward_declaration_tag.pyx @@ -1,14 +1,12 @@ -#if 0 ''' ' -#endif + #if defined(CBINDGEN_STYLE_TYPE) /* ANONYMOUS STRUCTS DO NOT SUPPORT FORWARD DECLARATIONS! #endif -#if 0 -' ''' -#endif +' ''' + from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t cdef extern from *: @@ -34,12 +32,10 @@ cdef extern from *: void root(TypeInfo x); -#if 0 ''' ' -#endif + #if defined(CBINDGEN_STYLE_TYPE) */ #endif -#if 0 + ' ''' -#endif diff --git a/tests/expectations/manuallydrop.c b/tests/expectations/manuallydrop.c index 869dea72..90bce006 100644 --- a/tests/expectations/manuallydrop.c +++ b/tests/expectations/manuallydrop.c @@ -1,17 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using ManuallyDrop = T; -#endif - -#if 0 -' ''' -#endif - - #include #include #include diff --git a/tests/expectations/manuallydrop.compat.c b/tests/expectations/manuallydrop.compat.c index b8bdf43e..76e134ff 100644 --- a/tests/expectations/manuallydrop.compat.c +++ b/tests/expectations/manuallydrop.compat.c @@ -1,17 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using ManuallyDrop = T; -#endif - -#if 0 -' ''' -#endif - - #include #include #include diff --git a/tests/expectations/manuallydrop.cpp b/tests/expectations/manuallydrop.cpp index df517dcb..6759fe6c 100644 --- a/tests/expectations/manuallydrop.cpp +++ b/tests/expectations/manuallydrop.cpp @@ -1,15 +1,5 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus template using ManuallyDrop = T; -#endif - -#if 0 -' ''' -#endif #include diff --git a/tests/expectations/manuallydrop.pyx b/tests/expectations/manuallydrop.pyx index 370d0df8..2635a492 100644 --- a/tests/expectations/manuallydrop.pyx +++ b/tests/expectations/manuallydrop.pyx @@ -1,17 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using ManuallyDrop = T; -#endif - -#if 0 -' ''' -#endif - - from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t cdef extern from *: diff --git a/tests/expectations/manuallydrop_both.c b/tests/expectations/manuallydrop_both.c index 255f4f52..9b1c67bd 100644 --- a/tests/expectations/manuallydrop_both.c +++ b/tests/expectations/manuallydrop_both.c @@ -1,17 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using ManuallyDrop = T; -#endif - -#if 0 -' ''' -#endif - - #include #include #include diff --git a/tests/expectations/manuallydrop_both.compat.c b/tests/expectations/manuallydrop_both.compat.c index 1975e268..461c08e0 100644 --- a/tests/expectations/manuallydrop_both.compat.c +++ b/tests/expectations/manuallydrop_both.compat.c @@ -1,17 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using ManuallyDrop = T; -#endif - -#if 0 -' ''' -#endif - - #include #include #include diff --git a/tests/expectations/manuallydrop_tag.c b/tests/expectations/manuallydrop_tag.c index 5d44aa21..7f56face 100644 --- a/tests/expectations/manuallydrop_tag.c +++ b/tests/expectations/manuallydrop_tag.c @@ -1,17 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using ManuallyDrop = T; -#endif - -#if 0 -' ''' -#endif - - #include #include #include diff --git a/tests/expectations/manuallydrop_tag.compat.c b/tests/expectations/manuallydrop_tag.compat.c index 08d952c8..571a3616 100644 --- a/tests/expectations/manuallydrop_tag.compat.c +++ b/tests/expectations/manuallydrop_tag.compat.c @@ -1,17 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using ManuallyDrop = T; -#endif - -#if 0 -' ''' -#endif - - #include #include #include diff --git a/tests/expectations/manuallydrop_tag.pyx b/tests/expectations/manuallydrop_tag.pyx index 388c3ef1..9cc1f55f 100644 --- a/tests/expectations/manuallydrop_tag.pyx +++ b/tests/expectations/manuallydrop_tag.pyx @@ -1,17 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using ManuallyDrop = T; -#endif - -#if 0 -' ''' -#endif - - from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t cdef extern from *: diff --git a/tests/expectations/maybeuninit.c b/tests/expectations/maybeuninit.c index 1eddcdc3..3434287d 100644 --- a/tests/expectations/maybeuninit.c +++ b/tests/expectations/maybeuninit.c @@ -1,17 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using MaybeUninit = T; -#endif - -#if 0 -' ''' -#endif - - #include #include #include diff --git a/tests/expectations/maybeuninit.compat.c b/tests/expectations/maybeuninit.compat.c index a9792999..b38f0dd8 100644 --- a/tests/expectations/maybeuninit.compat.c +++ b/tests/expectations/maybeuninit.compat.c @@ -1,17 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using MaybeUninit = T; -#endif - -#if 0 -' ''' -#endif - - #include #include #include diff --git a/tests/expectations/maybeuninit.cpp b/tests/expectations/maybeuninit.cpp index 638cdfd1..217aea48 100644 --- a/tests/expectations/maybeuninit.cpp +++ b/tests/expectations/maybeuninit.cpp @@ -1,15 +1,5 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus template using MaybeUninit = T; -#endif - -#if 0 -' ''' -#endif #include diff --git a/tests/expectations/maybeuninit.pyx b/tests/expectations/maybeuninit.pyx index 75d82b38..5705d26c 100644 --- a/tests/expectations/maybeuninit.pyx +++ b/tests/expectations/maybeuninit.pyx @@ -1,17 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using MaybeUninit = T; -#endif - -#if 0 -' ''' -#endif - - from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t cdef extern from *: diff --git a/tests/expectations/maybeuninit_both.c b/tests/expectations/maybeuninit_both.c index 850e3eb1..b0045d71 100644 --- a/tests/expectations/maybeuninit_both.c +++ b/tests/expectations/maybeuninit_both.c @@ -1,17 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using MaybeUninit = T; -#endif - -#if 0 -' ''' -#endif - - #include #include #include diff --git a/tests/expectations/maybeuninit_both.compat.c b/tests/expectations/maybeuninit_both.compat.c index 046822d6..fe7bb541 100644 --- a/tests/expectations/maybeuninit_both.compat.c +++ b/tests/expectations/maybeuninit_both.compat.c @@ -1,17 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using MaybeUninit = T; -#endif - -#if 0 -' ''' -#endif - - #include #include #include diff --git a/tests/expectations/maybeuninit_tag.c b/tests/expectations/maybeuninit_tag.c index a2f5a084..15cd0508 100644 --- a/tests/expectations/maybeuninit_tag.c +++ b/tests/expectations/maybeuninit_tag.c @@ -1,17 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using MaybeUninit = T; -#endif - -#if 0 -' ''' -#endif - - #include #include #include diff --git a/tests/expectations/maybeuninit_tag.compat.c b/tests/expectations/maybeuninit_tag.compat.c index 8ec05f15..1fda1e5d 100644 --- a/tests/expectations/maybeuninit_tag.compat.c +++ b/tests/expectations/maybeuninit_tag.compat.c @@ -1,17 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using MaybeUninit = T; -#endif - -#if 0 -' ''' -#endif - - #include #include #include diff --git a/tests/expectations/maybeuninit_tag.pyx b/tests/expectations/maybeuninit_tag.pyx index 82497d85..aa4faa8b 100644 --- a/tests/expectations/maybeuninit_tag.pyx +++ b/tests/expectations/maybeuninit_tag.pyx @@ -1,17 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using MaybeUninit = T; -#endif - -#if 0 -' ''' -#endif - - from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t cdef extern from *: diff --git a/tests/expectations/nonzero.c b/tests/expectations/nonzero.c index ec7d8e0c..884d9ddc 100644 --- a/tests/expectations/nonzero.c +++ b/tests/expectations/nonzero.c @@ -1,16 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -struct NonZeroI64; -#endif - -#if 0 -' ''' -#endif - - #include #include #include diff --git a/tests/expectations/nonzero.compat.c b/tests/expectations/nonzero.compat.c index f9e1703b..1315a22a 100644 --- a/tests/expectations/nonzero.compat.c +++ b/tests/expectations/nonzero.compat.c @@ -1,16 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -struct NonZeroI64; -#endif - -#if 0 -' ''' -#endif - - #include #include #include diff --git a/tests/expectations/nonzero.cpp b/tests/expectations/nonzero.cpp index 25a930c7..c58161c2 100644 --- a/tests/expectations/nonzero.cpp +++ b/tests/expectations/nonzero.cpp @@ -1,14 +1,4 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus struct NonZeroI64; -#endif - -#if 0 -' ''' -#endif #include diff --git a/tests/expectations/nonzero.pyx b/tests/expectations/nonzero.pyx index 737c4412..c9b0a0b1 100644 --- a/tests/expectations/nonzero.pyx +++ b/tests/expectations/nonzero.pyx @@ -1,16 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -struct NonZeroI64; -#endif - -#if 0 -' ''' -#endif - - from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t cdef extern from *: diff --git a/tests/expectations/nonzero_both.c b/tests/expectations/nonzero_both.c index 6f47e751..9ce5dfba 100644 --- a/tests/expectations/nonzero_both.c +++ b/tests/expectations/nonzero_both.c @@ -1,16 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -struct NonZeroI64; -#endif - -#if 0 -' ''' -#endif - - #include #include #include diff --git a/tests/expectations/nonzero_both.compat.c b/tests/expectations/nonzero_both.compat.c index ee8433e2..e017c750 100644 --- a/tests/expectations/nonzero_both.compat.c +++ b/tests/expectations/nonzero_both.compat.c @@ -1,16 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -struct NonZeroI64; -#endif - -#if 0 -' ''' -#endif - - #include #include #include diff --git a/tests/expectations/nonzero_tag.c b/tests/expectations/nonzero_tag.c index cf67b3d6..980201fc 100644 --- a/tests/expectations/nonzero_tag.c +++ b/tests/expectations/nonzero_tag.c @@ -1,16 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -struct NonZeroI64; -#endif - -#if 0 -' ''' -#endif - - #include #include #include diff --git a/tests/expectations/nonzero_tag.compat.c b/tests/expectations/nonzero_tag.compat.c index 896ddbf2..af9971ed 100644 --- a/tests/expectations/nonzero_tag.compat.c +++ b/tests/expectations/nonzero_tag.compat.c @@ -1,16 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -struct NonZeroI64; -#endif - -#if 0 -' ''' -#endif - - #include #include #include diff --git a/tests/expectations/nonzero_tag.pyx b/tests/expectations/nonzero_tag.pyx index 0f3caf34..c481cf16 100644 --- a/tests/expectations/nonzero_tag.pyx +++ b/tests/expectations/nonzero_tag.pyx @@ -1,16 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -struct NonZeroI64; -#endif - -#if 0 -' ''' -#endif - - from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t cdef extern from *: diff --git a/tests/expectations/opaque.c b/tests/expectations/opaque.c index 3a920e54..ea3ab627 100644 --- a/tests/expectations/opaque.c +++ b/tests/expectations/opaque.c @@ -1,20 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -// These could be added as opaque types I guess. -template -struct BuildHasherDefault; - -struct DefaultHasher; -#endif - -#if 0 -' ''' -#endif - - #include #include #include diff --git a/tests/expectations/opaque.compat.c b/tests/expectations/opaque.compat.c index 61a93ed2..2ea3f274 100644 --- a/tests/expectations/opaque.compat.c +++ b/tests/expectations/opaque.compat.c @@ -1,20 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -// These could be added as opaque types I guess. -template -struct BuildHasherDefault; - -struct DefaultHasher; -#endif - -#if 0 -' ''' -#endif - - #include #include #include diff --git a/tests/expectations/opaque.cpp b/tests/expectations/opaque.cpp index 0e22c0eb..131e81d2 100644 --- a/tests/expectations/opaque.cpp +++ b/tests/expectations/opaque.cpp @@ -1,18 +1,8 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus // These could be added as opaque types I guess. template struct BuildHasherDefault; struct DefaultHasher; -#endif - -#if 0 -' ''' -#endif #include diff --git a/tests/expectations/opaque.pyx b/tests/expectations/opaque.pyx index f60cfdbc..8c5059ba 100644 --- a/tests/expectations/opaque.pyx +++ b/tests/expectations/opaque.pyx @@ -1,20 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -// These could be added as opaque types I guess. -template -struct BuildHasherDefault; - -struct DefaultHasher; -#endif - -#if 0 -' ''' -#endif - - from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t cdef extern from *: diff --git a/tests/expectations/opaque_both.c b/tests/expectations/opaque_both.c index 6b36d9ec..c08936cc 100644 --- a/tests/expectations/opaque_both.c +++ b/tests/expectations/opaque_both.c @@ -1,20 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -// These could be added as opaque types I guess. -template -struct BuildHasherDefault; - -struct DefaultHasher; -#endif - -#if 0 -' ''' -#endif - - #include #include #include diff --git a/tests/expectations/opaque_both.compat.c b/tests/expectations/opaque_both.compat.c index fa057a16..de0c5f2f 100644 --- a/tests/expectations/opaque_both.compat.c +++ b/tests/expectations/opaque_both.compat.c @@ -1,20 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -// These could be added as opaque types I guess. -template -struct BuildHasherDefault; - -struct DefaultHasher; -#endif - -#if 0 -' ''' -#endif - - #include #include #include diff --git a/tests/expectations/opaque_tag.c b/tests/expectations/opaque_tag.c index 67d7740d..953c9bdf 100644 --- a/tests/expectations/opaque_tag.c +++ b/tests/expectations/opaque_tag.c @@ -1,20 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -// These could be added as opaque types I guess. -template -struct BuildHasherDefault; - -struct DefaultHasher; -#endif - -#if 0 -' ''' -#endif - - #include #include #include diff --git a/tests/expectations/opaque_tag.compat.c b/tests/expectations/opaque_tag.compat.c index 71ab06c3..d71dd606 100644 --- a/tests/expectations/opaque_tag.compat.c +++ b/tests/expectations/opaque_tag.compat.c @@ -1,20 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -// These could be added as opaque types I guess. -template -struct BuildHasherDefault; - -struct DefaultHasher; -#endif - -#if 0 -' ''' -#endif - - #include #include #include diff --git a/tests/expectations/opaque_tag.pyx b/tests/expectations/opaque_tag.pyx index 694073fd..8dd33f84 100644 --- a/tests/expectations/opaque_tag.pyx +++ b/tests/expectations/opaque_tag.pyx @@ -1,20 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -// These could be added as opaque types I guess. -template -struct BuildHasherDefault; - -struct DefaultHasher; -#endif - -#if 0 -' ''' -#endif - - from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t cdef extern from *: diff --git a/tests/expectations/pin.c b/tests/expectations/pin.c index df4cd320..5af2908d 100644 --- a/tests/expectations/pin.c +++ b/tests/expectations/pin.c @@ -1,19 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using Pin = T; -template -using Box = T*; -#endif - -#if 0 -' ''' -#endif - - #include #include #include diff --git a/tests/expectations/pin.compat.c b/tests/expectations/pin.compat.c index 117641d3..a27bc2d0 100644 --- a/tests/expectations/pin.compat.c +++ b/tests/expectations/pin.compat.c @@ -1,19 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using Pin = T; -template -using Box = T*; -#endif - -#if 0 -' ''' -#endif - - #include #include #include diff --git a/tests/expectations/pin.cpp b/tests/expectations/pin.cpp index f8a16c7b..da935b54 100644 --- a/tests/expectations/pin.cpp +++ b/tests/expectations/pin.cpp @@ -1,17 +1,7 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus template using Pin = T; template using Box = T*; -#endif - -#if 0 -' ''' -#endif #include diff --git a/tests/expectations/pin.pyx b/tests/expectations/pin.pyx index f5336e60..fde283ea 100644 --- a/tests/expectations/pin.pyx +++ b/tests/expectations/pin.pyx @@ -1,19 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using Pin = T; -template -using Box = T*; -#endif - -#if 0 -' ''' -#endif - - from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t cdef extern from *: diff --git a/tests/expectations/pin_both.c b/tests/expectations/pin_both.c index c43b4c34..da5e1aad 100644 --- a/tests/expectations/pin_both.c +++ b/tests/expectations/pin_both.c @@ -1,19 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using Pin = T; -template -using Box = T*; -#endif - -#if 0 -' ''' -#endif - - #include #include #include diff --git a/tests/expectations/pin_both.compat.c b/tests/expectations/pin_both.compat.c index 9424fbf7..1067fe2f 100644 --- a/tests/expectations/pin_both.compat.c +++ b/tests/expectations/pin_both.compat.c @@ -1,19 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using Pin = T; -template -using Box = T*; -#endif - -#if 0 -' ''' -#endif - - #include #include #include diff --git a/tests/expectations/pin_tag.c b/tests/expectations/pin_tag.c index 49fb9d84..3530410d 100644 --- a/tests/expectations/pin_tag.c +++ b/tests/expectations/pin_tag.c @@ -1,19 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using Pin = T; -template -using Box = T*; -#endif - -#if 0 -' ''' -#endif - - #include #include #include diff --git a/tests/expectations/pin_tag.compat.c b/tests/expectations/pin_tag.compat.c index 2bb04fd8..f7d09d68 100644 --- a/tests/expectations/pin_tag.compat.c +++ b/tests/expectations/pin_tag.compat.c @@ -1,19 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using Pin = T; -template -using Box = T*; -#endif - -#if 0 -' ''' -#endif - - #include #include #include diff --git a/tests/expectations/pin_tag.pyx b/tests/expectations/pin_tag.pyx index 04a60d73..d84ac2f0 100644 --- a/tests/expectations/pin_tag.pyx +++ b/tests/expectations/pin_tag.pyx @@ -1,19 +1,3 @@ -#if 0 -''' ' -#endif - -#ifdef __cplusplus -template -using Pin = T; -template -using Box = T*; -#endif - -#if 0 -' ''' -#endif - - from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t cdef extern from *: diff --git a/tests/rust/box.toml b/tests/rust/box.toml index 84cb6b08..79842d03 100644 --- a/tests/rust/box.toml +++ b/tests/rust/box.toml @@ -1,17 +1,8 @@ -header = """ -#if 0 -''' ' -#endif - -#ifdef __cplusplus +header = { language = "C++", line = """ template using Box = T*; -#endif +""" } -#if 0 -' ''' -#endif -""" [export] exclude = [ "Box", diff --git a/tests/rust/enum.toml b/tests/rust/enum.toml index 20073cf8..ab4556f6 100644 --- a/tests/rust/enum.toml +++ b/tests/rust/enum.toml @@ -1,34 +1,20 @@ -header = """ -#if 0 -''' ' -#endif - -#ifdef __cplusplus +header = { language = "C++", line = """ template using Box = T*; -#endif - -#if 0 -' ''' -#endif -""" - -trailer = """ -#if 0 -''' ' -#endif +""" } +trailer = [ + { language = "Cython", line = "''' '" }, + """ #include #include "testing-helpers.h" static_assert(offsetof(CBINDGEN_STRUCT(P), tag) == 0, "unexpected offset for tag"); static_assert(offsetof(CBINDGEN_STRUCT(P), p0) == 1, "unexpected offset for p0"); static_assert(offsetof(CBINDGEN_STRUCT(P), p0) == 1, "unexpected offset for p1"); static_assert(sizeof(CBINDGEN_STRUCT(P)) == 4, "unexpected size for P"); - -#if 0 -' ''' -#endif -""" +""", + { language = "Cython", line = "' '''" }, +] [export] exclude = [ diff --git a/tests/rust/exclude_generic_monomorph.toml b/tests/rust/exclude_generic_monomorph.toml index 15711ae3..585db47d 100644 --- a/tests/rust/exclude_generic_monomorph.toml +++ b/tests/rust/exclude_generic_monomorph.toml @@ -1,22 +1,17 @@ language = "C" -header = """ +header = [ + { language = "Cython", line = "''' '" }, + """ #include -#if 0 -''' ' -#endif - typedef uint64_t Option_Foo; - -#if 0 +""", + { language = "Cython", line = """ ' ''' -#endif - -#if 0 from libc.stdint cimport uint64_t ctypedef uint64_t Option_Foo -#endif -""" +""" }, +] [export] exclude = [ diff --git a/tests/rust/forward_declaration.toml b/tests/rust/forward_declaration.toml index 4f1d1ad7..3afdd592 100644 --- a/tests/rust/forward_declaration.toml +++ b/tests/rust/forward_declaration.toml @@ -1,23 +1,19 @@ -header = """ -#if 0 -''' ' -#endif +header = [ + { language = "Cython", line = "''' '" }, + """ #if defined(CBINDGEN_STYLE_TYPE) /* ANONYMOUS STRUCTS DO NOT SUPPORT FORWARD DECLARATIONS! #endif -#if 0 -' ''' -#endif -""" +""", + { language = "Cython", line = "' '''" }, +] -trailer = """ -#if 0 -''' ' -#endif +trailer = [ + { language = "Cython", line = "''' '" }, + """ #if defined(CBINDGEN_STYLE_TYPE) */ #endif -#if 0 -' ''' -#endif -""" +""", + { language = "Cython", line = "' '''" }, +] diff --git a/tests/rust/manuallydrop.toml b/tests/rust/manuallydrop.toml index 7ffee9ac..0240d83d 100644 --- a/tests/rust/manuallydrop.toml +++ b/tests/rust/manuallydrop.toml @@ -1,17 +1,8 @@ -header = """ -#if 0 -''' ' -#endif - -#ifdef __cplusplus +header = { language = "C++", line = """ template using ManuallyDrop = T; -#endif +""" } -#if 0 -' ''' -#endif -""" [export] exclude = [ "ManuallyDrop", diff --git a/tests/rust/maybeuninit.toml b/tests/rust/maybeuninit.toml index ba671fa1..10fd7cb7 100644 --- a/tests/rust/maybeuninit.toml +++ b/tests/rust/maybeuninit.toml @@ -1,17 +1,8 @@ -header = """ -#if 0 -''' ' -#endif - -#ifdef __cplusplus +header = { language = "C++", line = """ template using MaybeUninit = T; -#endif +""" } -#if 0 -' ''' -#endif -""" [export] exclude = [ "MaybeUninit", diff --git a/tests/rust/nonzero.toml b/tests/rust/nonzero.toml index 3c656dc7..656b0309 100644 --- a/tests/rust/nonzero.toml +++ b/tests/rust/nonzero.toml @@ -1,13 +1,3 @@ -header = """ -#if 0 -''' ' -#endif - -#ifdef __cplusplus +header = { language = "C++", line = """ struct NonZeroI64; -#endif - -#if 0 -' ''' -#endif -""" +""" } diff --git a/tests/rust/opaque.toml b/tests/rust/opaque.toml index cf56c976..16bc8a53 100644 --- a/tests/rust/opaque.toml +++ b/tests/rust/opaque.toml @@ -1,17 +1,7 @@ -header = """ -#if 0 -''' ' -#endif - -#ifdef __cplusplus +header = { language = "C++", line = """ // These could be added as opaque types I guess. template struct BuildHasherDefault; struct DefaultHasher; -#endif - -#if 0 -' ''' -#endif -""" +""" } diff --git a/tests/rust/pin.toml b/tests/rust/pin.toml index 5aeccf9d..f1be1416 100644 --- a/tests/rust/pin.toml +++ b/tests/rust/pin.toml @@ -1,19 +1,10 @@ -header = """ -#if 0 -''' ' -#endif - -#ifdef __cplusplus +header = { language = "C++", line = """ template using Pin = T; template using Box = T*; -#endif +""" } -#if 0 -' ''' -#endif -""" [export] exclude = [ "Pin",