Skip to content

Commit

Permalink
Apply clang-format 18
Browse files Browse the repository at this point in the history
Summary: Previously this code conformed from clang-format 12.

Reviewed By: igorsugak

Differential Revision: D56065247

fbshipit-source-id: f5a985dd8f8b84f2f9e1818b3719b43c5a1b05b3
  • Loading branch information
zertosh authored and facebook-github-bot committed Apr 14, 2024
1 parent 314a919 commit a5eeea8
Show file tree
Hide file tree
Showing 42 changed files with 212 additions and 206 deletions.
6 changes: 2 additions & 4 deletions packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,11 @@ - (RCTRootViewFactory *)createRCTRootViewFactory
turboModuleEnabled:self.turboModuleEnabled
bridgelessEnabled:self.bridgelessEnabled];

configuration.createRootViewWithBridge = ^UIView *(RCTBridge *bridge, NSString *moduleName, NSDictionary *initProps)
{
configuration.createRootViewWithBridge = ^UIView *(RCTBridge *bridge, NSString *moduleName, NSDictionary *initProps) {
return [weakSelf createRootViewWithBridge:bridge moduleName:moduleName initProps:initProps];
};

configuration.createBridgeWithDelegate = ^RCTBridge *(id<RCTBridgeDelegate> delegate, NSDictionary *launchOptions)
{
configuration.createBridgeWithDelegate = ^RCTBridge *(id<RCTBridgeDelegate> delegate, NSDictionary *launchOptions) {
return [weakSelf createBridgeWithDelegate:delegate launchOptions:launchOptions];
};

Expand Down
43 changes: 21 additions & 22 deletions packages/react-native/Libraries/AppDelegate/RCTAppSetupUtils.mm
Original file line number Diff line number Diff line change
Expand Up @@ -62,32 +62,31 @@ void RCTAppSetupPrepareApp(UIApplication *application, BOOL turboModuleEnabled)
{
// private block used to filter out modules depending on protocol conformance
NSArray * (^extractModuleConformingToProtocol)(RCTModuleRegistry *, Protocol *) =
^NSArray *(RCTModuleRegistry *moduleRegistry, Protocol *protocol)
{
NSArray<NSString *> *classNames = @[];
^NSArray *(RCTModuleRegistry *moduleRegistry, Protocol *protocol) {
NSArray<NSString *> *classNames = @[];

#if USE_OSS_CODEGEN
if (protocol == @protocol(RCTImageURLLoader)) {
classNames = [RCTModulesConformingToProtocolsProvider imageURLLoaderClassNames];
} else if (protocol == @protocol(RCTImageDataDecoder)) {
classNames = [RCTModulesConformingToProtocolsProvider imageDataDecoderClassNames];
} else if (protocol == @protocol(RCTURLRequestHandler)) {
classNames = [RCTModulesConformingToProtocolsProvider URLRequestHandlerClassNames];
}
if (protocol == @protocol(RCTImageURLLoader)) {
classNames = [RCTModulesConformingToProtocolsProvider imageURLLoaderClassNames];
} else if (protocol == @protocol(RCTImageDataDecoder)) {
classNames = [RCTModulesConformingToProtocolsProvider imageDataDecoderClassNames];
} else if (protocol == @protocol(RCTURLRequestHandler)) {
classNames = [RCTModulesConformingToProtocolsProvider URLRequestHandlerClassNames];
}
#endif

NSMutableArray *modules = [NSMutableArray new];

for (NSString *className in classNames) {
const char *cModuleName = [className cStringUsingEncoding:NSUTF8StringEncoding];
id moduleFromLibrary = [moduleRegistry moduleForName:cModuleName];
if (![moduleFromLibrary conformsToProtocol:protocol]) {
continue;
}
[modules addObject:moduleFromLibrary];
}
return modules;
};
NSMutableArray *modules = [NSMutableArray new];

for (NSString *className in classNames) {
const char *cModuleName = [className cStringUsingEncoding:NSUTF8StringEncoding];
id moduleFromLibrary = [moduleRegistry moduleForName:cModuleName];
if (![moduleFromLibrary conformsToProtocol:protocol]) {
continue;
}
[modules addObject:moduleFromLibrary];
}
return modules;
};

// Set up the default RCTImageLoader and RCTNetworking modules.
if (moduleClass == RCTImageLoader.class) {
Expand Down
10 changes: 4 additions & 6 deletions packages/react-native/React/Base/RCTBridgeModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,10 @@ RCT_EXTERN_C_END
/**
* Like RCT_EXTERN_MODULE, but allows setting a custom JavaScript name.
*/
#define RCT_EXTERN_REMAP_MODULE(js_name, objc_name, objc_supername) \
objc_name: \
objc_supername @ \
end @interface objc_name(RCTExternModule)<RCTBridgeModule> \
@end \
@implementation objc_name (RCTExternModule) \
#define RCT_EXTERN_REMAP_MODULE(js_name, objc_name, objc_supername) \
objc_name : objc_supername @end @interface objc_name(RCTExternModule)<RCTBridgeModule> \
@end \
@implementation objc_name (RCTExternModule) \
RCT_EXPORT_MODULE_NO_LOAD(js_name, objc_name)

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/React/Base/RCTModuleData.mm
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ int32_t getUniqueId()
static std::atomic<int32_t> counter{0};
return counter++;
}
}
} // namespace

@implementation RCTModuleData {
NSDictionary<NSString *, id> *_constantsToExport;
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/React/Base/RCTModuleRegistry.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ - (id)moduleForName:(const char *)moduleName lazilyLoadIfNecessary:(BOOL)lazilyL

RCTBridge *bridge = _bridge;
if (bridge) {
module = [bridge moduleForName:[NSString stringWithUTF8String:moduleName] lazilyLoadIfNecessary:lazilyLoad];
module = [bridge moduleForName: [NSString stringWithUTF8String:moduleName] lazilyLoadIfNecessary:lazilyLoad];
}

id<RCTTurboModuleRegistry> turboModuleRegistry = _turboModuleRegistry;
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/React/Base/RCTRootView.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ extern

NS_ASSUME_NONNULL_BEGIN

NSString *const RCTContentDidAppearNotification;
NSString *const RCTContentDidAppearNotification;

/**
* Native view used to host React-managed views within the app. Can be used just
Expand Down
8 changes: 4 additions & 4 deletions packages/react-native/React/Base/RCTUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ RCT_EXTERN BOOL RCTClassOverridesClassMethod(Class cls, SEL selector);
RCT_EXTERN BOOL RCTClassOverridesInstanceMethod(Class cls, SEL selector);

// Creates a standardized error object to return in callbacks
RCT_EXTERN NSDictionary<NSString *, id>
*RCTMakeError(NSString *message, id __nullable toStringify, NSDictionary<NSString *, id> *__nullable extraData);
RCT_EXTERN NSDictionary<NSString *, id> *
RCTMakeError(NSString *message, id __nullable toStringify, NSDictionary<NSString *, id> *__nullable extraData);
RCT_EXTERN NSDictionary<NSString *, id> *
RCTMakeAndLogError(NSString *message, id __nullable toStringify, NSDictionary<NSString *, id> *__nullable extraData);
RCT_EXTERN NSDictionary<NSString *, id> *RCTJSErrorFromNSError(NSError *error);
RCT_EXTERN NSDictionary<NSString *, id>
*RCTJSErrorFromCodeMessageAndNSError(NSString *code, NSString *message, NSError *__nullable error);
RCT_EXTERN NSDictionary<NSString *, id> *
RCTJSErrorFromCodeMessageAndNSError(NSString *code, NSString *message, NSError *__nullable error);

// The default error code to use as the `code` property for callback error objects
RCT_EXTERN NSString *const RCTErrorUnspecified;
Expand Down
8 changes: 4 additions & 4 deletions packages/react-native/React/Base/RCTUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,8 @@ BOOL RCTClassOverridesInstanceMethod(Class cls, SEL selector)
return NO;
}

NSDictionary<NSString *, id>
*RCTMakeError(NSString *message, id __nullable toStringify, NSDictionary<NSString *, id> *__nullable extraData)
NSDictionary<NSString *, id> *
RCTMakeError(NSString *message, id __nullable toStringify, NSDictionary<NSString *, id> *__nullable extraData)
{
if (toStringify) {
message = [message stringByAppendingString:[toStringify description]];
Expand All @@ -496,8 +496,8 @@ BOOL RCTClassOverridesInstanceMethod(Class cls, SEL selector)
}

// TODO: Can we just replace RCTMakeError with this function instead?
NSDictionary<NSString *, id>
*RCTJSErrorFromCodeMessageAndNSError(NSString *code, NSString *message, NSError *__nullable error)
NSDictionary<NSString *, id> *
RCTJSErrorFromCodeMessageAndNSError(NSString *code, NSString *message, NSError *__nullable error)
{
NSString *errorMessage;
NSArray<NSString *> *stackTrace = [NSThread callStackSymbols];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ - (UIView *)loadingView

- (void)setLoadingView:(UIView *)loadingView
{
super.activityIndicatorViewFactory = ^UIView *(void)
{
super.activityIndicatorViewFactory = ^UIView *(void) {
return loadingView;
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ RCT_EXTERN_C_BEGIN
// Only to be used for testing and internal tooling. Do not use this in
// production.
void RCTAccessibilityManagerSetIsVoiceOverEnabled(
RCTAccessibilityManager* accessibilityManager,
RCTAccessibilityManager *accessibilityManager,
BOOL isVoiceOverEnabled);

RCT_EXTERN_C_END
Expand Down
24 changes: 13 additions & 11 deletions packages/react-native/React/CoreModules/RCTPlatform.mm
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,20 @@ - (dispatch_queue_t)methodQueue
UIDevice *device = [UIDevice currentDevice];
auto versions = RCTGetReactNativeVersion();
constants = typedConstants<JS::NativePlatformConstantsIOS::Constants>({
.forceTouchAvailable = RCTForceTouchAvailable() ? true : false, .osVersion = [device systemVersion],
.systemName = [device systemName], .interfaceIdiom = interfaceIdiom([device userInterfaceIdiom]),
.isTesting = RCTRunningInTestEnvironment() ? true : false,
.reactNativeVersion = JS::NativePlatformConstantsIOS::ConstantsReactNativeVersion::Builder(
{.minor = [versions[@"minor"] doubleValue],
.major = [versions[@"major"] doubleValue],
.patch = [versions[@"patch"] doubleValue],
.prerelease = [versions[@"prerelease"] isKindOfClass:[NSNull class]]
? std::optional<double>{}
: [versions[@"prerelease"] doubleValue]}),
.forceTouchAvailable = RCTForceTouchAvailable() ? true : false,
.osVersion = [device systemVersion],
.systemName = [device systemName],
.interfaceIdiom = interfaceIdiom([device userInterfaceIdiom]),
.isTesting = RCTRunningInTestEnvironment() ? true : false,
.reactNativeVersion = JS::NativePlatformConstantsIOS::ConstantsReactNativeVersion::Builder(
{.minor = [versions[@"minor"] doubleValue],
.major = [versions[@"major"] doubleValue],
.patch = [versions[@"patch"] doubleValue],
.prerelease = [versions[@"prerelease"] isKindOfClass:[NSNull class]]
? std::optional<double>{}
: [versions[@"prerelease"] doubleValue]}),
#if TARGET_OS_MACCATALYST
.isMacCatalyst = true,
.isMacCatalyst = true,
#else
.isMacCatalyst = false,
#endif
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/React/CxxBridge/RCTCxxBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ int32_t getUniqueId()
std::shared_ptr<JSExecutorFactory> factory_;
};

}
} // namespace

static void mapReactMarkerToPerformanceLogger(
const ReactMarker::ReactMarkerId markerId,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/React/CxxBridge/RCTObjcExecutor.mm
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ virtual void setGlobalVariable(std::string propName, std::unique_ptr<const JSBig
RCTJavaScriptCallback m_jsCallback;
};

}
} // namespace

RCTObjcExecutorFactory::RCTObjcExecutorFactory(id<RCTJavaScriptExecutor> jse, RCTJavaScriptCompleteBlock errorBlock)
: m_jse(jse), m_errorBlock(errorBlock)
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/React/CxxModule/RCTCxxModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace facebook::xplat::module {
class CxxModule;
} // namespace facebook::react::module
} // namespace facebook::xplat::module

/**
* Subclass RCTCxxModule to use cross-platform CxxModule on iOS.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class RCTImageResponseObserverProxy final : public ImageResponseObserver {
public:
RCTImageResponseObserverProxy(id<RCTImageResponseDelegate> delegate = nil);

void didReceiveImage(const ImageResponse& imageResponse) const override;
void didReceiveImage(const ImageResponse &imageResponse) const override;
void didReceiveProgress(float progress) const override;
void didReceiveFailure() const override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
{
return [[NSString alloc] initWithBytes:(const char *)view.data() length:view.size() encoding:NSUTF8StringEncoding];
}
}
} // namespace
@interface RCTCxxInspectorWebSocketAdapter () <SRWebSocketDelegate> {
std::weak_ptr<IWebSocketDelegate> _delegate;
SRWebSocket *_webSocket;
Expand Down
Loading

0 comments on commit a5eeea8

Please sign in to comment.