Last active
December 13, 2015 16:48
-
-
Save numist/4942399 to your computer and use it in GitHub Desktop.
I'm not proud of this, but it's the cleanest answer available to me right now.
This file contains 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
// It would be a mistake to use this code and expect it to work at any point in the future. | |
NSNumber *encoding_requiresStret(const char *encoding) { | |
NSMethodSignature *signature = [NSMethodSignature signatureWithObjCTypes:encoding]; | |
// This information is obviously available internally, but it's only publicly exposed here. | |
NSString *signatureDescription = [signature debugDescription]; | |
BOOL isStret = [signatureDescription rangeOfString:@"is special struct return? YES"].location != NSNotFound; | |
BOOL isNotStret = [signatureDescription rangeOfString:@"is special struct return? NO"].location != NSNotFound; | |
if (isStret) { | |
// objc_msgSend_stret will be used to invoke methods with this signature | |
return @YES; | |
} else if (isNotStret) { | |
// objc_msgSend will be used to invoke methods with this signature | |
return @NO; | |
} else { | |
// This is so fragile, I'm not even sure how I sleep at night. This is why we can't ship nice things. | |
return nil; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
YES/NO/MAYBE