Skip to content

Commit dd390db

Browse files
Nick Lefevermeta-codesync[bot]
authored andcommitted
Add fixtures for optional object generation (#54727)
Summary: Pull Request resolved: #54727 See title Changelog: [Internal] Reviewed By: cortinico Differential Revision: D87843977 fbshipit-source-id: fdc8a1ecd60b46ab399150f3b38d7ef2ec83a7bf
1 parent e581fa4 commit dd390db

19 files changed

Lines changed: 6879 additions & 1616 deletions

packages/react-native-codegen/src/generators/components/__test_fixtures__/fixtures.js

Lines changed: 1292 additions & 408 deletions
Large diffs are not rendered by default.

packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentDescriptorCpp-test.js.snap

Lines changed: 115 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,34 @@ registry->add(concreteComponentDescriptorProvider<AllPropWithOptionalGenComponen
5656
}
5757
`;
5858
59+
exports[`GenerateComponentDescriptorCpp can generate fixture ALL_PROP_WITH_OPTIONAL_OBJECT_GEN 1`] = `
60+
Map {
61+
"ComponentDescriptors.cpp" => "
62+
/**
63+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
64+
*
65+
* Do not edit this file as changes may cause incorrect behavior and will be lost
66+
* once the code is regenerated.
67+
*
68+
* @generated by codegen project: GenerateComponentDescriptorCpp.js
69+
*/
70+
71+
#include <react/renderer/components/ALL_PROP_WITH_OPTIONAL_OBJECT_GEN/ComponentDescriptors.h>
72+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
73+
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
74+
75+
namespace facebook::react {
76+
77+
void ALL_PROP_WITH_OPTIONAL_OBJECT_GEN_registerComponentDescriptorsFromCodegen(
78+
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry) {
79+
registry->add(concreteComponentDescriptorProvider<AllPropWithOptionalObjectGenComponentDescriptor>());
80+
}
81+
82+
} // namespace facebook::react
83+
",
84+
}
85+
`;
86+
5987
exports[`GenerateComponentDescriptorCpp can generate fixture ARRAY_PROPS 1`] = `
6088
Map {
6189
"ComponentDescriptors.cpp" => "
@@ -132,7 +160,35 @@ namespace facebook::react {
132160
133161
void ARRAY_PROPS_WITH_NESTED_OBJECT_WITH_OPTIONAL_GEN_registerComponentDescriptorsFromCodegen(
134162
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry) {
135-
registry->add(concreteComponentDescriptorProvider<ArrayPropsNativeComponentComponentDescriptor>());
163+
registry->add(concreteComponentDescriptorProvider<ArrayPropsOptionalGenNativeComponentComponentDescriptor>());
164+
}
165+
166+
} // namespace facebook::react
167+
",
168+
}
169+
`;
170+
171+
exports[`GenerateComponentDescriptorCpp can generate fixture ARRAY_PROPS_WITH_NESTED_OBJECT_WITH_OPTIONAL_OBJECT_GEN 1`] = `
172+
Map {
173+
"ComponentDescriptors.cpp" => "
174+
/**
175+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
176+
*
177+
* Do not edit this file as changes may cause incorrect behavior and will be lost
178+
* once the code is regenerated.
179+
*
180+
* @generated by codegen project: GenerateComponentDescriptorCpp.js
181+
*/
182+
183+
#include <react/renderer/components/ARRAY_PROPS_WITH_NESTED_OBJECT_WITH_OPTIONAL_OBJECT_GEN/ComponentDescriptors.h>
184+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
185+
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
186+
187+
namespace facebook::react {
188+
189+
void ARRAY_PROPS_WITH_NESTED_OBJECT_WITH_OPTIONAL_OBJECT_GEN_registerComponentDescriptorsFromCodegen(
190+
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry) {
191+
registry->add(concreteComponentDescriptorProvider<ArrayPropsOptionalObjectGenNativeComponentComponentDescriptor>());
136192
}
137193
138194
} // namespace facebook::react
@@ -160,7 +216,35 @@ namespace facebook::react {
160216
161217
void ARRAY_PROPS_WITH_OPTIONAL_GEN_registerComponentDescriptorsFromCodegen(
162218
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry) {
163-
registry->add(concreteComponentDescriptorProvider<ArrayPropsNativeComponentComponentDescriptor>());
219+
registry->add(concreteComponentDescriptorProvider<ArrayPropsWithOptionalGenNativeComponentComponentDescriptor>());
220+
}
221+
222+
} // namespace facebook::react
223+
",
224+
}
225+
`;
226+
227+
exports[`GenerateComponentDescriptorCpp can generate fixture ARRAY_PROPS_WITH_OPTIONAL_OBJECT_GEN 1`] = `
228+
Map {
229+
"ComponentDescriptors.cpp" => "
230+
/**
231+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
232+
*
233+
* Do not edit this file as changes may cause incorrect behavior and will be lost
234+
* once the code is regenerated.
235+
*
236+
* @generated by codegen project: GenerateComponentDescriptorCpp.js
237+
*/
238+
239+
#include <react/renderer/components/ARRAY_PROPS_WITH_OPTIONAL_OBJECT_GEN/ComponentDescriptors.h>
240+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
241+
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
242+
243+
namespace facebook::react {
244+
245+
void ARRAY_PROPS_WITH_OPTIONAL_OBJECT_GEN_registerComponentDescriptorsFromCodegen(
246+
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry) {
247+
registry->add(concreteComponentDescriptorProvider<ArrayPropsWithOptionalObjectGenNativeComponentComponentDescriptor>());
164248
}
165249
166250
} // namespace facebook::react
@@ -805,7 +889,35 @@ namespace facebook::react {
805889
806890
void OBJECT_PROPS_WITH_OPTIONAL_GEN_registerComponentDescriptorsFromCodegen(
807891
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry) {
808-
registry->add(concreteComponentDescriptorProvider<ObjectPropsComponentDescriptor>());
892+
registry->add(concreteComponentDescriptorProvider<ObjectPropsWithOptionalGenComponentDescriptor>());
893+
}
894+
895+
} // namespace facebook::react
896+
",
897+
}
898+
`;
899+
900+
exports[`GenerateComponentDescriptorCpp can generate fixture OBJECT_PROPS_WITH_OPTIONAL_OBJECT_GEN 1`] = `
901+
Map {
902+
"ComponentDescriptors.cpp" => "
903+
/**
904+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
905+
*
906+
* Do not edit this file as changes may cause incorrect behavior and will be lost
907+
* once the code is regenerated.
908+
*
909+
* @generated by codegen project: GenerateComponentDescriptorCpp.js
910+
*/
911+
912+
#include <react/renderer/components/OBJECT_PROPS_WITH_OPTIONAL_OBJECT_GEN/ComponentDescriptors.h>
913+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
914+
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
915+
916+
namespace facebook::react {
917+
918+
void OBJECT_PROPS_WITH_OPTIONAL_OBJECT_GEN_registerComponentDescriptorsFromCodegen(
919+
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry) {
920+
registry->add(concreteComponentDescriptorProvider<ObjectPropsWithOptionalObjectGenComponentDescriptor>());
809921
}
810922
811923
} // namespace facebook::react

packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentDescriptorH-test.js.snap

Lines changed: 123 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,36 @@ void ALL_PROP_WITH_OPTIONAL_GEN_registerComponentDescriptorsFromCodegen(
6060
}
6161
`;
6262
63+
exports[`GenerateComponentDescriptorH can generate fixture ALL_PROP_WITH_OPTIONAL_OBJECT_GEN 1`] = `
64+
Map {
65+
"ComponentDescriptors.h" => "
66+
/**
67+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
68+
*
69+
* Do not edit this file as changes may cause incorrect behavior and will be lost
70+
* once the code is regenerated.
71+
*
72+
* @generated by codegen project: GenerateComponentDescriptorH.js
73+
*/
74+
75+
#pragma once
76+
77+
#include <react/renderer/components/ALL_PROP_WITH_OPTIONAL_OBJECT_GEN/ShadowNodes.h>
78+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
79+
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
80+
81+
namespace facebook::react {
82+
83+
using AllPropWithOptionalObjectGenComponentDescriptor = ConcreteComponentDescriptor<AllPropWithOptionalObjectGenShadowNode>;
84+
85+
void ALL_PROP_WITH_OPTIONAL_OBJECT_GEN_registerComponentDescriptorsFromCodegen(
86+
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry);
87+
88+
} // namespace facebook::react
89+
",
90+
}
91+
`;
92+
6393
exports[`GenerateComponentDescriptorH can generate fixture ARRAY_PROPS 1`] = `
6494
Map {
6595
"ComponentDescriptors.h" => "
@@ -140,7 +170,7 @@ Map {
140170
141171
namespace facebook::react {
142172
143-
using ArrayPropsNativeComponentComponentDescriptor = ConcreteComponentDescriptor<ArrayPropsNativeComponentShadowNode>;
173+
using ArrayPropsOptionalGenNativeComponentComponentDescriptor = ConcreteComponentDescriptor<ArrayPropsOptionalGenNativeComponentShadowNode>;
144174
145175
void ARRAY_PROPS_WITH_NESTED_OBJECT_WITH_OPTIONAL_GEN_registerComponentDescriptorsFromCodegen(
146176
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry);
@@ -150,6 +180,36 @@ void ARRAY_PROPS_WITH_NESTED_OBJECT_WITH_OPTIONAL_GEN_registerComponentDescripto
150180
}
151181
`;
152182
183+
exports[`GenerateComponentDescriptorH can generate fixture ARRAY_PROPS_WITH_NESTED_OBJECT_WITH_OPTIONAL_OBJECT_GEN 1`] = `
184+
Map {
185+
"ComponentDescriptors.h" => "
186+
/**
187+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
188+
*
189+
* Do not edit this file as changes may cause incorrect behavior and will be lost
190+
* once the code is regenerated.
191+
*
192+
* @generated by codegen project: GenerateComponentDescriptorH.js
193+
*/
194+
195+
#pragma once
196+
197+
#include <react/renderer/components/ARRAY_PROPS_WITH_NESTED_OBJECT_WITH_OPTIONAL_OBJECT_GEN/ShadowNodes.h>
198+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
199+
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
200+
201+
namespace facebook::react {
202+
203+
using ArrayPropsOptionalObjectGenNativeComponentComponentDescriptor = ConcreteComponentDescriptor<ArrayPropsOptionalObjectGenNativeComponentShadowNode>;
204+
205+
void ARRAY_PROPS_WITH_NESTED_OBJECT_WITH_OPTIONAL_OBJECT_GEN_registerComponentDescriptorsFromCodegen(
206+
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry);
207+
208+
} // namespace facebook::react
209+
",
210+
}
211+
`;
212+
153213
exports[`GenerateComponentDescriptorH can generate fixture ARRAY_PROPS_WITH_OPTIONAL_GEN 1`] = `
154214
Map {
155215
"ComponentDescriptors.h" => "
@@ -170,7 +230,7 @@ Map {
170230
171231
namespace facebook::react {
172232
173-
using ArrayPropsNativeComponentComponentDescriptor = ConcreteComponentDescriptor<ArrayPropsNativeComponentShadowNode>;
233+
using ArrayPropsWithOptionalGenNativeComponentComponentDescriptor = ConcreteComponentDescriptor<ArrayPropsWithOptionalGenNativeComponentShadowNode>;
174234
175235
void ARRAY_PROPS_WITH_OPTIONAL_GEN_registerComponentDescriptorsFromCodegen(
176236
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry);
@@ -180,6 +240,36 @@ void ARRAY_PROPS_WITH_OPTIONAL_GEN_registerComponentDescriptorsFromCodegen(
180240
}
181241
`;
182242
243+
exports[`GenerateComponentDescriptorH can generate fixture ARRAY_PROPS_WITH_OPTIONAL_OBJECT_GEN 1`] = `
244+
Map {
245+
"ComponentDescriptors.h" => "
246+
/**
247+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
248+
*
249+
* Do not edit this file as changes may cause incorrect behavior and will be lost
250+
* once the code is regenerated.
251+
*
252+
* @generated by codegen project: GenerateComponentDescriptorH.js
253+
*/
254+
255+
#pragma once
256+
257+
#include <react/renderer/components/ARRAY_PROPS_WITH_OPTIONAL_OBJECT_GEN/ShadowNodes.h>
258+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
259+
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
260+
261+
namespace facebook::react {
262+
263+
using ArrayPropsWithOptionalObjectGenNativeComponentComponentDescriptor = ConcreteComponentDescriptor<ArrayPropsWithOptionalObjectGenNativeComponentShadowNode>;
264+
265+
void ARRAY_PROPS_WITH_OPTIONAL_OBJECT_GEN_registerComponentDescriptorsFromCodegen(
266+
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry);
267+
268+
} // namespace facebook::react
269+
",
270+
}
271+
`;
272+
183273
exports[`GenerateComponentDescriptorH can generate fixture BOOLEAN_PROP 1`] = `
184274
Map {
185275
"ComponentDescriptors.h" => "
@@ -861,7 +951,7 @@ Map {
861951
862952
namespace facebook::react {
863953
864-
using ObjectPropsComponentDescriptor = ConcreteComponentDescriptor<ObjectPropsShadowNode>;
954+
using ObjectPropsWithOptionalGenComponentDescriptor = ConcreteComponentDescriptor<ObjectPropsWithOptionalGenShadowNode>;
865955
866956
void OBJECT_PROPS_WITH_OPTIONAL_GEN_registerComponentDescriptorsFromCodegen(
867957
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry);
@@ -871,6 +961,36 @@ void OBJECT_PROPS_WITH_OPTIONAL_GEN_registerComponentDescriptorsFromCodegen(
871961
}
872962
`;
873963
964+
exports[`GenerateComponentDescriptorH can generate fixture OBJECT_PROPS_WITH_OPTIONAL_OBJECT_GEN 1`] = `
965+
Map {
966+
"ComponentDescriptors.h" => "
967+
/**
968+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
969+
*
970+
* Do not edit this file as changes may cause incorrect behavior and will be lost
971+
* once the code is regenerated.
972+
*
973+
* @generated by codegen project: GenerateComponentDescriptorH.js
974+
*/
975+
976+
#pragma once
977+
978+
#include <react/renderer/components/OBJECT_PROPS_WITH_OPTIONAL_OBJECT_GEN/ShadowNodes.h>
979+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
980+
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
981+
982+
namespace facebook::react {
983+
984+
using ObjectPropsWithOptionalObjectGenComponentDescriptor = ConcreteComponentDescriptor<ObjectPropsWithOptionalObjectGenShadowNode>;
985+
986+
void OBJECT_PROPS_WITH_OPTIONAL_OBJECT_GEN_registerComponentDescriptorsFromCodegen(
987+
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry);
988+
989+
} // namespace facebook::react
990+
",
991+
}
992+
`;
993+
874994
exports[`GenerateComponentDescriptorH can generate fixture POINT_PROP 1`] = `
875995
Map {
876996
"ComponentDescriptors.h" => "

0 commit comments

Comments
 (0)