Use method_getNumberOfArguments
, method_copyArgumentType
and method_copyReturnType
to define argument and return types
#89
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.
I'm upgrading the iOS and macOS camera support on Kivy, and after a few tests I decided to use
pyobjus
sometimes, so the user can easily interact withAVCaptureDevice
andAVCaptureSession
, without writing a specific API.Unfortunately, during development, something took my attention:
So, I added some debug in
pyobjus
, and I found out that sometimes (E.g.(b'b@:@', b'conformsToProtocol:')
), the signature does not contain any stack layout info. (See: https://stackoverflow.com/questions/11527385/how-are-the-digits-in-objc-method-type-encoding-calculated)Our previous logic took the return value from
method_getTypeEncoding
and then parsed the signature, by using a regex to split it. Unfortunately, the regex works thanks to the stack layout info digits.Thankfully 🎉, Apple provides
method_getNumberOfArguments
,method_copyArgumentType
andmethod_copyReturnType
(https://developer.apple.com/documentation/objectivec/objective-c_functions?language=objc), so we can avoid implementing any extra logic or specific patches on our side, while also cleaning-up some complexity.While doing these changes, I needed to change the positional arguments of the
ObjcMethod
init method.Even if the risk of someone who used it directly is quite low, I'm still breaking the API, so we likely need a new major release bump and a warning should be added in the release notes.
💡Also likely fixes issue: #21