Add Float and Int type support for Android modules (#42126)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42126

This diff changes how numeric types are generated for Android native modules.
Before this diff:
|Codegen Type|Java Type|
| -- | -- |
|number|double|
|Float|double|
|Double|double|
|Int32|double|
After this diff:
|Codegen Type|Java Type|
| -- | -- |
|number|double|
|Float|**float**|
|Double|double|
|Int32|**int**|

Changelog: [Android][Breaking] - Codegen: mapping for numeric types is changed for Android native modules. `Float` -> `float`; `Int32` -> `int`.

Reviewed By: cipolleschi

Differential Revision: D52420921

fbshipit-source-id: 32b3bbdf5fd24db8d7ac12c262bab5fde4e1f2bc
This commit is contained in:
Dmitry Rykun
2024-01-05 02:47:17 -08:00
committed by Facebook GitHub Bot
parent 9ba3bc99e4
commit ccd3b04770
2 changed files with 4 additions and 4 deletions
@@ -136,11 +136,11 @@ function translateFunctionParamToJavaType(
case 'NumberTypeAnnotation':
return wrapOptional('double', isRequired);
case 'FloatTypeAnnotation':
return wrapOptional('double', isRequired);
return wrapOptional('float', isRequired);
case 'DoubleTypeAnnotation':
return wrapOptional('double', isRequired);
case 'Int32TypeAnnotation':
return wrapOptional('double', isRequired);
return wrapOptional('int', isRequired);
case 'BooleanTypeAnnotation':
return wrapOptional('boolean', isRequired);
case 'EnumDeclaration':
@@ -334,9 +334,9 @@ function translateReturnTypeToJniType(
case 'DoubleTypeAnnotation':
return nullable ? 'Ljava/lang/Double;' : 'D';
case 'FloatTypeAnnotation':
return nullable ? 'Ljava/lang/Double;' : 'D';
return nullable ? 'Ljava/lang/Float;' : 'F';
case 'Int32TypeAnnotation':
return nullable ? 'Ljava/lang/Double;' : 'D';
return nullable ? 'Ljava/lang/Integer;' : 'I';
case 'PromiseTypeAnnotation':
return 'Lcom/facebook/react/bridge/Promise;';
case 'GenericObjectTypeAnnotation':