From 0d748cf8bb033b63c9f0c36e196ddfb4c4ea61a3 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Thu, 5 Nov 2020 17:43:23 -0800 Subject: [PATCH] Rename NativeModulePropertySchema -> NativeModulePropertyShape Summary: Everywhere else in the CodegenSchema, type annotation partials are suffixed with "Shape". In the NativeModule schema, we were using the suffix "Schema". In this diff, we standardize on the "Shape" suffix. Changelog: [Internal] Reviewed By: yungsters Differential Revision: D24719395 fbshipit-source-id: 307935f5fe0681c31cd52e9cf4ae579f61c1ae68 --- packages/react-native-codegen/src/CodegenSchema.js | 4 ++-- .../src/generators/modules/GenerateModuleCpp.js | 4 ++-- .../src/generators/modules/GenerateModuleJavaSpec.js | 4 ++-- .../src/generators/modules/GenerateModuleJniCpp.js | 6 +++--- .../modules/GenerateModuleObjCpp/serializeMethod.js | 6 +++--- .../src/parsers/flow/modules/index.js | 12 ++++++------ 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/packages/react-native-codegen/src/CodegenSchema.js b/packages/react-native-codegen/src/CodegenSchema.js index 8fc315ae745..b5d931a119a 100644 --- a/packages/react-native-codegen/src/CodegenSchema.js +++ b/packages/react-native-codegen/src/CodegenSchema.js @@ -238,10 +238,10 @@ export type NativeModuleSchema = $ReadOnly<{| |}>; type NativeModuleSpec = $ReadOnly<{| - properties: $ReadOnlyArray, + properties: $ReadOnlyArray, |}>; -export type NativeModulePropertySchema = NamedShape< +export type NativeModulePropertyShape = NamedShape< Nullable, >; diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleCpp.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleCpp.js index dd30806c0cf..e20396e7681 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleCpp.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleCpp.js @@ -12,9 +12,9 @@ import type { SchemaType, - NativeModulePropertySchema, Nullable, NamedShape, + NativeModulePropertyShape, NativeModuleFunctionTypeAnnotation, NativeModuleParamTypeAnnotation, } from '../../CodegenSchema'; @@ -161,7 +161,7 @@ function serializeArg( function serializePropertyIntoHostFunction( hasteModuleName: string, - property: NativeModulePropertySchema, + property: NativeModulePropertyShape, resolveAlias: AliasResolver, ): string { const [ diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js index fdaf07657b2..539268b3692 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js @@ -14,7 +14,7 @@ import type { Nullable, NamedShape, SchemaType, - NativeModulePropertySchema, + NativeModulePropertyShape, NativeModuleReturnTypeAnnotation, NativeModuleFunctionTypeAnnotation, NativeModuleParamTypeAnnotation, @@ -285,7 +285,7 @@ function getFalsyReturnStatementFromReturnType( // Build special-cased runtime check for getConstants(). function buildGetConstantsMethod( - method: NativeModulePropertySchema, + method: NativeModulePropertyShape, imports: Set, ): string { const [ diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js index d02b0d6731b..9c8a599cc32 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js @@ -14,7 +14,7 @@ import type { Nullable, NamedShape, SchemaType, - NativeModulePropertySchema, + NativeModulePropertyShape, NativeModuleReturnTypeAnnotation, NativeModuleParamTypeAnnotation, NativeModuleFunctionTypeAnnotation, @@ -287,7 +287,7 @@ function translateReturnTypeToJniType( } function translateMethodTypeToJniSignature( - property: NativeModulePropertySchema, + property: NativeModulePropertyShape, resolveAlias: AliasResolver, ): string { const {name, typeAnnotation} = property; @@ -327,7 +327,7 @@ function translateMethodTypeToJniSignature( function translateMethodForImplementation( hasteModuleName: string, - property: NativeModulePropertySchema, + property: NativeModulePropertyShape, resolveAlias: AliasResolver, ): string { const [ 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 54ab9a2b72b..e3b5d39bc9b 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeMethod.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeMethod.js @@ -11,11 +11,11 @@ 'use strict'; import type { - NativeModulePropertySchema, Nullable, NamedShape, NativeModuleParamTypeAnnotation, NativeModuleReturnTypeAnnotation, + NativeModulePropertyShape, } from '../../../CodegenSchema'; import type {AliasResolver} from '../Utils'; @@ -62,7 +62,7 @@ export type MethodSerializationOutput = $ReadOnly<{| function serializeMethod( hasteModuleName: string, - property: NativeModulePropertySchema, + property: NativeModulePropertyShape, structCollector: StructCollector, resolveAlias: AliasResolver, ): $ReadOnlyArray { @@ -384,7 +384,7 @@ function getReturnJSType( function serializeConstantsProtocolMethods( hasteModuleName: string, - property: NativeModulePropertySchema, + property: NativeModulePropertyShape, structCollector: StructCollector, resolveAlias: AliasResolver, ): $ReadOnlyArray { diff --git a/packages/react-native-codegen/src/parsers/flow/modules/index.js b/packages/react-native-codegen/src/parsers/flow/modules/index.js index 6e44e657208..7bcff0dd894 100644 --- a/packages/react-native-codegen/src/parsers/flow/modules/index.js +++ b/packages/react-native-codegen/src/parsers/flow/modules/index.js @@ -16,8 +16,8 @@ import type { NativeModuleArrayTypeAnnotation, NativeModuleBaseTypeAnnotation, NativeModuleFunctionTypeAnnotation, - NativeModulePropertySchema, NativeModuleParamTypeAnnotation, + NativeModulePropertyShape, NativeModuleSchema, Nullable, } from '../../../CodegenSchema.js'; @@ -487,7 +487,7 @@ function buildPropertySchema( types: TypeDeclarationMap, aliasMap: {...NativeModuleAliasMap}, guard: ParserErrorCapturer, -): NativeModulePropertySchema { +): NativeModulePropertyShape { let nullable = false; let {key, value} = property; @@ -574,13 +574,13 @@ function buildModuleSchema( .filter(property => property.type === 'ObjectTypeProperty') .map(property => { const aliasMap: {...NativeModuleAliasMap} = {}; return guard(() => ({ aliasMap: aliasMap, - propertySchema: buildPropertySchema( + propertyShape: buildPropertySchema( hasteModuleName, property, types, @@ -591,12 +591,12 @@ function buildModuleSchema( }) .filter(Boolean) .reduce( - (moduleSchema: NativeModuleSchema, {aliasMap, propertySchema}) => { + (moduleSchema: NativeModuleSchema, {aliasMap, propertyShape}) => { return { type: 'NativeModule', aliases: {...moduleSchema.aliases, ...aliasMap}, spec: { - properties: [...moduleSchema.spec.properties, propertySchema], + properties: [...moduleSchema.spec.properties, propertyShape], }, moduleNames: moduleSchema.moduleNames, excludedPlatforms: moduleSchema.excludedPlatforms,