mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Make View conversion headers Apple warning-clean (#58542)
Summary: Pull Request resolved: https://github.com/react/react-native/pull/58542 Make public View and CSS conversion headers compile under Apple's -Wswitch-enum and -Wswitch-default policies. Add explicit safe defaults for exhaustive enum conversions and narrowly suppress -Wswitch-enum for the intentionally partial CSSLength token parser. Changelog: [Internal]. Reviewed By: cipolleschi Differential Revision: D120154654 fbshipit-source-id: b619a02b406746168d1652c6dd119d5f06426d56
This commit is contained in:
1 parent
a24bd322d7
commit
86ba0c6334
4 files changed
+55
-12
No files matched your search
+22
-10
@@ -182,6 +182,10 @@ inline std::string toString(const ImportantForAccessibility &importantForAccessi
|
||||
return "no";
|
||||
case ImportantForAccessibility::NoHideDescendants:
|
||||
return "no-hide-descendants";
|
||||
default:
|
||||
LOG(ERROR) << "Unsupported ImportantForAccessibility value: " << static_cast<int>(importantForAccessibility);
|
||||
react_native_expect(false);
|
||||
return "auto";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -372,12 +376,12 @@ inline std::string toString(const AccessibilityRole &accessibilityRole)
|
||||
return "slidingdrawer";
|
||||
case AccessibilityRole::Iconmenu:
|
||||
return "iconmenu";
|
||||
default:
|
||||
LOG(ERROR) << "Unsupported AccessibilityRole value: " << static_cast<int>(accessibilityRole);
|
||||
react_native_expect(false);
|
||||
// sane default for prod
|
||||
return "none";
|
||||
}
|
||||
|
||||
LOG(ERROR) << "Unsupported AccessibilityRole value";
|
||||
react_native_expect(false);
|
||||
// sane default for prod
|
||||
return "none";
|
||||
}
|
||||
|
||||
inline void fromRawValue(const PropsParserContext &context, const RawValue &value, AccessibilityRole &result)
|
||||
@@ -613,12 +617,12 @@ inline std::string toString(const Role &role)
|
||||
return "treegrid";
|
||||
case Role::Treeitem:
|
||||
return "treeitem";
|
||||
default:
|
||||
LOG(ERROR) << "Unsupported Role value: " << static_cast<int>(role);
|
||||
react_native_expect(false);
|
||||
// sane default for prod
|
||||
return "none";
|
||||
}
|
||||
|
||||
LOG(ERROR) << "Unsupported Role value";
|
||||
react_native_expect(false);
|
||||
// sane default for prod
|
||||
return "none";
|
||||
}
|
||||
|
||||
inline void fromRawValue(const PropsParserContext &context, const RawValue &value, Role &result)
|
||||
@@ -780,6 +784,10 @@ inline std::string toString(AccessibilityLiveRegion accessibilityLiveRegion)
|
||||
return "polite";
|
||||
case AccessibilityLiveRegion::Assertive:
|
||||
return "assertive";
|
||||
default:
|
||||
LOG(ERROR) << "Unsupported AccessibilityLiveRegion value: " << static_cast<int>(accessibilityLiveRegion);
|
||||
react_native_expect(false);
|
||||
return "none";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -795,6 +803,10 @@ inline std::string toString(AccessibilityState::CheckedState state)
|
||||
return "Mixed";
|
||||
case AccessibilityState::None:
|
||||
return "None";
|
||||
default:
|
||||
LOG(ERROR) << "Unsupported AccessibilityState::CheckedState value: " << static_cast<int>(state);
|
||||
react_native_expect(false);
|
||||
return "None";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -124,6 +124,10 @@ static inline PositionType positionTypeFromYogaPositionType(yoga::PositionType p
|
||||
return PositionType::Relative;
|
||||
case yoga::PositionType::Absolute:
|
||||
return PositionType::Absolute;
|
||||
default:
|
||||
LOG(ERROR) << "Unexpected yoga::PositionType value: " << static_cast<int>(positionType);
|
||||
react_native_expect(false);
|
||||
return PositionType::Relative;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,6 +142,10 @@ inline DisplayType displayTypeFromYGDisplay(YGDisplay display)
|
||||
return DisplayType::Flex;
|
||||
case YGDisplayGrid:
|
||||
return DisplayType::Grid;
|
||||
default:
|
||||
LOG(ERROR) << "Unexpected YGDisplay value: " << static_cast<int>(display);
|
||||
react_native_expect(false);
|
||||
return DisplayType::Flex;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,6 +193,10 @@ inline YGDirection yogaDirectionFromLayoutDirection(LayoutDirection direction)
|
||||
return YGDirectionLTR;
|
||||
case LayoutDirection::RightToLeft:
|
||||
return YGDirectionRTL;
|
||||
default:
|
||||
LOG(ERROR) << "Unexpected LayoutDirection value: " << static_cast<int>(direction);
|
||||
react_native_expect(false);
|
||||
return YGDirectionInherit;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1113,6 +1125,10 @@ inline std::string toString(PointerEventsMode value)
|
||||
return "box-none";
|
||||
case PointerEventsMode::BoxOnly:
|
||||
return "box-only";
|
||||
default:
|
||||
LOG(ERROR) << "Unsupported PointerEventsMode value: " << static_cast<int>(value);
|
||||
react_native_expect(false);
|
||||
return "auto";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1695,6 +1711,10 @@ inline std::string toString(const LayoutConformance &value)
|
||||
return "strict";
|
||||
case LayoutConformance::Compatibility:
|
||||
return "compatibility";
|
||||
default:
|
||||
LOG(ERROR) << "Unsupported LayoutConformance value: " << static_cast<int>(value);
|
||||
react_native_expect(false);
|
||||
return "strict";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1774,6 +1794,10 @@ inline std::string toString(const Transform &transform)
|
||||
result += "{\"identity\": true}";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG(ERROR) << "Unsupported TransformOperationType value: " << static_cast<int>(operation.type);
|
||||
react_native_expect(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,14 @@ template <>
|
||||
struct CSSDataTypeParser<CSSLength> {
|
||||
static constexpr auto consumePreservedToken(const CSSPreservedToken &token) -> std::optional<CSSLength>
|
||||
{
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wswitch-enum"
|
||||
#endif
|
||||
switch (token.type()) {
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
case CSSTokenType::Dimension:
|
||||
if (auto unit = parseCSSLengthUnit(token.unit())) {
|
||||
return CSSLength{.value = token.numericValue(), .unit = *unit};
|
||||
|
||||
@@ -195,9 +195,9 @@ struct CSSDataTypeParser<CSSTransformOrigin> {
|
||||
return CSSPercentage{100.0f};
|
||||
case CSSTransformOriginKeyword::Bottom:
|
||||
return CSSPercentage{100.0f};
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user