mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Don't support float enums
Summary: Changelog: [General][BREAKING] Don't support 'float' enums in Turbo Modules - The current implementation of 'float enums' in C++ does not work as invalid results are returned. - At potential fix could still cause rounding errors when crossing language bounaries, e.g. `4.6` can become `4.5599999942..` - C++ enum classes don't support float: https://eel.is/c++draft/dcl.enum#2.sentence-4 > The type-specifier-seq of an enum-base shall name an integral type; any cv-qualification is ignored. Hence removing the feature of `float enums` for now Reviewed By: NickGerleman Differential Revision: D52120405 fbshipit-source-id: 3685ad0629e16ff9db424ba67e07d09df6027553
This commit is contained in:
committed by
Facebook GitHub Bot
parent
12aef32b82
commit
536edf3726
@@ -32,7 +32,6 @@ const {getEnumName, toSafeCppString} = require('../Utils');
|
||||
const {indent} = require('../Utils');
|
||||
const {
|
||||
createAliasResolver,
|
||||
getAreEnumMembersInteger,
|
||||
getModules,
|
||||
isArrayRecursiveMember,
|
||||
isDirectRecursiveMember,
|
||||
@@ -344,7 +343,7 @@ ${value.properties
|
||||
.join('\n');
|
||||
}
|
||||
|
||||
type NativeEnumMemberValueType = 'std::string' | 'int32_t' | 'float';
|
||||
type NativeEnumMemberValueType = 'std::string' | 'int32_t';
|
||||
|
||||
const EnumTemplate = ({
|
||||
enumName,
|
||||
@@ -399,16 +398,10 @@ function generateEnum(
|
||||
const enumName = getEnumName(moduleName, origEnumName);
|
||||
|
||||
const nativeEnumMemberType: NativeEnumMemberValueType =
|
||||
memberType === 'StringTypeAnnotation'
|
||||
? 'std::string'
|
||||
: getAreEnumMembersInteger(members)
|
||||
? 'int32_t'
|
||||
: 'float';
|
||||
memberType === 'StringTypeAnnotation' ? 'std::string' : 'int32_t';
|
||||
|
||||
const getMemberValueAppearance = (value: string) =>
|
||||
memberType === 'StringTypeAnnotation'
|
||||
? `"${value}"`
|
||||
: `${value}${nativeEnumMemberType === 'float' ? 'f' : ''}`;
|
||||
memberType === 'StringTypeAnnotation' ? `"${value}"` : `${value}`;
|
||||
|
||||
const fromCases =
|
||||
members
|
||||
|
||||
Reference in New Issue
Block a user