From 1c1d4754ce8f9485fc6be129cce0545bae04c932 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Wed, 18 Nov 2020 16:50:59 +0300 Subject: [PATCH] tests: Remove Cython-specific configs --- src/bindgen/ir/constant.rs | 6 ++++- src/bindgen/ir/enumeration.rs | 24 ++++++++++++++----- tests/expectations/body.both.c | 14 +++++------ tests/expectations/body.both.compat.c | 14 +++++------ tests/expectations/body.c | 14 +++++------ tests/expectations/body.compat.c | 14 +++++------ tests/expectations/body.cpp | 14 +++++------ tests/expectations/body.pyx | 16 +++++++++++-- tests/expectations/body.tag.c | 14 +++++------ tests/expectations/body.tag.compat.c | 14 +++++------ tests/expectations/body.tag.pyx | 16 +++++++++++-- tests/expectations/box.both.c | 8 +++++++ tests/expectations/box.both.compat.c | 8 +++++++ tests/expectations/box.c | 8 +++++++ tests/expectations/box.compat.c | 8 +++++++ tests/expectations/box.cpp | 8 +++++++ tests/expectations/box.pyx | 14 +++++++++++ tests/expectations/box.tag.c | 8 +++++++ tests/expectations/box.tag.compat.c | 8 +++++++ tests/expectations/box.tag.pyx | 14 +++++++++++ tests/expectations/cfg.both.c | 8 +++++++ tests/expectations/cfg.both.compat.c | 8 +++++++ tests/expectations/cfg.c | 8 +++++++ tests/expectations/cfg.compat.c | 8 +++++++ tests/expectations/cfg.cpp | 8 +++++++ tests/expectations/cfg.pyx | 17 +++++++++++++ tests/expectations/cfg.tag.c | 8 +++++++ tests/expectations/cfg.tag.compat.c | 8 +++++++ tests/expectations/cfg.tag.pyx | 17 +++++++++++++ tests/expectations/cfg_2.both.c | 6 +++++ tests/expectations/cfg_2.both.compat.c | 6 +++++ tests/expectations/cfg_2.c | 6 +++++ tests/expectations/cfg_2.compat.c | 6 +++++ tests/expectations/cfg_2.cpp | 6 +++++ tests/expectations/cfg_2.pyx | 2 ++ tests/expectations/cfg_2.tag.c | 6 +++++ tests/expectations/cfg_2.tag.compat.c | 6 +++++ tests/expectations/cfg_2.tag.pyx | 2 ++ tests/expectations/constant.both.c | 6 +++-- tests/expectations/constant.both.compat.c | 6 +++-- tests/expectations/constant.c | 6 +++-- tests/expectations/constant.compat.c | 6 +++-- tests/expectations/constant.cpp | 6 +++-- tests/expectations/constant.pyx | 6 +++++ tests/expectations/constant.tag.c | 6 +++-- tests/expectations/constant.tag.compat.c | 6 +++-- tests/expectations/constant.tag.pyx | 6 +++++ tests/expectations/custom_header.c | 9 +++++-- tests/expectations/custom_header.compat.c | 9 +++++-- tests/expectations/custom_header.cpp | 9 +++++-- tests/expectations/custom_header.pyx | 7 +++++- tests/expectations/enum.both.c | 8 +++++++ tests/expectations/enum.both.compat.c | 8 +++++++ tests/expectations/enum.c | 8 +++++++ tests/expectations/enum.compat.c | 8 +++++++ tests/expectations/enum.cpp | 8 +++++++ tests/expectations/enum.pyx | 15 ++++++++++++ tests/expectations/enum.tag.c | 8 +++++++ tests/expectations/enum.tag.compat.c | 8 +++++++ tests/expectations/enum.tag.pyx | 15 ++++++++++++ tests/expectations/enum_discriminant.c | 10 ++------ tests/expectations/enum_discriminant.compat.c | 16 ++----------- tests/expectations/enum_discriminant.cpp | 7 +----- tests/expectations/enum_discriminant.pyx | 2 ++ .../exclude_generic_monomorph.both.c | 13 ++++++++++ .../exclude_generic_monomorph.both.compat.c | 13 ++++++++++ .../expectations/exclude_generic_monomorph.c | 13 ++++++++++ .../exclude_generic_monomorph.compat.c | 13 ++++++++++ .../exclude_generic_monomorph.cpp | 13 ++++++++++ .../exclude_generic_monomorph.pyx | 14 +++++++++++ .../exclude_generic_monomorph.tag.c | 13 ++++++++++ .../exclude_generic_monomorph.tag.compat.c | 13 ++++++++++ .../exclude_generic_monomorph.tag.pyx | 14 +++++++++++ tests/expectations/manuallydrop.both.c | 8 +++++++ tests/expectations/manuallydrop.both.compat.c | 8 +++++++ tests/expectations/manuallydrop.c | 8 +++++++ tests/expectations/manuallydrop.compat.c | 8 +++++++ tests/expectations/manuallydrop.cpp | 8 +++++++ tests/expectations/manuallydrop.pyx | 14 +++++++++++ tests/expectations/manuallydrop.tag.c | 8 +++++++ tests/expectations/manuallydrop.tag.compat.c | 8 +++++++ tests/expectations/manuallydrop.tag.pyx | 14 +++++++++++ tests/expectations/maybeuninit.both.c | 8 +++++++ tests/expectations/maybeuninit.both.compat.c | 8 +++++++ tests/expectations/maybeuninit.c | 8 +++++++ tests/expectations/maybeuninit.compat.c | 8 +++++++ tests/expectations/maybeuninit.cpp | 8 +++++++ tests/expectations/maybeuninit.pyx | 14 +++++++++++ tests/expectations/maybeuninit.tag.c | 8 +++++++ tests/expectations/maybeuninit.tag.compat.c | 8 +++++++ tests/expectations/maybeuninit.tag.pyx | 14 +++++++++++ tests/expectations/mod_attr.both.c | 6 +++++ tests/expectations/mod_attr.both.compat.c | 6 +++++ tests/expectations/mod_attr.c | 6 +++++ tests/expectations/mod_attr.compat.c | 6 +++++ tests/expectations/mod_attr.cpp | 6 +++++ tests/expectations/mod_attr.pyx | 2 ++ tests/expectations/mod_attr.tag.c | 6 +++++ tests/expectations/mod_attr.tag.compat.c | 6 +++++ tests/expectations/mod_attr.tag.pyx | 2 ++ tests/expectations/opaque.c | 8 +++++++ tests/expectations/opaque.compat.c | 8 +++++++ tests/expectations/opaque.cpp | 8 +++++++ tests/expectations/opaque.pyx | 17 +++++++++++++ tests/expectations/opaque.tag.c | 8 +++++++ tests/expectations/opaque.tag.compat.c | 8 +++++++ tests/expectations/opaque.tag.pyx | 17 +++++++++++++ tests/expectations/prefix.both.c | 4 +++- tests/expectations/prefix.both.compat.c | 4 +++- tests/expectations/prefix.c | 4 +++- tests/expectations/prefix.compat.c | 4 +++- tests/expectations/prefix.cpp | 4 +++- tests/expectations/prefix.pyx | 4 ++++ tests/expectations/prefix.tag.c | 4 +++- tests/expectations/prefix.tag.compat.c | 4 +++- tests/expectations/prefix.tag.pyx | 4 ++++ tests/expectations/rename_crate.both.c | 5 ++++ tests/expectations/rename_crate.both.compat.c | 5 ++++ tests/expectations/rename_crate.c | 5 ++++ tests/expectations/rename_crate.compat.c | 5 ++++ tests/expectations/rename_crate.cpp | 5 ++++ tests/expectations/rename_crate.pyx | 2 ++ tests/expectations/rename_crate.tag.c | 5 ++++ tests/expectations/rename_crate.tag.compat.c | 5 ++++ tests/expectations/rename_crate.tag.pyx | 2 ++ tests/expectations/swift_name.both.c | 3 +-- tests/expectations/swift_name.both.compat.c | 3 +-- tests/expectations/swift_name.c | 3 +-- tests/expectations/swift_name.compat.c | 3 +-- tests/expectations/swift_name.cpp | 3 +-- tests/expectations/swift_name.pyx | 2 ++ tests/expectations/swift_name.tag.c | 3 +-- tests/expectations/swift_name.tag.compat.c | 3 +-- tests/expectations/swift_name.tag.pyx | 2 ++ tests/rust/body.cython.toml | 17 ------------- tests/rust/body.toml | 15 ++++++------ tests/rust/box.cython.toml | 10 -------- tests/rust/box.toml | 9 ++++++- tests/rust/cfg.cython.toml | 15 ------------ tests/rust/cfg.toml | 9 +++++++ tests/rust/cfg_2.cython.toml | 9 ------- tests/rust/cfg_2.toml | 7 ++++++ tests/rust/constant.cython.toml | 5 ---- tests/rust/constant.rs | 7 ++++-- tests/rust/custom_header.cython.toml | 5 ---- tests/rust/custom_header.toml | 12 +++++++--- tests/rust/enum.cython.toml | 0 tests/rust/enum.toml | 10 +++++++- tests/rust/enum_discriminant.cython.toml | 2 -- tests/rust/enum_discriminant.rs | 11 ++------- .../exclude_generic_monomorph.cython.toml | 9 ------- tests/rust/exclude_generic_monomorph.toml | 13 ++++++++++ tests/rust/manuallydrop.cython.toml | 4 ---- tests/rust/manuallydrop.toml | 8 +++++++ tests/rust/maybeuninit.cython.toml | 4 ---- tests/rust/maybeuninit.toml | 8 +++++++ tests/rust/mod_attr.cython.toml | 9 ------- tests/rust/mod_attr/cbindgen.toml | 7 ++++++ tests/rust/opaque.cython.toml | 0 tests/rust/opaque.toml | 8 +++++++ tests/rust/prefix.cython.toml | 5 ---- tests/rust/prefix.rs | 6 ++++- tests/rust/rename_crate.cython.toml | 8 ------- tests/rust/rename_crate/cbindgen.toml | 6 +++++ tests/rust/swift_name.cython.toml | 9 ------- tests/rust/swift_name.rs | 1 - tests/tests.rs | 13 +++------- 167 files changed, 1080 insertions(+), 277 deletions(-) delete mode 100644 tests/rust/body.cython.toml delete mode 100644 tests/rust/box.cython.toml delete mode 100644 tests/rust/cfg.cython.toml delete mode 100644 tests/rust/cfg_2.cython.toml delete mode 100644 tests/rust/constant.cython.toml delete mode 100644 tests/rust/custom_header.cython.toml delete mode 100644 tests/rust/enum.cython.toml delete mode 100644 tests/rust/enum_discriminant.cython.toml delete mode 100644 tests/rust/exclude_generic_monomorph.cython.toml delete mode 100644 tests/rust/manuallydrop.cython.toml delete mode 100644 tests/rust/maybeuninit.cython.toml delete mode 100644 tests/rust/mod_attr.cython.toml delete mode 100644 tests/rust/opaque.cython.toml delete mode 100644 tests/rust/prefix.cython.toml delete mode 100644 tests/rust/rename_crate.cython.toml delete mode 100644 tests/rust/swift_name.cython.toml diff --git a/src/bindgen/ir/constant.rs b/src/bindgen/ir/constant.rs index ba64730..305c7f7 100644 --- a/src/bindgen/ir/constant.rs +++ b/src/bindgen/ir/constant.rs @@ -289,7 +289,11 @@ impl Literal { pub(crate) fn write(&self, config: &Config, out: &mut SourceWriter) { match self { - Literal::Expr(v) => write!(out, "{}", v), + Literal::Expr(v) => match (&**v, config.language) { + ("true", Language::Cython) => write!(out, "True"), + ("false", Language::Cython) => write!(out, "False"), + (v, _) => write!(out, "{}", v), + }, Literal::Path(v) => write!(out, "{}", v), Literal::PostfixUnaryOp { op, ref value } => { write!(out, "{}", op); diff --git a/src/bindgen/ir/enumeration.rs b/src/bindgen/ir/enumeration.rs index 1d5481c..3161e21 100644 --- a/src/bindgen/ir/enumeration.rs +++ b/src/bindgen/ir/enumeration.rs @@ -244,7 +244,9 @@ impl EnumVariant { impl Source for EnumVariant { fn write(&self, config: &Config, out: &mut SourceWriter) { let condition = self.cfg.to_condition(config); - condition.write_before(config, out); + if config.language != Language::Cython { + condition.write_before(config, out); + } self.documentation.write(config, out); write!(out, "{}", self.export_name); if let Some(discriminant) = &self.discriminant { @@ -252,7 +254,9 @@ impl Source for EnumVariant { discriminant.write(config, out); } out.write(","); - condition.write_after(config, out); + if config.language != Language::Cython { + condition.write_after(config, out); + } } } @@ -842,9 +846,13 @@ impl Source for Enum { out.new_line(); out.new_line(); let condition = variant.cfg.to_condition(config); - condition.write_before(config, out); + if config.language != Language::Cython { + condition.write_before(config, out); + } body.write(config, out); - condition.write_after(config, out); + if config.language != Language::Cython { + condition.write_after(config, out); + } } } @@ -920,13 +928,17 @@ impl Source for Enum { } first = false; let condition = variant.cfg.to_condition(config); - condition.write_before(config, out); + if config.language != Language::Cython { + condition.write_before(config, out); + } if config.style.generate_typedef() || config.language == Language::Cython { write!(out, "{} {};", body.export_name(), field_name); } else { write!(out, "struct {} {};", body.export_name(), field_name); } - condition.write_after(config, out); + if config.language != Language::Cython { + condition.write_after(config, out); + } } } diff --git a/tests/expectations/body.both.c b/tests/expectations/body.both.c index 743422b..e0684eb 100644 --- a/tests/expectations/body.both.c +++ b/tests/expectations/body.both.c @@ -18,7 +18,7 @@ typedef enum MyCLikeEnum_Prepended { typedef struct MyFancyStruct { int32_t i; #ifdef __cplusplus - inline void foo(); + inline void foo(); #endif } MyFancyStruct; @@ -43,19 +43,19 @@ typedef struct MyFancyEnum { Baz_Body baz; }; #ifdef __cplusplus - inline void wohoo(); + inline void wohoo(); #endif } MyFancyEnum; typedef union MyUnion { float f; uint32_t u; - int32_t extra_member; // yolo + int32_t extra_member; } MyUnion; typedef struct MyFancyStruct_Prepended { #ifdef __cplusplus - inline void prepended_wohoo(); + inline void prepended_wohoo(); #endif int32_t i; } MyFancyStruct_Prepended; @@ -75,9 +75,9 @@ typedef struct Baz_Prepended_Body { } Baz_Prepended_Body; typedef struct MyFancyEnum_Prepended { - #ifdef __cplusplus +#ifdef __cplusplus inline void wohoo(); - #endif +#endif MyFancyEnum_Prepended_Tag tag; union { Bar_Prepended_Body bar_prepended; @@ -86,7 +86,7 @@ typedef struct MyFancyEnum_Prepended { } MyFancyEnum_Prepended; typedef union MyUnion_Prepended { - int32_t extra_member; // yolo + int32_t extra_member; float f; uint32_t u; } MyUnion_Prepended; diff --git a/tests/expectations/body.both.compat.c b/tests/expectations/body.both.compat.c index 46b11c7..c58dd97 100644 --- a/tests/expectations/body.both.compat.c +++ b/tests/expectations/body.both.compat.c @@ -18,7 +18,7 @@ typedef enum MyCLikeEnum_Prepended { typedef struct MyFancyStruct { int32_t i; #ifdef __cplusplus - inline void foo(); + inline void foo(); #endif } MyFancyStruct; @@ -43,19 +43,19 @@ typedef struct MyFancyEnum { Baz_Body baz; }; #ifdef __cplusplus - inline void wohoo(); + inline void wohoo(); #endif } MyFancyEnum; typedef union MyUnion { float f; uint32_t u; - int32_t extra_member; // yolo + int32_t extra_member; } MyUnion; typedef struct MyFancyStruct_Prepended { #ifdef __cplusplus - inline void prepended_wohoo(); + inline void prepended_wohoo(); #endif int32_t i; } MyFancyStruct_Prepended; @@ -75,9 +75,9 @@ typedef struct Baz_Prepended_Body { } Baz_Prepended_Body; typedef struct MyFancyEnum_Prepended { - #ifdef __cplusplus +#ifdef __cplusplus inline void wohoo(); - #endif +#endif MyFancyEnum_Prepended_Tag tag; union { Bar_Prepended_Body bar_prepended; @@ -86,7 +86,7 @@ typedef struct MyFancyEnum_Prepended { } MyFancyEnum_Prepended; typedef union MyUnion_Prepended { - int32_t extra_member; // yolo + int32_t extra_member; float f; uint32_t u; } MyUnion_Prepended; diff --git a/tests/expectations/body.c b/tests/expectations/body.c index 4dc5506..041a2a3 100644 --- a/tests/expectations/body.c +++ b/tests/expectations/body.c @@ -18,7 +18,7 @@ typedef enum { typedef struct { int32_t i; #ifdef __cplusplus - inline void foo(); + inline void foo(); #endif } MyFancyStruct; @@ -43,19 +43,19 @@ typedef struct { Baz_Body baz; }; #ifdef __cplusplus - inline void wohoo(); + inline void wohoo(); #endif } MyFancyEnum; typedef union { float f; uint32_t u; - int32_t extra_member; // yolo + int32_t extra_member; } MyUnion; typedef struct { #ifdef __cplusplus - inline void prepended_wohoo(); + inline void prepended_wohoo(); #endif int32_t i; } MyFancyStruct_Prepended; @@ -75,9 +75,9 @@ typedef struct { } Baz_Prepended_Body; typedef struct { - #ifdef __cplusplus +#ifdef __cplusplus inline void wohoo(); - #endif +#endif MyFancyEnum_Prepended_Tag tag; union { Bar_Prepended_Body bar_prepended; @@ -86,7 +86,7 @@ typedef struct { } MyFancyEnum_Prepended; typedef union { - int32_t extra_member; // yolo + int32_t extra_member; float f; uint32_t u; } MyUnion_Prepended; diff --git a/tests/expectations/body.compat.c b/tests/expectations/body.compat.c index 3db7c7e..1ac0825 100644 --- a/tests/expectations/body.compat.c +++ b/tests/expectations/body.compat.c @@ -18,7 +18,7 @@ typedef enum { typedef struct { int32_t i; #ifdef __cplusplus - inline void foo(); + inline void foo(); #endif } MyFancyStruct; @@ -43,19 +43,19 @@ typedef struct { Baz_Body baz; }; #ifdef __cplusplus - inline void wohoo(); + inline void wohoo(); #endif } MyFancyEnum; typedef union { float f; uint32_t u; - int32_t extra_member; // yolo + int32_t extra_member; } MyUnion; typedef struct { #ifdef __cplusplus - inline void prepended_wohoo(); + inline void prepended_wohoo(); #endif int32_t i; } MyFancyStruct_Prepended; @@ -75,9 +75,9 @@ typedef struct { } Baz_Prepended_Body; typedef struct { - #ifdef __cplusplus +#ifdef __cplusplus inline void wohoo(); - #endif +#endif MyFancyEnum_Prepended_Tag tag; union { Bar_Prepended_Body bar_prepended; @@ -86,7 +86,7 @@ typedef struct { } MyFancyEnum_Prepended; typedef union { - int32_t extra_member; // yolo + int32_t extra_member; float f; uint32_t u; } MyUnion_Prepended; diff --git a/tests/expectations/body.cpp b/tests/expectations/body.cpp index b720ff6..c982576 100644 --- a/tests/expectations/body.cpp +++ b/tests/expectations/body.cpp @@ -19,7 +19,7 @@ enum class MyCLikeEnum_Prepended { struct MyFancyStruct { int32_t i; #ifdef __cplusplus - inline void foo(); + inline void foo(); #endif }; @@ -44,27 +44,27 @@ struct MyFancyEnum { Baz_Body baz; }; #ifdef __cplusplus - inline void wohoo(); + inline void wohoo(); #endif }; union MyUnion { float f; uint32_t u; - int32_t extra_member; // yolo + int32_t extra_member; }; struct MyFancyStruct_Prepended { #ifdef __cplusplus - inline void prepended_wohoo(); + inline void prepended_wohoo(); #endif int32_t i; }; struct MyFancyEnum_Prepended { - #ifdef __cplusplus +#ifdef __cplusplus inline void wohoo(); - #endif +#endif enum class Tag { Foo_Prepended, Bar_Prepended, @@ -87,7 +87,7 @@ struct MyFancyEnum_Prepended { }; union MyUnion_Prepended { - int32_t extra_member; // yolo + int32_t extra_member; float f; uint32_t u; }; diff --git a/tests/expectations/body.pyx b/tests/expectations/body.pyx index 2f496c6..8b3018b 100644 --- a/tests/expectations/body.pyx +++ b/tests/expectations/body.pyx @@ -18,6 +18,9 @@ cdef extern from *: ctypedef struct MyFancyStruct: int32_t i; +#ifdef __cplusplus + inline void foo(); +#endif ctypedef enum MyFancyEnum_Tag: Foo, @@ -34,13 +37,19 @@ cdef extern from *: MyFancyEnum_Tag tag; Bar_Body bar; Baz_Body baz; +#ifdef __cplusplus + inline void wohoo(); +#endif ctypedef union MyUnion: float f; uint32_t u; - int32_t extra_member; # yolo + int32_t extra_member; ctypedef struct MyFancyStruct_Prepended: +#ifdef __cplusplus + inline void prepended_wohoo(); +#endif int32_t i; ctypedef enum MyFancyEnum_Prepended_Tag: @@ -55,12 +64,15 @@ cdef extern from *: int32_t _0; ctypedef struct MyFancyEnum_Prepended: +#ifdef __cplusplus + inline void wohoo(); +#endif MyFancyEnum_Prepended_Tag tag; Bar_Prepended_Body bar_prepended; Baz_Prepended_Body baz_prepended; ctypedef union MyUnion_Prepended: - int32_t extra_member; # yolo + int32_t extra_member; float f; uint32_t u; diff --git a/tests/expectations/body.tag.c b/tests/expectations/body.tag.c index fd3125e..8a74672 100644 --- a/tests/expectations/body.tag.c +++ b/tests/expectations/body.tag.c @@ -18,7 +18,7 @@ enum MyCLikeEnum_Prepended { struct MyFancyStruct { int32_t i; #ifdef __cplusplus - inline void foo(); + inline void foo(); #endif }; @@ -43,19 +43,19 @@ struct MyFancyEnum { struct Baz_Body baz; }; #ifdef __cplusplus - inline void wohoo(); + inline void wohoo(); #endif }; union MyUnion { float f; uint32_t u; - int32_t extra_member; // yolo + int32_t extra_member; }; struct MyFancyStruct_Prepended { #ifdef __cplusplus - inline void prepended_wohoo(); + inline void prepended_wohoo(); #endif int32_t i; }; @@ -75,9 +75,9 @@ struct Baz_Prepended_Body { }; struct MyFancyEnum_Prepended { - #ifdef __cplusplus +#ifdef __cplusplus inline void wohoo(); - #endif +#endif enum MyFancyEnum_Prepended_Tag tag; union { struct Bar_Prepended_Body bar_prepended; @@ -86,7 +86,7 @@ struct MyFancyEnum_Prepended { }; union MyUnion_Prepended { - int32_t extra_member; // yolo + int32_t extra_member; float f; uint32_t u; }; diff --git a/tests/expectations/body.tag.compat.c b/tests/expectations/body.tag.compat.c index 9b1e657..b62f866 100644 --- a/tests/expectations/body.tag.compat.c +++ b/tests/expectations/body.tag.compat.c @@ -18,7 +18,7 @@ enum MyCLikeEnum_Prepended { struct MyFancyStruct { int32_t i; #ifdef __cplusplus - inline void foo(); + inline void foo(); #endif }; @@ -43,19 +43,19 @@ struct MyFancyEnum { struct Baz_Body baz; }; #ifdef __cplusplus - inline void wohoo(); + inline void wohoo(); #endif }; union MyUnion { float f; uint32_t u; - int32_t extra_member; // yolo + int32_t extra_member; }; struct MyFancyStruct_Prepended { #ifdef __cplusplus - inline void prepended_wohoo(); + inline void prepended_wohoo(); #endif int32_t i; }; @@ -75,9 +75,9 @@ struct Baz_Prepended_Body { }; struct MyFancyEnum_Prepended { - #ifdef __cplusplus +#ifdef __cplusplus inline void wohoo(); - #endif +#endif enum MyFancyEnum_Prepended_Tag tag; union { struct Bar_Prepended_Body bar_prepended; @@ -86,7 +86,7 @@ struct MyFancyEnum_Prepended { }; union MyUnion_Prepended { - int32_t extra_member; // yolo + int32_t extra_member; float f; uint32_t u; }; diff --git a/tests/expectations/body.tag.pyx b/tests/expectations/body.tag.pyx index cd8e24b..84d282e 100644 --- a/tests/expectations/body.tag.pyx +++ b/tests/expectations/body.tag.pyx @@ -18,6 +18,9 @@ cdef extern from *: cdef struct MyFancyStruct: int32_t i; +#ifdef __cplusplus + inline void foo(); +#endif cdef enum MyFancyEnum_Tag: Foo, @@ -34,13 +37,19 @@ cdef extern from *: MyFancyEnum_Tag tag; Bar_Body bar; Baz_Body baz; +#ifdef __cplusplus + inline void wohoo(); +#endif cdef union MyUnion: float f; uint32_t u; - int32_t extra_member; # yolo + int32_t extra_member; cdef struct MyFancyStruct_Prepended: +#ifdef __cplusplus + inline void prepended_wohoo(); +#endif int32_t i; cdef enum MyFancyEnum_Prepended_Tag: @@ -55,12 +64,15 @@ cdef extern from *: int32_t _0; cdef struct MyFancyEnum_Prepended: +#ifdef __cplusplus + inline void wohoo(); +#endif MyFancyEnum_Prepended_Tag tag; Bar_Prepended_Body bar_prepended; Baz_Prepended_Body baz_prepended; cdef union MyUnion_Prepended: - int32_t extra_member; # yolo + int32_t extra_member; float f; uint32_t u; diff --git a/tests/expectations/box.both.c b/tests/expectations/box.both.c index e7f0edb..78fe934 100644 --- a/tests/expectations/box.both.c +++ b/tests/expectations/box.both.c @@ -1,8 +1,16 @@ +#if 0 +''' ' +#endif + #ifdef __cplusplus template using Box = T*; #endif +#if 0 +' ''' +#endif + #include #include diff --git a/tests/expectations/box.both.compat.c b/tests/expectations/box.both.compat.c index 024af3e..484671e 100644 --- a/tests/expectations/box.both.compat.c +++ b/tests/expectations/box.both.compat.c @@ -1,8 +1,16 @@ +#if 0 +''' ' +#endif + #ifdef __cplusplus template using Box = T*; #endif +#if 0 +' ''' +#endif + #include #include diff --git a/tests/expectations/box.c b/tests/expectations/box.c index 840bfae..8c117c8 100644 --- a/tests/expectations/box.c +++ b/tests/expectations/box.c @@ -1,8 +1,16 @@ +#if 0 +''' ' +#endif + #ifdef __cplusplus template using Box = T*; #endif +#if 0 +' ''' +#endif + #include #include diff --git a/tests/expectations/box.compat.c b/tests/expectations/box.compat.c index 70d62ac..e882a12 100644 --- a/tests/expectations/box.compat.c +++ b/tests/expectations/box.compat.c @@ -1,8 +1,16 @@ +#if 0 +''' ' +#endif + #ifdef __cplusplus template using Box = T*; #endif +#if 0 +' ''' +#endif + #include #include diff --git a/tests/expectations/box.cpp b/tests/expectations/box.cpp index ac0bcbe..423c987 100644 --- a/tests/expectations/box.cpp +++ b/tests/expectations/box.cpp @@ -1,8 +1,16 @@ +#if 0 +''' ' +#endif + #ifdef __cplusplus template using Box = T*; #endif +#if 0 +' ''' +#endif + #include #include diff --git a/tests/expectations/box.pyx b/tests/expectations/box.pyx index f89a5cf..d31cd87 100644 --- a/tests/expectations/box.pyx +++ b/tests/expectations/box.pyx @@ -1,3 +1,17 @@ +#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.tag.c b/tests/expectations/box.tag.c index e3a6aee..2e5a8cb 100644 --- a/tests/expectations/box.tag.c +++ b/tests/expectations/box.tag.c @@ -1,8 +1,16 @@ +#if 0 +''' ' +#endif + #ifdef __cplusplus template using Box = T*; #endif +#if 0 +' ''' +#endif + #include #include diff --git a/tests/expectations/box.tag.compat.c b/tests/expectations/box.tag.compat.c index d8cbb1a..0f2fd42 100644 --- a/tests/expectations/box.tag.compat.c +++ b/tests/expectations/box.tag.compat.c @@ -1,8 +1,16 @@ +#if 0 +''' ' +#endif + #ifdef __cplusplus template using Box = T*; #endif +#if 0 +' ''' +#endif + #include #include diff --git a/tests/expectations/box.tag.pyx b/tests/expectations/box.tag.pyx index c347de9..8fb0191 100644 --- a/tests/expectations/box.tag.pyx +++ b/tests/expectations/box.tag.pyx @@ -1,3 +1,17 @@ +#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/cfg.both.c b/tests/expectations/cfg.both.c index a3242f9..666587d 100644 --- a/tests/expectations/cfg.both.c +++ b/tests/expectations/cfg.both.c @@ -1,3 +1,11 @@ +#if 0 +DEF PLATFORM_UNIX = 0 +DEF PLATFORM_WIN = 0 +DEF X11 = 0 +DEF M_32 = 0 +#endif + + #include #include #include diff --git a/tests/expectations/cfg.both.compat.c b/tests/expectations/cfg.both.compat.c index 63df735..036cbf3 100644 --- a/tests/expectations/cfg.both.compat.c +++ b/tests/expectations/cfg.both.compat.c @@ -1,3 +1,11 @@ +#if 0 +DEF PLATFORM_UNIX = 0 +DEF PLATFORM_WIN = 0 +DEF X11 = 0 +DEF M_32 = 0 +#endif + + #include #include #include diff --git a/tests/expectations/cfg.c b/tests/expectations/cfg.c index 7cf77b3..e2ebeb8 100644 --- a/tests/expectations/cfg.c +++ b/tests/expectations/cfg.c @@ -1,3 +1,11 @@ +#if 0 +DEF PLATFORM_UNIX = 0 +DEF PLATFORM_WIN = 0 +DEF X11 = 0 +DEF M_32 = 0 +#endif + + #include #include #include diff --git a/tests/expectations/cfg.compat.c b/tests/expectations/cfg.compat.c index 6f9dc7a..5208ede 100644 --- a/tests/expectations/cfg.compat.c +++ b/tests/expectations/cfg.compat.c @@ -1,3 +1,11 @@ +#if 0 +DEF PLATFORM_UNIX = 0 +DEF PLATFORM_WIN = 0 +DEF X11 = 0 +DEF M_32 = 0 +#endif + + #include #include #include diff --git a/tests/expectations/cfg.cpp b/tests/expectations/cfg.cpp index 45669ff..d227e0c 100644 --- a/tests/expectations/cfg.cpp +++ b/tests/expectations/cfg.cpp @@ -1,3 +1,11 @@ +#if 0 +DEF PLATFORM_UNIX = 0 +DEF PLATFORM_WIN = 0 +DEF X11 = 0 +DEF M_32 = 0 +#endif + + #include #include #include diff --git a/tests/expectations/cfg.pyx b/tests/expectations/cfg.pyx index 94ba1fb..19768fe 100644 --- a/tests/expectations/cfg.pyx +++ b/tests/expectations/cfg.pyx @@ -1,7 +1,9 @@ +#if 0 DEF PLATFORM_UNIX = 0 DEF PLATFORM_WIN = 0 DEF X11 = 0 DEF M_32 = 0 +#endif from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t @@ -32,6 +34,21 @@ cdef extern from *: int32_t x; float y; + cdef enum: + C1, + C2, + C3, + C5, + ctypedef uint8_t C_Tag; + + ctypedef struct C5_Body: + C_Tag tag; + int32_t int_; + + ctypedef union C: + C_Tag tag; + C5_Body c5; + IF (PLATFORM_WIN or M_32): ctypedef struct BarHandle: BarType ty; diff --git a/tests/expectations/cfg.tag.c b/tests/expectations/cfg.tag.c index 89d04e1..b9c7977 100644 --- a/tests/expectations/cfg.tag.c +++ b/tests/expectations/cfg.tag.c @@ -1,3 +1,11 @@ +#if 0 +DEF PLATFORM_UNIX = 0 +DEF PLATFORM_WIN = 0 +DEF X11 = 0 +DEF M_32 = 0 +#endif + + #include #include #include diff --git a/tests/expectations/cfg.tag.compat.c b/tests/expectations/cfg.tag.compat.c index d8bed6d..03b9b00 100644 --- a/tests/expectations/cfg.tag.compat.c +++ b/tests/expectations/cfg.tag.compat.c @@ -1,3 +1,11 @@ +#if 0 +DEF PLATFORM_UNIX = 0 +DEF PLATFORM_WIN = 0 +DEF X11 = 0 +DEF M_32 = 0 +#endif + + #include #include #include diff --git a/tests/expectations/cfg.tag.pyx b/tests/expectations/cfg.tag.pyx index 7b7de4a..5a1dbba 100644 --- a/tests/expectations/cfg.tag.pyx +++ b/tests/expectations/cfg.tag.pyx @@ -1,7 +1,9 @@ +#if 0 DEF PLATFORM_UNIX = 0 DEF PLATFORM_WIN = 0 DEF X11 = 0 DEF M_32 = 0 +#endif from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t @@ -32,6 +34,21 @@ cdef extern from *: int32_t x; float y; + cdef enum: + C1, + C2, + C3, + C5, + ctypedef uint8_t C_Tag; + + cdef struct C5_Body: + C_Tag tag; + int32_t int_; + + cdef union C: + C_Tag tag; + C5_Body c5; + IF (PLATFORM_WIN or M_32): cdef struct BarHandle: BarType ty; diff --git a/tests/expectations/cfg_2.both.c b/tests/expectations/cfg_2.both.c index dcedc22..2afee1d 100644 --- a/tests/expectations/cfg_2.both.c +++ b/tests/expectations/cfg_2.both.c @@ -1,3 +1,9 @@ +#if 0 +DEF DEFINED = 1 +DEF NOT_DEFINED = 0 +#endif + + #include #include #include diff --git a/tests/expectations/cfg_2.both.compat.c b/tests/expectations/cfg_2.both.compat.c index 3516b73..4b1b5f5 100644 --- a/tests/expectations/cfg_2.both.compat.c +++ b/tests/expectations/cfg_2.both.compat.c @@ -1,3 +1,9 @@ +#if 0 +DEF DEFINED = 1 +DEF NOT_DEFINED = 0 +#endif + + #include #include #include diff --git a/tests/expectations/cfg_2.c b/tests/expectations/cfg_2.c index 44adcc7..d63ec5f 100644 --- a/tests/expectations/cfg_2.c +++ b/tests/expectations/cfg_2.c @@ -1,3 +1,9 @@ +#if 0 +DEF DEFINED = 1 +DEF NOT_DEFINED = 0 +#endif + + #include #include #include diff --git a/tests/expectations/cfg_2.compat.c b/tests/expectations/cfg_2.compat.c index 4885e6e..6a0047a 100644 --- a/tests/expectations/cfg_2.compat.c +++ b/tests/expectations/cfg_2.compat.c @@ -1,3 +1,9 @@ +#if 0 +DEF DEFINED = 1 +DEF NOT_DEFINED = 0 +#endif + + #include #include #include diff --git a/tests/expectations/cfg_2.cpp b/tests/expectations/cfg_2.cpp index 8e36fc3..cddb7a4 100644 --- a/tests/expectations/cfg_2.cpp +++ b/tests/expectations/cfg_2.cpp @@ -1,3 +1,9 @@ +#if 0 +DEF DEFINED = 1 +DEF NOT_DEFINED = 0 +#endif + + #include #include #include diff --git a/tests/expectations/cfg_2.pyx b/tests/expectations/cfg_2.pyx index ba9383a..c8a6e5e 100644 --- a/tests/expectations/cfg_2.pyx +++ b/tests/expectations/cfg_2.pyx @@ -1,5 +1,7 @@ +#if 0 DEF DEFINED = 1 DEF NOT_DEFINED = 0 +#endif from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t diff --git a/tests/expectations/cfg_2.tag.c b/tests/expectations/cfg_2.tag.c index 2fcc464..6230738 100644 --- a/tests/expectations/cfg_2.tag.c +++ b/tests/expectations/cfg_2.tag.c @@ -1,3 +1,9 @@ +#if 0 +DEF DEFINED = 1 +DEF NOT_DEFINED = 0 +#endif + + #include #include #include diff --git a/tests/expectations/cfg_2.tag.compat.c b/tests/expectations/cfg_2.tag.compat.c index 2eda4b6..62a258d 100644 --- a/tests/expectations/cfg_2.tag.compat.c +++ b/tests/expectations/cfg_2.tag.compat.c @@ -1,3 +1,9 @@ +#if 0 +DEF DEFINED = 1 +DEF NOT_DEFINED = 0 +#endif + + #include #include #include diff --git a/tests/expectations/cfg_2.tag.pyx b/tests/expectations/cfg_2.tag.pyx index d6813fe..4ce0573 100644 --- a/tests/expectations/cfg_2.tag.pyx +++ b/tests/expectations/cfg_2.tag.pyx @@ -1,5 +1,7 @@ +#if 0 DEF DEFINED = 1 DEF NOT_DEFINED = 0 +#endif from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t diff --git a/tests/expectations/constant.both.c b/tests/expectations/constant.both.c index 5528f4f..8c01ab6 100644 --- a/tests/expectations/constant.both.c +++ b/tests/expectations/constant.both.c @@ -38,9 +38,11 @@ #define XBOOL 1 -#define XFALSE ((0 << SHIFT) | XBOOL) +#define XFALSE1 ((0 << 3) | 1) -#define XTRUE (1 << (SHIFT | XBOOL)) +#define XTRUE1 (1 << (3 | 1)) + +#define XFALSE2 (0 << SHIFT) #define CAST (uint8_t)'A' diff --git a/tests/expectations/constant.both.compat.c b/tests/expectations/constant.both.compat.c index 941b77b..3dfe508 100644 --- a/tests/expectations/constant.both.compat.c +++ b/tests/expectations/constant.both.compat.c @@ -38,9 +38,11 @@ #define XBOOL 1 -#define XFALSE ((0 << SHIFT) | XBOOL) +#define XFALSE1 ((0 << 3) | 1) -#define XTRUE (1 << (SHIFT | XBOOL)) +#define XTRUE1 (1 << (3 | 1)) + +#define XFALSE2 (0 << SHIFT) #define CAST (uint8_t)'A' diff --git a/tests/expectations/constant.c b/tests/expectations/constant.c index 3ae4680..831b205 100644 --- a/tests/expectations/constant.c +++ b/tests/expectations/constant.c @@ -38,9 +38,11 @@ #define XBOOL 1 -#define XFALSE ((0 << SHIFT) | XBOOL) +#define XFALSE1 ((0 << 3) | 1) -#define XTRUE (1 << (SHIFT | XBOOL)) +#define XTRUE1 (1 << (3 | 1)) + +#define XFALSE2 (0 << SHIFT) #define CAST (uint8_t)'A' diff --git a/tests/expectations/constant.compat.c b/tests/expectations/constant.compat.c index 654a75e..a14a251 100644 --- a/tests/expectations/constant.compat.c +++ b/tests/expectations/constant.compat.c @@ -38,9 +38,11 @@ #define XBOOL 1 -#define XFALSE ((0 << SHIFT) | XBOOL) +#define XFALSE1 ((0 << 3) | 1) -#define XTRUE (1 << (SHIFT | XBOOL)) +#define XTRUE1 (1 << (3 | 1)) + +#define XFALSE2 (0 << SHIFT) #define CAST (uint8_t)'A' diff --git a/tests/expectations/constant.cpp b/tests/expectations/constant.cpp index c8196d3..8c233ae 100644 --- a/tests/expectations/constant.cpp +++ b/tests/expectations/constant.cpp @@ -35,9 +35,11 @@ static const int64_t SHIFT = 3; static const int64_t XBOOL = 1; -static const int64_t XFALSE = ((0 << SHIFT) | XBOOL); +static const int64_t XFALSE1 = ((0 << 3) | 1); -static const int64_t XTRUE = (1 << (SHIFT | XBOOL)); +static const int64_t XTRUE1 = (1 << (3 | 1)); + +static const int64_t XFALSE2 = (0 << SHIFT); static const uint8_t CAST = (uint8_t)'A'; diff --git a/tests/expectations/constant.pyx b/tests/expectations/constant.pyx index 48a3aa5..417b083 100644 --- a/tests/expectations/constant.pyx +++ b/tests/expectations/constant.pyx @@ -37,6 +37,12 @@ cdef extern from *: const int64_t XBOOL = 1; + const int64_t XFALSE1 = ((0 << 3) | 1); + + const int64_t XTRUE1 = (1 << (3 | 1)); + + const int64_t XFALSE2 = (0 << SHIFT); + const uint8_t CAST = 'A'; const uint32_t DOUBLE_CAST = 1; diff --git a/tests/expectations/constant.tag.c b/tests/expectations/constant.tag.c index b5aa355..6b776ae 100644 --- a/tests/expectations/constant.tag.c +++ b/tests/expectations/constant.tag.c @@ -38,9 +38,11 @@ #define XBOOL 1 -#define XFALSE ((0 << SHIFT) | XBOOL) +#define XFALSE1 ((0 << 3) | 1) -#define XTRUE (1 << (SHIFT | XBOOL)) +#define XTRUE1 (1 << (3 | 1)) + +#define XFALSE2 (0 << SHIFT) #define CAST (uint8_t)'A' diff --git a/tests/expectations/constant.tag.compat.c b/tests/expectations/constant.tag.compat.c index 2154e49..f9f9889 100644 --- a/tests/expectations/constant.tag.compat.c +++ b/tests/expectations/constant.tag.compat.c @@ -38,9 +38,11 @@ #define XBOOL 1 -#define XFALSE ((0 << SHIFT) | XBOOL) +#define XFALSE1 ((0 << 3) | 1) -#define XTRUE (1 << (SHIFT | XBOOL)) +#define XTRUE1 (1 << (3 | 1)) + +#define XFALSE2 (0 << SHIFT) #define CAST (uint8_t)'A' diff --git a/tests/expectations/constant.tag.pyx b/tests/expectations/constant.tag.pyx index e64f5bf..0557f2f 100644 --- a/tests/expectations/constant.tag.pyx +++ b/tests/expectations/constant.tag.pyx @@ -37,6 +37,12 @@ cdef extern from *: const int64_t XBOOL = 1; + const int64_t XFALSE1 = ((0 << 3) | 1); + + const int64_t XTRUE1 = (1 << (3 | 1)); + + const int64_t XFALSE2 = (0 << SHIFT); + const uint8_t CAST = 'A'; const uint32_t DOUBLE_CAST = 1; diff --git a/tests/expectations/custom_header.c b/tests/expectations/custom_header.c index 3484920..0c9a83b 100644 --- a/tests/expectations/custom_header.c +++ b/tests/expectations/custom_header.c @@ -1,5 +1,10 @@ -// This file is generated by cbindgen. DO NOT EDIT +#if 0 +# This file is generated by cbindgen. DO NOT EDIT +#endif + void root(void); -/* This is a simple test to ensure that trailers don't cause extra newlines in files */ +#if 0 +# This is a simple test to ensure that trailers do not cause extra newlines in files +#endif diff --git a/tests/expectations/custom_header.compat.c b/tests/expectations/custom_header.compat.c index 1d3e044..7adabf2 100644 --- a/tests/expectations/custom_header.compat.c +++ b/tests/expectations/custom_header.compat.c @@ -1,4 +1,7 @@ -// This file is generated by cbindgen. DO NOT EDIT +#if 0 +# This file is generated by cbindgen. DO NOT EDIT +#endif + #ifdef __cplusplus extern "C" { @@ -10,4 +13,6 @@ void root(void); } // extern "C" #endif // __cplusplus -/* This is a simple test to ensure that trailers don't cause extra newlines in files */ +#if 0 +# This is a simple test to ensure that trailers do not cause extra newlines in files +#endif diff --git a/tests/expectations/custom_header.cpp b/tests/expectations/custom_header.cpp index 9d013f5..c7313b1 100644 --- a/tests/expectations/custom_header.cpp +++ b/tests/expectations/custom_header.cpp @@ -1,4 +1,7 @@ -// This file is generated by cbindgen. DO NOT EDIT +#if 0 +# This file is generated by cbindgen. DO NOT EDIT +#endif + extern "C" { @@ -6,4 +9,6 @@ void root(); } // extern "C" -/* This is a simple test to ensure that trailers don't cause extra newlines in files */ +#if 0 +# This is a simple test to ensure that trailers do not cause extra newlines in files +#endif diff --git a/tests/expectations/custom_header.pyx b/tests/expectations/custom_header.pyx index ebba482..eaef46c 100644 --- a/tests/expectations/custom_header.pyx +++ b/tests/expectations/custom_header.pyx @@ -1,7 +1,12 @@ +#if 0 # This file is generated by cbindgen. DO NOT EDIT +#endif + cdef extern from *: void root(); -# This is a simple test to ensure that trailers don't cause extra newlines in files +#if 0 +# This is a simple test to ensure that trailers do not cause extra newlines in files +#endif diff --git a/tests/expectations/enum.both.c b/tests/expectations/enum.both.c index 0a2a202..94b061b 100644 --- a/tests/expectations/enum.both.c +++ b/tests/expectations/enum.both.c @@ -199,9 +199,17 @@ void root(Opaque *opaque, O o, P p); +#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 5b93c76..e7276e3 100644 --- a/tests/expectations/enum.both.compat.c +++ b/tests/expectations/enum.both.compat.c @@ -273,9 +273,17 @@ 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.c b/tests/expectations/enum.c index 2cb8fac..2977033 100644 --- a/tests/expectations/enum.c +++ b/tests/expectations/enum.c @@ -199,9 +199,17 @@ void root(Opaque *opaque, O o, P p); +#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 075f27e..77ff924 100644 --- a/tests/expectations/enum.compat.c +++ b/tests/expectations/enum.compat.c @@ -273,9 +273,17 @@ 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 ecd6991..b3f15b1 100644 --- a/tests/expectations/enum.cpp +++ b/tests/expectations/enum.cpp @@ -195,9 +195,17 @@ 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 7b099f7..5fe9687 100644 --- a/tests/expectations/enum.pyx +++ b/tests/expectations/enum.pyx @@ -172,3 +172,18 @@ cdef extern from *: N n, O o, P p); + +#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 03d59f2..73eb5e6 100644 --- a/tests/expectations/enum.tag.c +++ b/tests/expectations/enum.tag.c @@ -199,9 +199,17 @@ void root(struct Opaque *opaque, O o, struct P p); +#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 21aafa3..74d0366 100644 --- a/tests/expectations/enum.tag.compat.c +++ b/tests/expectations/enum.tag.compat.c @@ -273,9 +273,17 @@ 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 87b24e6..9b1bc7a 100644 --- a/tests/expectations/enum.tag.pyx +++ b/tests/expectations/enum.tag.pyx @@ -172,3 +172,18 @@ cdef extern from *: N n, O o, P p); + +#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_discriminant.c b/tests/expectations/enum_discriminant.c index cbc7aea..ea1ae94 100644 --- a/tests/expectations/enum_discriminant.c +++ b/tests/expectations/enum_discriminant.c @@ -11,15 +11,9 @@ enum E { C = (1 + 2), D = FOUR, F = 5, + G = (int8_t)54, + H = (int8_t)false, }; typedef int8_t E; -enum E_NoCython { - G = (int8_t)'6', - H = (int8_t)false, -}; -typedef int8_t E_NoCython; - void root(const E*); - -void root_no_cython(const E_NoCython*); diff --git a/tests/expectations/enum_discriminant.compat.c b/tests/expectations/enum_discriminant.compat.c index 4aea7e0..2d41668 100644 --- a/tests/expectations/enum_discriminant.compat.c +++ b/tests/expectations/enum_discriminant.compat.c @@ -15,21 +15,11 @@ enum E C = (1 + 2), D = FOUR, F = 5, -}; -#ifndef __cplusplus -typedef int8_t E; -#endif // __cplusplus - -enum E_NoCython -#ifdef __cplusplus - : int8_t -#endif // __cplusplus - { - G = (int8_t)'6', + G = (int8_t)54, H = (int8_t)false, }; #ifndef __cplusplus -typedef int8_t E_NoCython; +typedef int8_t E; #endif // __cplusplus #ifdef __cplusplus @@ -38,8 +28,6 @@ extern "C" { void root(const E*); -void root_no_cython(const E_NoCython*); - #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/tests/expectations/enum_discriminant.cpp b/tests/expectations/enum_discriminant.cpp index 1d17ace..95a391c 100644 --- a/tests/expectations/enum_discriminant.cpp +++ b/tests/expectations/enum_discriminant.cpp @@ -12,10 +12,7 @@ enum class E : int8_t { C = (1 + 2), D = FOUR, F = 5, -}; - -enum class E_NoCython : int8_t { - G = (int8_t)'6', + G = (int8_t)54, H = (int8_t)false, }; @@ -23,6 +20,4 @@ extern "C" { void root(const E*); -void root_no_cython(const E_NoCython*); - } // extern "C" diff --git a/tests/expectations/enum_discriminant.pyx b/tests/expectations/enum_discriminant.pyx index 8f475d9..366b132 100644 --- a/tests/expectations/enum_discriminant.pyx +++ b/tests/expectations/enum_discriminant.pyx @@ -14,6 +14,8 @@ cdef extern from *: C = (1 + 2), D = FOUR, F = 5, + G = 54, + H = False, ctypedef int8_t E; void root(const E*); diff --git a/tests/expectations/exclude_generic_monomorph.both.c b/tests/expectations/exclude_generic_monomorph.both.c index 2d43ce1..b8983e1 100644 --- a/tests/expectations/exclude_generic_monomorph.both.c +++ b/tests/expectations/exclude_generic_monomorph.both.c @@ -1,7 +1,20 @@ #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 76a0a3b..0de5b6b 100644 --- a/tests/expectations/exclude_generic_monomorph.both.compat.c +++ b/tests/expectations/exclude_generic_monomorph.both.compat.c @@ -1,7 +1,20 @@ #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.c b/tests/expectations/exclude_generic_monomorph.c index e717836..a593dd7 100644 --- a/tests/expectations/exclude_generic_monomorph.c +++ b/tests/expectations/exclude_generic_monomorph.c @@ -1,7 +1,20 @@ #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 062e71c..5c10d43 100644 --- a/tests/expectations/exclude_generic_monomorph.compat.c +++ b/tests/expectations/exclude_generic_monomorph.compat.c @@ -1,7 +1,20 @@ #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 e717836..a593dd7 100644 --- a/tests/expectations/exclude_generic_monomorph.cpp +++ b/tests/expectations/exclude_generic_monomorph.cpp @@ -1,7 +1,20 @@ #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 2b4faba..48cd1e2 100644 --- a/tests/expectations/exclude_generic_monomorph.pyx +++ b/tests/expectations/exclude_generic_monomorph.pyx @@ -1,5 +1,19 @@ +#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 from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t diff --git a/tests/expectations/exclude_generic_monomorph.tag.c b/tests/expectations/exclude_generic_monomorph.tag.c index 32686ad..116a170 100644 --- a/tests/expectations/exclude_generic_monomorph.tag.c +++ b/tests/expectations/exclude_generic_monomorph.tag.c @@ -1,7 +1,20 @@ #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 2740851..fa8e3a1 100644 --- a/tests/expectations/exclude_generic_monomorph.tag.compat.c +++ b/tests/expectations/exclude_generic_monomorph.tag.compat.c @@ -1,7 +1,20 @@ #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 d0b3aeb..934536f 100644 --- a/tests/expectations/exclude_generic_monomorph.tag.pyx +++ b/tests/expectations/exclude_generic_monomorph.tag.pyx @@ -1,5 +1,19 @@ +#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 from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t diff --git a/tests/expectations/manuallydrop.both.c b/tests/expectations/manuallydrop.both.c index c2f72a3..7067cfb 100644 --- a/tests/expectations/manuallydrop.both.c +++ b/tests/expectations/manuallydrop.both.c @@ -1,8 +1,16 @@ +#if 0 +''' ' +#endif + #ifdef __cplusplus template using ManuallyDrop = T; #endif +#if 0 +' ''' +#endif + #include #include diff --git a/tests/expectations/manuallydrop.both.compat.c b/tests/expectations/manuallydrop.both.compat.c index 551f9e7..7900dee 100644 --- a/tests/expectations/manuallydrop.both.compat.c +++ b/tests/expectations/manuallydrop.both.compat.c @@ -1,8 +1,16 @@ +#if 0 +''' ' +#endif + #ifdef __cplusplus template using ManuallyDrop = T; #endif +#if 0 +' ''' +#endif + #include #include diff --git a/tests/expectations/manuallydrop.c b/tests/expectations/manuallydrop.c index c8eb148..8e744db 100644 --- a/tests/expectations/manuallydrop.c +++ b/tests/expectations/manuallydrop.c @@ -1,8 +1,16 @@ +#if 0 +''' ' +#endif + #ifdef __cplusplus template using ManuallyDrop = T; #endif +#if 0 +' ''' +#endif + #include #include diff --git a/tests/expectations/manuallydrop.compat.c b/tests/expectations/manuallydrop.compat.c index 3a766d4..e086665 100644 --- a/tests/expectations/manuallydrop.compat.c +++ b/tests/expectations/manuallydrop.compat.c @@ -1,8 +1,16 @@ +#if 0 +''' ' +#endif + #ifdef __cplusplus template using ManuallyDrop = T; #endif +#if 0 +' ''' +#endif + #include #include diff --git a/tests/expectations/manuallydrop.cpp b/tests/expectations/manuallydrop.cpp index 7a1e505..3f46196 100644 --- a/tests/expectations/manuallydrop.cpp +++ b/tests/expectations/manuallydrop.cpp @@ -1,8 +1,16 @@ +#if 0 +''' ' +#endif + #ifdef __cplusplus template using ManuallyDrop = T; #endif +#if 0 +' ''' +#endif + #include #include diff --git a/tests/expectations/manuallydrop.pyx b/tests/expectations/manuallydrop.pyx index 423bdc7..c35222a 100644 --- a/tests/expectations/manuallydrop.pyx +++ b/tests/expectations/manuallydrop.pyx @@ -1,3 +1,17 @@ +#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.tag.c b/tests/expectations/manuallydrop.tag.c index 8a0f8da..25cb4b5 100644 --- a/tests/expectations/manuallydrop.tag.c +++ b/tests/expectations/manuallydrop.tag.c @@ -1,8 +1,16 @@ +#if 0 +''' ' +#endif + #ifdef __cplusplus template using ManuallyDrop = T; #endif +#if 0 +' ''' +#endif + #include #include diff --git a/tests/expectations/manuallydrop.tag.compat.c b/tests/expectations/manuallydrop.tag.compat.c index 113bcb5..30d0434 100644 --- a/tests/expectations/manuallydrop.tag.compat.c +++ b/tests/expectations/manuallydrop.tag.compat.c @@ -1,8 +1,16 @@ +#if 0 +''' ' +#endif + #ifdef __cplusplus template using ManuallyDrop = T; #endif +#if 0 +' ''' +#endif + #include #include diff --git a/tests/expectations/manuallydrop.tag.pyx b/tests/expectations/manuallydrop.tag.pyx index e326533..e4ca2ff 100644 --- a/tests/expectations/manuallydrop.tag.pyx +++ b/tests/expectations/manuallydrop.tag.pyx @@ -1,3 +1,17 @@ +#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.both.c b/tests/expectations/maybeuninit.both.c index 2eb4dd2..a1e6015 100644 --- a/tests/expectations/maybeuninit.both.c +++ b/tests/expectations/maybeuninit.both.c @@ -1,8 +1,16 @@ +#if 0 +''' ' +#endif + #ifdef __cplusplus template using MaybeUninit = T; #endif +#if 0 +' ''' +#endif + #include #include diff --git a/tests/expectations/maybeuninit.both.compat.c b/tests/expectations/maybeuninit.both.compat.c index b840faa..e02983b 100644 --- a/tests/expectations/maybeuninit.both.compat.c +++ b/tests/expectations/maybeuninit.both.compat.c @@ -1,8 +1,16 @@ +#if 0 +''' ' +#endif + #ifdef __cplusplus template using MaybeUninit = T; #endif +#if 0 +' ''' +#endif + #include #include diff --git a/tests/expectations/maybeuninit.c b/tests/expectations/maybeuninit.c index 8120540..3f39925 100644 --- a/tests/expectations/maybeuninit.c +++ b/tests/expectations/maybeuninit.c @@ -1,8 +1,16 @@ +#if 0 +''' ' +#endif + #ifdef __cplusplus template using MaybeUninit = T; #endif +#if 0 +' ''' +#endif + #include #include diff --git a/tests/expectations/maybeuninit.compat.c b/tests/expectations/maybeuninit.compat.c index 8b31d2a..3aa30ce 100644 --- a/tests/expectations/maybeuninit.compat.c +++ b/tests/expectations/maybeuninit.compat.c @@ -1,8 +1,16 @@ +#if 0 +''' ' +#endif + #ifdef __cplusplus template using MaybeUninit = T; #endif +#if 0 +' ''' +#endif + #include #include diff --git a/tests/expectations/maybeuninit.cpp b/tests/expectations/maybeuninit.cpp index e0f7755..83d8515 100644 --- a/tests/expectations/maybeuninit.cpp +++ b/tests/expectations/maybeuninit.cpp @@ -1,8 +1,16 @@ +#if 0 +''' ' +#endif + #ifdef __cplusplus template using MaybeUninit = T; #endif +#if 0 +' ''' +#endif + #include #include diff --git a/tests/expectations/maybeuninit.pyx b/tests/expectations/maybeuninit.pyx index 6914dd5..cc67cae 100644 --- a/tests/expectations/maybeuninit.pyx +++ b/tests/expectations/maybeuninit.pyx @@ -1,3 +1,17 @@ +#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.tag.c b/tests/expectations/maybeuninit.tag.c index 56075ed..b0051f0 100644 --- a/tests/expectations/maybeuninit.tag.c +++ b/tests/expectations/maybeuninit.tag.c @@ -1,8 +1,16 @@ +#if 0 +''' ' +#endif + #ifdef __cplusplus template using MaybeUninit = T; #endif +#if 0 +' ''' +#endif + #include #include diff --git a/tests/expectations/maybeuninit.tag.compat.c b/tests/expectations/maybeuninit.tag.compat.c index 2a75f8b..3c7df34 100644 --- a/tests/expectations/maybeuninit.tag.compat.c +++ b/tests/expectations/maybeuninit.tag.compat.c @@ -1,8 +1,16 @@ +#if 0 +''' ' +#endif + #ifdef __cplusplus template using MaybeUninit = T; #endif +#if 0 +' ''' +#endif + #include #include diff --git a/tests/expectations/maybeuninit.tag.pyx b/tests/expectations/maybeuninit.tag.pyx index 0a2dae4..88dcbf6 100644 --- a/tests/expectations/maybeuninit.tag.pyx +++ b/tests/expectations/maybeuninit.tag.pyx @@ -1,3 +1,17 @@ +#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/mod_attr.both.c b/tests/expectations/mod_attr.both.c index c9815c0..cb7dab4 100644 --- a/tests/expectations/mod_attr.both.c +++ b/tests/expectations/mod_attr.both.c @@ -1,3 +1,9 @@ +#if 0 +DEF FOO = 0 +DEF BAR = 0 +#endif + + #include #include #include diff --git a/tests/expectations/mod_attr.both.compat.c b/tests/expectations/mod_attr.both.compat.c index fcf178f..5316f65 100644 --- a/tests/expectations/mod_attr.both.compat.c +++ b/tests/expectations/mod_attr.both.compat.c @@ -1,3 +1,9 @@ +#if 0 +DEF FOO = 0 +DEF BAR = 0 +#endif + + #include #include #include diff --git a/tests/expectations/mod_attr.c b/tests/expectations/mod_attr.c index 0f41156..63c36be 100644 --- a/tests/expectations/mod_attr.c +++ b/tests/expectations/mod_attr.c @@ -1,3 +1,9 @@ +#if 0 +DEF FOO = 0 +DEF BAR = 0 +#endif + + #include #include #include diff --git a/tests/expectations/mod_attr.compat.c b/tests/expectations/mod_attr.compat.c index fded9f0..0098503 100644 --- a/tests/expectations/mod_attr.compat.c +++ b/tests/expectations/mod_attr.compat.c @@ -1,3 +1,9 @@ +#if 0 +DEF FOO = 0 +DEF BAR = 0 +#endif + + #include #include #include diff --git a/tests/expectations/mod_attr.cpp b/tests/expectations/mod_attr.cpp index b49ce70..dd8a63d 100644 --- a/tests/expectations/mod_attr.cpp +++ b/tests/expectations/mod_attr.cpp @@ -1,3 +1,9 @@ +#if 0 +DEF FOO = 0 +DEF BAR = 0 +#endif + + #include #include #include diff --git a/tests/expectations/mod_attr.pyx b/tests/expectations/mod_attr.pyx index e848688..39c93df 100644 --- a/tests/expectations/mod_attr.pyx +++ b/tests/expectations/mod_attr.pyx @@ -1,5 +1,7 @@ +#if 0 DEF FOO = 0 DEF BAR = 0 +#endif from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t diff --git a/tests/expectations/mod_attr.tag.c b/tests/expectations/mod_attr.tag.c index c8fc689..0627aeb 100644 --- a/tests/expectations/mod_attr.tag.c +++ b/tests/expectations/mod_attr.tag.c @@ -1,3 +1,9 @@ +#if 0 +DEF FOO = 0 +DEF BAR = 0 +#endif + + #include #include #include diff --git a/tests/expectations/mod_attr.tag.compat.c b/tests/expectations/mod_attr.tag.compat.c index 1bdc9a7..aba6a6a 100644 --- a/tests/expectations/mod_attr.tag.compat.c +++ b/tests/expectations/mod_attr.tag.compat.c @@ -1,3 +1,9 @@ +#if 0 +DEF FOO = 0 +DEF BAR = 0 +#endif + + #include #include #include diff --git a/tests/expectations/mod_attr.tag.pyx b/tests/expectations/mod_attr.tag.pyx index 6eb149d..1858836 100644 --- a/tests/expectations/mod_attr.tag.pyx +++ b/tests/expectations/mod_attr.tag.pyx @@ -1,5 +1,7 @@ +#if 0 DEF FOO = 0 DEF BAR = 0 +#endif from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t diff --git a/tests/expectations/opaque.c b/tests/expectations/opaque.c index 75614b6..3a920e5 100644 --- a/tests/expectations/opaque.c +++ b/tests/expectations/opaque.c @@ -1,3 +1,7 @@ +#if 0 +''' ' +#endif + #ifdef __cplusplus // These could be added as opaque types I guess. template @@ -6,6 +10,10 @@ struct BuildHasherDefault; struct DefaultHasher; #endif +#if 0 +' ''' +#endif + #include #include diff --git a/tests/expectations/opaque.compat.c b/tests/expectations/opaque.compat.c index a467628..0efe467 100644 --- a/tests/expectations/opaque.compat.c +++ b/tests/expectations/opaque.compat.c @@ -1,3 +1,7 @@ +#if 0 +''' ' +#endif + #ifdef __cplusplus // These could be added as opaque types I guess. template @@ -6,6 +10,10 @@ struct BuildHasherDefault; struct DefaultHasher; #endif +#if 0 +' ''' +#endif + #include #include diff --git a/tests/expectations/opaque.cpp b/tests/expectations/opaque.cpp index 1a949b7..ea14421 100644 --- a/tests/expectations/opaque.cpp +++ b/tests/expectations/opaque.cpp @@ -1,3 +1,7 @@ +#if 0 +''' ' +#endif + #ifdef __cplusplus // These could be added as opaque types I guess. template @@ -6,6 +10,10 @@ struct BuildHasherDefault; struct DefaultHasher; #endif +#if 0 +' ''' +#endif + #include #include diff --git a/tests/expectations/opaque.pyx b/tests/expectations/opaque.pyx index 8c5059b..f60cfdb 100644 --- a/tests/expectations/opaque.pyx +++ b/tests/expectations/opaque.pyx @@ -1,3 +1,20 @@ +#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.tag.c b/tests/expectations/opaque.tag.c index 5728f2e..67d7740 100644 --- a/tests/expectations/opaque.tag.c +++ b/tests/expectations/opaque.tag.c @@ -1,3 +1,7 @@ +#if 0 +''' ' +#endif + #ifdef __cplusplus // These could be added as opaque types I guess. template @@ -6,6 +10,10 @@ struct BuildHasherDefault; struct DefaultHasher; #endif +#if 0 +' ''' +#endif + #include #include diff --git a/tests/expectations/opaque.tag.compat.c b/tests/expectations/opaque.tag.compat.c index ae56420..4fef399 100644 --- a/tests/expectations/opaque.tag.compat.c +++ b/tests/expectations/opaque.tag.compat.c @@ -1,3 +1,7 @@ +#if 0 +''' ' +#endif + #ifdef __cplusplus // These could be added as opaque types I guess. template @@ -6,6 +10,10 @@ struct BuildHasherDefault; struct DefaultHasher; #endif +#if 0 +' ''' +#endif + #include #include diff --git a/tests/expectations/opaque.tag.pyx b/tests/expectations/opaque.tag.pyx index 8dd33f8..694073f 100644 --- a/tests/expectations/opaque.tag.pyx +++ b/tests/expectations/opaque.tag.pyx @@ -1,3 +1,20 @@ +#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/prefix.both.c b/tests/expectations/prefix.both.c index 3d891e2..443c2c7 100644 --- a/tests/expectations/prefix.both.c +++ b/tests/expectations/prefix.both.c @@ -7,7 +7,9 @@ #define PREFIX_X (22 << 22) -#define PREFIX_Y (PREFIX_X + PREFIX_X) +#define PREFIX_Y1 ((22 << 22) + (22 << 22)) + +#define PREFIX_Y2 PREFIX_X typedef int32_t PREFIX_NamedLenArray[PREFIX_LEN]; diff --git a/tests/expectations/prefix.both.compat.c b/tests/expectations/prefix.both.compat.c index 311304d..aee88f5 100644 --- a/tests/expectations/prefix.both.compat.c +++ b/tests/expectations/prefix.both.compat.c @@ -7,7 +7,9 @@ #define PREFIX_X (22 << 22) -#define PREFIX_Y (PREFIX_X + PREFIX_X) +#define PREFIX_Y1 ((22 << 22) + (22 << 22)) + +#define PREFIX_Y2 PREFIX_X typedef int32_t PREFIX_NamedLenArray[PREFIX_LEN]; diff --git a/tests/expectations/prefix.c b/tests/expectations/prefix.c index 6ba9396..1f98d3d 100644 --- a/tests/expectations/prefix.c +++ b/tests/expectations/prefix.c @@ -7,7 +7,9 @@ #define PREFIX_X (22 << 22) -#define PREFIX_Y (PREFIX_X + PREFIX_X) +#define PREFIX_Y1 ((22 << 22) + (22 << 22)) + +#define PREFIX_Y2 PREFIX_X typedef int32_t PREFIX_NamedLenArray[PREFIX_LEN]; diff --git a/tests/expectations/prefix.compat.c b/tests/expectations/prefix.compat.c index bc719bf..5a715ae 100644 --- a/tests/expectations/prefix.compat.c +++ b/tests/expectations/prefix.compat.c @@ -7,7 +7,9 @@ #define PREFIX_X (22 << 22) -#define PREFIX_Y (PREFIX_X + PREFIX_X) +#define PREFIX_Y1 ((22 << 22) + (22 << 22)) + +#define PREFIX_Y2 PREFIX_X typedef int32_t PREFIX_NamedLenArray[PREFIX_LEN]; diff --git a/tests/expectations/prefix.cpp b/tests/expectations/prefix.cpp index abde339..57dda7e 100644 --- a/tests/expectations/prefix.cpp +++ b/tests/expectations/prefix.cpp @@ -8,7 +8,9 @@ static const int32_t PREFIX_LEN = 22; static const int64_t PREFIX_X = (22 << 22); -static const int64_t PREFIX_Y = (PREFIX_X + PREFIX_X); +static const int64_t PREFIX_Y1 = ((22 << 22) + (22 << 22)); + +static const int64_t PREFIX_Y2 = PREFIX_X; using PREFIX_NamedLenArray = int32_t[PREFIX_LEN]; diff --git a/tests/expectations/prefix.pyx b/tests/expectations/prefix.pyx index 76d7a1b..a6310ab 100644 --- a/tests/expectations/prefix.pyx +++ b/tests/expectations/prefix.pyx @@ -10,6 +10,10 @@ cdef extern from *: const int64_t PREFIX_X = (22 << 22); + const int64_t PREFIX_Y1 = ((22 << 22) + (22 << 22)); + + const int64_t PREFIX_Y2 = PREFIX_X; + ctypedef int32_t PREFIX_NamedLenArray[PREFIX_LEN]; ctypedef int32_t PREFIX_ValuedLenArray[22]; diff --git a/tests/expectations/prefix.tag.c b/tests/expectations/prefix.tag.c index 005f062..880f603 100644 --- a/tests/expectations/prefix.tag.c +++ b/tests/expectations/prefix.tag.c @@ -7,7 +7,9 @@ #define PREFIX_X (22 << 22) -#define PREFIX_Y (PREFIX_X + PREFIX_X) +#define PREFIX_Y1 ((22 << 22) + (22 << 22)) + +#define PREFIX_Y2 PREFIX_X typedef int32_t PREFIX_NamedLenArray[PREFIX_LEN]; diff --git a/tests/expectations/prefix.tag.compat.c b/tests/expectations/prefix.tag.compat.c index 52069c4..f691e31 100644 --- a/tests/expectations/prefix.tag.compat.c +++ b/tests/expectations/prefix.tag.compat.c @@ -7,7 +7,9 @@ #define PREFIX_X (22 << 22) -#define PREFIX_Y (PREFIX_X + PREFIX_X) +#define PREFIX_Y1 ((22 << 22) + (22 << 22)) + +#define PREFIX_Y2 PREFIX_X typedef int32_t PREFIX_NamedLenArray[PREFIX_LEN]; diff --git a/tests/expectations/prefix.tag.pyx b/tests/expectations/prefix.tag.pyx index 8e61bce..0579891 100644 --- a/tests/expectations/prefix.tag.pyx +++ b/tests/expectations/prefix.tag.pyx @@ -10,6 +10,10 @@ cdef extern from *: const int64_t PREFIX_X = (22 << 22); + const int64_t PREFIX_Y1 = ((22 << 22) + (22 << 22)); + + const int64_t PREFIX_Y2 = PREFIX_X; + ctypedef int32_t PREFIX_NamedLenArray[PREFIX_LEN]; ctypedef int32_t PREFIX_ValuedLenArray[22]; diff --git a/tests/expectations/rename_crate.both.c b/tests/expectations/rename_crate.both.c index 0e23f84..6a2704d 100644 --- a/tests/expectations/rename_crate.both.c +++ b/tests/expectations/rename_crate.both.c @@ -1,3 +1,8 @@ +#if 0 +DEF DEFINE_FREEBSD = 0 +#endif + + #include #include #include diff --git a/tests/expectations/rename_crate.both.compat.c b/tests/expectations/rename_crate.both.compat.c index ba818bf..729789c 100644 --- a/tests/expectations/rename_crate.both.compat.c +++ b/tests/expectations/rename_crate.both.compat.c @@ -1,3 +1,8 @@ +#if 0 +DEF DEFINE_FREEBSD = 0 +#endif + + #include #include #include diff --git a/tests/expectations/rename_crate.c b/tests/expectations/rename_crate.c index 1d37b25..395aaf3 100644 --- a/tests/expectations/rename_crate.c +++ b/tests/expectations/rename_crate.c @@ -1,3 +1,8 @@ +#if 0 +DEF DEFINE_FREEBSD = 0 +#endif + + #include #include #include diff --git a/tests/expectations/rename_crate.compat.c b/tests/expectations/rename_crate.compat.c index 905dffd..89ffcc4 100644 --- a/tests/expectations/rename_crate.compat.c +++ b/tests/expectations/rename_crate.compat.c @@ -1,3 +1,8 @@ +#if 0 +DEF DEFINE_FREEBSD = 0 +#endif + + #include #include #include diff --git a/tests/expectations/rename_crate.cpp b/tests/expectations/rename_crate.cpp index f93d502..3f15d72 100644 --- a/tests/expectations/rename_crate.cpp +++ b/tests/expectations/rename_crate.cpp @@ -1,3 +1,8 @@ +#if 0 +DEF DEFINE_FREEBSD = 0 +#endif + + #include #include #include diff --git a/tests/expectations/rename_crate.pyx b/tests/expectations/rename_crate.pyx index c294dfa..b7fa45f 100644 --- a/tests/expectations/rename_crate.pyx +++ b/tests/expectations/rename_crate.pyx @@ -1,4 +1,6 @@ +#if 0 DEF DEFINE_FREEBSD = 0 +#endif from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t diff --git a/tests/expectations/rename_crate.tag.c b/tests/expectations/rename_crate.tag.c index b5629aa..c91fa60 100644 --- a/tests/expectations/rename_crate.tag.c +++ b/tests/expectations/rename_crate.tag.c @@ -1,3 +1,8 @@ +#if 0 +DEF DEFINE_FREEBSD = 0 +#endif + + #include #include #include diff --git a/tests/expectations/rename_crate.tag.compat.c b/tests/expectations/rename_crate.tag.compat.c index daba119..71bf78e 100644 --- a/tests/expectations/rename_crate.tag.compat.c +++ b/tests/expectations/rename_crate.tag.compat.c @@ -1,3 +1,8 @@ +#if 0 +DEF DEFINE_FREEBSD = 0 +#endif + + #include #include #include diff --git a/tests/expectations/rename_crate.tag.pyx b/tests/expectations/rename_crate.tag.pyx index cf1fe77..b7f4332 100644 --- a/tests/expectations/rename_crate.tag.pyx +++ b/tests/expectations/rename_crate.tag.pyx @@ -1,4 +1,6 @@ +#if 0 DEF DEFINE_FREEBSD = 0 +#endif from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t diff --git a/tests/expectations/swift_name.both.c b/tests/expectations/swift_name.both.c index dca90ac..6d6c432 100644 --- a/tests/expectations/swift_name.both.c +++ b/tests/expectations/swift_name.both.c @@ -51,5 +51,4 @@ void free_function_should_exist_annotated_mut_by_name(SelfTypeTestStruct test_st PointerToOpaque PointerToOpaque_create(uint8_t times) CF_SWIFT_NAME(PointerToOpaque.create(times:)); -void PointerToOpaque_sayHello(PointerToOpaque self) -/*a comment!*/ CF_SWIFT_NAME(PointerToOpaque.sayHello(self:)); +void PointerToOpaque_sayHello(PointerToOpaque self) CF_SWIFT_NAME(PointerToOpaque.sayHello(self:)); diff --git a/tests/expectations/swift_name.both.compat.c b/tests/expectations/swift_name.both.compat.c index 99caec2..8a262c5 100644 --- a/tests/expectations/swift_name.both.compat.c +++ b/tests/expectations/swift_name.both.compat.c @@ -55,8 +55,7 @@ void free_function_should_exist_annotated_mut_by_name(SelfTypeTestStruct test_st PointerToOpaque PointerToOpaque_create(uint8_t times) CF_SWIFT_NAME(PointerToOpaque.create(times:)); -void PointerToOpaque_sayHello(PointerToOpaque self) -/*a comment!*/ CF_SWIFT_NAME(PointerToOpaque.sayHello(self:)); +void PointerToOpaque_sayHello(PointerToOpaque self) CF_SWIFT_NAME(PointerToOpaque.sayHello(self:)); #ifdef __cplusplus } // extern "C" diff --git a/tests/expectations/swift_name.c b/tests/expectations/swift_name.c index e02e326..17ec214 100644 --- a/tests/expectations/swift_name.c +++ b/tests/expectations/swift_name.c @@ -51,5 +51,4 @@ void free_function_should_exist_annotated_mut_by_name(SelfTypeTestStruct test_st PointerToOpaque PointerToOpaque_create(uint8_t times) CF_SWIFT_NAME(PointerToOpaque.create(times:)); -void PointerToOpaque_sayHello(PointerToOpaque self) -/*a comment!*/ CF_SWIFT_NAME(PointerToOpaque.sayHello(self:)); +void PointerToOpaque_sayHello(PointerToOpaque self) CF_SWIFT_NAME(PointerToOpaque.sayHello(self:)); diff --git a/tests/expectations/swift_name.compat.c b/tests/expectations/swift_name.compat.c index 3fecd4f..5409643 100644 --- a/tests/expectations/swift_name.compat.c +++ b/tests/expectations/swift_name.compat.c @@ -55,8 +55,7 @@ void free_function_should_exist_annotated_mut_by_name(SelfTypeTestStruct test_st PointerToOpaque PointerToOpaque_create(uint8_t times) CF_SWIFT_NAME(PointerToOpaque.create(times:)); -void PointerToOpaque_sayHello(PointerToOpaque self) -/*a comment!*/ CF_SWIFT_NAME(PointerToOpaque.sayHello(self:)); +void PointerToOpaque_sayHello(PointerToOpaque self) CF_SWIFT_NAME(PointerToOpaque.sayHello(self:)); #ifdef __cplusplus } // extern "C" diff --git a/tests/expectations/swift_name.cpp b/tests/expectations/swift_name.cpp index 1d30b94..5d5ae0b 100644 --- a/tests/expectations/swift_name.cpp +++ b/tests/expectations/swift_name.cpp @@ -57,7 +57,6 @@ void free_function_should_exist_annotated_mut_by_name(SelfTypeTestStruct test_st PointerToOpaque PointerToOpaque_create(uint8_t times) CF_SWIFT_NAME(PointerToOpaque.create(times:)); -void PointerToOpaque_sayHello(PointerToOpaque self) -/*a comment!*/ CF_SWIFT_NAME(PointerToOpaque.sayHello(self:)); +void PointerToOpaque_sayHello(PointerToOpaque self) CF_SWIFT_NAME(PointerToOpaque.sayHello(self:)); } // extern "C" diff --git a/tests/expectations/swift_name.pyx b/tests/expectations/swift_name.pyx index 93ded0c..3c2435a 100644 --- a/tests/expectations/swift_name.pyx +++ b/tests/expectations/swift_name.pyx @@ -52,3 +52,5 @@ cdef extern from *: void free_function_should_exist_annotated_mut_by_name(SelfTypeTestStruct test_struct); PointerToOpaque PointerToOpaque_create(uint8_t times); + + void PointerToOpaque_sayHello(PointerToOpaque self); diff --git a/tests/expectations/swift_name.tag.c b/tests/expectations/swift_name.tag.c index 60eb7b4..370b88a 100644 --- a/tests/expectations/swift_name.tag.c +++ b/tests/expectations/swift_name.tag.c @@ -51,5 +51,4 @@ void free_function_should_exist_annotated_mut_by_name(struct SelfTypeTestStruct struct PointerToOpaque PointerToOpaque_create(uint8_t times) CF_SWIFT_NAME(PointerToOpaque.create(times:)); -void PointerToOpaque_sayHello(struct PointerToOpaque self) -/*a comment!*/ CF_SWIFT_NAME(PointerToOpaque.sayHello(self:)); +void PointerToOpaque_sayHello(struct PointerToOpaque self) CF_SWIFT_NAME(PointerToOpaque.sayHello(self:)); diff --git a/tests/expectations/swift_name.tag.compat.c b/tests/expectations/swift_name.tag.compat.c index 2b96cd2..6ac6a00 100644 --- a/tests/expectations/swift_name.tag.compat.c +++ b/tests/expectations/swift_name.tag.compat.c @@ -55,8 +55,7 @@ void free_function_should_exist_annotated_mut_by_name(struct SelfTypeTestStruct struct PointerToOpaque PointerToOpaque_create(uint8_t times) CF_SWIFT_NAME(PointerToOpaque.create(times:)); -void PointerToOpaque_sayHello(struct PointerToOpaque self) -/*a comment!*/ CF_SWIFT_NAME(PointerToOpaque.sayHello(self:)); +void PointerToOpaque_sayHello(struct PointerToOpaque self) CF_SWIFT_NAME(PointerToOpaque.sayHello(self:)); #ifdef __cplusplus } // extern "C" diff --git a/tests/expectations/swift_name.tag.pyx b/tests/expectations/swift_name.tag.pyx index b234839..127fb32 100644 --- a/tests/expectations/swift_name.tag.pyx +++ b/tests/expectations/swift_name.tag.pyx @@ -52,3 +52,5 @@ cdef extern from *: void free_function_should_exist_annotated_mut_by_name(SelfTypeTestStruct test_struct); PointerToOpaque PointerToOpaque_create(uint8_t times); + + void PointerToOpaque_sayHello(PointerToOpaque self); diff --git a/tests/rust/body.cython.toml b/tests/rust/body.cython.toml deleted file mode 100644 index 0248608..0000000 --- a/tests/rust/body.cython.toml +++ /dev/null @@ -1,17 +0,0 @@ -[export.body] -"MyCLikeEnum" = """ - BogusVariantForSerializationForExample, -""" - -"MyUnion" = """ - int32_t extra_member; # yolo -""" - -[export.pre_body] -"MyCLikeEnum_Prepended" = """ - BogusVariantForSerializationForExample, -""" - -"MyUnion_Prepended" = """ - int32_t extra_member; # yolo -""" diff --git a/tests/rust/body.toml b/tests/rust/body.toml index 973a47f..ab96d70 100644 --- a/tests/rust/body.toml +++ b/tests/rust/body.toml @@ -1,13 +1,13 @@ [export.body] "MyFancyStruct" = """ #ifdef __cplusplus - inline void foo(); + inline void foo(); #endif """ "MyFancyEnum" = """ #ifdef __cplusplus - inline void wohoo(); + inline void wohoo(); #endif """ @@ -16,20 +16,20 @@ """ "MyUnion" = """ - int32_t extra_member; // yolo + int32_t extra_member; """ [export.pre_body] "MyFancyStruct_Prepended" = """ #ifdef __cplusplus - inline void prepended_wohoo(); + inline void prepended_wohoo(); #endif """ "MyFancyEnum_Prepended" = """ - #ifdef __cplusplus +#ifdef __cplusplus inline void wohoo(); - #endif +#endif """ "MyCLikeEnum_Prepended" = """ @@ -37,6 +37,5 @@ """ "MyUnion_Prepended" = """ - int32_t extra_member; // yolo + int32_t extra_member; """ - diff --git a/tests/rust/box.cython.toml b/tests/rust/box.cython.toml deleted file mode 100644 index 7748f8a..0000000 --- a/tests/rust/box.cython.toml +++ /dev/null @@ -1,10 +0,0 @@ -# header = """ -# #ifdef __cplusplus -# template -# using Box = T*; -# #endif -# """ -[export] -exclude = [ - "Box", -] diff --git a/tests/rust/box.toml b/tests/rust/box.toml index 1a303a5..84cb6b0 100644 --- a/tests/rust/box.toml +++ b/tests/rust/box.toml @@ -1,11 +1,18 @@ header = """ +#if 0 +''' ' +#endif + #ifdef __cplusplus template using Box = T*; #endif + +#if 0 +' ''' +#endif """ [export] exclude = [ "Box", ] - diff --git a/tests/rust/cfg.cython.toml b/tests/rust/cfg.cython.toml deleted file mode 100644 index e3e5b08..0000000 --- a/tests/rust/cfg.cython.toml +++ /dev/null @@ -1,15 +0,0 @@ -header = """ -DEF PLATFORM_UNIX = 0 -DEF PLATFORM_WIN = 0 -DEF X11 = 0 -DEF M_32 = 0 -""" - -[defines] -"unix" = "PLATFORM_UNIX" -"windows" = "PLATFORM_WIN" -"x11" = "X11" -"target_pointer_width = 32" = "M_32" - -[export] -exclude = ["C"] # conditional compilation is not supported for enumerators diff --git a/tests/rust/cfg.toml b/tests/rust/cfg.toml index 63f873a..4d6c4ca 100644 --- a/tests/rust/cfg.toml +++ b/tests/rust/cfg.toml @@ -1,3 +1,12 @@ +header = """ +#if 0 +DEF PLATFORM_UNIX = 0 +DEF PLATFORM_WIN = 0 +DEF X11 = 0 +DEF M_32 = 0 +#endif +""" + [defines] "unix" = "PLATFORM_UNIX" "windows" = "PLATFORM_WIN" diff --git a/tests/rust/cfg_2.cython.toml b/tests/rust/cfg_2.cython.toml deleted file mode 100644 index 98f1e6e..0000000 --- a/tests/rust/cfg_2.cython.toml +++ /dev/null @@ -1,9 +0,0 @@ -header = """ -DEF DEFINED = 1 -DEF NOT_DEFINED = 0 -""" - -[defines] -"unix" = "DEFINED" -"macos" = "NOT_DEFINED" -"windows" = "NOT_DEFINED" diff --git a/tests/rust/cfg_2.toml b/tests/rust/cfg_2.toml index f4ca752..4672d03 100644 --- a/tests/rust/cfg_2.toml +++ b/tests/rust/cfg_2.toml @@ -1,3 +1,10 @@ +header = """ +#if 0 +DEF DEFINED = 1 +DEF NOT_DEFINED = 0 +#endif +""" + [defines] "unix" = "DEFINED" "macos" = "NOT_DEFINED" diff --git a/tests/rust/constant.cython.toml b/tests/rust/constant.cython.toml deleted file mode 100644 index 2d2acf4..0000000 --- a/tests/rust/constant.cython.toml +++ /dev/null @@ -1,5 +0,0 @@ -[export] -exclude = [ - "XFALSE", # right hand side crashes Cython compiler - "XTRUE", # right hand side crashes Cython compiler -] diff --git a/tests/rust/constant.rs b/tests/rust/constant.rs index 637a2ce..db60b0b 100644 --- a/tests/rust/constant.rs +++ b/tests/rust/constant.rs @@ -23,8 +23,11 @@ pub const NEG_ONE: i8 = -1; // Some doc for shifting // pub const SHIFT: i64 = 3; pub const XBOOL: i64 = 1; -pub const XFALSE: i64 = (0 << SHIFT) | XBOOL; -pub const XTRUE: i64 = 1 << (SHIFT | XBOOL); +// pub const XFALSE: i64 = (0 << SHIFT) | XBOOL; // Crashes Cython compiler +// pub const XTRUE: i64 = 1 << (SHIFT | XBOOL); // Crashes Cython compiler +pub const XFALSE1: i64 = (0 << 3) | 1; +pub const XTRUE1: i64 = 1 << (3 | 1); +pub const XFALSE2: i64 = 0 << SHIFT; pub const CAST: u8 = 'A' as u8; pub const DOUBLE_CAST: u32 = 1 as f32 as u32; diff --git a/tests/rust/custom_header.cython.toml b/tests/rust/custom_header.cython.toml deleted file mode 100644 index a237c7d..0000000 --- a/tests/rust/custom_header.cython.toml +++ /dev/null @@ -1,5 +0,0 @@ -no_includes = true -header = "# This file is generated by cbindgen. DO NOT EDIT" -trailer = """ -# This is a simple test to ensure that trailers don't cause extra newlines in files -""" diff --git a/tests/rust/custom_header.toml b/tests/rust/custom_header.toml index b44a687..4b1c8ee 100644 --- a/tests/rust/custom_header.toml +++ b/tests/rust/custom_header.toml @@ -1,5 +1,11 @@ no_includes = true -header = "// This file is generated by cbindgen. DO NOT EDIT" -trailer = """ -/* This is a simple test to ensure that trailers don't cause extra newlines in files */ +header = """ +#if 0 +# This file is generated by cbindgen. DO NOT EDIT +#endif +""" +trailer = """ +#if 0 +# This is a simple test to ensure that trailers do not cause extra newlines in files +#endif """ diff --git a/tests/rust/enum.cython.toml b/tests/rust/enum.cython.toml deleted file mode 100644 index e69de29..0000000 diff --git a/tests/rust/enum.toml b/tests/rust/enum.toml index 145e4cc..807507b 100644 --- a/tests/rust/enum.toml +++ b/tests/rust/enum.toml @@ -1,8 +1,16 @@ trailer = """ +#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"); -""" \ No newline at end of file + +#if 0 +' ''' +#endif +""" diff --git a/tests/rust/enum_discriminant.cython.toml b/tests/rust/enum_discriminant.cython.toml deleted file mode 100644 index 9cf3349..0000000 --- a/tests/rust/enum_discriminant.cython.toml +++ /dev/null @@ -1,2 +0,0 @@ -[export] -exclude = ["root_no_cython"] diff --git a/tests/rust/enum_discriminant.rs b/tests/rust/enum_discriminant.rs index fbf2733..79c270f 100644 --- a/tests/rust/enum_discriminant.rs +++ b/tests/rust/enum_discriminant.rs @@ -7,16 +7,9 @@ enum E { C = 1 + 2, D = FOUR, F = (5), -} - -#[repr(i8)] -enum E_NoCython { - G = '6' as i8, // Not supported - H = false as i8, // Not supported + G = b'6' as i8, + H = false as i8, } #[no_mangle] pub extern "C" fn root(_: &E) {} - -#[no_mangle] -pub extern "C" fn root_no_cython(_: &E_NoCython) {} diff --git a/tests/rust/exclude_generic_monomorph.cython.toml b/tests/rust/exclude_generic_monomorph.cython.toml deleted file mode 100644 index fbcb05d..0000000 --- a/tests/rust/exclude_generic_monomorph.cython.toml +++ /dev/null @@ -1,9 +0,0 @@ -header = """ -from libc.stdint cimport uint64_t -ctypedef uint64_t Option_Foo -""" - -[export] -exclude = [ - "Option_Foo", -] diff --git a/tests/rust/exclude_generic_monomorph.toml b/tests/rust/exclude_generic_monomorph.toml index 82d3361..15711ae 100644 --- a/tests/rust/exclude_generic_monomorph.toml +++ b/tests/rust/exclude_generic_monomorph.toml @@ -2,7 +2,20 @@ language = "C" header = """ #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 """ [export] diff --git a/tests/rust/manuallydrop.cython.toml b/tests/rust/manuallydrop.cython.toml deleted file mode 100644 index 6b8ba3d..0000000 --- a/tests/rust/manuallydrop.cython.toml +++ /dev/null @@ -1,4 +0,0 @@ -[export] -exclude = [ - "ManuallyDrop", -] diff --git a/tests/rust/manuallydrop.toml b/tests/rust/manuallydrop.toml index f5353e4..7ffee9a 100644 --- a/tests/rust/manuallydrop.toml +++ b/tests/rust/manuallydrop.toml @@ -1,8 +1,16 @@ header = """ +#if 0 +''' ' +#endif + #ifdef __cplusplus template using ManuallyDrop = T; #endif + +#if 0 +' ''' +#endif """ [export] exclude = [ diff --git a/tests/rust/maybeuninit.cython.toml b/tests/rust/maybeuninit.cython.toml deleted file mode 100644 index 35b5ca8..0000000 --- a/tests/rust/maybeuninit.cython.toml +++ /dev/null @@ -1,4 +0,0 @@ -[export] -exclude = [ - "MaybeUninit", -] diff --git a/tests/rust/maybeuninit.toml b/tests/rust/maybeuninit.toml index d649cb0..ba671fa 100644 --- a/tests/rust/maybeuninit.toml +++ b/tests/rust/maybeuninit.toml @@ -1,8 +1,16 @@ header = """ +#if 0 +''' ' +#endif + #ifdef __cplusplus template using MaybeUninit = T; #endif + +#if 0 +' ''' +#endif """ [export] exclude = [ diff --git a/tests/rust/mod_attr.cython.toml b/tests/rust/mod_attr.cython.toml deleted file mode 100644 index d64a97a..0000000 --- a/tests/rust/mod_attr.cython.toml +++ /dev/null @@ -1,9 +0,0 @@ -header = """ -DEF FOO = 0 -DEF BAR = 0 -""" - -[defines] -"foo" = "FOO" -"bar" = "BAR" -# "feature = foobar" = "FOOBAR" diff --git a/tests/rust/mod_attr/cbindgen.toml b/tests/rust/mod_attr/cbindgen.toml index 0e04673..a0e602d 100644 --- a/tests/rust/mod_attr/cbindgen.toml +++ b/tests/rust/mod_attr/cbindgen.toml @@ -1,3 +1,10 @@ +header = """ +#if 0 +DEF FOO = 0 +DEF BAR = 0 +#endif +""" + [defines] "foo" = "FOO" "bar" = "BAR" diff --git a/tests/rust/opaque.cython.toml b/tests/rust/opaque.cython.toml deleted file mode 100644 index e69de29..0000000 diff --git a/tests/rust/opaque.toml b/tests/rust/opaque.toml index d7219e1..cf56c97 100644 --- a/tests/rust/opaque.toml +++ b/tests/rust/opaque.toml @@ -1,4 +1,8 @@ header = """ +#if 0 +''' ' +#endif + #ifdef __cplusplus // These could be added as opaque types I guess. template @@ -6,4 +10,8 @@ struct BuildHasherDefault; struct DefaultHasher; #endif + +#if 0 +' ''' +#endif """ diff --git a/tests/rust/prefix.cython.toml b/tests/rust/prefix.cython.toml deleted file mode 100644 index 0360704..0000000 --- a/tests/rust/prefix.cython.toml +++ /dev/null @@ -1,5 +0,0 @@ -[export] -prefix = "PREFIX_" -exclude = [ - "Y", # right hand side crashes Cython compiler -] diff --git a/tests/rust/prefix.rs b/tests/rust/prefix.rs index 47a87b7..6f29b5a 100644 --- a/tests/rust/prefix.rs +++ b/tests/rust/prefix.rs @@ -16,5 +16,9 @@ pub extern "C" fn root(x: NamedLenArray, y: ValuedLenArray, z: AbsoluteFontWeigh #[no_mangle] pub const X: i64 = 22 << 22; +// #[no_mangle] +// pub const Y: i64 = X + X; // Crashes Cython compiler #[no_mangle] -pub const Y: i64 = X + X; +pub const Y1: i64 = (22 << 22) + (22 << 22); +#[no_mangle] +pub const Y2: i64 = X; diff --git a/tests/rust/rename_crate.cython.toml b/tests/rust/rename_crate.cython.toml deleted file mode 100644 index eb8c79f..0000000 --- a/tests/rust/rename_crate.cython.toml +++ /dev/null @@ -1,8 +0,0 @@ -header = """ -DEF DEFINE_FREEBSD = 0 -""" - -[parse] -parse_deps = true -[defines] -"target_os = freebsd" = "DEFINE_FREEBSD" diff --git a/tests/rust/rename_crate/cbindgen.toml b/tests/rust/rename_crate/cbindgen.toml index 0e9b601..95c3dd5 100644 --- a/tests/rust/rename_crate/cbindgen.toml +++ b/tests/rust/rename_crate/cbindgen.toml @@ -1,3 +1,9 @@ +header = """ +#if 0 +DEF DEFINE_FREEBSD = 0 +#endif +""" + [parse] parse_deps = true [defines] diff --git a/tests/rust/swift_name.cython.toml b/tests/rust/swift_name.cython.toml deleted file mode 100644 index 1de9501..0000000 --- a/tests/rust/swift_name.cython.toml +++ /dev/null @@ -1,9 +0,0 @@ -header = "#define CF_SWIFT_NAME(_name) __attribute__((swift_name(#_name)))" - -[fn] -swift_name_macro = "CF_SWIFT_NAME" - -[export] -exclude = [ - "PointerToOpaque_sayHello", # has postfix with a C-style comment incompatible with Cython -] diff --git a/tests/rust/swift_name.rs b/tests/rust/swift_name.rs index 5abda40..01cfdbe 100644 --- a/tests/rust/swift_name.rs +++ b/tests/rust/swift_name.rs @@ -122,7 +122,6 @@ impl PointerToOpaque { PointerToOpaque { ptr: Box::into_raw(Box::new(Opaque { times })) } } - /// cbindgen:postfix=/*a comment!*/ #[export_name="PointerToOpaque_sayHello"] pub extern fn say_hello(self: PointerToOpaque) { if let Some(nonnull) = std::ptr::NonNull::new(self.ptr) { diff --git a/tests/tests.rs b/tests/tests.rs index f39dab3..9acbe2f 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -42,16 +42,9 @@ fn run_cbindgen( command.arg("--style").arg(style_str(style)); } - let config_exts = match language { - Language::Cython => &["cython.toml", "toml"][..], - _ => &["toml"], - }; - for config_ext in config_exts { - let config = path.with_extension(config_ext); - if config.exists() { - command.arg("--config").arg(config); - break; - } + let config = path.with_extension("toml"); + if config.exists() { + command.arg("--config").arg(config); } command.arg(path);