Skip to content

Commit cff9d33

Browse files
NickGerlemanfacebook-github-bot
authored andcommitted
Add missing default labels to CSS parser switch statements
Summary: Add missing `default` labels to `switch` statements in CSS parser headers (`CSSTokenizer.h`, `CSSSyntaxParser.h`, `CSSKeyword.h`) and move away from switch/case in `CSSColor.h` to fix `-Werror` build failures when fbobjc targets import CSS headers. Changelog: [Internal] Differential Revision: D94074704
1 parent 553fb2f commit cff9d33

4 files changed

Lines changed: 12 additions & 11 deletions

File tree

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,13 @@ template <>
3838
struct CSSDataTypeParser<CSSColor> {
3939
static constexpr auto consumePreservedToken(const CSSPreservedToken &token) -> std::optional<CSSColor>
4040
{
41-
switch (token.type()) {
42-
case CSSTokenType::Ident:
43-
return parseCSSNamedColor<CSSColor>(token.stringValue());
44-
case CSSTokenType::Hash:
45-
return parseCSSHexColor<CSSColor>(token.stringValue());
46-
default:
47-
return {};
41+
if (token.type() == CSSTokenType::Ident) {
42+
return parseCSSNamedColor<CSSColor>(token.stringValue());
43+
} else if (token.type() == CSSTokenType::Hash) {
44+
return parseCSSHexColor<CSSColor>(token.stringValue());
4845
}
46+
47+
return {};
4948
}
5049

5150
static constexpr auto consumeFunctionBlock(const CSSFunctionBlock &func, CSSSyntaxParser &parser)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,9 @@ constexpr std::optional<KeywordT> parseCSSKeyword(std::string_view ident)
346346
CSS_HANDLE_KEYWORD(Visible)
347347
CSS_HANDLE_KEYWORD(Wrap)
348348
CSS_HANDLE_KEYWORD(WrapReverse)
349+
default:
350+
return std::nullopt;
349351
}
350-
351-
return std::nullopt;
352352
}
353353

354354
template <CSSKeywordSet KeywordT>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,9 @@ class CSSSyntaxParser {
226226
return hasWhiteSpace;
227227
case CSSDelimiter::None:
228228
return true;
229+
default:
230+
return false;
229231
}
230-
231-
return false;
232232
}
233233

234234
private:

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ class CSSTokenizer {
6767
} else {
6868
return consumeDelim();
6969
}
70+
default:
71+
break;
7072
}
7173

7274
if (isDigit(nextChar)) {

0 commit comments

Comments
 (0)