diff --git a/.clippy.toml b/.clippy.toml index 4785aed4..08df7d89 100644 --- a/.clippy.toml +++ b/.clippy.toml @@ -1,2 +1,2 @@ # Specify the minimum supported Rust version -msrv = "1.70" +msrv = "1.74" diff --git a/docs.md b/docs.md index c3b2a697..299df475 100644 --- a/docs.md +++ b/docs.md @@ -1017,6 +1017,16 @@ derive_tagged_enum_copy_assignment = false # default: false private_default_tagged_enum_constructor = false +# Whether to only output a single tag enum for generic tagged enums. This only +# applies when generics are being monomorphized (i.e. not C++). +# +# For example, an enum monomorph `COption` would normally generate a tag enum +# `COption_u8_Tag`, but with this option enabled all monomorphs of `COption` will +# use the same tag enum, named `COption_Tag`. +# +# default: false +merge_generic_tags = false + diff --git a/src/bindgen/config.rs b/src/bindgen/config.rs index 3018a204..663c2b7c 100644 --- a/src/bindgen/config.rs +++ b/src/bindgen/config.rs @@ -610,6 +610,8 @@ pub struct EnumConfig { /// Whether to generate empty, private default-constructors for tagged /// enums. pub private_default_tagged_enum_constructor: bool, + /// Whether to only output a single tag enum for generic tagged enums. + pub merge_generic_tags: bool, } impl Default for EnumConfig { @@ -634,6 +636,7 @@ impl Default for EnumConfig { derive_ostream: false, enum_class: true, private_default_tagged_enum_constructor: false, + merge_generic_tags: false, } } } diff --git a/src/bindgen/dependencies.rs b/src/bindgen/dependencies.rs index 6a987381..78dab6df 100644 --- a/src/bindgen/dependencies.rs +++ b/src/bindgen/dependencies.rs @@ -7,6 +7,8 @@ use std::collections::HashSet; use crate::bindgen::ir::{ItemContainer, Path}; +use super::library::Library; + /// A dependency list is used for gathering what order to output the types. #[derive(Default)] pub struct Dependencies { @@ -22,6 +24,24 @@ impl Dependencies { } } + pub fn add_path(&mut self, library: &Library, path: &Path) { + if let Some(items) = library.get_items(path) { + if !self.items.contains(path) { + self.items.insert(path.clone()); + + for item in &items { + item.deref().add_dependencies(library, self); + } + self.order.extend(items); + } + } else { + warn!( + "Can't find {}. This usually means that this type was incompatible or not found.", + path + ); + } + } + pub fn sort(&mut self) { // Sort untagged enums and opaque structs into their own layers because they don't // depend on each other or anything else. diff --git a/src/bindgen/ir/enumeration.rs b/src/bindgen/ir/enumeration.rs index 8927b8be..2a6aa541 100644 --- a/src/bindgen/ir/enumeration.rs +++ b/src/bindgen/ir/enumeration.rs @@ -302,6 +302,7 @@ pub struct Enum { pub repr: Repr, pub variants: Vec, pub tag: Option, + pub external_tag: bool, pub cfg: Option, pub annotations: AnnotationSet, pub documentation: Documentation, @@ -415,6 +416,7 @@ impl Enum { repr, variants, tag, + /* external_tag */ false, Cfg::append(mod_cfg, Cfg::load(&item.attrs)), annotations, Documentation::load(&item.attrs), @@ -428,6 +430,7 @@ impl Enum { repr: Repr, variants: Vec, tag: Option, + external_tag: bool, cfg: Option, annotations: AnnotationSet, documentation: Documentation, @@ -440,6 +443,7 @@ impl Enum { repr, variants, tag, + external_tag, cfg, annotations, documentation, @@ -502,11 +506,18 @@ impl Item for Enum { } fn rename_for_config(&mut self, config: &Config) { - config.export.rename(&mut self.export_name); + // Check if the export_name already contains the prefix to avoid double prefixing + if let Some(ref prefix) = config.export.prefix { + if !self.export_name.starts_with(prefix) { + config.export.rename(&mut self.export_name); + } + } else { + config.export.rename(&mut self.export_name); + } - if config.language != Language::Cxx && self.tag.is_some() { + if config.language != Language::Cxx && self.tag.is_some() && !self.external_tag { // it makes sense to always prefix Tag with type name in C - let new_tag = format!("{}_Tag", self.export_name); + let new_tag = format!("{}_Tag", self.export_name()); if self.repr.style == ReprStyle::Rust { for variant in &mut self.variants { if let VariantBody::Body { ref mut body, .. } = variant.body { @@ -540,6 +551,8 @@ impl Item for Enum { .bool("prefix-with-name") .unwrap_or(config.enumeration.prefix_with_name) { + let prefix = self.export_name.trim_end_matches("_Tag"); + let separator = if config.export.mangle.remove_underscores { "" } else { @@ -547,11 +560,9 @@ impl Item for Enum { }; for variant in &mut self.variants { - variant.export_name = - format!("{}{}{}", self.export_name, separator, variant.export_name); + variant.export_name = format!("{}{}{}", prefix, separator, variant.export_name); if let VariantBody::Body { ref mut body, .. } = variant.body { - body.export_name = - format!("{}{}{}", self.export_name, separator, body.export_name()); + body.export_name = format!("{}{}{}", prefix, separator, body.export_name()); } } } @@ -603,6 +614,39 @@ impl Item for Enum { library: &Library, out: &mut Monomorphs, ) { + let config = library.get_config(); + // Only use external tags for generic enums when merge_generic_tags is enabled + let external_tag = config.enumeration.merge_generic_tags && !generic_values.is_empty(); + + let tag = if external_tag { + // Calculate what the prefixed tag name should be + let mut prefixed_export_name = self.export_name().to_string(); + config.export.rename(&mut prefixed_export_name); + let final_tag = format!("{}_Tag", prefixed_export_name); + + if !out.contains(&GenericPath::new(self.path.clone(), vec![])) { + // Create the shared tag enum with the final prefixed name + let tag_path = Path::new(final_tag.clone()); + let tag_enum = Enum::new( + tag_path, + GenericParams::default(), + self.repr, + self.variants.clone(), + None, + false, + self.cfg.clone(), + self.annotations.clone(), + self.documentation.clone(), + ); + + out.insert_enum(library, self, tag_enum, vec![]); + } + + Some(final_tag) + } else { + self.tag.clone() + }; + let mappings = self.generic_params.call(self.path.name(), generic_values); for variant in &self.variants { @@ -625,7 +669,8 @@ impl Item for Enum { .iter() .map(|v| v.specialize(generic_values, &mappings, library.get_config())) .collect(), - self.tag.clone(), + tag, + external_tag, self.cfg.clone(), self.annotations.clone(), self.documentation.clone(), @@ -635,6 +680,15 @@ impl Item for Enum { } fn add_dependencies(&self, library: &Library, out: &mut Dependencies) { + if self.external_tag { + if let Some(tag) = self.tag.clone() { + let path = Path::new(tag); + + // If there is an external tag enum, then add it as a dependency. + out.add_path(library, &path); + } + } + for variant in &self.variants { variant.add_dependencies(library, out); } @@ -771,6 +825,11 @@ impl Enum { } } + // Add a newline after the tag enum to ensure proper spacing + if size.is_some() || config.language == Language::Cython { + out.new_line(); + } + // Emit convenience methods for the tag enum. self.write_derived_functions_enum(config, language_backend, out); } @@ -830,8 +889,6 @@ impl Enum { .. } = variant.body { - out.new_line(); - out.new_line(); let condition = variant.cfg.to_condition(config); // Cython doesn't support conditional enum variants. if config.language != Language::Cython { @@ -841,6 +898,8 @@ impl Enum { if config.language != Language::Cython { condition.write_after(config, out); } + out.new_line(); + out.new_line(); } } } diff --git a/src/bindgen/ir/ty.rs b/src/bindgen/ir/ty.rs index c5df8ae4..3af6e0dc 100644 --- a/src/bindgen/ir/ty.rs +++ b/src/bindgen/ir/ty.rs @@ -701,24 +701,7 @@ impl Type { } let path = generic.path(); if !generic_params.iter().any(|param| param.name() == path) { - if let Some(items) = library.get_items(path) { - if !out.items.contains(path) { - out.items.insert(path.clone()); - - for item in &items { - item.deref().add_dependencies(library, out); - } - for item in items { - out.order.push(item); - } - } - } else { - warn!( - "Can't find {}. This usually means that this type was incompatible or \ - not found.", - path - ); - } + out.add_path(library, path); } } Type::Primitive(_) => {} diff --git a/src/bindgen/language_backend/clike.rs b/src/bindgen/language_backend/clike.rs index 3968193e..992e360a 100644 --- a/src/bindgen/language_backend/clike.rs +++ b/src/bindgen/language_backend/clike.rs @@ -485,7 +485,10 @@ impl LanguageBackend for CLikeLanguageBackend<'_> { } // Emit the tag enum and everything related to it. - e.write_tag_enum(self.config, self, out, size, Self::write_enum_variant); + // Skip writing the tag enum if this is a specialized monomorph with an external tag + if !e.external_tag { + e.write_tag_enum(self.config, self, out, size, Self::write_enum_variant); + } // If the enum has data, we need to emit structs for the variants and gather them together. if has_data { diff --git a/src/bindgen/language_backend/cython.rs b/src/bindgen/language_backend/cython.rs index 0327ffd0..acb04eda 100644 --- a/src/bindgen/language_backend/cython.rs +++ b/src/bindgen/language_backend/cython.rs @@ -129,7 +129,10 @@ impl LanguageBackend for CythonLanguageBackend<'_> { self.write_documentation(out, &e.documentation); // Emit the tag enum and everything related to it. - e.write_tag_enum(self.config, self, out, size, Self::write_enum_variant); + // Skip writing the tag enum if this is a specialized monomorph with an external tag + if !e.external_tag { + e.write_tag_enum(self.config, self, out, size, Self::write_enum_variant); + } // If the enum has data, we need to emit structs for the variants and gather them together. if has_data { diff --git a/template.toml b/template.toml index ff3b3232..a8815874 100644 --- a/template.toml +++ b/template.toml @@ -122,6 +122,7 @@ derive_tagged_enum_destructor = false derive_tagged_enum_copy_constructor = false enum_class = true private_default_tagged_enum_constructor = false +merge_generic_tags = false diff --git a/tests/expectations-symbols/merge_generic_tags.c.sym b/tests/expectations-symbols/merge_generic_tags.c.sym new file mode 100644 index 00000000..f018156f --- /dev/null +++ b/tests/expectations-symbols/merge_generic_tags.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; \ No newline at end of file diff --git a/tests/expectations-symbols/merge_generic_tags_export_prefix.c.sym b/tests/expectations-symbols/merge_generic_tags_export_prefix.c.sym new file mode 100644 index 00000000..a374b91c --- /dev/null +++ b/tests/expectations-symbols/merge_generic_tags_export_prefix.c.sym @@ -0,0 +1,6 @@ +{ +process_result; +process_str_result; +get_option_int; +get_option_str; +}; \ No newline at end of file diff --git a/tests/expectations-symbols/merge_generic_tags_with_prefix.c.sym b/tests/expectations-symbols/merge_generic_tags_with_prefix.c.sym new file mode 100644 index 00000000..f018156f --- /dev/null +++ b/tests/expectations-symbols/merge_generic_tags_with_prefix.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; \ No newline at end of file diff --git a/tests/expectations/alias.c b/tests/expectations/alias.c index 90478299..9e3ff6c3 100644 --- a/tests/expectations/alias.c +++ b/tests/expectations/alias.c @@ -9,6 +9,7 @@ enum Status { }; typedef uint32_t Status; + typedef struct { int32_t a; float b; diff --git a/tests/expectations/alias.compat.c b/tests/expectations/alias.compat.c index 565fb53f..d8532dc7 100644 --- a/tests/expectations/alias.compat.c +++ b/tests/expectations/alias.compat.c @@ -15,6 +15,7 @@ enum Status typedef uint32_t Status; #endif // __cplusplus + typedef struct { int32_t a; float b; diff --git a/tests/expectations/alias.cpp b/tests/expectations/alias.cpp index 38dd7604..ca44084d 100644 --- a/tests/expectations/alias.cpp +++ b/tests/expectations/alias.cpp @@ -9,6 +9,7 @@ enum class Status : uint32_t { Err, }; + struct Dep { int32_t a; float b; diff --git a/tests/expectations/alias.pyx b/tests/expectations/alias.pyx index 7471fb0f..cbf11945 100644 --- a/tests/expectations/alias.pyx +++ b/tests/expectations/alias.pyx @@ -11,6 +11,7 @@ cdef extern from *: Err, ctypedef uint32_t Status; + ctypedef struct Dep: int32_t a; float b; diff --git a/tests/expectations/alias_both.c b/tests/expectations/alias_both.c index 1c537b5d..f0f07084 100644 --- a/tests/expectations/alias_both.c +++ b/tests/expectations/alias_both.c @@ -9,6 +9,7 @@ enum Status { }; typedef uint32_t Status; + typedef struct Dep { int32_t a; float b; diff --git a/tests/expectations/alias_both.compat.c b/tests/expectations/alias_both.compat.c index a48b899e..6903b940 100644 --- a/tests/expectations/alias_both.compat.c +++ b/tests/expectations/alias_both.compat.c @@ -15,6 +15,7 @@ enum Status typedef uint32_t Status; #endif // __cplusplus + typedef struct Dep { int32_t a; float b; diff --git a/tests/expectations/alias_tag.c b/tests/expectations/alias_tag.c index 82f12dd5..79dbe78d 100644 --- a/tests/expectations/alias_tag.c +++ b/tests/expectations/alias_tag.c @@ -9,6 +9,7 @@ enum Status { }; typedef uint32_t Status; + struct Dep { int32_t a; float b; diff --git a/tests/expectations/alias_tag.compat.c b/tests/expectations/alias_tag.compat.c index 9f04708c..fee58a0b 100644 --- a/tests/expectations/alias_tag.compat.c +++ b/tests/expectations/alias_tag.compat.c @@ -15,6 +15,7 @@ enum Status typedef uint32_t Status; #endif // __cplusplus + struct Dep { int32_t a; float b; diff --git a/tests/expectations/alias_tag.pyx b/tests/expectations/alias_tag.pyx index e6d86623..09fa4f96 100644 --- a/tests/expectations/alias_tag.pyx +++ b/tests/expectations/alias_tag.pyx @@ -11,6 +11,7 @@ cdef extern from *: Err, ctypedef uint32_t Status; + cdef struct Dep: int32_t a; float b; diff --git a/tests/expectations/annotation.c b/tests/expectations/annotation.c index 9d72830a..b517e721 100644 --- a/tests/expectations/annotation.c +++ b/tests/expectations/annotation.c @@ -9,6 +9,7 @@ enum C { }; typedef uint32_t C; + typedef struct { int32_t m0; } A; @@ -24,13 +25,14 @@ enum F_Tag { Baz, }; typedef uint8_t F_Tag; - typedef struct { F_Tag tag; uint8_t x; int16_t y; } Bar_Body; + + typedef union { F_Tag tag; struct { @@ -46,12 +48,13 @@ enum H_Tag { Everyone, }; typedef uint8_t H_Tag; - typedef struct { uint8_t x; int16_t y; } There_Body; + + typedef struct { H_Tag tag; union { diff --git a/tests/expectations/annotation.compat.c b/tests/expectations/annotation.compat.c index 4a90fcab..1782867a 100644 --- a/tests/expectations/annotation.compat.c +++ b/tests/expectations/annotation.compat.c @@ -15,6 +15,7 @@ enum C typedef uint32_t C; #endif // __cplusplus + typedef struct { int32_t m0; } A; @@ -36,13 +37,14 @@ enum F_Tag #ifndef __cplusplus typedef uint8_t F_Tag; #endif // __cplusplus - typedef struct { F_Tag tag; uint8_t x; int16_t y; } Bar_Body; + + typedef union { F_Tag tag; struct { @@ -64,12 +66,13 @@ enum H_Tag #ifndef __cplusplus typedef uint8_t H_Tag; #endif // __cplusplus - typedef struct { uint8_t x; int16_t y; } There_Body; + + typedef struct { H_Tag tag; union { diff --git a/tests/expectations/annotation.cpp b/tests/expectations/annotation.cpp index 1197f450..ae043cc2 100644 --- a/tests/expectations/annotation.cpp +++ b/tests/expectations/annotation.cpp @@ -9,6 +9,7 @@ enum class C : uint32_t { Y, }; + struct A { int32_t m0; @@ -35,7 +36,6 @@ union F { Bar, Baz, }; - struct Foo_Body { Tag tag; int16_t _0; @@ -47,6 +47,8 @@ union F { int16_t y; }; + + struct { Tag tag; }; @@ -94,7 +96,6 @@ struct H { There, Everyone, }; - struct Hello_Body { int16_t _0; }; @@ -104,6 +105,8 @@ struct H { int16_t y; }; + + Tag tag; union { Hello_Body hello; diff --git a/tests/expectations/annotation.pyx b/tests/expectations/annotation.pyx index 8aa9b54a..9a47cd1c 100644 --- a/tests/expectations/annotation.pyx +++ b/tests/expectations/annotation.pyx @@ -11,6 +11,7 @@ cdef extern from *: Y, ctypedef uint32_t C; + ctypedef struct A: int32_t m0; @@ -23,12 +24,13 @@ cdef extern from *: Bar, Baz, ctypedef uint8_t F_Tag; - ctypedef struct Bar_Body: F_Tag tag; uint8_t x; int16_t y; + + ctypedef union F: F_Tag tag; int16_t foo; @@ -39,11 +41,12 @@ cdef extern from *: There, Everyone, ctypedef uint8_t H_Tag; - ctypedef struct There_Body: uint8_t x; int16_t y; + + ctypedef struct H: H_Tag tag; int16_t hello; diff --git a/tests/expectations/annotation_both.c b/tests/expectations/annotation_both.c index 17c4fd7b..d96cc28b 100644 --- a/tests/expectations/annotation_both.c +++ b/tests/expectations/annotation_both.c @@ -9,6 +9,7 @@ enum C { }; typedef uint32_t C; + typedef struct A { int32_t m0; } A; @@ -24,13 +25,14 @@ enum F_Tag { Baz, }; typedef uint8_t F_Tag; - typedef struct Bar_Body { F_Tag tag; uint8_t x; int16_t y; } Bar_Body; + + typedef union F { F_Tag tag; struct { @@ -46,12 +48,13 @@ enum H_Tag { Everyone, }; typedef uint8_t H_Tag; - typedef struct There_Body { uint8_t x; int16_t y; } There_Body; + + typedef struct H { H_Tag tag; union { diff --git a/tests/expectations/annotation_both.compat.c b/tests/expectations/annotation_both.compat.c index 57d9f297..7a587200 100644 --- a/tests/expectations/annotation_both.compat.c +++ b/tests/expectations/annotation_both.compat.c @@ -15,6 +15,7 @@ enum C typedef uint32_t C; #endif // __cplusplus + typedef struct A { int32_t m0; } A; @@ -36,13 +37,14 @@ enum F_Tag #ifndef __cplusplus typedef uint8_t F_Tag; #endif // __cplusplus - typedef struct Bar_Body { F_Tag tag; uint8_t x; int16_t y; } Bar_Body; + + typedef union F { F_Tag tag; struct { @@ -64,12 +66,13 @@ enum H_Tag #ifndef __cplusplus typedef uint8_t H_Tag; #endif // __cplusplus - typedef struct There_Body { uint8_t x; int16_t y; } There_Body; + + typedef struct H { H_Tag tag; union { diff --git a/tests/expectations/annotation_tag.c b/tests/expectations/annotation_tag.c index 826c41ab..034cadc9 100644 --- a/tests/expectations/annotation_tag.c +++ b/tests/expectations/annotation_tag.c @@ -9,6 +9,7 @@ enum C { }; typedef uint32_t C; + struct A { int32_t m0; }; @@ -24,13 +25,14 @@ enum F_Tag { Baz, }; typedef uint8_t F_Tag; - struct Bar_Body { F_Tag tag; uint8_t x; int16_t y; }; + + union F { F_Tag tag; struct { @@ -46,12 +48,13 @@ enum H_Tag { Everyone, }; typedef uint8_t H_Tag; - struct There_Body { uint8_t x; int16_t y; }; + + struct H { H_Tag tag; union { diff --git a/tests/expectations/annotation_tag.compat.c b/tests/expectations/annotation_tag.compat.c index ab022610..52d99966 100644 --- a/tests/expectations/annotation_tag.compat.c +++ b/tests/expectations/annotation_tag.compat.c @@ -15,6 +15,7 @@ enum C typedef uint32_t C; #endif // __cplusplus + struct A { int32_t m0; }; @@ -36,13 +37,14 @@ enum F_Tag #ifndef __cplusplus typedef uint8_t F_Tag; #endif // __cplusplus - struct Bar_Body { F_Tag tag; uint8_t x; int16_t y; }; + + union F { F_Tag tag; struct { @@ -64,12 +66,13 @@ enum H_Tag #ifndef __cplusplus typedef uint8_t H_Tag; #endif // __cplusplus - struct There_Body { uint8_t x; int16_t y; }; + + struct H { H_Tag tag; union { diff --git a/tests/expectations/annotation_tag.pyx b/tests/expectations/annotation_tag.pyx index 4f0b46ac..bfaafb9b 100644 --- a/tests/expectations/annotation_tag.pyx +++ b/tests/expectations/annotation_tag.pyx @@ -11,6 +11,7 @@ cdef extern from *: Y, ctypedef uint32_t C; + cdef struct A: int32_t m0; @@ -23,12 +24,13 @@ cdef extern from *: Bar, Baz, ctypedef uint8_t F_Tag; - cdef struct Bar_Body: F_Tag tag; uint8_t x; int16_t y; + + cdef union F: F_Tag tag; int16_t foo; @@ -39,11 +41,12 @@ cdef extern from *: There, Everyone, ctypedef uint8_t H_Tag; - cdef struct There_Body: uint8_t x; int16_t y; + + cdef struct H: H_Tag tag; int16_t hello; diff --git a/tests/expectations/array.cpp b/tests/expectations/array.cpp index 7e34fe9c..03186b4e 100644 --- a/tests/expectations/array.cpp +++ b/tests/expectations/array.cpp @@ -7,12 +7,12 @@ struct Foo { enum class Tag { A, - }; - - struct A_Body { + };struct A_Body { float _0[20]; }; + + Tag tag; union { A_Body a; diff --git a/tests/expectations/array.pyx b/tests/expectations/array.pyx index d0a8c23e..880e2f3f 100644 --- a/tests/expectations/array.pyx +++ b/tests/expectations/array.pyx @@ -9,6 +9,7 @@ cdef extern from *: ctypedef enum Foo_Tag: A, + ctypedef struct Foo: Foo_Tag tag; float a[20]; diff --git a/tests/expectations/array_tag.pyx b/tests/expectations/array_tag.pyx index 47e75f58..acdb325d 100644 --- a/tests/expectations/array_tag.pyx +++ b/tests/expectations/array_tag.pyx @@ -9,6 +9,7 @@ cdef extern from *: cdef enum Foo_Tag: A, + cdef struct Foo: Foo_Tag tag; float a[20]; diff --git a/tests/expectations/asserted_cast.c b/tests/expectations/asserted_cast.c index 5dad5225..ecbdb150 100644 --- a/tests/expectations/asserted_cast.c +++ b/tests/expectations/asserted_cast.c @@ -15,12 +15,13 @@ enum H_Tag { H_Baz, }; typedef uint8_t H_Tag; - typedef struct { uint8_t x; int16_t y; } H_Bar_Body; + + typedef struct { H_Tag tag; union { @@ -37,12 +38,13 @@ enum J_Tag { J_Baz, }; typedef uint8_t J_Tag; - typedef struct { uint8_t x; int16_t y; } J_Bar_Body; + + typedef struct { J_Tag tag; union { @@ -59,13 +61,14 @@ enum K_Tag { K_Baz, }; typedef uint8_t K_Tag; - typedef struct { K_Tag tag; uint8_t x; int16_t y; } K_Bar_Body; + + typedef union { K_Tag tag; struct { diff --git a/tests/expectations/asserted_cast.compat.c b/tests/expectations/asserted_cast.compat.c index 2d75731f..9e36c52a 100644 --- a/tests/expectations/asserted_cast.compat.c +++ b/tests/expectations/asserted_cast.compat.c @@ -21,12 +21,13 @@ enum H_Tag #ifndef __cplusplus typedef uint8_t H_Tag; #endif // __cplusplus - typedef struct { uint8_t x; int16_t y; } H_Bar_Body; + + typedef struct { H_Tag tag; union { @@ -49,12 +50,13 @@ enum J_Tag #ifndef __cplusplus typedef uint8_t J_Tag; #endif // __cplusplus - typedef struct { uint8_t x; int16_t y; } J_Bar_Body; + + typedef struct { J_Tag tag; union { @@ -77,13 +79,14 @@ enum K_Tag #ifndef __cplusplus typedef uint8_t K_Tag; #endif // __cplusplus - typedef struct { K_Tag tag; uint8_t x; int16_t y; } K_Bar_Body; + + typedef union { K_Tag tag; struct { diff --git a/tests/expectations/asserted_cast.cpp b/tests/expectations/asserted_cast.cpp index 3dfe5204..9d570569 100644 --- a/tests/expectations/asserted_cast.cpp +++ b/tests/expectations/asserted_cast.cpp @@ -16,7 +16,6 @@ struct H { H_Bar, H_Baz, }; - struct H_Foo_Body { int16_t _0; }; @@ -26,6 +25,8 @@ struct H { int16_t y; }; + + Tag tag; union { H_Foo_Body foo; @@ -93,7 +94,6 @@ struct J { J_Bar, J_Baz, }; - struct J_Foo_Body { int16_t _0; }; @@ -103,6 +103,8 @@ struct J { int16_t y; }; + + Tag tag; union { J_Foo_Body foo; @@ -170,7 +172,6 @@ union K { K_Bar, K_Baz, }; - struct K_Foo_Body { Tag tag; int16_t _0; @@ -182,6 +183,8 @@ union K { int16_t y; }; + + struct { Tag tag; }; diff --git a/tests/expectations/asserted_cast.pyx b/tests/expectations/asserted_cast.pyx index 126635c0..d1f66c33 100644 --- a/tests/expectations/asserted_cast.pyx +++ b/tests/expectations/asserted_cast.pyx @@ -18,11 +18,12 @@ cdef extern from *: H_Bar, H_Baz, ctypedef uint8_t H_Tag; - ctypedef struct H_Bar_Body: uint8_t x; int16_t y; + + ctypedef struct H: H_Tag tag; int16_t foo; @@ -33,11 +34,12 @@ cdef extern from *: J_Bar, J_Baz, ctypedef uint8_t J_Tag; - ctypedef struct J_Bar_Body: uint8_t x; int16_t y; + + ctypedef struct J: J_Tag tag; int16_t foo; @@ -48,12 +50,13 @@ cdef extern from *: K_Bar, K_Baz, ctypedef uint8_t K_Tag; - ctypedef struct K_Bar_Body: K_Tag tag; uint8_t x; int16_t y; + + ctypedef union K: K_Tag tag; int16_t foo; diff --git a/tests/expectations/asserted_cast_both.c b/tests/expectations/asserted_cast_both.c index 1cb6854a..4e48ebc1 100644 --- a/tests/expectations/asserted_cast_both.c +++ b/tests/expectations/asserted_cast_both.c @@ -15,12 +15,13 @@ enum H_Tag { H_Baz, }; typedef uint8_t H_Tag; - typedef struct H_Bar_Body { uint8_t x; int16_t y; } H_Bar_Body; + + typedef struct H { H_Tag tag; union { @@ -37,12 +38,13 @@ enum J_Tag { J_Baz, }; typedef uint8_t J_Tag; - typedef struct J_Bar_Body { uint8_t x; int16_t y; } J_Bar_Body; + + typedef struct J { J_Tag tag; union { @@ -59,13 +61,14 @@ enum K_Tag { K_Baz, }; typedef uint8_t K_Tag; - typedef struct K_Bar_Body { K_Tag tag; uint8_t x; int16_t y; } K_Bar_Body; + + typedef union K { K_Tag tag; struct { diff --git a/tests/expectations/asserted_cast_both.compat.c b/tests/expectations/asserted_cast_both.compat.c index 815190b5..a0db6c47 100644 --- a/tests/expectations/asserted_cast_both.compat.c +++ b/tests/expectations/asserted_cast_both.compat.c @@ -21,12 +21,13 @@ enum H_Tag #ifndef __cplusplus typedef uint8_t H_Tag; #endif // __cplusplus - typedef struct H_Bar_Body { uint8_t x; int16_t y; } H_Bar_Body; + + typedef struct H { H_Tag tag; union { @@ -49,12 +50,13 @@ enum J_Tag #ifndef __cplusplus typedef uint8_t J_Tag; #endif // __cplusplus - typedef struct J_Bar_Body { uint8_t x; int16_t y; } J_Bar_Body; + + typedef struct J { J_Tag tag; union { @@ -77,13 +79,14 @@ enum K_Tag #ifndef __cplusplus typedef uint8_t K_Tag; #endif // __cplusplus - typedef struct K_Bar_Body { K_Tag tag; uint8_t x; int16_t y; } K_Bar_Body; + + typedef union K { K_Tag tag; struct { diff --git a/tests/expectations/asserted_cast_tag.c b/tests/expectations/asserted_cast_tag.c index f953fbe1..362c2ffa 100644 --- a/tests/expectations/asserted_cast_tag.c +++ b/tests/expectations/asserted_cast_tag.c @@ -15,12 +15,13 @@ enum H_Tag { H_Baz, }; typedef uint8_t H_Tag; - struct H_Bar_Body { uint8_t x; int16_t y; }; + + struct H { H_Tag tag; union { @@ -37,12 +38,13 @@ enum J_Tag { J_Baz, }; typedef uint8_t J_Tag; - struct J_Bar_Body { uint8_t x; int16_t y; }; + + struct J { J_Tag tag; union { @@ -59,13 +61,14 @@ enum K_Tag { K_Baz, }; typedef uint8_t K_Tag; - struct K_Bar_Body { K_Tag tag; uint8_t x; int16_t y; }; + + union K { K_Tag tag; struct { diff --git a/tests/expectations/asserted_cast_tag.compat.c b/tests/expectations/asserted_cast_tag.compat.c index 005aadc7..4f1f9662 100644 --- a/tests/expectations/asserted_cast_tag.compat.c +++ b/tests/expectations/asserted_cast_tag.compat.c @@ -21,12 +21,13 @@ enum H_Tag #ifndef __cplusplus typedef uint8_t H_Tag; #endif // __cplusplus - struct H_Bar_Body { uint8_t x; int16_t y; }; + + struct H { H_Tag tag; union { @@ -49,12 +50,13 @@ enum J_Tag #ifndef __cplusplus typedef uint8_t J_Tag; #endif // __cplusplus - struct J_Bar_Body { uint8_t x; int16_t y; }; + + struct J { J_Tag tag; union { @@ -77,13 +79,14 @@ enum K_Tag #ifndef __cplusplus typedef uint8_t K_Tag; #endif // __cplusplus - struct K_Bar_Body { K_Tag tag; uint8_t x; int16_t y; }; + + union K { K_Tag tag; struct { diff --git a/tests/expectations/asserted_cast_tag.pyx b/tests/expectations/asserted_cast_tag.pyx index bf6dec5a..65f49f5b 100644 --- a/tests/expectations/asserted_cast_tag.pyx +++ b/tests/expectations/asserted_cast_tag.pyx @@ -18,11 +18,12 @@ cdef extern from *: H_Bar, H_Baz, ctypedef uint8_t H_Tag; - cdef struct H_Bar_Body: uint8_t x; int16_t y; + + cdef struct H: H_Tag tag; int16_t foo; @@ -33,11 +34,12 @@ cdef extern from *: J_Bar, J_Baz, ctypedef uint8_t J_Tag; - cdef struct J_Bar_Body: uint8_t x; int16_t y; + + cdef struct J: J_Tag tag; int16_t foo; @@ -48,12 +50,13 @@ cdef extern from *: K_Bar, K_Baz, ctypedef uint8_t K_Tag; - cdef struct K_Bar_Body: K_Tag tag; uint8_t x; int16_t y; + + cdef union K: K_Tag tag; int16_t foo; diff --git a/tests/expectations/body.cpp b/tests/expectations/body.cpp index ba974db1..1b1dd91e 100644 --- a/tests/expectations/body.cpp +++ b/tests/expectations/body.cpp @@ -28,9 +28,7 @@ struct MyFancyEnum { Foo, Bar, Baz, - }; - - struct Bar_Body { + };struct Bar_Body { int32_t _0; }; @@ -38,6 +36,8 @@ struct MyFancyEnum { int32_t _0; }; + + Tag tag; union { Bar_Body bar; @@ -69,9 +69,7 @@ struct MyFancyEnum_Prepended { Foo_Prepended, Bar_Prepended, Baz_Prepended, - }; - - struct Bar_Prepended_Body { + };struct Bar_Prepended_Body { int32_t _0; }; @@ -79,6 +77,8 @@ struct MyFancyEnum_Prepended { int32_t _0; }; + + Tag tag; union { Bar_Prepended_Body bar_prepended; diff --git a/tests/expectations/body.pyx b/tests/expectations/body.pyx index 6ea366fa..f53450de 100644 --- a/tests/expectations/body.pyx +++ b/tests/expectations/body.pyx @@ -11,11 +11,13 @@ cdef extern from *: Bar1, Baz1, + ctypedef enum MyCLikeEnum_Prepended: Foo1_Prepended, Bar1_Prepended, Baz1_Prepended, + ctypedef struct MyFancyStruct: int32_t i; #ifdef __cplusplus @@ -27,6 +29,7 @@ cdef extern from *: Bar, Baz, + ctypedef struct MyFancyEnum: MyFancyEnum_Tag tag; int32_t bar; @@ -51,6 +54,7 @@ cdef extern from *: Bar_Prepended, Baz_Prepended, + ctypedef struct MyFancyEnum_Prepended: #ifdef __cplusplus inline void wohoo(); diff --git a/tests/expectations/body_tag.pyx b/tests/expectations/body_tag.pyx index 15a63a45..36b6bba8 100644 --- a/tests/expectations/body_tag.pyx +++ b/tests/expectations/body_tag.pyx @@ -11,11 +11,13 @@ cdef extern from *: Bar1, Baz1, + cdef enum MyCLikeEnum_Prepended: Foo1_Prepended, Bar1_Prepended, Baz1_Prepended, + cdef struct MyFancyStruct: int32_t i; #ifdef __cplusplus @@ -27,6 +29,7 @@ cdef extern from *: Bar, Baz, + cdef struct MyFancyEnum: MyFancyEnum_Tag tag; int32_t bar; @@ -51,6 +54,7 @@ cdef extern from *: Bar_Prepended, Baz_Prepended, + cdef struct MyFancyEnum_Prepended: #ifdef __cplusplus inline void wohoo(); diff --git a/tests/expectations/cfg.c b/tests/expectations/cfg.c index 800b518f..e81e61a2 100644 --- a/tests/expectations/cfg.c +++ b/tests/expectations/cfg.c @@ -18,6 +18,7 @@ enum BarType { C, }; typedef uint32_t BarType; + #endif #if (defined(PLATFORM_UNIX) && defined(X11)) @@ -27,6 +28,7 @@ enum FooType { C, }; typedef uint32_t FooType; + #endif #if (defined(PLATFORM_UNIX) && defined(X11)) @@ -48,7 +50,6 @@ enum C_Tag { #endif }; typedef uint8_t C_Tag; - #if defined(PLATFORM_UNIX) typedef struct { C_Tag tag; @@ -56,6 +57,8 @@ typedef struct { } C5_Body; #endif + + typedef union { C_Tag tag; #if defined(PLATFORM_UNIX) diff --git a/tests/expectations/cfg.compat.c b/tests/expectations/cfg.compat.c index 6a457435..b7256fec 100644 --- a/tests/expectations/cfg.compat.c +++ b/tests/expectations/cfg.compat.c @@ -24,6 +24,7 @@ enum BarType #ifndef __cplusplus typedef uint32_t BarType; #endif // __cplusplus + #endif #if (defined(PLATFORM_UNIX) && defined(X11)) @@ -39,6 +40,7 @@ enum FooType #ifndef __cplusplus typedef uint32_t FooType; #endif // __cplusplus + #endif #if (defined(PLATFORM_UNIX) && defined(X11)) @@ -66,7 +68,6 @@ enum C_Tag #ifndef __cplusplus typedef uint8_t C_Tag; #endif // __cplusplus - #if defined(PLATFORM_UNIX) typedef struct { C_Tag tag; @@ -74,6 +75,8 @@ typedef struct { } C5_Body; #endif + + typedef union { C_Tag tag; #if defined(PLATFORM_UNIX) diff --git a/tests/expectations/cfg.cpp b/tests/expectations/cfg.cpp index 1eed9afd..51774865 100644 --- a/tests/expectations/cfg.cpp +++ b/tests/expectations/cfg.cpp @@ -18,6 +18,7 @@ enum class BarType : uint32_t { B, C, }; + #endif #if (defined(PLATFORM_UNIX) && defined(X11)) @@ -26,6 +27,7 @@ enum class FooType : uint32_t { B, C, }; + #endif #if (defined(PLATFORM_UNIX) && defined(X11)) @@ -58,7 +60,6 @@ union C { C5, #endif }; - #if defined(PLATFORM_UNIX) struct C5_Body { Tag tag; @@ -73,6 +74,8 @@ union C { }; #endif + + struct { Tag tag; }; diff --git a/tests/expectations/cfg.pyx b/tests/expectations/cfg.pyx index 803fd7a7..5c7f49d8 100644 --- a/tests/expectations/cfg.pyx +++ b/tests/expectations/cfg.pyx @@ -21,6 +21,7 @@ cdef extern from *: C, ctypedef uint32_t BarType; + IF (PLATFORM_UNIX and X11): cdef enum: A, @@ -28,6 +29,7 @@ cdef extern from *: C, ctypedef uint32_t FooType; + IF (PLATFORM_UNIX and X11): ctypedef struct FooHandle: FooType ty; @@ -40,11 +42,12 @@ cdef extern from *: 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; diff --git a/tests/expectations/cfg_both.c b/tests/expectations/cfg_both.c index 55fcc894..bab35971 100644 --- a/tests/expectations/cfg_both.c +++ b/tests/expectations/cfg_both.c @@ -18,6 +18,7 @@ enum BarType { C, }; typedef uint32_t BarType; + #endif #if (defined(PLATFORM_UNIX) && defined(X11)) @@ -27,6 +28,7 @@ enum FooType { C, }; typedef uint32_t FooType; + #endif #if (defined(PLATFORM_UNIX) && defined(X11)) @@ -48,7 +50,6 @@ enum C_Tag { #endif }; typedef uint8_t C_Tag; - #if defined(PLATFORM_UNIX) typedef struct C5_Body { C_Tag tag; @@ -56,6 +57,8 @@ typedef struct C5_Body { } C5_Body; #endif + + typedef union C { C_Tag tag; #if defined(PLATFORM_UNIX) diff --git a/tests/expectations/cfg_both.compat.c b/tests/expectations/cfg_both.compat.c index 000b03d4..dfbb34ef 100644 --- a/tests/expectations/cfg_both.compat.c +++ b/tests/expectations/cfg_both.compat.c @@ -24,6 +24,7 @@ enum BarType #ifndef __cplusplus typedef uint32_t BarType; #endif // __cplusplus + #endif #if (defined(PLATFORM_UNIX) && defined(X11)) @@ -39,6 +40,7 @@ enum FooType #ifndef __cplusplus typedef uint32_t FooType; #endif // __cplusplus + #endif #if (defined(PLATFORM_UNIX) && defined(X11)) @@ -66,7 +68,6 @@ enum C_Tag #ifndef __cplusplus typedef uint8_t C_Tag; #endif // __cplusplus - #if defined(PLATFORM_UNIX) typedef struct C5_Body { C_Tag tag; @@ -74,6 +75,8 @@ typedef struct C5_Body { } C5_Body; #endif + + typedef union C { C_Tag tag; #if defined(PLATFORM_UNIX) diff --git a/tests/expectations/cfg_tag.c b/tests/expectations/cfg_tag.c index f9cad7b5..abc7ae45 100644 --- a/tests/expectations/cfg_tag.c +++ b/tests/expectations/cfg_tag.c @@ -18,6 +18,7 @@ enum BarType { C, }; typedef uint32_t BarType; + #endif #if (defined(PLATFORM_UNIX) && defined(X11)) @@ -27,6 +28,7 @@ enum FooType { C, }; typedef uint32_t FooType; + #endif #if (defined(PLATFORM_UNIX) && defined(X11)) @@ -48,7 +50,6 @@ enum C_Tag { #endif }; typedef uint8_t C_Tag; - #if defined(PLATFORM_UNIX) struct C5_Body { C_Tag tag; @@ -56,6 +57,8 @@ struct C5_Body { }; #endif + + union C { C_Tag tag; #if defined(PLATFORM_UNIX) diff --git a/tests/expectations/cfg_tag.compat.c b/tests/expectations/cfg_tag.compat.c index cfe66ffd..e166851a 100644 --- a/tests/expectations/cfg_tag.compat.c +++ b/tests/expectations/cfg_tag.compat.c @@ -24,6 +24,7 @@ enum BarType #ifndef __cplusplus typedef uint32_t BarType; #endif // __cplusplus + #endif #if (defined(PLATFORM_UNIX) && defined(X11)) @@ -39,6 +40,7 @@ enum FooType #ifndef __cplusplus typedef uint32_t FooType; #endif // __cplusplus + #endif #if (defined(PLATFORM_UNIX) && defined(X11)) @@ -66,7 +68,6 @@ enum C_Tag #ifndef __cplusplus typedef uint8_t C_Tag; #endif // __cplusplus - #if defined(PLATFORM_UNIX) struct C5_Body { C_Tag tag; @@ -74,6 +75,8 @@ struct C5_Body { }; #endif + + union C { C_Tag tag; #if defined(PLATFORM_UNIX) diff --git a/tests/expectations/cfg_tag.pyx b/tests/expectations/cfg_tag.pyx index 6a0d44d7..0d53304b 100644 --- a/tests/expectations/cfg_tag.pyx +++ b/tests/expectations/cfg_tag.pyx @@ -21,6 +21,7 @@ cdef extern from *: C, ctypedef uint32_t BarType; + IF (PLATFORM_UNIX and X11): cdef enum: A, @@ -28,6 +29,7 @@ cdef extern from *: C, ctypedef uint32_t FooType; + IF (PLATFORM_UNIX and X11): cdef struct FooHandle: FooType ty; @@ -40,11 +42,12 @@ cdef extern from *: 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; diff --git a/tests/expectations/constant_user_defined_type.pyx b/tests/expectations/constant_user_defined_type.pyx index fc29bd2f..45d6d916 100644 --- a/tests/expectations/constant_user_defined_type.pyx +++ b/tests/expectations/constant_user_defined_type.pyx @@ -9,6 +9,7 @@ cdef extern from *: ctypedef enum E: V, + ctypedef struct S: uint8_t field; diff --git a/tests/expectations/constant_user_defined_type_tag.pyx b/tests/expectations/constant_user_defined_type_tag.pyx index bc95105e..8078ad1c 100644 --- a/tests/expectations/constant_user_defined_type_tag.pyx +++ b/tests/expectations/constant_user_defined_type_tag.pyx @@ -9,6 +9,7 @@ cdef extern from *: cdef enum E: V, + cdef struct S: uint8_t field; diff --git a/tests/expectations/decl_name_conflicting.c b/tests/expectations/decl_name_conflicting.c index 41a148e4..290380ab 100644 --- a/tests/expectations/decl_name_conflicting.c +++ b/tests/expectations/decl_name_conflicting.c @@ -9,6 +9,7 @@ enum BindingType { }; typedef uint32_t BindingType; + typedef struct { BindingType ty; } BindGroupLayoutEntry; diff --git a/tests/expectations/decl_name_conflicting.compat.c b/tests/expectations/decl_name_conflicting.compat.c index 6866bb81..0f0cc1ea 100644 --- a/tests/expectations/decl_name_conflicting.compat.c +++ b/tests/expectations/decl_name_conflicting.compat.c @@ -15,6 +15,7 @@ enum BindingType typedef uint32_t BindingType; #endif // __cplusplus + typedef struct { BindingType ty; } BindGroupLayoutEntry; diff --git a/tests/expectations/decl_name_conflicting.cpp b/tests/expectations/decl_name_conflicting.cpp index bc675c1b..337e3bb6 100644 --- a/tests/expectations/decl_name_conflicting.cpp +++ b/tests/expectations/decl_name_conflicting.cpp @@ -9,6 +9,7 @@ enum class BindingType : uint32_t { NotBuffer = 1, }; + struct BindGroupLayoutEntry { BindingType ty; }; diff --git a/tests/expectations/decl_name_conflicting.pyx b/tests/expectations/decl_name_conflicting.pyx index d7dbc5e6..04e30118 100644 --- a/tests/expectations/decl_name_conflicting.pyx +++ b/tests/expectations/decl_name_conflicting.pyx @@ -11,6 +11,7 @@ cdef extern from *: NotBuffer # = 1, ctypedef uint32_t BindingType; + ctypedef struct BindGroupLayoutEntry: BindingType ty; diff --git a/tests/expectations/decl_name_conflicting_both.c b/tests/expectations/decl_name_conflicting_both.c index 486b31c6..5cdd9ae1 100644 --- a/tests/expectations/decl_name_conflicting_both.c +++ b/tests/expectations/decl_name_conflicting_both.c @@ -9,6 +9,7 @@ enum BindingType { }; typedef uint32_t BindingType; + typedef struct BindGroupLayoutEntry { BindingType ty; } BindGroupLayoutEntry; diff --git a/tests/expectations/decl_name_conflicting_both.compat.c b/tests/expectations/decl_name_conflicting_both.compat.c index 143f0d1d..6ac06b90 100644 --- a/tests/expectations/decl_name_conflicting_both.compat.c +++ b/tests/expectations/decl_name_conflicting_both.compat.c @@ -15,6 +15,7 @@ enum BindingType typedef uint32_t BindingType; #endif // __cplusplus + typedef struct BindGroupLayoutEntry { BindingType ty; } BindGroupLayoutEntry; diff --git a/tests/expectations/decl_name_conflicting_tag.c b/tests/expectations/decl_name_conflicting_tag.c index 7504e4aa..a14bf5f2 100644 --- a/tests/expectations/decl_name_conflicting_tag.c +++ b/tests/expectations/decl_name_conflicting_tag.c @@ -9,6 +9,7 @@ enum BindingType { }; typedef uint32_t BindingType; + struct BindGroupLayoutEntry { BindingType ty; }; diff --git a/tests/expectations/decl_name_conflicting_tag.compat.c b/tests/expectations/decl_name_conflicting_tag.compat.c index df722be0..7c42c770 100644 --- a/tests/expectations/decl_name_conflicting_tag.compat.c +++ b/tests/expectations/decl_name_conflicting_tag.compat.c @@ -15,6 +15,7 @@ enum BindingType typedef uint32_t BindingType; #endif // __cplusplus + struct BindGroupLayoutEntry { BindingType ty; }; diff --git a/tests/expectations/decl_name_conflicting_tag.pyx b/tests/expectations/decl_name_conflicting_tag.pyx index 82ebc2f0..68fd569f 100644 --- a/tests/expectations/decl_name_conflicting_tag.pyx +++ b/tests/expectations/decl_name_conflicting_tag.pyx @@ -11,6 +11,7 @@ cdef extern from *: NotBuffer # = 1, ctypedef uint32_t BindingType; + cdef struct BindGroupLayoutEntry: BindingType ty; diff --git a/tests/expectations/deprecated.c b/tests/expectations/deprecated.c index 48f5574d..0c702a80 100644 --- a/tests/expectations/deprecated.c +++ b/tests/expectations/deprecated.c @@ -18,11 +18,13 @@ enum DEPRECATED_ENUM DeprecatedEnum { }; typedef int32_t DeprecatedEnum; + enum DEPRECATED_ENUM_WITH_NOTE("This is a note") DeprecatedEnumWithNote { B = 0, }; typedef int32_t DeprecatedEnumWithNote; + enum EnumWithDeprecatedVariants { C = 0, D DEPRECATED_ENUM_VARIANT = 1, @@ -31,6 +33,7 @@ enum EnumWithDeprecatedVariants { }; typedef int32_t EnumWithDeprecatedVariants; + typedef struct DEPRECATED_STRUCT { int32_t a; } DeprecatedStruct; @@ -45,7 +48,6 @@ enum EnumWithDeprecatedStructVariants_Tag { Baz DEPRECATED_ENUM_VARIANT_WITH_NOTE("This is a note"), }; typedef uint8_t EnumWithDeprecatedStructVariants_Tag; - typedef struct DEPRECATED_STRUCT { EnumWithDeprecatedStructVariants_Tag tag; uint8_t x; @@ -58,6 +60,8 @@ typedef struct DEPRECATED_STRUCT_WITH_NOTE("This is a note") { uint8_t y; } Baz_Body; + + typedef union { EnumWithDeprecatedStructVariants_Tag tag; struct { diff --git a/tests/expectations/deprecated.compat.c b/tests/expectations/deprecated.compat.c index dcdede48..d188f12c 100644 --- a/tests/expectations/deprecated.compat.c +++ b/tests/expectations/deprecated.compat.c @@ -24,6 +24,7 @@ enum DEPRECATED_ENUM DeprecatedEnum typedef int32_t DeprecatedEnum; #endif // __cplusplus + enum DEPRECATED_ENUM_WITH_NOTE("This is a note") DeprecatedEnumWithNote #ifdef __cplusplus : int32_t @@ -35,6 +36,7 @@ enum DEPRECATED_ENUM_WITH_NOTE("This is a note") DeprecatedEnumWithNote typedef int32_t DeprecatedEnumWithNote; #endif // __cplusplus + enum EnumWithDeprecatedVariants #ifdef __cplusplus : int32_t @@ -49,6 +51,7 @@ enum EnumWithDeprecatedVariants typedef int32_t EnumWithDeprecatedVariants; #endif // __cplusplus + typedef struct DEPRECATED_STRUCT { int32_t a; } DeprecatedStruct; @@ -69,7 +72,6 @@ enum EnumWithDeprecatedStructVariants_Tag #ifndef __cplusplus typedef uint8_t EnumWithDeprecatedStructVariants_Tag; #endif // __cplusplus - typedef struct DEPRECATED_STRUCT { EnumWithDeprecatedStructVariants_Tag tag; uint8_t x; @@ -82,6 +84,8 @@ typedef struct DEPRECATED_STRUCT_WITH_NOTE("This is a note") { uint8_t y; } Baz_Body; + + typedef union { EnumWithDeprecatedStructVariants_Tag tag; struct { diff --git a/tests/expectations/deprecated.cpp b/tests/expectations/deprecated.cpp index d7bd3d63..a82b736b 100644 --- a/tests/expectations/deprecated.cpp +++ b/tests/expectations/deprecated.cpp @@ -18,10 +18,12 @@ enum class DEPRECATED_ENUM DeprecatedEnum : int32_t { A = 0, }; + enum class DEPRECATED_ENUM_WITH_NOTE("This is a note") DeprecatedEnumWithNote : int32_t { B = 0, }; + enum class EnumWithDeprecatedVariants : int32_t { C = 0, D DEPRECATED_ENUM_VARIANT = 1, @@ -29,6 +31,7 @@ enum class EnumWithDeprecatedVariants : int32_t { F DEPRECATED_ENUM_VARIANT_WITH_NOTE("This is a note") = 3, }; + struct DEPRECATED_STRUCT DeprecatedStruct { int32_t a; }; @@ -43,7 +46,6 @@ union EnumWithDeprecatedStructVariants { Bar DEPRECATED_ENUM_VARIANT, Baz DEPRECATED_ENUM_VARIANT_WITH_NOTE("This is a note"), }; - struct Foo_Body { Tag tag; int16_t _0; @@ -61,6 +63,8 @@ union EnumWithDeprecatedStructVariants { uint8_t y; }; + + struct { Tag tag; }; diff --git a/tests/expectations/deprecated.pyx b/tests/expectations/deprecated.pyx index 6f362ae7..a3a5879c 100644 --- a/tests/expectations/deprecated.pyx +++ b/tests/expectations/deprecated.pyx @@ -20,10 +20,12 @@ cdef extern from *: A # = 0, ctypedef int32_t DeprecatedEnum; + cdef enum: B # = 0, ctypedef int32_t DeprecatedEnumWithNote; + cdef enum: C # = 0, D # = 1, @@ -31,6 +33,7 @@ cdef extern from *: F # = 3, ctypedef int32_t EnumWithDeprecatedVariants; + ctypedef struct DeprecatedStruct: int32_t a; @@ -42,7 +45,6 @@ cdef extern from *: Bar, Baz, ctypedef uint8_t EnumWithDeprecatedStructVariants_Tag; - ctypedef struct Bar_Body: EnumWithDeprecatedStructVariants_Tag tag; uint8_t x; @@ -53,6 +55,8 @@ cdef extern from *: uint8_t x; uint8_t y; + + ctypedef union EnumWithDeprecatedStructVariants: EnumWithDeprecatedStructVariants_Tag tag; int16_t foo; diff --git a/tests/expectations/deprecated_both.c b/tests/expectations/deprecated_both.c index e2713c4d..41dce8bc 100644 --- a/tests/expectations/deprecated_both.c +++ b/tests/expectations/deprecated_both.c @@ -18,11 +18,13 @@ enum DEPRECATED_ENUM DeprecatedEnum { }; typedef int32_t DeprecatedEnum; + enum DEPRECATED_ENUM_WITH_NOTE("This is a note") DeprecatedEnumWithNote { B = 0, }; typedef int32_t DeprecatedEnumWithNote; + enum EnumWithDeprecatedVariants { C = 0, D DEPRECATED_ENUM_VARIANT = 1, @@ -31,6 +33,7 @@ enum EnumWithDeprecatedVariants { }; typedef int32_t EnumWithDeprecatedVariants; + typedef struct DEPRECATED_STRUCT DeprecatedStruct { int32_t a; } DeprecatedStruct; @@ -45,7 +48,6 @@ enum EnumWithDeprecatedStructVariants_Tag { Baz DEPRECATED_ENUM_VARIANT_WITH_NOTE("This is a note"), }; typedef uint8_t EnumWithDeprecatedStructVariants_Tag; - typedef struct DEPRECATED_STRUCT Bar_Body { EnumWithDeprecatedStructVariants_Tag tag; uint8_t x; @@ -58,6 +60,8 @@ typedef struct DEPRECATED_STRUCT_WITH_NOTE("This is a note") Baz_Body { uint8_t y; } Baz_Body; + + typedef union EnumWithDeprecatedStructVariants { EnumWithDeprecatedStructVariants_Tag tag; struct { diff --git a/tests/expectations/deprecated_both.compat.c b/tests/expectations/deprecated_both.compat.c index 479aa730..46f9adc1 100644 --- a/tests/expectations/deprecated_both.compat.c +++ b/tests/expectations/deprecated_both.compat.c @@ -24,6 +24,7 @@ enum DEPRECATED_ENUM DeprecatedEnum typedef int32_t DeprecatedEnum; #endif // __cplusplus + enum DEPRECATED_ENUM_WITH_NOTE("This is a note") DeprecatedEnumWithNote #ifdef __cplusplus : int32_t @@ -35,6 +36,7 @@ enum DEPRECATED_ENUM_WITH_NOTE("This is a note") DeprecatedEnumWithNote typedef int32_t DeprecatedEnumWithNote; #endif // __cplusplus + enum EnumWithDeprecatedVariants #ifdef __cplusplus : int32_t @@ -49,6 +51,7 @@ enum EnumWithDeprecatedVariants typedef int32_t EnumWithDeprecatedVariants; #endif // __cplusplus + typedef struct DEPRECATED_STRUCT DeprecatedStruct { int32_t a; } DeprecatedStruct; @@ -69,7 +72,6 @@ enum EnumWithDeprecatedStructVariants_Tag #ifndef __cplusplus typedef uint8_t EnumWithDeprecatedStructVariants_Tag; #endif // __cplusplus - typedef struct DEPRECATED_STRUCT Bar_Body { EnumWithDeprecatedStructVariants_Tag tag; uint8_t x; @@ -82,6 +84,8 @@ typedef struct DEPRECATED_STRUCT_WITH_NOTE("This is a note") Baz_Body { uint8_t y; } Baz_Body; + + typedef union EnumWithDeprecatedStructVariants { EnumWithDeprecatedStructVariants_Tag tag; struct { diff --git a/tests/expectations/deprecated_tag.c b/tests/expectations/deprecated_tag.c index 982cdc55..e28970d1 100644 --- a/tests/expectations/deprecated_tag.c +++ b/tests/expectations/deprecated_tag.c @@ -18,11 +18,13 @@ enum DEPRECATED_ENUM DeprecatedEnum { }; typedef int32_t DeprecatedEnum; + enum DEPRECATED_ENUM_WITH_NOTE("This is a note") DeprecatedEnumWithNote { B = 0, }; typedef int32_t DeprecatedEnumWithNote; + enum EnumWithDeprecatedVariants { C = 0, D DEPRECATED_ENUM_VARIANT = 1, @@ -31,6 +33,7 @@ enum EnumWithDeprecatedVariants { }; typedef int32_t EnumWithDeprecatedVariants; + struct DEPRECATED_STRUCT DeprecatedStruct { int32_t a; }; @@ -45,7 +48,6 @@ enum EnumWithDeprecatedStructVariants_Tag { Baz DEPRECATED_ENUM_VARIANT_WITH_NOTE("This is a note"), }; typedef uint8_t EnumWithDeprecatedStructVariants_Tag; - struct DEPRECATED_STRUCT Bar_Body { EnumWithDeprecatedStructVariants_Tag tag; uint8_t x; @@ -58,6 +60,8 @@ struct DEPRECATED_STRUCT_WITH_NOTE("This is a note") Baz_Body { uint8_t y; }; + + union EnumWithDeprecatedStructVariants { EnumWithDeprecatedStructVariants_Tag tag; struct { diff --git a/tests/expectations/deprecated_tag.compat.c b/tests/expectations/deprecated_tag.compat.c index 322b79d2..9e19c20f 100644 --- a/tests/expectations/deprecated_tag.compat.c +++ b/tests/expectations/deprecated_tag.compat.c @@ -24,6 +24,7 @@ enum DEPRECATED_ENUM DeprecatedEnum typedef int32_t DeprecatedEnum; #endif // __cplusplus + enum DEPRECATED_ENUM_WITH_NOTE("This is a note") DeprecatedEnumWithNote #ifdef __cplusplus : int32_t @@ -35,6 +36,7 @@ enum DEPRECATED_ENUM_WITH_NOTE("This is a note") DeprecatedEnumWithNote typedef int32_t DeprecatedEnumWithNote; #endif // __cplusplus + enum EnumWithDeprecatedVariants #ifdef __cplusplus : int32_t @@ -49,6 +51,7 @@ enum EnumWithDeprecatedVariants typedef int32_t EnumWithDeprecatedVariants; #endif // __cplusplus + struct DEPRECATED_STRUCT DeprecatedStruct { int32_t a; }; @@ -69,7 +72,6 @@ enum EnumWithDeprecatedStructVariants_Tag #ifndef __cplusplus typedef uint8_t EnumWithDeprecatedStructVariants_Tag; #endif // __cplusplus - struct DEPRECATED_STRUCT Bar_Body { EnumWithDeprecatedStructVariants_Tag tag; uint8_t x; @@ -82,6 +84,8 @@ struct DEPRECATED_STRUCT_WITH_NOTE("This is a note") Baz_Body { uint8_t y; }; + + union EnumWithDeprecatedStructVariants { EnumWithDeprecatedStructVariants_Tag tag; struct { diff --git a/tests/expectations/deprecated_tag.pyx b/tests/expectations/deprecated_tag.pyx index 767da956..638fc44d 100644 --- a/tests/expectations/deprecated_tag.pyx +++ b/tests/expectations/deprecated_tag.pyx @@ -20,10 +20,12 @@ cdef extern from *: A # = 0, ctypedef int32_t DeprecatedEnum; + cdef enum: B # = 0, ctypedef int32_t DeprecatedEnumWithNote; + cdef enum: C # = 0, D # = 1, @@ -31,6 +33,7 @@ cdef extern from *: F # = 3, ctypedef int32_t EnumWithDeprecatedVariants; + cdef struct DeprecatedStruct: int32_t a; @@ -42,7 +45,6 @@ cdef extern from *: Bar, Baz, ctypedef uint8_t EnumWithDeprecatedStructVariants_Tag; - cdef struct Bar_Body: EnumWithDeprecatedStructVariants_Tag tag; uint8_t x; @@ -53,6 +55,8 @@ cdef extern from *: uint8_t x; uint8_t y; + + cdef union EnumWithDeprecatedStructVariants: EnumWithDeprecatedStructVariants_Tag tag; int16_t foo; diff --git a/tests/expectations/derive_eq.c b/tests/expectations/derive_eq.c index 339a937d..cdd34a71 100644 --- a/tests/expectations/derive_eq.c +++ b/tests/expectations/derive_eq.c @@ -15,7 +15,6 @@ enum Bar_Tag { FooParen, }; typedef uint8_t Bar_Tag; - typedef struct { Bar_Tag tag; Foo named; @@ -33,6 +32,8 @@ typedef struct { Foo _1; } FooParen_Body; + + typedef union { Bar_Tag tag; Bazz_Body bazz; diff --git a/tests/expectations/derive_eq.compat.c b/tests/expectations/derive_eq.compat.c index d3037f88..278d4938 100644 --- a/tests/expectations/derive_eq.compat.c +++ b/tests/expectations/derive_eq.compat.c @@ -21,7 +21,6 @@ enum Bar_Tag #ifndef __cplusplus typedef uint8_t Bar_Tag; #endif // __cplusplus - typedef struct { Bar_Tag tag; Foo named; @@ -39,6 +38,8 @@ typedef struct { Foo _1; } FooParen_Body; + + typedef union { Bar_Tag tag; Bazz_Body bazz; diff --git a/tests/expectations/derive_eq.cpp b/tests/expectations/derive_eq.cpp index 355fbd9c..cf197ffa 100644 --- a/tests/expectations/derive_eq.cpp +++ b/tests/expectations/derive_eq.cpp @@ -25,7 +25,6 @@ union Bar { FooNamed, FooParen, }; - struct Bazz_Body { Tag tag; Foo named; @@ -68,6 +67,8 @@ union Bar { } }; + + struct { Tag tag; }; diff --git a/tests/expectations/derive_eq.pyx b/tests/expectations/derive_eq.pyx index 0281a8aa..0baa7c94 100644 --- a/tests/expectations/derive_eq.pyx +++ b/tests/expectations/derive_eq.pyx @@ -16,7 +16,6 @@ cdef extern from *: FooNamed, FooParen, ctypedef uint8_t Bar_Tag; - ctypedef struct Bazz_Body: Bar_Tag tag; Foo named; @@ -31,6 +30,8 @@ cdef extern from *: int32_t _0; Foo _1; + + ctypedef union Bar: Bar_Tag tag; Bazz_Body bazz; diff --git a/tests/expectations/derive_eq_both.c b/tests/expectations/derive_eq_both.c index eab5b1c1..31ab4ebd 100644 --- a/tests/expectations/derive_eq_both.c +++ b/tests/expectations/derive_eq_both.c @@ -15,7 +15,6 @@ enum Bar_Tag { FooParen, }; typedef uint8_t Bar_Tag; - typedef struct Bazz_Body { Bar_Tag tag; struct Foo named; @@ -33,6 +32,8 @@ typedef struct FooParen_Body { struct Foo _1; } FooParen_Body; + + typedef union Bar { Bar_Tag tag; Bazz_Body bazz; diff --git a/tests/expectations/derive_eq_both.compat.c b/tests/expectations/derive_eq_both.compat.c index 1a0a366c..b07c4360 100644 --- a/tests/expectations/derive_eq_both.compat.c +++ b/tests/expectations/derive_eq_both.compat.c @@ -21,7 +21,6 @@ enum Bar_Tag #ifndef __cplusplus typedef uint8_t Bar_Tag; #endif // __cplusplus - typedef struct Bazz_Body { Bar_Tag tag; struct Foo named; @@ -39,6 +38,8 @@ typedef struct FooParen_Body { struct Foo _1; } FooParen_Body; + + typedef union Bar { Bar_Tag tag; Bazz_Body bazz; diff --git a/tests/expectations/derive_eq_tag.c b/tests/expectations/derive_eq_tag.c index 4de1da99..84a8c9f8 100644 --- a/tests/expectations/derive_eq_tag.c +++ b/tests/expectations/derive_eq_tag.c @@ -15,7 +15,6 @@ enum Bar_Tag { FooParen, }; typedef uint8_t Bar_Tag; - struct Bazz_Body { Bar_Tag tag; struct Foo named; @@ -33,6 +32,8 @@ struct FooParen_Body { struct Foo _1; }; + + union Bar { Bar_Tag tag; struct Bazz_Body bazz; diff --git a/tests/expectations/derive_eq_tag.compat.c b/tests/expectations/derive_eq_tag.compat.c index 66f02aed..64813437 100644 --- a/tests/expectations/derive_eq_tag.compat.c +++ b/tests/expectations/derive_eq_tag.compat.c @@ -21,7 +21,6 @@ enum Bar_Tag #ifndef __cplusplus typedef uint8_t Bar_Tag; #endif // __cplusplus - struct Bazz_Body { Bar_Tag tag; struct Foo named; @@ -39,6 +38,8 @@ struct FooParen_Body { struct Foo _1; }; + + union Bar { Bar_Tag tag; struct Bazz_Body bazz; diff --git a/tests/expectations/derive_eq_tag.pyx b/tests/expectations/derive_eq_tag.pyx index 10024bb9..5f5115b5 100644 --- a/tests/expectations/derive_eq_tag.pyx +++ b/tests/expectations/derive_eq_tag.pyx @@ -16,7 +16,6 @@ cdef extern from *: FooNamed, FooParen, ctypedef uint8_t Bar_Tag; - cdef struct Bazz_Body: Bar_Tag tag; Foo named; @@ -31,6 +30,8 @@ cdef extern from *: int32_t _0; Foo _1; + + cdef union Bar: Bar_Tag tag; Bazz_Body bazz; diff --git a/tests/expectations/derive_ostream.c b/tests/expectations/derive_ostream.c index 2db696db..047ad978 100644 --- a/tests/expectations/derive_ostream.c +++ b/tests/expectations/derive_ostream.c @@ -9,6 +9,7 @@ enum C { }; typedef uint32_t C; + typedef struct { int32_t _0; } A; @@ -30,13 +31,14 @@ enum F_Tag { Baz, }; typedef uint8_t F_Tag; - typedef struct { F_Tag tag; uint8_t x; int16_t y; } Bar_Body; + + typedef union { F_Tag tag; struct { @@ -52,12 +54,13 @@ enum H_Tag { Everyone, }; typedef uint8_t H_Tag; - typedef struct { uint8_t x; int16_t y; } There_Body; + + typedef struct { H_Tag tag; union { @@ -73,12 +76,13 @@ enum I_Tag { SomethingElse, }; typedef uint8_t I_Tag; - typedef struct { uint8_t x; int16_t y; } ThereAgain_Body; + + typedef struct { I_Tag tag; union { diff --git a/tests/expectations/derive_ostream.compat.c b/tests/expectations/derive_ostream.compat.c index e235353d..02db9ce2 100644 --- a/tests/expectations/derive_ostream.compat.c +++ b/tests/expectations/derive_ostream.compat.c @@ -15,6 +15,7 @@ enum C typedef uint32_t C; #endif // __cplusplus + typedef struct { int32_t _0; } A; @@ -42,13 +43,14 @@ enum F_Tag #ifndef __cplusplus typedef uint8_t F_Tag; #endif // __cplusplus - typedef struct { F_Tag tag; uint8_t x; int16_t y; } Bar_Body; + + typedef union { F_Tag tag; struct { @@ -70,12 +72,13 @@ enum H_Tag #ifndef __cplusplus typedef uint8_t H_Tag; #endif // __cplusplus - typedef struct { uint8_t x; int16_t y; } There_Body; + + typedef struct { H_Tag tag; union { @@ -97,12 +100,13 @@ enum I_Tag #ifndef __cplusplus typedef uint8_t I_Tag; #endif // __cplusplus - typedef struct { uint8_t x; int16_t y; } ThereAgain_Body; + + typedef struct { I_Tag tag; union { diff --git a/tests/expectations/derive_ostream.cpp b/tests/expectations/derive_ostream.cpp index 447a27df..e92f86cf 100644 --- a/tests/expectations/derive_ostream.cpp +++ b/tests/expectations/derive_ostream.cpp @@ -9,6 +9,7 @@ enum class C : uint32_t { Y, }; + inline std::ostream& operator<<(std::ostream& stream, const C& instance) { switch (instance) { case C::X: stream << "X"; break; @@ -54,6 +55,7 @@ union F { Baz, }; + friend std::ostream& operator<<(std::ostream& stream, const Tag& instance) { using Tag = F::Tag; switch (instance) { @@ -72,9 +74,7 @@ union F { case Tag::Baz: stream << "Baz"; break; } return stream; - } - - struct Foo_Body { + }struct Foo_Body { Tag tag; int16_t _0; @@ -96,6 +96,8 @@ union F { } }; + + struct { Tag tag; }; @@ -110,6 +112,7 @@ struct H { Everyone, }; + friend std::ostream& operator<<(std::ostream& stream, const Tag& instance) { using Tag = H::Tag; switch (instance) { @@ -128,9 +131,7 @@ struct H { case Tag::Everyone: stream << "Everyone"; break; } return stream; - } - - struct Hello_Body { + }struct Hello_Body { int16_t _0; friend std::ostream& operator<<(std::ostream& stream, const Hello_Body& instance) { @@ -148,6 +149,8 @@ struct H { } }; + + Tag tag; union { Hello_Body hello; @@ -160,7 +163,6 @@ struct I { ThereAgain, SomethingElse, }; - struct ThereAgain_Body { uint8_t x; int16_t y; @@ -171,6 +173,8 @@ struct I { } }; + + Tag tag; union { ThereAgain_Body there_again; diff --git a/tests/expectations/derive_ostream.pyx b/tests/expectations/derive_ostream.pyx index 2a416211..5c15c8cc 100644 --- a/tests/expectations/derive_ostream.pyx +++ b/tests/expectations/derive_ostream.pyx @@ -11,6 +11,7 @@ cdef extern from *: Y, ctypedef uint32_t C; + ctypedef struct A: int32_t _0; @@ -28,12 +29,13 @@ cdef extern from *: Bar, Baz, ctypedef uint8_t F_Tag; - ctypedef struct Bar_Body: F_Tag tag; uint8_t x; int16_t y; + + ctypedef union F: F_Tag tag; int16_t foo; @@ -44,11 +46,12 @@ cdef extern from *: There, Everyone, ctypedef uint8_t H_Tag; - ctypedef struct There_Body: uint8_t x; int16_t y; + + ctypedef struct H: H_Tag tag; int16_t hello; @@ -58,11 +61,12 @@ cdef extern from *: ThereAgain, SomethingElse, ctypedef uint8_t I_Tag; - ctypedef struct ThereAgain_Body: uint8_t x; int16_t y; + + ctypedef struct I: I_Tag tag; ThereAgain_Body there_again; diff --git a/tests/expectations/derive_ostream_both.c b/tests/expectations/derive_ostream_both.c index 8f45660e..33acc6fb 100644 --- a/tests/expectations/derive_ostream_both.c +++ b/tests/expectations/derive_ostream_both.c @@ -9,6 +9,7 @@ enum C { }; typedef uint32_t C; + typedef struct A { int32_t _0; } A; @@ -30,13 +31,14 @@ enum F_Tag { Baz, }; typedef uint8_t F_Tag; - typedef struct Bar_Body { F_Tag tag; uint8_t x; int16_t y; } Bar_Body; + + typedef union F { F_Tag tag; struct { @@ -52,12 +54,13 @@ enum H_Tag { Everyone, }; typedef uint8_t H_Tag; - typedef struct There_Body { uint8_t x; int16_t y; } There_Body; + + typedef struct H { H_Tag tag; union { @@ -73,12 +76,13 @@ enum I_Tag { SomethingElse, }; typedef uint8_t I_Tag; - typedef struct ThereAgain_Body { uint8_t x; int16_t y; } ThereAgain_Body; + + typedef struct I { I_Tag tag; union { diff --git a/tests/expectations/derive_ostream_both.compat.c b/tests/expectations/derive_ostream_both.compat.c index 69165d1d..24c93b79 100644 --- a/tests/expectations/derive_ostream_both.compat.c +++ b/tests/expectations/derive_ostream_both.compat.c @@ -15,6 +15,7 @@ enum C typedef uint32_t C; #endif // __cplusplus + typedef struct A { int32_t _0; } A; @@ -42,13 +43,14 @@ enum F_Tag #ifndef __cplusplus typedef uint8_t F_Tag; #endif // __cplusplus - typedef struct Bar_Body { F_Tag tag; uint8_t x; int16_t y; } Bar_Body; + + typedef union F { F_Tag tag; struct { @@ -70,12 +72,13 @@ enum H_Tag #ifndef __cplusplus typedef uint8_t H_Tag; #endif // __cplusplus - typedef struct There_Body { uint8_t x; int16_t y; } There_Body; + + typedef struct H { H_Tag tag; union { @@ -97,12 +100,13 @@ enum I_Tag #ifndef __cplusplus typedef uint8_t I_Tag; #endif // __cplusplus - typedef struct ThereAgain_Body { uint8_t x; int16_t y; } ThereAgain_Body; + + typedef struct I { I_Tag tag; union { diff --git a/tests/expectations/derive_ostream_tag.c b/tests/expectations/derive_ostream_tag.c index 4217a4be..7f522d8d 100644 --- a/tests/expectations/derive_ostream_tag.c +++ b/tests/expectations/derive_ostream_tag.c @@ -9,6 +9,7 @@ enum C { }; typedef uint32_t C; + struct A { int32_t _0; }; @@ -30,13 +31,14 @@ enum F_Tag { Baz, }; typedef uint8_t F_Tag; - struct Bar_Body { F_Tag tag; uint8_t x; int16_t y; }; + + union F { F_Tag tag; struct { @@ -52,12 +54,13 @@ enum H_Tag { Everyone, }; typedef uint8_t H_Tag; - struct There_Body { uint8_t x; int16_t y; }; + + struct H { H_Tag tag; union { @@ -73,12 +76,13 @@ enum I_Tag { SomethingElse, }; typedef uint8_t I_Tag; - struct ThereAgain_Body { uint8_t x; int16_t y; }; + + struct I { I_Tag tag; union { diff --git a/tests/expectations/derive_ostream_tag.compat.c b/tests/expectations/derive_ostream_tag.compat.c index f7b1b77b..2f5e6af2 100644 --- a/tests/expectations/derive_ostream_tag.compat.c +++ b/tests/expectations/derive_ostream_tag.compat.c @@ -15,6 +15,7 @@ enum C typedef uint32_t C; #endif // __cplusplus + struct A { int32_t _0; }; @@ -42,13 +43,14 @@ enum F_Tag #ifndef __cplusplus typedef uint8_t F_Tag; #endif // __cplusplus - struct Bar_Body { F_Tag tag; uint8_t x; int16_t y; }; + + union F { F_Tag tag; struct { @@ -70,12 +72,13 @@ enum H_Tag #ifndef __cplusplus typedef uint8_t H_Tag; #endif // __cplusplus - struct There_Body { uint8_t x; int16_t y; }; + + struct H { H_Tag tag; union { @@ -97,12 +100,13 @@ enum I_Tag #ifndef __cplusplus typedef uint8_t I_Tag; #endif // __cplusplus - struct ThereAgain_Body { uint8_t x; int16_t y; }; + + struct I { I_Tag tag; union { diff --git a/tests/expectations/derive_ostream_tag.pyx b/tests/expectations/derive_ostream_tag.pyx index 5e288851..3e7f96dc 100644 --- a/tests/expectations/derive_ostream_tag.pyx +++ b/tests/expectations/derive_ostream_tag.pyx @@ -11,6 +11,7 @@ cdef extern from *: Y, ctypedef uint32_t C; + cdef struct A: int32_t _0; @@ -28,12 +29,13 @@ cdef extern from *: Bar, Baz, ctypedef uint8_t F_Tag; - cdef struct Bar_Body: F_Tag tag; uint8_t x; int16_t y; + + cdef union F: F_Tag tag; int16_t foo; @@ -44,11 +46,12 @@ cdef extern from *: There, Everyone, ctypedef uint8_t H_Tag; - cdef struct There_Body: uint8_t x; int16_t y; + + cdef struct H: H_Tag tag; int16_t hello; @@ -58,11 +61,12 @@ cdef extern from *: ThereAgain, SomethingElse, ctypedef uint8_t I_Tag; - cdef struct ThereAgain_Body: uint8_t x; int16_t y; + + cdef struct I: I_Tag tag; ThereAgain_Body there_again; diff --git a/tests/expectations/destructor_and_copy_ctor.c b/tests/expectations/destructor_and_copy_ctor.c index 0f616ab2..421d1db8 100644 --- a/tests/expectations/destructor_and_copy_ctor.c +++ b/tests/expectations/destructor_and_copy_ctor.c @@ -13,6 +13,7 @@ enum FillRule { }; typedef uint8_t FillRule; + /** * This will have a destructor manually implemented via variant_body, and * similarly a Drop impl in Rust. @@ -45,7 +46,6 @@ enum Foo_u32_Tag { Slice4_u32, }; typedef uint8_t Foo_u32_Tag; - typedef struct { FillRule fill; OwnedSlice_u32 coords; @@ -56,6 +56,8 @@ typedef struct { OwnedSlice_i32 coords; } Slice4_Body_u32; + + typedef struct { Foo_u32_Tag tag; union { @@ -87,7 +89,6 @@ enum Baz_i32_Tag { Slice24_i32, }; typedef uint8_t Baz_i32_Tag; - typedef struct { Baz_i32_Tag tag; FillRule fill; @@ -100,6 +101,8 @@ typedef struct { OwnedSlice_i32 coords; } Slice24_Body_i32; + + typedef union { Baz_i32_Tag tag; struct { @@ -125,6 +128,7 @@ enum Taz_Tag { }; typedef uint8_t Taz_Tag; + typedef union { Taz_Tag tag; struct { @@ -143,6 +147,7 @@ enum Tazz_Tag { }; typedef uint8_t Tazz_Tag; + typedef union { Tazz_Tag tag; struct { @@ -157,6 +162,7 @@ enum Tazzz_Tag { }; typedef uint8_t Tazzz_Tag; + typedef union { Tazzz_Tag tag; struct { @@ -171,6 +177,7 @@ enum Tazzzz_Tag { }; typedef uint8_t Tazzzz_Tag; + typedef union { Tazzzz_Tag tag; struct { @@ -189,6 +196,7 @@ enum Qux_Tag { }; typedef uint8_t Qux_Tag; + typedef union { Qux_Tag tag; struct { diff --git a/tests/expectations/destructor_and_copy_ctor.compat.c b/tests/expectations/destructor_and_copy_ctor.compat.c index f12119b0..0c930c69 100644 --- a/tests/expectations/destructor_and_copy_ctor.compat.c +++ b/tests/expectations/destructor_and_copy_ctor.compat.c @@ -19,6 +19,7 @@ enum FillRule typedef uint8_t FillRule; #endif // __cplusplus + /** * This will have a destructor manually implemented via variant_body, and * similarly a Drop impl in Rust. @@ -57,7 +58,6 @@ enum Foo_u32_Tag #ifndef __cplusplus typedef uint8_t Foo_u32_Tag; #endif // __cplusplus - typedef struct { FillRule fill; OwnedSlice_u32 coords; @@ -68,6 +68,8 @@ typedef struct { OwnedSlice_i32 coords; } Slice4_Body_u32; + + typedef struct { Foo_u32_Tag tag; union { @@ -105,7 +107,6 @@ enum Baz_i32_Tag #ifndef __cplusplus typedef uint8_t Baz_i32_Tag; #endif // __cplusplus - typedef struct { Baz_i32_Tag tag; FillRule fill; @@ -118,6 +119,8 @@ typedef struct { OwnedSlice_i32 coords; } Slice24_Body_i32; + + typedef union { Baz_i32_Tag tag; struct { @@ -149,6 +152,7 @@ enum Taz_Tag typedef uint8_t Taz_Tag; #endif // __cplusplus + typedef union { Taz_Tag tag; struct { @@ -173,6 +177,7 @@ enum Tazz_Tag typedef uint8_t Tazz_Tag; #endif // __cplusplus + typedef union { Tazz_Tag tag; struct { @@ -193,6 +198,7 @@ enum Tazzz_Tag typedef uint8_t Tazzz_Tag; #endif // __cplusplus + typedef union { Tazzz_Tag tag; struct { @@ -213,6 +219,7 @@ enum Tazzzz_Tag typedef uint8_t Tazzzz_Tag; #endif // __cplusplus + typedef union { Tazzzz_Tag tag; struct { @@ -237,6 +244,7 @@ enum Qux_Tag typedef uint8_t Qux_Tag; #endif // __cplusplus + typedef union { Qux_Tag tag; struct { diff --git a/tests/expectations/destructor_and_copy_ctor.cpp b/tests/expectations/destructor_and_copy_ctor.cpp index 005b0863..164d8a64 100644 --- a/tests/expectations/destructor_and_copy_ctor.cpp +++ b/tests/expectations/destructor_and_copy_ctor.cpp @@ -13,6 +13,7 @@ enum class FillRule : uint8_t { B, }; + /// This will have a destructor manually implemented via variant_body, and /// similarly a Drop impl in Rust. template @@ -38,7 +39,6 @@ struct Foo { Slice3, Slice4, }; - struct Polygon1_Body { Polygon _0; }; @@ -61,6 +61,8 @@ struct Foo { OwnedSlice coords; }; + + Tag tag; union { Polygon1_Body polygon1; @@ -187,7 +189,6 @@ union Baz { Slice23, Slice24, }; - struct Polygon21_Body { Tag tag; Polygon _0; @@ -215,6 +216,8 @@ union Baz { OwnedSlice coords; }; + + struct { Tag tag; }; @@ -337,7 +340,6 @@ union Taz { Taz1, Taz3, }; - struct Taz1_Body { Tag tag; int32_t _0; @@ -348,6 +350,8 @@ union Taz { OwnedSlice _0; }; + + struct { Tag tag; }; @@ -423,12 +427,13 @@ union Tazz { Bar4, Taz2, }; - struct Taz2_Body { Tag tag; int32_t _0; }; + + struct { Tag tag; }; @@ -468,12 +473,13 @@ union Tazzz { Bar5, Taz5, }; - struct Taz5_Body { Tag tag; int32_t _0; }; + + struct { Tag tag; }; @@ -528,7 +534,6 @@ union Tazzzz { Taz6, Taz7, }; - struct Taz6_Body { Tag tag; int32_t _0; @@ -539,6 +544,8 @@ union Tazzzz { uint32_t _0; }; + + struct { Tag tag; }; @@ -604,7 +611,6 @@ union Qux { Qux1, Qux2, }; - struct Qux1_Body { Tag tag; int32_t _0; @@ -623,6 +629,8 @@ union Qux { } }; + + struct { Tag tag; }; diff --git a/tests/expectations/destructor_and_copy_ctor.pyx b/tests/expectations/destructor_and_copy_ctor.pyx index 745e04d4..9f0a5130 100644 --- a/tests/expectations/destructor_and_copy_ctor.pyx +++ b/tests/expectations/destructor_and_copy_ctor.pyx @@ -15,6 +15,7 @@ cdef extern from *: B, ctypedef uint8_t FillRule; + # This will have a destructor manually implemented via variant_body, and # similarly a Drop impl in Rust. ctypedef struct OwnedSlice_u32: @@ -39,7 +40,6 @@ cdef extern from *: Slice3_u32, Slice4_u32, ctypedef uint8_t Foo_u32_Tag; - ctypedef struct Slice3_Body_u32: FillRule fill; OwnedSlice_u32 coords; @@ -48,6 +48,8 @@ cdef extern from *: FillRule fill; OwnedSlice_i32 coords; + + ctypedef struct Foo_u32: Foo_u32_Tag tag; Polygon_u32 polygon1; @@ -68,7 +70,6 @@ cdef extern from *: Slice23_i32, Slice24_i32, ctypedef uint8_t Baz_i32_Tag; - ctypedef struct Slice23_Body_i32: Baz_i32_Tag tag; FillRule fill; @@ -79,6 +80,8 @@ cdef extern from *: FillRule fill; OwnedSlice_i32 coords; + + ctypedef union Baz_i32: Baz_i32_Tag tag; Polygon_i32 polygon21; @@ -93,6 +96,7 @@ cdef extern from *: Taz3, ctypedef uint8_t Taz_Tag; + ctypedef union Taz: Taz_Tag tag; int32_t taz1; @@ -103,6 +107,7 @@ cdef extern from *: Taz2, ctypedef uint8_t Tazz_Tag; + ctypedef union Tazz: Tazz_Tag tag; int32_t taz2; @@ -112,6 +117,7 @@ cdef extern from *: Taz5, ctypedef uint8_t Tazzz_Tag; + ctypedef union Tazzz: Tazzz_Tag tag; int32_t taz5; @@ -121,6 +127,7 @@ cdef extern from *: Taz7, ctypedef uint8_t Tazzzz_Tag; + ctypedef union Tazzzz: Tazzzz_Tag tag; int32_t taz6; @@ -131,6 +138,7 @@ cdef extern from *: Qux2, ctypedef uint8_t Qux_Tag; + ctypedef union Qux: Qux_Tag tag; int32_t qux1; diff --git a/tests/expectations/destructor_and_copy_ctor_both.c b/tests/expectations/destructor_and_copy_ctor_both.c index 12910395..1963907f 100644 --- a/tests/expectations/destructor_and_copy_ctor_both.c +++ b/tests/expectations/destructor_and_copy_ctor_both.c @@ -13,6 +13,7 @@ enum FillRule { }; typedef uint8_t FillRule; + /** * This will have a destructor manually implemented via variant_body, and * similarly a Drop impl in Rust. @@ -45,7 +46,6 @@ enum Foo_u32_Tag { Slice4_u32, }; typedef uint8_t Foo_u32_Tag; - typedef struct Slice3_Body_u32 { FillRule fill; struct OwnedSlice_u32 coords; @@ -56,6 +56,8 @@ typedef struct Slice4_Body_u32 { struct OwnedSlice_i32 coords; } Slice4_Body_u32; + + typedef struct Foo_u32 { Foo_u32_Tag tag; union { @@ -87,7 +89,6 @@ enum Baz_i32_Tag { Slice24_i32, }; typedef uint8_t Baz_i32_Tag; - typedef struct Slice23_Body_i32 { Baz_i32_Tag tag; FillRule fill; @@ -100,6 +101,8 @@ typedef struct Slice24_Body_i32 { struct OwnedSlice_i32 coords; } Slice24_Body_i32; + + typedef union Baz_i32 { Baz_i32_Tag tag; struct { @@ -125,6 +128,7 @@ enum Taz_Tag { }; typedef uint8_t Taz_Tag; + typedef union Taz { Taz_Tag tag; struct { @@ -143,6 +147,7 @@ enum Tazz_Tag { }; typedef uint8_t Tazz_Tag; + typedef union Tazz { Tazz_Tag tag; struct { @@ -157,6 +162,7 @@ enum Tazzz_Tag { }; typedef uint8_t Tazzz_Tag; + typedef union Tazzz { Tazzz_Tag tag; struct { @@ -171,6 +177,7 @@ enum Tazzzz_Tag { }; typedef uint8_t Tazzzz_Tag; + typedef union Tazzzz { Tazzzz_Tag tag; struct { @@ -189,6 +196,7 @@ enum Qux_Tag { }; typedef uint8_t Qux_Tag; + typedef union Qux { Qux_Tag tag; struct { diff --git a/tests/expectations/destructor_and_copy_ctor_both.compat.c b/tests/expectations/destructor_and_copy_ctor_both.compat.c index d151c7d8..1302b04a 100644 --- a/tests/expectations/destructor_and_copy_ctor_both.compat.c +++ b/tests/expectations/destructor_and_copy_ctor_both.compat.c @@ -19,6 +19,7 @@ enum FillRule typedef uint8_t FillRule; #endif // __cplusplus + /** * This will have a destructor manually implemented via variant_body, and * similarly a Drop impl in Rust. @@ -57,7 +58,6 @@ enum Foo_u32_Tag #ifndef __cplusplus typedef uint8_t Foo_u32_Tag; #endif // __cplusplus - typedef struct Slice3_Body_u32 { FillRule fill; struct OwnedSlice_u32 coords; @@ -68,6 +68,8 @@ typedef struct Slice4_Body_u32 { struct OwnedSlice_i32 coords; } Slice4_Body_u32; + + typedef struct Foo_u32 { Foo_u32_Tag tag; union { @@ -105,7 +107,6 @@ enum Baz_i32_Tag #ifndef __cplusplus typedef uint8_t Baz_i32_Tag; #endif // __cplusplus - typedef struct Slice23_Body_i32 { Baz_i32_Tag tag; FillRule fill; @@ -118,6 +119,8 @@ typedef struct Slice24_Body_i32 { struct OwnedSlice_i32 coords; } Slice24_Body_i32; + + typedef union Baz_i32 { Baz_i32_Tag tag; struct { @@ -149,6 +152,7 @@ enum Taz_Tag typedef uint8_t Taz_Tag; #endif // __cplusplus + typedef union Taz { Taz_Tag tag; struct { @@ -173,6 +177,7 @@ enum Tazz_Tag typedef uint8_t Tazz_Tag; #endif // __cplusplus + typedef union Tazz { Tazz_Tag tag; struct { @@ -193,6 +198,7 @@ enum Tazzz_Tag typedef uint8_t Tazzz_Tag; #endif // __cplusplus + typedef union Tazzz { Tazzz_Tag tag; struct { @@ -213,6 +219,7 @@ enum Tazzzz_Tag typedef uint8_t Tazzzz_Tag; #endif // __cplusplus + typedef union Tazzzz { Tazzzz_Tag tag; struct { @@ -237,6 +244,7 @@ enum Qux_Tag typedef uint8_t Qux_Tag; #endif // __cplusplus + typedef union Qux { Qux_Tag tag; struct { diff --git a/tests/expectations/destructor_and_copy_ctor_tag.c b/tests/expectations/destructor_and_copy_ctor_tag.c index 537ec6f7..3828cd71 100644 --- a/tests/expectations/destructor_and_copy_ctor_tag.c +++ b/tests/expectations/destructor_and_copy_ctor_tag.c @@ -13,6 +13,7 @@ enum FillRule { }; typedef uint8_t FillRule; + /** * This will have a destructor manually implemented via variant_body, and * similarly a Drop impl in Rust. @@ -45,7 +46,6 @@ enum Foo_u32_Tag { Slice4_u32, }; typedef uint8_t Foo_u32_Tag; - struct Slice3_Body_u32 { FillRule fill; struct OwnedSlice_u32 coords; @@ -56,6 +56,8 @@ struct Slice4_Body_u32 { struct OwnedSlice_i32 coords; }; + + struct Foo_u32 { Foo_u32_Tag tag; union { @@ -87,7 +89,6 @@ enum Baz_i32_Tag { Slice24_i32, }; typedef uint8_t Baz_i32_Tag; - struct Slice23_Body_i32 { Baz_i32_Tag tag; FillRule fill; @@ -100,6 +101,8 @@ struct Slice24_Body_i32 { struct OwnedSlice_i32 coords; }; + + union Baz_i32 { Baz_i32_Tag tag; struct { @@ -125,6 +128,7 @@ enum Taz_Tag { }; typedef uint8_t Taz_Tag; + union Taz { Taz_Tag tag; struct { @@ -143,6 +147,7 @@ enum Tazz_Tag { }; typedef uint8_t Tazz_Tag; + union Tazz { Tazz_Tag tag; struct { @@ -157,6 +162,7 @@ enum Tazzz_Tag { }; typedef uint8_t Tazzz_Tag; + union Tazzz { Tazzz_Tag tag; struct { @@ -171,6 +177,7 @@ enum Tazzzz_Tag { }; typedef uint8_t Tazzzz_Tag; + union Tazzzz { Tazzzz_Tag tag; struct { @@ -189,6 +196,7 @@ enum Qux_Tag { }; typedef uint8_t Qux_Tag; + union Qux { Qux_Tag tag; struct { diff --git a/tests/expectations/destructor_and_copy_ctor_tag.compat.c b/tests/expectations/destructor_and_copy_ctor_tag.compat.c index e6233263..f19a50b4 100644 --- a/tests/expectations/destructor_and_copy_ctor_tag.compat.c +++ b/tests/expectations/destructor_and_copy_ctor_tag.compat.c @@ -19,6 +19,7 @@ enum FillRule typedef uint8_t FillRule; #endif // __cplusplus + /** * This will have a destructor manually implemented via variant_body, and * similarly a Drop impl in Rust. @@ -57,7 +58,6 @@ enum Foo_u32_Tag #ifndef __cplusplus typedef uint8_t Foo_u32_Tag; #endif // __cplusplus - struct Slice3_Body_u32 { FillRule fill; struct OwnedSlice_u32 coords; @@ -68,6 +68,8 @@ struct Slice4_Body_u32 { struct OwnedSlice_i32 coords; }; + + struct Foo_u32 { Foo_u32_Tag tag; union { @@ -105,7 +107,6 @@ enum Baz_i32_Tag #ifndef __cplusplus typedef uint8_t Baz_i32_Tag; #endif // __cplusplus - struct Slice23_Body_i32 { Baz_i32_Tag tag; FillRule fill; @@ -118,6 +119,8 @@ struct Slice24_Body_i32 { struct OwnedSlice_i32 coords; }; + + union Baz_i32 { Baz_i32_Tag tag; struct { @@ -149,6 +152,7 @@ enum Taz_Tag typedef uint8_t Taz_Tag; #endif // __cplusplus + union Taz { Taz_Tag tag; struct { @@ -173,6 +177,7 @@ enum Tazz_Tag typedef uint8_t Tazz_Tag; #endif // __cplusplus + union Tazz { Tazz_Tag tag; struct { @@ -193,6 +198,7 @@ enum Tazzz_Tag typedef uint8_t Tazzz_Tag; #endif // __cplusplus + union Tazzz { Tazzz_Tag tag; struct { @@ -213,6 +219,7 @@ enum Tazzzz_Tag typedef uint8_t Tazzzz_Tag; #endif // __cplusplus + union Tazzzz { Tazzzz_Tag tag; struct { @@ -237,6 +244,7 @@ enum Qux_Tag typedef uint8_t Qux_Tag; #endif // __cplusplus + union Qux { Qux_Tag tag; struct { diff --git a/tests/expectations/destructor_and_copy_ctor_tag.pyx b/tests/expectations/destructor_and_copy_ctor_tag.pyx index 49619ebf..b507fb86 100644 --- a/tests/expectations/destructor_and_copy_ctor_tag.pyx +++ b/tests/expectations/destructor_and_copy_ctor_tag.pyx @@ -15,6 +15,7 @@ cdef extern from *: B, ctypedef uint8_t FillRule; + # This will have a destructor manually implemented via variant_body, and # similarly a Drop impl in Rust. cdef struct OwnedSlice_u32: @@ -39,7 +40,6 @@ cdef extern from *: Slice3_u32, Slice4_u32, ctypedef uint8_t Foo_u32_Tag; - cdef struct Slice3_Body_u32: FillRule fill; OwnedSlice_u32 coords; @@ -48,6 +48,8 @@ cdef extern from *: FillRule fill; OwnedSlice_i32 coords; + + cdef struct Foo_u32: Foo_u32_Tag tag; Polygon_u32 polygon1; @@ -68,7 +70,6 @@ cdef extern from *: Slice23_i32, Slice24_i32, ctypedef uint8_t Baz_i32_Tag; - cdef struct Slice23_Body_i32: Baz_i32_Tag tag; FillRule fill; @@ -79,6 +80,8 @@ cdef extern from *: FillRule fill; OwnedSlice_i32 coords; + + cdef union Baz_i32: Baz_i32_Tag tag; Polygon_i32 polygon21; @@ -93,6 +96,7 @@ cdef extern from *: Taz3, ctypedef uint8_t Taz_Tag; + cdef union Taz: Taz_Tag tag; int32_t taz1; @@ -103,6 +107,7 @@ cdef extern from *: Taz2, ctypedef uint8_t Tazz_Tag; + cdef union Tazz: Tazz_Tag tag; int32_t taz2; @@ -112,6 +117,7 @@ cdef extern from *: Taz5, ctypedef uint8_t Tazzz_Tag; + cdef union Tazzz: Tazzz_Tag tag; int32_t taz5; @@ -121,6 +127,7 @@ cdef extern from *: Taz7, ctypedef uint8_t Tazzzz_Tag; + cdef union Tazzzz: Tazzzz_Tag tag; int32_t taz6; @@ -131,6 +138,7 @@ cdef extern from *: Qux2, ctypedef uint8_t Qux_Tag; + cdef union Qux: Qux_Tag tag; int32_t qux1; diff --git a/tests/expectations/display_list.c b/tests/expectations/display_list.c index 41a37d6a..8ff87c48 100644 --- a/tests/expectations/display_list.c +++ b/tests/expectations/display_list.c @@ -23,7 +23,6 @@ enum DisplayItem_Tag { ClearScreen, }; typedef uint8_t DisplayItem_Tag; - typedef struct { DisplayItem_Tag tag; Rect _0; @@ -36,6 +35,8 @@ typedef struct { Rect bounds; } Image_Body; + + typedef union { DisplayItem_Tag tag; Fill_Body fill; diff --git a/tests/expectations/display_list.compat.c b/tests/expectations/display_list.compat.c index 79c7470d..653d9d74 100644 --- a/tests/expectations/display_list.compat.c +++ b/tests/expectations/display_list.compat.c @@ -29,7 +29,6 @@ enum DisplayItem_Tag #ifndef __cplusplus typedef uint8_t DisplayItem_Tag; #endif // __cplusplus - typedef struct { DisplayItem_Tag tag; Rect _0; @@ -42,6 +41,8 @@ typedef struct { Rect bounds; } Image_Body; + + typedef union { DisplayItem_Tag tag; Fill_Body fill; diff --git a/tests/expectations/display_list.cpp b/tests/expectations/display_list.cpp index 09957fc6..6c44b4a0 100644 --- a/tests/expectations/display_list.cpp +++ b/tests/expectations/display_list.cpp @@ -24,7 +24,6 @@ union DisplayItem { Image, ClearScreen, }; - struct Fill_Body { Tag tag; Rect _0; @@ -37,6 +36,8 @@ union DisplayItem { Rect bounds; }; + + struct { Tag tag; }; diff --git a/tests/expectations/display_list.pyx b/tests/expectations/display_list.pyx index 45d6b056..df125325 100644 --- a/tests/expectations/display_list.pyx +++ b/tests/expectations/display_list.pyx @@ -23,7 +23,6 @@ cdef extern from *: Image, ClearScreen, ctypedef uint8_t DisplayItem_Tag; - ctypedef struct Fill_Body: DisplayItem_Tag tag; Rect _0; @@ -34,6 +33,8 @@ cdef extern from *: uint32_t id; Rect bounds; + + ctypedef union DisplayItem: DisplayItem_Tag tag; Fill_Body fill; diff --git a/tests/expectations/display_list_both.c b/tests/expectations/display_list_both.c index 451eab73..2c7ed4de 100644 --- a/tests/expectations/display_list_both.c +++ b/tests/expectations/display_list_both.c @@ -23,7 +23,6 @@ enum DisplayItem_Tag { ClearScreen, }; typedef uint8_t DisplayItem_Tag; - typedef struct Fill_Body { DisplayItem_Tag tag; struct Rect _0; @@ -36,6 +35,8 @@ typedef struct Image_Body { struct Rect bounds; } Image_Body; + + typedef union DisplayItem { DisplayItem_Tag tag; Fill_Body fill; diff --git a/tests/expectations/display_list_both.compat.c b/tests/expectations/display_list_both.compat.c index 8dfd5223..d0712e5c 100644 --- a/tests/expectations/display_list_both.compat.c +++ b/tests/expectations/display_list_both.compat.c @@ -29,7 +29,6 @@ enum DisplayItem_Tag #ifndef __cplusplus typedef uint8_t DisplayItem_Tag; #endif // __cplusplus - typedef struct Fill_Body { DisplayItem_Tag tag; struct Rect _0; @@ -42,6 +41,8 @@ typedef struct Image_Body { struct Rect bounds; } Image_Body; + + typedef union DisplayItem { DisplayItem_Tag tag; Fill_Body fill; diff --git a/tests/expectations/display_list_tag.c b/tests/expectations/display_list_tag.c index 78f53de3..a93e1cc4 100644 --- a/tests/expectations/display_list_tag.c +++ b/tests/expectations/display_list_tag.c @@ -23,7 +23,6 @@ enum DisplayItem_Tag { ClearScreen, }; typedef uint8_t DisplayItem_Tag; - struct Fill_Body { DisplayItem_Tag tag; struct Rect _0; @@ -36,6 +35,8 @@ struct Image_Body { struct Rect bounds; }; + + union DisplayItem { DisplayItem_Tag tag; struct Fill_Body fill; diff --git a/tests/expectations/display_list_tag.compat.c b/tests/expectations/display_list_tag.compat.c index ec7c2cd0..4c08dd1c 100644 --- a/tests/expectations/display_list_tag.compat.c +++ b/tests/expectations/display_list_tag.compat.c @@ -29,7 +29,6 @@ enum DisplayItem_Tag #ifndef __cplusplus typedef uint8_t DisplayItem_Tag; #endif // __cplusplus - struct Fill_Body { DisplayItem_Tag tag; struct Rect _0; @@ -42,6 +41,8 @@ struct Image_Body { struct Rect bounds; }; + + union DisplayItem { DisplayItem_Tag tag; struct Fill_Body fill; diff --git a/tests/expectations/display_list_tag.pyx b/tests/expectations/display_list_tag.pyx index 6bf900e4..db330bd8 100644 --- a/tests/expectations/display_list_tag.pyx +++ b/tests/expectations/display_list_tag.pyx @@ -23,7 +23,6 @@ cdef extern from *: Image, ClearScreen, ctypedef uint8_t DisplayItem_Tag; - cdef struct Fill_Body: DisplayItem_Tag tag; Rect _0; @@ -34,6 +33,8 @@ cdef extern from *: uint32_t id; Rect bounds; + + cdef union DisplayItem: DisplayItem_Tag tag; Fill_Body fill; diff --git a/tests/expectations/enum.c b/tests/expectations/enum.c index 0562a56a..524517cf 100644 --- a/tests/expectations/enum.c +++ b/tests/expectations/enum.c @@ -25,6 +25,7 @@ enum A { }; typedef uint64_t A; + enum B { b1 = 0, b2 = 2, @@ -33,6 +34,7 @@ enum B { }; typedef uint32_t B; + enum C { c1 = 0, c2 = 2, @@ -41,6 +43,7 @@ enum C { }; typedef uint16_t C; + enum D { d1 = 0, d2 = 2, @@ -49,6 +52,7 @@ enum D { }; typedef uint8_t D; + enum E { e1 = 0, e2 = 2, @@ -57,6 +61,7 @@ enum E { }; typedef uintptr_t E; + enum F { f1 = 0, f2 = 2, @@ -65,6 +70,7 @@ enum F { }; typedef intptr_t F; + typedef enum { l1, l2, @@ -79,6 +85,7 @@ enum M { }; typedef int8_t M; + typedef enum { n1, n2, @@ -94,6 +101,7 @@ enum O { }; typedef int8_t O; + typedef struct J J; typedef struct K K; @@ -106,13 +114,14 @@ enum G_Tag { Baz, }; typedef uint8_t G_Tag; - typedef struct { G_Tag tag; uint8_t x; int16_t y; } Bar_Body; + + typedef union { G_Tag tag; struct { @@ -126,13 +135,13 @@ typedef enum { H_Foo, H_Bar, H_Baz, -} H_Tag; - -typedef struct { +} H_Tag;typedef struct { uint8_t x; int16_t y; } H_Bar_Body; + + typedef struct { H_Tag tag; union { @@ -149,12 +158,13 @@ enum ExI_Tag { ExI_Baz, }; typedef uint8_t ExI_Tag; - typedef struct { uint8_t x; int16_t y; } ExI_Bar_Body; + + typedef struct { ExI_Tag tag; union { @@ -170,13 +180,14 @@ enum P_Tag { P1, }; typedef uint8_t P_Tag; - typedef struct { uint8_t _0; uint8_t _1; uint8_t _2; } P1_Body; + + typedef struct { P_Tag tag; union { @@ -208,13 +219,13 @@ typedef enum { IRFoo, IRBar, IRBaz, -} R_Tag; - -typedef struct { +} R_Tag;typedef struct { uint8_t x; int16_t y; } IRBar_Body; + + typedef struct { R_Tag tag; union { diff --git a/tests/expectations/enum.compat.c b/tests/expectations/enum.compat.c index 86cedb9f..e247ea7e 100644 --- a/tests/expectations/enum.compat.c +++ b/tests/expectations/enum.compat.c @@ -31,6 +31,7 @@ enum A typedef uint64_t A; #endif // __cplusplus + enum B #ifdef __cplusplus : uint32_t @@ -45,6 +46,7 @@ enum B typedef uint32_t B; #endif // __cplusplus + enum C #ifdef __cplusplus : uint16_t @@ -59,6 +61,7 @@ enum C typedef uint16_t C; #endif // __cplusplus + enum D #ifdef __cplusplus : uint8_t @@ -73,6 +76,7 @@ enum D typedef uint8_t D; #endif // __cplusplus + enum E #ifdef __cplusplus : uintptr_t @@ -87,6 +91,7 @@ enum E typedef uintptr_t E; #endif // __cplusplus + enum F #ifdef __cplusplus : intptr_t @@ -101,6 +106,7 @@ enum F typedef intptr_t F; #endif // __cplusplus + typedef enum { l1, l2, @@ -121,6 +127,7 @@ enum M typedef int8_t M; #endif // __cplusplus + typedef enum { n1, n2, @@ -142,6 +149,7 @@ enum O typedef int8_t O; #endif // __cplusplus + typedef struct J J; typedef struct K K; @@ -160,13 +168,14 @@ enum G_Tag #ifndef __cplusplus typedef uint8_t G_Tag; #endif // __cplusplus - typedef struct { G_Tag tag; uint8_t x; int16_t y; } Bar_Body; + + typedef union { G_Tag tag; struct { @@ -180,13 +189,13 @@ typedef enum { H_Foo, H_Bar, H_Baz, -} H_Tag; - -typedef struct { +} H_Tag;typedef struct { uint8_t x; int16_t y; } H_Bar_Body; + + typedef struct { H_Tag tag; union { @@ -209,12 +218,13 @@ enum ExI_Tag #ifndef __cplusplus typedef uint8_t ExI_Tag; #endif // __cplusplus - typedef struct { uint8_t x; int16_t y; } ExI_Bar_Body; + + typedef struct { ExI_Tag tag; union { @@ -236,13 +246,14 @@ enum P_Tag #ifndef __cplusplus typedef uint8_t P_Tag; #endif // __cplusplus - typedef struct { uint8_t _0; uint8_t _1; uint8_t _2; } P1_Body; + + typedef struct { P_Tag tag; union { @@ -274,13 +285,13 @@ typedef enum { IRFoo, IRBar, IRBaz, -} R_Tag; - -typedef struct { +} R_Tag;typedef struct { uint8_t x; int16_t y; } IRBar_Body; + + typedef struct { R_Tag tag; union { diff --git a/tests/expectations/enum.cpp b/tests/expectations/enum.cpp index 66d9209b..6a63ffec 100644 --- a/tests/expectations/enum.cpp +++ b/tests/expectations/enum.cpp @@ -25,6 +25,7 @@ enum class A : uint64_t { a4 = 5, }; + enum class B : uint32_t { b1 = 0, b2 = 2, @@ -32,6 +33,7 @@ enum class B : uint32_t { b4 = 5, }; + enum class C : uint16_t { c1 = 0, c2 = 2, @@ -39,6 +41,7 @@ enum class C : uint16_t { c4 = 5, }; + enum class D : uint8_t { d1 = 0, d2 = 2, @@ -46,6 +49,7 @@ enum class D : uint8_t { d4 = 5, }; + enum class E : uintptr_t { e1 = 0, e2 = 2, @@ -53,6 +57,7 @@ enum class E : uintptr_t { e4 = 5, }; + enum class F : intptr_t { f1 = 0, f2 = 2, @@ -60,6 +65,7 @@ enum class F : intptr_t { f4 = 5, }; + enum class L { l1, l2, @@ -73,6 +79,7 @@ enum class M : int8_t { m3 = 1, }; + enum N { n1, n2, @@ -87,6 +94,7 @@ enum O : int8_t { o4, }; + struct J; struct K; @@ -99,7 +107,6 @@ union G { Bar, Baz, }; - struct Foo_Body { Tag tag; int16_t _0; @@ -111,6 +118,8 @@ union G { int16_t y; }; + + struct { Tag tag; }; @@ -123,9 +132,7 @@ struct H { H_Foo, H_Bar, H_Baz, - }; - - struct H_Foo_Body { + };struct H_Foo_Body { int16_t _0; }; @@ -134,6 +141,8 @@ struct H { int16_t y; }; + + Tag tag; union { H_Foo_Body foo; @@ -147,7 +156,6 @@ struct ExI { ExI_Bar, ExI_Baz, }; - struct ExI_Foo_Body { int16_t _0; }; @@ -157,6 +165,8 @@ struct ExI { int16_t y; }; + + Tag tag; union { ExI_Foo_Body foo; @@ -169,7 +179,6 @@ struct P { P0, P1, }; - struct P0_Body { uint8_t _0; }; @@ -180,6 +189,8 @@ struct P { uint8_t _2; }; + + Tag tag; union { P0_Body p0; @@ -191,9 +202,7 @@ struct Q { enum class Tag { Ok, Err, - }; - - struct Ok_Body { + };struct Ok_Body { Box _0; }; @@ -201,6 +210,8 @@ struct Q { uint32_t _0; }; + + Tag tag; union { Ok_Body ok; @@ -213,9 +224,7 @@ struct R { IRFoo, IRBar, IRBaz, - }; - - struct IRFoo_Body { + };struct IRFoo_Body { int16_t _0; }; @@ -224,6 +233,8 @@ struct R { int16_t y; }; + + Tag tag; union { IRFoo_Body IRFoo; diff --git a/tests/expectations/enum.pyx b/tests/expectations/enum.pyx index 03570f2c..541c8150 100644 --- a/tests/expectations/enum.pyx +++ b/tests/expectations/enum.pyx @@ -27,6 +27,7 @@ cdef extern from *: a4 # = 5, ctypedef uint64_t A; + cdef enum: b1 # = 0, b2 # = 2, @@ -34,6 +35,7 @@ cdef extern from *: b4 # = 5, ctypedef uint32_t B; + cdef enum: c1 # = 0, c2 # = 2, @@ -41,6 +43,7 @@ cdef extern from *: c4 # = 5, ctypedef uint16_t C; + cdef enum: d1 # = 0, d2 # = 2, @@ -48,6 +51,7 @@ cdef extern from *: d4 # = 5, ctypedef uint8_t D; + cdef enum: e1 # = 0, e2 # = 2, @@ -55,6 +59,7 @@ cdef extern from *: e4 # = 5, ctypedef uintptr_t E; + cdef enum: f1 # = 0, f2 # = 2, @@ -62,24 +67,28 @@ cdef extern from *: f4 # = 5, ctypedef intptr_t F; + ctypedef enum L: l1, l2, l3, l4, + cdef enum: m1 # = -1, m2 # = 0, m3 # = 1, ctypedef int8_t M; + ctypedef enum N: n1, n2, n3, n4, + cdef enum: o1, o2, @@ -87,6 +96,7 @@ cdef extern from *: o4, ctypedef int8_t O; + ctypedef struct J: pass @@ -101,12 +111,13 @@ cdef extern from *: Bar, Baz, ctypedef uint8_t G_Tag; - ctypedef struct Bar_Body: G_Tag tag; uint8_t x; int16_t y; + + ctypedef union G: G_Tag tag; int16_t foo; @@ -116,11 +127,12 @@ cdef extern from *: H_Foo, H_Bar, H_Baz, - ctypedef struct H_Bar_Body: uint8_t x; int16_t y; + + ctypedef struct H: H_Tag tag; int16_t foo; @@ -131,11 +143,12 @@ cdef extern from *: ExI_Bar, ExI_Baz, ctypedef uint8_t ExI_Tag; - ctypedef struct ExI_Bar_Body: uint8_t x; int16_t y; + + ctypedef struct ExI: ExI_Tag tag; int16_t foo; @@ -145,12 +158,13 @@ cdef extern from *: P0, P1, ctypedef uint8_t P_Tag; - ctypedef struct P1_Body: uint8_t _0; uint8_t _1; uint8_t _2; + + ctypedef struct P: P_Tag tag; uint8_t p0; @@ -160,6 +174,7 @@ cdef extern from *: Ok, Err, + ctypedef struct Q: Q_Tag tag; uint32_t *ok; @@ -169,11 +184,12 @@ cdef extern from *: IRFoo, IRBar, IRBaz, - ctypedef struct IRBar_Body: uint8_t x; int16_t y; + + ctypedef struct R: R_Tag tag; int16_t IRFoo; diff --git a/tests/expectations/enum_both.c b/tests/expectations/enum_both.c index a0f88c13..21f0ee40 100644 --- a/tests/expectations/enum_both.c +++ b/tests/expectations/enum_both.c @@ -25,6 +25,7 @@ enum A { }; typedef uint64_t A; + enum B { b1 = 0, b2 = 2, @@ -33,6 +34,7 @@ enum B { }; typedef uint32_t B; + enum C { c1 = 0, c2 = 2, @@ -41,6 +43,7 @@ enum C { }; typedef uint16_t C; + enum D { d1 = 0, d2 = 2, @@ -49,6 +52,7 @@ enum D { }; typedef uint8_t D; + enum E { e1 = 0, e2 = 2, @@ -57,6 +61,7 @@ enum E { }; typedef uintptr_t E; + enum F { f1 = 0, f2 = 2, @@ -65,6 +70,7 @@ enum F { }; typedef intptr_t F; + typedef enum L { l1, l2, @@ -79,6 +85,7 @@ enum M { }; typedef int8_t M; + typedef enum N { n1, n2, @@ -94,6 +101,7 @@ enum O { }; typedef int8_t O; + typedef struct J J; typedef struct K K; @@ -106,13 +114,14 @@ enum G_Tag { Baz, }; typedef uint8_t G_Tag; - typedef struct Bar_Body { G_Tag tag; uint8_t x; int16_t y; } Bar_Body; + + typedef union G { G_Tag tag; struct { @@ -126,13 +135,13 @@ typedef enum H_Tag { H_Foo, H_Bar, H_Baz, -} H_Tag; - -typedef struct H_Bar_Body { +} H_Tag;typedef struct H_Bar_Body { uint8_t x; int16_t y; } H_Bar_Body; + + typedef struct H { H_Tag tag; union { @@ -149,12 +158,13 @@ enum ExI_Tag { ExI_Baz, }; typedef uint8_t ExI_Tag; - typedef struct ExI_Bar_Body { uint8_t x; int16_t y; } ExI_Bar_Body; + + typedef struct ExI { ExI_Tag tag; union { @@ -170,13 +180,14 @@ enum P_Tag { P1, }; typedef uint8_t P_Tag; - typedef struct P1_Body { uint8_t _0; uint8_t _1; uint8_t _2; } P1_Body; + + typedef struct P { P_Tag tag; union { @@ -208,13 +219,13 @@ typedef enum R_Tag { IRFoo, IRBar, IRBaz, -} R_Tag; - -typedef struct IRBar_Body { +} R_Tag;typedef struct IRBar_Body { uint8_t x; int16_t y; } IRBar_Body; + + typedef struct R { R_Tag tag; union { diff --git a/tests/expectations/enum_both.compat.c b/tests/expectations/enum_both.compat.c index 35488252..1349b1bc 100644 --- a/tests/expectations/enum_both.compat.c +++ b/tests/expectations/enum_both.compat.c @@ -31,6 +31,7 @@ enum A typedef uint64_t A; #endif // __cplusplus + enum B #ifdef __cplusplus : uint32_t @@ -45,6 +46,7 @@ enum B typedef uint32_t B; #endif // __cplusplus + enum C #ifdef __cplusplus : uint16_t @@ -59,6 +61,7 @@ enum C typedef uint16_t C; #endif // __cplusplus + enum D #ifdef __cplusplus : uint8_t @@ -73,6 +76,7 @@ enum D typedef uint8_t D; #endif // __cplusplus + enum E #ifdef __cplusplus : uintptr_t @@ -87,6 +91,7 @@ enum E typedef uintptr_t E; #endif // __cplusplus + enum F #ifdef __cplusplus : intptr_t @@ -101,6 +106,7 @@ enum F typedef intptr_t F; #endif // __cplusplus + typedef enum L { l1, l2, @@ -121,6 +127,7 @@ enum M typedef int8_t M; #endif // __cplusplus + typedef enum N { n1, n2, @@ -142,6 +149,7 @@ enum O typedef int8_t O; #endif // __cplusplus + typedef struct J J; typedef struct K K; @@ -160,13 +168,14 @@ enum G_Tag #ifndef __cplusplus typedef uint8_t G_Tag; #endif // __cplusplus - typedef struct Bar_Body { G_Tag tag; uint8_t x; int16_t y; } Bar_Body; + + typedef union G { G_Tag tag; struct { @@ -180,13 +189,13 @@ typedef enum H_Tag { H_Foo, H_Bar, H_Baz, -} H_Tag; - -typedef struct H_Bar_Body { +} H_Tag;typedef struct H_Bar_Body { uint8_t x; int16_t y; } H_Bar_Body; + + typedef struct H { H_Tag tag; union { @@ -209,12 +218,13 @@ enum ExI_Tag #ifndef __cplusplus typedef uint8_t ExI_Tag; #endif // __cplusplus - typedef struct ExI_Bar_Body { uint8_t x; int16_t y; } ExI_Bar_Body; + + typedef struct ExI { ExI_Tag tag; union { @@ -236,13 +246,14 @@ enum P_Tag #ifndef __cplusplus typedef uint8_t P_Tag; #endif // __cplusplus - typedef struct P1_Body { uint8_t _0; uint8_t _1; uint8_t _2; } P1_Body; + + typedef struct P { P_Tag tag; union { @@ -274,13 +285,13 @@ typedef enum R_Tag { IRFoo, IRBar, IRBaz, -} R_Tag; - -typedef struct IRBar_Body { +} R_Tag;typedef struct IRBar_Body { uint8_t x; int16_t y; } IRBar_Body; + + typedef struct R { R_Tag tag; union { diff --git a/tests/expectations/enum_discriminant.c b/tests/expectations/enum_discriminant.c index 181dab15..e611b79d 100644 --- a/tests/expectations/enum_discriminant.c +++ b/tests/expectations/enum_discriminant.c @@ -16,4 +16,5 @@ enum E { }; typedef int8_t E; + void root(const E*); diff --git a/tests/expectations/enum_discriminant.compat.c b/tests/expectations/enum_discriminant.compat.c index 381ee4be..fa3ca5b9 100644 --- a/tests/expectations/enum_discriminant.compat.c +++ b/tests/expectations/enum_discriminant.compat.c @@ -22,6 +22,7 @@ enum E typedef int8_t E; #endif // __cplusplus + #ifdef __cplusplus extern "C" { #endif // __cplusplus diff --git a/tests/expectations/enum_discriminant.cpp b/tests/expectations/enum_discriminant.cpp index 68edbf68..52f2a173 100644 --- a/tests/expectations/enum_discriminant.cpp +++ b/tests/expectations/enum_discriminant.cpp @@ -16,6 +16,7 @@ enum class E : int8_t { H = (int8_t)false, }; + extern "C" { void root(const E*); diff --git a/tests/expectations/enum_discriminant.pyx b/tests/expectations/enum_discriminant.pyx index 6ab1f0e4..1f39410e 100644 --- a/tests/expectations/enum_discriminant.pyx +++ b/tests/expectations/enum_discriminant.pyx @@ -18,4 +18,5 @@ cdef extern from *: H # = False, ctypedef int8_t E; + void root(const E*); diff --git a/tests/expectations/enum_self.c b/tests/expectations/enum_self.c index e383e76a..d9fcfe97 100644 --- a/tests/expectations/enum_self.c +++ b/tests/expectations/enum_self.c @@ -14,6 +14,7 @@ enum Bar_Tag { }; typedef uint8_t Bar_Tag; + typedef union { Bar_Tag tag; struct { diff --git a/tests/expectations/enum_self.compat.c b/tests/expectations/enum_self.compat.c index 0b5472dc..35cd975f 100644 --- a/tests/expectations/enum_self.compat.c +++ b/tests/expectations/enum_self.compat.c @@ -20,6 +20,7 @@ enum Bar_Tag typedef uint8_t Bar_Tag; #endif // __cplusplus + typedef union { Bar_Tag tag; struct { diff --git a/tests/expectations/enum_self.cpp b/tests/expectations/enum_self.cpp index 37be086e..ea67ecaa 100644 --- a/tests/expectations/enum_self.cpp +++ b/tests/expectations/enum_self.cpp @@ -15,7 +15,6 @@ union Bar { Max, Other, }; - struct Min_Body { Tag tag; Foo _0; @@ -26,6 +25,8 @@ union Bar { Foo _0; }; + + struct { Tag tag; }; diff --git a/tests/expectations/enum_self.pyx b/tests/expectations/enum_self.pyx index 556afb9d..fae01dc8 100644 --- a/tests/expectations/enum_self.pyx +++ b/tests/expectations/enum_self.pyx @@ -15,6 +15,7 @@ cdef extern from *: Other, ctypedef uint8_t Bar_Tag; + ctypedef union Bar: Bar_Tag tag; Foo_Bar min; diff --git a/tests/expectations/enum_self_both.c b/tests/expectations/enum_self_both.c index cc661216..3ae678e7 100644 --- a/tests/expectations/enum_self_both.c +++ b/tests/expectations/enum_self_both.c @@ -14,6 +14,7 @@ enum Bar_Tag { }; typedef uint8_t Bar_Tag; + typedef union Bar { Bar_Tag tag; struct { diff --git a/tests/expectations/enum_self_both.compat.c b/tests/expectations/enum_self_both.compat.c index 34d08e27..f11675dd 100644 --- a/tests/expectations/enum_self_both.compat.c +++ b/tests/expectations/enum_self_both.compat.c @@ -20,6 +20,7 @@ enum Bar_Tag typedef uint8_t Bar_Tag; #endif // __cplusplus + typedef union Bar { Bar_Tag tag; struct { diff --git a/tests/expectations/enum_self_tag.c b/tests/expectations/enum_self_tag.c index e0935033..c24f8505 100644 --- a/tests/expectations/enum_self_tag.c +++ b/tests/expectations/enum_self_tag.c @@ -14,6 +14,7 @@ enum Bar_Tag { }; typedef uint8_t Bar_Tag; + union Bar { Bar_Tag tag; struct { diff --git a/tests/expectations/enum_self_tag.compat.c b/tests/expectations/enum_self_tag.compat.c index 77f5a381..c28fafd2 100644 --- a/tests/expectations/enum_self_tag.compat.c +++ b/tests/expectations/enum_self_tag.compat.c @@ -20,6 +20,7 @@ enum Bar_Tag typedef uint8_t Bar_Tag; #endif // __cplusplus + union Bar { Bar_Tag tag; struct { diff --git a/tests/expectations/enum_self_tag.pyx b/tests/expectations/enum_self_tag.pyx index 5034b868..5b42f5b4 100644 --- a/tests/expectations/enum_self_tag.pyx +++ b/tests/expectations/enum_self_tag.pyx @@ -15,6 +15,7 @@ cdef extern from *: Other, ctypedef uint8_t Bar_Tag; + cdef union Bar: Bar_Tag tag; Foo_Bar min; diff --git a/tests/expectations/enum_tag.c b/tests/expectations/enum_tag.c index a7f10468..c98a8929 100644 --- a/tests/expectations/enum_tag.c +++ b/tests/expectations/enum_tag.c @@ -25,6 +25,7 @@ enum A { }; typedef uint64_t A; + enum B { b1 = 0, b2 = 2, @@ -33,6 +34,7 @@ enum B { }; typedef uint32_t B; + enum C { c1 = 0, c2 = 2, @@ -41,6 +43,7 @@ enum C { }; typedef uint16_t C; + enum D { d1 = 0, d2 = 2, @@ -49,6 +52,7 @@ enum D { }; typedef uint8_t D; + enum E { e1 = 0, e2 = 2, @@ -57,6 +61,7 @@ enum E { }; typedef uintptr_t E; + enum F { f1 = 0, f2 = 2, @@ -65,6 +70,7 @@ enum F { }; typedef intptr_t F; + enum L { l1, l2, @@ -79,6 +85,7 @@ enum M { }; typedef int8_t M; + enum N { n1, n2, @@ -94,6 +101,7 @@ enum O { }; typedef int8_t O; + struct J; struct K; @@ -106,13 +114,14 @@ enum G_Tag { Baz, }; typedef uint8_t G_Tag; - struct Bar_Body { G_Tag tag; uint8_t x; int16_t y; }; + + union G { G_Tag tag; struct { @@ -126,13 +135,13 @@ enum H_Tag { H_Foo, H_Bar, H_Baz, -}; - -struct H_Bar_Body { +};struct H_Bar_Body { uint8_t x; int16_t y; }; + + struct H { enum H_Tag tag; union { @@ -149,12 +158,13 @@ enum ExI_Tag { ExI_Baz, }; typedef uint8_t ExI_Tag; - struct ExI_Bar_Body { uint8_t x; int16_t y; }; + + struct ExI { ExI_Tag tag; union { @@ -170,13 +180,14 @@ enum P_Tag { P1, }; typedef uint8_t P_Tag; - struct P1_Body { uint8_t _0; uint8_t _1; uint8_t _2; }; + + struct P { P_Tag tag; union { @@ -208,13 +219,13 @@ enum R_Tag { IRFoo, IRBar, IRBaz, -}; - -struct IRBar_Body { +};struct IRBar_Body { uint8_t x; int16_t y; }; + + struct R { enum R_Tag tag; union { diff --git a/tests/expectations/enum_tag.compat.c b/tests/expectations/enum_tag.compat.c index 9662a652..50ef9769 100644 --- a/tests/expectations/enum_tag.compat.c +++ b/tests/expectations/enum_tag.compat.c @@ -31,6 +31,7 @@ enum A typedef uint64_t A; #endif // __cplusplus + enum B #ifdef __cplusplus : uint32_t @@ -45,6 +46,7 @@ enum B typedef uint32_t B; #endif // __cplusplus + enum C #ifdef __cplusplus : uint16_t @@ -59,6 +61,7 @@ enum C typedef uint16_t C; #endif // __cplusplus + enum D #ifdef __cplusplus : uint8_t @@ -73,6 +76,7 @@ enum D typedef uint8_t D; #endif // __cplusplus + enum E #ifdef __cplusplus : uintptr_t @@ -87,6 +91,7 @@ enum E typedef uintptr_t E; #endif // __cplusplus + enum F #ifdef __cplusplus : intptr_t @@ -101,6 +106,7 @@ enum F typedef intptr_t F; #endif // __cplusplus + enum L { l1, l2, @@ -121,6 +127,7 @@ enum M typedef int8_t M; #endif // __cplusplus + enum N { n1, n2, @@ -142,6 +149,7 @@ enum O typedef int8_t O; #endif // __cplusplus + struct J; struct K; @@ -160,13 +168,14 @@ enum G_Tag #ifndef __cplusplus typedef uint8_t G_Tag; #endif // __cplusplus - struct Bar_Body { G_Tag tag; uint8_t x; int16_t y; }; + + union G { G_Tag tag; struct { @@ -180,13 +189,13 @@ enum H_Tag { H_Foo, H_Bar, H_Baz, -}; - -struct H_Bar_Body { +};struct H_Bar_Body { uint8_t x; int16_t y; }; + + struct H { enum H_Tag tag; union { @@ -209,12 +218,13 @@ enum ExI_Tag #ifndef __cplusplus typedef uint8_t ExI_Tag; #endif // __cplusplus - struct ExI_Bar_Body { uint8_t x; int16_t y; }; + + struct ExI { ExI_Tag tag; union { @@ -236,13 +246,14 @@ enum P_Tag #ifndef __cplusplus typedef uint8_t P_Tag; #endif // __cplusplus - struct P1_Body { uint8_t _0; uint8_t _1; uint8_t _2; }; + + struct P { P_Tag tag; union { @@ -274,13 +285,13 @@ enum R_Tag { IRFoo, IRBar, IRBaz, -}; - -struct IRBar_Body { +};struct IRBar_Body { uint8_t x; int16_t y; }; + + struct R { enum R_Tag tag; union { diff --git a/tests/expectations/enum_tag.pyx b/tests/expectations/enum_tag.pyx index a0c9ef08..cf3e2182 100644 --- a/tests/expectations/enum_tag.pyx +++ b/tests/expectations/enum_tag.pyx @@ -27,6 +27,7 @@ cdef extern from *: a4 # = 5, ctypedef uint64_t A; + cdef enum: b1 # = 0, b2 # = 2, @@ -34,6 +35,7 @@ cdef extern from *: b4 # = 5, ctypedef uint32_t B; + cdef enum: c1 # = 0, c2 # = 2, @@ -41,6 +43,7 @@ cdef extern from *: c4 # = 5, ctypedef uint16_t C; + cdef enum: d1 # = 0, d2 # = 2, @@ -48,6 +51,7 @@ cdef extern from *: d4 # = 5, ctypedef uint8_t D; + cdef enum: e1 # = 0, e2 # = 2, @@ -55,6 +59,7 @@ cdef extern from *: e4 # = 5, ctypedef uintptr_t E; + cdef enum: f1 # = 0, f2 # = 2, @@ -62,24 +67,28 @@ cdef extern from *: f4 # = 5, ctypedef intptr_t F; + cdef enum L: l1, l2, l3, l4, + cdef enum: m1 # = -1, m2 # = 0, m3 # = 1, ctypedef int8_t M; + cdef enum N: n1, n2, n3, n4, + cdef enum: o1, o2, @@ -87,6 +96,7 @@ cdef extern from *: o4, ctypedef int8_t O; + cdef struct J: pass @@ -101,12 +111,13 @@ cdef extern from *: Bar, Baz, ctypedef uint8_t G_Tag; - cdef struct Bar_Body: G_Tag tag; uint8_t x; int16_t y; + + cdef union G: G_Tag tag; int16_t foo; @@ -116,11 +127,12 @@ cdef extern from *: H_Foo, H_Bar, H_Baz, - cdef struct H_Bar_Body: uint8_t x; int16_t y; + + cdef struct H: H_Tag tag; int16_t foo; @@ -131,11 +143,12 @@ cdef extern from *: ExI_Bar, ExI_Baz, ctypedef uint8_t ExI_Tag; - cdef struct ExI_Bar_Body: uint8_t x; int16_t y; + + cdef struct ExI: ExI_Tag tag; int16_t foo; @@ -145,12 +158,13 @@ cdef extern from *: P0, P1, ctypedef uint8_t P_Tag; - cdef struct P1_Body: uint8_t _0; uint8_t _1; uint8_t _2; + + cdef struct P: P_Tag tag; uint8_t p0; @@ -160,6 +174,7 @@ cdef extern from *: Ok, Err, + cdef struct Q: Q_Tag tag; uint32_t *ok; @@ -169,11 +184,12 @@ cdef extern from *: IRFoo, IRBar, IRBaz, - cdef struct IRBar_Body: uint8_t x; int16_t y; + + cdef struct R: R_Tag tag; int16_t IRFoo; diff --git a/tests/expectations/forward_declaration.cpp b/tests/expectations/forward_declaration.cpp index 766b7994..c83f27e6 100644 --- a/tests/expectations/forward_declaration.cpp +++ b/tests/expectations/forward_declaration.cpp @@ -24,12 +24,12 @@ struct TypeData { enum class Tag { Primitive, Struct, - }; - - struct Struct_Body { + };struct Struct_Body { StructInfo _0; }; + + Tag tag; union { Struct_Body struct_; diff --git a/tests/expectations/forward_declaration.pyx b/tests/expectations/forward_declaration.pyx index 451852e6..7743716d 100644 --- a/tests/expectations/forward_declaration.pyx +++ b/tests/expectations/forward_declaration.pyx @@ -25,6 +25,7 @@ cdef extern from *: Primitive, Struct, + ctypedef struct TypeData: TypeData_Tag tag; StructInfo struct_; diff --git a/tests/expectations/forward_declaration_tag.pyx b/tests/expectations/forward_declaration_tag.pyx index af110c23..ba6a161c 100644 --- a/tests/expectations/forward_declaration_tag.pyx +++ b/tests/expectations/forward_declaration_tag.pyx @@ -25,6 +25,7 @@ cdef extern from *: Primitive, Struct, + cdef struct TypeData: TypeData_Tag tag; StructInfo struct_; diff --git a/tests/expectations/item_types.c b/tests/expectations/item_types.c index 3d033a86..00cd65f2 100644 --- a/tests/expectations/item_types.c +++ b/tests/expectations/item_types.c @@ -8,3 +8,4 @@ enum OnlyThisShouldBeGenerated { Bar, }; typedef uint8_t OnlyThisShouldBeGenerated; + diff --git a/tests/expectations/item_types.compat.c b/tests/expectations/item_types.compat.c index 6eab9e04..4d9a8f9a 100644 --- a/tests/expectations/item_types.compat.c +++ b/tests/expectations/item_types.compat.c @@ -14,3 +14,4 @@ enum OnlyThisShouldBeGenerated #ifndef __cplusplus typedef uint8_t OnlyThisShouldBeGenerated; #endif // __cplusplus + diff --git a/tests/expectations/item_types.cpp b/tests/expectations/item_types.cpp index 2ca14371..1c5f0bce 100644 --- a/tests/expectations/item_types.cpp +++ b/tests/expectations/item_types.cpp @@ -8,3 +8,4 @@ enum class OnlyThisShouldBeGenerated : uint8_t { Foo, Bar, }; + diff --git a/tests/expectations/item_types.pyx b/tests/expectations/item_types.pyx index 740710cb..a73baded 100644 --- a/tests/expectations/item_types.pyx +++ b/tests/expectations/item_types.pyx @@ -10,3 +10,4 @@ cdef extern from *: Foo, Bar, ctypedef uint8_t OnlyThisShouldBeGenerated; + diff --git a/tests/expectations/item_types_renamed.c b/tests/expectations/item_types_renamed.c index ffa3eaa5..a53a1c8b 100644 --- a/tests/expectations/item_types_renamed.c +++ b/tests/expectations/item_types_renamed.c @@ -8,3 +8,4 @@ enum StyleOnlyThisShouldBeGenerated { Bar, }; typedef uint8_t StyleOnlyThisShouldBeGenerated; + diff --git a/tests/expectations/item_types_renamed.compat.c b/tests/expectations/item_types_renamed.compat.c index 4912fa78..81ba271c 100644 --- a/tests/expectations/item_types_renamed.compat.c +++ b/tests/expectations/item_types_renamed.compat.c @@ -14,3 +14,4 @@ enum StyleOnlyThisShouldBeGenerated #ifndef __cplusplus typedef uint8_t StyleOnlyThisShouldBeGenerated; #endif // __cplusplus + diff --git a/tests/expectations/item_types_renamed.cpp b/tests/expectations/item_types_renamed.cpp index a80f1284..8588fcca 100644 --- a/tests/expectations/item_types_renamed.cpp +++ b/tests/expectations/item_types_renamed.cpp @@ -8,3 +8,4 @@ enum class StyleOnlyThisShouldBeGenerated : uint8_t { Foo, Bar, }; + diff --git a/tests/expectations/item_types_renamed.pyx b/tests/expectations/item_types_renamed.pyx index c922a7f0..155d7e59 100644 --- a/tests/expectations/item_types_renamed.pyx +++ b/tests/expectations/item_types_renamed.pyx @@ -10,3 +10,4 @@ cdef extern from *: Foo, Bar, ctypedef uint8_t StyleOnlyThisShouldBeGenerated; + diff --git a/tests/expectations/lifetime_arg.cpp b/tests/expectations/lifetime_arg.cpp index 72b21034..4beb082e 100644 --- a/tests/expectations/lifetime_arg.cpp +++ b/tests/expectations/lifetime_arg.cpp @@ -12,12 +12,12 @@ struct E { enum class Tag { V, U, - }; - - struct U_Body { + };struct U_Body { const uint8_t *_0; }; + + Tag tag; union { U_Body u; diff --git a/tests/expectations/lifetime_arg.pyx b/tests/expectations/lifetime_arg.pyx index 36c6cefb..3e1a45ca 100644 --- a/tests/expectations/lifetime_arg.pyx +++ b/tests/expectations/lifetime_arg.pyx @@ -13,6 +13,7 @@ cdef extern from *: V, U, + ctypedef struct E: E_Tag tag; const uint8_t *u; diff --git a/tests/expectations/lifetime_arg_tag.pyx b/tests/expectations/lifetime_arg_tag.pyx index a81108ba..4ea68ed9 100644 --- a/tests/expectations/lifetime_arg_tag.pyx +++ b/tests/expectations/lifetime_arg_tag.pyx @@ -13,6 +13,7 @@ cdef extern from *: V, U, + cdef struct E: E_Tag tag; const uint8_t *u; diff --git a/tests/expectations/mangle.pyx b/tests/expectations/mangle.pyx index 8ab50d77..ea163a01 100644 --- a/tests/expectations/mangle.pyx +++ b/tests/expectations/mangle.pyx @@ -10,6 +10,7 @@ cdef extern from *: BarSome, BarThing, + ctypedef struct FooU8: uint8_t a; diff --git a/tests/expectations/mangle_tag.pyx b/tests/expectations/mangle_tag.pyx index 8a83d2d6..8c550480 100644 --- a/tests/expectations/mangle_tag.pyx +++ b/tests/expectations/mangle_tag.pyx @@ -10,6 +10,7 @@ cdef extern from *: BarSome, BarThing, + cdef struct FooU8: uint8_t a; diff --git a/tests/expectations/merge_generic_tags.both.c b/tests/expectations/merge_generic_tags.both.c new file mode 100644 index 00000000..d4227fda --- /dev/null +++ b/tests/expectations/merge_generic_tags.both.c @@ -0,0 +1,29 @@ +#include +#include +#include +#include + +typedef enum COption_Tag { + Some, + None, +} COption_Tag; + +typedef struct COption_u8 { + COption_Tag tag; + union { + struct { + uint8_t some; + }; + }; +} COption_u8; + +typedef struct COption_u32 { + COption_Tag tag; + union { + struct { + uint32_t some; + }; + }; +} COption_u32; + +void root(struct COption_u8 a, struct COption_u32 b); diff --git a/tests/expectations/merge_generic_tags.both.compat.c b/tests/expectations/merge_generic_tags.both.compat.c new file mode 100644 index 00000000..eea6b2f1 --- /dev/null +++ b/tests/expectations/merge_generic_tags.both.compat.c @@ -0,0 +1,37 @@ +#include +#include +#include +#include + +typedef enum COption_Tag { + Some, + None, +} COption_Tag; + +typedef struct COption_u8 { + COption_Tag tag; + union { + struct { + uint8_t some; + }; + }; +} COption_u8; + +typedef struct COption_u32 { + COption_Tag tag; + union { + struct { + uint32_t some; + }; + }; +} COption_u32; + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +void root(struct COption_u8 a, struct COption_u32 b); + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus diff --git a/tests/expectations/merge_generic_tags.c b/tests/expectations/merge_generic_tags.c new file mode 100644 index 00000000..91ad387d --- /dev/null +++ b/tests/expectations/merge_generic_tags.c @@ -0,0 +1,33 @@ +#include +#include +#include +#include + +typedef enum { + Some, + None, +} COption_Tag; + + + +typedef struct { + COption_Tag tag; + union { + struct { + uint8_t some; + }; + }; +} COption_u8; + + + +typedef struct { + COption_Tag tag; + union { + struct { + uint32_t some; + }; + }; +} COption_u32; + +void root(COption_u8 a, COption_u32 b); diff --git a/tests/expectations/merge_generic_tags.compat.c b/tests/expectations/merge_generic_tags.compat.c new file mode 100644 index 00000000..2f93dc61 --- /dev/null +++ b/tests/expectations/merge_generic_tags.compat.c @@ -0,0 +1,41 @@ +#include +#include +#include +#include + +typedef enum { + Some, + None, +} COption_Tag; + + + +typedef struct { + COption_Tag tag; + union { + struct { + uint8_t some; + }; + }; +} COption_u8; + + + +typedef struct { + COption_Tag tag; + union { + struct { + uint32_t some; + }; + }; +} COption_u32; + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +void root(COption_u8 a, COption_u32 b); + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus diff --git a/tests/expectations/merge_generic_tags.cpp b/tests/expectations/merge_generic_tags.cpp new file mode 100644 index 00000000..2fb49ad4 --- /dev/null +++ b/tests/expectations/merge_generic_tags.cpp @@ -0,0 +1,28 @@ +#include +#include +#include +#include +#include + +template +struct COption { + enum class Tag { + Some, + None, + };struct Some_Body { + T _0; + }; + + + + Tag tag; + union { + Some_Body some; + }; +}; + +extern "C" { + +void root(COption a, COption b); + +} // extern "C" diff --git a/tests/expectations/merge_generic_tags.pyx b/tests/expectations/merge_generic_tags.pyx new file mode 100644 index 00000000..169fb244 --- /dev/null +++ b/tests/expectations/merge_generic_tags.pyx @@ -0,0 +1,26 @@ +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 *: + ctypedef bint bool + ctypedef struct va_list + +cdef extern from *: + + ctypedef enum COption_Tag: + Some, + None, + + + + + ctypedef struct COption_u8: + COption_Tag tag; + uint8_t some; + + + + ctypedef struct COption_u32: + COption_Tag tag; + uint32_t some; + + void root(COption_u8 a, COption_u32 b); diff --git a/tests/expectations/merge_generic_tags.tag.c b/tests/expectations/merge_generic_tags.tag.c new file mode 100644 index 00000000..45508900 --- /dev/null +++ b/tests/expectations/merge_generic_tags.tag.c @@ -0,0 +1,29 @@ +#include +#include +#include +#include + +enum COption_Tag { + Some, + None, +}; + +struct COption_u8 { + enum COption_Tag tag; + union { + struct { + uint8_t some; + }; + }; +}; + +struct COption_u32 { + enum COption_Tag tag; + union { + struct { + uint32_t some; + }; + }; +}; + +void root(struct COption_u8 a, struct COption_u32 b); diff --git a/tests/expectations/merge_generic_tags.tag.compat.c b/tests/expectations/merge_generic_tags.tag.compat.c new file mode 100644 index 00000000..dee2d2a5 --- /dev/null +++ b/tests/expectations/merge_generic_tags.tag.compat.c @@ -0,0 +1,37 @@ +#include +#include +#include +#include + +enum COption_Tag { + Some, + None, +}; + +struct COption_u8 { + enum COption_Tag tag; + union { + struct { + uint8_t some; + }; + }; +}; + +struct COption_u32 { + enum COption_Tag tag; + union { + struct { + uint32_t some; + }; + }; +}; + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +void root(struct COption_u8 a, struct COption_u32 b); + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus diff --git a/tests/expectations/merge_generic_tags.tag.pyx b/tests/expectations/merge_generic_tags.tag.pyx new file mode 100644 index 00000000..5029d210 --- /dev/null +++ b/tests/expectations/merge_generic_tags.tag.pyx @@ -0,0 +1,21 @@ +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 *: + ctypedef bint bool + ctypedef struct va_list + +cdef extern from *: + + cdef enum COption_Tag: + Some, + None, + + cdef struct COption_u8: + COption_Tag tag; + uint8_t some; + + cdef struct COption_u32: + COption_Tag tag; + uint32_t some; + + void root(COption_u8 a, COption_u32 b); diff --git a/tests/expectations/merge_generic_tags_both.c b/tests/expectations/merge_generic_tags_both.c new file mode 100644 index 00000000..26d919c4 --- /dev/null +++ b/tests/expectations/merge_generic_tags_both.c @@ -0,0 +1,33 @@ +#include +#include +#include +#include + +typedef enum COption_Tag { + Some, + None, +} COption_Tag; + + + +typedef struct COption_u8 { + COption_Tag tag; + union { + struct { + uint8_t some; + }; + }; +} COption_u8; + + + +typedef struct COption_u32 { + COption_Tag tag; + union { + struct { + uint32_t some; + }; + }; +} COption_u32; + +void root(struct COption_u8 a, struct COption_u32 b); diff --git a/tests/expectations/merge_generic_tags_both.compat.c b/tests/expectations/merge_generic_tags_both.compat.c new file mode 100644 index 00000000..0ebd2509 --- /dev/null +++ b/tests/expectations/merge_generic_tags_both.compat.c @@ -0,0 +1,41 @@ +#include +#include +#include +#include + +typedef enum COption_Tag { + Some, + None, +} COption_Tag; + + + +typedef struct COption_u8 { + COption_Tag tag; + union { + struct { + uint8_t some; + }; + }; +} COption_u8; + + + +typedef struct COption_u32 { + COption_Tag tag; + union { + struct { + uint32_t some; + }; + }; +} COption_u32; + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +void root(struct COption_u8 a, struct COption_u32 b); + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus diff --git a/tests/expectations/merge_generic_tags_export_prefix.c b/tests/expectations/merge_generic_tags_export_prefix.c new file mode 100644 index 00000000..a853e1c3 --- /dev/null +++ b/tests/expectations/merge_generic_tags_export_prefix.c @@ -0,0 +1,88 @@ +#include +#include +#include +#include + +typedef enum { + PREFIX_C_OPTION_SOME, + PREFIX_C_OPTION_NONE, +} Prefix_COption_Tag; + +typedef enum { + PREFIX_C_RESULT_OK, + PREFIX_C_RESULT_ERR, +} Prefix_CResult_Tag; + + + +typedef struct { + Prefix_COption_Tag tag; + union { + struct { + uint32_t some; + }; + }; +} Prefix_COption_u32; + +typedef struct { + int32_t code; + const uint8_t *message; +} Prefix_ErrorInfo; + + + +typedef struct { + Prefix_CResult_Tag tag; + union { + struct { + uint32_t ok; + }; + struct { + Prefix_ErrorInfo err; + }; + }; +} Prefix_CResult_u32__ErrorInfo; + + + +typedef struct { + Prefix_COption_Tag tag; + union { + struct { + const uint8_t *some; + }; + }; +} Prefix_COption______u8; + + + +typedef struct { + Prefix_CResult_Tag tag; + union { + struct { + const uint8_t *ok; + }; + struct { + int32_t err; + }; + }; +} Prefix_CResult______u8__i32; + + + +typedef struct { + Prefix_COption_Tag tag; + union { + struct { + int32_t some; + }; + }; +} Prefix_COption_i32; + +Prefix_COption_u32 process_result(Prefix_CResult_u32__ErrorInfo r); + +Prefix_COption______u8 process_str_result(Prefix_CResult______u8__i32 r); + +Prefix_COption_i32 get_option_int(void); + +Prefix_COption______u8 get_option_str(void); diff --git a/tests/expectations/merge_generic_tags_export_prefix.compat.c b/tests/expectations/merge_generic_tags_export_prefix.compat.c new file mode 100644 index 00000000..3217aa36 --- /dev/null +++ b/tests/expectations/merge_generic_tags_export_prefix.compat.c @@ -0,0 +1,96 @@ +#include +#include +#include +#include + +typedef enum { + PREFIX_C_OPTION_SOME, + PREFIX_C_OPTION_NONE, +} Prefix_COption_Tag; + +typedef enum { + PREFIX_C_RESULT_OK, + PREFIX_C_RESULT_ERR, +} Prefix_CResult_Tag; + + + +typedef struct { + Prefix_COption_Tag tag; + union { + struct { + uint32_t some; + }; + }; +} Prefix_COption_u32; + +typedef struct { + int32_t code; + const uint8_t *message; +} Prefix_ErrorInfo; + + + +typedef struct { + Prefix_CResult_Tag tag; + union { + struct { + uint32_t ok; + }; + struct { + Prefix_ErrorInfo err; + }; + }; +} Prefix_CResult_u32__ErrorInfo; + + + +typedef struct { + Prefix_COption_Tag tag; + union { + struct { + const uint8_t *some; + }; + }; +} Prefix_COption______u8; + + + +typedef struct { + Prefix_CResult_Tag tag; + union { + struct { + const uint8_t *ok; + }; + struct { + int32_t err; + }; + }; +} Prefix_CResult______u8__i32; + + + +typedef struct { + Prefix_COption_Tag tag; + union { + struct { + int32_t some; + }; + }; +} Prefix_COption_i32; + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +Prefix_COption_u32 process_result(Prefix_CResult_u32__ErrorInfo r); + +Prefix_COption______u8 process_str_result(Prefix_CResult______u8__i32 r); + +Prefix_COption_i32 get_option_int(void); + +Prefix_COption______u8 get_option_str(void); + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus diff --git a/tests/expectations/merge_generic_tags_export_prefix.cpp b/tests/expectations/merge_generic_tags_export_prefix.cpp new file mode 100644 index 00000000..0141e4ba --- /dev/null +++ b/tests/expectations/merge_generic_tags_export_prefix.cpp @@ -0,0 +1,61 @@ +#include +#include +#include +#include +#include + +template +struct Prefix_COption { + enum class Tag { + PREFIX_C_OPTION_SOME, + PREFIX_C_OPTION_NONE, + };struct Prefix_COption_Prefix_Some_Body { + T _0; + }; + + + + Tag tag; + union { + Prefix_COption_Prefix_Some_Body SOME; + }; +}; + +struct Prefix_ErrorInfo { + int32_t code; + const uint8_t *message; +}; + +template +struct Prefix_CResult { + enum class Tag { + PREFIX_C_RESULT_OK, + PREFIX_C_RESULT_ERR, + };struct Prefix_CResult_Prefix_Ok_Body { + T _0; + }; + + struct Prefix_CResult_Prefix_Err_Body { + E _0; + }; + + + + Tag tag; + union { + Prefix_CResult_Prefix_Ok_Body OK; + Prefix_CResult_Prefix_Err_Body ERR; + }; +}; + +extern "C" { + +Prefix_COption process_result(Prefix_CResult r); + +Prefix_COption process_str_result(Prefix_CResult r); + +Prefix_COption get_option_int(); + +Prefix_COption get_option_str(); + +} // extern "C" diff --git a/tests/expectations/merge_generic_tags_export_prefix.pyx b/tests/expectations/merge_generic_tags_export_prefix.pyx new file mode 100644 index 00000000..26f6db6d --- /dev/null +++ b/tests/expectations/merge_generic_tags_export_prefix.pyx @@ -0,0 +1,61 @@ +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 *: + ctypedef bint bool + ctypedef struct va_list + +cdef extern from *: + + ctypedef enum Prefix_COption_Tag: + PREFIX_C_OPTION_SOME, + PREFIX_C_OPTION_NONE, + + + ctypedef enum Prefix_CResult_Tag: + PREFIX_C_RESULT_OK, + PREFIX_C_RESULT_ERR, + + + + + ctypedef struct Prefix_COption_u32: + Prefix_COption_Tag tag; + uint32_t some; + + ctypedef struct Prefix_ErrorInfo: + int32_t code; + const uint8_t *message; + + + + ctypedef struct Prefix_CResult_u32__ErrorInfo: + Prefix_CResult_Tag tag; + uint32_t ok; + Prefix_ErrorInfo err; + + + + ctypedef struct Prefix_COption______u8: + Prefix_COption_Tag tag; + const uint8_t *some; + + + + ctypedef struct Prefix_CResult______u8__i32: + Prefix_CResult_Tag tag; + const uint8_t *ok; + int32_t err; + + + + ctypedef struct Prefix_COption_i32: + Prefix_COption_Tag tag; + int32_t some; + + Prefix_COption_u32 process_result(Prefix_CResult_u32__ErrorInfo r); + + Prefix_COption______u8 process_str_result(Prefix_CResult______u8__i32 r); + + Prefix_COption_i32 get_option_int(); + + Prefix_COption______u8 get_option_str(); diff --git a/tests/expectations/merge_generic_tags_export_prefix_both.c b/tests/expectations/merge_generic_tags_export_prefix_both.c new file mode 100644 index 00000000..635bdabf --- /dev/null +++ b/tests/expectations/merge_generic_tags_export_prefix_both.c @@ -0,0 +1,88 @@ +#include +#include +#include +#include + +typedef enum Prefix_COption_Tag { + PREFIX_C_OPTION_SOME, + PREFIX_C_OPTION_NONE, +} Prefix_COption_Tag; + +typedef enum Prefix_CResult_Tag { + PREFIX_C_RESULT_OK, + PREFIX_C_RESULT_ERR, +} Prefix_CResult_Tag; + + + +typedef struct Prefix_COption_u32 { + Prefix_COption_Tag tag; + union { + struct { + uint32_t some; + }; + }; +} Prefix_COption_u32; + +typedef struct Prefix_ErrorInfo { + int32_t code; + const uint8_t *message; +} Prefix_ErrorInfo; + + + +typedef struct Prefix_CResult_u32__ErrorInfo { + Prefix_CResult_Tag tag; + union { + struct { + uint32_t ok; + }; + struct { + struct Prefix_ErrorInfo err; + }; + }; +} Prefix_CResult_u32__ErrorInfo; + + + +typedef struct Prefix_COption______u8 { + Prefix_COption_Tag tag; + union { + struct { + const uint8_t *some; + }; + }; +} Prefix_COption______u8; + + + +typedef struct Prefix_CResult______u8__i32 { + Prefix_CResult_Tag tag; + union { + struct { + const uint8_t *ok; + }; + struct { + int32_t err; + }; + }; +} Prefix_CResult______u8__i32; + + + +typedef struct Prefix_COption_i32 { + Prefix_COption_Tag tag; + union { + struct { + int32_t some; + }; + }; +} Prefix_COption_i32; + +struct Prefix_COption_u32 process_result(struct Prefix_CResult_u32__ErrorInfo r); + +struct Prefix_COption______u8 process_str_result(struct Prefix_CResult______u8__i32 r); + +struct Prefix_COption_i32 get_option_int(void); + +struct Prefix_COption______u8 get_option_str(void); diff --git a/tests/expectations/merge_generic_tags_export_prefix_both.compat.c b/tests/expectations/merge_generic_tags_export_prefix_both.compat.c new file mode 100644 index 00000000..44f8cede --- /dev/null +++ b/tests/expectations/merge_generic_tags_export_prefix_both.compat.c @@ -0,0 +1,96 @@ +#include +#include +#include +#include + +typedef enum Prefix_COption_Tag { + PREFIX_C_OPTION_SOME, + PREFIX_C_OPTION_NONE, +} Prefix_COption_Tag; + +typedef enum Prefix_CResult_Tag { + PREFIX_C_RESULT_OK, + PREFIX_C_RESULT_ERR, +} Prefix_CResult_Tag; + + + +typedef struct Prefix_COption_u32 { + Prefix_COption_Tag tag; + union { + struct { + uint32_t some; + }; + }; +} Prefix_COption_u32; + +typedef struct Prefix_ErrorInfo { + int32_t code; + const uint8_t *message; +} Prefix_ErrorInfo; + + + +typedef struct Prefix_CResult_u32__ErrorInfo { + Prefix_CResult_Tag tag; + union { + struct { + uint32_t ok; + }; + struct { + struct Prefix_ErrorInfo err; + }; + }; +} Prefix_CResult_u32__ErrorInfo; + + + +typedef struct Prefix_COption______u8 { + Prefix_COption_Tag tag; + union { + struct { + const uint8_t *some; + }; + }; +} Prefix_COption______u8; + + + +typedef struct Prefix_CResult______u8__i32 { + Prefix_CResult_Tag tag; + union { + struct { + const uint8_t *ok; + }; + struct { + int32_t err; + }; + }; +} Prefix_CResult______u8__i32; + + + +typedef struct Prefix_COption_i32 { + Prefix_COption_Tag tag; + union { + struct { + int32_t some; + }; + }; +} Prefix_COption_i32; + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +struct Prefix_COption_u32 process_result(struct Prefix_CResult_u32__ErrorInfo r); + +struct Prefix_COption______u8 process_str_result(struct Prefix_CResult______u8__i32 r); + +struct Prefix_COption_i32 get_option_int(void); + +struct Prefix_COption______u8 get_option_str(void); + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus diff --git a/tests/expectations/merge_generic_tags_export_prefix_tag.c b/tests/expectations/merge_generic_tags_export_prefix_tag.c new file mode 100644 index 00000000..905b52f9 --- /dev/null +++ b/tests/expectations/merge_generic_tags_export_prefix_tag.c @@ -0,0 +1,88 @@ +#include +#include +#include +#include + +enum Prefix_COption_Tag { + PREFIX_C_OPTION_SOME, + PREFIX_C_OPTION_NONE, +}; + +enum Prefix_CResult_Tag { + PREFIX_C_RESULT_OK, + PREFIX_C_RESULT_ERR, +}; + + + +struct Prefix_COption_u32 { + enum Prefix_COption_Tag tag; + union { + struct { + uint32_t some; + }; + }; +}; + +struct Prefix_ErrorInfo { + int32_t code; + const uint8_t *message; +}; + + + +struct Prefix_CResult_u32__ErrorInfo { + enum Prefix_CResult_Tag tag; + union { + struct { + uint32_t ok; + }; + struct { + struct Prefix_ErrorInfo err; + }; + }; +}; + + + +struct Prefix_COption______u8 { + enum Prefix_COption_Tag tag; + union { + struct { + const uint8_t *some; + }; + }; +}; + + + +struct Prefix_CResult______u8__i32 { + enum Prefix_CResult_Tag tag; + union { + struct { + const uint8_t *ok; + }; + struct { + int32_t err; + }; + }; +}; + + + +struct Prefix_COption_i32 { + enum Prefix_COption_Tag tag; + union { + struct { + int32_t some; + }; + }; +}; + +struct Prefix_COption_u32 process_result(struct Prefix_CResult_u32__ErrorInfo r); + +struct Prefix_COption______u8 process_str_result(struct Prefix_CResult______u8__i32 r); + +struct Prefix_COption_i32 get_option_int(void); + +struct Prefix_COption______u8 get_option_str(void); diff --git a/tests/expectations/merge_generic_tags_export_prefix_tag.compat.c b/tests/expectations/merge_generic_tags_export_prefix_tag.compat.c new file mode 100644 index 00000000..d0a0c382 --- /dev/null +++ b/tests/expectations/merge_generic_tags_export_prefix_tag.compat.c @@ -0,0 +1,96 @@ +#include +#include +#include +#include + +enum Prefix_COption_Tag { + PREFIX_C_OPTION_SOME, + PREFIX_C_OPTION_NONE, +}; + +enum Prefix_CResult_Tag { + PREFIX_C_RESULT_OK, + PREFIX_C_RESULT_ERR, +}; + + + +struct Prefix_COption_u32 { + enum Prefix_COption_Tag tag; + union { + struct { + uint32_t some; + }; + }; +}; + +struct Prefix_ErrorInfo { + int32_t code; + const uint8_t *message; +}; + + + +struct Prefix_CResult_u32__ErrorInfo { + enum Prefix_CResult_Tag tag; + union { + struct { + uint32_t ok; + }; + struct { + struct Prefix_ErrorInfo err; + }; + }; +}; + + + +struct Prefix_COption______u8 { + enum Prefix_COption_Tag tag; + union { + struct { + const uint8_t *some; + }; + }; +}; + + + +struct Prefix_CResult______u8__i32 { + enum Prefix_CResult_Tag tag; + union { + struct { + const uint8_t *ok; + }; + struct { + int32_t err; + }; + }; +}; + + + +struct Prefix_COption_i32 { + enum Prefix_COption_Tag tag; + union { + struct { + int32_t some; + }; + }; +}; + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +struct Prefix_COption_u32 process_result(struct Prefix_CResult_u32__ErrorInfo r); + +struct Prefix_COption______u8 process_str_result(struct Prefix_CResult______u8__i32 r); + +struct Prefix_COption_i32 get_option_int(void); + +struct Prefix_COption______u8 get_option_str(void); + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus diff --git a/tests/expectations/merge_generic_tags_export_prefix_tag.pyx b/tests/expectations/merge_generic_tags_export_prefix_tag.pyx new file mode 100644 index 00000000..168e8529 --- /dev/null +++ b/tests/expectations/merge_generic_tags_export_prefix_tag.pyx @@ -0,0 +1,61 @@ +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 *: + ctypedef bint bool + ctypedef struct va_list + +cdef extern from *: + + cdef enum Prefix_COption_Tag: + PREFIX_C_OPTION_SOME, + PREFIX_C_OPTION_NONE, + + + cdef enum Prefix_CResult_Tag: + PREFIX_C_RESULT_OK, + PREFIX_C_RESULT_ERR, + + + + + cdef struct Prefix_COption_u32: + Prefix_COption_Tag tag; + uint32_t some; + + cdef struct Prefix_ErrorInfo: + int32_t code; + const uint8_t *message; + + + + cdef struct Prefix_CResult_u32__ErrorInfo: + Prefix_CResult_Tag tag; + uint32_t ok; + Prefix_ErrorInfo err; + + + + cdef struct Prefix_COption______u8: + Prefix_COption_Tag tag; + const uint8_t *some; + + + + cdef struct Prefix_CResult______u8__i32: + Prefix_CResult_Tag tag; + const uint8_t *ok; + int32_t err; + + + + cdef struct Prefix_COption_i32: + Prefix_COption_Tag tag; + int32_t some; + + Prefix_COption_u32 process_result(Prefix_CResult_u32__ErrorInfo r); + + Prefix_COption______u8 process_str_result(Prefix_CResult______u8__i32 r); + + Prefix_COption_i32 get_option_int(); + + Prefix_COption______u8 get_option_str(); diff --git a/tests/expectations/merge_generic_tags_tag.c b/tests/expectations/merge_generic_tags_tag.c new file mode 100644 index 00000000..a8497d5e --- /dev/null +++ b/tests/expectations/merge_generic_tags_tag.c @@ -0,0 +1,33 @@ +#include +#include +#include +#include + +enum COption_Tag { + Some, + None, +}; + + + +struct COption_u8 { + enum COption_Tag tag; + union { + struct { + uint8_t some; + }; + }; +}; + + + +struct COption_u32 { + enum COption_Tag tag; + union { + struct { + uint32_t some; + }; + }; +}; + +void root(struct COption_u8 a, struct COption_u32 b); diff --git a/tests/expectations/merge_generic_tags_tag.compat.c b/tests/expectations/merge_generic_tags_tag.compat.c new file mode 100644 index 00000000..a8211b0e --- /dev/null +++ b/tests/expectations/merge_generic_tags_tag.compat.c @@ -0,0 +1,41 @@ +#include +#include +#include +#include + +enum COption_Tag { + Some, + None, +}; + + + +struct COption_u8 { + enum COption_Tag tag; + union { + struct { + uint8_t some; + }; + }; +}; + + + +struct COption_u32 { + enum COption_Tag tag; + union { + struct { + uint32_t some; + }; + }; +}; + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +void root(struct COption_u8 a, struct COption_u32 b); + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus diff --git a/tests/expectations/merge_generic_tags_tag.pyx b/tests/expectations/merge_generic_tags_tag.pyx new file mode 100644 index 00000000..c53372d2 --- /dev/null +++ b/tests/expectations/merge_generic_tags_tag.pyx @@ -0,0 +1,26 @@ +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 *: + ctypedef bint bool + ctypedef struct va_list + +cdef extern from *: + + cdef enum COption_Tag: + Some, + None, + + + + + cdef struct COption_u8: + COption_Tag tag; + uint8_t some; + + + + cdef struct COption_u32: + COption_Tag tag; + uint32_t some; + + void root(COption_u8 a, COption_u32 b); diff --git a/tests/expectations/merge_generic_tags_with_prefix.both.c b/tests/expectations/merge_generic_tags_with_prefix.both.c new file mode 100644 index 00000000..f0c3078d --- /dev/null +++ b/tests/expectations/merge_generic_tags_with_prefix.both.c @@ -0,0 +1,29 @@ +#include +#include +#include +#include + +typedef enum COption_Tag { + COption_Some, + COption_None, +} COption_Tag; + +typedef struct COption_u8 { + COption_Tag tag; + union { + struct { + uint8_t some; + }; + }; +} COption_u8; + +typedef struct COption_u32 { + COption_Tag tag; + union { + struct { + uint32_t some; + }; + }; +} COption_u32; + +void root(struct COption_u8 a, struct COption_u32 b); diff --git a/tests/expectations/merge_generic_tags_with_prefix.both.compat.c b/tests/expectations/merge_generic_tags_with_prefix.both.compat.c new file mode 100644 index 00000000..ab9ce6c7 --- /dev/null +++ b/tests/expectations/merge_generic_tags_with_prefix.both.compat.c @@ -0,0 +1,37 @@ +#include +#include +#include +#include + +typedef enum COption_Tag { + COption_Some, + COption_None, +} COption_Tag; + +typedef struct COption_u8 { + COption_Tag tag; + union { + struct { + uint8_t some; + }; + }; +} COption_u8; + +typedef struct COption_u32 { + COption_Tag tag; + union { + struct { + uint32_t some; + }; + }; +} COption_u32; + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +void root(struct COption_u8 a, struct COption_u32 b); + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus diff --git a/tests/expectations/merge_generic_tags_with_prefix.c b/tests/expectations/merge_generic_tags_with_prefix.c new file mode 100644 index 00000000..93c573f9 --- /dev/null +++ b/tests/expectations/merge_generic_tags_with_prefix.c @@ -0,0 +1,33 @@ +#include +#include +#include +#include + +typedef enum { + COption_Some, + COption_None, +} COption_Tag; + + + +typedef struct { + COption_Tag tag; + union { + struct { + uint8_t some; + }; + }; +} COption_u8; + + + +typedef struct { + COption_Tag tag; + union { + struct { + uint32_t some; + }; + }; +} COption_u32; + +void root(COption_u8 a, COption_u32 b); diff --git a/tests/expectations/merge_generic_tags_with_prefix.compat.c b/tests/expectations/merge_generic_tags_with_prefix.compat.c new file mode 100644 index 00000000..b901a4b8 --- /dev/null +++ b/tests/expectations/merge_generic_tags_with_prefix.compat.c @@ -0,0 +1,41 @@ +#include +#include +#include +#include + +typedef enum { + COption_Some, + COption_None, +} COption_Tag; + + + +typedef struct { + COption_Tag tag; + union { + struct { + uint8_t some; + }; + }; +} COption_u8; + + + +typedef struct { + COption_Tag tag; + union { + struct { + uint32_t some; + }; + }; +} COption_u32; + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +void root(COption_u8 a, COption_u32 b); + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus diff --git a/tests/expectations/merge_generic_tags_with_prefix.cpp b/tests/expectations/merge_generic_tags_with_prefix.cpp new file mode 100644 index 00000000..af2b8eec --- /dev/null +++ b/tests/expectations/merge_generic_tags_with_prefix.cpp @@ -0,0 +1,28 @@ +#include +#include +#include +#include +#include + +template +struct COption { + enum class Tag { + COption_Some, + COption_None, + };struct COption_Some_Body { + T _0; + }; + + + + Tag tag; + union { + COption_Some_Body some; + }; +}; + +extern "C" { + +void root(COption a, COption b); + +} // extern "C" diff --git a/tests/expectations/merge_generic_tags_with_prefix.pyx b/tests/expectations/merge_generic_tags_with_prefix.pyx new file mode 100644 index 00000000..7abed3b3 --- /dev/null +++ b/tests/expectations/merge_generic_tags_with_prefix.pyx @@ -0,0 +1,26 @@ +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 *: + ctypedef bint bool + ctypedef struct va_list + +cdef extern from *: + + ctypedef enum COption_Tag: + COption_Some, + COption_None, + + + + + ctypedef struct COption_u8: + COption_Tag tag; + uint8_t some; + + + + ctypedef struct COption_u32: + COption_Tag tag; + uint32_t some; + + void root(COption_u8 a, COption_u32 b); diff --git a/tests/expectations/merge_generic_tags_with_prefix.tag.c b/tests/expectations/merge_generic_tags_with_prefix.tag.c new file mode 100644 index 00000000..a8318f88 --- /dev/null +++ b/tests/expectations/merge_generic_tags_with_prefix.tag.c @@ -0,0 +1,29 @@ +#include +#include +#include +#include + +enum COption_Tag { + COption_Some, + COption_None, +}; + +struct COption_u8 { + enum COption_Tag tag; + union { + struct { + uint8_t some; + }; + }; +}; + +struct COption_u32 { + enum COption_Tag tag; + union { + struct { + uint32_t some; + }; + }; +}; + +void root(struct COption_u8 a, struct COption_u32 b); diff --git a/tests/expectations/merge_generic_tags_with_prefix.tag.compat.c b/tests/expectations/merge_generic_tags_with_prefix.tag.compat.c new file mode 100644 index 00000000..fa9297fb --- /dev/null +++ b/tests/expectations/merge_generic_tags_with_prefix.tag.compat.c @@ -0,0 +1,37 @@ +#include +#include +#include +#include + +enum COption_Tag { + COption_Some, + COption_None, +}; + +struct COption_u8 { + enum COption_Tag tag; + union { + struct { + uint8_t some; + }; + }; +}; + +struct COption_u32 { + enum COption_Tag tag; + union { + struct { + uint32_t some; + }; + }; +}; + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +void root(struct COption_u8 a, struct COption_u32 b); + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus diff --git a/tests/expectations/merge_generic_tags_with_prefix.tag.pyx b/tests/expectations/merge_generic_tags_with_prefix.tag.pyx new file mode 100644 index 00000000..64482ebb --- /dev/null +++ b/tests/expectations/merge_generic_tags_with_prefix.tag.pyx @@ -0,0 +1,21 @@ +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 *: + ctypedef bint bool + ctypedef struct va_list + +cdef extern from *: + + cdef enum COption_Tag: + COption_Some, + COption_None, + + cdef struct COption_u8: + COption_Tag tag; + uint8_t some; + + cdef struct COption_u32: + COption_Tag tag; + uint32_t some; + + void root(COption_u8 a, COption_u32 b); diff --git a/tests/expectations/merge_generic_tags_with_prefix_both.c b/tests/expectations/merge_generic_tags_with_prefix_both.c new file mode 100644 index 00000000..11104e69 --- /dev/null +++ b/tests/expectations/merge_generic_tags_with_prefix_both.c @@ -0,0 +1,33 @@ +#include +#include +#include +#include + +typedef enum COption_Tag { + COption_Some, + COption_None, +} COption_Tag; + + + +typedef struct COption_u8 { + COption_Tag tag; + union { + struct { + uint8_t some; + }; + }; +} COption_u8; + + + +typedef struct COption_u32 { + COption_Tag tag; + union { + struct { + uint32_t some; + }; + }; +} COption_u32; + +void root(struct COption_u8 a, struct COption_u32 b); diff --git a/tests/expectations/merge_generic_tags_with_prefix_both.compat.c b/tests/expectations/merge_generic_tags_with_prefix_both.compat.c new file mode 100644 index 00000000..30c474d2 --- /dev/null +++ b/tests/expectations/merge_generic_tags_with_prefix_both.compat.c @@ -0,0 +1,41 @@ +#include +#include +#include +#include + +typedef enum COption_Tag { + COption_Some, + COption_None, +} COption_Tag; + + + +typedef struct COption_u8 { + COption_Tag tag; + union { + struct { + uint8_t some; + }; + }; +} COption_u8; + + + +typedef struct COption_u32 { + COption_Tag tag; + union { + struct { + uint32_t some; + }; + }; +} COption_u32; + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +void root(struct COption_u8 a, struct COption_u32 b); + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus diff --git a/tests/expectations/merge_generic_tags_with_prefix_tag.c b/tests/expectations/merge_generic_tags_with_prefix_tag.c new file mode 100644 index 00000000..1379b141 --- /dev/null +++ b/tests/expectations/merge_generic_tags_with_prefix_tag.c @@ -0,0 +1,33 @@ +#include +#include +#include +#include + +enum COption_Tag { + COption_Some, + COption_None, +}; + + + +struct COption_u8 { + enum COption_Tag tag; + union { + struct { + uint8_t some; + }; + }; +}; + + + +struct COption_u32 { + enum COption_Tag tag; + union { + struct { + uint32_t some; + }; + }; +}; + +void root(struct COption_u8 a, struct COption_u32 b); diff --git a/tests/expectations/merge_generic_tags_with_prefix_tag.compat.c b/tests/expectations/merge_generic_tags_with_prefix_tag.compat.c new file mode 100644 index 00000000..e0e6819c --- /dev/null +++ b/tests/expectations/merge_generic_tags_with_prefix_tag.compat.c @@ -0,0 +1,41 @@ +#include +#include +#include +#include + +enum COption_Tag { + COption_Some, + COption_None, +}; + + + +struct COption_u8 { + enum COption_Tag tag; + union { + struct { + uint8_t some; + }; + }; +}; + + + +struct COption_u32 { + enum COption_Tag tag; + union { + struct { + uint32_t some; + }; + }; +}; + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +void root(struct COption_u8 a, struct COption_u32 b); + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus diff --git a/tests/expectations/merge_generic_tags_with_prefix_tag.pyx b/tests/expectations/merge_generic_tags_with_prefix_tag.pyx new file mode 100644 index 00000000..7ba61d12 --- /dev/null +++ b/tests/expectations/merge_generic_tags_with_prefix_tag.pyx @@ -0,0 +1,26 @@ +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 *: + ctypedef bint bool + ctypedef struct va_list + +cdef extern from *: + + cdef enum COption_Tag: + COption_Some, + COption_None, + + + + + cdef struct COption_u8: + COption_Tag tag; + uint8_t some; + + + + cdef struct COption_u32: + COption_Tag tag; + uint32_t some; + + void root(COption_u8 a, COption_u32 b); diff --git a/tests/expectations/must_use.c b/tests/expectations/must_use.c index 1ecad729..b5ebdbb3 100644 --- a/tests/expectations/must_use.c +++ b/tests/expectations/must_use.c @@ -14,6 +14,7 @@ enum MaybeOwnedPtr_i32_Tag { }; typedef uint8_t MaybeOwnedPtr_i32_Tag; + typedef struct MUST_USE_STRUCT { MaybeOwnedPtr_i32_Tag tag; union { diff --git a/tests/expectations/must_use.compat.c b/tests/expectations/must_use.compat.c index b6fd1724..13062681 100644 --- a/tests/expectations/must_use.compat.c +++ b/tests/expectations/must_use.compat.c @@ -20,6 +20,7 @@ enum MaybeOwnedPtr_i32_Tag typedef uint8_t MaybeOwnedPtr_i32_Tag; #endif // __cplusplus + typedef struct MUST_USE_STRUCT { MaybeOwnedPtr_i32_Tag tag; union { diff --git a/tests/expectations/must_use.cpp b/tests/expectations/must_use.cpp index 45333eb4..808802df 100644 --- a/tests/expectations/must_use.cpp +++ b/tests/expectations/must_use.cpp @@ -15,11 +15,12 @@ struct MUST_USE_STRUCT MaybeOwnedPtr { Owned, None, }; - struct Owned_Body { T *_0; }; + + Tag tag; union { Owned_Body owned; diff --git a/tests/expectations/must_use.pyx b/tests/expectations/must_use.pyx index 50f97403..ab30190e 100644 --- a/tests/expectations/must_use.pyx +++ b/tests/expectations/must_use.pyx @@ -16,6 +16,7 @@ cdef extern from *: None_i32, ctypedef uint8_t MaybeOwnedPtr_i32_Tag; + ctypedef struct MaybeOwnedPtr_i32: MaybeOwnedPtr_i32_Tag tag; int32_t *owned; diff --git a/tests/expectations/must_use_both.c b/tests/expectations/must_use_both.c index c55ce31c..c432ac17 100644 --- a/tests/expectations/must_use_both.c +++ b/tests/expectations/must_use_both.c @@ -14,6 +14,7 @@ enum MaybeOwnedPtr_i32_Tag { }; typedef uint8_t MaybeOwnedPtr_i32_Tag; + typedef struct MUST_USE_STRUCT MaybeOwnedPtr_i32 { MaybeOwnedPtr_i32_Tag tag; union { diff --git a/tests/expectations/must_use_both.compat.c b/tests/expectations/must_use_both.compat.c index f56e8f03..e2e5dfdb 100644 --- a/tests/expectations/must_use_both.compat.c +++ b/tests/expectations/must_use_both.compat.c @@ -20,6 +20,7 @@ enum MaybeOwnedPtr_i32_Tag typedef uint8_t MaybeOwnedPtr_i32_Tag; #endif // __cplusplus + typedef struct MUST_USE_STRUCT MaybeOwnedPtr_i32 { MaybeOwnedPtr_i32_Tag tag; union { diff --git a/tests/expectations/must_use_tag.c b/tests/expectations/must_use_tag.c index 16c3d34a..7879c691 100644 --- a/tests/expectations/must_use_tag.c +++ b/tests/expectations/must_use_tag.c @@ -14,6 +14,7 @@ enum MaybeOwnedPtr_i32_Tag { }; typedef uint8_t MaybeOwnedPtr_i32_Tag; + struct MUST_USE_STRUCT MaybeOwnedPtr_i32 { MaybeOwnedPtr_i32_Tag tag; union { diff --git a/tests/expectations/must_use_tag.compat.c b/tests/expectations/must_use_tag.compat.c index 7aa48cef..d7950fc8 100644 --- a/tests/expectations/must_use_tag.compat.c +++ b/tests/expectations/must_use_tag.compat.c @@ -20,6 +20,7 @@ enum MaybeOwnedPtr_i32_Tag typedef uint8_t MaybeOwnedPtr_i32_Tag; #endif // __cplusplus + struct MUST_USE_STRUCT MaybeOwnedPtr_i32 { MaybeOwnedPtr_i32_Tag tag; union { diff --git a/tests/expectations/must_use_tag.pyx b/tests/expectations/must_use_tag.pyx index 01e9df67..8a84b4cc 100644 --- a/tests/expectations/must_use_tag.pyx +++ b/tests/expectations/must_use_tag.pyx @@ -16,6 +16,7 @@ cdef extern from *: None_i32, ctypedef uint8_t MaybeOwnedPtr_i32_Tag; + cdef struct MaybeOwnedPtr_i32: MaybeOwnedPtr_i32_Tag tag; int32_t *owned; diff --git a/tests/expectations/prefix.c b/tests/expectations/prefix.c index 4ef6a712..fbf55401 100644 --- a/tests/expectations/prefix.c +++ b/tests/expectations/prefix.c @@ -20,6 +20,7 @@ enum PREFIX_AbsoluteFontWeight_Tag { }; typedef uint8_t PREFIX_AbsoluteFontWeight_Tag; + typedef union { PREFIX_AbsoluteFontWeight_Tag tag; struct { diff --git a/tests/expectations/prefix.compat.c b/tests/expectations/prefix.compat.c index a37a15a0..02bdd20a 100644 --- a/tests/expectations/prefix.compat.c +++ b/tests/expectations/prefix.compat.c @@ -26,6 +26,7 @@ enum PREFIX_AbsoluteFontWeight_Tag typedef uint8_t PREFIX_AbsoluteFontWeight_Tag; #endif // __cplusplus + typedef union { PREFIX_AbsoluteFontWeight_Tag tag; struct { diff --git a/tests/expectations/prefix.cpp b/tests/expectations/prefix.cpp index e11ffc73..97416072 100644 --- a/tests/expectations/prefix.cpp +++ b/tests/expectations/prefix.cpp @@ -20,12 +20,13 @@ union PREFIX_AbsoluteFontWeight { Normal, Bold, }; - struct Weight_Body { Tag tag; float _0; }; + + struct { Tag tag; }; diff --git a/tests/expectations/prefix.pyx b/tests/expectations/prefix.pyx index 7d93ed4f..26939e3b 100644 --- a/tests/expectations/prefix.pyx +++ b/tests/expectations/prefix.pyx @@ -22,6 +22,7 @@ cdef extern from *: Bold, ctypedef uint8_t PREFIX_AbsoluteFontWeight_Tag; + ctypedef union PREFIX_AbsoluteFontWeight: PREFIX_AbsoluteFontWeight_Tag tag; float weight; diff --git a/tests/expectations/prefix_both.c b/tests/expectations/prefix_both.c index 1eb9f74c..0316b8a1 100644 --- a/tests/expectations/prefix_both.c +++ b/tests/expectations/prefix_both.c @@ -20,6 +20,7 @@ enum PREFIX_AbsoluteFontWeight_Tag { }; typedef uint8_t PREFIX_AbsoluteFontWeight_Tag; + typedef union PREFIX_AbsoluteFontWeight { PREFIX_AbsoluteFontWeight_Tag tag; struct { diff --git a/tests/expectations/prefix_both.compat.c b/tests/expectations/prefix_both.compat.c index 1b6475c3..047be68a 100644 --- a/tests/expectations/prefix_both.compat.c +++ b/tests/expectations/prefix_both.compat.c @@ -26,6 +26,7 @@ enum PREFIX_AbsoluteFontWeight_Tag typedef uint8_t PREFIX_AbsoluteFontWeight_Tag; #endif // __cplusplus + typedef union PREFIX_AbsoluteFontWeight { PREFIX_AbsoluteFontWeight_Tag tag; struct { diff --git a/tests/expectations/prefix_tag.c b/tests/expectations/prefix_tag.c index d23d556f..2f825721 100644 --- a/tests/expectations/prefix_tag.c +++ b/tests/expectations/prefix_tag.c @@ -20,6 +20,7 @@ enum PREFIX_AbsoluteFontWeight_Tag { }; typedef uint8_t PREFIX_AbsoluteFontWeight_Tag; + union PREFIX_AbsoluteFontWeight { PREFIX_AbsoluteFontWeight_Tag tag; struct { diff --git a/tests/expectations/prefix_tag.compat.c b/tests/expectations/prefix_tag.compat.c index e300cdad..0970c350 100644 --- a/tests/expectations/prefix_tag.compat.c +++ b/tests/expectations/prefix_tag.compat.c @@ -26,6 +26,7 @@ enum PREFIX_AbsoluteFontWeight_Tag typedef uint8_t PREFIX_AbsoluteFontWeight_Tag; #endif // __cplusplus + union PREFIX_AbsoluteFontWeight { PREFIX_AbsoluteFontWeight_Tag tag; struct { diff --git a/tests/expectations/prefix_tag.pyx b/tests/expectations/prefix_tag.pyx index 32f38d98..dadc7dd2 100644 --- a/tests/expectations/prefix_tag.pyx +++ b/tests/expectations/prefix_tag.pyx @@ -22,6 +22,7 @@ cdef extern from *: Bold, ctypedef uint8_t PREFIX_AbsoluteFontWeight_Tag; + cdef union PREFIX_AbsoluteFontWeight: PREFIX_AbsoluteFontWeight_Tag tag; float weight; diff --git a/tests/expectations/raw_ident.c b/tests/expectations/raw_ident.c index 4b6ccd98..b45dc284 100644 --- a/tests/expectations/raw_ident.c +++ b/tests/expectations/raw_ident.c @@ -9,6 +9,7 @@ enum Enum { }; typedef uint8_t Enum; + typedef struct { Enum field; } Struct; diff --git a/tests/expectations/raw_ident.compat.c b/tests/expectations/raw_ident.compat.c index a8d14907..238da248 100644 --- a/tests/expectations/raw_ident.compat.c +++ b/tests/expectations/raw_ident.compat.c @@ -15,6 +15,7 @@ enum Enum typedef uint8_t Enum; #endif // __cplusplus + typedef struct { Enum field; } Struct; diff --git a/tests/expectations/raw_ident.cpp b/tests/expectations/raw_ident.cpp index 46d14d57..a83a9070 100644 --- a/tests/expectations/raw_ident.cpp +++ b/tests/expectations/raw_ident.cpp @@ -9,6 +9,7 @@ enum class Enum : uint8_t { b, }; + struct Struct { Enum field; }; diff --git a/tests/expectations/raw_ident.pyx b/tests/expectations/raw_ident.pyx index 1c194b65..c15bf8ba 100644 --- a/tests/expectations/raw_ident.pyx +++ b/tests/expectations/raw_ident.pyx @@ -11,6 +11,7 @@ cdef extern from *: b, ctypedef uint8_t Enum; + ctypedef struct Struct: Enum field; diff --git a/tests/expectations/raw_ident_both.c b/tests/expectations/raw_ident_both.c index fc302c32..65668119 100644 --- a/tests/expectations/raw_ident_both.c +++ b/tests/expectations/raw_ident_both.c @@ -9,6 +9,7 @@ enum Enum { }; typedef uint8_t Enum; + typedef struct Struct { Enum field; } Struct; diff --git a/tests/expectations/raw_ident_both.compat.c b/tests/expectations/raw_ident_both.compat.c index 07f66e89..68db096c 100644 --- a/tests/expectations/raw_ident_both.compat.c +++ b/tests/expectations/raw_ident_both.compat.c @@ -15,6 +15,7 @@ enum Enum typedef uint8_t Enum; #endif // __cplusplus + typedef struct Struct { Enum field; } Struct; diff --git a/tests/expectations/raw_ident_tag.c b/tests/expectations/raw_ident_tag.c index ae77cf04..09983a33 100644 --- a/tests/expectations/raw_ident_tag.c +++ b/tests/expectations/raw_ident_tag.c @@ -9,6 +9,7 @@ enum Enum { }; typedef uint8_t Enum; + struct Struct { Enum field; }; diff --git a/tests/expectations/raw_ident_tag.compat.c b/tests/expectations/raw_ident_tag.compat.c index afa24586..f2750af2 100644 --- a/tests/expectations/raw_ident_tag.compat.c +++ b/tests/expectations/raw_ident_tag.compat.c @@ -15,6 +15,7 @@ enum Enum typedef uint8_t Enum; #endif // __cplusplus + struct Struct { Enum field; }; diff --git a/tests/expectations/raw_ident_tag.pyx b/tests/expectations/raw_ident_tag.pyx index 8b11c904..78173130 100644 --- a/tests/expectations/raw_ident_tag.pyx +++ b/tests/expectations/raw_ident_tag.pyx @@ -11,6 +11,7 @@ cdef extern from *: b, ctypedef uint8_t Enum; + cdef struct Struct: Enum field; diff --git a/tests/expectations/rename.c b/tests/expectations/rename.c index 738907d4..32e1f050 100644 --- a/tests/expectations/rename.c +++ b/tests/expectations/rename.c @@ -11,6 +11,7 @@ enum C_E { }; typedef uint8_t C_E; + typedef struct C_A C_A; typedef struct C_C C_C; diff --git a/tests/expectations/rename.compat.c b/tests/expectations/rename.compat.c index 75f6644e..778159c7 100644 --- a/tests/expectations/rename.compat.c +++ b/tests/expectations/rename.compat.c @@ -17,6 +17,7 @@ enum C_E typedef uint8_t C_E; #endif // __cplusplus + typedef struct C_A C_A; typedef struct C_C C_C; diff --git a/tests/expectations/rename.cpp b/tests/expectations/rename.cpp index e27a6360..42932eee 100644 --- a/tests/expectations/rename.cpp +++ b/tests/expectations/rename.cpp @@ -11,6 +11,7 @@ enum class C_E : uint8_t { y = 1, }; + struct C_A; struct C_C; diff --git a/tests/expectations/rename.pyx b/tests/expectations/rename.pyx index 9911089f..37c1dfc0 100644 --- a/tests/expectations/rename.pyx +++ b/tests/expectations/rename.pyx @@ -13,6 +13,7 @@ cdef extern from *: y # = 1, ctypedef uint8_t C_E; + ctypedef struct C_A: pass diff --git a/tests/expectations/rename_both.c b/tests/expectations/rename_both.c index 6c6e9a5a..90230017 100644 --- a/tests/expectations/rename_both.c +++ b/tests/expectations/rename_both.c @@ -11,6 +11,7 @@ enum C_E { }; typedef uint8_t C_E; + typedef struct C_A C_A; typedef struct C_C C_C; diff --git a/tests/expectations/rename_both.compat.c b/tests/expectations/rename_both.compat.c index 9361e68b..2f564ac0 100644 --- a/tests/expectations/rename_both.compat.c +++ b/tests/expectations/rename_both.compat.c @@ -17,6 +17,7 @@ enum C_E typedef uint8_t C_E; #endif // __cplusplus + typedef struct C_A C_A; typedef struct C_C C_C; diff --git a/tests/expectations/rename_tag.c b/tests/expectations/rename_tag.c index ca127187..607ef932 100644 --- a/tests/expectations/rename_tag.c +++ b/tests/expectations/rename_tag.c @@ -11,6 +11,7 @@ enum C_E { }; typedef uint8_t C_E; + struct C_A; struct C_C; diff --git a/tests/expectations/rename_tag.compat.c b/tests/expectations/rename_tag.compat.c index e952b49e..27a617a5 100644 --- a/tests/expectations/rename_tag.compat.c +++ b/tests/expectations/rename_tag.compat.c @@ -17,6 +17,7 @@ enum C_E typedef uint8_t C_E; #endif // __cplusplus + struct C_A; struct C_C; diff --git a/tests/expectations/rename_tag.pyx b/tests/expectations/rename_tag.pyx index e9abd0fb..90e1f4df 100644 --- a/tests/expectations/rename_tag.pyx +++ b/tests/expectations/rename_tag.pyx @@ -13,6 +13,7 @@ cdef extern from *: y # = 1, ctypedef uint8_t C_E; + cdef struct C_A: pass diff --git a/tests/expectations/reserved.c b/tests/expectations/reserved.c index d4c81c60..6901a4c8 100644 --- a/tests/expectations/reserved.c +++ b/tests/expectations/reserved.c @@ -17,12 +17,13 @@ enum C_Tag { D, }; typedef uint8_t C_Tag; - typedef struct { int32_t namespace_; float float_; } D_Body; + + typedef struct { C_Tag tag; union { @@ -36,6 +37,7 @@ enum E_Tag { }; typedef uint8_t E_Tag; + typedef struct { E_Tag tag; union { @@ -54,6 +56,7 @@ enum F_Tag { }; typedef uint8_t F_Tag; + typedef struct { F_Tag tag; union { diff --git a/tests/expectations/reserved.compat.c b/tests/expectations/reserved.compat.c index ecdade3c..5036e727 100644 --- a/tests/expectations/reserved.compat.c +++ b/tests/expectations/reserved.compat.c @@ -23,12 +23,13 @@ enum C_Tag #ifndef __cplusplus typedef uint8_t C_Tag; #endif // __cplusplus - typedef struct { int32_t namespace_; float float_; } D_Body; + + typedef struct { C_Tag tag; union { @@ -48,6 +49,7 @@ enum E_Tag typedef uint8_t E_Tag; #endif // __cplusplus + typedef struct { E_Tag tag; union { @@ -72,6 +74,7 @@ enum F_Tag typedef uint8_t F_Tag; #endif // __cplusplus + typedef struct { F_Tag tag; union { diff --git a/tests/expectations/reserved.cpp b/tests/expectations/reserved.cpp index 4883eb2a..d56c96f3 100644 --- a/tests/expectations/reserved.cpp +++ b/tests/expectations/reserved.cpp @@ -18,12 +18,13 @@ struct C { enum class Tag : uint8_t { D, }; - struct D_Body { int32_t namespace_; float float_; }; + + Tag tag; union { D_Body d; @@ -35,7 +36,6 @@ struct E { Double, Float, }; - struct Double_Body { double _0; }; @@ -44,6 +44,8 @@ struct E { float _0; }; + + Tag tag; union { Double_Body double_; @@ -56,7 +58,6 @@ struct F { double_, float_, }; - struct double_Body { double _0; }; @@ -65,6 +66,8 @@ struct F { float _0; }; + + Tag tag; union { double_Body double_; diff --git a/tests/expectations/reserved.pyx b/tests/expectations/reserved.pyx index 65e0da93..d1c6a2ed 100644 --- a/tests/expectations/reserved.pyx +++ b/tests/expectations/reserved.pyx @@ -17,11 +17,12 @@ cdef extern from *: cdef enum: D, ctypedef uint8_t C_Tag; - ctypedef struct D_Body: int32_t namespace_; float float_; + + ctypedef struct C: C_Tag tag; D_Body d; @@ -31,6 +32,7 @@ cdef extern from *: Float, ctypedef uint8_t E_Tag; + ctypedef struct E: E_Tag tag; double double_; @@ -41,6 +43,7 @@ cdef extern from *: float_, ctypedef uint8_t F_Tag; + ctypedef struct F: F_Tag tag; double double_; diff --git a/tests/expectations/reserved_both.c b/tests/expectations/reserved_both.c index ce7d6e42..7bf9dd28 100644 --- a/tests/expectations/reserved_both.c +++ b/tests/expectations/reserved_both.c @@ -17,12 +17,13 @@ enum C_Tag { D, }; typedef uint8_t C_Tag; - typedef struct D_Body { int32_t namespace_; float float_; } D_Body; + + typedef struct C { C_Tag tag; union { @@ -36,6 +37,7 @@ enum E_Tag { }; typedef uint8_t E_Tag; + typedef struct E { E_Tag tag; union { @@ -54,6 +56,7 @@ enum F_Tag { }; typedef uint8_t F_Tag; + typedef struct F { F_Tag tag; union { diff --git a/tests/expectations/reserved_both.compat.c b/tests/expectations/reserved_both.compat.c index 702a1b7e..b4941d87 100644 --- a/tests/expectations/reserved_both.compat.c +++ b/tests/expectations/reserved_both.compat.c @@ -23,12 +23,13 @@ enum C_Tag #ifndef __cplusplus typedef uint8_t C_Tag; #endif // __cplusplus - typedef struct D_Body { int32_t namespace_; float float_; } D_Body; + + typedef struct C { C_Tag tag; union { @@ -48,6 +49,7 @@ enum E_Tag typedef uint8_t E_Tag; #endif // __cplusplus + typedef struct E { E_Tag tag; union { @@ -72,6 +74,7 @@ enum F_Tag typedef uint8_t F_Tag; #endif // __cplusplus + typedef struct F { F_Tag tag; union { diff --git a/tests/expectations/reserved_tag.c b/tests/expectations/reserved_tag.c index d81f89e8..b336b8ce 100644 --- a/tests/expectations/reserved_tag.c +++ b/tests/expectations/reserved_tag.c @@ -17,12 +17,13 @@ enum C_Tag { D, }; typedef uint8_t C_Tag; - struct D_Body { int32_t namespace_; float float_; }; + + struct C { C_Tag tag; union { @@ -36,6 +37,7 @@ enum E_Tag { }; typedef uint8_t E_Tag; + struct E { E_Tag tag; union { @@ -54,6 +56,7 @@ enum F_Tag { }; typedef uint8_t F_Tag; + struct F { F_Tag tag; union { diff --git a/tests/expectations/reserved_tag.compat.c b/tests/expectations/reserved_tag.compat.c index 0ce3ee23..fff15019 100644 --- a/tests/expectations/reserved_tag.compat.c +++ b/tests/expectations/reserved_tag.compat.c @@ -23,12 +23,13 @@ enum C_Tag #ifndef __cplusplus typedef uint8_t C_Tag; #endif // __cplusplus - struct D_Body { int32_t namespace_; float float_; }; + + struct C { C_Tag tag; union { @@ -48,6 +49,7 @@ enum E_Tag typedef uint8_t E_Tag; #endif // __cplusplus + struct E { E_Tag tag; union { @@ -72,6 +74,7 @@ enum F_Tag typedef uint8_t F_Tag; #endif // __cplusplus + struct F { F_Tag tag; union { diff --git a/tests/expectations/reserved_tag.pyx b/tests/expectations/reserved_tag.pyx index b3aefece..15749812 100644 --- a/tests/expectations/reserved_tag.pyx +++ b/tests/expectations/reserved_tag.pyx @@ -17,11 +17,12 @@ cdef extern from *: cdef enum: D, ctypedef uint8_t C_Tag; - cdef struct D_Body: int32_t namespace_; float float_; + + cdef struct C: C_Tag tag; D_Body d; @@ -31,6 +32,7 @@ cdef extern from *: Float, ctypedef uint8_t E_Tag; + cdef struct E: E_Tag tag; double double_; @@ -41,6 +43,7 @@ cdef extern from *: float_, ctypedef uint8_t F_Tag; + cdef struct F: F_Tag tag; double double_; diff --git a/tests/expectations/sentinel.c b/tests/expectations/sentinel.c index 27057f3a..c7414aa5 100644 --- a/tests/expectations/sentinel.c +++ b/tests/expectations/sentinel.c @@ -14,6 +14,7 @@ enum A { }; typedef uint8_t A; + enum B { B_B1, B_B2, @@ -25,6 +26,7 @@ enum B { }; typedef uint8_t B; + enum C_Tag { C_C1, C_C2, @@ -35,7 +37,6 @@ enum C_Tag { C_Sentinel, }; typedef uint8_t C_Tag; - typedef struct { C_Tag tag; uint32_t a; @@ -46,6 +47,8 @@ typedef struct { uint32_t b; } C_C2_Body; + + typedef union { C_Tag tag; C_C1_Body c1; diff --git a/tests/expectations/sentinel.compat.c b/tests/expectations/sentinel.compat.c index 124b06e8..6f813517 100644 --- a/tests/expectations/sentinel.compat.c +++ b/tests/expectations/sentinel.compat.c @@ -20,6 +20,7 @@ enum A typedef uint8_t A; #endif // __cplusplus + enum B #ifdef __cplusplus : uint8_t @@ -37,6 +38,7 @@ enum B typedef uint8_t B; #endif // __cplusplus + enum C_Tag #ifdef __cplusplus : uint8_t @@ -53,7 +55,6 @@ enum C_Tag #ifndef __cplusplus typedef uint8_t C_Tag; #endif // __cplusplus - typedef struct { C_Tag tag; uint32_t a; @@ -64,6 +65,8 @@ typedef struct { uint32_t b; } C_C2_Body; + + typedef union { C_Tag tag; C_C1_Body c1; diff --git a/tests/expectations/sentinel.cpp b/tests/expectations/sentinel.cpp index db0a5e61..166fd60b 100644 --- a/tests/expectations/sentinel.cpp +++ b/tests/expectations/sentinel.cpp @@ -12,6 +12,7 @@ enum class A : uint8_t { A_Sentinel, }; + enum class B : uint8_t { B_B1, B_B2, @@ -20,6 +21,7 @@ enum class B : uint8_t { B_Sentinel, }; + union C { enum class Tag : uint8_t { C_C1, @@ -28,7 +30,6 @@ union C { /// Must be last for serialization purposes C_Sentinel, }; - struct C_C1_Body { Tag tag; uint32_t a; @@ -39,6 +40,8 @@ union C { uint32_t b; }; + + struct { Tag tag; }; diff --git a/tests/expectations/sentinel.pyx b/tests/expectations/sentinel.pyx index 828705d0..62673563 100644 --- a/tests/expectations/sentinel.pyx +++ b/tests/expectations/sentinel.pyx @@ -14,6 +14,7 @@ cdef extern from *: A_Sentinel, ctypedef uint8_t A; + cdef enum: B_B1, B_B2, @@ -22,6 +23,7 @@ cdef extern from *: B_Sentinel, ctypedef uint8_t B; + cdef enum: C_C1, C_C2, @@ -29,7 +31,6 @@ cdef extern from *: # Must be last for serialization purposes C_Sentinel, ctypedef uint8_t C_Tag; - ctypedef struct C_C1_Body: C_Tag tag; uint32_t a; @@ -38,6 +39,8 @@ cdef extern from *: C_Tag tag; uint32_t b; + + ctypedef union C: C_Tag tag; C_C1_Body c1; diff --git a/tests/expectations/sentinel_both.c b/tests/expectations/sentinel_both.c index 0ffb5afe..24550ab2 100644 --- a/tests/expectations/sentinel_both.c +++ b/tests/expectations/sentinel_both.c @@ -14,6 +14,7 @@ enum A { }; typedef uint8_t A; + enum B { B_B1, B_B2, @@ -25,6 +26,7 @@ enum B { }; typedef uint8_t B; + enum C_Tag { C_C1, C_C2, @@ -35,7 +37,6 @@ enum C_Tag { C_Sentinel, }; typedef uint8_t C_Tag; - typedef struct C_C1_Body { C_Tag tag; uint32_t a; @@ -46,6 +47,8 @@ typedef struct C_C2_Body { uint32_t b; } C_C2_Body; + + typedef union C { C_Tag tag; C_C1_Body c1; diff --git a/tests/expectations/sentinel_both.compat.c b/tests/expectations/sentinel_both.compat.c index ac26146d..76c66d32 100644 --- a/tests/expectations/sentinel_both.compat.c +++ b/tests/expectations/sentinel_both.compat.c @@ -20,6 +20,7 @@ enum A typedef uint8_t A; #endif // __cplusplus + enum B #ifdef __cplusplus : uint8_t @@ -37,6 +38,7 @@ enum B typedef uint8_t B; #endif // __cplusplus + enum C_Tag #ifdef __cplusplus : uint8_t @@ -53,7 +55,6 @@ enum C_Tag #ifndef __cplusplus typedef uint8_t C_Tag; #endif // __cplusplus - typedef struct C_C1_Body { C_Tag tag; uint32_t a; @@ -64,6 +65,8 @@ typedef struct C_C2_Body { uint32_t b; } C_C2_Body; + + typedef union C { C_Tag tag; C_C1_Body c1; diff --git a/tests/expectations/sentinel_tag.c b/tests/expectations/sentinel_tag.c index 8e376e63..71984ce7 100644 --- a/tests/expectations/sentinel_tag.c +++ b/tests/expectations/sentinel_tag.c @@ -14,6 +14,7 @@ enum A { }; typedef uint8_t A; + enum B { B_B1, B_B2, @@ -25,6 +26,7 @@ enum B { }; typedef uint8_t B; + enum C_Tag { C_C1, C_C2, @@ -35,7 +37,6 @@ enum C_Tag { C_Sentinel, }; typedef uint8_t C_Tag; - struct C_C1_Body { C_Tag tag; uint32_t a; @@ -46,6 +47,8 @@ struct C_C2_Body { uint32_t b; }; + + union C { C_Tag tag; struct C_C1_Body c1; diff --git a/tests/expectations/sentinel_tag.compat.c b/tests/expectations/sentinel_tag.compat.c index e4dac92b..e4b49922 100644 --- a/tests/expectations/sentinel_tag.compat.c +++ b/tests/expectations/sentinel_tag.compat.c @@ -20,6 +20,7 @@ enum A typedef uint8_t A; #endif // __cplusplus + enum B #ifdef __cplusplus : uint8_t @@ -37,6 +38,7 @@ enum B typedef uint8_t B; #endif // __cplusplus + enum C_Tag #ifdef __cplusplus : uint8_t @@ -53,7 +55,6 @@ enum C_Tag #ifndef __cplusplus typedef uint8_t C_Tag; #endif // __cplusplus - struct C_C1_Body { C_Tag tag; uint32_t a; @@ -64,6 +65,8 @@ struct C_C2_Body { uint32_t b; }; + + union C { C_Tag tag; struct C_C1_Body c1; diff --git a/tests/expectations/sentinel_tag.pyx b/tests/expectations/sentinel_tag.pyx index e68c9d2a..ba83135d 100644 --- a/tests/expectations/sentinel_tag.pyx +++ b/tests/expectations/sentinel_tag.pyx @@ -14,6 +14,7 @@ cdef extern from *: A_Sentinel, ctypedef uint8_t A; + cdef enum: B_B1, B_B2, @@ -22,6 +23,7 @@ cdef extern from *: B_Sentinel, ctypedef uint8_t B; + cdef enum: C_C1, C_C2, @@ -29,7 +31,6 @@ cdef extern from *: # Must be last for serialization purposes C_Sentinel, ctypedef uint8_t C_Tag; - cdef struct C_C1_Body: C_Tag tag; uint32_t a; @@ -38,6 +39,8 @@ cdef extern from *: C_Tag tag; uint32_t b; + + cdef union C: C_Tag tag; C_C1_Body c1; diff --git a/tests/expectations/size_types.c b/tests/expectations/size_types.c index b3b64c0f..45ab6fd1 100644 --- a/tests/expectations/size_types.c +++ b/tests/expectations/size_types.c @@ -9,11 +9,13 @@ enum IE { }; typedef ptrdiff_t IE; + enum UE { UV, }; typedef size_t UE; + typedef size_t Usize; typedef ptrdiff_t Isize; diff --git a/tests/expectations/size_types.compat.c b/tests/expectations/size_types.compat.c index 4ca5273c..d29c6cbf 100644 --- a/tests/expectations/size_types.compat.c +++ b/tests/expectations/size_types.compat.c @@ -15,6 +15,7 @@ enum IE typedef ptrdiff_t IE; #endif // __cplusplus + enum UE #ifdef __cplusplus : size_t @@ -26,6 +27,7 @@ enum UE typedef size_t UE; #endif // __cplusplus + typedef size_t Usize; typedef ptrdiff_t Isize; diff --git a/tests/expectations/size_types.cpp b/tests/expectations/size_types.cpp index ce7b41cc..5835b22e 100644 --- a/tests/expectations/size_types.cpp +++ b/tests/expectations/size_types.cpp @@ -9,10 +9,12 @@ enum class IE : ptrdiff_t { IV, }; + enum class UE : size_t { UV, }; + using Usize = size_t; using Isize = ptrdiff_t; diff --git a/tests/expectations/size_types.pyx b/tests/expectations/size_types.pyx index c08b7c65..afbcb19a 100644 --- a/tests/expectations/size_types.pyx +++ b/tests/expectations/size_types.pyx @@ -10,10 +10,12 @@ cdef extern from *: IV, ctypedef ptrdiff_t IE; + cdef enum: UV, ctypedef size_t UE; + ctypedef size_t Usize; ctypedef ptrdiff_t Isize; diff --git a/tests/expectations/transform_op.c b/tests/expectations/transform_op.c index 640ba550..8b1299b2 100644 --- a/tests/expectations/transform_op.c +++ b/tests/expectations/transform_op.c @@ -20,7 +20,6 @@ enum StyleFoo_i32_Tag { Bazz_i32, }; typedef uint8_t StyleFoo_i32_Tag; - typedef struct { StyleFoo_i32_Tag tag; int32_t x; @@ -28,6 +27,8 @@ typedef struct { StylePoint_f32 z; } StyleFoo_Body_i32; + + typedef union { StyleFoo_i32_Tag tag; StyleFoo_Body_i32 foo; @@ -46,15 +47,15 @@ typedef enum { Bar2_i32, Bar3_i32, Bar4_i32, -} StyleBar_i32_Tag; - -typedef struct { +} StyleBar_i32_Tag;typedef struct { int32_t x; StylePoint_i32 y; StylePoint_f32 z; int32_t (*u)(int32_t); } StyleBar1_Body_i32; + + typedef struct { StyleBar_i32_Tag tag; union { @@ -78,15 +79,15 @@ typedef enum { Bar2_u32, Bar3_u32, Bar4_u32, -} StyleBar_u32_Tag; - -typedef struct { +} StyleBar_u32_Tag;typedef struct { int32_t x; StylePoint_u32 y; StylePoint_f32 z; int32_t (*u)(int32_t); } StyleBar1_Body_u32; + + typedef struct { StyleBar_u32_Tag tag; union { @@ -107,6 +108,7 @@ enum StyleBaz_Tag { }; typedef uint8_t StyleBaz_Tag; + typedef union { StyleBaz_Tag tag; struct { @@ -126,6 +128,7 @@ enum StyleTaz_Tag { }; typedef uint8_t StyleTaz_Tag; + typedef struct { StyleTaz_Tag tag; union { diff --git a/tests/expectations/transform_op.compat.c b/tests/expectations/transform_op.compat.c index 8608b43b..29a9e9c9 100644 --- a/tests/expectations/transform_op.compat.c +++ b/tests/expectations/transform_op.compat.c @@ -26,7 +26,6 @@ enum StyleFoo_i32_Tag #ifndef __cplusplus typedef uint8_t StyleFoo_i32_Tag; #endif // __cplusplus - typedef struct { StyleFoo_i32_Tag tag; int32_t x; @@ -34,6 +33,8 @@ typedef struct { StylePoint_f32 z; } StyleFoo_Body_i32; + + typedef union { StyleFoo_i32_Tag tag; StyleFoo_Body_i32 foo; @@ -52,15 +53,15 @@ typedef enum { Bar2_i32, Bar3_i32, Bar4_i32, -} StyleBar_i32_Tag; - -typedef struct { +} StyleBar_i32_Tag;typedef struct { int32_t x; StylePoint_i32 y; StylePoint_f32 z; int32_t (*u)(int32_t); } StyleBar1_Body_i32; + + typedef struct { StyleBar_i32_Tag tag; union { @@ -84,15 +85,15 @@ typedef enum { Bar2_u32, Bar3_u32, Bar4_u32, -} StyleBar_u32_Tag; - -typedef struct { +} StyleBar_u32_Tag;typedef struct { int32_t x; StylePoint_u32 y; StylePoint_f32 z; int32_t (*u)(int32_t); } StyleBar1_Body_u32; + + typedef struct { StyleBar_u32_Tag tag; union { @@ -119,6 +120,7 @@ enum StyleBaz_Tag typedef uint8_t StyleBaz_Tag; #endif // __cplusplus + typedef union { StyleBaz_Tag tag; struct { @@ -144,6 +146,7 @@ enum StyleTaz_Tag typedef uint8_t StyleTaz_Tag; #endif // __cplusplus + typedef struct { StyleTaz_Tag tag; union { diff --git a/tests/expectations/transform_op.cpp b/tests/expectations/transform_op.cpp index 2d070ba4..0bc5ceb0 100644 --- a/tests/expectations/transform_op.cpp +++ b/tests/expectations/transform_op.cpp @@ -19,7 +19,6 @@ union StyleFoo { Baz, Bazz, }; - struct Foo_Body { Tag tag; int32_t x; @@ -37,6 +36,8 @@ union StyleFoo { StylePoint _0; }; + + struct { Tag tag; }; @@ -129,9 +130,7 @@ struct StyleBar { Bar2, Bar3, Bar4, - }; - - struct StyleBar1_Body { + };struct StyleBar1_Body { int32_t x; StylePoint y; StylePoint z; @@ -146,6 +145,8 @@ struct StyleBar { StylePoint _0; }; + + Tag tag; union { StyleBar1_Body bar1; @@ -239,7 +240,6 @@ union StyleBaz { Baz2, Baz3, }; - struct Baz1_Body { Tag tag; StyleBar _0; @@ -250,6 +250,8 @@ union StyleBaz { StylePoint _0; }; + + struct { Tag tag; }; @@ -315,7 +317,6 @@ struct StyleTaz { Taz2, Taz3, }; - struct StyleTaz1_Body { StyleBar _0; }; @@ -324,6 +325,8 @@ struct StyleTaz { StyleBaz _0; }; + + Tag tag; union { StyleTaz1_Body taz1; diff --git a/tests/expectations/transform_op.pyx b/tests/expectations/transform_op.pyx index c35fb427..84135e0d 100644 --- a/tests/expectations/transform_op.pyx +++ b/tests/expectations/transform_op.pyx @@ -20,13 +20,14 @@ cdef extern from *: Baz_i32, Bazz_i32, ctypedef uint8_t StyleFoo_i32_Tag; - ctypedef struct StyleFoo_Body_i32: StyleFoo_i32_Tag tag; int32_t x; StylePoint_i32 y; StylePoint_f32 z; + + ctypedef union StyleFoo_i32: StyleFoo_i32_Tag tag; StyleFoo_Body_i32 foo; @@ -38,13 +39,14 @@ cdef extern from *: Bar2_i32, Bar3_i32, Bar4_i32, - ctypedef struct StyleBar1_Body_i32: int32_t x; StylePoint_i32 y; StylePoint_f32 z; int32_t (*u)(int32_t); + + ctypedef struct StyleBar_i32: StyleBar_i32_Tag tag; StyleBar1_Body_i32 bar1; @@ -60,13 +62,14 @@ cdef extern from *: Bar2_u32, Bar3_u32, Bar4_u32, - ctypedef struct StyleBar1_Body_u32: int32_t x; StylePoint_u32 y; StylePoint_f32 z; int32_t (*u)(int32_t); + + ctypedef struct StyleBar_u32: StyleBar_u32_Tag tag; StyleBar1_Body_u32 bar1; @@ -79,6 +82,7 @@ cdef extern from *: Baz3, ctypedef uint8_t StyleBaz_Tag; + ctypedef union StyleBaz: StyleBaz_Tag tag; StyleBar_u32 baz1; @@ -90,6 +94,7 @@ cdef extern from *: Taz3, ctypedef uint8_t StyleTaz_Tag; + ctypedef struct StyleTaz: StyleTaz_Tag tag; StyleBar_u32 taz1; diff --git a/tests/expectations/transform_op_both.c b/tests/expectations/transform_op_both.c index e9605c39..4a8fac6c 100644 --- a/tests/expectations/transform_op_both.c +++ b/tests/expectations/transform_op_both.c @@ -20,7 +20,6 @@ enum StyleFoo_i32_Tag { Bazz_i32, }; typedef uint8_t StyleFoo_i32_Tag; - typedef struct StyleFoo_Body_i32 { StyleFoo_i32_Tag tag; int32_t x; @@ -28,6 +27,8 @@ typedef struct StyleFoo_Body_i32 { struct StylePoint_f32 z; } StyleFoo_Body_i32; + + typedef union StyleFoo_i32 { StyleFoo_i32_Tag tag; StyleFoo_Body_i32 foo; @@ -46,15 +47,15 @@ typedef enum StyleBar_i32_Tag { Bar2_i32, Bar3_i32, Bar4_i32, -} StyleBar_i32_Tag; - -typedef struct StyleBar1_Body_i32 { +} StyleBar_i32_Tag;typedef struct StyleBar1_Body_i32 { int32_t x; struct StylePoint_i32 y; struct StylePoint_f32 z; int32_t (*u)(int32_t); } StyleBar1_Body_i32; + + typedef struct StyleBar_i32 { StyleBar_i32_Tag tag; union { @@ -78,15 +79,15 @@ typedef enum StyleBar_u32_Tag { Bar2_u32, Bar3_u32, Bar4_u32, -} StyleBar_u32_Tag; - -typedef struct StyleBar1_Body_u32 { +} StyleBar_u32_Tag;typedef struct StyleBar1_Body_u32 { int32_t x; struct StylePoint_u32 y; struct StylePoint_f32 z; int32_t (*u)(int32_t); } StyleBar1_Body_u32; + + typedef struct StyleBar_u32 { StyleBar_u32_Tag tag; union { @@ -107,6 +108,7 @@ enum StyleBaz_Tag { }; typedef uint8_t StyleBaz_Tag; + typedef union StyleBaz { StyleBaz_Tag tag; struct { @@ -126,6 +128,7 @@ enum StyleTaz_Tag { }; typedef uint8_t StyleTaz_Tag; + typedef struct StyleTaz { StyleTaz_Tag tag; union { diff --git a/tests/expectations/transform_op_both.compat.c b/tests/expectations/transform_op_both.compat.c index d4ab94d3..55fbed81 100644 --- a/tests/expectations/transform_op_both.compat.c +++ b/tests/expectations/transform_op_both.compat.c @@ -26,7 +26,6 @@ enum StyleFoo_i32_Tag #ifndef __cplusplus typedef uint8_t StyleFoo_i32_Tag; #endif // __cplusplus - typedef struct StyleFoo_Body_i32 { StyleFoo_i32_Tag tag; int32_t x; @@ -34,6 +33,8 @@ typedef struct StyleFoo_Body_i32 { struct StylePoint_f32 z; } StyleFoo_Body_i32; + + typedef union StyleFoo_i32 { StyleFoo_i32_Tag tag; StyleFoo_Body_i32 foo; @@ -52,15 +53,15 @@ typedef enum StyleBar_i32_Tag { Bar2_i32, Bar3_i32, Bar4_i32, -} StyleBar_i32_Tag; - -typedef struct StyleBar1_Body_i32 { +} StyleBar_i32_Tag;typedef struct StyleBar1_Body_i32 { int32_t x; struct StylePoint_i32 y; struct StylePoint_f32 z; int32_t (*u)(int32_t); } StyleBar1_Body_i32; + + typedef struct StyleBar_i32 { StyleBar_i32_Tag tag; union { @@ -84,15 +85,15 @@ typedef enum StyleBar_u32_Tag { Bar2_u32, Bar3_u32, Bar4_u32, -} StyleBar_u32_Tag; - -typedef struct StyleBar1_Body_u32 { +} StyleBar_u32_Tag;typedef struct StyleBar1_Body_u32 { int32_t x; struct StylePoint_u32 y; struct StylePoint_f32 z; int32_t (*u)(int32_t); } StyleBar1_Body_u32; + + typedef struct StyleBar_u32 { StyleBar_u32_Tag tag; union { @@ -119,6 +120,7 @@ enum StyleBaz_Tag typedef uint8_t StyleBaz_Tag; #endif // __cplusplus + typedef union StyleBaz { StyleBaz_Tag tag; struct { @@ -144,6 +146,7 @@ enum StyleTaz_Tag typedef uint8_t StyleTaz_Tag; #endif // __cplusplus + typedef struct StyleTaz { StyleTaz_Tag tag; union { diff --git a/tests/expectations/transform_op_tag.c b/tests/expectations/transform_op_tag.c index a97d4ae3..0bed0d4a 100644 --- a/tests/expectations/transform_op_tag.c +++ b/tests/expectations/transform_op_tag.c @@ -20,7 +20,6 @@ enum StyleFoo_i32_Tag { Bazz_i32, }; typedef uint8_t StyleFoo_i32_Tag; - struct StyleFoo_Body_i32 { StyleFoo_i32_Tag tag; int32_t x; @@ -28,6 +27,8 @@ struct StyleFoo_Body_i32 { struct StylePoint_f32 z; }; + + union StyleFoo_i32 { StyleFoo_i32_Tag tag; struct StyleFoo_Body_i32 foo; @@ -46,15 +47,15 @@ enum StyleBar_i32_Tag { Bar2_i32, Bar3_i32, Bar4_i32, -}; - -struct StyleBar1_Body_i32 { +};struct StyleBar1_Body_i32 { int32_t x; struct StylePoint_i32 y; struct StylePoint_f32 z; int32_t (*u)(int32_t); }; + + struct StyleBar_i32 { enum StyleBar_i32_Tag tag; union { @@ -78,15 +79,15 @@ enum StyleBar_u32_Tag { Bar2_u32, Bar3_u32, Bar4_u32, -}; - -struct StyleBar1_Body_u32 { +};struct StyleBar1_Body_u32 { int32_t x; struct StylePoint_u32 y; struct StylePoint_f32 z; int32_t (*u)(int32_t); }; + + struct StyleBar_u32 { enum StyleBar_u32_Tag tag; union { @@ -107,6 +108,7 @@ enum StyleBaz_Tag { }; typedef uint8_t StyleBaz_Tag; + union StyleBaz { StyleBaz_Tag tag; struct { @@ -126,6 +128,7 @@ enum StyleTaz_Tag { }; typedef uint8_t StyleTaz_Tag; + struct StyleTaz { StyleTaz_Tag tag; union { diff --git a/tests/expectations/transform_op_tag.compat.c b/tests/expectations/transform_op_tag.compat.c index 3e6c48d8..cc38144e 100644 --- a/tests/expectations/transform_op_tag.compat.c +++ b/tests/expectations/transform_op_tag.compat.c @@ -26,7 +26,6 @@ enum StyleFoo_i32_Tag #ifndef __cplusplus typedef uint8_t StyleFoo_i32_Tag; #endif // __cplusplus - struct StyleFoo_Body_i32 { StyleFoo_i32_Tag tag; int32_t x; @@ -34,6 +33,8 @@ struct StyleFoo_Body_i32 { struct StylePoint_f32 z; }; + + union StyleFoo_i32 { StyleFoo_i32_Tag tag; struct StyleFoo_Body_i32 foo; @@ -52,15 +53,15 @@ enum StyleBar_i32_Tag { Bar2_i32, Bar3_i32, Bar4_i32, -}; - -struct StyleBar1_Body_i32 { +};struct StyleBar1_Body_i32 { int32_t x; struct StylePoint_i32 y; struct StylePoint_f32 z; int32_t (*u)(int32_t); }; + + struct StyleBar_i32 { enum StyleBar_i32_Tag tag; union { @@ -84,15 +85,15 @@ enum StyleBar_u32_Tag { Bar2_u32, Bar3_u32, Bar4_u32, -}; - -struct StyleBar1_Body_u32 { +};struct StyleBar1_Body_u32 { int32_t x; struct StylePoint_u32 y; struct StylePoint_f32 z; int32_t (*u)(int32_t); }; + + struct StyleBar_u32 { enum StyleBar_u32_Tag tag; union { @@ -119,6 +120,7 @@ enum StyleBaz_Tag typedef uint8_t StyleBaz_Tag; #endif // __cplusplus + union StyleBaz { StyleBaz_Tag tag; struct { @@ -144,6 +146,7 @@ enum StyleTaz_Tag typedef uint8_t StyleTaz_Tag; #endif // __cplusplus + struct StyleTaz { StyleTaz_Tag tag; union { diff --git a/tests/expectations/transform_op_tag.pyx b/tests/expectations/transform_op_tag.pyx index 5831bdbd..c0d8a5e9 100644 --- a/tests/expectations/transform_op_tag.pyx +++ b/tests/expectations/transform_op_tag.pyx @@ -20,13 +20,14 @@ cdef extern from *: Baz_i32, Bazz_i32, ctypedef uint8_t StyleFoo_i32_Tag; - cdef struct StyleFoo_Body_i32: StyleFoo_i32_Tag tag; int32_t x; StylePoint_i32 y; StylePoint_f32 z; + + cdef union StyleFoo_i32: StyleFoo_i32_Tag tag; StyleFoo_Body_i32 foo; @@ -38,13 +39,14 @@ cdef extern from *: Bar2_i32, Bar3_i32, Bar4_i32, - cdef struct StyleBar1_Body_i32: int32_t x; StylePoint_i32 y; StylePoint_f32 z; int32_t (*u)(int32_t); + + cdef struct StyleBar_i32: StyleBar_i32_Tag tag; StyleBar1_Body_i32 bar1; @@ -60,13 +62,14 @@ cdef extern from *: Bar2_u32, Bar3_u32, Bar4_u32, - cdef struct StyleBar1_Body_u32: int32_t x; StylePoint_u32 y; StylePoint_f32 z; int32_t (*u)(int32_t); + + cdef struct StyleBar_u32: StyleBar_u32_Tag tag; StyleBar1_Body_u32 bar1; @@ -79,6 +82,7 @@ cdef extern from *: Baz3, ctypedef uint8_t StyleBaz_Tag; + cdef union StyleBaz: StyleBaz_Tag tag; StyleBar_u32 baz1; @@ -90,6 +94,7 @@ cdef extern from *: Taz3, ctypedef uint8_t StyleTaz_Tag; + cdef struct StyleTaz: StyleTaz_Tag tag; StyleBar_u32 taz1; diff --git a/tests/rust/merge_generic_tags.rs b/tests/rust/merge_generic_tags.rs new file mode 100644 index 00000000..d82164c0 --- /dev/null +++ b/tests/rust/merge_generic_tags.rs @@ -0,0 +1,8 @@ +#[repr(C)] +pub enum COption { + Some(T), + None, +} + +#[no_mangle] +pub extern "C" fn root(a: COption, b: COption) {} diff --git a/tests/rust/merge_generic_tags.toml b/tests/rust/merge_generic_tags.toml new file mode 100644 index 00000000..5014534d --- /dev/null +++ b/tests/rust/merge_generic_tags.toml @@ -0,0 +1,2 @@ +[enum] +merge_generic_tags = true diff --git a/tests/rust/merge_generic_tags_export_prefix.rs b/tests/rust/merge_generic_tags_export_prefix.rs new file mode 100644 index 00000000..7b587892 --- /dev/null +++ b/tests/rust/merge_generic_tags_export_prefix.rs @@ -0,0 +1,43 @@ +#[repr(C)] +pub enum CResult { + Ok(T), + Err(E), +} + +#[repr(C)] +pub enum COption { + Some(T), + None, +} + +#[repr(C)] +pub struct ErrorInfo { + code: i32, + message: *const u8, +} + +#[no_mangle] +pub extern "C" fn process_result(r: CResult) -> COption { + match r { + CResult::Ok(val) => COption::Some(val), + CResult::Err(_) => COption::None, + } +} + +#[no_mangle] +pub extern "C" fn process_str_result(r: CResult<*const u8, i32>) -> COption<*const u8> { + match r { + CResult::Ok(val) => COption::Some(val), + CResult::Err(_) => COption::None, + } +} + +#[no_mangle] +pub extern "C" fn get_option_int() -> COption { + COption::Some(42) +} + +#[no_mangle] +pub extern "C" fn get_option_str() -> COption<*const u8> { + COption::None +} \ No newline at end of file diff --git a/tests/rust/merge_generic_tags_export_prefix.toml b/tests/rust/merge_generic_tags_export_prefix.toml new file mode 100644 index 00000000..8dcbc076 --- /dev/null +++ b/tests/rust/merge_generic_tags_export_prefix.toml @@ -0,0 +1,7 @@ +[export] +prefix = "Prefix_" + +[enum] +merge_generic_tags = true +prefix_with_name = true +rename_variants = "ScreamingSnakeCase" \ No newline at end of file diff --git a/tests/rust/merge_generic_tags_with_prefix.rs b/tests/rust/merge_generic_tags_with_prefix.rs new file mode 100644 index 00000000..d82164c0 --- /dev/null +++ b/tests/rust/merge_generic_tags_with_prefix.rs @@ -0,0 +1,8 @@ +#[repr(C)] +pub enum COption { + Some(T), + None, +} + +#[no_mangle] +pub extern "C" fn root(a: COption, b: COption) {} diff --git a/tests/rust/merge_generic_tags_with_prefix.toml b/tests/rust/merge_generic_tags_with_prefix.toml new file mode 100644 index 00000000..57e15f6c --- /dev/null +++ b/tests/rust/merge_generic_tags_with_prefix.toml @@ -0,0 +1,3 @@ +[enum] +merge_generic_tags = true +prefix_with_name = true