From 7490ad4a213aa75bfff205b57733cc71c79ca62c Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Mon, 10 Oct 2022 02:51:06 -0700 Subject: [PATCH] Generate Custom Native State (#34796) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/34796 This diff introduces the generation of custom native states using basic types as we do with the Props. To make it work, the custom types are already writte in the Props.h file, therefore the State.h file must import that other file to have access to the required types. This diff adds and updates the tests for the State. ## Changelog [General][Added] - Generate custom Native State Reviewed By: cortinico Differential Revision: D39816763 fbshipit-source-id: 42d1aa9a6df23145f4a46ae8ccfb43d81fa651fb --- .../components/ComponentsGeneratorUtils.js | 158 ++ .../generators/components/GeneratePropsH.js | 109 +- .../generators/components/GenerateStateCpp.js | 51 +- .../generators/components/GenerateStateH.js | 125 +- .../components/__test_fixtures__/fixtures.js | 856 +++++++++++ .../GenerateComponentDescriptorH-test.js.snap | 392 +++++ .../GenerateComponentHObjCpp-test.js.snap | 350 +++++ .../GenerateEventEmitterCpp-test.js.snap | 350 +++++ .../GenerateEventEmitterH-test.js.snap | 476 ++++++ .../GeneratePropsCpp-test.js.snap | 462 ++++++ .../__snapshots__/GeneratePropsH-test.js.snap | 504 +++++++ .../GeneratePropsJavaDelegate-test.js.snap | 434 ++++++ .../GeneratePropsJavaInterface-test.js.snap | 308 ++++ .../GeneratePropsJavaPojo-test.js.snap | 336 +++++ .../GenerateShadowNodeCpp-test.js.snap | 350 +++++ .../GenerateShadowNodeH-test.js.snap | 560 +++++++ .../GenerateStateCpp-test.js.snap | 432 ++++++ .../__snapshots__/GenerateStateH-test.js.snap | 1292 ++++++++++++++--- .../__snapshots__/GenerateTests-test.js.snap | 490 +++++++ ...artyFabricComponentsProviderH-test.js.snap | 14 + ...abricComponentsProviderObjCpp-test.js.snap | 28 + .../GenerateViewConfigJs-test.js.snap | 434 ++++++ 22 files changed, 8222 insertions(+), 289 deletions(-) create mode 100644 packages/react-native-codegen/src/generators/components/ComponentsGeneratorUtils.js diff --git a/packages/react-native-codegen/src/generators/components/ComponentsGeneratorUtils.js b/packages/react-native-codegen/src/generators/components/ComponentsGeneratorUtils.js new file mode 100644 index 00000000000..9b0244127cd --- /dev/null +++ b/packages/react-native-codegen/src/generators/components/ComponentsGeneratorUtils.js @@ -0,0 +1,158 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict + * @format + */ + +'use strict'; + +import type { + NamedShape, + PropTypeAnnotation, + StateTypeAnnotation, +} from '../../CodegenSchema'; + +import type { + StringTypeAnnotation, + ReservedPropTypeAnnotation, + ObjectTypeAnnotation, + Int32TypeAnnotation, + FloatTypeAnnotation, + DoubleTypeAnnotation, + BooleanTypeAnnotation, +} from '../../CodegenSchema'; + +const { + convertDefaultTypeToString, + getCppTypeForAnnotation, + getEnumMaskName, + getEnumName, + generateStructName, +} = require('./CppHelpers.js'); + +function getNativeTypeFromAnnotation( + componentName: string, + prop: + | NamedShape + | NamedShape + | { + name: string, + typeAnnotation: + | $FlowFixMe + | DoubleTypeAnnotation + | FloatTypeAnnotation + | BooleanTypeAnnotation + | Int32TypeAnnotation + | StringTypeAnnotation + | ObjectTypeAnnotation + | ReservedPropTypeAnnotation + | { + +default: string, + +options: $ReadOnlyArray, + +type: 'StringEnumTypeAnnotation', + } + | { + +elementType: ObjectTypeAnnotation, + +type: 'ArrayTypeAnnotation', + }, + }, + nameParts: $ReadOnlyArray, +): string { + const typeAnnotation = prop.typeAnnotation; + + switch (typeAnnotation.type) { + case 'BooleanTypeAnnotation': + case 'StringTypeAnnotation': + case 'Int32TypeAnnotation': + case 'DoubleTypeAnnotation': + case 'FloatTypeAnnotation': + return getCppTypeForAnnotation(typeAnnotation.type); + case 'ReservedPropTypeAnnotation': + switch (typeAnnotation.name) { + case 'ColorPrimitive': + return 'SharedColor'; + case 'ImageSourcePrimitive': + return 'ImageSource'; + case 'PointPrimitive': + return 'Point'; + case 'EdgeInsetsPrimitive': + return 'EdgeInsets'; + default: + (typeAnnotation.name: empty); + throw new Error('Received unknown ReservedPropTypeAnnotation'); + } + case 'ArrayTypeAnnotation': { + const arrayType = typeAnnotation.elementType.type; + if (arrayType === 'ArrayTypeAnnotation') { + return `std::vector<${getNativeTypeFromAnnotation( + componentName, + {typeAnnotation: typeAnnotation.elementType, name: ''}, + nameParts.concat([prop.name]), + )}>`; + } + if (arrayType === 'ObjectTypeAnnotation') { + const structName = generateStructName( + componentName, + nameParts.concat([prop.name]), + ); + return `std::vector<${structName}>`; + } + if (arrayType === 'StringEnumTypeAnnotation') { + const enumName = getEnumName(componentName, prop.name); + return getEnumMaskName(enumName); + } + const itemAnnotation = getNativeTypeFromAnnotation( + componentName, + { + typeAnnotation: typeAnnotation.elementType, + name: componentName, + }, + nameParts.concat([prop.name]), + ); + return `std::vector<${itemAnnotation}>`; + } + case 'ObjectTypeAnnotation': { + return generateStructName(componentName, nameParts.concat([prop.name])); + } + case 'StringEnumTypeAnnotation': + return getEnumName(componentName, prop.name); + case 'Int32EnumTypeAnnotation': + return getEnumName(componentName, prop.name); + default: + (typeAnnotation: empty); + throw new Error( + `Received invalid typeAnnotation for ${componentName} prop ${prop.name}, received ${typeAnnotation.type}`, + ); + } +} + +function getStateConstituents( + componentName: string, + stateShape: NamedShape, +): { + name: string, + varName: string, + type: string, + defaultValue: $FlowFixMe, +} { + const name = stateShape.name; + const varName = `${name}_`; + const type = getNativeTypeFromAnnotation(componentName, stateShape, []); + const defaultValue = convertDefaultTypeToString(componentName, stateShape); + + return { + name, + varName, + type, + defaultValue, + }; +} + +module.exports = { + getNativeTypeFromAnnotation, + getStateConstituents, +}; diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsH.js b/packages/react-native-codegen/src/generators/components/GeneratePropsH.js index 26521b0cbb1..168dba84e12 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsH.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsH.js @@ -9,20 +9,12 @@ */ 'use strict'; -import type { - StringTypeAnnotation, - ReservedPropTypeAnnotation, - ObjectTypeAnnotation, - Int32TypeAnnotation, - FloatTypeAnnotation, - DoubleTypeAnnotation, - ComponentShape, - BooleanTypeAnnotation, -} from '../../CodegenSchema'; +import type {ComponentShape} from '../../CodegenSchema'; + +const {getNativeTypeFromAnnotation} = require('./ComponentsGeneratorUtils.js'); const { convertDefaultTypeToString, - getCppTypeForAnnotation, getEnumMaskName, getEnumName, toSafeCppString, @@ -294,101 +286,6 @@ function getClassExtendString(component: ComponentShape): string { return extendString; } -function getNativeTypeFromAnnotation( - componentName: string, - prop: - | NamedShape - | { - name: string, - typeAnnotation: - | $FlowFixMe - | DoubleTypeAnnotation - | FloatTypeAnnotation - | BooleanTypeAnnotation - | Int32TypeAnnotation - | StringTypeAnnotation - | ObjectTypeAnnotation - | ReservedPropTypeAnnotation - | { - +default: string, - +options: $ReadOnlyArray, - +type: 'StringEnumTypeAnnotation', - } - | { - +elementType: ObjectTypeAnnotation, - +type: 'ArrayTypeAnnotation', - }, - }, - nameParts: $ReadOnlyArray, -): string { - const typeAnnotation = prop.typeAnnotation; - - switch (typeAnnotation.type) { - case 'BooleanTypeAnnotation': - case 'StringTypeAnnotation': - case 'Int32TypeAnnotation': - case 'DoubleTypeAnnotation': - case 'FloatTypeAnnotation': - return getCppTypeForAnnotation(typeAnnotation.type); - case 'ReservedPropTypeAnnotation': - switch (typeAnnotation.name) { - case 'ColorPrimitive': - return 'SharedColor'; - case 'ImageSourcePrimitive': - return 'ImageSource'; - case 'PointPrimitive': - return 'Point'; - case 'EdgeInsetsPrimitive': - return 'EdgeInsets'; - default: - (typeAnnotation.name: empty); - throw new Error('Received unknown ReservedPropTypeAnnotation'); - } - case 'ArrayTypeAnnotation': { - const arrayType = typeAnnotation.elementType.type; - if (arrayType === 'ArrayTypeAnnotation') { - return `std::vector<${getNativeTypeFromAnnotation( - componentName, - {typeAnnotation: typeAnnotation.elementType, name: ''}, - nameParts.concat([prop.name]), - )}>`; - } - if (arrayType === 'ObjectTypeAnnotation') { - const structName = generateStructName( - componentName, - nameParts.concat([prop.name]), - ); - return `std::vector<${structName}>`; - } - if (arrayType === 'StringEnumTypeAnnotation') { - const enumName = getEnumName(componentName, prop.name); - return getEnumMaskName(enumName); - } - const itemAnnotation = getNativeTypeFromAnnotation( - componentName, - { - typeAnnotation: typeAnnotation.elementType, - name: componentName, - }, - nameParts.concat([prop.name]), - ); - return `std::vector<${itemAnnotation}>`; - } - case 'ObjectTypeAnnotation': { - return generateStructName(componentName, nameParts.concat([prop.name])); - } - case 'StringEnumTypeAnnotation': - return getEnumName(componentName, prop.name); - case 'Int32EnumTypeAnnotation': - return getEnumName(componentName, prop.name); - default: - (typeAnnotation: empty); - throw new Error( - `Received invalid typeAnnotation for ${componentName} prop ${prop.name}, received ${typeAnnotation.type}`, - ); - } -} - function convertValueToEnumOption(value: string): string { return toSafeCppString(value); } diff --git a/packages/react-native-codegen/src/generators/components/GenerateStateCpp.js b/packages/react-native-codegen/src/generators/components/GenerateStateCpp.js index 1bbcc0e16e4..5f8f0c39b0a 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateStateCpp.js +++ b/packages/react-native-codegen/src/generators/components/GenerateStateCpp.js @@ -10,17 +10,23 @@ 'use strict'; -import type {SchemaType} from '../../CodegenSchema'; +import type { + NamedShape, + SchemaType, + StateTypeAnnotation, +} from '../../CodegenSchema'; +const {capitalize} = require('../Utils.js'); +const {getStateConstituents} = require('./ComponentsGeneratorUtils.js'); // File path -> contents type FilesOutput = Map; const FileTemplate = ({ libraryName, - stateClasses, + stateGetters, }: { libraryName: string, - stateClasses: string, + stateGetters: string, }) => ` /** * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). @@ -35,13 +41,32 @@ const FileTemplate = ({ namespace facebook { namespace react { -${stateClasses} +${stateGetters} } // namespace react } // namespace facebook `; -const StateTemplate = ({stateName}: {stateName: string}) => ''; +function generateStrings( + componentName: string, + state: $ReadOnlyArray>, +) { + let getters = ''; + state.forEach(stateShape => { + const {name, varName, type} = getStateConstituents( + componentName, + stateShape, + ); + + getters += ` +${type} ${componentName}::get${capitalize(name)}() const { + return ${varName}; +} +`; + }); + + return getters.trim(); +} module.exports = { generate( @@ -52,7 +77,7 @@ module.exports = { ): FilesOutput { const fileName = 'States.cpp'; - const stateClasses = Object.keys(schema.modules) + const stateGetters = Object.keys(schema.modules) .map(moduleName => { const module = schema.modules[moduleName]; if (module.type !== 'Component') { @@ -67,12 +92,16 @@ module.exports = { return Object.keys(components) .map(componentName => { - if (components[componentName].interfaceOnly === true) { + const component = components[componentName]; + if (component.interfaceOnly === true) { return null; } - return StateTemplate({ - stateName: `${componentName}State`, - }); + + const state = component.state; + if (!state) { + return ''; + } + return generateStrings(componentName, state); }) .filter(Boolean) .join('\n'); @@ -82,7 +111,7 @@ module.exports = { const replacedTemplate = FileTemplate({ libraryName, - stateClasses, + stateGetters, }); return new Map([[fileName, replacedTemplate]]); diff --git a/packages/react-native-codegen/src/generators/components/GenerateStateH.js b/packages/react-native-codegen/src/generators/components/GenerateStateH.js index 76f46403d15..24520e311c5 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateStateH.js +++ b/packages/react-native-codegen/src/generators/components/GenerateStateH.js @@ -10,7 +10,13 @@ 'use strict'; -import type {SchemaType} from '../../CodegenSchema'; +import type { + NamedShape, + SchemaType, + StateTypeAnnotation, +} from '../../CodegenSchema'; +const {capitalize} = require('../Utils.js'); +const {getStateConstituents} = require('./ComponentsGeneratorUtils.js'); // File path -> contents type FilesOutput = Map; @@ -21,7 +27,8 @@ const FileTemplate = ({ }: { libraryName: string, stateClasses: string, -}) => ` +}) => + ` /** * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * @@ -32,6 +39,8 @@ const FileTemplate = ({ */ #pragma once +#include + #ifdef ANDROID #include #include @@ -45,13 +54,39 @@ ${stateClasses} } // namespace react } // namespace facebook -`; +`.trim(); -const StateTemplate = ({stateName}: {stateName: string}) => ` +const StateTemplate = ({ + stateName, + ctorParams, + ctorInits, + getters, + stateProps, +}: { + stateName: string, + ctorParams: string, + ctorInits: string, + getters: string, + stateProps: string, +}) => { + let stateWithParams = ''; + if (ctorParams.length > 0) { + stateWithParams = ` + ${stateName}State( + ${ctorParams} + ) + : ${ctorInits}{}; + `; + } + + return ` class ${stateName}State { public: + ${stateWithParams} ${stateName}State() = default; + ${getters} + #ifdef ANDROID ${stateName}State(${stateName}State const &previousState, folly::dynamic data){}; folly::dynamic getDynamic() const { @@ -61,8 +96,61 @@ class ${stateName}State { return MapBufferBuilder::EMPTY(); }; #endif + + private: + ${stateProps} }; -`; +`.trim(); +}; + +function sanitize(stringToSanitize: string, endString: string) { + if (stringToSanitize.endsWith(endString)) { + return stringToSanitize.slice(0, -1 * endString.length); + } + return stringToSanitize; +} + +function generateStrings( + componentName: string, + state: $ReadOnlyArray>, +): { + ctorParams: string, + ctorInits: string, + getters: string, + stateProps: string, +} { + let ctorParams = ''; + let ctorInits = ''; + let getters = ''; + let stateProps = ''; + + state.forEach(stateShape => { + const {name, varName, type, defaultValue} = getStateConstituents( + componentName, + stateShape, + ); + + ctorParams += ` ${type} ${name},\n`; + ctorInits += `${varName}(${name}),\n `; + getters += `${type} get${capitalize(name)}() const;\n `; + let finalDefaultValue = defaultValue; + if (defaultValue.length > 0) { + finalDefaultValue = `{${defaultValue}}`; + } + stateProps += ` ${type} ${varName}${finalDefaultValue};\n `; + }); + + // Sanitize + ctorParams = sanitize(ctorParams.trim(), ','); + ctorInits = sanitize(ctorInits.trim(), ','); + + return { + ctorParams, + ctorInits, + getters, + stateProps, + }; +} module.exports = { generate( @@ -72,6 +160,7 @@ module.exports = { assumeNonnull: boolean = false, ): FilesOutput { const fileName = 'States.h'; + const stateClasses = Object.keys(schema.modules) .map(moduleName => { const module = schema.modules[moduleName]; @@ -84,14 +173,34 @@ module.exports = { if (components == null) { return null; } - return Object.keys(components) .map(componentName => { - if (components[componentName].interfaceOnly === true) { + const component = components[componentName]; + if (component.interfaceOnly === true) { return null; } - return StateTemplate({stateName: componentName}); + const state = component.state; + if (!state) { + return StateTemplate({ + stateName: componentName, + ctorParams: '', + ctorInits: '', + getters: '', + stateProps: '', + }); + } + + const {ctorParams, ctorInits, getters, stateProps} = + generateStrings(componentName, state); + + return StateTemplate({ + stateName: componentName, + ctorParams, + ctorInits, + getters, + stateProps, + }); }) .filter(Boolean) .join('\n\n'); diff --git a/packages/react-native-codegen/src/generators/components/__test_fixtures__/fixtures.js b/packages/react-native-codegen/src/generators/components/__test_fixtures__/fixtures.js index b38d07d189e..abc7cadf8c8 100644 --- a/packages/react-native-codegen/src/generators/components/__test_fixtures__/fixtures.js +++ b/packages/react-native-codegen/src/generators/components/__test_fixtures__/fixtures.js @@ -1641,6 +1641,848 @@ const EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES: SchemaType = { }, }; +const COMPONENT_WITH_BOOL_STATE: SchemaType = { + modules: { + MyComponent: { + type: 'Component', + components: { + SimpleComponent: { + extendsProps: [ + { + type: 'ReactNativeBuiltInType', + knownTypeName: 'ReactNativeCoreViewProps', + }, + ], + events: [], + props: [], + commands: [], + state: [ + { + name: 'disabled', + optional: false, + typeAnnotation: { + type: 'BooleanTypeAnnotation', + default: false, + }, + }, + ], + }, + }, + }, + }, +}; + +const COMPONENT_WITH_STRING_STATE: SchemaType = { + modules: { + MyComponent: { + type: 'Component', + components: { + SimpleComponent: { + extendsProps: [ + { + type: 'ReactNativeBuiltInType', + knownTypeName: 'ReactNativeCoreViewProps', + }, + ], + events: [], + props: [], + commands: [], + state: [ + { + name: 'accessibilityHint', + optional: true, + typeAnnotation: { + type: 'StringTypeAnnotation', + default: '', + }, + }, + { + name: 'accessibilityRole', + optional: true, + typeAnnotation: { + type: 'StringTypeAnnotation', + default: null, + }, + }, + ], + }, + }, + }, + }, +}; + +const COMPONENT_WITH_INT_STATE: SchemaType = { + modules: { + MyComponent: { + type: 'Component', + components: { + SimpleComponent: { + extendsProps: [ + { + type: 'ReactNativeBuiltInType', + knownTypeName: 'ReactNativeCoreViewProps', + }, + ], + events: [], + props: [], + commands: [], + state: [ + { + name: 'progress1', + optional: true, + typeAnnotation: { + type: 'Int32TypeAnnotation', + default: 0, + }, + }, + { + name: 'progress2', + optional: true, + typeAnnotation: { + type: 'Int32TypeAnnotation', + default: -1, + }, + }, + { + name: 'progress3', + optional: true, + typeAnnotation: { + type: 'Int32TypeAnnotation', + default: 10, + }, + }, + ], + }, + }, + }, + }, +}; + +const COMPONENT_WITH_FLOAT_STATE: SchemaType = { + modules: { + MyComponent: { + type: 'Component', + components: { + SimpleComponent: { + extendsProps: [ + { + type: 'ReactNativeBuiltInType', + knownTypeName: 'ReactNativeCoreViewProps', + }, + ], + events: [], + props: [], + commands: [], + state: [ + { + name: 'blurRadius', + optional: false, + typeAnnotation: { + type: 'FloatTypeAnnotation', + default: 0.0, + }, + }, + { + name: 'blurRadius2', + optional: true, + typeAnnotation: { + type: 'FloatTypeAnnotation', + default: 7.5, + }, + }, + { + name: 'blurRadius3', + optional: true, + typeAnnotation: { + type: 'FloatTypeAnnotation', + default: -2.1, + }, + }, + ], + }, + }, + }, + }, +}; + +const COMPONENT_WITH_DOUBLE_STATE: SchemaType = { + modules: { + MyComponent: { + type: 'Component', + components: { + SimpleComponent: { + extendsProps: [ + { + type: 'ReactNativeBuiltInType', + knownTypeName: 'ReactNativeCoreViewProps', + }, + ], + events: [], + props: [], + commands: [], + state: [ + { + name: 'd_blurRadius', + optional: false, + typeAnnotation: { + type: 'DoubleTypeAnnotation', + default: 0.0, + }, + }, + { + name: 'd_blurRadius2', + optional: true, + typeAnnotation: { + type: 'DoubleTypeAnnotation', + default: 8.9, + }, + }, + { + name: 'd_blurRadius3', + optional: true, + typeAnnotation: { + type: 'DoubleTypeAnnotation', + default: -0.5, + }, + }, + ], + }, + }, + }, + }, +}; + +const COMPONENT_WITH_COLOR_STATE: SchemaType = { + modules: { + MyComponent: { + type: 'Component', + components: { + SimpleComponent: { + extendsProps: [ + { + type: 'ReactNativeBuiltInType', + knownTypeName: 'ReactNativeCoreViewProps', + }, + ], + events: [], + props: [], + commands: [], + state: [ + { + name: 'tintColor', + optional: true, + typeAnnotation: { + type: 'ReservedPropTypeAnnotation', + name: 'ColorPrimitive', + }, + }, + ], + }, + }, + }, + }, +}; + +const COMPONENT_WITH_IMAGE_STATE: SchemaType = { + modules: { + MyComponent: { + type: 'Component', + components: { + SimpleComponent: { + extendsProps: [ + { + type: 'ReactNativeBuiltInType', + knownTypeName: 'ReactNativeCoreViewProps', + }, + ], + events: [], + props: [], + commands: [], + state: [ + { + name: 'thumbImage', + optional: true, + typeAnnotation: { + type: 'ReservedPropTypeAnnotation', + name: 'ImageSourcePrimitive', + }, + }, + ], + }, + }, + }, + }, +}; + +const COMPONENT_WITH_POINT_STATE: SchemaType = { + modules: { + MyComponent: { + type: 'Component', + components: { + SimpleComponent: { + extendsProps: [ + { + type: 'ReactNativeBuiltInType', + knownTypeName: 'ReactNativeCoreViewProps', + }, + ], + events: [], + props: [], + commands: [], + state: [ + { + name: 'startPoint', + optional: true, + typeAnnotation: { + type: 'ReservedPropTypeAnnotation', + name: 'PointPrimitive', + }, + }, + ], + }, + }, + }, + }, +}; + +const COMPONENT_WITH_EDGE_INSET_STATE_PROPS: SchemaType = { + modules: { + MyComponent: { + type: 'Component', + components: { + SimpleComponent: { + extendsProps: [ + { + type: 'ReactNativeBuiltInType', + knownTypeName: 'ReactNativeCoreViewProps', + }, + ], + events: [], + props: [], + commands: [], + state: [ + { + name: 'contentInset', + optional: true, + typeAnnotation: { + type: 'ReservedPropTypeAnnotation', + name: 'EdgeInsetsPrimitive', + }, + }, + ], + }, + }, + }, + }, +}; + +const COMPONENT_WITH_ARRAY_OF_OBJECTS_STATE: SchemaType = { + modules: { + MyComponent: { + type: 'Component', + components: { + SimpleComponent: { + extendsProps: [ + { + type: 'ReactNativeBuiltInType', + knownTypeName: 'ReactNativeCoreViewProps', + }, + ], + events: [], + props: [], + commands: [], + state: [ + { + name: 'arrayState', + optional: true, + typeAnnotation: { + type: 'ArrayTypeAnnotation', + elementType: { + type: 'ObjectTypeAnnotation', + properties: [ + { + name: 'colors', + optional: true, + typeAnnotation: { + type: 'ArrayTypeAnnotation', + elementType: { + type: 'ReservedPropTypeAnnotation', + name: 'ColorPrimitive', + }, + }, + }, + { + name: 'srcs', + optional: true, + typeAnnotation: { + type: 'ArrayTypeAnnotation', + elementType: { + type: 'ReservedPropTypeAnnotation', + name: 'ImageSourcePrimitive', + }, + }, + }, + { + name: 'points', + optional: true, + typeAnnotation: { + type: 'ArrayTypeAnnotation', + elementType: { + type: 'ReservedPropTypeAnnotation', + name: 'PointPrimitive', + }, + }, + }, + ], + }, + }, + }, + ], + }, + }, + }, + }, +}; + +const COMPONENT_WITH_ARRAY_STATE: SchemaType = { + modules: { + MyComponent: { + type: 'Component', + components: { + SimpleComponent: { + extendsProps: [ + { + type: 'ReactNativeBuiltInType', + knownTypeName: 'ReactNativeCoreViewProps', + }, + ], + events: [], + props: [], + commands: [], + state: [ + { + name: 'names', + optional: true, + typeAnnotation: { + type: 'ArrayTypeAnnotation', + elementType: { + type: 'StringTypeAnnotation', + }, + }, + }, + { + name: 'disableds', + optional: true, + typeAnnotation: { + type: 'ArrayTypeAnnotation', + elementType: { + type: 'BooleanTypeAnnotation', + }, + }, + }, + { + name: 'progress', + optional: true, + typeAnnotation: { + type: 'ArrayTypeAnnotation', + elementType: { + type: 'Int32TypeAnnotation', + }, + }, + }, + { + name: 'radii', + optional: true, + typeAnnotation: { + type: 'ArrayTypeAnnotation', + elementType: { + type: 'FloatTypeAnnotation', + }, + }, + }, + { + name: 'colors', + optional: true, + typeAnnotation: { + type: 'ArrayTypeAnnotation', + elementType: { + type: 'ReservedPropTypeAnnotation', + name: 'ColorPrimitive', + }, + }, + }, + { + name: 'srcs', + optional: true, + typeAnnotation: { + type: 'ArrayTypeAnnotation', + elementType: { + type: 'ReservedPropTypeAnnotation', + name: 'ImageSourcePrimitive', + }, + }, + }, + { + name: 'points', + optional: true, + typeAnnotation: { + type: 'ArrayTypeAnnotation', + elementType: { + type: 'ReservedPropTypeAnnotation', + name: 'PointPrimitive', + }, + }, + }, + { + name: 'sizes', + optional: true, + typeAnnotation: { + type: 'ArrayTypeAnnotation', + elementType: { + type: 'StringEnumTypeAnnotation', + default: 'small', + options: ['small', 'large'], + }, + }, + }, + { + name: 'object', + optional: true, + typeAnnotation: { + type: 'ArrayTypeAnnotation', + elementType: { + type: 'ObjectTypeAnnotation', + properties: [ + { + name: 'stringProp', + optional: true, + typeAnnotation: { + type: 'StringTypeAnnotation', + default: '', + }, + }, + ], + }, + }, + }, + { + name: 'array', + optional: true, + typeAnnotation: { + type: 'ArrayTypeAnnotation', + elementType: { + type: 'ObjectTypeAnnotation', + properties: [ + { + // This needs to stay the same as the object above + // to confirm that the structs are generated + // with unique non-colliding names + name: 'object', + optional: true, + typeAnnotation: { + type: 'ArrayTypeAnnotation', + elementType: { + type: 'ObjectTypeAnnotation', + properties: [ + { + name: 'stringProp', + optional: true, + typeAnnotation: { + type: 'StringTypeAnnotation', + default: '', + }, + }, + ], + }, + }, + }, + ], + }, + }, + }, + { + name: 'arrayOfArrayOfObject', + optional: true, + typeAnnotation: { + type: 'ArrayTypeAnnotation', + elementType: { + type: 'ArrayTypeAnnotation', + elementType: { + type: 'ObjectTypeAnnotation', + properties: [ + { + name: 'stringProp', + optional: true, + typeAnnotation: { + type: 'StringTypeAnnotation', + default: '', + }, + }, + ], + }, + }, + }, + }, + ], + }, + }, + }, + }, +}; + +const COMPONENT_WITH_OBJECT_STATE: SchemaType = { + modules: { + MyComponent: { + type: 'Component', + components: { + SimpleComponent: { + extendsProps: [ + { + type: 'ReactNativeBuiltInType', + knownTypeName: 'ReactNativeCoreViewProps', + }, + ], + events: [], + props: [], + commands: [], + state: [ + { + name: 'objectProp', + optional: true, + typeAnnotation: { + type: 'ObjectTypeAnnotation', + properties: [ + { + name: 'stringProp', + optional: true, + typeAnnotation: { + type: 'StringTypeAnnotation', + default: '', + }, + }, + { + name: 'booleanProp', + optional: true, + typeAnnotation: { + type: 'BooleanTypeAnnotation', + default: false, + }, + }, + { + name: 'floatProp', + optional: true, + typeAnnotation: { + type: 'FloatTypeAnnotation', + default: 0.0, + }, + }, + { + name: 'intProp', + optional: true, + typeAnnotation: { + type: 'Int32TypeAnnotation', + default: 0, + }, + }, + { + name: 'stringEnumProp', + optional: true, + typeAnnotation: { + type: 'StringEnumTypeAnnotation', + default: 'option1', + options: ['option1'], + }, + }, + { + name: 'intEnumProp', + optional: true, + typeAnnotation: { + type: 'Int32EnumTypeAnnotation', + default: 0, + options: [0], + }, + }, + { + name: 'objectArrayProp', + optional: false, + typeAnnotation: { + type: 'ObjectTypeAnnotation', + properties: [ + { + name: 'array', + optional: true, + typeAnnotation: { + type: 'ArrayTypeAnnotation', + elementType: { + type: 'StringTypeAnnotation', + }, + }, + }, + ], + }, + }, + { + name: 'objectPrimitiveRequiredProp', + optional: false, + typeAnnotation: { + type: 'ObjectTypeAnnotation', + properties: [ + { + name: 'image', + optional: true, + typeAnnotation: { + type: 'ReservedPropTypeAnnotation', + name: 'ImageSourcePrimitive', + }, + }, + { + name: 'color', + optional: true, + typeAnnotation: { + type: 'ReservedPropTypeAnnotation', + name: 'ColorPrimitive', + }, + }, + { + name: 'point', + optional: true, + typeAnnotation: { + type: 'ReservedPropTypeAnnotation', + name: 'PointPrimitive', + }, + }, + ], + }, + }, + { + name: 'nestedPropA', + optional: false, + typeAnnotation: { + type: 'ObjectTypeAnnotation', + properties: [ + { + name: 'nestedPropB', + optional: false, + typeAnnotation: { + type: 'ObjectTypeAnnotation', + properties: [ + { + name: 'nestedPropC', + optional: true, + typeAnnotation: { + type: 'StringTypeAnnotation', + default: '', + }, + }, + ], + }, + }, + ], + }, + }, + { + name: 'nestedArrayAsProperty', + optional: false, + typeAnnotation: { + type: 'ObjectTypeAnnotation', + properties: [ + { + name: 'arrayProp', + optional: false, + typeAnnotation: { + type: 'ArrayTypeAnnotation', + elementType: { + type: 'ObjectTypeAnnotation', + properties: [ + { + name: 'stringProp', + optional: false, + typeAnnotation: { + type: 'StringTypeAnnotation', + default: '', + }, + }, + ], + }, + }, + }, + ], + }, + }, + ], + }, + }, + ], + }, + }, + }, + }, +}; + +const COMPONENT_WITH_STRING_ENUM_STATE_PROPS: SchemaType = { + modules: { + MyComponent: { + type: 'Component', + components: { + SimpleComponent: { + extendsProps: [ + { + type: 'ReactNativeBuiltInType', + knownTypeName: 'ReactNativeCoreViewProps', + }, + ], + events: [], + props: [], + commands: [], + state: [ + { + name: 'alignment', + optional: true, + typeAnnotation: { + type: 'StringEnumTypeAnnotation', + default: 'center', + options: ['top', 'center', 'bottom-right'], + }, + }, + ], + }, + }, + }, + }, +}; + +const COMPONENT_WITH_INT_ENUM_STATE: SchemaType = { + modules: { + MyComponent: { + type: 'Component', + components: { + SimpleComponent: { + extendsProps: [ + { + type: 'ReactNativeBuiltInType', + knownTypeName: 'ReactNativeCoreViewProps', + }, + ], + events: [], + props: [], + commands: [], + state: [ + { + name: 'maxInterval', + optional: true, + typeAnnotation: { + type: 'Int32EnumTypeAnnotation', + default: 0, + options: [0, 1, 2], + }, + }, + ], + }, + }, + }, + }, +}; + module.exports = { NO_PROPS_NO_EVENTS, INTERFACE_ONLY, @@ -1669,4 +2511,18 @@ module.exports = { EXCLUDE_ANDROID, EXCLUDE_ANDROID_IOS, EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES, + COMPONENT_WITH_BOOL_STATE, + COMPONENT_WITH_STRING_STATE, + COMPONENT_WITH_INT_STATE, + COMPONENT_WITH_FLOAT_STATE, + COMPONENT_WITH_DOUBLE_STATE, + COMPONENT_WITH_COLOR_STATE, + COMPONENT_WITH_POINT_STATE, + COMPONENT_WITH_IMAGE_STATE, + COMPONENT_WITH_EDGE_INSET_STATE_PROPS, + COMPONENT_WITH_ARRAY_STATE, + COMPONENT_WITH_OBJECT_STATE, + COMPONENT_WITH_ARRAY_OF_OBJECTS_STATE, + COMPONENT_WITH_STRING_ENUM_STATE_PROPS, + COMPONENT_WITH_INT_ENUM_STATE, }; diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentDescriptorH-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentDescriptorH-test.js.snap index 7cf29170dec..4555d7aa5a4 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentDescriptorH-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentDescriptorH-test.js.snap @@ -168,6 +168,398 @@ using CommandNativeComponentComponentDescriptor = ConcreteComponentDescriptor " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorH.js + */ + +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +using SimpleComponentComponentDescriptor = ConcreteComponentDescriptor; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateComponentDescriptorH can generate fixture COMPONENT_WITH_ARRAY_STATE 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorH.js + */ + +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +using SimpleComponentComponentDescriptor = ConcreteComponentDescriptor; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateComponentDescriptorH can generate fixture COMPONENT_WITH_BOOL_STATE 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorH.js + */ + +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +using SimpleComponentComponentDescriptor = ConcreteComponentDescriptor; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateComponentDescriptorH can generate fixture COMPONENT_WITH_COLOR_STATE 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorH.js + */ + +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +using SimpleComponentComponentDescriptor = ConcreteComponentDescriptor; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateComponentDescriptorH can generate fixture COMPONENT_WITH_DOUBLE_STATE 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorH.js + */ + +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +using SimpleComponentComponentDescriptor = ConcreteComponentDescriptor; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateComponentDescriptorH can generate fixture COMPONENT_WITH_EDGE_INSET_STATE_PROPS 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorH.js + */ + +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +using SimpleComponentComponentDescriptor = ConcreteComponentDescriptor; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateComponentDescriptorH can generate fixture COMPONENT_WITH_FLOAT_STATE 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorH.js + */ + +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +using SimpleComponentComponentDescriptor = ConcreteComponentDescriptor; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateComponentDescriptorH can generate fixture COMPONENT_WITH_IMAGE_STATE 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorH.js + */ + +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +using SimpleComponentComponentDescriptor = ConcreteComponentDescriptor; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateComponentDescriptorH can generate fixture COMPONENT_WITH_INT_ENUM_STATE 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorH.js + */ + +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +using SimpleComponentComponentDescriptor = ConcreteComponentDescriptor; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateComponentDescriptorH can generate fixture COMPONENT_WITH_INT_STATE 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorH.js + */ + +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +using SimpleComponentComponentDescriptor = ConcreteComponentDescriptor; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateComponentDescriptorH can generate fixture COMPONENT_WITH_OBJECT_STATE 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorH.js + */ + +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +using SimpleComponentComponentDescriptor = ConcreteComponentDescriptor; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateComponentDescriptorH can generate fixture COMPONENT_WITH_POINT_STATE 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorH.js + */ + +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +using SimpleComponentComponentDescriptor = ConcreteComponentDescriptor; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateComponentDescriptorH can generate fixture COMPONENT_WITH_STRING_ENUM_STATE_PROPS 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorH.js + */ + +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +using SimpleComponentComponentDescriptor = ConcreteComponentDescriptor; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateComponentDescriptorH can generate fixture COMPONENT_WITH_STRING_STATE 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorH.js + */ + +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +using SimpleComponentComponentDescriptor = ConcreteComponentDescriptor; + +} // namespace react +} // namespace facebook +", +} +`; + exports[`GenerateComponentDescriptorH can generate fixture DOUBLE_PROPS 1`] = ` Map { "ComponentDescriptors.h" => " diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentHObjCpp-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentHObjCpp-test.js.snap index f7b45e6fc31..cca8a5d707a 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentHObjCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentHObjCpp-test.js.snap @@ -286,6 +286,356 @@ NS_ASSUME_NONNULL_END", } `; +exports[`GenerateComponentHObjCpp can generate fixture COMPONENT_WITH_ARRAY_OF_OBJECTS_STATE 1`] = ` +Map { + "RCTComponentViewHelpers.h" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GenerateComponentHObjCpp.js +*/ + +#import +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +@protocol RCTSimpleComponentViewProtocol + +@end + +NS_ASSUME_NONNULL_END", +} +`; + +exports[`GenerateComponentHObjCpp can generate fixture COMPONENT_WITH_ARRAY_STATE 1`] = ` +Map { + "RCTComponentViewHelpers.h" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GenerateComponentHObjCpp.js +*/ + +#import +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +@protocol RCTSimpleComponentViewProtocol + +@end + +NS_ASSUME_NONNULL_END", +} +`; + +exports[`GenerateComponentHObjCpp can generate fixture COMPONENT_WITH_BOOL_STATE 1`] = ` +Map { + "RCTComponentViewHelpers.h" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GenerateComponentHObjCpp.js +*/ + +#import +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +@protocol RCTSimpleComponentViewProtocol + +@end + +NS_ASSUME_NONNULL_END", +} +`; + +exports[`GenerateComponentHObjCpp can generate fixture COMPONENT_WITH_COLOR_STATE 1`] = ` +Map { + "RCTComponentViewHelpers.h" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GenerateComponentHObjCpp.js +*/ + +#import +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +@protocol RCTSimpleComponentViewProtocol + +@end + +NS_ASSUME_NONNULL_END", +} +`; + +exports[`GenerateComponentHObjCpp can generate fixture COMPONENT_WITH_DOUBLE_STATE 1`] = ` +Map { + "RCTComponentViewHelpers.h" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GenerateComponentHObjCpp.js +*/ + +#import +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +@protocol RCTSimpleComponentViewProtocol + +@end + +NS_ASSUME_NONNULL_END", +} +`; + +exports[`GenerateComponentHObjCpp can generate fixture COMPONENT_WITH_EDGE_INSET_STATE_PROPS 1`] = ` +Map { + "RCTComponentViewHelpers.h" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GenerateComponentHObjCpp.js +*/ + +#import +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +@protocol RCTSimpleComponentViewProtocol + +@end + +NS_ASSUME_NONNULL_END", +} +`; + +exports[`GenerateComponentHObjCpp can generate fixture COMPONENT_WITH_FLOAT_STATE 1`] = ` +Map { + "RCTComponentViewHelpers.h" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GenerateComponentHObjCpp.js +*/ + +#import +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +@protocol RCTSimpleComponentViewProtocol + +@end + +NS_ASSUME_NONNULL_END", +} +`; + +exports[`GenerateComponentHObjCpp can generate fixture COMPONENT_WITH_IMAGE_STATE 1`] = ` +Map { + "RCTComponentViewHelpers.h" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GenerateComponentHObjCpp.js +*/ + +#import +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +@protocol RCTSimpleComponentViewProtocol + +@end + +NS_ASSUME_NONNULL_END", +} +`; + +exports[`GenerateComponentHObjCpp can generate fixture COMPONENT_WITH_INT_ENUM_STATE 1`] = ` +Map { + "RCTComponentViewHelpers.h" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GenerateComponentHObjCpp.js +*/ + +#import +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +@protocol RCTSimpleComponentViewProtocol + +@end + +NS_ASSUME_NONNULL_END", +} +`; + +exports[`GenerateComponentHObjCpp can generate fixture COMPONENT_WITH_INT_STATE 1`] = ` +Map { + "RCTComponentViewHelpers.h" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GenerateComponentHObjCpp.js +*/ + +#import +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +@protocol RCTSimpleComponentViewProtocol + +@end + +NS_ASSUME_NONNULL_END", +} +`; + +exports[`GenerateComponentHObjCpp can generate fixture COMPONENT_WITH_OBJECT_STATE 1`] = ` +Map { + "RCTComponentViewHelpers.h" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GenerateComponentHObjCpp.js +*/ + +#import +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +@protocol RCTSimpleComponentViewProtocol + +@end + +NS_ASSUME_NONNULL_END", +} +`; + +exports[`GenerateComponentHObjCpp can generate fixture COMPONENT_WITH_POINT_STATE 1`] = ` +Map { + "RCTComponentViewHelpers.h" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GenerateComponentHObjCpp.js +*/ + +#import +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +@protocol RCTSimpleComponentViewProtocol + +@end + +NS_ASSUME_NONNULL_END", +} +`; + +exports[`GenerateComponentHObjCpp can generate fixture COMPONENT_WITH_STRING_ENUM_STATE_PROPS 1`] = ` +Map { + "RCTComponentViewHelpers.h" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GenerateComponentHObjCpp.js +*/ + +#import +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +@protocol RCTSimpleComponentViewProtocol + +@end + +NS_ASSUME_NONNULL_END", +} +`; + +exports[`GenerateComponentHObjCpp can generate fixture COMPONENT_WITH_STRING_STATE 1`] = ` +Map { + "RCTComponentViewHelpers.h" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GenerateComponentHObjCpp.js +*/ + +#import +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +@protocol RCTSimpleComponentViewProtocol + +@end + +NS_ASSUME_NONNULL_END", +} +`; + exports[`GenerateComponentHObjCpp can generate fixture DOUBLE_PROPS 1`] = ` Map { "RCTComponentViewHelpers.h" => "/** diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterCpp-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterCpp-test.js.snap index 9c58425980f..27acf965121 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterCpp-test.js.snap @@ -144,6 +144,356 @@ namespace react { +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateEventEmitterCpp can generate fixture COMPONENT_WITH_ARRAY_OF_OBJECTS_STATE 1`] = ` +Map { + "EventEmitters.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateEventEmitterCpp.js + */ + +#include + +namespace facebook { +namespace react { + + + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateEventEmitterCpp can generate fixture COMPONENT_WITH_ARRAY_STATE 1`] = ` +Map { + "EventEmitters.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateEventEmitterCpp.js + */ + +#include + +namespace facebook { +namespace react { + + + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateEventEmitterCpp can generate fixture COMPONENT_WITH_BOOL_STATE 1`] = ` +Map { + "EventEmitters.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateEventEmitterCpp.js + */ + +#include + +namespace facebook { +namespace react { + + + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateEventEmitterCpp can generate fixture COMPONENT_WITH_COLOR_STATE 1`] = ` +Map { + "EventEmitters.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateEventEmitterCpp.js + */ + +#include + +namespace facebook { +namespace react { + + + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateEventEmitterCpp can generate fixture COMPONENT_WITH_DOUBLE_STATE 1`] = ` +Map { + "EventEmitters.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateEventEmitterCpp.js + */ + +#include + +namespace facebook { +namespace react { + + + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateEventEmitterCpp can generate fixture COMPONENT_WITH_EDGE_INSET_STATE_PROPS 1`] = ` +Map { + "EventEmitters.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateEventEmitterCpp.js + */ + +#include + +namespace facebook { +namespace react { + + + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateEventEmitterCpp can generate fixture COMPONENT_WITH_FLOAT_STATE 1`] = ` +Map { + "EventEmitters.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateEventEmitterCpp.js + */ + +#include + +namespace facebook { +namespace react { + + + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateEventEmitterCpp can generate fixture COMPONENT_WITH_IMAGE_STATE 1`] = ` +Map { + "EventEmitters.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateEventEmitterCpp.js + */ + +#include + +namespace facebook { +namespace react { + + + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateEventEmitterCpp can generate fixture COMPONENT_WITH_INT_ENUM_STATE 1`] = ` +Map { + "EventEmitters.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateEventEmitterCpp.js + */ + +#include + +namespace facebook { +namespace react { + + + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateEventEmitterCpp can generate fixture COMPONENT_WITH_INT_STATE 1`] = ` +Map { + "EventEmitters.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateEventEmitterCpp.js + */ + +#include + +namespace facebook { +namespace react { + + + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateEventEmitterCpp can generate fixture COMPONENT_WITH_OBJECT_STATE 1`] = ` +Map { + "EventEmitters.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateEventEmitterCpp.js + */ + +#include + +namespace facebook { +namespace react { + + + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateEventEmitterCpp can generate fixture COMPONENT_WITH_POINT_STATE 1`] = ` +Map { + "EventEmitters.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateEventEmitterCpp.js + */ + +#include + +namespace facebook { +namespace react { + + + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateEventEmitterCpp can generate fixture COMPONENT_WITH_STRING_ENUM_STATE_PROPS 1`] = ` +Map { + "EventEmitters.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateEventEmitterCpp.js + */ + +#include + +namespace facebook { +namespace react { + + + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateEventEmitterCpp can generate fixture COMPONENT_WITH_STRING_STATE 1`] = ` +Map { + "EventEmitters.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateEventEmitterCpp.js + */ + +#include + +namespace facebook { +namespace react { + + + } // namespace react } // namespace facebook ", diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterH-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterH-test.js.snap index fffed704338..715f181cd61 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterH-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterH-test.js.snap @@ -196,6 +196,482 @@ class JSI_EXPORT CommandNativeComponentEventEmitter : public ViewEventEmitter { +}; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateEventEmitterH can generate fixture COMPONENT_WITH_ARRAY_OF_OBJECTS_STATE 1`] = ` +Map { + "EventEmitters.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateEventEmitterH.js + */ +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +class JSI_EXPORT SimpleComponentEventEmitter : public ViewEventEmitter { + public: + using ViewEventEmitter::ViewEventEmitter; + + + + +}; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateEventEmitterH can generate fixture COMPONENT_WITH_ARRAY_STATE 1`] = ` +Map { + "EventEmitters.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateEventEmitterH.js + */ +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +class JSI_EXPORT SimpleComponentEventEmitter : public ViewEventEmitter { + public: + using ViewEventEmitter::ViewEventEmitter; + + + + +}; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateEventEmitterH can generate fixture COMPONENT_WITH_BOOL_STATE 1`] = ` +Map { + "EventEmitters.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateEventEmitterH.js + */ +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +class JSI_EXPORT SimpleComponentEventEmitter : public ViewEventEmitter { + public: + using ViewEventEmitter::ViewEventEmitter; + + + + +}; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateEventEmitterH can generate fixture COMPONENT_WITH_COLOR_STATE 1`] = ` +Map { + "EventEmitters.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateEventEmitterH.js + */ +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +class JSI_EXPORT SimpleComponentEventEmitter : public ViewEventEmitter { + public: + using ViewEventEmitter::ViewEventEmitter; + + + + +}; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateEventEmitterH can generate fixture COMPONENT_WITH_DOUBLE_STATE 1`] = ` +Map { + "EventEmitters.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateEventEmitterH.js + */ +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +class JSI_EXPORT SimpleComponentEventEmitter : public ViewEventEmitter { + public: + using ViewEventEmitter::ViewEventEmitter; + + + + +}; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateEventEmitterH can generate fixture COMPONENT_WITH_EDGE_INSET_STATE_PROPS 1`] = ` +Map { + "EventEmitters.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateEventEmitterH.js + */ +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +class JSI_EXPORT SimpleComponentEventEmitter : public ViewEventEmitter { + public: + using ViewEventEmitter::ViewEventEmitter; + + + + +}; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateEventEmitterH can generate fixture COMPONENT_WITH_FLOAT_STATE 1`] = ` +Map { + "EventEmitters.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateEventEmitterH.js + */ +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +class JSI_EXPORT SimpleComponentEventEmitter : public ViewEventEmitter { + public: + using ViewEventEmitter::ViewEventEmitter; + + + + +}; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateEventEmitterH can generate fixture COMPONENT_WITH_IMAGE_STATE 1`] = ` +Map { + "EventEmitters.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateEventEmitterH.js + */ +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +class JSI_EXPORT SimpleComponentEventEmitter : public ViewEventEmitter { + public: + using ViewEventEmitter::ViewEventEmitter; + + + + +}; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateEventEmitterH can generate fixture COMPONENT_WITH_INT_ENUM_STATE 1`] = ` +Map { + "EventEmitters.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateEventEmitterH.js + */ +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +class JSI_EXPORT SimpleComponentEventEmitter : public ViewEventEmitter { + public: + using ViewEventEmitter::ViewEventEmitter; + + + + +}; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateEventEmitterH can generate fixture COMPONENT_WITH_INT_STATE 1`] = ` +Map { + "EventEmitters.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateEventEmitterH.js + */ +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +class JSI_EXPORT SimpleComponentEventEmitter : public ViewEventEmitter { + public: + using ViewEventEmitter::ViewEventEmitter; + + + + +}; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateEventEmitterH can generate fixture COMPONENT_WITH_OBJECT_STATE 1`] = ` +Map { + "EventEmitters.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateEventEmitterH.js + */ +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +class JSI_EXPORT SimpleComponentEventEmitter : public ViewEventEmitter { + public: + using ViewEventEmitter::ViewEventEmitter; + + + + +}; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateEventEmitterH can generate fixture COMPONENT_WITH_POINT_STATE 1`] = ` +Map { + "EventEmitters.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateEventEmitterH.js + */ +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +class JSI_EXPORT SimpleComponentEventEmitter : public ViewEventEmitter { + public: + using ViewEventEmitter::ViewEventEmitter; + + + + +}; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateEventEmitterH can generate fixture COMPONENT_WITH_STRING_ENUM_STATE_PROPS 1`] = ` +Map { + "EventEmitters.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateEventEmitterH.js + */ +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +class JSI_EXPORT SimpleComponentEventEmitter : public ViewEventEmitter { + public: + using ViewEventEmitter::ViewEventEmitter; + + + + +}; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateEventEmitterH can generate fixture COMPONENT_WITH_STRING_STATE 1`] = ` +Map { + "EventEmitters.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateEventEmitterH.js + */ +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +class JSI_EXPORT SimpleComponentEventEmitter : public ViewEventEmitter { + public: + using ViewEventEmitter::ViewEventEmitter; + + + + }; } // namespace react diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsCpp-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsCpp-test.js.snap index 56ada8a6bff..6056796857e 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsCpp-test.js.snap @@ -209,6 +209,468 @@ CommandNativeComponentProps::CommandNativeComponentProps( } `; +exports[`GeneratePropsCpp can generate fixture COMPONENT_WITH_ARRAY_OF_OBJECTS_STATE 1`] = ` +Map { + "Props.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GeneratePropsCpp.js + */ + +#include +#include +#include + +namespace facebook { +namespace react { + +SimpleComponentProps::SimpleComponentProps( + const PropsParserContext &context, + const SimpleComponentProps &sourceProps, + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps) + + + {} + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GeneratePropsCpp can generate fixture COMPONENT_WITH_ARRAY_STATE 1`] = ` +Map { + "Props.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GeneratePropsCpp.js + */ + +#include +#include +#include + +namespace facebook { +namespace react { + +SimpleComponentProps::SimpleComponentProps( + const PropsParserContext &context, + const SimpleComponentProps &sourceProps, + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps) + + + {} + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GeneratePropsCpp can generate fixture COMPONENT_WITH_BOOL_STATE 1`] = ` +Map { + "Props.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GeneratePropsCpp.js + */ + +#include +#include +#include + +namespace facebook { +namespace react { + +SimpleComponentProps::SimpleComponentProps( + const PropsParserContext &context, + const SimpleComponentProps &sourceProps, + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps) + + + {} + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GeneratePropsCpp can generate fixture COMPONENT_WITH_COLOR_STATE 1`] = ` +Map { + "Props.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GeneratePropsCpp.js + */ + +#include +#include +#include + +namespace facebook { +namespace react { + +SimpleComponentProps::SimpleComponentProps( + const PropsParserContext &context, + const SimpleComponentProps &sourceProps, + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps) + + + {} + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GeneratePropsCpp can generate fixture COMPONENT_WITH_DOUBLE_STATE 1`] = ` +Map { + "Props.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GeneratePropsCpp.js + */ + +#include +#include +#include + +namespace facebook { +namespace react { + +SimpleComponentProps::SimpleComponentProps( + const PropsParserContext &context, + const SimpleComponentProps &sourceProps, + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps) + + + {} + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GeneratePropsCpp can generate fixture COMPONENT_WITH_EDGE_INSET_STATE_PROPS 1`] = ` +Map { + "Props.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GeneratePropsCpp.js + */ + +#include +#include +#include + +namespace facebook { +namespace react { + +SimpleComponentProps::SimpleComponentProps( + const PropsParserContext &context, + const SimpleComponentProps &sourceProps, + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps) + + + {} + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GeneratePropsCpp can generate fixture COMPONENT_WITH_FLOAT_STATE 1`] = ` +Map { + "Props.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GeneratePropsCpp.js + */ + +#include +#include +#include + +namespace facebook { +namespace react { + +SimpleComponentProps::SimpleComponentProps( + const PropsParserContext &context, + const SimpleComponentProps &sourceProps, + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps) + + + {} + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GeneratePropsCpp can generate fixture COMPONENT_WITH_IMAGE_STATE 1`] = ` +Map { + "Props.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GeneratePropsCpp.js + */ + +#include +#include +#include + +namespace facebook { +namespace react { + +SimpleComponentProps::SimpleComponentProps( + const PropsParserContext &context, + const SimpleComponentProps &sourceProps, + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps) + + + {} + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GeneratePropsCpp can generate fixture COMPONENT_WITH_INT_ENUM_STATE 1`] = ` +Map { + "Props.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GeneratePropsCpp.js + */ + +#include +#include +#include + +namespace facebook { +namespace react { + +SimpleComponentProps::SimpleComponentProps( + const PropsParserContext &context, + const SimpleComponentProps &sourceProps, + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps) + + + {} + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GeneratePropsCpp can generate fixture COMPONENT_WITH_INT_STATE 1`] = ` +Map { + "Props.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GeneratePropsCpp.js + */ + +#include +#include +#include + +namespace facebook { +namespace react { + +SimpleComponentProps::SimpleComponentProps( + const PropsParserContext &context, + const SimpleComponentProps &sourceProps, + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps) + + + {} + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GeneratePropsCpp can generate fixture COMPONENT_WITH_OBJECT_STATE 1`] = ` +Map { + "Props.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GeneratePropsCpp.js + */ + +#include +#include +#include + +namespace facebook { +namespace react { + +SimpleComponentProps::SimpleComponentProps( + const PropsParserContext &context, + const SimpleComponentProps &sourceProps, + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps) + + + {} + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GeneratePropsCpp can generate fixture COMPONENT_WITH_POINT_STATE 1`] = ` +Map { + "Props.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GeneratePropsCpp.js + */ + +#include +#include +#include + +namespace facebook { +namespace react { + +SimpleComponentProps::SimpleComponentProps( + const PropsParserContext &context, + const SimpleComponentProps &sourceProps, + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps) + + + {} + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GeneratePropsCpp can generate fixture COMPONENT_WITH_STRING_ENUM_STATE_PROPS 1`] = ` +Map { + "Props.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GeneratePropsCpp.js + */ + +#include +#include +#include + +namespace facebook { +namespace react { + +SimpleComponentProps::SimpleComponentProps( + const PropsParserContext &context, + const SimpleComponentProps &sourceProps, + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps) + + + {} + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GeneratePropsCpp can generate fixture COMPONENT_WITH_STRING_STATE 1`] = ` +Map { + "Props.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GeneratePropsCpp.js + */ + +#include +#include +#include + +namespace facebook { +namespace react { + +SimpleComponentProps::SimpleComponentProps( + const PropsParserContext &context, + const SimpleComponentProps &sourceProps, + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps) + + + {} + +} // namespace react +} // namespace facebook +", +} +`; + exports[`GeneratePropsCpp can generate fixture DOUBLE_PROPS 1`] = ` Map { "Props.cpp" => " diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsH-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsH-test.js.snap index 7f8a84fe002..908a1746d77 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsH-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsH-test.js.snap @@ -439,6 +439,510 @@ class JSI_EXPORT CommandNativeComponentProps final : public ViewProps { } `; +exports[`GeneratePropsH can generate fixture COMPONENT_WITH_ARRAY_OF_OBJECTS_STATE 1`] = ` +Map { + "Props.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GeneratePropsH.js + */ +#pragma once + +#include +#include +#include + +namespace facebook { +namespace react { + +class JSI_EXPORT SimpleComponentProps final : public ViewProps { + public: + SimpleComponentProps() = default; + SimpleComponentProps(const PropsParserContext& context, const SimpleComponentProps &sourceProps, const RawProps &rawProps); + +#pragma mark - Props + + +}; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GeneratePropsH can generate fixture COMPONENT_WITH_ARRAY_STATE 1`] = ` +Map { + "Props.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GeneratePropsH.js + */ +#pragma once + +#include +#include +#include + +namespace facebook { +namespace react { + +class JSI_EXPORT SimpleComponentProps final : public ViewProps { + public: + SimpleComponentProps() = default; + SimpleComponentProps(const PropsParserContext& context, const SimpleComponentProps &sourceProps, const RawProps &rawProps); + +#pragma mark - Props + + +}; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GeneratePropsH can generate fixture COMPONENT_WITH_BOOL_STATE 1`] = ` +Map { + "Props.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GeneratePropsH.js + */ +#pragma once + +#include +#include +#include + +namespace facebook { +namespace react { + +class JSI_EXPORT SimpleComponentProps final : public ViewProps { + public: + SimpleComponentProps() = default; + SimpleComponentProps(const PropsParserContext& context, const SimpleComponentProps &sourceProps, const RawProps &rawProps); + +#pragma mark - Props + + +}; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GeneratePropsH can generate fixture COMPONENT_WITH_COLOR_STATE 1`] = ` +Map { + "Props.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GeneratePropsH.js + */ +#pragma once + +#include +#include +#include + +namespace facebook { +namespace react { + +class JSI_EXPORT SimpleComponentProps final : public ViewProps { + public: + SimpleComponentProps() = default; + SimpleComponentProps(const PropsParserContext& context, const SimpleComponentProps &sourceProps, const RawProps &rawProps); + +#pragma mark - Props + + +}; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GeneratePropsH can generate fixture COMPONENT_WITH_DOUBLE_STATE 1`] = ` +Map { + "Props.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GeneratePropsH.js + */ +#pragma once + +#include +#include +#include + +namespace facebook { +namespace react { + +class JSI_EXPORT SimpleComponentProps final : public ViewProps { + public: + SimpleComponentProps() = default; + SimpleComponentProps(const PropsParserContext& context, const SimpleComponentProps &sourceProps, const RawProps &rawProps); + +#pragma mark - Props + + +}; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GeneratePropsH can generate fixture COMPONENT_WITH_EDGE_INSET_STATE_PROPS 1`] = ` +Map { + "Props.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GeneratePropsH.js + */ +#pragma once + +#include +#include +#include + +namespace facebook { +namespace react { + +class JSI_EXPORT SimpleComponentProps final : public ViewProps { + public: + SimpleComponentProps() = default; + SimpleComponentProps(const PropsParserContext& context, const SimpleComponentProps &sourceProps, const RawProps &rawProps); + +#pragma mark - Props + + +}; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GeneratePropsH can generate fixture COMPONENT_WITH_FLOAT_STATE 1`] = ` +Map { + "Props.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GeneratePropsH.js + */ +#pragma once + +#include +#include +#include + +namespace facebook { +namespace react { + +class JSI_EXPORT SimpleComponentProps final : public ViewProps { + public: + SimpleComponentProps() = default; + SimpleComponentProps(const PropsParserContext& context, const SimpleComponentProps &sourceProps, const RawProps &rawProps); + +#pragma mark - Props + + +}; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GeneratePropsH can generate fixture COMPONENT_WITH_IMAGE_STATE 1`] = ` +Map { + "Props.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GeneratePropsH.js + */ +#pragma once + +#include +#include +#include + +namespace facebook { +namespace react { + +class JSI_EXPORT SimpleComponentProps final : public ViewProps { + public: + SimpleComponentProps() = default; + SimpleComponentProps(const PropsParserContext& context, const SimpleComponentProps &sourceProps, const RawProps &rawProps); + +#pragma mark - Props + + +}; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GeneratePropsH can generate fixture COMPONENT_WITH_INT_ENUM_STATE 1`] = ` +Map { + "Props.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GeneratePropsH.js + */ +#pragma once + +#include +#include +#include + +namespace facebook { +namespace react { + +class JSI_EXPORT SimpleComponentProps final : public ViewProps { + public: + SimpleComponentProps() = default; + SimpleComponentProps(const PropsParserContext& context, const SimpleComponentProps &sourceProps, const RawProps &rawProps); + +#pragma mark - Props + + +}; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GeneratePropsH can generate fixture COMPONENT_WITH_INT_STATE 1`] = ` +Map { + "Props.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GeneratePropsH.js + */ +#pragma once + +#include +#include +#include + +namespace facebook { +namespace react { + +class JSI_EXPORT SimpleComponentProps final : public ViewProps { + public: + SimpleComponentProps() = default; + SimpleComponentProps(const PropsParserContext& context, const SimpleComponentProps &sourceProps, const RawProps &rawProps); + +#pragma mark - Props + + +}; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GeneratePropsH can generate fixture COMPONENT_WITH_OBJECT_STATE 1`] = ` +Map { + "Props.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GeneratePropsH.js + */ +#pragma once + +#include +#include +#include + +namespace facebook { +namespace react { + +class JSI_EXPORT SimpleComponentProps final : public ViewProps { + public: + SimpleComponentProps() = default; + SimpleComponentProps(const PropsParserContext& context, const SimpleComponentProps &sourceProps, const RawProps &rawProps); + +#pragma mark - Props + + +}; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GeneratePropsH can generate fixture COMPONENT_WITH_POINT_STATE 1`] = ` +Map { + "Props.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GeneratePropsH.js + */ +#pragma once + +#include +#include +#include + +namespace facebook { +namespace react { + +class JSI_EXPORT SimpleComponentProps final : public ViewProps { + public: + SimpleComponentProps() = default; + SimpleComponentProps(const PropsParserContext& context, const SimpleComponentProps &sourceProps, const RawProps &rawProps); + +#pragma mark - Props + + +}; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GeneratePropsH can generate fixture COMPONENT_WITH_STRING_ENUM_STATE_PROPS 1`] = ` +Map { + "Props.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GeneratePropsH.js + */ +#pragma once + +#include +#include +#include + +namespace facebook { +namespace react { + +class JSI_EXPORT SimpleComponentProps final : public ViewProps { + public: + SimpleComponentProps() = default; + SimpleComponentProps(const PropsParserContext& context, const SimpleComponentProps &sourceProps, const RawProps &rawProps); + +#pragma mark - Props + + +}; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GeneratePropsH can generate fixture COMPONENT_WITH_STRING_STATE 1`] = ` +Map { + "Props.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GeneratePropsH.js + */ +#pragma once + +#include +#include +#include + +namespace facebook { +namespace react { + +class JSI_EXPORT SimpleComponentProps final : public ViewProps { + public: + SimpleComponentProps() = default; + SimpleComponentProps(const PropsParserContext& context, const SimpleComponentProps &sourceProps, const RawProps &rawProps); + +#pragma mark - Props + + +}; + +} // namespace react +} // namespace facebook +", +} +`; + exports[`GeneratePropsH can generate fixture DOUBLE_PROPS 1`] = ` Map { "Props.h" => " diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaDelegate-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaDelegate-test.js.snap index 6c5dd2dbb4f..0c2e9079678 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaDelegate-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaDelegate-test.js.snap @@ -275,6 +275,440 @@ public class CommandNativeComponentManagerDelegate "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GeneratePropsJavaDelegate.js +*/ + +package com.facebook.react.viewmanagers; + +import android.view.View; +import androidx.annotation.Nullable; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.BaseViewManagerInterface; + +public class SimpleComponentManagerDelegate & SimpleComponentManagerInterface> extends BaseViewManagerDelegate { + public SimpleComponentManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { + super.setProperty(view, propName, value); + } +} +", +} +`; + +exports[`GeneratePropsJavaDelegate can generate fixture COMPONENT_WITH_ARRAY_STATE 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/SimpleComponentManagerDelegate.java" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GeneratePropsJavaDelegate.js +*/ + +package com.facebook.react.viewmanagers; + +import android.view.View; +import androidx.annotation.Nullable; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.BaseViewManagerInterface; + +public class SimpleComponentManagerDelegate & SimpleComponentManagerInterface> extends BaseViewManagerDelegate { + public SimpleComponentManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { + super.setProperty(view, propName, value); + } +} +", +} +`; + +exports[`GeneratePropsJavaDelegate can generate fixture COMPONENT_WITH_BOOL_STATE 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/SimpleComponentManagerDelegate.java" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GeneratePropsJavaDelegate.js +*/ + +package com.facebook.react.viewmanagers; + +import android.view.View; +import androidx.annotation.Nullable; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.BaseViewManagerInterface; + +public class SimpleComponentManagerDelegate & SimpleComponentManagerInterface> extends BaseViewManagerDelegate { + public SimpleComponentManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { + super.setProperty(view, propName, value); + } +} +", +} +`; + +exports[`GeneratePropsJavaDelegate can generate fixture COMPONENT_WITH_COLOR_STATE 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/SimpleComponentManagerDelegate.java" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GeneratePropsJavaDelegate.js +*/ + +package com.facebook.react.viewmanagers; + +import android.view.View; +import androidx.annotation.Nullable; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.BaseViewManagerInterface; + +public class SimpleComponentManagerDelegate & SimpleComponentManagerInterface> extends BaseViewManagerDelegate { + public SimpleComponentManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { + super.setProperty(view, propName, value); + } +} +", +} +`; + +exports[`GeneratePropsJavaDelegate can generate fixture COMPONENT_WITH_DOUBLE_STATE 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/SimpleComponentManagerDelegate.java" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GeneratePropsJavaDelegate.js +*/ + +package com.facebook.react.viewmanagers; + +import android.view.View; +import androidx.annotation.Nullable; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.BaseViewManagerInterface; + +public class SimpleComponentManagerDelegate & SimpleComponentManagerInterface> extends BaseViewManagerDelegate { + public SimpleComponentManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { + super.setProperty(view, propName, value); + } +} +", +} +`; + +exports[`GeneratePropsJavaDelegate can generate fixture COMPONENT_WITH_EDGE_INSET_STATE_PROPS 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/SimpleComponentManagerDelegate.java" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GeneratePropsJavaDelegate.js +*/ + +package com.facebook.react.viewmanagers; + +import android.view.View; +import androidx.annotation.Nullable; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.BaseViewManagerInterface; + +public class SimpleComponentManagerDelegate & SimpleComponentManagerInterface> extends BaseViewManagerDelegate { + public SimpleComponentManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { + super.setProperty(view, propName, value); + } +} +", +} +`; + +exports[`GeneratePropsJavaDelegate can generate fixture COMPONENT_WITH_FLOAT_STATE 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/SimpleComponentManagerDelegate.java" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GeneratePropsJavaDelegate.js +*/ + +package com.facebook.react.viewmanagers; + +import android.view.View; +import androidx.annotation.Nullable; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.BaseViewManagerInterface; + +public class SimpleComponentManagerDelegate & SimpleComponentManagerInterface> extends BaseViewManagerDelegate { + public SimpleComponentManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { + super.setProperty(view, propName, value); + } +} +", +} +`; + +exports[`GeneratePropsJavaDelegate can generate fixture COMPONENT_WITH_IMAGE_STATE 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/SimpleComponentManagerDelegate.java" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GeneratePropsJavaDelegate.js +*/ + +package com.facebook.react.viewmanagers; + +import android.view.View; +import androidx.annotation.Nullable; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.BaseViewManagerInterface; + +public class SimpleComponentManagerDelegate & SimpleComponentManagerInterface> extends BaseViewManagerDelegate { + public SimpleComponentManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { + super.setProperty(view, propName, value); + } +} +", +} +`; + +exports[`GeneratePropsJavaDelegate can generate fixture COMPONENT_WITH_INT_ENUM_STATE 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/SimpleComponentManagerDelegate.java" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GeneratePropsJavaDelegate.js +*/ + +package com.facebook.react.viewmanagers; + +import android.view.View; +import androidx.annotation.Nullable; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.BaseViewManagerInterface; + +public class SimpleComponentManagerDelegate & SimpleComponentManagerInterface> extends BaseViewManagerDelegate { + public SimpleComponentManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { + super.setProperty(view, propName, value); + } +} +", +} +`; + +exports[`GeneratePropsJavaDelegate can generate fixture COMPONENT_WITH_INT_STATE 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/SimpleComponentManagerDelegate.java" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GeneratePropsJavaDelegate.js +*/ + +package com.facebook.react.viewmanagers; + +import android.view.View; +import androidx.annotation.Nullable; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.BaseViewManagerInterface; + +public class SimpleComponentManagerDelegate & SimpleComponentManagerInterface> extends BaseViewManagerDelegate { + public SimpleComponentManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { + super.setProperty(view, propName, value); + } +} +", +} +`; + +exports[`GeneratePropsJavaDelegate can generate fixture COMPONENT_WITH_OBJECT_STATE 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/SimpleComponentManagerDelegate.java" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GeneratePropsJavaDelegate.js +*/ + +package com.facebook.react.viewmanagers; + +import android.view.View; +import androidx.annotation.Nullable; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.BaseViewManagerInterface; + +public class SimpleComponentManagerDelegate & SimpleComponentManagerInterface> extends BaseViewManagerDelegate { + public SimpleComponentManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { + super.setProperty(view, propName, value); + } +} +", +} +`; + +exports[`GeneratePropsJavaDelegate can generate fixture COMPONENT_WITH_POINT_STATE 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/SimpleComponentManagerDelegate.java" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GeneratePropsJavaDelegate.js +*/ + +package com.facebook.react.viewmanagers; + +import android.view.View; +import androidx.annotation.Nullable; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.BaseViewManagerInterface; + +public class SimpleComponentManagerDelegate & SimpleComponentManagerInterface> extends BaseViewManagerDelegate { + public SimpleComponentManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { + super.setProperty(view, propName, value); + } +} +", +} +`; + +exports[`GeneratePropsJavaDelegate can generate fixture COMPONENT_WITH_STRING_ENUM_STATE_PROPS 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/SimpleComponentManagerDelegate.java" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GeneratePropsJavaDelegate.js +*/ + +package com.facebook.react.viewmanagers; + +import android.view.View; +import androidx.annotation.Nullable; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.BaseViewManagerInterface; + +public class SimpleComponentManagerDelegate & SimpleComponentManagerInterface> extends BaseViewManagerDelegate { + public SimpleComponentManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { + super.setProperty(view, propName, value); + } +} +", +} +`; + +exports[`GeneratePropsJavaDelegate can generate fixture COMPONENT_WITH_STRING_STATE 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/SimpleComponentManagerDelegate.java" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GeneratePropsJavaDelegate.js +*/ + +package com.facebook.react.viewmanagers; + +import android.view.View; +import androidx.annotation.Nullable; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.BaseViewManagerInterface; + +public class SimpleComponentManagerDelegate & SimpleComponentManagerInterface> extends BaseViewManagerDelegate { + public SimpleComponentManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { + super.setProperty(view, propName, value); + } +} +", +} +`; + exports[`GeneratePropsJavaDelegate can generate fixture DOUBLE_PROPS 1`] = ` Map { "java/com/facebook/react/viewmanagers/DoublePropNativeComponentManagerDelegate.java" => "/** diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaInterface-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaInterface-test.js.snap index c4e652f19a3..a8079769492 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaInterface-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaInterface-test.js.snap @@ -152,6 +152,314 @@ public interface CommandNativeComponentManagerInterface { } `; +exports[`GeneratePropsJavaInterface can generate fixture COMPONENT_WITH_ARRAY_OF_OBJECTS_STATE 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/SimpleComponentManagerInterface.java" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GeneratePropsJavaInterface.js +*/ + +package com.facebook.react.viewmanagers; + +import android.view.View; + +public interface SimpleComponentManagerInterface { + // No props +} +", +} +`; + +exports[`GeneratePropsJavaInterface can generate fixture COMPONENT_WITH_ARRAY_STATE 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/SimpleComponentManagerInterface.java" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GeneratePropsJavaInterface.js +*/ + +package com.facebook.react.viewmanagers; + +import android.view.View; + +public interface SimpleComponentManagerInterface { + // No props +} +", +} +`; + +exports[`GeneratePropsJavaInterface can generate fixture COMPONENT_WITH_BOOL_STATE 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/SimpleComponentManagerInterface.java" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GeneratePropsJavaInterface.js +*/ + +package com.facebook.react.viewmanagers; + +import android.view.View; + +public interface SimpleComponentManagerInterface { + // No props +} +", +} +`; + +exports[`GeneratePropsJavaInterface can generate fixture COMPONENT_WITH_COLOR_STATE 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/SimpleComponentManagerInterface.java" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GeneratePropsJavaInterface.js +*/ + +package com.facebook.react.viewmanagers; + +import android.view.View; + +public interface SimpleComponentManagerInterface { + // No props +} +", +} +`; + +exports[`GeneratePropsJavaInterface can generate fixture COMPONENT_WITH_DOUBLE_STATE 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/SimpleComponentManagerInterface.java" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GeneratePropsJavaInterface.js +*/ + +package com.facebook.react.viewmanagers; + +import android.view.View; + +public interface SimpleComponentManagerInterface { + // No props +} +", +} +`; + +exports[`GeneratePropsJavaInterface can generate fixture COMPONENT_WITH_EDGE_INSET_STATE_PROPS 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/SimpleComponentManagerInterface.java" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GeneratePropsJavaInterface.js +*/ + +package com.facebook.react.viewmanagers; + +import android.view.View; + +public interface SimpleComponentManagerInterface { + // No props +} +", +} +`; + +exports[`GeneratePropsJavaInterface can generate fixture COMPONENT_WITH_FLOAT_STATE 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/SimpleComponentManagerInterface.java" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GeneratePropsJavaInterface.js +*/ + +package com.facebook.react.viewmanagers; + +import android.view.View; + +public interface SimpleComponentManagerInterface { + // No props +} +", +} +`; + +exports[`GeneratePropsJavaInterface can generate fixture COMPONENT_WITH_IMAGE_STATE 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/SimpleComponentManagerInterface.java" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GeneratePropsJavaInterface.js +*/ + +package com.facebook.react.viewmanagers; + +import android.view.View; + +public interface SimpleComponentManagerInterface { + // No props +} +", +} +`; + +exports[`GeneratePropsJavaInterface can generate fixture COMPONENT_WITH_INT_ENUM_STATE 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/SimpleComponentManagerInterface.java" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GeneratePropsJavaInterface.js +*/ + +package com.facebook.react.viewmanagers; + +import android.view.View; + +public interface SimpleComponentManagerInterface { + // No props +} +", +} +`; + +exports[`GeneratePropsJavaInterface can generate fixture COMPONENT_WITH_INT_STATE 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/SimpleComponentManagerInterface.java" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GeneratePropsJavaInterface.js +*/ + +package com.facebook.react.viewmanagers; + +import android.view.View; + +public interface SimpleComponentManagerInterface { + // No props +} +", +} +`; + +exports[`GeneratePropsJavaInterface can generate fixture COMPONENT_WITH_OBJECT_STATE 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/SimpleComponentManagerInterface.java" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GeneratePropsJavaInterface.js +*/ + +package com.facebook.react.viewmanagers; + +import android.view.View; + +public interface SimpleComponentManagerInterface { + // No props +} +", +} +`; + +exports[`GeneratePropsJavaInterface can generate fixture COMPONENT_WITH_POINT_STATE 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/SimpleComponentManagerInterface.java" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GeneratePropsJavaInterface.js +*/ + +package com.facebook.react.viewmanagers; + +import android.view.View; + +public interface SimpleComponentManagerInterface { + // No props +} +", +} +`; + +exports[`GeneratePropsJavaInterface can generate fixture COMPONENT_WITH_STRING_ENUM_STATE_PROPS 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/SimpleComponentManagerInterface.java" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GeneratePropsJavaInterface.js +*/ + +package com.facebook.react.viewmanagers; + +import android.view.View; + +public interface SimpleComponentManagerInterface { + // No props +} +", +} +`; + +exports[`GeneratePropsJavaInterface can generate fixture COMPONENT_WITH_STRING_STATE 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/SimpleComponentManagerInterface.java" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GeneratePropsJavaInterface.js +*/ + +package com.facebook.react.viewmanagers; + +import android.view.View; + +public interface SimpleComponentManagerInterface { + // No props +} +", +} +`; + exports[`GeneratePropsJavaInterface can generate fixture DOUBLE_PROPS 1`] = ` Map { "java/com/facebook/react/viewmanagers/DoublePropNativeComponentManagerInterface.java" => "/** diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaPojo-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaPojo-test.js.snap index 9cb2b17fe2b..b8315f88c31 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaPojo-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaPojo-test.js.snap @@ -340,6 +340,342 @@ public class CommandNativeComponentProps { } `; +exports[`GeneratePropsJavaPojo can generate fixture COMPONENT_WITH_ARRAY_OF_OBJECTS_STATE 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/MyComponent/SimpleComponentProps.java" => "/** +* Copyright (c) Meta Platforms, Inc. and affiliates. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.MyComponent; + +import com.facebook.proguard.annotations.DoNotStrip; + +@DoNotStrip +public class SimpleComponentProps { + + +} +", +} +`; + +exports[`GeneratePropsJavaPojo can generate fixture COMPONENT_WITH_ARRAY_STATE 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/MyComponent/SimpleComponentProps.java" => "/** +* Copyright (c) Meta Platforms, Inc. and affiliates. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.MyComponent; + +import com.facebook.proguard.annotations.DoNotStrip; + +@DoNotStrip +public class SimpleComponentProps { + + +} +", +} +`; + +exports[`GeneratePropsJavaPojo can generate fixture COMPONENT_WITH_BOOL_STATE 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/MyComponent/SimpleComponentProps.java" => "/** +* Copyright (c) Meta Platforms, Inc. and affiliates. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.MyComponent; + +import com.facebook.proguard.annotations.DoNotStrip; + +@DoNotStrip +public class SimpleComponentProps { + + +} +", +} +`; + +exports[`GeneratePropsJavaPojo can generate fixture COMPONENT_WITH_COLOR_STATE 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/MyComponent/SimpleComponentProps.java" => "/** +* Copyright (c) Meta Platforms, Inc. and affiliates. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.MyComponent; + +import com.facebook.proguard.annotations.DoNotStrip; + +@DoNotStrip +public class SimpleComponentProps { + + +} +", +} +`; + +exports[`GeneratePropsJavaPojo can generate fixture COMPONENT_WITH_DOUBLE_STATE 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/MyComponent/SimpleComponentProps.java" => "/** +* Copyright (c) Meta Platforms, Inc. and affiliates. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.MyComponent; + +import com.facebook.proguard.annotations.DoNotStrip; + +@DoNotStrip +public class SimpleComponentProps { + + +} +", +} +`; + +exports[`GeneratePropsJavaPojo can generate fixture COMPONENT_WITH_EDGE_INSET_STATE_PROPS 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/MyComponent/SimpleComponentProps.java" => "/** +* Copyright (c) Meta Platforms, Inc. and affiliates. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.MyComponent; + +import com.facebook.proguard.annotations.DoNotStrip; + +@DoNotStrip +public class SimpleComponentProps { + + +} +", +} +`; + +exports[`GeneratePropsJavaPojo can generate fixture COMPONENT_WITH_FLOAT_STATE 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/MyComponent/SimpleComponentProps.java" => "/** +* Copyright (c) Meta Platforms, Inc. and affiliates. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.MyComponent; + +import com.facebook.proguard.annotations.DoNotStrip; + +@DoNotStrip +public class SimpleComponentProps { + + +} +", +} +`; + +exports[`GeneratePropsJavaPojo can generate fixture COMPONENT_WITH_IMAGE_STATE 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/MyComponent/SimpleComponentProps.java" => "/** +* Copyright (c) Meta Platforms, Inc. and affiliates. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.MyComponent; + +import com.facebook.proguard.annotations.DoNotStrip; + +@DoNotStrip +public class SimpleComponentProps { + + +} +", +} +`; + +exports[`GeneratePropsJavaPojo can generate fixture COMPONENT_WITH_INT_ENUM_STATE 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/MyComponent/SimpleComponentProps.java" => "/** +* Copyright (c) Meta Platforms, Inc. and affiliates. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.MyComponent; + +import com.facebook.proguard.annotations.DoNotStrip; + +@DoNotStrip +public class SimpleComponentProps { + + +} +", +} +`; + +exports[`GeneratePropsJavaPojo can generate fixture COMPONENT_WITH_INT_STATE 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/MyComponent/SimpleComponentProps.java" => "/** +* Copyright (c) Meta Platforms, Inc. and affiliates. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.MyComponent; + +import com.facebook.proguard.annotations.DoNotStrip; + +@DoNotStrip +public class SimpleComponentProps { + + +} +", +} +`; + +exports[`GeneratePropsJavaPojo can generate fixture COMPONENT_WITH_OBJECT_STATE 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/MyComponent/SimpleComponentProps.java" => "/** +* Copyright (c) Meta Platforms, Inc. and affiliates. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.MyComponent; + +import com.facebook.proguard.annotations.DoNotStrip; + +@DoNotStrip +public class SimpleComponentProps { + + +} +", +} +`; + +exports[`GeneratePropsJavaPojo can generate fixture COMPONENT_WITH_POINT_STATE 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/MyComponent/SimpleComponentProps.java" => "/** +* Copyright (c) Meta Platforms, Inc. and affiliates. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.MyComponent; + +import com.facebook.proguard.annotations.DoNotStrip; + +@DoNotStrip +public class SimpleComponentProps { + + +} +", +} +`; + +exports[`GeneratePropsJavaPojo can generate fixture COMPONENT_WITH_STRING_ENUM_STATE_PROPS 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/MyComponent/SimpleComponentProps.java" => "/** +* Copyright (c) Meta Platforms, Inc. and affiliates. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.MyComponent; + +import com.facebook.proguard.annotations.DoNotStrip; + +@DoNotStrip +public class SimpleComponentProps { + + +} +", +} +`; + +exports[`GeneratePropsJavaPojo can generate fixture COMPONENT_WITH_STRING_STATE 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/MyComponent/SimpleComponentProps.java" => "/** +* Copyright (c) Meta Platforms, Inc. and affiliates. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.MyComponent; + +import com.facebook.proguard.annotations.DoNotStrip; + +@DoNotStrip +public class SimpleComponentProps { + + +} +", +} +`; + exports[`GeneratePropsJavaPojo can generate fixture DOUBLE_PROPS 1`] = ` Map { "java/com/facebook/react/viewmanagers/Switch/DoublePropNativeComponentProps.java" => "/** diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeCpp-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeCpp-test.js.snap index b09ab9ea8be..25a9aa58bf5 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeCpp-test.js.snap @@ -150,6 +150,356 @@ extern const char CommandNativeComponentComponentName[] = \\"CommandNativeCompon } `; +exports[`GenerateShadowNodeCpp can generate fixture COMPONENT_WITH_ARRAY_OF_OBJECTS_STATE 1`] = ` +Map { + "ShadowNodes.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateShadowNodeCpp.js + */ + +#include + +namespace facebook { +namespace react { + +extern const char SimpleComponentComponentName[] = \\"SimpleComponent\\"; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateShadowNodeCpp can generate fixture COMPONENT_WITH_ARRAY_STATE 1`] = ` +Map { + "ShadowNodes.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateShadowNodeCpp.js + */ + +#include + +namespace facebook { +namespace react { + +extern const char SimpleComponentComponentName[] = \\"SimpleComponent\\"; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateShadowNodeCpp can generate fixture COMPONENT_WITH_BOOL_STATE 1`] = ` +Map { + "ShadowNodes.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateShadowNodeCpp.js + */ + +#include + +namespace facebook { +namespace react { + +extern const char SimpleComponentComponentName[] = \\"SimpleComponent\\"; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateShadowNodeCpp can generate fixture COMPONENT_WITH_COLOR_STATE 1`] = ` +Map { + "ShadowNodes.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateShadowNodeCpp.js + */ + +#include + +namespace facebook { +namespace react { + +extern const char SimpleComponentComponentName[] = \\"SimpleComponent\\"; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateShadowNodeCpp can generate fixture COMPONENT_WITH_DOUBLE_STATE 1`] = ` +Map { + "ShadowNodes.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateShadowNodeCpp.js + */ + +#include + +namespace facebook { +namespace react { + +extern const char SimpleComponentComponentName[] = \\"SimpleComponent\\"; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateShadowNodeCpp can generate fixture COMPONENT_WITH_EDGE_INSET_STATE_PROPS 1`] = ` +Map { + "ShadowNodes.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateShadowNodeCpp.js + */ + +#include + +namespace facebook { +namespace react { + +extern const char SimpleComponentComponentName[] = \\"SimpleComponent\\"; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateShadowNodeCpp can generate fixture COMPONENT_WITH_FLOAT_STATE 1`] = ` +Map { + "ShadowNodes.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateShadowNodeCpp.js + */ + +#include + +namespace facebook { +namespace react { + +extern const char SimpleComponentComponentName[] = \\"SimpleComponent\\"; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateShadowNodeCpp can generate fixture COMPONENT_WITH_IMAGE_STATE 1`] = ` +Map { + "ShadowNodes.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateShadowNodeCpp.js + */ + +#include + +namespace facebook { +namespace react { + +extern const char SimpleComponentComponentName[] = \\"SimpleComponent\\"; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateShadowNodeCpp can generate fixture COMPONENT_WITH_INT_ENUM_STATE 1`] = ` +Map { + "ShadowNodes.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateShadowNodeCpp.js + */ + +#include + +namespace facebook { +namespace react { + +extern const char SimpleComponentComponentName[] = \\"SimpleComponent\\"; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateShadowNodeCpp can generate fixture COMPONENT_WITH_INT_STATE 1`] = ` +Map { + "ShadowNodes.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateShadowNodeCpp.js + */ + +#include + +namespace facebook { +namespace react { + +extern const char SimpleComponentComponentName[] = \\"SimpleComponent\\"; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateShadowNodeCpp can generate fixture COMPONENT_WITH_OBJECT_STATE 1`] = ` +Map { + "ShadowNodes.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateShadowNodeCpp.js + */ + +#include + +namespace facebook { +namespace react { + +extern const char SimpleComponentComponentName[] = \\"SimpleComponent\\"; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateShadowNodeCpp can generate fixture COMPONENT_WITH_POINT_STATE 1`] = ` +Map { + "ShadowNodes.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateShadowNodeCpp.js + */ + +#include + +namespace facebook { +namespace react { + +extern const char SimpleComponentComponentName[] = \\"SimpleComponent\\"; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateShadowNodeCpp can generate fixture COMPONENT_WITH_STRING_ENUM_STATE_PROPS 1`] = ` +Map { + "ShadowNodes.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateShadowNodeCpp.js + */ + +#include + +namespace facebook { +namespace react { + +extern const char SimpleComponentComponentName[] = \\"SimpleComponent\\"; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateShadowNodeCpp can generate fixture COMPONENT_WITH_STRING_STATE 1`] = ` +Map { + "ShadowNodes.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateShadowNodeCpp.js + */ + +#include + +namespace facebook { +namespace react { + +extern const char SimpleComponentComponentName[] = \\"SimpleComponent\\"; + +} // namespace react +} // namespace facebook +", +} +`; + exports[`GenerateShadowNodeCpp can generate fixture DOUBLE_PROPS 1`] = ` Map { "ShadowNodes.cpp" => " diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeH-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeH-test.js.snap index 86226abbbd7..ae384f30fee 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeH-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeH-test.js.snap @@ -240,6 +240,566 @@ using CommandNativeComponentShadowNode = ConcreteViewShadowNode< } `; +exports[`GenerateShadowNodeH can generate fixture COMPONENT_WITH_ARRAY_OF_OBJECTS_STATE 1`] = ` +Map { + "ShadowNodes.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateShadowNodeH.js + */ + +#pragma once + +#include +#include +#include +#include +#include + +namespace facebook { +namespace react { + +JSI_EXPORT extern const char SimpleComponentComponentName[]; + +/* + * \`ShadowNode\` for component. + */ +using SimpleComponentShadowNode = ConcreteViewShadowNode< + SimpleComponentComponentName, + SimpleComponentProps, + SimpleComponentEventEmitter, + SimpleComponentState>; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateShadowNodeH can generate fixture COMPONENT_WITH_ARRAY_STATE 1`] = ` +Map { + "ShadowNodes.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateShadowNodeH.js + */ + +#pragma once + +#include +#include +#include +#include +#include + +namespace facebook { +namespace react { + +JSI_EXPORT extern const char SimpleComponentComponentName[]; + +/* + * \`ShadowNode\` for component. + */ +using SimpleComponentShadowNode = ConcreteViewShadowNode< + SimpleComponentComponentName, + SimpleComponentProps, + SimpleComponentEventEmitter, + SimpleComponentState>; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateShadowNodeH can generate fixture COMPONENT_WITH_BOOL_STATE 1`] = ` +Map { + "ShadowNodes.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateShadowNodeH.js + */ + +#pragma once + +#include +#include +#include +#include +#include + +namespace facebook { +namespace react { + +JSI_EXPORT extern const char SimpleComponentComponentName[]; + +/* + * \`ShadowNode\` for component. + */ +using SimpleComponentShadowNode = ConcreteViewShadowNode< + SimpleComponentComponentName, + SimpleComponentProps, + SimpleComponentEventEmitter, + SimpleComponentState>; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateShadowNodeH can generate fixture COMPONENT_WITH_COLOR_STATE 1`] = ` +Map { + "ShadowNodes.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateShadowNodeH.js + */ + +#pragma once + +#include +#include +#include +#include +#include + +namespace facebook { +namespace react { + +JSI_EXPORT extern const char SimpleComponentComponentName[]; + +/* + * \`ShadowNode\` for component. + */ +using SimpleComponentShadowNode = ConcreteViewShadowNode< + SimpleComponentComponentName, + SimpleComponentProps, + SimpleComponentEventEmitter, + SimpleComponentState>; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateShadowNodeH can generate fixture COMPONENT_WITH_DOUBLE_STATE 1`] = ` +Map { + "ShadowNodes.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateShadowNodeH.js + */ + +#pragma once + +#include +#include +#include +#include +#include + +namespace facebook { +namespace react { + +JSI_EXPORT extern const char SimpleComponentComponentName[]; + +/* + * \`ShadowNode\` for component. + */ +using SimpleComponentShadowNode = ConcreteViewShadowNode< + SimpleComponentComponentName, + SimpleComponentProps, + SimpleComponentEventEmitter, + SimpleComponentState>; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateShadowNodeH can generate fixture COMPONENT_WITH_EDGE_INSET_STATE_PROPS 1`] = ` +Map { + "ShadowNodes.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateShadowNodeH.js + */ + +#pragma once + +#include +#include +#include +#include +#include + +namespace facebook { +namespace react { + +JSI_EXPORT extern const char SimpleComponentComponentName[]; + +/* + * \`ShadowNode\` for component. + */ +using SimpleComponentShadowNode = ConcreteViewShadowNode< + SimpleComponentComponentName, + SimpleComponentProps, + SimpleComponentEventEmitter, + SimpleComponentState>; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateShadowNodeH can generate fixture COMPONENT_WITH_FLOAT_STATE 1`] = ` +Map { + "ShadowNodes.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateShadowNodeH.js + */ + +#pragma once + +#include +#include +#include +#include +#include + +namespace facebook { +namespace react { + +JSI_EXPORT extern const char SimpleComponentComponentName[]; + +/* + * \`ShadowNode\` for component. + */ +using SimpleComponentShadowNode = ConcreteViewShadowNode< + SimpleComponentComponentName, + SimpleComponentProps, + SimpleComponentEventEmitter, + SimpleComponentState>; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateShadowNodeH can generate fixture COMPONENT_WITH_IMAGE_STATE 1`] = ` +Map { + "ShadowNodes.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateShadowNodeH.js + */ + +#pragma once + +#include +#include +#include +#include +#include + +namespace facebook { +namespace react { + +JSI_EXPORT extern const char SimpleComponentComponentName[]; + +/* + * \`ShadowNode\` for component. + */ +using SimpleComponentShadowNode = ConcreteViewShadowNode< + SimpleComponentComponentName, + SimpleComponentProps, + SimpleComponentEventEmitter, + SimpleComponentState>; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateShadowNodeH can generate fixture COMPONENT_WITH_INT_ENUM_STATE 1`] = ` +Map { + "ShadowNodes.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateShadowNodeH.js + */ + +#pragma once + +#include +#include +#include +#include +#include + +namespace facebook { +namespace react { + +JSI_EXPORT extern const char SimpleComponentComponentName[]; + +/* + * \`ShadowNode\` for component. + */ +using SimpleComponentShadowNode = ConcreteViewShadowNode< + SimpleComponentComponentName, + SimpleComponentProps, + SimpleComponentEventEmitter, + SimpleComponentState>; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateShadowNodeH can generate fixture COMPONENT_WITH_INT_STATE 1`] = ` +Map { + "ShadowNodes.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateShadowNodeH.js + */ + +#pragma once + +#include +#include +#include +#include +#include + +namespace facebook { +namespace react { + +JSI_EXPORT extern const char SimpleComponentComponentName[]; + +/* + * \`ShadowNode\` for component. + */ +using SimpleComponentShadowNode = ConcreteViewShadowNode< + SimpleComponentComponentName, + SimpleComponentProps, + SimpleComponentEventEmitter, + SimpleComponentState>; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateShadowNodeH can generate fixture COMPONENT_WITH_OBJECT_STATE 1`] = ` +Map { + "ShadowNodes.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateShadowNodeH.js + */ + +#pragma once + +#include +#include +#include +#include +#include + +namespace facebook { +namespace react { + +JSI_EXPORT extern const char SimpleComponentComponentName[]; + +/* + * \`ShadowNode\` for component. + */ +using SimpleComponentShadowNode = ConcreteViewShadowNode< + SimpleComponentComponentName, + SimpleComponentProps, + SimpleComponentEventEmitter, + SimpleComponentState>; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateShadowNodeH can generate fixture COMPONENT_WITH_POINT_STATE 1`] = ` +Map { + "ShadowNodes.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateShadowNodeH.js + */ + +#pragma once + +#include +#include +#include +#include +#include + +namespace facebook { +namespace react { + +JSI_EXPORT extern const char SimpleComponentComponentName[]; + +/* + * \`ShadowNode\` for component. + */ +using SimpleComponentShadowNode = ConcreteViewShadowNode< + SimpleComponentComponentName, + SimpleComponentProps, + SimpleComponentEventEmitter, + SimpleComponentState>; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateShadowNodeH can generate fixture COMPONENT_WITH_STRING_ENUM_STATE_PROPS 1`] = ` +Map { + "ShadowNodes.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateShadowNodeH.js + */ + +#pragma once + +#include +#include +#include +#include +#include + +namespace facebook { +namespace react { + +JSI_EXPORT extern const char SimpleComponentComponentName[]; + +/* + * \`ShadowNode\` for component. + */ +using SimpleComponentShadowNode = ConcreteViewShadowNode< + SimpleComponentComponentName, + SimpleComponentProps, + SimpleComponentEventEmitter, + SimpleComponentState>; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateShadowNodeH can generate fixture COMPONENT_WITH_STRING_STATE 1`] = ` +Map { + "ShadowNodes.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateShadowNodeH.js + */ + +#pragma once + +#include +#include +#include +#include +#include + +namespace facebook { +namespace react { + +JSI_EXPORT extern const char SimpleComponentComponentName[]; + +/* + * \`ShadowNode\` for component. + */ +using SimpleComponentShadowNode = ConcreteViewShadowNode< + SimpleComponentComponentName, + SimpleComponentProps, + SimpleComponentEventEmitter, + SimpleComponentState>; + +} // namespace react +} // namespace facebook +", +} +`; + exports[`GenerateShadowNodeH can generate fixture DOUBLE_PROPS 1`] = ` Map { "ShadowNodes.h" => " diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateStateCpp-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateStateCpp-test.js.snap index 04084fb1b5a..85fac1d0d71 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateStateCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateStateCpp-test.js.snap @@ -138,6 +138,438 @@ namespace react { +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateStateCpp can generate fixture COMPONENT_WITH_ARRAY_OF_OBJECTS_STATE 1`] = ` +Map { + "States.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateStateCpp.js + */ +#include + +namespace facebook { +namespace react { + +std::vector SimpleComponent::getArrayState() const { + return arrayState_; +} + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateStateCpp can generate fixture COMPONENT_WITH_ARRAY_STATE 1`] = ` +Map { + "States.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateStateCpp.js + */ +#include + +namespace facebook { +namespace react { + +std::vector SimpleComponent::getNames() const { + return names_; +} + +std::vector SimpleComponent::getDisableds() const { + return disableds_; +} + +std::vector SimpleComponent::getProgress() const { + return progress_; +} + +std::vector SimpleComponent::getRadii() const { + return radii_; +} + +std::vector SimpleComponent::getColors() const { + return colors_; +} + +std::vector SimpleComponent::getSrcs() const { + return srcs_; +} + +std::vector SimpleComponent::getPoints() const { + return points_; +} + +SimpleComponentSizesMask SimpleComponent::getSizes() const { + return sizes_; +} + +std::vector SimpleComponent::getObject() const { + return object_; +} + +std::vector SimpleComponent::getArray() const { + return array_; +} + +std::vector> SimpleComponent::getArrayOfArrayOfObject() const { + return arrayOfArrayOfObject_; +} + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateStateCpp can generate fixture COMPONENT_WITH_BOOL_STATE 1`] = ` +Map { + "States.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateStateCpp.js + */ +#include + +namespace facebook { +namespace react { + +bool SimpleComponent::getDisabled() const { + return disabled_; +} + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateStateCpp can generate fixture COMPONENT_WITH_COLOR_STATE 1`] = ` +Map { + "States.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateStateCpp.js + */ +#include + +namespace facebook { +namespace react { + +SharedColor SimpleComponent::getTintColor() const { + return tintColor_; +} + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateStateCpp can generate fixture COMPONENT_WITH_DOUBLE_STATE 1`] = ` +Map { + "States.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateStateCpp.js + */ +#include + +namespace facebook { +namespace react { + +double SimpleComponent::getD_blurRadius() const { + return d_blurRadius_; +} + +double SimpleComponent::getD_blurRadius2() const { + return d_blurRadius2_; +} + +double SimpleComponent::getD_blurRadius3() const { + return d_blurRadius3_; +} + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateStateCpp can generate fixture COMPONENT_WITH_EDGE_INSET_STATE_PROPS 1`] = ` +Map { + "States.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateStateCpp.js + */ +#include + +namespace facebook { +namespace react { + +EdgeInsets SimpleComponent::getContentInset() const { + return contentInset_; +} + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateStateCpp can generate fixture COMPONENT_WITH_FLOAT_STATE 1`] = ` +Map { + "States.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateStateCpp.js + */ +#include + +namespace facebook { +namespace react { + +Float SimpleComponent::getBlurRadius() const { + return blurRadius_; +} + +Float SimpleComponent::getBlurRadius2() const { + return blurRadius2_; +} + +Float SimpleComponent::getBlurRadius3() const { + return blurRadius3_; +} + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateStateCpp can generate fixture COMPONENT_WITH_IMAGE_STATE 1`] = ` +Map { + "States.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateStateCpp.js + */ +#include + +namespace facebook { +namespace react { + +ImageSource SimpleComponent::getThumbImage() const { + return thumbImage_; +} + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateStateCpp can generate fixture COMPONENT_WITH_INT_ENUM_STATE 1`] = ` +Map { + "States.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateStateCpp.js + */ +#include + +namespace facebook { +namespace react { + +SimpleComponentMaxInterval SimpleComponent::getMaxInterval() const { + return maxInterval_; +} + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateStateCpp can generate fixture COMPONENT_WITH_INT_STATE 1`] = ` +Map { + "States.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateStateCpp.js + */ +#include + +namespace facebook { +namespace react { + +int SimpleComponent::getProgress1() const { + return progress1_; +} + +int SimpleComponent::getProgress2() const { + return progress2_; +} + +int SimpleComponent::getProgress3() const { + return progress3_; +} + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateStateCpp can generate fixture COMPONENT_WITH_OBJECT_STATE 1`] = ` +Map { + "States.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateStateCpp.js + */ +#include + +namespace facebook { +namespace react { + +SimpleComponentObjectPropStruct SimpleComponent::getObjectProp() const { + return objectProp_; +} + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateStateCpp can generate fixture COMPONENT_WITH_POINT_STATE 1`] = ` +Map { + "States.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateStateCpp.js + */ +#include + +namespace facebook { +namespace react { + +Point SimpleComponent::getStartPoint() const { + return startPoint_; +} + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateStateCpp can generate fixture COMPONENT_WITH_STRING_ENUM_STATE_PROPS 1`] = ` +Map { + "States.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateStateCpp.js + */ +#include + +namespace facebook { +namespace react { + +SimpleComponentAlignment SimpleComponent::getAlignment() const { + return alignment_; +} + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateStateCpp can generate fixture COMPONENT_WITH_STRING_STATE 1`] = ` +Map { + "States.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateStateCpp.js + */ +#include + +namespace facebook { +namespace react { + +std::string SimpleComponent::getAccessibilityHint() const { + return accessibilityHint_; +} + +std::string SimpleComponent::getAccessibilityRole() const { + return accessibilityRole_; +} + } // namespace react } // namespace facebook ", diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateStateH-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateStateH-test.js.snap index d450b769097..e4737f93112 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateStateH-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateStateH-test.js.snap @@ -2,8 +2,7 @@ exports[`GenerateStateH can generate fixture ARRAY_PROPS 1`] = ` Map { - "States.h" => " -/** + "States.h" => "/** * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * * Do not edit this file as changes may cause incorrect behavior and will be lost @@ -13,6 +12,8 @@ Map { */ #pragma once +#include + #ifdef ANDROID #include #include @@ -22,11 +23,13 @@ Map { namespace facebook { namespace react { - class ArrayPropsNativeComponentState { public: + ArrayPropsNativeComponentState() = default; + + #ifdef ANDROID ArrayPropsNativeComponentState(ArrayPropsNativeComponentState const &previousState, folly::dynamic data){}; folly::dynamic getDynamic() const { @@ -36,19 +39,19 @@ class ArrayPropsNativeComponentState { return MapBufferBuilder::EMPTY(); }; #endif + + private: + }; - } // namespace react -} // namespace facebook -", +} // namespace facebook", } `; exports[`GenerateStateH can generate fixture ARRAY_PROPS_WITH_NESTED_OBJECT 1`] = ` Map { - "States.h" => " -/** + "States.h" => "/** * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * * Do not edit this file as changes may cause incorrect behavior and will be lost @@ -58,6 +61,8 @@ Map { */ #pragma once +#include + #ifdef ANDROID #include #include @@ -67,11 +72,13 @@ Map { namespace facebook { namespace react { - class ArrayPropsNativeComponentState { public: + ArrayPropsNativeComponentState() = default; + + #ifdef ANDROID ArrayPropsNativeComponentState(ArrayPropsNativeComponentState const &previousState, folly::dynamic data){}; folly::dynamic getDynamic() const { @@ -81,19 +88,19 @@ class ArrayPropsNativeComponentState { return MapBufferBuilder::EMPTY(); }; #endif + + private: + }; - } // namespace react -} // namespace facebook -", +} // namespace facebook", } `; exports[`GenerateStateH can generate fixture BOOLEAN_PROP 1`] = ` Map { - "States.h" => " -/** + "States.h" => "/** * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * * Do not edit this file as changes may cause incorrect behavior and will be lost @@ -103,6 +110,8 @@ Map { */ #pragma once +#include + #ifdef ANDROID #include #include @@ -112,11 +121,13 @@ Map { namespace facebook { namespace react { - class BooleanPropNativeComponentState { public: + BooleanPropNativeComponentState() = default; + + #ifdef ANDROID BooleanPropNativeComponentState(BooleanPropNativeComponentState const &previousState, folly::dynamic data){}; folly::dynamic getDynamic() const { @@ -126,19 +137,19 @@ class BooleanPropNativeComponentState { return MapBufferBuilder::EMPTY(); }; #endif + + private: + }; - } // namespace react -} // namespace facebook -", +} // namespace facebook", } `; exports[`GenerateStateH can generate fixture COLOR_PROP 1`] = ` Map { - "States.h" => " -/** + "States.h" => "/** * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * * Do not edit this file as changes may cause incorrect behavior and will be lost @@ -148,6 +159,8 @@ Map { */ #pragma once +#include + #ifdef ANDROID #include #include @@ -157,11 +170,13 @@ Map { namespace facebook { namespace react { - class ColorPropNativeComponentState { public: + ColorPropNativeComponentState() = default; + + #ifdef ANDROID ColorPropNativeComponentState(ColorPropNativeComponentState const &previousState, folly::dynamic data){}; folly::dynamic getDynamic() const { @@ -171,19 +186,19 @@ class ColorPropNativeComponentState { return MapBufferBuilder::EMPTY(); }; #endif + + private: + }; - } // namespace react -} // namespace facebook -", +} // namespace facebook", } `; exports[`GenerateStateH can generate fixture COMMANDS 1`] = ` Map { - "States.h" => " -/** + "States.h" => "/** * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * * Do not edit this file as changes may cause incorrect behavior and will be lost @@ -193,6 +208,8 @@ Map { */ #pragma once +#include + #ifdef ANDROID #include #include @@ -202,11 +219,13 @@ Map { namespace facebook { namespace react { - class CommandNativeComponentState { public: + CommandNativeComponentState() = default; + + #ifdef ANDROID CommandNativeComponentState(CommandNativeComponentState const &previousState, folly::dynamic data){}; folly::dynamic getDynamic() const { @@ -216,19 +235,19 @@ class CommandNativeComponentState { return MapBufferBuilder::EMPTY(); }; #endif + + private: + }; - } // namespace react -} // namespace facebook -", +} // namespace facebook", } `; exports[`GenerateStateH can generate fixture COMMANDS_AND_PROPS 1`] = ` Map { - "States.h" => " -/** + "States.h" => "/** * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * * Do not edit this file as changes may cause incorrect behavior and will be lost @@ -238,6 +257,8 @@ Map { */ #pragma once +#include + #ifdef ANDROID #include #include @@ -247,11 +268,13 @@ Map { namespace facebook { namespace react { - class CommandNativeComponentState { public: + CommandNativeComponentState() = default; + + #ifdef ANDROID CommandNativeComponentState(CommandNativeComponentState const &previousState, folly::dynamic data){}; folly::dynamic getDynamic() const { @@ -261,19 +284,19 @@ class CommandNativeComponentState { return MapBufferBuilder::EMPTY(); }; #endif + + private: + }; - } // namespace react -} // namespace facebook -", +} // namespace facebook", } `; -exports[`GenerateStateH can generate fixture DOUBLE_PROPS 1`] = ` +exports[`GenerateStateH can generate fixture COMPONENT_WITH_ARRAY_OF_OBJECTS_STATE 1`] = ` Map { - "States.h" => " -/** + "States.h" => "/** * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * * Do not edit this file as changes may cause incorrect behavior and will be lost @@ -283,6 +306,8 @@ Map { */ #pragma once +#include + #ifdef ANDROID #include #include @@ -292,11 +317,865 @@ Map { namespace facebook { namespace react { +class SimpleComponentState { + public: + + SimpleComponentState( + std::vector arrayState + ) + : arrayState_(arrayState){}; + + SimpleComponentState() = default; + + std::vector getArrayState() const; + + +#ifdef ANDROID + SimpleComponentState(SimpleComponentState const &previousState, folly::dynamic data){}; + folly::dynamic getDynamic() const { + return {}; + }; + MapBuffer getMapBuffer() const { + return MapBufferBuilder::EMPTY(); + }; +#endif + + private: + std::vector arrayState_; + +}; + +} // namespace react +} // namespace facebook", +} +`; + +exports[`GenerateStateH can generate fixture COMPONENT_WITH_ARRAY_STATE 1`] = ` +Map { + "States.h" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateStateH.js + */ +#pragma once + +#include + +#ifdef ANDROID +#include +#include +#include +#endif + +namespace facebook { +namespace react { + +class SimpleComponentState { + public: + + SimpleComponentState( + std::vector names, + std::vector disableds, + std::vector progress, + std::vector radii, + std::vector colors, + std::vector srcs, + std::vector points, + SimpleComponentSizesMask sizes, + std::vector object, + std::vector array, + std::vector> arrayOfArrayOfObject + ) + : names_(names), + disableds_(disableds), + progress_(progress), + radii_(radii), + colors_(colors), + srcs_(srcs), + points_(points), + sizes_(sizes), + object_(object), + array_(array), + arrayOfArrayOfObject_(arrayOfArrayOfObject){}; + + SimpleComponentState() = default; + + std::vector getNames() const; + std::vector getDisableds() const; + std::vector getProgress() const; + std::vector getRadii() const; + std::vector getColors() const; + std::vector getSrcs() const; + std::vector getPoints() const; + SimpleComponentSizesMask getSizes() const; + std::vector getObject() const; + std::vector getArray() const; + std::vector> getArrayOfArrayOfObject() const; + + +#ifdef ANDROID + SimpleComponentState(SimpleComponentState const &previousState, folly::dynamic data){}; + folly::dynamic getDynamic() const { + return {}; + }; + MapBuffer getMapBuffer() const { + return MapBufferBuilder::EMPTY(); + }; +#endif + + private: + std::vector names_; + std::vector disableds_; + std::vector progress_; + std::vector radii_; + std::vector colors_; + std::vector srcs_; + std::vector points_; + SimpleComponentSizesMask sizes_{static_cast(SimpleComponentSizes::Small)}; + std::vector object_; + std::vector array_; + std::vector> arrayOfArrayOfObject_; + +}; + +} // namespace react +} // namespace facebook", +} +`; + +exports[`GenerateStateH can generate fixture COMPONENT_WITH_BOOL_STATE 1`] = ` +Map { + "States.h" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateStateH.js + */ +#pragma once + +#include + +#ifdef ANDROID +#include +#include +#include +#endif + +namespace facebook { +namespace react { + +class SimpleComponentState { + public: + + SimpleComponentState( + bool disabled + ) + : disabled_(disabled){}; + + SimpleComponentState() = default; + + bool getDisabled() const; + + +#ifdef ANDROID + SimpleComponentState(SimpleComponentState const &previousState, folly::dynamic data){}; + folly::dynamic getDynamic() const { + return {}; + }; + MapBuffer getMapBuffer() const { + return MapBufferBuilder::EMPTY(); + }; +#endif + + private: + bool disabled_{false}; + +}; + +} // namespace react +} // namespace facebook", +} +`; + +exports[`GenerateStateH can generate fixture COMPONENT_WITH_COLOR_STATE 1`] = ` +Map { + "States.h" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateStateH.js + */ +#pragma once + +#include + +#ifdef ANDROID +#include +#include +#include +#endif + +namespace facebook { +namespace react { + +class SimpleComponentState { + public: + + SimpleComponentState( + SharedColor tintColor + ) + : tintColor_(tintColor){}; + + SimpleComponentState() = default; + + SharedColor getTintColor() const; + + +#ifdef ANDROID + SimpleComponentState(SimpleComponentState const &previousState, folly::dynamic data){}; + folly::dynamic getDynamic() const { + return {}; + }; + MapBuffer getMapBuffer() const { + return MapBufferBuilder::EMPTY(); + }; +#endif + + private: + SharedColor tintColor_; + +}; + +} // namespace react +} // namespace facebook", +} +`; + +exports[`GenerateStateH can generate fixture COMPONENT_WITH_DOUBLE_STATE 1`] = ` +Map { + "States.h" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateStateH.js + */ +#pragma once + +#include + +#ifdef ANDROID +#include +#include +#include +#endif + +namespace facebook { +namespace react { + +class SimpleComponentState { + public: + + SimpleComponentState( + double d_blurRadius, + double d_blurRadius2, + double d_blurRadius3 + ) + : d_blurRadius_(d_blurRadius), + d_blurRadius2_(d_blurRadius2), + d_blurRadius3_(d_blurRadius3){}; + + SimpleComponentState() = default; + + double getD_blurRadius() const; + double getD_blurRadius2() const; + double getD_blurRadius3() const; + + +#ifdef ANDROID + SimpleComponentState(SimpleComponentState const &previousState, folly::dynamic data){}; + folly::dynamic getDynamic() const { + return {}; + }; + MapBuffer getMapBuffer() const { + return MapBufferBuilder::EMPTY(); + }; +#endif + + private: + double d_blurRadius_{0.0}; + double d_blurRadius2_{8.9}; + double d_blurRadius3_{-0.5}; + +}; + +} // namespace react +} // namespace facebook", +} +`; + +exports[`GenerateStateH can generate fixture COMPONENT_WITH_EDGE_INSET_STATE_PROPS 1`] = ` +Map { + "States.h" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateStateH.js + */ +#pragma once + +#include + +#ifdef ANDROID +#include +#include +#include +#endif + +namespace facebook { +namespace react { + +class SimpleComponentState { + public: + + SimpleComponentState( + EdgeInsets contentInset + ) + : contentInset_(contentInset){}; + + SimpleComponentState() = default; + + EdgeInsets getContentInset() const; + + +#ifdef ANDROID + SimpleComponentState(SimpleComponentState const &previousState, folly::dynamic data){}; + folly::dynamic getDynamic() const { + return {}; + }; + MapBuffer getMapBuffer() const { + return MapBufferBuilder::EMPTY(); + }; +#endif + + private: + EdgeInsets contentInset_; + +}; + +} // namespace react +} // namespace facebook", +} +`; + +exports[`GenerateStateH can generate fixture COMPONENT_WITH_FLOAT_STATE 1`] = ` +Map { + "States.h" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateStateH.js + */ +#pragma once + +#include + +#ifdef ANDROID +#include +#include +#include +#endif + +namespace facebook { +namespace react { + +class SimpleComponentState { + public: + + SimpleComponentState( + Float blurRadius, + Float blurRadius2, + Float blurRadius3 + ) + : blurRadius_(blurRadius), + blurRadius2_(blurRadius2), + blurRadius3_(blurRadius3){}; + + SimpleComponentState() = default; + + Float getBlurRadius() const; + Float getBlurRadius2() const; + Float getBlurRadius3() const; + + +#ifdef ANDROID + SimpleComponentState(SimpleComponentState const &previousState, folly::dynamic data){}; + folly::dynamic getDynamic() const { + return {}; + }; + MapBuffer getMapBuffer() const { + return MapBufferBuilder::EMPTY(); + }; +#endif + + private: + Float blurRadius_{0.0}; + Float blurRadius2_{7.5}; + Float blurRadius3_{-2.1}; + +}; + +} // namespace react +} // namespace facebook", +} +`; + +exports[`GenerateStateH can generate fixture COMPONENT_WITH_IMAGE_STATE 1`] = ` +Map { + "States.h" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateStateH.js + */ +#pragma once + +#include + +#ifdef ANDROID +#include +#include +#include +#endif + +namespace facebook { +namespace react { + +class SimpleComponentState { + public: + + SimpleComponentState( + ImageSource thumbImage + ) + : thumbImage_(thumbImage){}; + + SimpleComponentState() = default; + + ImageSource getThumbImage() const; + + +#ifdef ANDROID + SimpleComponentState(SimpleComponentState const &previousState, folly::dynamic data){}; + folly::dynamic getDynamic() const { + return {}; + }; + MapBuffer getMapBuffer() const { + return MapBufferBuilder::EMPTY(); + }; +#endif + + private: + ImageSource thumbImage_; + +}; + +} // namespace react +} // namespace facebook", +} +`; + +exports[`GenerateStateH can generate fixture COMPONENT_WITH_INT_ENUM_STATE 1`] = ` +Map { + "States.h" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateStateH.js + */ +#pragma once + +#include + +#ifdef ANDROID +#include +#include +#include +#endif + +namespace facebook { +namespace react { + +class SimpleComponentState { + public: + + SimpleComponentState( + SimpleComponentMaxInterval maxInterval + ) + : maxInterval_(maxInterval){}; + + SimpleComponentState() = default; + + SimpleComponentMaxInterval getMaxInterval() const; + + +#ifdef ANDROID + SimpleComponentState(SimpleComponentState const &previousState, folly::dynamic data){}; + folly::dynamic getDynamic() const { + return {}; + }; + MapBuffer getMapBuffer() const { + return MapBufferBuilder::EMPTY(); + }; +#endif + + private: + SimpleComponentMaxInterval maxInterval_{SimpleComponentMaxInterval::MaxInterval0}; + +}; + +} // namespace react +} // namespace facebook", +} +`; + +exports[`GenerateStateH can generate fixture COMPONENT_WITH_INT_STATE 1`] = ` +Map { + "States.h" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateStateH.js + */ +#pragma once + +#include + +#ifdef ANDROID +#include +#include +#include +#endif + +namespace facebook { +namespace react { + +class SimpleComponentState { + public: + + SimpleComponentState( + int progress1, + int progress2, + int progress3 + ) + : progress1_(progress1), + progress2_(progress2), + progress3_(progress3){}; + + SimpleComponentState() = default; + + int getProgress1() const; + int getProgress2() const; + int getProgress3() const; + + +#ifdef ANDROID + SimpleComponentState(SimpleComponentState const &previousState, folly::dynamic data){}; + folly::dynamic getDynamic() const { + return {}; + }; + MapBuffer getMapBuffer() const { + return MapBufferBuilder::EMPTY(); + }; +#endif + + private: + int progress1_{0}; + int progress2_{-1}; + int progress3_{10}; + +}; + +} // namespace react +} // namespace facebook", +} +`; + +exports[`GenerateStateH can generate fixture COMPONENT_WITH_OBJECT_STATE 1`] = ` +Map { + "States.h" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateStateH.js + */ +#pragma once + +#include + +#ifdef ANDROID +#include +#include +#include +#endif + +namespace facebook { +namespace react { + +class SimpleComponentState { + public: + + SimpleComponentState( + SimpleComponentObjectPropStruct objectProp + ) + : objectProp_(objectProp){}; + + SimpleComponentState() = default; + + SimpleComponentObjectPropStruct getObjectProp() const; + + +#ifdef ANDROID + SimpleComponentState(SimpleComponentState const &previousState, folly::dynamic data){}; + folly::dynamic getDynamic() const { + return {}; + }; + MapBuffer getMapBuffer() const { + return MapBufferBuilder::EMPTY(); + }; +#endif + + private: + SimpleComponentObjectPropStruct objectProp_; + +}; + +} // namespace react +} // namespace facebook", +} +`; + +exports[`GenerateStateH can generate fixture COMPONENT_WITH_POINT_STATE 1`] = ` +Map { + "States.h" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateStateH.js + */ +#pragma once + +#include + +#ifdef ANDROID +#include +#include +#include +#endif + +namespace facebook { +namespace react { + +class SimpleComponentState { + public: + + SimpleComponentState( + Point startPoint + ) + : startPoint_(startPoint){}; + + SimpleComponentState() = default; + + Point getStartPoint() const; + + +#ifdef ANDROID + SimpleComponentState(SimpleComponentState const &previousState, folly::dynamic data){}; + folly::dynamic getDynamic() const { + return {}; + }; + MapBuffer getMapBuffer() const { + return MapBufferBuilder::EMPTY(); + }; +#endif + + private: + Point startPoint_; + +}; + +} // namespace react +} // namespace facebook", +} +`; + +exports[`GenerateStateH can generate fixture COMPONENT_WITH_STRING_ENUM_STATE_PROPS 1`] = ` +Map { + "States.h" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateStateH.js + */ +#pragma once + +#include + +#ifdef ANDROID +#include +#include +#include +#endif + +namespace facebook { +namespace react { + +class SimpleComponentState { + public: + + SimpleComponentState( + SimpleComponentAlignment alignment + ) + : alignment_(alignment){}; + + SimpleComponentState() = default; + + SimpleComponentAlignment getAlignment() const; + + +#ifdef ANDROID + SimpleComponentState(SimpleComponentState const &previousState, folly::dynamic data){}; + folly::dynamic getDynamic() const { + return {}; + }; + MapBuffer getMapBuffer() const { + return MapBufferBuilder::EMPTY(); + }; +#endif + + private: + SimpleComponentAlignment alignment_{SimpleComponentAlignment::Center}; + +}; + +} // namespace react +} // namespace facebook", +} +`; + +exports[`GenerateStateH can generate fixture COMPONENT_WITH_STRING_STATE 1`] = ` +Map { + "States.h" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateStateH.js + */ +#pragma once + +#include + +#ifdef ANDROID +#include +#include +#include +#endif + +namespace facebook { +namespace react { + +class SimpleComponentState { + public: + + SimpleComponentState( + std::string accessibilityHint, + std::string accessibilityRole + ) + : accessibilityHint_(accessibilityHint), + accessibilityRole_(accessibilityRole){}; + + SimpleComponentState() = default; + + std::string getAccessibilityHint() const; + std::string getAccessibilityRole() const; + + +#ifdef ANDROID + SimpleComponentState(SimpleComponentState const &previousState, folly::dynamic data){}; + folly::dynamic getDynamic() const { + return {}; + }; + MapBuffer getMapBuffer() const { + return MapBufferBuilder::EMPTY(); + }; +#endif + + private: + std::string accessibilityHint_{\\"\\"}; + std::string accessibilityRole_; + +}; + +} // namespace react +} // namespace facebook", +} +`; + +exports[`GenerateStateH can generate fixture DOUBLE_PROPS 1`] = ` +Map { + "States.h" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateStateH.js + */ +#pragma once + +#include + +#ifdef ANDROID +#include +#include +#include +#endif + +namespace facebook { +namespace react { class DoublePropNativeComponentState { public: + DoublePropNativeComponentState() = default; + + #ifdef ANDROID DoublePropNativeComponentState(DoublePropNativeComponentState const &previousState, folly::dynamic data){}; folly::dynamic getDynamic() const { @@ -306,19 +1185,19 @@ class DoublePropNativeComponentState { return MapBufferBuilder::EMPTY(); }; #endif + + private: + }; - } // namespace react -} // namespace facebook -", +} // namespace facebook", } `; exports[`GenerateStateH can generate fixture EVENT_NESTED_OBJECT_PROPS 1`] = ` Map { - "States.h" => " -/** + "States.h" => "/** * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * * Do not edit this file as changes may cause incorrect behavior and will be lost @@ -328,6 +1207,8 @@ Map { */ #pragma once +#include + #ifdef ANDROID #include #include @@ -337,11 +1218,13 @@ Map { namespace facebook { namespace react { - class EventsNestedObjectNativeComponentState { public: + EventsNestedObjectNativeComponentState() = default; + + #ifdef ANDROID EventsNestedObjectNativeComponentState(EventsNestedObjectNativeComponentState const &previousState, folly::dynamic data){}; folly::dynamic getDynamic() const { @@ -351,19 +1234,19 @@ class EventsNestedObjectNativeComponentState { return MapBufferBuilder::EMPTY(); }; #endif + + private: + }; - } // namespace react -} // namespace facebook -", +} // namespace facebook", } `; exports[`GenerateStateH can generate fixture EVENT_PROPS 1`] = ` Map { - "States.h" => " -/** + "States.h" => "/** * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * * Do not edit this file as changes may cause incorrect behavior and will be lost @@ -373,6 +1256,8 @@ Map { */ #pragma once +#include + #ifdef ANDROID #include #include @@ -382,11 +1267,13 @@ Map { namespace facebook { namespace react { - class EventsNativeComponentState { public: + EventsNativeComponentState() = default; + + #ifdef ANDROID EventsNativeComponentState(EventsNativeComponentState const &previousState, folly::dynamic data){}; folly::dynamic getDynamic() const { @@ -396,19 +1283,19 @@ class EventsNativeComponentState { return MapBufferBuilder::EMPTY(); }; #endif + + private: + }; - } // namespace react -} // namespace facebook -", +} // namespace facebook", } `; exports[`GenerateStateH can generate fixture EVENTS_WITH_PAPER_NAME 1`] = ` Map { - "States.h" => " -/** + "States.h" => "/** * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * * Do not edit this file as changes may cause incorrect behavior and will be lost @@ -418,6 +1305,8 @@ Map { */ #pragma once +#include + #ifdef ANDROID #include #include @@ -430,15 +1319,13 @@ namespace react { } // namespace react -} // namespace facebook -", +} // namespace facebook", } `; exports[`GenerateStateH can generate fixture EXCLUDE_ANDROID 1`] = ` Map { - "States.h" => " -/** + "States.h" => "/** * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * * Do not edit this file as changes may cause incorrect behavior and will be lost @@ -448,6 +1335,8 @@ Map { */ #pragma once +#include + #ifdef ANDROID #include #include @@ -457,11 +1346,13 @@ Map { namespace facebook { namespace react { - class ExcludedAndroidComponentState { public: + ExcludedAndroidComponentState() = default; + + #ifdef ANDROID ExcludedAndroidComponentState(ExcludedAndroidComponentState const &previousState, folly::dynamic data){}; folly::dynamic getDynamic() const { @@ -471,19 +1362,19 @@ class ExcludedAndroidComponentState { return MapBufferBuilder::EMPTY(); }; #endif + + private: + }; - } // namespace react -} // namespace facebook -", +} // namespace facebook", } `; exports[`GenerateStateH can generate fixture EXCLUDE_ANDROID_IOS 1`] = ` Map { - "States.h" => " -/** + "States.h" => "/** * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * * Do not edit this file as changes may cause incorrect behavior and will be lost @@ -493,6 +1384,8 @@ Map { */ #pragma once +#include + #ifdef ANDROID #include #include @@ -502,11 +1395,13 @@ Map { namespace facebook { namespace react { - class ExcludedAndroidIosComponentState { public: + ExcludedAndroidIosComponentState() = default; + + #ifdef ANDROID ExcludedAndroidIosComponentState(ExcludedAndroidIosComponentState const &previousState, folly::dynamic data){}; folly::dynamic getDynamic() const { @@ -516,19 +1411,19 @@ class ExcludedAndroidIosComponentState { return MapBufferBuilder::EMPTY(); }; #endif + + private: + }; - } // namespace react -} // namespace facebook -", +} // namespace facebook", } `; exports[`GenerateStateH can generate fixture EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES 1`] = ` Map { - "States.h" => " -/** + "States.h" => "/** * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * * Do not edit this file as changes may cause incorrect behavior and will be lost @@ -538,6 +1433,8 @@ Map { */ #pragma once +#include + #ifdef ANDROID #include #include @@ -547,11 +1444,13 @@ Map { namespace facebook { namespace react { - class ExcludedIosComponentState { public: + ExcludedIosComponentState() = default; + + #ifdef ANDROID ExcludedIosComponentState(ExcludedIosComponentState const &previousState, folly::dynamic data){}; folly::dynamic getDynamic() const { @@ -561,14 +1460,18 @@ class ExcludedIosComponentState { return MapBufferBuilder::EMPTY(); }; #endif + + private: + }; - - class MultiFileIncludedNativeComponentState { public: + MultiFileIncludedNativeComponentState() = default; + + #ifdef ANDROID MultiFileIncludedNativeComponentState(MultiFileIncludedNativeComponentState const &previousState, folly::dynamic data){}; folly::dynamic getDynamic() const { @@ -578,19 +1481,19 @@ class MultiFileIncludedNativeComponentState { return MapBufferBuilder::EMPTY(); }; #endif + + private: + }; - } // namespace react -} // namespace facebook -", +} // namespace facebook", } `; exports[`GenerateStateH can generate fixture FLOAT_PROPS 1`] = ` Map { - "States.h" => " -/** + "States.h" => "/** * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * * Do not edit this file as changes may cause incorrect behavior and will be lost @@ -600,6 +1503,8 @@ Map { */ #pragma once +#include + #ifdef ANDROID #include #include @@ -609,11 +1514,13 @@ Map { namespace facebook { namespace react { - class FloatPropNativeComponentState { public: + FloatPropNativeComponentState() = default; + + #ifdef ANDROID FloatPropNativeComponentState(FloatPropNativeComponentState const &previousState, folly::dynamic data){}; folly::dynamic getDynamic() const { @@ -623,19 +1530,19 @@ class FloatPropNativeComponentState { return MapBufferBuilder::EMPTY(); }; #endif + + private: + }; - } // namespace react -} // namespace facebook -", +} // namespace facebook", } `; exports[`GenerateStateH can generate fixture IMAGE_PROP 1`] = ` Map { - "States.h" => " -/** + "States.h" => "/** * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * * Do not edit this file as changes may cause incorrect behavior and will be lost @@ -645,6 +1552,8 @@ Map { */ #pragma once +#include + #ifdef ANDROID #include #include @@ -654,11 +1563,13 @@ Map { namespace facebook { namespace react { - class ImagePropNativeComponentState { public: + ImagePropNativeComponentState() = default; + + #ifdef ANDROID ImagePropNativeComponentState(ImagePropNativeComponentState const &previousState, folly::dynamic data){}; folly::dynamic getDynamic() const { @@ -668,19 +1579,19 @@ class ImagePropNativeComponentState { return MapBufferBuilder::EMPTY(); }; #endif + + private: + }; - } // namespace react -} // namespace facebook -", +} // namespace facebook", } `; exports[`GenerateStateH can generate fixture INSETS_PROP 1`] = ` Map { - "States.h" => " -/** + "States.h" => "/** * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * * Do not edit this file as changes may cause incorrect behavior and will be lost @@ -690,6 +1601,8 @@ Map { */ #pragma once +#include + #ifdef ANDROID #include #include @@ -699,11 +1612,13 @@ Map { namespace facebook { namespace react { - class InsetsPropNativeComponentState { public: + InsetsPropNativeComponentState() = default; + + #ifdef ANDROID InsetsPropNativeComponentState(InsetsPropNativeComponentState const &previousState, folly::dynamic data){}; folly::dynamic getDynamic() const { @@ -713,19 +1628,19 @@ class InsetsPropNativeComponentState { return MapBufferBuilder::EMPTY(); }; #endif + + private: + }; - } // namespace react -} // namespace facebook -", +} // namespace facebook", } `; exports[`GenerateStateH can generate fixture INT32_ENUM_PROP 1`] = ` Map { - "States.h" => " -/** + "States.h" => "/** * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * * Do not edit this file as changes may cause incorrect behavior and will be lost @@ -735,6 +1650,8 @@ Map { */ #pragma once +#include + #ifdef ANDROID #include #include @@ -744,11 +1661,13 @@ Map { namespace facebook { namespace react { - class Int32EnumPropsNativeComponentState { public: + Int32EnumPropsNativeComponentState() = default; + + #ifdef ANDROID Int32EnumPropsNativeComponentState(Int32EnumPropsNativeComponentState const &previousState, folly::dynamic data){}; folly::dynamic getDynamic() const { @@ -758,19 +1677,19 @@ class Int32EnumPropsNativeComponentState { return MapBufferBuilder::EMPTY(); }; #endif + + private: + }; - } // namespace react -} // namespace facebook -", +} // namespace facebook", } `; exports[`GenerateStateH can generate fixture INTEGER_PROPS 1`] = ` Map { - "States.h" => " -/** + "States.h" => "/** * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * * Do not edit this file as changes may cause incorrect behavior and will be lost @@ -780,6 +1699,8 @@ Map { */ #pragma once +#include + #ifdef ANDROID #include #include @@ -789,11 +1710,13 @@ Map { namespace facebook { namespace react { - class IntegerPropNativeComponentState { public: + IntegerPropNativeComponentState() = default; + + #ifdef ANDROID IntegerPropNativeComponentState(IntegerPropNativeComponentState const &previousState, folly::dynamic data){}; folly::dynamic getDynamic() const { @@ -803,19 +1726,19 @@ class IntegerPropNativeComponentState { return MapBufferBuilder::EMPTY(); }; #endif + + private: + }; - } // namespace react -} // namespace facebook -", +} // namespace facebook", } `; exports[`GenerateStateH can generate fixture INTERFACE_ONLY 1`] = ` Map { - "States.h" => " -/** + "States.h" => "/** * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * * Do not edit this file as changes may cause incorrect behavior and will be lost @@ -825,6 +1748,8 @@ Map { */ #pragma once +#include + #ifdef ANDROID #include #include @@ -837,15 +1762,13 @@ namespace react { } // namespace react -} // namespace facebook -", +} // namespace facebook", } `; exports[`GenerateStateH can generate fixture MULTI_NATIVE_PROP 1`] = ` Map { - "States.h" => " -/** + "States.h" => "/** * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * * Do not edit this file as changes may cause incorrect behavior and will be lost @@ -855,6 +1778,8 @@ Map { */ #pragma once +#include + #ifdef ANDROID #include #include @@ -864,11 +1789,13 @@ Map { namespace facebook { namespace react { - class ImageColorPropNativeComponentState { public: + ImageColorPropNativeComponentState() = default; + + #ifdef ANDROID ImageColorPropNativeComponentState(ImageColorPropNativeComponentState const &previousState, folly::dynamic data){}; folly::dynamic getDynamic() const { @@ -878,19 +1805,19 @@ class ImageColorPropNativeComponentState { return MapBufferBuilder::EMPTY(); }; #endif + + private: + }; - } // namespace react -} // namespace facebook -", +} // namespace facebook", } `; exports[`GenerateStateH can generate fixture NO_PROPS_NO_EVENTS 1`] = ` Map { - "States.h" => " -/** + "States.h" => "/** * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * * Do not edit this file as changes may cause incorrect behavior and will be lost @@ -900,6 +1827,8 @@ Map { */ #pragma once +#include + #ifdef ANDROID #include #include @@ -909,11 +1838,13 @@ Map { namespace facebook { namespace react { - class NoPropsNoEventsComponentState { public: + NoPropsNoEventsComponentState() = default; + + #ifdef ANDROID NoPropsNoEventsComponentState(NoPropsNoEventsComponentState const &previousState, folly::dynamic data){}; folly::dynamic getDynamic() const { @@ -923,19 +1854,19 @@ class NoPropsNoEventsComponentState { return MapBufferBuilder::EMPTY(); }; #endif + + private: + }; - } // namespace react -} // namespace facebook -", +} // namespace facebook", } `; exports[`GenerateStateH can generate fixture OBJECT_PROPS 1`] = ` Map { - "States.h" => " -/** + "States.h" => "/** * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * * Do not edit this file as changes may cause incorrect behavior and will be lost @@ -945,6 +1876,8 @@ Map { */ #pragma once +#include + #ifdef ANDROID #include #include @@ -954,11 +1887,13 @@ Map { namespace facebook { namespace react { - class ObjectPropsState { public: + ObjectPropsState() = default; + + #ifdef ANDROID ObjectPropsState(ObjectPropsState const &previousState, folly::dynamic data){}; folly::dynamic getDynamic() const { @@ -968,19 +1903,19 @@ class ObjectPropsState { return MapBufferBuilder::EMPTY(); }; #endif + + private: + }; - } // namespace react -} // namespace facebook -", +} // namespace facebook", } `; exports[`GenerateStateH can generate fixture POINT_PROP 1`] = ` Map { - "States.h" => " -/** + "States.h" => "/** * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * * Do not edit this file as changes may cause incorrect behavior and will be lost @@ -990,6 +1925,8 @@ Map { */ #pragma once +#include + #ifdef ANDROID #include #include @@ -999,11 +1936,13 @@ Map { namespace facebook { namespace react { - class PointPropNativeComponentState { public: + PointPropNativeComponentState() = default; + + #ifdef ANDROID PointPropNativeComponentState(PointPropNativeComponentState const &previousState, folly::dynamic data){}; folly::dynamic getDynamic() const { @@ -1013,19 +1952,19 @@ class PointPropNativeComponentState { return MapBufferBuilder::EMPTY(); }; #endif + + private: + }; - } // namespace react -} // namespace facebook -", +} // namespace facebook", } `; exports[`GenerateStateH can generate fixture STRING_ENUM_PROP 1`] = ` Map { - "States.h" => " -/** + "States.h" => "/** * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * * Do not edit this file as changes may cause incorrect behavior and will be lost @@ -1035,6 +1974,8 @@ Map { */ #pragma once +#include + #ifdef ANDROID #include #include @@ -1044,11 +1985,13 @@ Map { namespace facebook { namespace react { - class StringEnumPropsNativeComponentState { public: + StringEnumPropsNativeComponentState() = default; + + #ifdef ANDROID StringEnumPropsNativeComponentState(StringEnumPropsNativeComponentState const &previousState, folly::dynamic data){}; folly::dynamic getDynamic() const { @@ -1058,19 +2001,19 @@ class StringEnumPropsNativeComponentState { return MapBufferBuilder::EMPTY(); }; #endif + + private: + }; - } // namespace react -} // namespace facebook -", +} // namespace facebook", } `; exports[`GenerateStateH can generate fixture STRING_PROP 1`] = ` Map { - "States.h" => " -/** + "States.h" => "/** * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * * Do not edit this file as changes may cause incorrect behavior and will be lost @@ -1080,6 +2023,8 @@ Map { */ #pragma once +#include + #ifdef ANDROID #include #include @@ -1089,11 +2034,13 @@ Map { namespace facebook { namespace react { - class StringPropComponentState { public: + StringPropComponentState() = default; + + #ifdef ANDROID StringPropComponentState(StringPropComponentState const &previousState, folly::dynamic data){}; folly::dynamic getDynamic() const { @@ -1103,19 +2050,19 @@ class StringPropComponentState { return MapBufferBuilder::EMPTY(); }; #endif + + private: + }; - } // namespace react -} // namespace facebook -", +} // namespace facebook", } `; exports[`GenerateStateH can generate fixture TWO_COMPONENTS_DIFFERENT_FILES 1`] = ` Map { - "States.h" => " -/** + "States.h" => "/** * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * * Do not edit this file as changes may cause incorrect behavior and will be lost @@ -1125,6 +2072,8 @@ Map { */ #pragma once +#include + #ifdef ANDROID #include #include @@ -1134,11 +2083,13 @@ Map { namespace facebook { namespace react { - class MultiFile1NativeComponentState { public: + MultiFile1NativeComponentState() = default; + + #ifdef ANDROID MultiFile1NativeComponentState(MultiFile1NativeComponentState const &previousState, folly::dynamic data){}; folly::dynamic getDynamic() const { @@ -1148,14 +2099,18 @@ class MultiFile1NativeComponentState { return MapBufferBuilder::EMPTY(); }; #endif + + private: + }; - - class MultiFile2NativeComponentState { public: + MultiFile2NativeComponentState() = default; + + #ifdef ANDROID MultiFile2NativeComponentState(MultiFile2NativeComponentState const &previousState, folly::dynamic data){}; folly::dynamic getDynamic() const { @@ -1165,19 +2120,19 @@ class MultiFile2NativeComponentState { return MapBufferBuilder::EMPTY(); }; #endif + + private: + }; - } // namespace react -} // namespace facebook -", +} // namespace facebook", } `; exports[`GenerateStateH can generate fixture TWO_COMPONENTS_SAME_FILE 1`] = ` Map { - "States.h" => " -/** + "States.h" => "/** * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * * Do not edit this file as changes may cause incorrect behavior and will be lost @@ -1187,6 +2142,8 @@ Map { */ #pragma once +#include + #ifdef ANDROID #include #include @@ -1196,11 +2153,13 @@ Map { namespace facebook { namespace react { - class MultiComponent1NativeComponentState { public: + MultiComponent1NativeComponentState() = default; + + #ifdef ANDROID MultiComponent1NativeComponentState(MultiComponent1NativeComponentState const &previousState, folly::dynamic data){}; folly::dynamic getDynamic() const { @@ -1210,14 +2169,18 @@ class MultiComponent1NativeComponentState { return MapBufferBuilder::EMPTY(); }; #endif + + private: + }; - - class MultiComponent2NativeComponentState { public: + MultiComponent2NativeComponentState() = default; + + #ifdef ANDROID MultiComponent2NativeComponentState(MultiComponent2NativeComponentState const &previousState, folly::dynamic data){}; folly::dynamic getDynamic() const { @@ -1227,11 +2190,12 @@ class MultiComponent2NativeComponentState { return MapBufferBuilder::EMPTY(); }; #endif + + private: + }; - } // namespace react -} // namespace facebook -", +} // namespace facebook", } `; diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateTests-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateTests-test.js.snap index e8f46ea1f10..e5b038cd646 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateTests-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateTests-test.js.snap @@ -250,6 +250,496 @@ TEST(CommandNativeComponentProps_accessibilityHint, etc) { } `; +exports[`GenerateTests can generate fixture COMPONENT_WITH_ARRAY_OF_OBJECTS_STATE 1`] = ` +Map { + "Tests.cpp" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateTests.js + * */ + +#include +#include +#include +#include +#include +#include + +using namespace facebook::react; + +TEST(SimpleComponentProps_DoesNotDie, etc) { + auto propParser = RawPropsParser(); + propParser.prepare(); + auto const &sourceProps = SimpleComponentProps(); + auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + SimpleComponentProps(parserContext, sourceProps, rawProps); +}", +} +`; + +exports[`GenerateTests can generate fixture COMPONENT_WITH_ARRAY_STATE 1`] = ` +Map { + "Tests.cpp" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateTests.js + * */ + +#include +#include +#include +#include +#include +#include + +using namespace facebook::react; + +TEST(SimpleComponentProps_DoesNotDie, etc) { + auto propParser = RawPropsParser(); + propParser.prepare(); + auto const &sourceProps = SimpleComponentProps(); + auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + SimpleComponentProps(parserContext, sourceProps, rawProps); +}", +} +`; + +exports[`GenerateTests can generate fixture COMPONENT_WITH_BOOL_STATE 1`] = ` +Map { + "Tests.cpp" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateTests.js + * */ + +#include +#include +#include +#include +#include +#include + +using namespace facebook::react; + +TEST(SimpleComponentProps_DoesNotDie, etc) { + auto propParser = RawPropsParser(); + propParser.prepare(); + auto const &sourceProps = SimpleComponentProps(); + auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + SimpleComponentProps(parserContext, sourceProps, rawProps); +}", +} +`; + +exports[`GenerateTests can generate fixture COMPONENT_WITH_COLOR_STATE 1`] = ` +Map { + "Tests.cpp" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateTests.js + * */ + +#include +#include +#include +#include +#include +#include + +using namespace facebook::react; + +TEST(SimpleComponentProps_DoesNotDie, etc) { + auto propParser = RawPropsParser(); + propParser.prepare(); + auto const &sourceProps = SimpleComponentProps(); + auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + SimpleComponentProps(parserContext, sourceProps, rawProps); +}", +} +`; + +exports[`GenerateTests can generate fixture COMPONENT_WITH_DOUBLE_STATE 1`] = ` +Map { + "Tests.cpp" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateTests.js + * */ + +#include +#include +#include +#include +#include +#include + +using namespace facebook::react; + +TEST(SimpleComponentProps_DoesNotDie, etc) { + auto propParser = RawPropsParser(); + propParser.prepare(); + auto const &sourceProps = SimpleComponentProps(); + auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + SimpleComponentProps(parserContext, sourceProps, rawProps); +}", +} +`; + +exports[`GenerateTests can generate fixture COMPONENT_WITH_EDGE_INSET_STATE_PROPS 1`] = ` +Map { + "Tests.cpp" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateTests.js + * */ + +#include +#include +#include +#include +#include +#include + +using namespace facebook::react; + +TEST(SimpleComponentProps_DoesNotDie, etc) { + auto propParser = RawPropsParser(); + propParser.prepare(); + auto const &sourceProps = SimpleComponentProps(); + auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + SimpleComponentProps(parserContext, sourceProps, rawProps); +}", +} +`; + +exports[`GenerateTests can generate fixture COMPONENT_WITH_FLOAT_STATE 1`] = ` +Map { + "Tests.cpp" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateTests.js + * */ + +#include +#include +#include +#include +#include +#include + +using namespace facebook::react; + +TEST(SimpleComponentProps_DoesNotDie, etc) { + auto propParser = RawPropsParser(); + propParser.prepare(); + auto const &sourceProps = SimpleComponentProps(); + auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + SimpleComponentProps(parserContext, sourceProps, rawProps); +}", +} +`; + +exports[`GenerateTests can generate fixture COMPONENT_WITH_IMAGE_STATE 1`] = ` +Map { + "Tests.cpp" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateTests.js + * */ + +#include +#include +#include +#include +#include +#include + +using namespace facebook::react; + +TEST(SimpleComponentProps_DoesNotDie, etc) { + auto propParser = RawPropsParser(); + propParser.prepare(); + auto const &sourceProps = SimpleComponentProps(); + auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + SimpleComponentProps(parserContext, sourceProps, rawProps); +}", +} +`; + +exports[`GenerateTests can generate fixture COMPONENT_WITH_INT_ENUM_STATE 1`] = ` +Map { + "Tests.cpp" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateTests.js + * */ + +#include +#include +#include +#include +#include +#include + +using namespace facebook::react; + +TEST(SimpleComponentProps_DoesNotDie, etc) { + auto propParser = RawPropsParser(); + propParser.prepare(); + auto const &sourceProps = SimpleComponentProps(); + auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + SimpleComponentProps(parserContext, sourceProps, rawProps); +}", +} +`; + +exports[`GenerateTests can generate fixture COMPONENT_WITH_INT_STATE 1`] = ` +Map { + "Tests.cpp" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateTests.js + * */ + +#include +#include +#include +#include +#include +#include + +using namespace facebook::react; + +TEST(SimpleComponentProps_DoesNotDie, etc) { + auto propParser = RawPropsParser(); + propParser.prepare(); + auto const &sourceProps = SimpleComponentProps(); + auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + SimpleComponentProps(parserContext, sourceProps, rawProps); +}", +} +`; + +exports[`GenerateTests can generate fixture COMPONENT_WITH_OBJECT_STATE 1`] = ` +Map { + "Tests.cpp" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateTests.js + * */ + +#include +#include +#include +#include +#include +#include + +using namespace facebook::react; + +TEST(SimpleComponentProps_DoesNotDie, etc) { + auto propParser = RawPropsParser(); + propParser.prepare(); + auto const &sourceProps = SimpleComponentProps(); + auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + SimpleComponentProps(parserContext, sourceProps, rawProps); +}", +} +`; + +exports[`GenerateTests can generate fixture COMPONENT_WITH_POINT_STATE 1`] = ` +Map { + "Tests.cpp" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateTests.js + * */ + +#include +#include +#include +#include +#include +#include + +using namespace facebook::react; + +TEST(SimpleComponentProps_DoesNotDie, etc) { + auto propParser = RawPropsParser(); + propParser.prepare(); + auto const &sourceProps = SimpleComponentProps(); + auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + SimpleComponentProps(parserContext, sourceProps, rawProps); +}", +} +`; + +exports[`GenerateTests can generate fixture COMPONENT_WITH_STRING_ENUM_STATE_PROPS 1`] = ` +Map { + "Tests.cpp" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateTests.js + * */ + +#include +#include +#include +#include +#include +#include + +using namespace facebook::react; + +TEST(SimpleComponentProps_DoesNotDie, etc) { + auto propParser = RawPropsParser(); + propParser.prepare(); + auto const &sourceProps = SimpleComponentProps(); + auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + SimpleComponentProps(parserContext, sourceProps, rawProps); +}", +} +`; + +exports[`GenerateTests can generate fixture COMPONENT_WITH_STRING_STATE 1`] = ` +Map { + "Tests.cpp" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateTests.js + * */ + +#include +#include +#include +#include +#include +#include + +using namespace facebook::react; + +TEST(SimpleComponentProps_DoesNotDie, etc) { + auto propParser = RawPropsParser(); + propParser.prepare(); + auto const &sourceProps = SimpleComponentProps(); + auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + SimpleComponentProps(parserContext, sourceProps, rawProps); +}", +} +`; + exports[`GenerateTests can generate fixture DOUBLE_PROPS 1`] = ` Map { "Tests.cpp" => "/** diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateThirdPartyFabricComponentsProviderH-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateThirdPartyFabricComponentsProviderH-test.js.snap index 4cab36433d2..d6ac27d7b87 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateThirdPartyFabricComponentsProviderH-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateThirdPartyFabricComponentsProviderH-test.js.snap @@ -52,6 +52,20 @@ Class CommandNativeComponentCls(void) __attribute__((u Class ExcludedAndroidComponentCls(void) __attribute__((used)); // EXCLUDE_ANDROID Class MultiFileIncludedNativeComponentCls(void) __attribute__((used)); // EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES +Class SimpleComponentCls(void) __attribute__((used)); // COMPONENT_WITH_BOOL_STATE +Class SimpleComponentCls(void) __attribute__((used)); // COMPONENT_WITH_STRING_STATE +Class SimpleComponentCls(void) __attribute__((used)); // COMPONENT_WITH_INT_STATE +Class SimpleComponentCls(void) __attribute__((used)); // COMPONENT_WITH_FLOAT_STATE +Class SimpleComponentCls(void) __attribute__((used)); // COMPONENT_WITH_DOUBLE_STATE +Class SimpleComponentCls(void) __attribute__((used)); // COMPONENT_WITH_COLOR_STATE +Class SimpleComponentCls(void) __attribute__((used)); // COMPONENT_WITH_POINT_STATE +Class SimpleComponentCls(void) __attribute__((used)); // COMPONENT_WITH_IMAGE_STATE +Class SimpleComponentCls(void) __attribute__((used)); // COMPONENT_WITH_EDGE_INSET_STATE_PROPS +Class SimpleComponentCls(void) __attribute__((used)); // COMPONENT_WITH_ARRAY_STATE +Class SimpleComponentCls(void) __attribute__((used)); // COMPONENT_WITH_OBJECT_STATE +Class SimpleComponentCls(void) __attribute__((used)); // COMPONENT_WITH_ARRAY_OF_OBJECTS_STATE +Class SimpleComponentCls(void) __attribute__((used)); // COMPONENT_WITH_STRING_ENUM_STATE_PROPS +Class SimpleComponentCls(void) __attribute__((used)); // COMPONENT_WITH_INT_ENUM_STATE #ifdef __cplusplus } diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateThirdPartyFabricComponentsProviderObjCpp-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateThirdPartyFabricComponentsProviderObjCpp-test.js.snap index 0fa2add3459..f140a9cb238 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateThirdPartyFabricComponentsProviderObjCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateThirdPartyFabricComponentsProviderObjCpp-test.js.snap @@ -76,6 +76,34 @@ Class RCTThirdPartyFabricComponentsProvider(const char {\\"MultiFileIncludedNativeComponent\\", MultiFileIncludedNativeComponentCls}, // EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES + + {\\"SimpleComponent\\", SimpleComponentCls}, // COMPONENT_WITH_BOOL_STATE + + {\\"SimpleComponent\\", SimpleComponentCls}, // COMPONENT_WITH_STRING_STATE + + {\\"SimpleComponent\\", SimpleComponentCls}, // COMPONENT_WITH_INT_STATE + + {\\"SimpleComponent\\", SimpleComponentCls}, // COMPONENT_WITH_FLOAT_STATE + + {\\"SimpleComponent\\", SimpleComponentCls}, // COMPONENT_WITH_DOUBLE_STATE + + {\\"SimpleComponent\\", SimpleComponentCls}, // COMPONENT_WITH_COLOR_STATE + + {\\"SimpleComponent\\", SimpleComponentCls}, // COMPONENT_WITH_POINT_STATE + + {\\"SimpleComponent\\", SimpleComponentCls}, // COMPONENT_WITH_IMAGE_STATE + + {\\"SimpleComponent\\", SimpleComponentCls}, // COMPONENT_WITH_EDGE_INSET_STATE_PROPS + + {\\"SimpleComponent\\", SimpleComponentCls}, // COMPONENT_WITH_ARRAY_STATE + + {\\"SimpleComponent\\", SimpleComponentCls}, // COMPONENT_WITH_OBJECT_STATE + + {\\"SimpleComponent\\", SimpleComponentCls}, // COMPONENT_WITH_ARRAY_OF_OBJECTS_STATE + + {\\"SimpleComponent\\", SimpleComponentCls}, // COMPONENT_WITH_STRING_ENUM_STATE_PROPS + + {\\"SimpleComponent\\", SimpleComponentCls}, // COMPONENT_WITH_INT_ENUM_STATE }; auto p = sFabricComponentsClassMap.find(name); diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateViewConfigJs-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateViewConfigJs-test.js.snap index a48a2426a81..0b209211cb4 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateViewConfigJs-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateViewConfigJs-test.js.snap @@ -239,6 +239,440 @@ export const Commands = { } `; +exports[`GenerateViewConfigJs can generate fixture COMPONENT_WITH_ARRAY_OF_OBJECTS_STATE 1`] = ` +Map { + "COMPONENT_WITH_ARRAY_OF_OBJECTS_STATENativeViewConfig.js" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @flow + * + * @generated by codegen project: GenerateViewConfigJs.js + */ + +'use strict'; + +const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry'); + +let nativeComponentName = 'SimpleComponent'; + + +export const __INTERNAL_VIEW_CONFIG = { + uiViewClassName: 'SimpleComponent', + validAttributes: {}, +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); +", +} +`; + +exports[`GenerateViewConfigJs can generate fixture COMPONENT_WITH_ARRAY_STATE 1`] = ` +Map { + "COMPONENT_WITH_ARRAY_STATENativeViewConfig.js" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @flow + * + * @generated by codegen project: GenerateViewConfigJs.js + */ + +'use strict'; + +const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry'); + +let nativeComponentName = 'SimpleComponent'; + + +export const __INTERNAL_VIEW_CONFIG = { + uiViewClassName: 'SimpleComponent', + validAttributes: {}, +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); +", +} +`; + +exports[`GenerateViewConfigJs can generate fixture COMPONENT_WITH_BOOL_STATE 1`] = ` +Map { + "COMPONENT_WITH_BOOL_STATENativeViewConfig.js" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @flow + * + * @generated by codegen project: GenerateViewConfigJs.js + */ + +'use strict'; + +const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry'); + +let nativeComponentName = 'SimpleComponent'; + + +export const __INTERNAL_VIEW_CONFIG = { + uiViewClassName: 'SimpleComponent', + validAttributes: {}, +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); +", +} +`; + +exports[`GenerateViewConfigJs can generate fixture COMPONENT_WITH_COLOR_STATE 1`] = ` +Map { + "COMPONENT_WITH_COLOR_STATENativeViewConfig.js" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @flow + * + * @generated by codegen project: GenerateViewConfigJs.js + */ + +'use strict'; + +const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry'); + +let nativeComponentName = 'SimpleComponent'; + + +export const __INTERNAL_VIEW_CONFIG = { + uiViewClassName: 'SimpleComponent', + validAttributes: {}, +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); +", +} +`; + +exports[`GenerateViewConfigJs can generate fixture COMPONENT_WITH_DOUBLE_STATE 1`] = ` +Map { + "COMPONENT_WITH_DOUBLE_STATENativeViewConfig.js" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @flow + * + * @generated by codegen project: GenerateViewConfigJs.js + */ + +'use strict'; + +const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry'); + +let nativeComponentName = 'SimpleComponent'; + + +export const __INTERNAL_VIEW_CONFIG = { + uiViewClassName: 'SimpleComponent', + validAttributes: {}, +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); +", +} +`; + +exports[`GenerateViewConfigJs can generate fixture COMPONENT_WITH_EDGE_INSET_STATE_PROPS 1`] = ` +Map { + "COMPONENT_WITH_EDGE_INSET_STATE_PROPSNativeViewConfig.js" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @flow + * + * @generated by codegen project: GenerateViewConfigJs.js + */ + +'use strict'; + +const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry'); + +let nativeComponentName = 'SimpleComponent'; + + +export const __INTERNAL_VIEW_CONFIG = { + uiViewClassName: 'SimpleComponent', + validAttributes: {}, +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); +", +} +`; + +exports[`GenerateViewConfigJs can generate fixture COMPONENT_WITH_FLOAT_STATE 1`] = ` +Map { + "COMPONENT_WITH_FLOAT_STATENativeViewConfig.js" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @flow + * + * @generated by codegen project: GenerateViewConfigJs.js + */ + +'use strict'; + +const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry'); + +let nativeComponentName = 'SimpleComponent'; + + +export const __INTERNAL_VIEW_CONFIG = { + uiViewClassName: 'SimpleComponent', + validAttributes: {}, +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); +", +} +`; + +exports[`GenerateViewConfigJs can generate fixture COMPONENT_WITH_IMAGE_STATE 1`] = ` +Map { + "COMPONENT_WITH_IMAGE_STATENativeViewConfig.js" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @flow + * + * @generated by codegen project: GenerateViewConfigJs.js + */ + +'use strict'; + +const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry'); + +let nativeComponentName = 'SimpleComponent'; + + +export const __INTERNAL_VIEW_CONFIG = { + uiViewClassName: 'SimpleComponent', + validAttributes: {}, +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); +", +} +`; + +exports[`GenerateViewConfigJs can generate fixture COMPONENT_WITH_INT_ENUM_STATE 1`] = ` +Map { + "COMPONENT_WITH_INT_ENUM_STATENativeViewConfig.js" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @flow + * + * @generated by codegen project: GenerateViewConfigJs.js + */ + +'use strict'; + +const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry'); + +let nativeComponentName = 'SimpleComponent'; + + +export const __INTERNAL_VIEW_CONFIG = { + uiViewClassName: 'SimpleComponent', + validAttributes: {}, +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); +", +} +`; + +exports[`GenerateViewConfigJs can generate fixture COMPONENT_WITH_INT_STATE 1`] = ` +Map { + "COMPONENT_WITH_INT_STATENativeViewConfig.js" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @flow + * + * @generated by codegen project: GenerateViewConfigJs.js + */ + +'use strict'; + +const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry'); + +let nativeComponentName = 'SimpleComponent'; + + +export const __INTERNAL_VIEW_CONFIG = { + uiViewClassName: 'SimpleComponent', + validAttributes: {}, +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); +", +} +`; + +exports[`GenerateViewConfigJs can generate fixture COMPONENT_WITH_OBJECT_STATE 1`] = ` +Map { + "COMPONENT_WITH_OBJECT_STATENativeViewConfig.js" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @flow + * + * @generated by codegen project: GenerateViewConfigJs.js + */ + +'use strict'; + +const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry'); + +let nativeComponentName = 'SimpleComponent'; + + +export const __INTERNAL_VIEW_CONFIG = { + uiViewClassName: 'SimpleComponent', + validAttributes: {}, +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); +", +} +`; + +exports[`GenerateViewConfigJs can generate fixture COMPONENT_WITH_POINT_STATE 1`] = ` +Map { + "COMPONENT_WITH_POINT_STATENativeViewConfig.js" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @flow + * + * @generated by codegen project: GenerateViewConfigJs.js + */ + +'use strict'; + +const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry'); + +let nativeComponentName = 'SimpleComponent'; + + +export const __INTERNAL_VIEW_CONFIG = { + uiViewClassName: 'SimpleComponent', + validAttributes: {}, +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); +", +} +`; + +exports[`GenerateViewConfigJs can generate fixture COMPONENT_WITH_STRING_ENUM_STATE_PROPS 1`] = ` +Map { + "COMPONENT_WITH_STRING_ENUM_STATE_PROPSNativeViewConfig.js" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @flow + * + * @generated by codegen project: GenerateViewConfigJs.js + */ + +'use strict'; + +const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry'); + +let nativeComponentName = 'SimpleComponent'; + + +export const __INTERNAL_VIEW_CONFIG = { + uiViewClassName: 'SimpleComponent', + validAttributes: {}, +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); +", +} +`; + +exports[`GenerateViewConfigJs can generate fixture COMPONENT_WITH_STRING_STATE 1`] = ` +Map { + "COMPONENT_WITH_STRING_STATENativeViewConfig.js" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @flow + * + * @generated by codegen project: GenerateViewConfigJs.js + */ + +'use strict'; + +const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry'); + +let nativeComponentName = 'SimpleComponent'; + + +export const __INTERNAL_VIEW_CONFIG = { + uiViewClassName: 'SimpleComponent', + validAttributes: {}, +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); +", +} +`; + exports[`GenerateViewConfigJs can generate fixture DOUBLE_PROPS 1`] = ` Map { "DOUBLE_PROPSNativeViewConfig.js" => "