From 5aa425c0867e1e737cce9b7de9752cd9518b95ac Mon Sep 17 00:00:00 2001 From: Dmitry Rykun Date: Thu, 4 Jan 2024 05:41:51 -0800 Subject: [PATCH] Add Float and Int type support for iOS modules (#42125) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/42125 This diff changes how numeric types are generated for Objective-C native modules. Before this diff: |Codegen Type|Objective-C Type| | -- | -- | |number|double| |Float|double| |Double|double| |Int32|double| After this diff: |Codegen Type|Objective-C Type| | -- | -- | |number|double| |Float|**float**| |Double|double| |Int32|**NSInteger**| Changelog: [iOS][Breaking] - Codegen: mapping for numeric types is changed for Objective-C native modules. `Float` -> `float`; `Int32` -> `NSInteger`. Reviewed By: cipolleschi Differential Revision: D52479442 fbshipit-source-id: 1b2e101a9593a75c7c19b0da3a01a0e592a35ba5 --- .../modules/GenerateModuleObjCpp/serializeMethod.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeMethod.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeMethod.js index 0bf872f0daef9e..14f0ed724c78d4 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeMethod.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeMethod.js @@ -260,11 +260,11 @@ function getParamObjCType( case 'NumberTypeAnnotation': return notStruct(isRequired ? 'double' : 'NSNumber *'); case 'FloatTypeAnnotation': - return notStruct(isRequired ? 'double' : 'NSNumber *'); + return notStruct(isRequired ? 'float' : 'NSNumber *'); case 'DoubleTypeAnnotation': return notStruct(isRequired ? 'double' : 'NSNumber *'); case 'Int32TypeAnnotation': - return notStruct(isRequired ? 'double' : 'NSNumber *'); + return notStruct(isRequired ? 'NSInteger' : 'NSNumber *'); case 'BooleanTypeAnnotation': return notStruct(isRequired ? 'BOOL' : 'NSNumber *'); case 'EnumDeclaration':