[Executor] Make executor ID functions non-static to fix ASan

Summary:
When `RCTGetExecutorID` was a static function in the header file, it would return nil when the app was running with ASan enabled even though directly calling `objc_getAssociatedObject(executor, RCTJavaScriptExecutorID)` returned the correct ID as an NSNumber. Moving this function into the .m file fixes this issue.

Closes https://github.com/facebook/react-native/pull/1712
Github Author: James Ide <ide@jameside.com>

Test Plan:  Run the UIExplorer with ASan enabled in Xcode 7. Before this diff, the app would just hang since the executor was unable to read a valid ID and so it would bail out from running JS. With this diff the executor runs the JS and the UIExplorer works fine.
This commit is contained in:
James Ide
2015-06-29 03:22:37 -07:00
parent 7196445cc6
commit c953aa7e0b
3 changed files with 32 additions and 13 deletions

View File

@@ -67,16 +67,5 @@ typedef void (^RCTJavaScriptCallback)(id json, NSError *error);
@end
static const char *RCTJavaScriptExecutorID = "RCTJavaScriptExecutorID";
__used static void RCTSetExecutorID(id<RCTJavaScriptExecutor> executor)
{
static NSUInteger executorID = 0;
if (executor) {
objc_setAssociatedObject(executor, RCTJavaScriptExecutorID, @(++executorID), OBJC_ASSOCIATION_RETAIN);
}
}
__used static NSNumber *RCTGetExecutorID(id<RCTJavaScriptExecutor> executor)
{
return executor ? objc_getAssociatedObject(executor, RCTJavaScriptExecutorID) : @0;
}
void RCTSetExecutorID(id<RCTJavaScriptExecutor> executor);
NSNumber *RCTGetExecutorID(id<RCTJavaScriptExecutor> executor);