Skip to content

Commit

Permalink
Mark non-extern strings static
Browse files Browse the repository at this point in the history
Reviewed By: shergin

Differential Revision: D5479934

fbshipit-source-id: 2dcf873f44c4847e838d0fae10ecd754d43be262
  • Loading branch information
javache authored and facebook-github-bot committed Jul 25, 2017
1 parent 6555f9b commit ca9e26c
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 65 deletions.
12 changes: 6 additions & 6 deletions Libraries/CameraRoll/RCTCameraRollManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ @implementation RCTCameraRollManager

@synthesize bridge = _bridge;

NSString *const RCTErrorUnableToLoad = @"E_UNABLE_TO_LOAD";
NSString *const RCTErrorUnableToSave = @"E_UNABLE_TO_SAVE";
static NSString *const kErrorUnableToLoad = @"E_UNABLE_TO_LOAD";
static NSString *const kErrorUnableToSave = @"E_UNABLE_TO_SAVE";

RCT_EXPORT_METHOD(saveToCameraRoll:(NSURLRequest *)request
type:(NSString *)type
Expand All @@ -93,7 +93,7 @@ @implementation RCTCameraRollManager
dispatch_async(dispatch_get_main_queue(), ^{
[self->_bridge.assetsLibrary writeVideoAtPathToSavedPhotosAlbum:request.URL completionBlock:^(NSURL *assetURL, NSError *saveError) {
if (saveError) {
reject(RCTErrorUnableToSave, nil, saveError);
reject(kErrorUnableToSave, nil, saveError);
} else {
resolve(assetURL.absoluteString);
}
Expand All @@ -103,15 +103,15 @@ @implementation RCTCameraRollManager
[_bridge.imageLoader loadImageWithURLRequest:request
callback:^(NSError *loadError, UIImage *loadedImage) {
if (loadError) {
reject(RCTErrorUnableToLoad, nil, loadError);
reject(kErrorUnableToLoad, nil, loadError);
return;
}
// It's unclear if writeImageToSavedPhotosAlbum is thread-safe
dispatch_async(dispatch_get_main_queue(), ^{
[self->_bridge.assetsLibrary writeImageToSavedPhotosAlbum:loadedImage.CGImage metadata:nil completionBlock:^(NSURL *assetURL, NSError *saveError) {
if (saveError) {
RCTLogWarn(@"Error saving cropped image: %@", saveError);
reject(RCTErrorUnableToSave, nil, saveError);
reject(kErrorUnableToSave, nil, saveError);
} else {
resolve(assetURL.absoluteString);
}
Expand Down Expand Up @@ -230,7 +230,7 @@ static void RCTResolvePromise(RCTPromiseResolveBlock resolve,
if (error.code != ALAssetsLibraryAccessUserDeniedError) {
RCTLogError(@"Failure while iterating through asset groups %@", error);
}
reject(RCTErrorUnableToLoad, nil, error);
reject(kErrorUnableToLoad, nil, error);
}];
}

Expand Down
13 changes: 6 additions & 7 deletions Libraries/LinkingIOS/RCTLinkingManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@
#import <React/RCTEventDispatcher.h>
#import <React/RCTUtils.h>

NSString *const RCTOpenURLNotification = @"RCTOpenURLNotification";

static NSString *const kOpenURLNotification = @"RCTOpenURLNotification";

static void postNotificationWithURL(NSURL *URL, id sender)
{
NSDictionary<NSString *, id> *payload = @{@"url": URL.absoluteString};
[[NSNotificationCenter defaultCenter] postNotificationName:RCTOpenURLNotification
object:sender
userInfo:payload];
[[NSNotificationCenter defaultCenter] postNotificationName:kOpenURLNotification
object:sender
userInfo:payload];
}

@implementation RCTLinkingManager
Expand All @@ -37,7 +36,7 @@ - (void)startObserving
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleOpenURLNotification:)
name:RCTOpenURLNotification
name:kOpenURLNotification
object:nil];
}

Expand Down Expand Up @@ -74,7 +73,7 @@ + (BOOL)application:(UIApplication *)application
{
if ([userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
NSDictionary *payload = @{@"url": userActivity.webpageURL.absoluteString};
[[NSNotificationCenter defaultCenter] postNotificationName:RCTOpenURLNotification
[[NSNotificationCenter defaultCenter] postNotificationName:kOpenURLNotification
object:self
userInfo:payload];
}
Expand Down
29 changes: 15 additions & 14 deletions Libraries/PushNotificationIOS/RCTPushNotificationManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
#import <React/RCTEventDispatcher.h>
#import <React/RCTUtils.h>

NSString *const RCTLocalNotificationReceived = @"LocalNotificationReceived";
NSString *const RCTRemoteNotificationReceived = @"RemoteNotificationReceived";
NSString *const RCTRemoteNotificationsRegistered = @"RemoteNotificationsRegistered";
NSString *const RCTRegisterUserNotificationSettings = @"RegisterUserNotificationSettings";

NSString *const RCTErrorUnableToRequestPermissions = @"E_UNABLE_TO_REQUEST_PERMISSIONS";
NSString *const RCTErrorRemoteNotificationRegistrationFailed = @"E_FAILED_TO_REGISTER_FOR_REMOTE_NOTIFICATIONS";
static NSString *const kLocalNotificationReceived = @"LocalNotificationReceived";
static NSString *const kRemoteNotificationsRegistered = @"RemoteNotificationsRegistered";
static NSString *const kRegisterUserNotificationSettings = @"RegisterUserNotificationSettings";
static NSString *const kRemoteNotificationRegistrationFailed = @"RemoteNotificationRegistrationFailed";

static NSString *const kErrorUnableToRequestPermissions = @"E_UNABLE_TO_REQUEST_PERMISSIONS";

#if !TARGET_OS_TV
@implementation RCTConvert (NSCalendarUnit)
Expand Down Expand Up @@ -139,23 +140,23 @@ - (void)startObserving
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleLocalNotificationReceived:)
name:RCTLocalNotificationReceived
name:kLocalNotificationReceived
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleRemoteNotificationReceived:)
name:RCTRemoteNotificationReceived
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleRegisterUserNotificationSettings:)
name:RCTRegisterUserNotificationSettings
name:kRegisterUserNotificationSettings
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleRemoteNotificationsRegistered:)
name:RCTRemoteNotificationsRegistered
name:kRemoteNotificationsRegistered
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleRemoteNotificationRegistrationError:)
name:RCTErrorRemoteNotificationRegistrationFailed
name:kRemoteNotificationRegistrationFailed
object:nil];
}

Expand All @@ -176,7 +177,7 @@ + (void)didRegisterUserNotificationSettings:(__unused UIUserNotificationSettings
{
if ([UIApplication instancesRespondToSelector:@selector(registerForRemoteNotifications)]) {
[RCTSharedApplication() registerForRemoteNotifications];
[[NSNotificationCenter defaultCenter] postNotificationName:RCTRegisterUserNotificationSettings
[[NSNotificationCenter defaultCenter] postNotificationName:kRegisterUserNotificationSettings
object:self
userInfo:@{@"notificationSettings": notificationSettings}];
}
Expand All @@ -190,14 +191,14 @@ + (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
for (NSUInteger i = 0; i < deviceTokenLength; i++) {
[hexString appendFormat:@"%02x", bytes[i]];
}
[[NSNotificationCenter defaultCenter] postNotificationName:RCTRemoteNotificationsRegistered
[[NSNotificationCenter defaultCenter] postNotificationName:kRemoteNotificationsRegistered
object:self
userInfo:@{@"deviceToken" : [hexString copy]}];
}

+ (void)didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
[[NSNotificationCenter defaultCenter] postNotificationName:RCTErrorRemoteNotificationRegistrationFailed
[[NSNotificationCenter defaultCenter] postNotificationName:kRemoteNotificationRegistrationFailed
object:self
userInfo:@{@"error": error}];
}
Expand All @@ -221,7 +222,7 @@ + (void)didReceiveRemoteNotification:(NSDictionary *)notification

+ (void)didReceiveLocalNotification:(UILocalNotification *)notification
{
[[NSNotificationCenter defaultCenter] postNotificationName:RCTLocalNotificationReceived
[[NSNotificationCenter defaultCenter] postNotificationName:kLocalNotificationReceived
object:self
userInfo:RCTFormatLocalNotification(notification)];
}
Expand Down Expand Up @@ -315,7 +316,7 @@ - (void)handleRegisterUserNotificationSettings:(NSNotification *)notification
rejecter:(RCTPromiseRejectBlock)reject)
{
if (RCTRunningInAppExtension()) {
reject(RCTErrorUnableToRequestPermissions, nil, RCTErrorWithMessage(@"Requesting push notifications is currently unavailable in an app extension"));
reject(kErrorUnableToRequestPermissions, nil, RCTErrorWithMessage(@"Requesting push notifications is currently unavailable in an app extension"));
return;
}

Expand Down
24 changes: 12 additions & 12 deletions Libraries/Text/RCTShadowText.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
#import "RCTText.h"
#import "RCTTextView.h"

NSString *const RCTShadowViewAttributeName = @"RCTShadowViewAttributeName";
NSString *const RCTIsHighlightedAttributeName = @"IsHighlightedAttributeName";
NSString *const RCTReactTagAttributeName = @"ReactTagAttributeName";

CGFloat const RCTTextAutoSizeDefaultMinimumFontScale = 0.5f;
CGFloat const RCTTextAutoSizeWidthErrorMargin = 0.05f;
CGFloat const RCTTextAutoSizeHeightErrorMargin = 0.025f;
CGFloat const RCTTextAutoSizeGranularity = 0.001f;
static NSString *const kShadowViewAttributeName = @"RCTShadowViewAttributeName";

static CGFloat const kAutoSizeWidthErrorMargin = 0.05f;
static CGFloat const kAutoSizeHeightErrorMargin = 0.025f;
static CGFloat const kAutoSizeGranularity = 0.001f;

@implementation RCTShadowText
{
Expand Down Expand Up @@ -165,7 +165,7 @@ - (void)applyLayoutToChildren:(YGNodeRef)node
NSTextContainer *textContainer = layoutManager.textContainers.firstObject;
NSRange glyphRange = [layoutManager glyphRangeForTextContainer:textContainer];
NSRange characterRange = [layoutManager characterRangeForGlyphRange:glyphRange actualGlyphRange:NULL];
[layoutManager.textStorage enumerateAttribute:RCTShadowViewAttributeName inRange:characterRange options:0 usingBlock:^(RCTShadowView *child, NSRange range, BOOL *_) {
[layoutManager.textStorage enumerateAttribute:kShadowViewAttributeName inRange:characterRange options:0 usingBlock:^(RCTShadowView *child, NSRange range, BOOL *_) {
if (child) {
YGNodeRef childNode = child.yogaNode;
float width = YGNodeStyleGetWidth(childNode).value;
Expand Down Expand Up @@ -334,7 +334,7 @@ - (NSAttributedString *)_attributedStringWithFontFamily:(NSString *)fontFamily
attachment.bounds = (CGRect){CGPointZero, {width, height}};
NSMutableAttributedString *attachmentString = [NSMutableAttributedString new];
[attachmentString appendAttributedString:[NSAttributedString attributedStringWithAttachment:attachment]];
[attachmentString addAttribute:RCTShadowViewAttributeName value:child range:(NSRange){0, attachmentString.length}];
[attachmentString addAttribute:kShadowViewAttributeName value:child range:(NSRange){0, attachmentString.length}];
[attributedString appendAttributedString:attachmentString];
if (height > heightOfTallestSubview) {
heightOfTallestSubview = height;
Expand Down Expand Up @@ -516,7 +516,7 @@ - (CGSize)calculateOptimumScaleInFrame:(CGRect)frame
prevMid:(CGFloat)prevMid
{
CGFloat midScale = (minScale + maxScale) / 2.0f;
if (round((prevMid / RCTTextAutoSizeGranularity)) == round((midScale / RCTTextAutoSizeGranularity))) {
if (round((prevMid / kAutoSizeGranularity)) == round((midScale / kAutoSizeGranularity))) {
//Bail because we can't meet error margin.
return [self calculateSize:textStorage];
} else {
Expand All @@ -529,12 +529,12 @@ - (CGSize)calculateOptimumScaleInFrame:(CGRect)frame
return [self calculateOptimumScaleInFrame:frame
forStorage:textStorage
minScale:minScale
maxScale:midScale - RCTTextAutoSizeGranularity
maxScale:midScale - kAutoSizeGranularity
prevMid:midScale];
} else {
return [self calculateOptimumScaleInFrame:frame
forStorage:textStorage
minScale:midScale + RCTTextAutoSizeGranularity
minScale:midScale + kAutoSizeGranularity
maxScale:maxScale
prevMid:midScale];
}
Expand Down Expand Up @@ -577,8 +577,8 @@ - (RCTSizeComparison)attemptScale:(CGFloat)scale
textContainer.maximumNumberOfLines == 0;

if (fitLines && fitSize) {
if ((requiredSize.width + (CGRectGetWidth(frame) * RCTTextAutoSizeWidthErrorMargin)) > CGRectGetWidth(frame) &&
(requiredSize.height + (CGRectGetHeight(frame) * RCTTextAutoSizeHeightErrorMargin)) > CGRectGetHeight(frame))
if ((requiredSize.width + (CGRectGetWidth(frame) * kAutoSizeWidthErrorMargin)) > CGRectGetWidth(frame) &&
(requiredSize.height + (CGRectGetHeight(frame) * kAutoSizeHeightErrorMargin)) > CGRectGetHeight(frame))
{
return RCTSizeWithinRange;
} else {
Expand Down
22 changes: 11 additions & 11 deletions React/Modules/RCTDevSettings.mm
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@
#import "RCTProfile.h"
#import "RCTUtils.h"

NSString *const kRCTDevSettingProfilingEnabled = @"profilingEnabled";
NSString *const kRCTDevSettingHotLoadingEnabled = @"hotLoadingEnabled";
NSString *const kRCTDevSettingLiveReloadEnabled = @"liveReloadEnabled";
NSString *const kRCTDevSettingIsInspectorShown = @"showInspector";
NSString *const kRCTDevSettingIsDebuggingRemotely = @"isDebuggingRemotely";
NSString *const kRCTDevSettingExecutorOverrideClass = @"executor-override";
NSString *const kRCTDevSettingShakeToShowDevMenu = @"shakeToShow";
NSString *const kRCTDevSettingIsPerfMonitorShown = @"RCTPerfMonitorKey";
NSString *const kRCTDevSettingStartSamplingProfilerOnLaunch = @"startSamplingProfilerOnLaunch";

NSString *const kRCTDevSettingsUserDefaultsKey = @"RCTDevMenu";
static NSString *const kRCTDevSettingProfilingEnabled = @"profilingEnabled";
static NSString *const kRCTDevSettingHotLoadingEnabled = @"hotLoadingEnabled";
static NSString *const kRCTDevSettingLiveReloadEnabled = @"liveReloadEnabled";
static NSString *const kRCTDevSettingIsInspectorShown = @"showInspector";
static NSString *const kRCTDevSettingIsDebuggingRemotely = @"isDebuggingRemotely";
static NSString *const kRCTDevSettingExecutorOverrideClass = @"executor-override";
static NSString *const kRCTDevSettingShakeToShowDevMenu = @"shakeToShow";
static NSString *const kRCTDevSettingIsPerfMonitorShown = @"RCTPerfMonitorKey";
static NSString *const kRCTDevSettingStartSamplingProfilerOnLaunch = @"startSamplingProfilerOnLaunch";

static NSString *const kRCTDevSettingsUserDefaultsKey = @"RCTDevMenu";

#define ENABLE_PACKAGER_CONNECTION RCT_DEV && __has_include("RCTPackagerConnection.h")

Expand Down
24 changes: 12 additions & 12 deletions React/Profiler/RCTProfile.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@

#pragma mark - Constants

NSString *const RCTProfileTraceEvents = @"traceEvents";
NSString *const RCTProfileSamples = @"samples";
NSString *const RCTProfilePrefix = @"rct_profile_";
static NSString *const kProfileTraceEvents = @"traceEvents";
static NSString *const kProfileSamples = @"samples";
static NSString *const kProfilePrefix = @"rct_profile_";

#pragma mark - Variables

Expand Down Expand Up @@ -135,7 +135,7 @@ void RCTProfileRegisterCallbacks(RCTProfileCallbacks *cb)

static const char *RCTProfileProxyClassName(Class class)
{
return [RCTProfilePrefix stringByAppendingString:NSStringFromClass(class)].UTF8String;
return [kProfilePrefix stringByAppendingString:NSStringFromClass(class)].UTF8String;
}

static dispatch_group_t RCTProfileGetUnhookGroup(void)
Expand Down Expand Up @@ -459,8 +459,8 @@ void RCTProfileInit(RCTBridge *bridge)
RCTProfileStartTime = time;
RCTProfileOngoingEvents = [NSMutableDictionary new];
RCTProfileInfo = @{
RCTProfileTraceEvents: [NSMutableArray new],
RCTProfileSamples: [NSMutableArray new],
kProfileTraceEvents: [NSMutableArray new],
kProfileSamples: [NSMutableArray new],
};
});
}
Expand All @@ -470,7 +470,7 @@ void RCTProfileInit(RCTBridge *bridge)
NSArray *orderedThreads = @[@"JS async", @"RCTPerformanceLogger", @"com.facebook.react.JavaScript",
@(RCTUIManagerQueueName), @"main"];
[orderedThreads enumerateObjectsUsingBlock:^(NSString *thread, NSUInteger idx, __unused BOOL *stop) {
RCTProfileAddEvent(RCTProfileTraceEvents,
RCTProfileAddEvent(kProfileTraceEvents,
@"ph": @"M", // metadata event
@"name": @"thread_sort_index",
@"tid": thread,
Expand Down Expand Up @@ -587,7 +587,7 @@ void _RCTProfileEndEvent(
}

NSNumber *start = event[0];
RCTProfileAddEvent(RCTProfileTraceEvents,
RCTProfileAddEvent(kProfileTraceEvents,
@"tid": threadName,
@"name": event[1],
@"cat": category,
Expand Down Expand Up @@ -650,7 +650,7 @@ void RCTProfileEndAsyncEvent(
if (event) {
NSNumber *endTimestamp = RCTProfileTimestamp(time);

RCTProfileAddEvent(RCTProfileTraceEvents,
RCTProfileAddEvent(kProfileTraceEvents,
@"tid": threadName,
@"name": event[1],
@"cat": category,
Expand Down Expand Up @@ -680,7 +680,7 @@ void RCTProfileImmediateEvent(
NSString *threadName = RCTCurrentThreadName();

dispatch_async(RCTProfileGetQueue(), ^{
RCTProfileAddEvent(RCTProfileTraceEvents,
RCTProfileAddEvent(kProfileTraceEvents,
@"tid": threadName,
@"name": name,
@"ts": RCTProfileTimestamp(time),
Expand All @@ -707,7 +707,7 @@ NSUInteger _RCTProfileBeginFlowEvent(void)
NSString *threadName = RCTCurrentThreadName();

dispatch_async(RCTProfileGetQueue(), ^{
RCTProfileAddEvent(RCTProfileTraceEvents,
RCTProfileAddEvent(kProfileTraceEvents,
@"tid": threadName,
@"name": @"flow",
@"id": @(cookie),
Expand All @@ -734,7 +734,7 @@ void _RCTProfileEndFlowEvent(NSUInteger cookie)
NSString *threadName = RCTCurrentThreadName();

dispatch_async(RCTProfileGetQueue(), ^{
RCTProfileAddEvent(RCTProfileTraceEvents,
RCTProfileAddEvent(kProfileTraceEvents,
@"tid": threadName,
@"name": @"flow",
@"id": @(cookie),
Expand Down
Loading

0 comments on commit ca9e26c

Please sign in to comment.