Skip to content

Commit 880e889

Browse files
p-sunfacebook-github-bot
authored andcommitted
Drop using namespace in .h files
Summary: using namespace in header file is a bad practice due to many reasons as well as discouraged by -Wheader-hygiene compiler flag which is default for many apps https://stackoverflow.com/questions/5849457/using-namespace-in-c-headers https://stackoverflow.com/questions/223021/whats-the-scope-of-the-using-declaration-in-c Changelog: [Internal] Drop `using namespace` in .h files. Reviewed By: christophpurrer Differential Revision: D40628064 fbshipit-source-id: 8a032f3ab0321a531e26bd88656ad9a65b6d5154
1 parent 5449148 commit 880e889

File tree

5 files changed

+48
-48
lines changed

5 files changed

+48
-48
lines changed

Libraries/Blob/RCTBlobCollector.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
#import <jsi/jsi.h>
99

10-
using namespace facebook;
11-
1210
@class RCTBlobManager;
1311

1412
namespace facebook {

React/Fabric/Mounting/RCTComponentViewFactory.mm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040
#import <objc/runtime.h>
4141

42+
using namespace facebook;
4243
using namespace facebook::react;
4344

4445
// Allow JS runtime to register native components as needed. For static view configs.

ReactCommon/react/renderer/core/tests/TestComponent.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
#include <react/renderer/core/RawProps.h>
1919
#include <react/renderer/core/ShadowNode.h>
2020

21-
using namespace facebook::react;
22-
2321
/**
2422
* This defines a set of TestComponent classes: Props, ShadowNode,
2523
* ComponentDescriptor. To be used for testing purpose.
2624
*/
2725

26+
namespace facebook::react {
27+
2828
class TestState {
2929
public:
3030
int number;
@@ -75,3 +75,5 @@ class TestComponentDescriptor
7575
public:
7676
using ConcreteComponentDescriptor::ConcreteComponentDescriptor;
7777
};
78+
79+
} // namespace facebook::react

ReactCommon/react/renderer/imagemanager/platform/ios/RCTImagePrimitivesConversions.h

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,43 +10,41 @@
1010
#import <React/RCTImageLoader.h>
1111
#import <react/renderer/imagemanager/primitives.h>
1212

13-
using namespace facebook::react;
14-
15-
inline static UIViewContentMode RCTContentModeFromImageResizeMode(ImageResizeMode imageResizeMode)
13+
inline static UIViewContentMode RCTContentModeFromImageResizeMode(facebook::react::ImageResizeMode imageResizeMode)
1614
{
1715
switch (imageResizeMode) {
18-
case ImageResizeMode::Cover:
16+
case facebook::react::ImageResizeMode::Cover:
1917
return UIViewContentModeScaleAspectFill;
20-
case ImageResizeMode::Contain:
18+
case facebook::react::ImageResizeMode::Contain:
2119
return UIViewContentModeScaleAspectFit;
22-
case ImageResizeMode::Stretch:
20+
case facebook::react::ImageResizeMode::Stretch:
2321
return UIViewContentModeScaleToFill;
24-
case ImageResizeMode::Center:
22+
case facebook::react::ImageResizeMode::Center:
2523
return UIViewContentModeCenter;
26-
case ImageResizeMode::Repeat:
24+
case facebook::react::ImageResizeMode::Repeat:
2725
// Repeat resize mode is handled by the UIImage. Use scale to fill
2826
// so the repeated image fills the UIImageView.
2927
return UIViewContentModeScaleToFill;
3028
}
3129
}
3230

33-
inline std::string toString(const ImageResizeMode &value)
31+
inline std::string toString(const facebook::react::ImageResizeMode &value)
3432
{
3533
switch (value) {
36-
case ImageResizeMode::Cover:
34+
case facebook::react::ImageResizeMode::Cover:
3735
return "cover";
38-
case ImageResizeMode::Contain:
36+
case facebook::react::ImageResizeMode::Contain:
3937
return "contain";
40-
case ImageResizeMode::Stretch:
38+
case facebook::react::ImageResizeMode::Stretch:
4139
return "stretch";
42-
case ImageResizeMode::Center:
40+
case facebook::react::ImageResizeMode::Center:
4341
return "center";
44-
case ImageResizeMode::Repeat:
42+
case facebook::react::ImageResizeMode::Repeat:
4543
return "repeat";
4644
}
4745
}
4846

49-
inline static NSURL *NSURLFromImageSource(const ImageSource &imageSource)
47+
inline static NSURL *NSURLFromImageSource(const facebook::react::ImageSource &imageSource)
5048
{
5149
// `NSURL` has a history of crashing with bad input, so let's be safe.
5250
@try {
@@ -92,7 +90,7 @@ inline static NSURL *NSURLFromImageSource(const ImageSource &imageSource)
9290
}
9391
}
9492

95-
inline static NSURLRequest *NSURLRequestFromImageSource(const ImageSource &imageSource)
93+
inline static NSURLRequest *NSURLRequestFromImageSource(const facebook::react::ImageSource &imageSource)
9694
{
9795
NSURL *url = NSURLFromImageSource(imageSource);
9896

ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTTextPrimitivesConversions.h

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,50 +10,50 @@
1010
#include <react/renderer/textlayoutmanager/RCTFontProperties.h>
1111
#include <react/renderer/textlayoutmanager/RCTFontUtils.h>
1212

13-
using namespace facebook::react;
14-
15-
inline static NSTextAlignment RCTNSTextAlignmentFromTextAlignment(TextAlignment textAlignment)
13+
inline static NSTextAlignment RCTNSTextAlignmentFromTextAlignment(facebook::react::TextAlignment textAlignment)
1614
{
1715
switch (textAlignment) {
18-
case TextAlignment::Natural:
16+
case facebook::react::TextAlignment::Natural:
1917
return NSTextAlignmentNatural;
20-
case TextAlignment::Left:
18+
case facebook::react::TextAlignment::Left:
2119
return NSTextAlignmentLeft;
22-
case TextAlignment::Right:
20+
case facebook::react::TextAlignment::Right:
2321
return NSTextAlignmentRight;
24-
case TextAlignment::Center:
22+
case facebook::react::TextAlignment::Center:
2523
return NSTextAlignmentCenter;
26-
case TextAlignment::Justified:
24+
case facebook::react::TextAlignment::Justified:
2725
return NSTextAlignmentJustified;
2826
}
2927
}
3028

31-
inline static NSWritingDirection RCTNSWritingDirectionFromWritingDirection(WritingDirection writingDirection)
29+
inline static NSWritingDirection RCTNSWritingDirectionFromWritingDirection(
30+
facebook::react::WritingDirection writingDirection)
3231
{
3332
switch (writingDirection) {
34-
case WritingDirection::Natural:
33+
case facebook::react::WritingDirection::Natural:
3534
return NSWritingDirectionNatural;
36-
case WritingDirection::LeftToRight:
35+
case facebook::react::WritingDirection::LeftToRight:
3736
return NSWritingDirectionLeftToRight;
38-
case WritingDirection::RightToLeft:
37+
case facebook::react::WritingDirection::RightToLeft:
3938
return NSWritingDirectionRightToLeft;
4039
}
4140
}
4241

43-
inline static NSLineBreakStrategy RCTNSLineBreakStrategyFromLineBreakStrategy(LineBreakStrategy lineBreakStrategy)
42+
inline static NSLineBreakStrategy RCTNSLineBreakStrategyFromLineBreakStrategy(
43+
facebook::react::LineBreakStrategy lineBreakStrategy)
4444
{
4545
switch (lineBreakStrategy) {
46-
case LineBreakStrategy::None:
46+
case facebook::react::LineBreakStrategy::None:
4747
return NSLineBreakStrategyNone;
48-
case LineBreakStrategy::PushOut:
48+
case facebook::react::LineBreakStrategy::PushOut:
4949
return NSLineBreakStrategyPushOut;
50-
case LineBreakStrategy::HangulWordPriority:
50+
case facebook::react::LineBreakStrategy::HangulWordPriority:
5151
if (@available(iOS 14.0, *)) {
5252
return NSLineBreakStrategyHangulWordPriority;
5353
} else {
5454
return NSLineBreakStrategyNone;
5555
}
56-
case LineBreakStrategy::Standard:
56+
case facebook::react::LineBreakStrategy::Standard:
5757
if (@available(iOS 14.0, *)) {
5858
return NSLineBreakStrategyStandard;
5959
} else {
@@ -62,38 +62,39 @@ inline static NSLineBreakStrategy RCTNSLineBreakStrategyFromLineBreakStrategy(Li
6262
}
6363
}
6464

65-
inline static RCTFontStyle RCTFontStyleFromFontStyle(FontStyle fontStyle)
65+
inline static RCTFontStyle RCTFontStyleFromFontStyle(facebook::react::FontStyle fontStyle)
6666
{
6767
switch (fontStyle) {
68-
case FontStyle::Normal:
68+
case facebook::react::FontStyle::Normal:
6969
return RCTFontStyleNormal;
70-
case FontStyle::Italic:
70+
case facebook::react::FontStyle::Italic:
7171
return RCTFontStyleItalic;
72-
case FontStyle::Oblique:
72+
case facebook::react::FontStyle::Oblique:
7373
return RCTFontStyleOblique;
7474
}
7575
}
7676

77-
inline static RCTFontVariant RCTFontVariantFromFontVariant(FontVariant fontVariant)
77+
inline static RCTFontVariant RCTFontVariantFromFontVariant(facebook::react::FontVariant fontVariant)
7878
{
7979
return (RCTFontVariant)fontVariant;
8080
}
8181

82-
inline static NSUnderlineStyle RCTNSUnderlineStyleFromTextDecorationStyle(TextDecorationStyle textDecorationStyle)
82+
inline static NSUnderlineStyle RCTNSUnderlineStyleFromTextDecorationStyle(
83+
facebook::react::TextDecorationStyle textDecorationStyle)
8384
{
8485
switch (textDecorationStyle) {
85-
case TextDecorationStyle::Solid:
86+
case facebook::react::TextDecorationStyle::Solid:
8687
return NSUnderlineStyleSingle;
87-
case TextDecorationStyle::Double:
88+
case facebook::react::TextDecorationStyle::Double:
8889
return NSUnderlineStyleDouble;
89-
case TextDecorationStyle::Dashed:
90+
case facebook::react::TextDecorationStyle::Dashed:
9091
return NSUnderlinePatternDash | NSUnderlineStyleSingle;
91-
case TextDecorationStyle::Dotted:
92+
case facebook::react::TextDecorationStyle::Dotted:
9293
return NSUnderlinePatternDot | NSUnderlineStyleSingle;
9394
}
9495
}
9596

96-
inline static UIColor *RCTUIColorFromSharedColor(const SharedColor &sharedColor)
97+
inline static UIColor *RCTUIColorFromSharedColor(const facebook::react::SharedColor &sharedColor)
9798
{
9899
if (!sharedColor) {
99100
return nil;

0 commit comments

Comments
 (0)