Last active
August 29, 2015 14:02
-
-
Save danielpunkass/1290afe953edc2401736 to your computer and use it in GitHub Desktop.
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
// These function pointers are intialized to point to objc_msgSend but with specific | |
// signatures to help clarify what the selector's expected signature and behavior are. | |
extern NSString* (*PerformSelectorReturningAutoreleasedString)(id, SEL); | |
extern NSString* (*PerformSelectorWithObjectReturningAutoreleasedString)(id, SEL, id); | |
extern id (*PerformSelectorReturningAutoreleasedObject)(id, SEL); | |
extern void (*PerformSelectorWithObjectReturningVoid)(id, SEL, id); | |
// To safely dynamic message an object where we expect a BOOL response, we | |
// need to clue the compiler into the situation sufficiently (this is especially | |
// broken on Intel if we don't do this). | |
extern BOOL (*PerformSelectorReturningBOOL)(id, SEL); | |
extern BOOL (*PerformSelectorWithObjectReturningBOOL)(id, SEL, id); | |
-------- | |
NSString* (*PerformSelectorReturningAutoreleasedString)(id, SEL) = (NSString* (*)(id, SEL)) objc_msgSend; | |
NSString* (*PerformSelectorWithObjectReturningAutoreleasedString)(id, SEL, id) = (NSString* (*)(id, SEL, id)) objc_msgSend; | |
id (*PerformSelectorReturningAutoreleasedObject)(id, SEL) = (id (*)(id, SEL)) objc_msgSend; | |
void (*PerformSelectorWithObjectReturningVoid)(id, SEL, id) = (void (*)(id, SEL, id)) objc_msgSend; | |
BOOL (*PerformSelectorReturningBOOL)(id, SEL) = (BOOL (*)(id, SEL)) objc_msgSend; | |
BOOL (*PerformSelectorWithObjectReturningBOOL)(id, SEL, id) = (BOOL (*)(id, SEL, id)) objc_msgSend; | |
--------- | |
- (NSString *) rsScriptingValueForSelector:(SEL)selector | |
{ | |
NSString *s = PerformSelectorReturningAutoreleasedString(self, selector); | |
if (!s) | |
{ | |
return @""; | |
} | |
return s; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment