[JSContext] Define `ContextExecutor.setContextName` for debugging

Summary:
Add a method that lets JS set the name of the JSContext for debugging purposes. I check `JSGlobalContextSetName` since it is not available on iOS 7.

Closes https://github.com/facebook/react-native/pull/2144
Github Author: James Ide <ide@jameside.com>
This commit is contained in:
James Ide 2015-08-04 06:05:31 -07:00
Родитель 47e1d1aef8
Коммит eab7b00cee
1 изменённых файлов: 9 добавлений и 0 удалений

Просмотреть файл

@ -557,4 +557,13 @@ static NSError *RCTNSErrorFromJSError(JSContextRef context, JSValueRef jsError)
}), @"js_call,json_call", (@{@"objectName": objectName}))];
}
RCT_EXPORT_METHOD(setContextName:(NSString *)name)
{
if (JSGlobalContextSetName != NULL) {
JSStringRef JSName = JSStringCreateWithCFString((__bridge CFStringRef)name);
JSGlobalContextSetName(_context.ctx, JSName);
JSStringRelease(JSName);
}
}
@end