mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
react-native-code-gen Add Enum Type support for iOS/Android TurboModules
Summary: Adding enum support to Android/iOS generated code Changelog: [General][Added] - react-native-code-gen Add Enum Type support for iOS/Android TurboModules Reviewed By: javache Differential Revision: D38967241 fbshipit-source-id: d8bb3019dab198e16905a6422e877cd751119122
This commit is contained in:
1 parent
e9b89b5ff2
commit
745f3ee8c5
19 files changed
+347
-7
No files matched your search
Vendored
+33
@@ -271,6 +271,17 @@ function getParamObjCType(
|
||||
return notStruct(notRequired ? 'NSNumber *' : 'double');
|
||||
case 'BooleanTypeAnnotation':
|
||||
return notStruct(notRequired ? 'NSNumber *' : 'BOOL');
|
||||
case 'EnumDeclaration':
|
||||
switch (typeAnnotation.memberType) {
|
||||
case 'NumberTypeAnnotation':
|
||||
return notStruct(notRequired ? 'NSNumber *' : 'double');
|
||||
case 'StringTypeAnnotation':
|
||||
return notStruct(wrapIntoNullableIfNeeded('NSString *'));
|
||||
default:
|
||||
throw new Error(
|
||||
`Unsupported enum type for param "${paramName}" in ${methodName}. Found: ${typeAnnotation.type}`,
|
||||
);
|
||||
}
|
||||
case 'GenericObjectTypeAnnotation':
|
||||
return notStruct(wrapIntoNullableIfNeeded('NSDictionary *'));
|
||||
default:
|
||||
@@ -335,6 +346,17 @@ function getReturnObjCType(
|
||||
return wrapIntoNullableIfNeeded('NSNumber *');
|
||||
case 'BooleanTypeAnnotation':
|
||||
return wrapIntoNullableIfNeeded('NSNumber *');
|
||||
case 'EnumDeclaration':
|
||||
switch (typeAnnotation.memberType) {
|
||||
case 'NumberTypeAnnotation':
|
||||
return wrapIntoNullableIfNeeded('NSNumber *');
|
||||
case 'StringTypeAnnotation':
|
||||
return wrapIntoNullableIfNeeded('NSString *');
|
||||
default:
|
||||
throw new Error(
|
||||
`Unsupported enum return type for ${methodName}. Found: ${typeAnnotation.type}`,
|
||||
);
|
||||
}
|
||||
case 'GenericObjectTypeAnnotation':
|
||||
return wrapIntoNullableIfNeeded('NSDictionary *');
|
||||
default:
|
||||
@@ -380,6 +402,17 @@ function getReturnJSType(
|
||||
return 'BooleanKind';
|
||||
case 'GenericObjectTypeAnnotation':
|
||||
return 'ObjectKind';
|
||||
case 'EnumDeclaration':
|
||||
switch (typeAnnotation.memberType) {
|
||||
case 'NumberTypeAnnotation':
|
||||
return 'NumberKind';
|
||||
case 'StringTypeAnnotation':
|
||||
return 'StringKind';
|
||||
default:
|
||||
throw new Error(
|
||||
`Unsupported return type for ${methodName}. Found: ${typeAnnotation.type}`,
|
||||
);
|
||||
}
|
||||
default:
|
||||
(typeAnnotation.type:
|
||||
| 'EnumDeclaration'
|
||||
|
||||
Reference in new issue
Block a user