From dfdc71eb4ce936a598d58850f50234748d35c112 Mon Sep 17 00:00:00 2001 From: Dmitry Rykun Date: Wed, 3 Jan 2024 02:28:48 -0800 Subject: [PATCH] Add Float and Int type support for iOS modules (#42125) Summary: 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`. Differential Revision: D52479442 --- .../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 19eea87e31e19e..266688ce35c394 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeMethod.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeMethod.js @@ -255,11 +255,11 @@ function getParamObjCType( case 'NumberTypeAnnotation': return isRequired ? 'double' : 'NSNumber *'; case 'FloatTypeAnnotation': - return isRequired ? 'double' : 'NSNumber *'; + return isRequired ? 'float' : 'NSNumber *'; case 'DoubleTypeAnnotation': return isRequired ? 'double' : 'NSNumber *'; case 'Int32TypeAnnotation': - return isRequired ? 'double' : 'NSNumber *'; + return isRequired ? 'NSInteger' : 'NSNumber *'; case 'BooleanTypeAnnotation': return isRequired ? 'BOOL' : 'NSNumber *'; case 'EnumDeclaration':