Skip to content

Commit f687292

Browse files
NSProgrammermeta-codesync[bot]
authored andcommitted
Fix missing enum values in switch statements (xplat/js)
Summary: Make improvements so that it is safe to use the `-Wswitch-enum` compiler error in a project consuming RN Changelog: [iOS] [Fixed] - Improve support for projects with `-Wswitch-enum` compiler error Differential Revision: D86026884 fbshipit-source-id: 0407cc24d39d8da3badcc38a890b1dcff4b8f10c
1 parent e189075 commit f687292

4 files changed

Lines changed: 24 additions & 2 deletions

File tree

packages/react-native/React/CoreModules/RCTPlatform.mm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@
3131
return @"tv";
3232
case UIUserInterfaceIdiomCarPlay:
3333
return @"carplay";
34-
#if TARGET_OS_VISION
3534
case UIUserInterfaceIdiomVision:
3635
return @"vision";
37-
#endif
36+
case UIUserInterfaceIdiomMac:
37+
return @"mac";
38+
case UIUserInterfaceIdiomUnspecified:
3839
default:
3940
return @"unknown";
4041
}

packages/react-native/ReactCommon/react/renderer/css/CSSSyntaxParser.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,14 @@ struct CSSComponentValueVisitorDispatcher {
277277
return {};
278278
}
279279

280+
#ifdef __clang__
281+
#pragma clang diagnostic push
282+
#pragma clang diagnostic ignored "-Wswitch-enum"
283+
#endif
280284
switch (parser.peek().type()) {
285+
#ifdef __clang__
286+
#pragma clang diagnostic pop
287+
#endif
281288
case CSSTokenType::Function:
282289
if (auto ret = visitFunction(visitors...)) {
283290
return *ret;

packages/react-native/ReactCommon/yoga/yoga/style/StyleLength.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,14 @@ class StyleLength {
7474
}
7575

7676
constexpr FloatOptional resolve(float referenceLength) {
77+
#ifdef __clang__
78+
#pragma clang diagnostic push
79+
#pragma clang diagnostic ignored "-Wswitch-enum"
80+
#endif
7781
switch (unit_) {
82+
#ifdef __clang__
83+
#pragma clang diagnostic pop
84+
#endif
7885
case Unit::Point:
7986
return value_;
8087
case Unit::Percent:

packages/react-native/ReactCommon/yoga/yoga/style/StyleSizeLength.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,14 @@ class StyleSizeLength {
9999
}
100100

101101
constexpr FloatOptional resolve(float referenceLength) {
102+
#ifdef __clang__
103+
#pragma clang diagnostic push
104+
#pragma clang diagnostic ignored "-Wswitch-enum"
105+
#endif
102106
switch (unit_) {
107+
#ifdef __clang__
108+
#pragma clang diagnostic pop
109+
#endif
103110
case Unit::Point:
104111
return value_;
105112
case Unit::Percent:

0 commit comments

Comments
 (0)