diff --git a/crates/objc2-encode/src/encoding.rs b/crates/objc2-encode/src/encoding.rs index 0404f5b61..ebdf6a16d 100644 --- a/crates/objc2-encode/src/encoding.rs +++ b/crates/objc2-encode/src/encoding.rs @@ -129,13 +129,13 @@ pub enum Encoding { /// It is not uncommon for the name to be `"?"`. /// /// Corresponds to the `"{" name "=" fields... "}"` code. - Struct(&'static str, &'static [Encoding]), + Struct(&'static str, Option<&'static [Encoding]>), /// A union with the given name and fields. /// /// The order of the fields must match the order of the order in this. /// /// Corresponds to the `"(" name "=" fields... ")"` code. - Union(&'static str, &'static [Encoding]), + Union(&'static str, Option<&'static [Encoding]>), // TODO: "Vector" types have the '!' encoding, but are not implemented in // clang @@ -560,6 +560,13 @@ mod tests { Encoding::Struct("_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", &[]); "{_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789=}"; } + + fn cgl_context_obj() { + Encoding::Pointer(&Encoding::Struct("_CGLContextObject", &[])); + "^{_CGLContextObject=}"; + "^{_CGLContextObject=^{__GLIContextRec}{__GLIFunctionDispatchRec=^?^?^?^?^?}^{_CGLPrivateObject}^v}"; + !"^{SomeOtherStruct=}"; + } } #[test] diff --git a/crates/objc2-encode/src/helper.rs b/crates/objc2-encode/src/helper.rs index aa0a09258..174786cb5 100644 --- a/crates/objc2-encode/src/helper.rs +++ b/crates/objc2-encode/src/helper.rs @@ -126,7 +126,7 @@ pub(crate) fn compare_encodings( // Note that this may be confusing, since a `Pointer` to // the two containers might suddenly start comparing // equal, but - _ => false, + _ => true, } } (_, _) => false,