More Encode and RefEncode implementations#52
Merged
Merged
Conversation
This was not done previously because of uncertainty with the `char*` being the "String" encoding. But investigation shows that: - @encode(signed char) -> "c" - @encode(unsigned char) -> "C" - @encode(char*) -> "*" - @encode(char**) -> "^*" And here it doesn't matter if we replace `char` with e.g. `uint8_t`, the encoding scheme still works like this. Luckily `RefEncode` is designed in just the right way that it can actually handle this really nicely!
Allows `*const *const c_void` and such.
madsmtm
commented
Oct 30, 2021
| /// You should not rely on this encoding to exist for any other purpose (since | ||
| /// `()` is not FFI-safe)! | ||
| /// | ||
| /// TODO: Figure out a way to remove this. |
Owner
Author
There was a problem hiding this comment.
Calling attention to this. Possible solution would be to change encode_fn_pointer_impl! and similar macros to handle both the case where R: Encode and where R = ()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RefEncodefor number types (fixes Implement Encode for more types SSheldon/rust-objc#26)RefEncodefor*const c_voidand*mut c_voidEncodeandRefEncodeforWrapping<T>I chose not to implement
RefEncodeforBoxbecause of the hazzle withno_stdstuff, and because I don't think it'll be very useful.RefEncodebeingEncode::Stringoni8andu8makesRefEncodeonBOOLwrong (apparentlyBOOLis more special than just a type-alias overchar?), but this was a problem before (just limited to raw pointers toBOOL; now it's also a problem with references toBOOL).However, the newtype
Booldoesn't suffer from this issue, and using pointers toBOOLis very rare in practice; so I think proper documentation onBOOL(which this PR adds) should solve this issue well enough.