Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Oct 24, 2023
1 parent 2ad20c3 commit 05e6906
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions crates/objc2-encode/src/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion crates/objc2-encode/src/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ pub(crate) fn compare_encodings<E1: EncodingType, E2: EncodingType>(
// Note that this may be confusing, since a `Pointer` to
// the two containers might suddenly start comparing
// equal, but
_ => false,
_ => true,
}
}
(_, _) => false,
Expand Down

0 comments on commit 05e6906

Please sign in to comment.