From 175b1ea636a48803428a6937446cee861e56e2f3 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Wed, 28 Jul 2021 20:16:53 -0700 Subject: [PATCH] Pass PropsParserContext to prop parsing layer Summary: Changelog: [internal] Reviewed By: mdvacca Differential Revision: D29921232 fbshipit-source-id: ba045f545b564aedf1b287045a0e75428de30a0f --- .../Mounting/RCTComponentViewFactory.mm | 1 + React/Fabric/Mounting/RCTMountingManager.h | 3 + React/Fabric/Mounting/RCTMountingManager.mm | 9 +- React/Fabric/RCTSurfacePresenter.mm | 2 + .../fabric/jni/CoreComponentsRegistry.cpp | 7 +- .../animations/tests/LayoutAnimationTest.cpp | 9 +- .../ComponentDescriptorProviderRegistry.cpp | 5 +- .../ComponentDescriptorProviderRegistry.h | 3 +- .../LegacyViewManagerInteropViewProps.cpp | 7 +- .../root/tests/RootShadowNodeTest.cpp | 12 +- .../UnimplementedViewComponentDescriptor.cpp | 6 +- .../UnimplementedViewComponentDescriptor.h | 7 +- .../components/view/tests/ViewTest.cpp | 9 +- .../core/tests/ComponentDescriptorTest.cpp | 20 +- .../renderer/core/tests/RawPropsTest.cpp | 65 ++- .../react/renderer/core/tests/TestComponent.h | 8 +- .../renderer/mounting/tests/MountingTest.cpp | 13 +- .../tests/ShadowTreeLifeCycleTest.cpp | 9 +- .../tests/StateReconciliationTest.cpp | 13 +- .../react/test_utils/shadowTreeGeneration.h | 22 +- .../generators/components/GenerateTests.js | 9 +- .../GeneratePropsCpp-test.js.snap | 205 +++++--- .../__snapshots__/GeneratePropsH-test.js.snap | 187 ++++--- .../__snapshots__/GenerateTests-test.js.snap | 466 +++++++++++++----- 24 files changed, 772 insertions(+), 325 deletions(-) diff --git a/React/Fabric/Mounting/RCTComponentViewFactory.mm b/React/Fabric/Mounting/RCTComponentViewFactory.mm index 677a04dbf8c..eef565f17dc 100644 --- a/React/Fabric/Mounting/RCTComponentViewFactory.mm +++ b/React/Fabric/Mounting/RCTComponentViewFactory.mm @@ -17,6 +17,7 @@ #import #import #import +#import #import #ifdef RN_DISABLE_OSS_PLUGIN_HEADER diff --git a/React/Fabric/Mounting/RCTMountingManager.h b/React/Fabric/Mounting/RCTMountingManager.h index 3644f364a04..cf713c1468f 100644 --- a/React/Fabric/Mounting/RCTMountingManager.h +++ b/React/Fabric/Mounting/RCTMountingManager.h @@ -13,6 +13,7 @@ #import #import #import +#import NS_ASSUME_NONNULL_BEGIN @@ -26,6 +27,8 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, weak) id delegate; @property (nonatomic, strong) RCTComponentViewRegistry *componentViewRegistry; +- (void)setContextContainer:(facebook::react::ContextContainer::Shared)contextContainer; + /** * Designates the view as a rendering viewport of a React Native surface. * The provided view must not have any subviews, and the caller is not supposed to interact with the view hierarchy diff --git a/React/Fabric/Mounting/RCTMountingManager.mm b/React/Fabric/Mounting/RCTMountingManager.mm index 40cae827bd0..beb1ed2b660 100644 --- a/React/Fabric/Mounting/RCTMountingManager.mm +++ b/React/Fabric/Mounting/RCTMountingManager.mm @@ -136,6 +136,7 @@ static void RCTPerformMountInstructions( RCTMountingTransactionObserverCoordinator _observerCoordinator; BOOL _transactionInFlight; BOOL _followUpTransactionRequired; + ContextContainer::Shared _contextContainer; } - (instancetype)init @@ -147,6 +148,11 @@ static void RCTPerformMountInstructions( return self; } +- (void)setContextContainer:(ContextContainer::Shared)contextContainer +{ + _contextContainer = contextContainer; +} + - (void)attachSurfaceToView:(UIView *)view surfaceId:(SurfaceId)surfaceId { RCTAssertMainQueue(); @@ -277,7 +283,8 @@ static void RCTPerformMountInstructions( RCTAssertMainQueue(); UIView *componentView = [_componentViewRegistry findComponentViewWithTag:reactTag]; SharedProps oldProps = [componentView props]; - SharedProps newProps = componentDescriptor.cloneProps(oldProps, RawProps(convertIdToFollyDynamic(props))); + SharedProps newProps = componentDescriptor.cloneProps( + PropsParserContext{-1, *_contextContainer.get()}, oldProps, RawProps(convertIdToFollyDynamic(props))); NSSet *propKeys = componentView.propKeysManagedByAnimated_DO_NOT_USE_THIS_IS_BROKEN ?: [NSSet new]; propKeys = [propKeys setByAddingObjectsFromArray:props.allKeys]; diff --git a/React/Fabric/RCTSurfacePresenter.mm b/React/Fabric/RCTSurfacePresenter.mm index 97662d95cb2..e3deefef3d2 100644 --- a/React/Fabric/RCTSurfacePresenter.mm +++ b/React/Fabric/RCTSurfacePresenter.mm @@ -96,6 +96,7 @@ static BackgroundExecutor RCTGetBackgroundExecutor() _surfaceRegistry = [[RCTSurfaceRegistry alloc] init]; _mountingManager = [[RCTMountingManager alloc] init]; + _mountingManager.contextContainer = contextContainer; _mountingManager.delegate = self; _observers = [NSMutableArray array]; @@ -127,6 +128,7 @@ static BackgroundExecutor RCTGetBackgroundExecutor() { std::lock_guard lock(_schedulerLifeCycleMutex); _contextContainer = contextContainer; + _mountingManager.contextContainer = contextContainer; } - (RuntimeExecutor)runtimeExecutor diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/CoreComponentsRegistry.cpp b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/CoreComponentsRegistry.cpp index 477c819b58b..f92c84d625c 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/CoreComponentsRegistry.cpp +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/CoreComponentsRegistry.cpp @@ -87,10 +87,9 @@ CoreComponentsRegistry::initHybrid( [](EventDispatcher::Weak const &eventDispatcher, ContextContainer::Shared const &contextContainer) -> ComponentDescriptorRegistry::Shared { - auto registry = - CoreComponentsRegistry::sharedProviderRegistry() - ->createComponentDescriptorRegistry( - {eventDispatcher, contextContainer}, contextContainer); + auto registry = CoreComponentsRegistry::sharedProviderRegistry() + ->createComponentDescriptorRegistry( + {eventDispatcher, contextContainer}); auto mutableRegistry = std::const_pointer_cast(registry); mutableRegistry->setFallbackComponentDescriptor( diff --git a/ReactCommon/react/renderer/animations/tests/LayoutAnimationTest.cpp b/ReactCommon/react/renderer/animations/tests/LayoutAnimationTest.cpp index 5529ec9eec8..52e07d9d87d 100644 --- a/ReactCommon/react/renderer/animations/tests/LayoutAnimationTest.cpp +++ b/ReactCommon/react/renderer/animations/tests/LayoutAnimationTest.cpp @@ -10,17 +10,17 @@ #include #include +#include #include #include #include - -#include #include #include +#include #include #include -#include +#include #include #include #include @@ -61,6 +61,8 @@ static void testShadowNodeTreeLifeCycleLayoutAnimations( auto noopEventEmitter = std::make_shared(nullptr, -1, eventDispatcher); + PropsParserContext parserContext{-1, *contextContainer}; + // Create a RuntimeExecutor RuntimeExecutor runtimeExecutor = [](std::function fn) {}; @@ -106,6 +108,7 @@ static void testShadowNodeTreeLifeCycleLayoutAnimations( // Applying size constraints. emptyRootNode = emptyRootNode->clone( + parserContext, LayoutConstraints{ Size{512, 0}, Size{512, std::numeric_limits::infinity()}}, LayoutContext{}); diff --git a/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.cpp b/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.cpp index 3ffb39e493a..609316369d3 100644 --- a/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.cpp +++ b/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.cpp @@ -65,12 +65,11 @@ void ComponentDescriptorProviderRegistry::request( ComponentDescriptorRegistry::Shared ComponentDescriptorProviderRegistry::createComponentDescriptorRegistry( - ComponentDescriptorParameters const ¶meters, - ContextContainer::Shared contextContainer) const { + ComponentDescriptorParameters const ¶meters) const { std::shared_lock lock(mutex_); auto registry = std::make_shared( - parameters, *this, contextContainer); + parameters, *this, parameters.contextContainer); for (auto const &pair : componentDescriptorProviders_) { registry->add(pair.second); diff --git a/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h b/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h index 25c3ed8c5cf..c4d1982b0b0 100644 --- a/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h +++ b/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h @@ -52,8 +52,7 @@ class ComponentDescriptorProviderRegistry final { * The methods can be called on any thread. */ ComponentDescriptorRegistry::Shared createComponentDescriptorRegistry( - ComponentDescriptorParameters const ¶meters, - ContextContainer::Shared contextContainer) const; + ComponentDescriptorParameters const ¶meters) const; private: friend class ComponentDescriptorRegistry; diff --git a/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropViewProps.cpp b/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropViewProps.cpp index 059384e82c0..4676a2c01e1 100644 --- a/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropViewProps.cpp +++ b/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropViewProps.cpp @@ -16,10 +16,9 @@ LegacyViewManagerInteropViewProps::LegacyViewManagerInteropViewProps( const LegacyViewManagerInteropViewProps &sourceProps, const RawProps &rawProps) : ViewProps(context, sourceProps, rawProps), - otherProps(mergeDynamicProps( - context, - sourceProps.otherProps, - (folly::dynamic)rawProps)) {} + otherProps( + mergeDynamicProps(sourceProps.otherProps, (folly::dynamic)rawProps)) { +} } // namespace react } // namespace facebook diff --git a/ReactCommon/react/renderer/components/root/tests/RootShadowNodeTest.cpp b/ReactCommon/react/renderer/components/root/tests/RootShadowNodeTest.cpp index f0553e7b99c..66d67ee817c 100644 --- a/ReactCommon/react/renderer/components/root/tests/RootShadowNodeTest.cpp +++ b/ReactCommon/react/renderer/components/root/tests/RootShadowNodeTest.cpp @@ -6,15 +6,19 @@ */ #include +#include #include -#include -#include #include +#include +#include namespace facebook::react { TEST(RootShadowNodeTest, cloneWithLayoutConstraints) { + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + auto builder = simpleComponentBuilder(); std::shared_ptr rootShadowNode; LayoutConstraints defaultLayoutConstraints = {}; @@ -32,8 +36,8 @@ TEST(RootShadowNodeTest, cloneWithLayoutConstraints) { EXPECT_TRUE(rootShadowNode->layoutIfNeeded()); EXPECT_TRUE(rootShadowNode->getIsLayoutClean()); - auto clonedWithDiffentLayoutConstraints = - rootShadowNode->clone(LayoutConstraints{{0, 0}, {10, 10}}, {}); + auto clonedWithDiffentLayoutConstraints = rootShadowNode->clone( + parserContext, LayoutConstraints{{0, 0}, {10, 10}}, {}); EXPECT_FALSE(clonedWithDiffentLayoutConstraints->getIsLayoutClean()); EXPECT_TRUE(clonedWithDiffentLayoutConstraints->layoutIfNeeded()); diff --git a/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewComponentDescriptor.cpp b/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewComponentDescriptor.cpp index 56e5d2a6fa1..375a95c5d94 100644 --- a/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewComponentDescriptor.cpp +++ b/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewComponentDescriptor.cpp @@ -22,19 +22,21 @@ ComponentName UnimplementedViewComponentDescriptor::getComponentName() const { } Props::Shared UnimplementedViewComponentDescriptor::cloneProps( + PropsParserContext const &context, Props::Shared const &props, RawProps const &rawProps) const { auto clonedProps = ConcreteComponentDescriptor::cloneProps( - props, rawProps); + context, props, rawProps); react_native_assert( std::dynamic_pointer_cast(clonedProps)); // We have to clone `Props` object one more time to make sure that we have // an unshared (and non-`const`) copy of it which we can mutate. RawProps emptyRawProps{}; - emptyRawProps.parse(rawPropsParser_); + emptyRawProps.parse(rawPropsParser_, context); auto unimplementedViewProps = std::make_shared( + context, *std::static_pointer_cast(clonedProps), emptyRawProps); diff --git a/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewComponentDescriptor.h b/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewComponentDescriptor.h index b2de61f3b1c..2f5bfca3a95 100644 --- a/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewComponentDescriptor.h +++ b/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewComponentDescriptor.h @@ -9,6 +9,7 @@ #include #include +#include namespace facebook { namespace react { @@ -32,8 +33,10 @@ class UnimplementedViewComponentDescriptor final * In addtion to base implementation, stores a component name inside cloned * `Props` object. */ - Props::Shared cloneProps(Props::Shared const &props, RawProps const &rawProps) - const override; + Props::Shared cloneProps( + PropsParserContext const &context, + Props::Shared const &props, + RawProps const &rawProps) const override; }; } // namespace react diff --git a/ReactCommon/react/renderer/components/view/tests/ViewTest.cpp b/ReactCommon/react/renderer/components/view/tests/ViewTest.cpp index ab2d603ac99..8da0ed46ea6 100644 --- a/ReactCommon/react/renderer/components/view/tests/ViewTest.cpp +++ b/ReactCommon/react/renderer/components/view/tests/ViewTest.cpp @@ -14,7 +14,9 @@ #include #include #include +#include #include + #include #include @@ -85,14 +87,17 @@ class YogaDirtyFlagTest : public ::testing::Test { }; TEST_F(YogaDirtyFlagTest, cloningPropsWithoutChangingThem) { + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + /* * Cloning props without changing them must *not* dirty a Yoga node. */ auto newRootShadowNode = rootShadowNode_->cloneTree( - innerShadowNode_->getFamily(), [](ShadowNode const &oldShadowNode) { + innerShadowNode_->getFamily(), [&](ShadowNode const &oldShadowNode) { auto &componentDescriptor = oldShadowNode.getComponentDescriptor(); auto props = componentDescriptor.cloneProps( - oldShadowNode.getProps(), RawProps()); + parserContext, oldShadowNode.getProps(), RawProps()); return oldShadowNode.clone(ShadowNodeFragment{props}); }); diff --git a/ReactCommon/react/renderer/core/tests/ComponentDescriptorTest.cpp b/ReactCommon/react/renderer/core/tests/ComponentDescriptorTest.cpp index 58baadffb32..35a12911b25 100644 --- a/ReactCommon/react/renderer/core/tests/ComponentDescriptorTest.cpp +++ b/ReactCommon/react/renderer/core/tests/ComponentDescriptorTest.cpp @@ -7,6 +7,8 @@ #include +#include + #include "TestComponent.h" using namespace facebook::react; @@ -21,8 +23,11 @@ TEST(ComponentDescriptorTest, createShadowNode) { EXPECT_STREQ(descriptor->getComponentName(), TestShadowNode::Name()); EXPECT_STREQ(descriptor->getComponentName(), "Test"); + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + const auto &raw = RawProps(folly::dynamic::object("nativeID", "abc")); - SharedProps props = descriptor->cloneProps(nullptr, raw); + SharedProps props = descriptor->cloneProps(parserContext, nullptr, raw); auto family = descriptor->createFamily( ShadowNodeFamilyFragment{ @@ -52,8 +57,11 @@ TEST(ComponentDescriptorTest, cloneShadowNode) { std::make_shared( ComponentDescriptorParameters{eventDispatcher, nullptr, nullptr}); + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + const auto &raw = RawProps(folly::dynamic::object("nativeID", "abc")); - SharedProps props = descriptor->cloneProps(nullptr, raw); + SharedProps props = descriptor->cloneProps(parserContext, nullptr, raw); auto family = descriptor->createFamily( ShadowNodeFamilyFragment{ /* .tag = */ 9, @@ -73,7 +81,8 @@ TEST(ComponentDescriptorTest, cloneShadowNode) { EXPECT_EQ(cloned->getSurfaceId(), 1); EXPECT_STREQ(cloned->getProps()->nativeId.c_str(), "abc"); - auto clonedButSameProps = descriptor->cloneProps(props, RawProps()); + auto clonedButSameProps = + descriptor->cloneProps(parserContext, props, RawProps()); EXPECT_NE(clonedButSameProps, props); } @@ -83,8 +92,11 @@ TEST(ComponentDescriptorTest, appendChild) { std::make_shared( ComponentDescriptorParameters{eventDispatcher, nullptr, nullptr}); + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + const auto &raw = RawProps(folly::dynamic::object("nativeID", "abc")); - SharedProps props = descriptor->cloneProps(nullptr, raw); + SharedProps props = descriptor->cloneProps(parserContext, nullptr, raw); auto family1 = descriptor->createFamily( ShadowNodeFamilyFragment{ /* .tag = */ 1, diff --git a/ReactCommon/react/renderer/core/tests/RawPropsTest.cpp b/ReactCommon/react/renderer/core/tests/RawPropsTest.cpp index de5b1b2bcf7..e54b623c998 100644 --- a/ReactCommon/react/renderer/core/tests/RawPropsTest.cpp +++ b/ReactCommon/react/renderer/core/tests/RawPropsTest.cpp @@ -148,12 +148,15 @@ class PropsMultiLookup : public Props { }; TEST(RawPropsTest, handleProps) { + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + const auto &raw = RawProps(folly::dynamic::object("nativeID", "abc")); auto parser = RawPropsParser(); parser.prepare(); - raw.parse(parser, {}); + raw.parse(parser, parserContext); - auto props = std::make_shared(Props(), raw); + auto props = std::make_shared(parserContext, Props(), raw); // Props are not sealed after applying raw props. EXPECT_FALSE(props->getSealed()); @@ -162,10 +165,13 @@ TEST(RawPropsTest, handleProps) { } TEST(RawPropsTest, handleRawPropsSingleString) { + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + const auto &raw = RawProps(folly::dynamic::object("nativeID", "abc")); auto parser = RawPropsParser(); parser.prepare(); - raw.parse(parser, {}); + raw.parse(parser, parserContext); std::string value = (std::string)*raw.at("nativeID", nullptr, nullptr); @@ -173,11 +179,14 @@ TEST(RawPropsTest, handleRawPropsSingleString) { } TEST(RawPropsTest, handleRawPropsSingleFloat) { + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + const auto &raw = RawProps(folly::dynamic::object("floatValue", (float)42.42)); auto parser = RawPropsParser(); parser.prepare(); - raw.parse(parser, {}); + raw.parse(parser, parserContext); float value = (float)*raw.at("floatValue", nullptr, nullptr); @@ -185,11 +194,14 @@ TEST(RawPropsTest, handleRawPropsSingleFloat) { } TEST(RawPropsTest, handleRawPropsSingleDouble) { + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + const auto &raw = RawProps(folly::dynamic::object("doubleValue", (double)42.42)); auto parser = RawPropsParser(); parser.prepare(); - raw.parse(parser, {}); + raw.parse(parser, parserContext); double value = (double)*raw.at("doubleValue", nullptr, nullptr); @@ -197,10 +209,13 @@ TEST(RawPropsTest, handleRawPropsSingleDouble) { } TEST(RawPropsTest, handleRawPropsSingleInt) { + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + const auto &raw = RawProps(folly::dynamic::object("intValue", (int)42.42)); auto parser = RawPropsParser(); parser.prepare(); - raw.parse(parser, {}); + raw.parse(parser, parserContext); int value = (int)*raw.at("intValue", nullptr, nullptr); @@ -208,10 +223,13 @@ TEST(RawPropsTest, handleRawPropsSingleInt) { } TEST(RawPropsTest, handleRawPropsSingleIntGetManyTimes) { + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + const auto &raw = RawProps(folly::dynamic::object("intValue", (int)42.42)); auto parser = RawPropsParser(); parser.prepare(); - raw.parse(parser, {}); + raw.parse(parser, parserContext); EXPECT_EQ((int)*raw.at("intValue", nullptr, nullptr), 42); EXPECT_EQ((int)*raw.at("intValue", nullptr, nullptr), 42); @@ -219,6 +237,9 @@ TEST(RawPropsTest, handleRawPropsSingleIntGetManyTimes) { } TEST(RawPropsTest, handleRawPropsPrimitiveTypes) { + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + const auto &raw = RawProps( folly::dynamic::object("intValue", (int)42)("doubleValue", (double)17.42)( "floatValue", @@ -226,7 +247,7 @@ TEST(RawPropsTest, handleRawPropsPrimitiveTypes) { auto parser = RawPropsParser(); parser.prepare(); - raw.parse(parser, {}); + raw.parse(parser, parserContext); EXPECT_EQ((int)*raw.at("intValue", nullptr, nullptr), 42); EXPECT_NEAR((double)*raw.at("doubleValue", nullptr, nullptr), 17.42, 0.0001); @@ -238,6 +259,9 @@ TEST(RawPropsTest, handleRawPropsPrimitiveTypes) { } TEST(RawPropsTest, handleRawPropsPrimitiveTypesGetTwice) { + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + const auto &raw = RawProps( folly::dynamic::object("intValue", (int)42)("doubleValue", (double)17.42)( "floatValue", @@ -245,7 +269,7 @@ TEST(RawPropsTest, handleRawPropsPrimitiveTypesGetTwice) { auto parser = RawPropsParser(); parser.prepare(); - raw.parse(parser, {}); + raw.parse(parser, parserContext); EXPECT_EQ((int)*raw.at("intValue", nullptr, nullptr), 42); EXPECT_NEAR((double)*raw.at("doubleValue", nullptr, nullptr), 17.42, 0.0001); @@ -265,6 +289,9 @@ TEST(RawPropsTest, handleRawPropsPrimitiveTypesGetTwice) { } TEST(RawPropsTest, handleRawPropsPrimitiveTypesGetOutOfOrder) { + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + const auto &raw = RawProps( folly::dynamic::object("intValue", (int)42)("doubleValue", (double)17.42)( "floatValue", @@ -272,7 +299,7 @@ TEST(RawPropsTest, handleRawPropsPrimitiveTypesGetOutOfOrder) { auto parser = RawPropsParser(); parser.prepare(); - raw.parse(parser, {}); + raw.parse(parser, parserContext); EXPECT_EQ((int)*raw.at("intValue", nullptr, nullptr), 42); EXPECT_NEAR((double)*raw.at("doubleValue", nullptr, nullptr), 17.42, 0.0001); @@ -292,11 +319,14 @@ TEST(RawPropsTest, handleRawPropsPrimitiveTypesGetOutOfOrder) { } TEST(RawPropsTest, handleRawPropsPrimitiveTypesIncomplete) { + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + const auto &raw = RawProps(folly::dynamic::object("intValue", (int)42)); auto parser = RawPropsParser(); parser.prepare(); - raw.parse(parser, {}); + raw.parse(parser, parserContext); EXPECT_EQ((int)*raw.at("intValue", nullptr, nullptr), 42); EXPECT_EQ(raw.at("doubleValue", nullptr, nullptr), nullptr); @@ -309,11 +339,14 @@ TEST(RawPropsTest, handleRawPropsPrimitiveTypesIncomplete) { #ifdef REACT_NATIVE_DEBUG TEST(RawPropsTest, handleRawPropsPrimitiveTypesIncorrectLookup) { + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + const auto &raw = RawProps(folly::dynamic::object("intValue", (int)42)); auto parser = RawPropsParser(); parser.prepare(); - raw.parse(parser, {}); + raw.parse(parser, parserContext); // Before D18662135, looking up an invalid key would trigger // an infinite loop. This is out of contract, so we should only @@ -324,12 +357,16 @@ TEST(RawPropsTest, handleRawPropsPrimitiveTypesIncorrectLookup) { #endif TEST(RawPropsTest, handlePropsMultiLookup) { + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + const auto &raw = RawProps(folly::dynamic::object("floatValue", (float)10.0)); auto parser = RawPropsParser(); parser.prepare(); - raw.parse(parser, {}); + raw.parse(parser, parserContext); - auto props = std::make_shared(PropsMultiLookup(), raw); + auto props = std::make_shared( + parserContext, PropsMultiLookup(), raw); // Props are not sealed after applying raw props. EXPECT_FALSE(props->getSealed()); diff --git a/ReactCommon/react/renderer/core/tests/TestComponent.h b/ReactCommon/react/renderer/core/tests/TestComponent.h index c93a5e58ffd..a396f1ba621 100644 --- a/ReactCommon/react/renderer/core/tests/TestComponent.h +++ b/ReactCommon/react/renderer/core/tests/TestComponent.h @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -35,8 +36,11 @@ class TestProps : public ViewProps { public: TestProps() = default; - TestProps(const TestProps &sourceProps, const RawProps &rawProps) - : ViewProps(sourceProps, rawProps) {} + TestProps( + const PropsParserContext &context, + const TestProps &sourceProps, + const RawProps &rawProps) + : ViewProps(context, sourceProps, rawProps) {} }; using SharedTestProps = std::shared_ptr; diff --git a/ReactCommon/react/renderer/mounting/tests/MountingTest.cpp b/ReactCommon/react/renderer/mounting/tests/MountingTest.cpp index bd90f794d81..8ad2395bef7 100644 --- a/ReactCommon/react/renderer/mounting/tests/MountingTest.cpp +++ b/ReactCommon/react/renderer/mounting/tests/MountingTest.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -31,8 +32,12 @@ static SharedViewProps nonFlattenedDefaultProps( dynamic["nativeId"] = "NativeId"; dynamic["accessible"] = true; + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + return std::static_pointer_cast( - componentDescriptor.cloneProps(nullptr, RawProps{dynamic})); + componentDescriptor.cloneProps( + parserContext, nullptr, RawProps{dynamic})); } static ShadowNode::Shared makeNode( @@ -78,8 +83,11 @@ TEST(MountingTest, testReorderingInstructionGeneration) { ShadowNodeFragment{RootShadowNode::defaultSharedProps()}, rootFamily))); + PropsParserContext parserContext{-1, *contextContainer}; + // Applying size constraints. emptyRootNode = emptyRootNode->clone( + parserContext, LayoutConstraints{ Size{512, 0}, Size{512, std::numeric_limits::infinity()}}, LayoutContext{}); @@ -383,8 +391,11 @@ TEST(MountingTest, testViewReparentingInstructionGeneration) { ShadowNodeFragment{RootShadowNode::defaultSharedProps()}, rootFamily))); + PropsParserContext parserContext{-1, *contextContainer}; + // Applying size constraints. emptyRootNode = emptyRootNode->clone( + parserContext, LayoutConstraints{ Size{512, 0}, Size{512, std::numeric_limits::infinity()}}, LayoutContext{}); diff --git a/ReactCommon/react/renderer/mounting/tests/ShadowTreeLifeCycleTest.cpp b/ReactCommon/react/renderer/mounting/tests/ShadowTreeLifeCycleTest.cpp index f0ed62cfa2c..da9806e58dc 100644 --- a/ReactCommon/react/renderer/mounting/tests/ShadowTreeLifeCycleTest.cpp +++ b/ReactCommon/react/renderer/mounting/tests/ShadowTreeLifeCycleTest.cpp @@ -12,10 +12,11 @@ #include #include +#include #include #include -#include +#include #include #include @@ -44,6 +45,8 @@ static void testShadowNodeTreeLifeCycle( auto noopEventEmitter = std::make_shared(nullptr, -1, eventDispatcher); + PropsParserContext parserContext{-1, *contextContainer}; + auto allNodes = std::vector{}; for (int i = 0; i < repeats; i++) { @@ -61,6 +64,7 @@ static void testShadowNodeTreeLifeCycle( // Applying size constraints. emptyRootNode = emptyRootNode->clone( + parserContext, LayoutConstraints{ Size{512, 0}, Size{512, std::numeric_limits::infinity()}}, LayoutContext{}); @@ -191,6 +195,8 @@ static void testShadowNodeTreeLifeCycleExtensiveFlatteningUnflattening( auto noopEventEmitter = std::make_shared(nullptr, -1, eventDispatcher); + PropsParserContext parserContext{-1, *contextContainer}; + auto allNodes = std::vector{}; for (int i = 0; i < repeats; i++) { @@ -208,6 +214,7 @@ static void testShadowNodeTreeLifeCycleExtensiveFlatteningUnflattening( // Applying size constraints. emptyRootNode = emptyRootNode->clone( + parserContext, LayoutConstraints{ Size{512, 0}, Size{512, std::numeric_limits::infinity()}}, LayoutContext{}); diff --git a/ReactCommon/react/renderer/mounting/tests/StateReconciliationTest.cpp b/ReactCommon/react/renderer/mounting/tests/StateReconciliationTest.cpp index c8f80e5b0fb..b88ec2c33f7 100644 --- a/ReactCommon/react/renderer/mounting/tests/StateReconciliationTest.cpp +++ b/ReactCommon/react/renderer/mounting/tests/StateReconciliationTest.cpp @@ -11,14 +11,15 @@ #include #include +#include #include #include -#include - #include #include #include +#include + using namespace facebook::react; class DummyShadowTreeDelegate : public ShadowTreeDelegate { @@ -89,6 +90,8 @@ TEST(StateReconciliationTest, testStateReconciliation) { }); // clang-format on + ContextContainer contextContainer{}; + auto shadowNode = builder.build(element); auto rootShadowNodeState1 = shadowNode->ShadowNode::clone({}); @@ -98,7 +101,11 @@ TEST(StateReconciliationTest, testStateReconciliation) { auto state1 = shadowNodeAB->getState(); auto shadowTreeDelegate = DummyShadowTreeDelegate{}; ShadowTree shadowTree{ - SurfaceId{11}, LayoutConstraints{}, LayoutContext{}, shadowTreeDelegate}; + SurfaceId{11}, + LayoutConstraints{}, + LayoutContext{}, + shadowTreeDelegate, + contextContainer}; shadowTree.commit( [&](RootShadowNode const &oldRootShadowNode) { diff --git a/ReactCommon/react/test_utils/shadowTreeGeneration.h b/ReactCommon/react/test_utils/shadowTreeGeneration.h index bd17f9036aa..f2897cb5e18 100644 --- a/ReactCommon/react/test_utils/shadowTreeGeneration.h +++ b/ReactCommon/react/test_utils/shadowTreeGeneration.h @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -120,8 +121,12 @@ static inline ShadowNode::Unshared messWithLayoutableOnlyFlag( Entropy const &entropy, ShadowNode const &shadowNode) { auto oldProps = shadowNode.getProps(); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + auto newProps = shadowNode.getComponentDescriptor().cloneProps( - oldProps, RawProps(folly::dynamic::object())); + parserContext, oldProps, RawProps(folly::dynamic::object())); auto &viewProps = const_cast(static_cast(*newProps)); @@ -175,9 +180,12 @@ static inline ShadowNode::Unshared messWithLayoutableOnlyFlag( static inline ShadowNode::Unshared messWithNodeFlattenednessFlags( Entropy const &entropy, ShadowNode const &shadowNode) { + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + auto oldProps = shadowNode.getProps(); auto newProps = shadowNode.getComponentDescriptor().cloneProps( - oldProps, RawProps(folly::dynamic::object())); + parserContext, oldProps, RawProps(folly::dynamic::object())); auto &viewProps = const_cast(static_cast(*newProps)); @@ -231,9 +239,12 @@ static inline ShadowNode::Unshared messWithYogaStyles( } } + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + auto oldProps = shadowNode.getProps(); auto newProps = shadowNode.getComponentDescriptor().cloneProps( - oldProps, RawProps(dynamic)); + parserContext, oldProps, RawProps(dynamic)); return shadowNode.clone({newProps}); } @@ -263,8 +274,11 @@ static inline void alterShadowTree( static SharedViewProps generateDefaultProps( ComponentDescriptor const &componentDescriptor) { + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + return std::static_pointer_cast( - componentDescriptor.cloneProps(nullptr, RawProps{})); + componentDescriptor.cloneProps(parserContext, nullptr, RawProps{})); } static inline ShadowNode::Shared generateShadowNodeTree( diff --git a/packages/react-native-codegen/src/generators/components/GenerateTests.js b/packages/react-native-codegen/src/generators/components/GenerateTests.js index bd4fa382c3e..1681fd9922f 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateTests.js +++ b/packages/react-native-codegen/src/generators/components/GenerateTests.js @@ -34,6 +34,7 @@ const fileTemplate = ` * */ #include +#include #include ::_IMPORTS_:: @@ -47,8 +48,12 @@ TEST(::_COMPONENT_NAME_::_::_TEST_NAME_::, etc) { propParser.prepare<::_COMPONENT_NAME_::>(); auto const &sourceProps = ::_COMPONENT_NAME_::(); auto const &rawProps = RawProps(folly::dynamic::object("::_PROP_NAME_::", ::_PROP_VALUE_::)); - rawProps.parse(propParser); - ::_COMPONENT_NAME_::(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + ::_COMPONENT_NAME_::(parserContext, sourceProps, rawProps); } `; 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 3dabcf8bdcb..3e5a5b031f9 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 @@ -14,26 +14,28 @@ Map { #include #include +#include #include namespace facebook { namespace react { ArrayPropsNativeComponentProps::ArrayPropsNativeComponentProps( + const PropsParserContext &context, const ArrayPropsNativeComponentProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps), + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - names(convertRawProp(rawProps, \\"names\\", sourceProps.names, {})), - disableds(convertRawProp(rawProps, \\"disableds\\", sourceProps.disableds, {})), - progress(convertRawProp(rawProps, \\"progress\\", sourceProps.progress, {})), - radii(convertRawProp(rawProps, \\"radii\\", sourceProps.radii, {})), - colors(convertRawProp(rawProps, \\"colors\\", sourceProps.colors, {})), - srcs(convertRawProp(rawProps, \\"srcs\\", sourceProps.srcs, {})), - points(convertRawProp(rawProps, \\"points\\", sourceProps.points, {})), - sizes(convertRawProp(rawProps, \\"sizes\\", sourceProps.sizes, {static_cast(ArrayPropsNativeComponentSizes::Small)})), - object(convertRawProp(rawProps, \\"object\\", sourceProps.object, {})), - array(convertRawProp(rawProps, \\"array\\", sourceProps.array, {})), - arrayOfArrayOfObject(convertRawProp(rawProps, \\"arrayOfArrayOfObject\\", sourceProps.arrayOfArrayOfObject, {})) + names(convertRawProp(context, rawProps, \\"names\\", sourceProps.names, {})), + disableds(convertRawProp(context, rawProps, \\"disableds\\", sourceProps.disableds, {})), + progress(convertRawProp(context, rawProps, \\"progress\\", sourceProps.progress, {})), + radii(convertRawProp(context, rawProps, \\"radii\\", sourceProps.radii, {})), + colors(convertRawProp(context, rawProps, \\"colors\\", sourceProps.colors, {})), + srcs(convertRawProp(context, rawProps, \\"srcs\\", sourceProps.srcs, {})), + points(convertRawProp(context, rawProps, \\"points\\", sourceProps.points, {})), + sizes(convertRawProp(context, rawProps, \\"sizes\\", sourceProps.sizes, {static_cast(ArrayPropsNativeComponentSizes::Small)})), + object(convertRawProp(context, rawProps, \\"object\\", sourceProps.object, {})), + array(convertRawProp(context, rawProps, \\"array\\", sourceProps.array, {})), + arrayOfArrayOfObject(convertRawProp(context, rawProps, \\"arrayOfArrayOfObject\\", sourceProps.arrayOfArrayOfObject, {})) {} } // namespace react @@ -55,16 +57,18 @@ Map { */ #include +#include #include namespace facebook { namespace react { ArrayPropsNativeComponentProps::ArrayPropsNativeComponentProps( + const PropsParserContext &context, const ArrayPropsNativeComponentProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps), + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - nativePrimitives(convertRawProp(rawProps, \\"nativePrimitives\\", sourceProps.nativePrimitives, {})) + nativePrimitives(convertRawProp(context, rawProps, \\"nativePrimitives\\", sourceProps.nativePrimitives, {})) {} } // namespace react @@ -86,16 +90,18 @@ Map { */ #include +#include #include namespace facebook { namespace react { BooleanPropNativeComponentProps::BooleanPropNativeComponentProps( + const PropsParserContext &context, const BooleanPropNativeComponentProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps), + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - disabled(convertRawProp(rawProps, \\"disabled\\", sourceProps.disabled, {false})) + disabled(convertRawProp(context, rawProps, \\"disabled\\", sourceProps.disabled, {false})) {} } // namespace react @@ -117,16 +123,18 @@ Map { */ #include +#include #include namespace facebook { namespace react { ColorPropNativeComponentProps::ColorPropNativeComponentProps( + const PropsParserContext &context, const ColorPropNativeComponentProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps), + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - tintColor(convertRawProp(rawProps, \\"tintColor\\", sourceProps.tintColor, {})) + tintColor(convertRawProp(context, rawProps, \\"tintColor\\", sourceProps.tintColor, {})) {} } // namespace react @@ -148,14 +156,16 @@ Map { */ #include +#include #include namespace facebook { namespace react { CommandNativeComponentProps::CommandNativeComponentProps( + const PropsParserContext &context, const CommandNativeComponentProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps) + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps) {} @@ -179,16 +189,18 @@ Map { */ #include +#include #include namespace facebook { namespace react { CommandNativeComponentProps::CommandNativeComponentProps( + const PropsParserContext &context, const CommandNativeComponentProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps), + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - accessibilityHint(convertRawProp(rawProps, \\"accessibilityHint\\", sourceProps.accessibilityHint, {\\"\\"})) + accessibilityHint(convertRawProp(context, rawProps, \\"accessibilityHint\\", sourceProps.accessibilityHint, {\\"\\"})) {} } // namespace react @@ -210,21 +222,23 @@ Map { */ #include +#include #include namespace facebook { namespace react { DoublePropNativeComponentProps::DoublePropNativeComponentProps( + const PropsParserContext &context, const DoublePropNativeComponentProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps), + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - blurRadius(convertRawProp(rawProps, \\"blurRadius\\", sourceProps.blurRadius, {0.0})), - blurRadius2(convertRawProp(rawProps, \\"blurRadius2\\", sourceProps.blurRadius2, {0.001})), - blurRadius3(convertRawProp(rawProps, \\"blurRadius3\\", sourceProps.blurRadius3, {2.1})), - blurRadius4(convertRawProp(rawProps, \\"blurRadius4\\", sourceProps.blurRadius4, {0.0})), - blurRadius5(convertRawProp(rawProps, \\"blurRadius5\\", sourceProps.blurRadius5, {1.0})), - blurRadius6(convertRawProp(rawProps, \\"blurRadius6\\", sourceProps.blurRadius6, {0.0})) + blurRadius(convertRawProp(context, rawProps, \\"blurRadius\\", sourceProps.blurRadius, {0.0})), + blurRadius2(convertRawProp(context, rawProps, \\"blurRadius2\\", sourceProps.blurRadius2, {0.001})), + blurRadius3(convertRawProp(context, rawProps, \\"blurRadius3\\", sourceProps.blurRadius3, {2.1})), + blurRadius4(convertRawProp(context, rawProps, \\"blurRadius4\\", sourceProps.blurRadius4, {0.0})), + blurRadius5(convertRawProp(context, rawProps, \\"blurRadius5\\", sourceProps.blurRadius5, {1.0})), + blurRadius6(convertRawProp(context, rawProps, \\"blurRadius6\\", sourceProps.blurRadius6, {0.0})) {} } // namespace react @@ -246,16 +260,18 @@ Map { */ #include +#include #include namespace facebook { namespace react { EventsNestedObjectNativeComponentProps::EventsNestedObjectNativeComponentProps( + const PropsParserContext &context, const EventsNestedObjectNativeComponentProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps), + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - disabled(convertRawProp(rawProps, \\"disabled\\", sourceProps.disabled, {false})) + disabled(convertRawProp(context, rawProps, \\"disabled\\", sourceProps.disabled, {false})) {} } // namespace react @@ -277,16 +293,18 @@ Map { */ #include +#include #include namespace facebook { namespace react { EventsNativeComponentProps::EventsNativeComponentProps( + const PropsParserContext &context, const EventsNativeComponentProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps), + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - disabled(convertRawProp(rawProps, \\"disabled\\", sourceProps.disabled, {false})) + disabled(convertRawProp(context, rawProps, \\"disabled\\", sourceProps.disabled, {false})) {} } // namespace react @@ -308,14 +326,16 @@ Map { */ #include +#include #include namespace facebook { namespace react { InterfaceOnlyComponentProps::InterfaceOnlyComponentProps( + const PropsParserContext &context, const InterfaceOnlyComponentProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps) + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps) {} @@ -339,14 +359,16 @@ Map { */ #include +#include #include namespace facebook { namespace react { ExcludedAndroidComponentProps::ExcludedAndroidComponentProps( + const PropsParserContext &context, const ExcludedAndroidComponentProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps) + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps) {} @@ -370,6 +392,7 @@ Map { */ #include +#include #include namespace facebook { @@ -396,21 +419,23 @@ Map { */ #include +#include #include namespace facebook { namespace react { FloatPropNativeComponentProps::FloatPropNativeComponentProps( + const PropsParserContext &context, const FloatPropNativeComponentProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps), + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - blurRadius(convertRawProp(rawProps, \\"blurRadius\\", sourceProps.blurRadius, {0.0})), - blurRadius2(convertRawProp(rawProps, \\"blurRadius2\\", sourceProps.blurRadius2, {0.001})), - blurRadius3(convertRawProp(rawProps, \\"blurRadius3\\", sourceProps.blurRadius3, {2.1})), - blurRadius4(convertRawProp(rawProps, \\"blurRadius4\\", sourceProps.blurRadius4, {0.0})), - blurRadius5(convertRawProp(rawProps, \\"blurRadius5\\", sourceProps.blurRadius5, {1.0})), - blurRadius6(convertRawProp(rawProps, \\"blurRadius6\\", sourceProps.blurRadius6, {0.0})) + blurRadius(convertRawProp(context, rawProps, \\"blurRadius\\", sourceProps.blurRadius, {0.0})), + blurRadius2(convertRawProp(context, rawProps, \\"blurRadius2\\", sourceProps.blurRadius2, {0.001})), + blurRadius3(convertRawProp(context, rawProps, \\"blurRadius3\\", sourceProps.blurRadius3, {2.1})), + blurRadius4(convertRawProp(context, rawProps, \\"blurRadius4\\", sourceProps.blurRadius4, {0.0})), + blurRadius5(convertRawProp(context, rawProps, \\"blurRadius5\\", sourceProps.blurRadius5, {1.0})), + blurRadius6(convertRawProp(context, rawProps, \\"blurRadius6\\", sourceProps.blurRadius6, {0.0})) {} } // namespace react @@ -433,16 +458,18 @@ Map { #include #include +#include #include namespace facebook { namespace react { ImagePropNativeComponentProps::ImagePropNativeComponentProps( + const PropsParserContext &context, const ImagePropNativeComponentProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps), + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - thumbImage(convertRawProp(rawProps, \\"thumbImage\\", sourceProps.thumbImage, {})) + thumbImage(convertRawProp(context, rawProps, \\"thumbImage\\", sourceProps.thumbImage, {})) {} } // namespace react @@ -464,16 +491,18 @@ Map { */ #include +#include #include namespace facebook { namespace react { InsetsPropNativeComponentProps::InsetsPropNativeComponentProps( + const PropsParserContext &context, const InsetsPropNativeComponentProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps), + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - contentInset(convertRawProp(rawProps, \\"contentInset\\", sourceProps.contentInset, {})) + contentInset(convertRawProp(context, rawProps, \\"contentInset\\", sourceProps.contentInset, {})) {} } // namespace react @@ -495,16 +524,18 @@ Map { */ #include +#include #include namespace facebook { namespace react { Int32EnumPropsNativeComponentProps::Int32EnumPropsNativeComponentProps( + const PropsParserContext &context, const Int32EnumPropsNativeComponentProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps), + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - maxInterval(convertRawProp(rawProps, \\"maxInterval\\", sourceProps.maxInterval, {Int32EnumPropsNativeComponentMaxInterval::MaxInterval0})) + maxInterval(convertRawProp(context, rawProps, \\"maxInterval\\", sourceProps.maxInterval, {Int32EnumPropsNativeComponentMaxInterval::MaxInterval0})) {} } // namespace react @@ -526,18 +557,20 @@ Map { */ #include +#include #include namespace facebook { namespace react { IntegerPropNativeComponentProps::IntegerPropNativeComponentProps( + const PropsParserContext &context, const IntegerPropNativeComponentProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps), + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - progress1(convertRawProp(rawProps, \\"progress1\\", sourceProps.progress1, {0})), - progress2(convertRawProp(rawProps, \\"progress2\\", sourceProps.progress2, {-1})), - progress3(convertRawProp(rawProps, \\"progress3\\", sourceProps.progress3, {10})) + progress1(convertRawProp(context, rawProps, \\"progress1\\", sourceProps.progress1, {0})), + progress2(convertRawProp(context, rawProps, \\"progress2\\", sourceProps.progress2, {-1})), + progress3(convertRawProp(context, rawProps, \\"progress3\\", sourceProps.progress3, {10})) {} } // namespace react @@ -559,16 +592,18 @@ Map { */ #include +#include #include namespace facebook { namespace react { InterfaceOnlyComponentProps::InterfaceOnlyComponentProps( + const PropsParserContext &context, const InterfaceOnlyComponentProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps), + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - accessibilityHint(convertRawProp(rawProps, \\"accessibilityHint\\", sourceProps.accessibilityHint, {\\"\\"})) + accessibilityHint(convertRawProp(context, rawProps, \\"accessibilityHint\\", sourceProps.accessibilityHint, {\\"\\"})) {} } // namespace react @@ -591,19 +626,21 @@ Map { #include #include +#include #include namespace facebook { namespace react { ImageColorPropNativeComponentProps::ImageColorPropNativeComponentProps( + const PropsParserContext &context, const ImageColorPropNativeComponentProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps), + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - thumbImage(convertRawProp(rawProps, \\"thumbImage\\", sourceProps.thumbImage, {})), - color(convertRawProp(rawProps, \\"color\\", sourceProps.color, {})), - thumbTintColor(convertRawProp(rawProps, \\"thumbTintColor\\", sourceProps.thumbTintColor, {})), - point(convertRawProp(rawProps, \\"point\\", sourceProps.point, {})) + thumbImage(convertRawProp(context, rawProps, \\"thumbImage\\", sourceProps.thumbImage, {})), + color(convertRawProp(context, rawProps, \\"color\\", sourceProps.color, {})), + thumbTintColor(convertRawProp(context, rawProps, \\"thumbTintColor\\", sourceProps.thumbTintColor, {})), + point(convertRawProp(context, rawProps, \\"point\\", sourceProps.point, {})) {} } // namespace react @@ -625,14 +662,16 @@ Map { */ #include +#include #include namespace facebook { namespace react { NoPropsNoEventsComponentProps::NoPropsNoEventsComponentProps( + const PropsParserContext &context, const NoPropsNoEventsComponentProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps) + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps) {} @@ -657,16 +696,18 @@ Map { #include #include +#include #include namespace facebook { namespace react { ObjectPropsProps::ObjectPropsProps( + const PropsParserContext &context, const ObjectPropsProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps), + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - objectProp(convertRawProp(rawProps, \\"objectProp\\", sourceProps.objectProp, {})) + objectProp(convertRawProp(context, rawProps, \\"objectProp\\", sourceProps.objectProp, {})) {} } // namespace react @@ -688,16 +729,18 @@ Map { */ #include +#include #include namespace facebook { namespace react { PointPropNativeComponentProps::PointPropNativeComponentProps( + const PropsParserContext &context, const PointPropNativeComponentProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps), + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - startPoint(convertRawProp(rawProps, \\"startPoint\\", sourceProps.startPoint, {})) + startPoint(convertRawProp(context, rawProps, \\"startPoint\\", sourceProps.startPoint, {})) {} } // namespace react @@ -719,16 +762,18 @@ Map { */ #include +#include #include namespace facebook { namespace react { StringEnumPropsNativeComponentProps::StringEnumPropsNativeComponentProps( + const PropsParserContext &context, const StringEnumPropsNativeComponentProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps), + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - alignment(convertRawProp(rawProps, \\"alignment\\", sourceProps.alignment, {StringEnumPropsNativeComponentAlignment::Center})) + alignment(convertRawProp(context, rawProps, \\"alignment\\", sourceProps.alignment, {StringEnumPropsNativeComponentAlignment::Center})) {} } // namespace react @@ -750,17 +795,19 @@ Map { */ #include +#include #include namespace facebook { namespace react { StringPropComponentProps::StringPropComponentProps( + const PropsParserContext &context, const StringPropComponentProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps), + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - accessibilityHint(convertRawProp(rawProps, \\"accessibilityHint\\", sourceProps.accessibilityHint, {\\"\\"})), - accessibilityRole(convertRawProp(rawProps, \\"accessibilityRole\\", sourceProps.accessibilityRole, {})) + accessibilityHint(convertRawProp(context, rawProps, \\"accessibilityHint\\", sourceProps.accessibilityHint, {\\"\\"})), + accessibilityRole(convertRawProp(context, rawProps, \\"accessibilityRole\\", sourceProps.accessibilityRole, {})) {} } // namespace react @@ -782,22 +829,25 @@ Map { */ #include +#include #include namespace facebook { namespace react { MultiFile1NativeComponentProps::MultiFile1NativeComponentProps( + const PropsParserContext &context, const MultiFile1NativeComponentProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps), + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - disabled(convertRawProp(rawProps, \\"disabled\\", sourceProps.disabled, {false})) + disabled(convertRawProp(context, rawProps, \\"disabled\\", sourceProps.disabled, {false})) {} MultiFile2NativeComponentProps::MultiFile2NativeComponentProps( + const PropsParserContext &context, const MultiFile2NativeComponentProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps), + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - disabled(convertRawProp(rawProps, \\"disabled\\", sourceProps.disabled, {true})) + disabled(convertRawProp(context, rawProps, \\"disabled\\", sourceProps.disabled, {true})) {} } // namespace react @@ -819,22 +869,25 @@ Map { */ #include +#include #include namespace facebook { namespace react { MultiComponent1NativeComponentProps::MultiComponent1NativeComponentProps( + const PropsParserContext &context, const MultiComponent1NativeComponentProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps), + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - disabled(convertRawProp(rawProps, \\"disabled\\", sourceProps.disabled, {false})) + disabled(convertRawProp(context, rawProps, \\"disabled\\", sourceProps.disabled, {false})) {} MultiComponent2NativeComponentProps::MultiComponent2NativeComponentProps( + const PropsParserContext &context, const MultiComponent2NativeComponentProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps), + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - disabled(convertRawProp(rawProps, \\"disabled\\", sourceProps.disabled, {true})) + disabled(convertRawProp(context, rawProps, \\"disabled\\", sourceProps.disabled, {true})) {} } // namespace react 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 3fed947a715..707ce40d932 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 @@ -15,6 +15,7 @@ Map { #include #include +#include #include #include #include @@ -48,7 +49,7 @@ constexpr void operator|=( lhs = lhs | static_cast(rhs); } -static inline void fromRawValue(const RawValue &value, ArrayPropsNativeComponentSizesMask &result) { +static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ArrayPropsNativeComponentSizesMask &result) { auto items = std::vector{value}; for (const auto &item : items) { if (item == \\"small\\") { @@ -82,12 +83,12 @@ struct ArrayPropsNativeComponentObjectStruct { std::string stringProp; }; -static inline void fromRawValue(const RawValue &value, ArrayPropsNativeComponentObjectStruct &result) { +static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ArrayPropsNativeComponentObjectStruct &result) { auto map = (better::map)value; auto stringProp = map.find(\\"stringProp\\"); if (stringProp != map.end()) { - fromRawValue(stringProp->second, result.stringProp); + fromRawValue(context, stringProp->second, result.stringProp); } } @@ -95,11 +96,11 @@ static inline std::string toString(const ArrayPropsNativeComponentObjectStruct & return \\"[Object ArrayPropsNativeComponentObjectStruct]\\"; } -static inline void fromRawValue(const RawValue &value, std::vector &result) { +static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, std::vector &result) { auto items = (std::vector)value; for (const auto &item : items) { ArrayPropsNativeComponentObjectStruct newItem; - fromRawValue(item, newItem); + fromRawValue(context, item, newItem); result.emplace_back(newItem); } } @@ -109,12 +110,12 @@ struct ArrayPropsNativeComponentArrayObjectStruct { std::string stringProp; }; -static inline void fromRawValue(const RawValue &value, ArrayPropsNativeComponentArrayObjectStruct &result) { +static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ArrayPropsNativeComponentArrayObjectStruct &result) { auto map = (better::map)value; auto stringProp = map.find(\\"stringProp\\"); if (stringProp != map.end()) { - fromRawValue(stringProp->second, result.stringProp); + fromRawValue(context, stringProp->second, result.stringProp); } } @@ -122,11 +123,11 @@ static inline std::string toString(const ArrayPropsNativeComponentArrayObjectStr return \\"[Object ArrayPropsNativeComponentArrayObjectStruct]\\"; } -static inline void fromRawValue(const RawValue &value, std::vector &result) { +static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, std::vector &result) { auto items = (std::vector)value; for (const auto &item : items) { ArrayPropsNativeComponentArrayObjectStruct newItem; - fromRawValue(item, newItem); + fromRawValue(context, item, newItem); result.emplace_back(newItem); } } @@ -136,12 +137,12 @@ struct ArrayPropsNativeComponentArrayStruct { std::vector object; }; -static inline void fromRawValue(const RawValue &value, ArrayPropsNativeComponentArrayStruct &result) { +static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ArrayPropsNativeComponentArrayStruct &result) { auto map = (better::map)value; auto object = map.find(\\"object\\"); if (object != map.end()) { - fromRawValue(object->second, result.object); + fromRawValue(context, object->second, result.object); } } @@ -149,11 +150,11 @@ static inline std::string toString(const ArrayPropsNativeComponentArrayStruct &v return \\"[Object ArrayPropsNativeComponentArrayStruct]\\"; } -static inline void fromRawValue(const RawValue &value, std::vector &result) { +static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, std::vector &result) { auto items = (std::vector)value; for (const auto &item : items) { ArrayPropsNativeComponentArrayStruct newItem; - fromRawValue(item, newItem); + fromRawValue(context, item, newItem); result.emplace_back(newItem); } } @@ -163,12 +164,12 @@ struct ArrayPropsNativeComponentArrayOfArrayOfObjectStruct { std::string stringProp; }; -static inline void fromRawValue(const RawValue &value, ArrayPropsNativeComponentArrayOfArrayOfObjectStruct &result) { +static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ArrayPropsNativeComponentArrayOfArrayOfObjectStruct &result) { auto map = (better::map)value; auto stringProp = map.find(\\"stringProp\\"); if (stringProp != map.end()) { - fromRawValue(stringProp->second, result.stringProp); + fromRawValue(context, stringProp->second, result.stringProp); } } @@ -176,13 +177,13 @@ static inline std::string toString(const ArrayPropsNativeComponentArrayOfArrayOf return \\"[Object ArrayPropsNativeComponentArrayOfArrayOfObjectStruct]\\"; } -static inline void fromRawValue(const RawValue &value, std::vector> &result) { +static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, std::vector> &result) { auto items = (std::vector>)value; for (const std::vector &item : items) { auto nestedArray = std::vector{}; for (const RawValue &nestedItem : item) { ArrayPropsNativeComponentArrayOfArrayOfObjectStruct newItem; - fromRawValue(nestedItem, newItem); + fromRawValue(context, nestedItem, newItem); nestedArray.emplace_back(newItem); } result.emplace_back(nestedArray); @@ -192,7 +193,7 @@ static inline void fromRawValue(const RawValue &value, std::vector #include +#include #include #include #include @@ -244,20 +246,20 @@ struct ArrayPropsNativeComponentNativePrimitivesStruct { std::vector points; }; -static inline void fromRawValue(const RawValue &value, ArrayPropsNativeComponentNativePrimitivesStruct &result) { +static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ArrayPropsNativeComponentNativePrimitivesStruct &result) { auto map = (better::map)value; auto colors = map.find(\\"colors\\"); if (colors != map.end()) { - fromRawValue(colors->second, result.colors); + fromRawValue(context, colors->second, result.colors); } auto srcs = map.find(\\"srcs\\"); if (srcs != map.end()) { - fromRawValue(srcs->second, result.srcs); + fromRawValue(context, srcs->second, result.srcs); } auto points = map.find(\\"points\\"); if (points != map.end()) { - fromRawValue(points->second, result.points); + fromRawValue(context, points->second, result.points); } } @@ -265,11 +267,11 @@ static inline std::string toString(const ArrayPropsNativeComponentNativePrimitiv return \\"[Object ArrayPropsNativeComponentNativePrimitivesStruct]\\"; } -static inline void fromRawValue(const RawValue &value, std::vector &result) { +static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, std::vector &result) { auto items = (std::vector)value; for (const auto &item : items) { ArrayPropsNativeComponentNativePrimitivesStruct newItem; - fromRawValue(item, newItem); + fromRawValue(context, item, newItem); result.emplace_back(newItem); } } @@ -277,7 +279,7 @@ static inline void fromRawValue(const RawValue &value, std::vector +#include namespace facebook { namespace react { @@ -311,7 +314,7 @@ namespace react { class BooleanPropNativeComponentProps final : public ViewProps { public: BooleanPropNativeComponentProps() = default; - BooleanPropNativeComponentProps(const BooleanPropNativeComponentProps &sourceProps, const RawProps &rawProps); + BooleanPropNativeComponentProps(const PropsParserContext& context, const BooleanPropNativeComponentProps &sourceProps, const RawProps &rawProps); #pragma mark - Props @@ -338,6 +341,7 @@ Map { #pragma once #include +#include #include namespace facebook { @@ -346,7 +350,7 @@ namespace react { class ColorPropNativeComponentProps final : public ViewProps { public: ColorPropNativeComponentProps() = default; - ColorPropNativeComponentProps(const ColorPropNativeComponentProps &sourceProps, const RawProps &rawProps); + ColorPropNativeComponentProps(const PropsParserContext& context, const ColorPropNativeComponentProps &sourceProps, const RawProps &rawProps); #pragma mark - Props @@ -373,6 +377,7 @@ Map { #pragma once #include +#include namespace facebook { namespace react { @@ -380,7 +385,7 @@ namespace react { class CommandNativeComponentProps final : public ViewProps { public: CommandNativeComponentProps() = default; - CommandNativeComponentProps(const CommandNativeComponentProps &sourceProps, const RawProps &rawProps); + CommandNativeComponentProps(const PropsParserContext& context, const CommandNativeComponentProps &sourceProps, const RawProps &rawProps); #pragma mark - Props @@ -407,6 +412,7 @@ Map { #pragma once #include +#include namespace facebook { namespace react { @@ -414,7 +420,7 @@ namespace react { class CommandNativeComponentProps final : public ViewProps { public: CommandNativeComponentProps() = default; - CommandNativeComponentProps(const CommandNativeComponentProps &sourceProps, const RawProps &rawProps); + CommandNativeComponentProps(const PropsParserContext& context, const CommandNativeComponentProps &sourceProps, const RawProps &rawProps); #pragma mark - Props @@ -441,6 +447,7 @@ Map { #pragma once #include +#include namespace facebook { namespace react { @@ -448,7 +455,7 @@ namespace react { class DoublePropNativeComponentProps final : public ViewProps { public: DoublePropNativeComponentProps() = default; - DoublePropNativeComponentProps(const DoublePropNativeComponentProps &sourceProps, const RawProps &rawProps); + DoublePropNativeComponentProps(const PropsParserContext& context, const DoublePropNativeComponentProps &sourceProps, const RawProps &rawProps); #pragma mark - Props @@ -480,6 +487,7 @@ Map { #pragma once #include +#include namespace facebook { namespace react { @@ -487,7 +495,7 @@ namespace react { class EventsNestedObjectNativeComponentProps final : public ViewProps { public: EventsNestedObjectNativeComponentProps() = default; - EventsNestedObjectNativeComponentProps(const EventsNestedObjectNativeComponentProps &sourceProps, const RawProps &rawProps); + EventsNestedObjectNativeComponentProps(const PropsParserContext& context, const EventsNestedObjectNativeComponentProps &sourceProps, const RawProps &rawProps); #pragma mark - Props @@ -514,6 +522,7 @@ Map { #pragma once #include +#include namespace facebook { namespace react { @@ -521,7 +530,7 @@ namespace react { class EventsNativeComponentProps final : public ViewProps { public: EventsNativeComponentProps() = default; - EventsNativeComponentProps(const EventsNativeComponentProps &sourceProps, const RawProps &rawProps); + EventsNativeComponentProps(const PropsParserContext& context, const EventsNativeComponentProps &sourceProps, const RawProps &rawProps); #pragma mark - Props @@ -548,6 +557,7 @@ Map { #pragma once #include +#include namespace facebook { namespace react { @@ -555,7 +565,7 @@ namespace react { class InterfaceOnlyComponentProps final : public ViewProps { public: InterfaceOnlyComponentProps() = default; - InterfaceOnlyComponentProps(const InterfaceOnlyComponentProps &sourceProps, const RawProps &rawProps); + InterfaceOnlyComponentProps(const PropsParserContext& context, const InterfaceOnlyComponentProps &sourceProps, const RawProps &rawProps); #pragma mark - Props @@ -582,6 +592,7 @@ Map { #pragma once #include +#include namespace facebook { namespace react { @@ -589,7 +600,7 @@ namespace react { class ExcludedAndroidComponentProps final : public ViewProps { public: ExcludedAndroidComponentProps() = default; - ExcludedAndroidComponentProps(const ExcludedAndroidComponentProps &sourceProps, const RawProps &rawProps); + ExcludedAndroidComponentProps(const PropsParserContext& context, const ExcludedAndroidComponentProps &sourceProps, const RawProps &rawProps); #pragma mark - Props @@ -642,6 +653,7 @@ Map { #pragma once #include +#include namespace facebook { namespace react { @@ -649,7 +661,7 @@ namespace react { class FloatPropNativeComponentProps final : public ViewProps { public: FloatPropNativeComponentProps() = default; - FloatPropNativeComponentProps(const FloatPropNativeComponentProps &sourceProps, const RawProps &rawProps); + FloatPropNativeComponentProps(const PropsParserContext& context, const FloatPropNativeComponentProps &sourceProps, const RawProps &rawProps); #pragma mark - Props @@ -681,6 +693,7 @@ Map { #pragma once #include +#include #include namespace facebook { @@ -689,7 +702,7 @@ namespace react { class ImagePropNativeComponentProps final : public ViewProps { public: ImagePropNativeComponentProps() = default; - ImagePropNativeComponentProps(const ImagePropNativeComponentProps &sourceProps, const RawProps &rawProps); + ImagePropNativeComponentProps(const PropsParserContext& context, const ImagePropNativeComponentProps &sourceProps, const RawProps &rawProps); #pragma mark - Props @@ -716,6 +729,7 @@ Map { #pragma once #include +#include #include namespace facebook { @@ -724,7 +738,7 @@ namespace react { class InsetsPropNativeComponentProps final : public ViewProps { public: InsetsPropNativeComponentProps() = default; - InsetsPropNativeComponentProps(const InsetsPropNativeComponentProps &sourceProps, const RawProps &rawProps); + InsetsPropNativeComponentProps(const PropsParserContext& context, const InsetsPropNativeComponentProps &sourceProps, const RawProps &rawProps); #pragma mark - Props @@ -751,13 +765,14 @@ Map { #pragma once #include +#include namespace facebook { namespace react { enum class Int32EnumPropsNativeComponentMaxInterval { MaxInterval0 = 0, MaxInterval1 = 1, MaxInterval2 = 2 }; -static inline void fromRawValue(const RawValue &value, Int32EnumPropsNativeComponentMaxInterval &result) { +static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, Int32EnumPropsNativeComponentMaxInterval &result) { assert(value.hasType()); auto integerValue = (int)value; switch (integerValue) { @@ -785,7 +800,7 @@ static inline std::string toString(const Int32EnumPropsNativeComponentMaxInterva class Int32EnumPropsNativeComponentProps final : public ViewProps { public: Int32EnumPropsNativeComponentProps() = default; - Int32EnumPropsNativeComponentProps(const Int32EnumPropsNativeComponentProps &sourceProps, const RawProps &rawProps); + Int32EnumPropsNativeComponentProps(const PropsParserContext& context, const Int32EnumPropsNativeComponentProps &sourceProps, const RawProps &rawProps); #pragma mark - Props @@ -812,6 +827,7 @@ Map { #pragma once #include +#include namespace facebook { namespace react { @@ -819,7 +835,7 @@ namespace react { class IntegerPropNativeComponentProps final : public ViewProps { public: IntegerPropNativeComponentProps() = default; - IntegerPropNativeComponentProps(const IntegerPropNativeComponentProps &sourceProps, const RawProps &rawProps); + IntegerPropNativeComponentProps(const PropsParserContext& context, const IntegerPropNativeComponentProps &sourceProps, const RawProps &rawProps); #pragma mark - Props @@ -848,6 +864,7 @@ Map { #pragma once #include +#include namespace facebook { namespace react { @@ -855,7 +872,7 @@ namespace react { class InterfaceOnlyComponentProps final : public ViewProps { public: InterfaceOnlyComponentProps() = default; - InterfaceOnlyComponentProps(const InterfaceOnlyComponentProps &sourceProps, const RawProps &rawProps); + InterfaceOnlyComponentProps(const PropsParserContext& context, const InterfaceOnlyComponentProps &sourceProps, const RawProps &rawProps); #pragma mark - Props @@ -882,6 +899,7 @@ Map { #pragma once #include +#include #include #include #include @@ -892,7 +910,7 @@ namespace react { class ImageColorPropNativeComponentProps final : public ViewProps { public: ImageColorPropNativeComponentProps() = default; - ImageColorPropNativeComponentProps(const ImageColorPropNativeComponentProps &sourceProps, const RawProps &rawProps); + ImageColorPropNativeComponentProps(const PropsParserContext& context, const ImageColorPropNativeComponentProps &sourceProps, const RawProps &rawProps); #pragma mark - Props @@ -922,6 +940,7 @@ Map { #pragma once #include +#include namespace facebook { namespace react { @@ -929,7 +948,7 @@ namespace react { class NoPropsNoEventsComponentProps final : public ViewProps { public: NoPropsNoEventsComponentProps() = default; - NoPropsNoEventsComponentProps(const NoPropsNoEventsComponentProps &sourceProps, const RawProps &rawProps); + NoPropsNoEventsComponentProps(const PropsParserContext& context, const NoPropsNoEventsComponentProps &sourceProps, const RawProps &rawProps); #pragma mark - Props @@ -957,6 +976,7 @@ Map { #include #include +#include #include #include #include @@ -968,7 +988,7 @@ namespace react { enum class ObjectPropsStringEnumProp { Option1 }; -static inline void fromRawValue(const RawValue &value, ObjectPropsStringEnumProp &result) { +static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ObjectPropsStringEnumProp &result) { auto string = (std::string)value; if (string == \\"option1\\") { result = ObjectPropsStringEnumProp::Option1; return; } abort(); @@ -981,7 +1001,7 @@ static inline std::string toString(const ObjectPropsStringEnumProp &value) { } enum class ObjectPropsIntEnumProp { IntEnumProp0 = 0 }; -static inline void fromRawValue(const RawValue &value, ObjectPropsIntEnumProp &result) { +static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ObjectPropsIntEnumProp &result) { assert(value.hasType()); auto integerValue = (int)value; switch (integerValue) { @@ -1001,12 +1021,12 @@ struct ObjectPropsObjectPropObjectArrayPropStruct { std::vector array; }; -static inline void fromRawValue(const RawValue &value, ObjectPropsObjectPropObjectArrayPropStruct &result) { +static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ObjectPropsObjectPropObjectArrayPropStruct &result) { auto map = (better::map)value; auto array = map.find(\\"array\\"); if (array != map.end()) { - fromRawValue(array->second, result.array); + fromRawValue(context, array->second, result.array); } } @@ -1020,20 +1040,20 @@ struct ObjectPropsObjectPropObjectPrimitiveRequiredPropStruct { Point point; }; -static inline void fromRawValue(const RawValue &value, ObjectPropsObjectPropObjectPrimitiveRequiredPropStruct &result) { +static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ObjectPropsObjectPropObjectPrimitiveRequiredPropStruct &result) { auto map = (better::map)value; auto image = map.find(\\"image\\"); if (image != map.end()) { - fromRawValue(image->second, result.image); + fromRawValue(context, image->second, result.image); } auto color = map.find(\\"color\\"); if (color != map.end()) { - fromRawValue(color->second, result.color); + fromRawValue(context, color->second, result.color); } auto point = map.find(\\"point\\"); if (point != map.end()) { - fromRawValue(point->second, result.point); + fromRawValue(context, point->second, result.point); } } @@ -1045,12 +1065,12 @@ struct ObjectPropsObjectPropNestedPropANestedPropBStruct { std::string nestedPropC; }; -static inline void fromRawValue(const RawValue &value, ObjectPropsObjectPropNestedPropANestedPropBStruct &result) { +static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ObjectPropsObjectPropNestedPropANestedPropBStruct &result) { auto map = (better::map)value; auto nestedPropC = map.find(\\"nestedPropC\\"); if (nestedPropC != map.end()) { - fromRawValue(nestedPropC->second, result.nestedPropC); + fromRawValue(context, nestedPropC->second, result.nestedPropC); } } @@ -1062,12 +1082,12 @@ struct ObjectPropsObjectPropNestedPropAStruct { ObjectPropsObjectPropNestedPropANestedPropBStruct nestedPropB; }; -static inline void fromRawValue(const RawValue &value, ObjectPropsObjectPropNestedPropAStruct &result) { +static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ObjectPropsObjectPropNestedPropAStruct &result) { auto map = (better::map)value; auto nestedPropB = map.find(\\"nestedPropB\\"); if (nestedPropB != map.end()) { - fromRawValue(nestedPropB->second, result.nestedPropB); + fromRawValue(context, nestedPropB->second, result.nestedPropB); } } @@ -1079,12 +1099,12 @@ struct ObjectPropsObjectPropNestedArrayAsPropertyArrayPropStruct { std::string stringProp; }; -static inline void fromRawValue(const RawValue &value, ObjectPropsObjectPropNestedArrayAsPropertyArrayPropStruct &result) { +static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ObjectPropsObjectPropNestedArrayAsPropertyArrayPropStruct &result) { auto map = (better::map)value; auto stringProp = map.find(\\"stringProp\\"); if (stringProp != map.end()) { - fromRawValue(stringProp->second, result.stringProp); + fromRawValue(context, stringProp->second, result.stringProp); } } @@ -1092,11 +1112,11 @@ static inline std::string toString(const ObjectPropsObjectPropNestedArrayAsPrope return \\"[Object ObjectPropsObjectPropNestedArrayAsPropertyArrayPropStruct]\\"; } -static inline void fromRawValue(const RawValue &value, std::vector &result) { +static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, std::vector &result) { auto items = (std::vector)value; for (const auto &item : items) { ObjectPropsObjectPropNestedArrayAsPropertyArrayPropStruct newItem; - fromRawValue(item, newItem); + fromRawValue(context, item, newItem); result.emplace_back(newItem); } } @@ -1106,12 +1126,12 @@ struct ObjectPropsObjectPropNestedArrayAsPropertyStruct { std::vector arrayProp; }; -static inline void fromRawValue(const RawValue &value, ObjectPropsObjectPropNestedArrayAsPropertyStruct &result) { +static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ObjectPropsObjectPropNestedArrayAsPropertyStruct &result) { auto map = (better::map)value; auto arrayProp = map.find(\\"arrayProp\\"); if (arrayProp != map.end()) { - fromRawValue(arrayProp->second, result.arrayProp); + fromRawValue(context, arrayProp->second, result.arrayProp); } } @@ -1132,48 +1152,48 @@ struct ObjectPropsObjectPropStruct { ObjectPropsObjectPropNestedArrayAsPropertyStruct nestedArrayAsProperty; }; -static inline void fromRawValue(const RawValue &value, ObjectPropsObjectPropStruct &result) { +static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ObjectPropsObjectPropStruct &result) { auto map = (better::map)value; auto stringProp = map.find(\\"stringProp\\"); if (stringProp != map.end()) { - fromRawValue(stringProp->second, result.stringProp); + fromRawValue(context, stringProp->second, result.stringProp); } auto booleanProp = map.find(\\"booleanProp\\"); if (booleanProp != map.end()) { - fromRawValue(booleanProp->second, result.booleanProp); + fromRawValue(context, booleanProp->second, result.booleanProp); } auto floatProp = map.find(\\"floatProp\\"); if (floatProp != map.end()) { - fromRawValue(floatProp->second, result.floatProp); + fromRawValue(context, floatProp->second, result.floatProp); } auto intProp = map.find(\\"intProp\\"); if (intProp != map.end()) { - fromRawValue(intProp->second, result.intProp); + fromRawValue(context, intProp->second, result.intProp); } auto stringEnumProp = map.find(\\"stringEnumProp\\"); if (stringEnumProp != map.end()) { - fromRawValue(stringEnumProp->second, result.stringEnumProp); + fromRawValue(context, stringEnumProp->second, result.stringEnumProp); } auto intEnumProp = map.find(\\"intEnumProp\\"); if (intEnumProp != map.end()) { - fromRawValue(intEnumProp->second, result.intEnumProp); + fromRawValue(context, intEnumProp->second, result.intEnumProp); } auto objectArrayProp = map.find(\\"objectArrayProp\\"); if (objectArrayProp != map.end()) { - fromRawValue(objectArrayProp->second, result.objectArrayProp); + fromRawValue(context, objectArrayProp->second, result.objectArrayProp); } auto objectPrimitiveRequiredProp = map.find(\\"objectPrimitiveRequiredProp\\"); if (objectPrimitiveRequiredProp != map.end()) { - fromRawValue(objectPrimitiveRequiredProp->second, result.objectPrimitiveRequiredProp); + fromRawValue(context, objectPrimitiveRequiredProp->second, result.objectPrimitiveRequiredProp); } auto nestedPropA = map.find(\\"nestedPropA\\"); if (nestedPropA != map.end()) { - fromRawValue(nestedPropA->second, result.nestedPropA); + fromRawValue(context, nestedPropA->second, result.nestedPropA); } auto nestedArrayAsProperty = map.find(\\"nestedArrayAsProperty\\"); if (nestedArrayAsProperty != map.end()) { - fromRawValue(nestedArrayAsProperty->second, result.nestedArrayAsProperty); + fromRawValue(context, nestedArrayAsProperty->second, result.nestedArrayAsProperty); } } @@ -1183,7 +1203,7 @@ static inline std::string toString(const ObjectPropsObjectPropStruct &value) { class ObjectPropsProps final : public ViewProps { public: ObjectPropsProps() = default; - ObjectPropsProps(const ObjectPropsProps &sourceProps, const RawProps &rawProps); + ObjectPropsProps(const PropsParserContext& context, const ObjectPropsProps &sourceProps, const RawProps &rawProps); #pragma mark - Props @@ -1210,6 +1230,7 @@ Map { #pragma once #include +#include #include namespace facebook { @@ -1218,7 +1239,7 @@ namespace react { class PointPropNativeComponentProps final : public ViewProps { public: PointPropNativeComponentProps() = default; - PointPropNativeComponentProps(const PointPropNativeComponentProps &sourceProps, const RawProps &rawProps); + PointPropNativeComponentProps(const PropsParserContext& context, const PointPropNativeComponentProps &sourceProps, const RawProps &rawProps); #pragma mark - Props @@ -1245,13 +1266,14 @@ Map { #pragma once #include +#include namespace facebook { namespace react { enum class StringEnumPropsNativeComponentAlignment { Top, Center, BottomRight }; -static inline void fromRawValue(const RawValue &value, StringEnumPropsNativeComponentAlignment &result) { +static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, StringEnumPropsNativeComponentAlignment &result) { auto string = (std::string)value; if (string == \\"top\\") { result = StringEnumPropsNativeComponentAlignment::Top; return; } if (string == \\"center\\") { result = StringEnumPropsNativeComponentAlignment::Center; return; } @@ -1270,7 +1292,7 @@ static inline std::string toString(const StringEnumPropsNativeComponentAlignment class StringEnumPropsNativeComponentProps final : public ViewProps { public: StringEnumPropsNativeComponentProps() = default; - StringEnumPropsNativeComponentProps(const StringEnumPropsNativeComponentProps &sourceProps, const RawProps &rawProps); + StringEnumPropsNativeComponentProps(const PropsParserContext& context, const StringEnumPropsNativeComponentProps &sourceProps, const RawProps &rawProps); #pragma mark - Props @@ -1297,6 +1319,7 @@ Map { #pragma once #include +#include namespace facebook { namespace react { @@ -1304,7 +1327,7 @@ namespace react { class StringPropComponentProps final : public ViewProps { public: StringPropComponentProps() = default; - StringPropComponentProps(const StringPropComponentProps &sourceProps, const RawProps &rawProps); + StringPropComponentProps(const PropsParserContext& context, const StringPropComponentProps &sourceProps, const RawProps &rawProps); #pragma mark - Props @@ -1332,6 +1355,7 @@ Map { #pragma once #include +#include namespace facebook { namespace react { @@ -1339,7 +1363,7 @@ namespace react { class MultiFile1NativeComponentProps final : public ViewProps { public: MultiFile1NativeComponentProps() = default; - MultiFile1NativeComponentProps(const MultiFile1NativeComponentProps &sourceProps, const RawProps &rawProps); + MultiFile1NativeComponentProps(const PropsParserContext& context, const MultiFile1NativeComponentProps &sourceProps, const RawProps &rawProps); #pragma mark - Props @@ -1349,7 +1373,7 @@ class MultiFile1NativeComponentProps final : public ViewProps { class MultiFile2NativeComponentProps final : public ViewProps { public: MultiFile2NativeComponentProps() = default; - MultiFile2NativeComponentProps(const MultiFile2NativeComponentProps &sourceProps, const RawProps &rawProps); + MultiFile2NativeComponentProps(const PropsParserContext& context, const MultiFile2NativeComponentProps &sourceProps, const RawProps &rawProps); #pragma mark - Props @@ -1376,6 +1400,7 @@ Map { #pragma once #include +#include namespace facebook { namespace react { @@ -1383,7 +1408,7 @@ namespace react { class MultiComponent1NativeComponentProps final : public ViewProps { public: MultiComponent1NativeComponentProps() = default; - MultiComponent1NativeComponentProps(const MultiComponent1NativeComponentProps &sourceProps, const RawProps &rawProps); + MultiComponent1NativeComponentProps(const PropsParserContext& context, const MultiComponent1NativeComponentProps &sourceProps, const RawProps &rawProps); #pragma mark - Props @@ -1393,7 +1418,7 @@ class MultiComponent1NativeComponentProps final : public ViewProps { class MultiComponent2NativeComponentProps final : public ViewProps { public: MultiComponent2NativeComponentProps() = default; - MultiComponent2NativeComponentProps(const MultiComponent2NativeComponentProps &sourceProps, const RawProps &rawProps); + MultiComponent2NativeComponentProps(const PropsParserContext& context, const MultiComponent2NativeComponentProps &sourceProps, const RawProps &rawProps); #pragma mark - Props 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 c4add04c895..a7981270dcd 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 @@ -12,6 +12,7 @@ Map { * */ #include +#include #include #include #include @@ -25,8 +26,12 @@ TEST(ArrayPropsNativeComponentProps_DoesNotDie, etc) { propParser.prepare(); auto const &sourceProps = ArrayPropsNativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); - rawProps.parse(propParser); - ArrayPropsNativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + ArrayPropsNativeComponentProps(parserContext, sourceProps, rawProps); }", } `; @@ -43,6 +48,7 @@ Map { * */ #include +#include #include #include #include @@ -55,8 +61,12 @@ TEST(ArrayPropsNativeComponentProps_DoesNotDie, etc) { propParser.prepare(); auto const &sourceProps = ArrayPropsNativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); - rawProps.parse(propParser); - ArrayPropsNativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + ArrayPropsNativeComponentProps(parserContext, sourceProps, rawProps); }", } `; @@ -73,6 +83,7 @@ Map { * */ #include +#include #include #include #include @@ -85,8 +96,12 @@ TEST(BooleanPropNativeComponentProps_DoesNotDie, etc) { propParser.prepare(); auto const &sourceProps = BooleanPropNativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); - rawProps.parse(propParser); - BooleanPropNativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + BooleanPropNativeComponentProps(parserContext, sourceProps, rawProps); } TEST(BooleanPropNativeComponentProps_disabled, etc) { @@ -94,8 +109,12 @@ TEST(BooleanPropNativeComponentProps_disabled, etc) { propParser.prepare(); auto const &sourceProps = BooleanPropNativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"disabled\\", false)); - rawProps.parse(propParser); - BooleanPropNativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + BooleanPropNativeComponentProps(parserContext, sourceProps, rawProps); }", } `; @@ -112,6 +131,7 @@ Map { * */ #include +#include #include #include #include @@ -124,8 +144,12 @@ TEST(ColorPropNativeComponentProps_DoesNotDie, etc) { propParser.prepare(); auto const &sourceProps = ColorPropNativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); - rawProps.parse(propParser); - ColorPropNativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + ColorPropNativeComponentProps(parserContext, sourceProps, rawProps); } TEST(ColorPropNativeComponentProps_tintColor, etc) { @@ -133,8 +157,12 @@ TEST(ColorPropNativeComponentProps_tintColor, etc) { propParser.prepare(); auto const &sourceProps = ColorPropNativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"tintColor\\", 1)); - rawProps.parse(propParser); - ColorPropNativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + ColorPropNativeComponentProps(parserContext, sourceProps, rawProps); }", } `; @@ -151,6 +179,7 @@ Map { * */ #include +#include #include #include #include @@ -163,8 +192,12 @@ TEST(CommandNativeComponentProps_DoesNotDie, etc) { propParser.prepare(); auto const &sourceProps = CommandNativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); - rawProps.parse(propParser); - CommandNativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + CommandNativeComponentProps(parserContext, sourceProps, rawProps); }", } `; @@ -181,6 +214,7 @@ Map { * */ #include +#include #include #include #include @@ -193,8 +227,12 @@ TEST(CommandNativeComponentProps_DoesNotDie, etc) { propParser.prepare(); auto const &sourceProps = CommandNativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); - rawProps.parse(propParser); - CommandNativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + CommandNativeComponentProps(parserContext, sourceProps, rawProps); } TEST(CommandNativeComponentProps_accessibilityHint, etc) { @@ -202,8 +240,12 @@ TEST(CommandNativeComponentProps_accessibilityHint, etc) { propParser.prepare(); auto const &sourceProps = CommandNativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"accessibilityHint\\", \\"foo\\")); - rawProps.parse(propParser); - CommandNativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + CommandNativeComponentProps(parserContext, sourceProps, rawProps); }", } `; @@ -220,6 +262,7 @@ Map { * */ #include +#include #include #include #include @@ -232,8 +275,12 @@ TEST(DoublePropNativeComponentProps_DoesNotDie, etc) { propParser.prepare(); auto const &sourceProps = DoublePropNativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); - rawProps.parse(propParser); - DoublePropNativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + DoublePropNativeComponentProps(parserContext, sourceProps, rawProps); }", } `; @@ -250,6 +297,7 @@ Map { * */ #include +#include #include #include #include @@ -262,8 +310,12 @@ TEST(EventsNestedObjectNativeComponentProps_DoesNotDie, etc) { propParser.prepare(); auto const &sourceProps = EventsNestedObjectNativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); - rawProps.parse(propParser); - EventsNestedObjectNativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + EventsNestedObjectNativeComponentProps(parserContext, sourceProps, rawProps); } TEST(EventsNestedObjectNativeComponentProps_disabled, etc) { @@ -271,8 +323,12 @@ TEST(EventsNestedObjectNativeComponentProps_disabled, etc) { propParser.prepare(); auto const &sourceProps = EventsNestedObjectNativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"disabled\\", false)); - rawProps.parse(propParser); - EventsNestedObjectNativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + EventsNestedObjectNativeComponentProps(parserContext, sourceProps, rawProps); }", } `; @@ -289,6 +345,7 @@ Map { * */ #include +#include #include #include #include @@ -301,8 +358,12 @@ TEST(EventsNativeComponentProps_DoesNotDie, etc) { propParser.prepare(); auto const &sourceProps = EventsNativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); - rawProps.parse(propParser); - EventsNativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + EventsNativeComponentProps(parserContext, sourceProps, rawProps); } TEST(EventsNativeComponentProps_disabled, etc) { @@ -310,8 +371,12 @@ TEST(EventsNativeComponentProps_disabled, etc) { propParser.prepare(); auto const &sourceProps = EventsNativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"disabled\\", false)); - rawProps.parse(propParser); - EventsNativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + EventsNativeComponentProps(parserContext, sourceProps, rawProps); }", } `; @@ -328,6 +393,7 @@ Map { * */ #include +#include #include #include #include @@ -340,8 +406,12 @@ TEST(InterfaceOnlyComponentProps_DoesNotDie, etc) { propParser.prepare(); auto const &sourceProps = InterfaceOnlyComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); - rawProps.parse(propParser); - InterfaceOnlyComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + InterfaceOnlyComponentProps(parserContext, sourceProps, rawProps); }", } `; @@ -358,6 +428,7 @@ Map { * */ #include +#include #include #include #include @@ -370,8 +441,12 @@ TEST(ExcludedAndroidComponentProps_DoesNotDie, etc) { propParser.prepare(); auto const &sourceProps = ExcludedAndroidComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); - rawProps.parse(propParser); - ExcludedAndroidComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + ExcludedAndroidComponentProps(parserContext, sourceProps, rawProps); }", } `; @@ -388,6 +463,7 @@ Map { * */ #include +#include #include #include #include @@ -400,8 +476,12 @@ TEST(ExcludedAndroidIosComponentProps_DoesNotDie, etc) { propParser.prepare(); auto const &sourceProps = ExcludedAndroidIosComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); - rawProps.parse(propParser); - ExcludedAndroidIosComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + ExcludedAndroidIosComponentProps(parserContext, sourceProps, rawProps); }", } `; @@ -418,6 +498,7 @@ Map { * */ #include +#include #include #include #include @@ -430,8 +511,12 @@ TEST(FloatPropNativeComponentProps_DoesNotDie, etc) { propParser.prepare(); auto const &sourceProps = FloatPropNativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); - rawProps.parse(propParser); - FloatPropNativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + FloatPropNativeComponentProps(parserContext, sourceProps, rawProps); } TEST(FloatPropNativeComponentProps_blurRadius, etc) { @@ -439,8 +524,12 @@ TEST(FloatPropNativeComponentProps_blurRadius, etc) { propParser.prepare(); auto const &sourceProps = FloatPropNativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"blurRadius\\", 0)); - rawProps.parse(propParser); - FloatPropNativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + FloatPropNativeComponentProps(parserContext, sourceProps, rawProps); } TEST(FloatPropNativeComponentProps_blurRadius2, etc) { @@ -448,8 +537,12 @@ TEST(FloatPropNativeComponentProps_blurRadius2, etc) { propParser.prepare(); auto const &sourceProps = FloatPropNativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"blurRadius2\\", 0.001)); - rawProps.parse(propParser); - FloatPropNativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + FloatPropNativeComponentProps(parserContext, sourceProps, rawProps); } TEST(FloatPropNativeComponentProps_blurRadius3, etc) { @@ -457,8 +550,12 @@ TEST(FloatPropNativeComponentProps_blurRadius3, etc) { propParser.prepare(); auto const &sourceProps = FloatPropNativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"blurRadius3\\", 2.1)); - rawProps.parse(propParser); - FloatPropNativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + FloatPropNativeComponentProps(parserContext, sourceProps, rawProps); } TEST(FloatPropNativeComponentProps_blurRadius4, etc) { @@ -466,8 +563,12 @@ TEST(FloatPropNativeComponentProps_blurRadius4, etc) { propParser.prepare(); auto const &sourceProps = FloatPropNativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"blurRadius4\\", 0)); - rawProps.parse(propParser); - FloatPropNativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + FloatPropNativeComponentProps(parserContext, sourceProps, rawProps); } TEST(FloatPropNativeComponentProps_blurRadius5, etc) { @@ -475,8 +576,12 @@ TEST(FloatPropNativeComponentProps_blurRadius5, etc) { propParser.prepare(); auto const &sourceProps = FloatPropNativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"blurRadius5\\", 1)); - rawProps.parse(propParser); - FloatPropNativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + FloatPropNativeComponentProps(parserContext, sourceProps, rawProps); } TEST(FloatPropNativeComponentProps_blurRadius6, etc) { @@ -484,8 +589,12 @@ TEST(FloatPropNativeComponentProps_blurRadius6, etc) { propParser.prepare(); auto const &sourceProps = FloatPropNativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"blurRadius6\\", 0)); - rawProps.parse(propParser); - FloatPropNativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + FloatPropNativeComponentProps(parserContext, sourceProps, rawProps); }", } `; @@ -502,6 +611,7 @@ Map { * */ #include +#include #include #include #include @@ -515,8 +625,12 @@ TEST(ImagePropNativeComponentProps_DoesNotDie, etc) { propParser.prepare(); auto const &sourceProps = ImagePropNativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); - rawProps.parse(propParser); - ImagePropNativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + ImagePropNativeComponentProps(parserContext, sourceProps, rawProps); } TEST(ImagePropNativeComponentProps_thumbImage, etc) { @@ -524,8 +638,12 @@ TEST(ImagePropNativeComponentProps_thumbImage, etc) { propParser.prepare(); auto const &sourceProps = ImagePropNativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"thumbImage\\", folly::dynamic::object(\\"url\\", \\"testurl\\"))); - rawProps.parse(propParser); - ImagePropNativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + ImagePropNativeComponentProps(parserContext, sourceProps, rawProps); }", } `; @@ -542,6 +660,7 @@ Map { * */ #include +#include #include #include #include @@ -554,8 +673,12 @@ TEST(InsetsPropNativeComponentProps_DoesNotDie, etc) { propParser.prepare(); auto const &sourceProps = InsetsPropNativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); - rawProps.parse(propParser); - InsetsPropNativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + InsetsPropNativeComponentProps(parserContext, sourceProps, rawProps); }", } `; @@ -572,6 +695,7 @@ Map { * */ #include +#include #include #include #include @@ -584,8 +708,12 @@ TEST(Int32EnumPropsNativeComponentProps_DoesNotDie, etc) { propParser.prepare(); auto const &sourceProps = Int32EnumPropsNativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); - rawProps.parse(propParser); - Int32EnumPropsNativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + Int32EnumPropsNativeComponentProps(parserContext, sourceProps, rawProps); }", } `; @@ -602,6 +730,7 @@ Map { * */ #include +#include #include #include #include @@ -614,8 +743,12 @@ TEST(IntegerPropNativeComponentProps_DoesNotDie, etc) { propParser.prepare(); auto const &sourceProps = IntegerPropNativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); - rawProps.parse(propParser); - IntegerPropNativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + IntegerPropNativeComponentProps(parserContext, sourceProps, rawProps); }", } `; @@ -632,6 +765,7 @@ Map { * */ #include +#include #include #include #include @@ -644,8 +778,12 @@ TEST(InterfaceOnlyComponentProps_DoesNotDie, etc) { propParser.prepare(); auto const &sourceProps = InterfaceOnlyComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); - rawProps.parse(propParser); - InterfaceOnlyComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + InterfaceOnlyComponentProps(parserContext, sourceProps, rawProps); } TEST(InterfaceOnlyComponentProps_accessibilityHint, etc) { @@ -653,8 +791,12 @@ TEST(InterfaceOnlyComponentProps_accessibilityHint, etc) { propParser.prepare(); auto const &sourceProps = InterfaceOnlyComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"accessibilityHint\\", \\"foo\\")); - rawProps.parse(propParser); - InterfaceOnlyComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + InterfaceOnlyComponentProps(parserContext, sourceProps, rawProps); }", } `; @@ -671,6 +813,7 @@ Map { * */ #include +#include #include #include #include @@ -684,8 +827,12 @@ TEST(ImageColorPropNativeComponentProps_DoesNotDie, etc) { propParser.prepare(); auto const &sourceProps = ImageColorPropNativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); - rawProps.parse(propParser); - ImageColorPropNativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + ImageColorPropNativeComponentProps(parserContext, sourceProps, rawProps); } TEST(ImageColorPropNativeComponentProps_thumbImage, etc) { @@ -693,8 +840,12 @@ TEST(ImageColorPropNativeComponentProps_thumbImage, etc) { propParser.prepare(); auto const &sourceProps = ImageColorPropNativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"thumbImage\\", folly::dynamic::object(\\"url\\", \\"testurl\\"))); - rawProps.parse(propParser); - ImageColorPropNativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + ImageColorPropNativeComponentProps(parserContext, sourceProps, rawProps); } TEST(ImageColorPropNativeComponentProps_color, etc) { @@ -702,8 +853,12 @@ TEST(ImageColorPropNativeComponentProps_color, etc) { propParser.prepare(); auto const &sourceProps = ImageColorPropNativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"color\\", 1)); - rawProps.parse(propParser); - ImageColorPropNativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + ImageColorPropNativeComponentProps(parserContext, sourceProps, rawProps); } TEST(ImageColorPropNativeComponentProps_thumbTintColor, etc) { @@ -711,8 +866,12 @@ TEST(ImageColorPropNativeComponentProps_thumbTintColor, etc) { propParser.prepare(); auto const &sourceProps = ImageColorPropNativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"thumbTintColor\\", 1)); - rawProps.parse(propParser); - ImageColorPropNativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + ImageColorPropNativeComponentProps(parserContext, sourceProps, rawProps); } TEST(ImageColorPropNativeComponentProps_point, etc) { @@ -720,8 +879,12 @@ TEST(ImageColorPropNativeComponentProps_point, etc) { propParser.prepare(); auto const &sourceProps = ImageColorPropNativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"point\\", folly::dynamic::object(\\"x\\", 1)(\\"y\\", 1))); - rawProps.parse(propParser); - ImageColorPropNativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + ImageColorPropNativeComponentProps(parserContext, sourceProps, rawProps); }", } `; @@ -738,6 +901,7 @@ Map { * */ #include +#include #include #include #include @@ -750,8 +914,12 @@ TEST(NoPropsNoEventsComponentProps_DoesNotDie, etc) { propParser.prepare(); auto const &sourceProps = NoPropsNoEventsComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); - rawProps.parse(propParser); - NoPropsNoEventsComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + NoPropsNoEventsComponentProps(parserContext, sourceProps, rawProps); }", } `; @@ -768,6 +936,7 @@ Map { * */ #include +#include #include #include #include @@ -781,8 +950,12 @@ TEST(ObjectPropsProps_DoesNotDie, etc) { propParser.prepare(); auto const &sourceProps = ObjectPropsProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); - rawProps.parse(propParser); - ObjectPropsProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + ObjectPropsProps(parserContext, sourceProps, rawProps); }", } `; @@ -799,6 +972,7 @@ Map { * */ #include +#include #include #include #include @@ -811,8 +985,12 @@ TEST(PointPropNativeComponentProps_DoesNotDie, etc) { propParser.prepare(); auto const &sourceProps = PointPropNativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); - rawProps.parse(propParser); - PointPropNativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + PointPropNativeComponentProps(parserContext, sourceProps, rawProps); } TEST(PointPropNativeComponentProps_startPoint, etc) { @@ -820,8 +998,12 @@ TEST(PointPropNativeComponentProps_startPoint, etc) { propParser.prepare(); auto const &sourceProps = PointPropNativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"startPoint\\", folly::dynamic::object(\\"x\\", 1)(\\"y\\", 1))); - rawProps.parse(propParser); - PointPropNativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + PointPropNativeComponentProps(parserContext, sourceProps, rawProps); }", } `; @@ -838,6 +1020,7 @@ Map { * */ #include +#include #include #include #include @@ -850,8 +1033,12 @@ TEST(StringEnumPropsNativeComponentProps_DoesNotDie, etc) { propParser.prepare(); auto const &sourceProps = StringEnumPropsNativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); - rawProps.parse(propParser); - StringEnumPropsNativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + StringEnumPropsNativeComponentProps(parserContext, sourceProps, rawProps); } TEST(StringEnumPropsNativeComponentProps_alignment_Top, etc) { @@ -859,8 +1046,12 @@ TEST(StringEnumPropsNativeComponentProps_alignment_Top, etc) { propParser.prepare(); auto const &sourceProps = StringEnumPropsNativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"alignment\\", \\"top\\")); - rawProps.parse(propParser); - StringEnumPropsNativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + StringEnumPropsNativeComponentProps(parserContext, sourceProps, rawProps); } TEST(StringEnumPropsNativeComponentProps_alignment_Center, etc) { @@ -868,8 +1059,12 @@ TEST(StringEnumPropsNativeComponentProps_alignment_Center, etc) { propParser.prepare(); auto const &sourceProps = StringEnumPropsNativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"alignment\\", \\"center\\")); - rawProps.parse(propParser); - StringEnumPropsNativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + StringEnumPropsNativeComponentProps(parserContext, sourceProps, rawProps); } TEST(StringEnumPropsNativeComponentProps_alignment_BottomRight, etc) { @@ -877,8 +1072,12 @@ TEST(StringEnumPropsNativeComponentProps_alignment_BottomRight, etc) { propParser.prepare(); auto const &sourceProps = StringEnumPropsNativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"alignment\\", \\"bottom-right\\")); - rawProps.parse(propParser); - StringEnumPropsNativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + StringEnumPropsNativeComponentProps(parserContext, sourceProps, rawProps); }", } `; @@ -895,6 +1094,7 @@ Map { * */ #include +#include #include #include #include @@ -907,8 +1107,12 @@ TEST(StringPropComponentProps_DoesNotDie, etc) { propParser.prepare(); auto const &sourceProps = StringPropComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); - rawProps.parse(propParser); - StringPropComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + StringPropComponentProps(parserContext, sourceProps, rawProps); } TEST(StringPropComponentProps_accessibilityHint, etc) { @@ -916,8 +1120,12 @@ TEST(StringPropComponentProps_accessibilityHint, etc) { propParser.prepare(); auto const &sourceProps = StringPropComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"accessibilityHint\\", \\"foo\\")); - rawProps.parse(propParser); - StringPropComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + StringPropComponentProps(parserContext, sourceProps, rawProps); } TEST(StringPropComponentProps_accessibilityRole, etc) { @@ -925,8 +1133,12 @@ TEST(StringPropComponentProps_accessibilityRole, etc) { propParser.prepare(); auto const &sourceProps = StringPropComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"accessibilityRole\\", \\"foo\\")); - rawProps.parse(propParser); - StringPropComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + StringPropComponentProps(parserContext, sourceProps, rawProps); }", } `; @@ -943,6 +1155,7 @@ Map { * */ #include +#include #include #include #include @@ -955,8 +1168,12 @@ TEST(MultiFile1NativeComponentProps_DoesNotDie, etc) { propParser.prepare(); auto const &sourceProps = MultiFile1NativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); - rawProps.parse(propParser); - MultiFile1NativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + MultiFile1NativeComponentProps(parserContext, sourceProps, rawProps); } TEST(MultiFile1NativeComponentProps_disabled, etc) { @@ -964,8 +1181,12 @@ TEST(MultiFile1NativeComponentProps_disabled, etc) { propParser.prepare(); auto const &sourceProps = MultiFile1NativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"disabled\\", false)); - rawProps.parse(propParser); - MultiFile1NativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + MultiFile1NativeComponentProps(parserContext, sourceProps, rawProps); } TEST(MultiFile2NativeComponentProps_DoesNotDie, etc) { @@ -973,8 +1194,12 @@ TEST(MultiFile2NativeComponentProps_DoesNotDie, etc) { propParser.prepare(); auto const &sourceProps = MultiFile2NativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); - rawProps.parse(propParser); - MultiFile2NativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + MultiFile2NativeComponentProps(parserContext, sourceProps, rawProps); } TEST(MultiFile2NativeComponentProps_disabled, etc) { @@ -982,8 +1207,12 @@ TEST(MultiFile2NativeComponentProps_disabled, etc) { propParser.prepare(); auto const &sourceProps = MultiFile2NativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"disabled\\", true)); - rawProps.parse(propParser); - MultiFile2NativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + MultiFile2NativeComponentProps(parserContext, sourceProps, rawProps); }", } `; @@ -1000,6 +1229,7 @@ Map { * */ #include +#include #include #include #include @@ -1012,8 +1242,12 @@ TEST(MultiComponent1NativeComponentProps_DoesNotDie, etc) { propParser.prepare(); auto const &sourceProps = MultiComponent1NativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); - rawProps.parse(propParser); - MultiComponent1NativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + MultiComponent1NativeComponentProps(parserContext, sourceProps, rawProps); } TEST(MultiComponent1NativeComponentProps_disabled, etc) { @@ -1021,8 +1255,12 @@ TEST(MultiComponent1NativeComponentProps_disabled, etc) { propParser.prepare(); auto const &sourceProps = MultiComponent1NativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"disabled\\", false)); - rawProps.parse(propParser); - MultiComponent1NativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + MultiComponent1NativeComponentProps(parserContext, sourceProps, rawProps); } TEST(MultiComponent2NativeComponentProps_DoesNotDie, etc) { @@ -1030,8 +1268,12 @@ TEST(MultiComponent2NativeComponentProps_DoesNotDie, etc) { propParser.prepare(); auto const &sourceProps = MultiComponent2NativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); - rawProps.parse(propParser); - MultiComponent2NativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + MultiComponent2NativeComponentProps(parserContext, sourceProps, rawProps); } TEST(MultiComponent2NativeComponentProps_disabled, etc) { @@ -1039,8 +1281,12 @@ TEST(MultiComponent2NativeComponentProps_disabled, etc) { propParser.prepare(); auto const &sourceProps = MultiComponent2NativeComponentProps(); auto const &rawProps = RawProps(folly::dynamic::object(\\"disabled\\", true)); - rawProps.parse(propParser); - MultiComponent2NativeComponentProps(sourceProps, rawProps); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + MultiComponent2NativeComponentProps(parserContext, sourceProps, rawProps); }", } `;