From 524119323f245583af832b5e64932088bdf53fdb Mon Sep 17 00:00:00 2001 From: James Ide Date: Fri, 4 Dec 2026 01:36:32 -0800 Subject: [PATCH] Represent classic Fabric prop names as static identifiers The classic Fabric props parser registers each name a component reads and keeps a view of its bytes for later lookups. A `const char*` name leaves that lifetime requirement unstated, and every lookup measures a length the compiler already knows. This change adds `RawPropName` and uses it for the single-name `RawProps::at` and for `convertRawProp`. Its `consteval` constructor accepts string literals and static `constexpr` character arrays, so the compiler computes the length and the name has static storage. A name ends at its first NUL, or at the end of an array that has none. Generated code and calls that pass a literal keep their syntax. Names built at run time go through the new `RawProps::atRuntime`. The parser copies such a name when it registers it, and later lookups compare against the argument without copying it. The deprecated three-argument prefix and suffix overload of `RawProps::at` uses `atRuntime`, so the parser no longer keeps a view of the temporary string that overload composes. A Props constructor that reads its props only under a condition that was false while the parser was prepared leaves the parser with no registered names. A lookup in such a parser now returns `nullptr` instead of reading the first element of an empty name list. C++ code that passes a `const char*` or `std::string_view` name to `convertRawProp` or `RawProps::at` no longer compiles. A helper that forwards a declared name takes a `RawPropName` instead; code that builds a name at run time calls `RawProps::atRuntime` and converts the returned `RawValue`. #60541 proposes making the iterator-based setter the default for components that support it. That path hashes each supplied name and calls `setProp` without the registered names, so this change does not affect it. Components that use the classic constructor keep the registered-name path. `react_renderer_core_tests --gtest_filter='RawPropsTest.*:PropsConceptsTest.*:ComponentDescriptorTest.*'` passes in Debug. New tests look up a name without a terminating NUL, check that the parser copies composed names while it prepares, and look up a name in a parser that registered none. Compile-time checks accept string literals and reject `std::string`, `const char*` and `std::string_view` names. The Debug View and TextInput prop tests pass. The generated Safe Area props compile, and the Android NDK compiles the TextInput and View prop sources. `FANTOM_FORCE_OSS_BUILD=1 yarn fantom --maxWorkers=4` passes, including the View tests with the iterator flag on and off. `python -m scripts.cxx-api.parser --validate` passes with Doxygen 1.16.1. In an optimized build on an Apple M6, cloning `ViewProps` with six supplied props retires a median of 38,462 instructions on `075deb0d98` and 31,095 with this change on the classic path, 19.15% fewer. With the iterator flag on, the same clone retires 6,924 and 6,905. Signed-off-by: James Ide --- .../AndroidTextInputProps.cpp | 2 +- .../components/view/propsConversions.h | 56 +++---- .../react/renderer/core/RawProps.cpp | 18 ++- .../react/renderer/core/RawProps.h | 32 +++- .../react/renderer/core/RawPropsParser.cpp | 10 +- .../react/renderer/core/RawPropsParser.h | 6 +- .../react/renderer/core/propsConversions.h | 4 +- .../renderer/core/tests/RawPropsTest.cpp | 137 ++++++++++++++++++ .../api-snapshots/ReactAndroidDebugCxx.api | 11 +- .../ReactAndroidFrameworksCxx.api | 11 +- .../api-snapshots/ReactAndroidNewarchCxx.api | 11 +- .../api-snapshots/ReactAndroidReleaseCxx.api | 11 +- .../api-snapshots/ReactAppleDebugCxx.api | 11 +- .../api-snapshots/ReactAppleFrameworksCxx.api | 11 +- .../api-snapshots/ReactAppleNewarchCxx.api | 11 +- .../api-snapshots/ReactAppleReleaseCxx.api | 11 +- .../api-snapshots/ReactCommonDebugCxx.api | 11 +- .../ReactCommonFrameworksCxx.api | 11 +- .../api-snapshots/ReactCommonNewarchCxx.api | 11 +- .../api-snapshots/ReactCommonReleaseCxx.api | 11 +- 20 files changed, 330 insertions(+), 67 deletions(-) diff --git a/packages/react-native/ReactCommon/react/renderer/components/textinput/platform/android/react/renderer/components/androidtextinput/AndroidTextInputProps.cpp b/packages/react-native/ReactCommon/react/renderer/components/textinput/platform/android/react/renderer/components/androidtextinput/AndroidTextInputProps.cpp index e4ad212de108..372211097bc0 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/textinput/platform/android/react/renderer/components/androidtextinput/AndroidTextInputProps.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/textinput/platform/android/react/renderer/components/androidtextinput/AndroidTextInputProps.cpp @@ -15,7 +15,7 @@ namespace facebook::react { static bool -hasValue(const RawProps& rawProps, bool defaultValue, const char* name) { +hasValue(const RawProps& rawProps, bool defaultValue, RawPropName name) { auto rawValue = rawProps.at(name); // No change to prop - use default diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/propsConversions.h b/packages/react-native/ReactCommon/react/renderer/components/view/propsConversions.h index 9d4fc75dfeb7..ce3532f6ba2e 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/propsConversions.h +++ b/packages/react-native/ReactCommon/react/renderer/components/view/propsConversions.h @@ -374,37 +374,37 @@ convertRawProp(const PropsParserContext &context, const RawProps &rawProps, cons } struct CascadedRectangleCornersNames { - const char *topLeft; - const char *topRight; - const char *bottomLeft; - const char *bottomRight; - const char *topStart; - const char *topEnd; - const char *bottomStart; - const char *bottomEnd; - const char *endEnd; - const char *endStart; - const char *startEnd; - const char *startStart; - const char *all; + RawPropName topLeft; + RawPropName topRight; + RawPropName bottomLeft; + RawPropName bottomRight; + RawPropName topStart; + RawPropName topEnd; + RawPropName bottomStart; + RawPropName bottomEnd; + RawPropName endEnd; + RawPropName endStart; + RawPropName startEnd; + RawPropName startStart; + RawPropName all; }; struct CascadedRectangleEdgesNames { - const char *left; - const char *right; - const char *top; - const char *bottom; - const char *start; - const char *end; - const char *horizontal; - const char *vertical; - const char *block; - const char *blockEnd; - const char *blockStart; - const char *inline_; - const char *inlineEnd; - const char *inlineStart; - const char *all; + RawPropName left; + RawPropName right; + RawPropName top; + RawPropName bottom; + RawPropName start; + RawPropName end; + RawPropName horizontal; + RawPropName vertical; + RawPropName block; + RawPropName blockEnd; + RawPropName blockStart; + RawPropName inline_; + RawPropName inlineEnd; + RawPropName inlineStart; + RawPropName all; }; // This can be deleted when non-iterator ViewProp parsing is deleted diff --git a/packages/react-native/ReactCommon/react/renderer/core/RawProps.cpp b/packages/react-native/ReactCommon/react/renderer/core/RawProps.cpp index bf1849ffa10c..ebd435a85843 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/RawProps.cpp +++ b/packages/react-native/ReactCommon/react/renderer/core/RawProps.cpp @@ -109,11 +109,18 @@ bool RawProps::isEmpty() const noexcept { * Returns a const unowning pointer to `RawValue` of a prop with a given name. * Returns `nullptr` if a prop with the given name does not exist. */ -const RawValue* RawProps::at(const char* name) const noexcept { +const RawValue* RawProps::at(RawPropName name) const noexcept { react_native_assert( parser_ && "The object is not parsed. `parse` must be called before `at`."); - return parser_->at(*this, name); + return parser_->at(*this, name.view(), /* copyKey */ false); +} + +const RawValue* RawProps::atRuntime(std::string_view name) const noexcept { + react_native_assert( + parser_ && + "The object is not parsed. `parse` must be called before `atRuntime`."); + return parser_->at(*this, name, /* copyKey */ true); } const RawValue* RawProps::at( @@ -121,7 +128,7 @@ const RawValue* RawProps::at( const char* prefix, const char* suffix) const noexcept { if (prefix == nullptr && suffix == nullptr) { - return at(name); + return atRuntime(name); } std::string concatenated; @@ -132,10 +139,7 @@ const RawValue* RawProps::at( if (suffix != nullptr) { concatenated += suffix; } - react_native_assert( - parser_ && - "The object is not parsed. `parse` must be called before `at`."); - return parser_->at(*this, concatenated); + return atRuntime(concatenated); } } // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/renderer/core/RawProps.h b/packages/react-native/ReactCommon/react/renderer/core/RawProps.h index 8685ec6f575d..70d0fa27d80e 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/RawProps.h +++ b/packages/react-native/ReactCommon/react/renderer/core/RawProps.h @@ -9,9 +9,11 @@ #include +#include #include #include #include +#include #include #include @@ -25,6 +27,26 @@ namespace facebook::react { class RawPropsParser; +// A classic prop name backed by a string literal or static constexpr array. +// Immediate construction rejects arrays whose addresses cannot escape constant +// evaluation and determines the length at the call site. +class RawPropName final { + public: + template + consteval RawPropName(const char (&name)[Size]) : name_(name, Size) + { + name_ = name_.substr(0, name_.find('\0')); + } + + constexpr std::string_view view() const noexcept + { + return name_; + } + + private: + std::string_view name_; +}; + /* * `RawProps` represents an untyped map of props comes from JavaScript side. * `RawProps` stores JSI (or `folly::dynamic`) primitives inside and abstract @@ -99,10 +121,14 @@ class RawProps final { * Returns a const unowning pointer to `RawValue` of a prop with a given name. * Returns `nullptr` if a prop with the given name does not exist. */ - const RawValue *at(const char *name) const noexcept; + const RawValue *at(RawPropName name) const noexcept; + + // Looks up a name composed at runtime. The name must also be requested while + // preparing the parser, which copies its bytes so they need only live through + // the call. + const RawValue *atRuntime(std::string_view name) const noexcept; - // Deprecated: Use at(name) instead. This overload exists for backwards - // compatibility with callers that pass prefix/suffix separately. + // Deprecated: compose the name and call atRuntime instead. const RawValue *at(const char *name, const char *prefix, const char *suffix) const noexcept; /* diff --git a/packages/react-native/ReactCommon/react/renderer/core/RawPropsParser.cpp b/packages/react-native/ReactCommon/react/renderer/core/RawPropsParser.cpp index 23ee075e2267..de88df0fe58b 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/RawPropsParser.cpp +++ b/packages/react-native/ReactCommon/react/renderer/core/RawPropsParser.cpp @@ -30,7 +30,8 @@ inline bool keysEqual(std::string_view a, std::string_view b) noexcept { // which props are accessed during parsing, and in which order. const RawValue* RawPropsParser::at( const RawProps& rawProps, - std::string_view key) const noexcept { + std::string_view key, + bool copyKey) const noexcept { if (!ready_) [[unlikely]] { // Check against the same key being inserted more than once. // This happens commonly with nested Props structs, where the higher-level @@ -50,6 +51,10 @@ const RawValue* RawPropsParser::at( } // This is not thread-safe part; this happens only during initialization of // a `ComponentDescriptor` where it is actually safe. + if (copyKey) { + ownedKeys_.push_back(std::make_shared(key)); + key = *ownedKeys_.back(); + } keys_.push_back(key); react_native_assert(size < std::numeric_limits::max()); nameToIndex_.insert(key, static_cast(size)); @@ -65,6 +70,9 @@ const RawValue* RawPropsParser::at( if (static_cast(rawProps.keyIndexCursor_) >= keys_.size()) [[unlikely]] { + if (keys_.empty()) { + return nullptr; + } rawProps.keyIndexCursor_ = 0; } diff --git a/packages/react-native/ReactCommon/react/renderer/core/RawPropsParser.h b/packages/react-native/ReactCommon/react/renderer/core/RawPropsParser.h index 5613f794ef06..2819771e3a1f 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/RawPropsParser.h +++ b/packages/react-native/ReactCommon/react/renderer/core/RawPropsParser.h @@ -15,6 +15,8 @@ #include #include #include +#include +#include #include namespace facebook::react { @@ -72,8 +74,10 @@ class RawPropsParser final { /* * To be used by `RawProps` only. */ - const RawValue *at(const RawProps &rawProps, std::string_view key) const noexcept; + const RawValue *at(const RawProps &rawProps, std::string_view key, bool copyKey) const noexcept; + // Keep the backing storage of runtime keys stable across parser copies. + mutable std::vector> ownedKeys_{}; mutable std::vector keys_{}; mutable RawPropsKeyMap nameToIndex_{}; mutable bool ready_{false}; diff --git a/packages/react-native/ReactCommon/react/renderer/core/propsConversions.h b/packages/react-native/ReactCommon/react/renderer/core/propsConversions.h index 0e7ed7608641..fae9fc54b226 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/propsConversions.h +++ b/packages/react-native/ReactCommon/react/renderer/core/propsConversions.h @@ -172,7 +172,7 @@ template T convertRawProp( const PropsParserContext &context, const RawProps &rawProps, - const char *name, + RawPropName name, const T &sourceValue, const U &defaultValue) { @@ -194,7 +194,7 @@ T convertRawProp( } catch (const std::exception &e) { // In case of errors, log the error and fall back to the default // TODO: report this using ErrorUtils so it's more visible to the user - LOG(ERROR) << "Error while converting prop '" << name << "': " << e.what(); + LOG(ERROR) << "Error while converting prop '" << name.view() << "': " << e.what(); return defaultValue; } } diff --git a/packages/react-native/ReactCommon/react/renderer/core/tests/RawPropsTest.cpp b/packages/react-native/ReactCommon/react/renderer/core/tests/RawPropsTest.cpp index 46774b3d1401..15f56bdafde8 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/tests/RawPropsTest.cpp +++ b/packages/react-native/ReactCommon/react/renderer/core/tests/RawPropsTest.cpp @@ -16,10 +16,147 @@ #include #include #include +#include +#include +#include using namespace facebook; using namespace facebook::react; +namespace { + +template +concept CanLookUpProp = requires(const RawProps& props, Name&& name) { + props.at(std::forward(name)); +}; + +template +concept CanConvertProp = requires( + const PropsParserContext& context, + const RawProps& props, + Name&& name) { + convertRawProp(context, props, std::forward(name), 0, {}); +}; + +static_assert(CanLookUpProp); +static_assert(CanConvertProp); +static_assert(!CanLookUpProp); +static_assert(!CanConvertProp); +static_assert(!CanLookUpProp); +static_assert(!CanConvertProp); +static_assert(!CanLookUpProp); +static_assert(!CanConvertProp); + +constexpr char unterminatedName[] = {'v', 'a', 'l', 'u', 'e'}; +constexpr char paddedName[12] = "value"; + +struct PropsWithUnterminatedName : Props { + PropsWithUnterminatedName( + const PropsParserContext& context, + const PropsWithUnterminatedName& source, + const RawProps& rawProps) + : value(convertRawProp( + context, + rawProps, + unterminatedName, + source.value, + {})) {} + + PropsWithUnterminatedName() = default; + int value{}; +}; + +struct PropsWithComposedNames : Props { + PropsWithComposedNames( + const PropsParserContext&, + const PropsWithComposedNames&, + const RawProps& rawProps) { + std::string name = "test"; + name += "PropA"; + if (const auto* rawValue = rawProps.atRuntime(name)) { + first = static_cast(*rawValue); + } + name.back() = 'B'; + if (const auto* rawValue = rawProps.atRuntime(name)) { + second = static_cast(*rawValue); + } + if (const auto* rawValue = rawProps.at("Prop", "compat", "Value")) { + composed = static_cast(*rawValue); + } + } + + PropsWithComposedNames() = default; + int first{}; + int second{}; + int composed{}; +}; + +// Reads its prop only when props are supplied, so preparing the parser, which +// passes empty props, registers no names +struct PropsWithConditionalRead : Props { + PropsWithConditionalRead( + const PropsParserContext&, + const PropsWithConditionalRead&, + const RawProps& rawProps) { + if (!rawProps.isEmpty()) { + unregistered = rawProps.at("value"); + } + } + + PropsWithConditionalRead() = default; + const RawValue* unregistered{}; +}; + +} // namespace + +TEST(RawPropsTest, looksUpAnUnterminatedName) { + RawPropsParser parser; + parser.prepare(); + RawProps raw(folly::dynamic::object("value", 42)("valueExtra", 19)); + raw.parse(parser); + + ContextContainer contextContainer; + PropsParserContext context{-1, contextContainer}; + EXPECT_EQ(PropsWithUnterminatedName(context, {}, raw).value, 42); + const auto* value = raw.at(paddedName); + ASSERT_NE(value, nullptr); + EXPECT_EQ(static_cast(*value), 42); +} + +TEST(RawPropsTest, copiesComposedNamesWhilePreparing) { + const auto parser = [] { + RawPropsParser original; + original.prepare(); + return RawPropsParser(original); + }(); + RawProps raw( + folly::dynamic::object("testPropA", 42)("testPropB", 19)( + "compatPropValue", 7)); + raw.parse(parser); + + ContextContainer contextContainer; + PropsParserContext context{-1, contextContainer}; + PropsWithComposedNames props(context, {}, raw); + EXPECT_EQ(props.first, 42); + EXPECT_EQ(props.second, 19); + EXPECT_EQ(props.composed, 7); + const auto* value = raw.at("compatPropValue", nullptr, nullptr); + ASSERT_NE(value, nullptr); + EXPECT_EQ(static_cast(*value), 7); +} + +TEST(RawPropsTest, looksUpANameInAParserWithNoNames) { + RawPropsParser parser; + parser.prepare(); + RawProps raw(folly::dynamic::object("value", 42)); + raw.parse(parser); + + ContextContainer contextContainer; + PropsParserContext context{-1, contextContainer}; + EXPECT_EQ(PropsWithConditionalRead(context, {}, raw).unregistered, nullptr); + EXPECT_EQ(raw.at("value"), nullptr); +} + TEST(RawPropsTest, dynamicSourceIsBorrowed) { const auto rawProps = RawProps(folly::dynamic::object("opacity", 0.5)); const auto* dynamic = rawProps.getDynamic(); diff --git a/scripts/cxx-api/api-snapshots/ReactAndroidDebugCxx.api b/scripts/cxx-api/api-snapshots/ReactAndroidDebugCxx.api index 3ab4e7cd11e1..161209542a2a 100644 --- a/scripts/cxx-api/api-snapshots/ReactAndroidDebugCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactAndroidDebugCxx.api @@ -579,7 +579,7 @@ facebook::react::ComponentDescriptorProvider facebook::react::concreteComponentD template DestinationTimePointT facebook::react::clockCast(SourceTimePointT timePoint); template -T facebook::react::convertRawProp(const facebook::react::PropsParserContext& context, const facebook::react::RawProps& rawProps, const char* name, const T& sourceValue, const U& defaultValue); +T facebook::react::convertRawProp(const facebook::react::PropsParserContext& context, const facebook::react::RawProps& rawProps, facebook::react::RawPropName name, const T& sourceValue, const U& defaultValue); template folly::dynamic facebook::react::toDynamic(const std::vector& arrayValue); template @@ -2130,6 +2130,12 @@ class facebook::react::PullToRefreshViewProps : public facebook::react::HostPlat public virtual folly::dynamic getDiffProps(const facebook::react::Props* prevProps) const override; } +class facebook::react::RawPropName { + public constexpr std::string_view view() const noexcept; + template + public consteval RawPropName(const char(&name)[Size]); +} + class facebook::react::RawProps { public RawProps(); public RawProps(const facebook::react::RawProps& other) noexcept; @@ -2137,8 +2143,9 @@ class facebook::react::RawProps { public RawProps(facebook::react::RawProps&& other) noexcept = default; public RawProps(folly::dynamic dynamic) noexcept; public bool isEmpty() const noexcept; - public const facebook::react::RawValue* at(const char* name) const noexcept; public const facebook::react::RawValue* at(const char* name, const char* prefix, const char* suffix) const noexcept; + public const facebook::react::RawValue* at(facebook::react::RawPropName name) const noexcept; + public const facebook::react::RawValue* atRuntime(std::string_view name) const noexcept; public const folly::dynamic* getDynamic() const noexcept; public facebook::react::RawProps& operator=(const facebook::react::RawProps& other) noexcept = delete; public facebook::react::RawProps& operator=(facebook::react::RawProps&& other) noexcept = delete; diff --git a/scripts/cxx-api/api-snapshots/ReactAndroidFrameworksCxx.api b/scripts/cxx-api/api-snapshots/ReactAndroidFrameworksCxx.api index b520c48af496..bd0c577ccb1f 100644 --- a/scripts/cxx-api/api-snapshots/ReactAndroidFrameworksCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactAndroidFrameworksCxx.api @@ -850,7 +850,7 @@ facebook::react::ComponentDescriptorProvider facebook::react::concreteComponentD template DestinationTimePointT facebook::react::clockCast(SourceTimePointT timePoint); template -T facebook::react::convertRawProp(const facebook::react::PropsParserContext& context, const facebook::react::RawProps& rawProps, const char* name, const T& sourceValue, const U& defaultValue); +T facebook::react::convertRawProp(const facebook::react::PropsParserContext& context, const facebook::react::RawProps& rawProps, facebook::react::RawPropName name, const T& sourceValue, const U& defaultValue); template T facebook::react::get(const facebook::react::AnimatedPropBase& animatedProp); template @@ -3279,6 +3279,12 @@ class facebook::react::PullToRefreshViewProps : public facebook::react::HostPlat public virtual folly::dynamic getDiffProps(const facebook::react::Props* prevProps) const override; } +class facebook::react::RawPropName { + public constexpr std::string_view view() const noexcept; + template + public consteval RawPropName(const char(&name)[Size]); +} + class facebook::react::RawProps { public RawProps(); public RawProps(const facebook::react::RawProps& other) noexcept; @@ -3286,8 +3292,9 @@ class facebook::react::RawProps { public RawProps(facebook::react::RawProps&& other) noexcept = default; public RawProps(folly::dynamic dynamic) noexcept; public bool isEmpty() const noexcept; - public const facebook::react::RawValue* at(const char* name) const noexcept; public const facebook::react::RawValue* at(const char* name, const char* prefix, const char* suffix) const noexcept; + public const facebook::react::RawValue* at(facebook::react::RawPropName name) const noexcept; + public const facebook::react::RawValue* atRuntime(std::string_view name) const noexcept; public const folly::dynamic* getDynamic() const noexcept; public facebook::react::RawProps& operator=(const facebook::react::RawProps& other) noexcept = delete; public facebook::react::RawProps& operator=(facebook::react::RawProps&& other) noexcept = delete; diff --git a/scripts/cxx-api/api-snapshots/ReactAndroidNewarchCxx.api b/scripts/cxx-api/api-snapshots/ReactAndroidNewarchCxx.api index d48c22c4efe9..6d2aee78b589 100644 --- a/scripts/cxx-api/api-snapshots/ReactAndroidNewarchCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactAndroidNewarchCxx.api @@ -579,7 +579,7 @@ facebook::react::ComponentDescriptorProvider facebook::react::concreteComponentD template DestinationTimePointT facebook::react::clockCast(SourceTimePointT timePoint); template -T facebook::react::convertRawProp(const facebook::react::PropsParserContext& context, const facebook::react::RawProps& rawProps, const char* name, const T& sourceValue, const U& defaultValue); +T facebook::react::convertRawProp(const facebook::react::PropsParserContext& context, const facebook::react::RawProps& rawProps, facebook::react::RawPropName name, const T& sourceValue, const U& defaultValue); template folly::dynamic facebook::react::toDynamic(const std::vector& arrayValue); template @@ -2129,6 +2129,12 @@ class facebook::react::PullToRefreshViewProps : public facebook::react::HostPlat public virtual folly::dynamic getDiffProps(const facebook::react::Props* prevProps) const override; } +class facebook::react::RawPropName { + public constexpr std::string_view view() const noexcept; + template + public consteval RawPropName(const char(&name)[Size]); +} + class facebook::react::RawProps { public RawProps(); public RawProps(const facebook::react::RawProps& other) noexcept; @@ -2136,8 +2142,9 @@ class facebook::react::RawProps { public RawProps(facebook::react::RawProps&& other) noexcept = default; public RawProps(folly::dynamic dynamic) noexcept; public bool isEmpty() const noexcept; - public const facebook::react::RawValue* at(const char* name) const noexcept; public const facebook::react::RawValue* at(const char* name, const char* prefix, const char* suffix) const noexcept; + public const facebook::react::RawValue* at(facebook::react::RawPropName name) const noexcept; + public const facebook::react::RawValue* atRuntime(std::string_view name) const noexcept; public const folly::dynamic* getDynamic() const noexcept; public facebook::react::RawProps& operator=(const facebook::react::RawProps& other) noexcept = delete; public facebook::react::RawProps& operator=(facebook::react::RawProps&& other) noexcept = delete; diff --git a/scripts/cxx-api/api-snapshots/ReactAndroidReleaseCxx.api b/scripts/cxx-api/api-snapshots/ReactAndroidReleaseCxx.api index d48c22c4efe9..6d2aee78b589 100644 --- a/scripts/cxx-api/api-snapshots/ReactAndroidReleaseCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactAndroidReleaseCxx.api @@ -579,7 +579,7 @@ facebook::react::ComponentDescriptorProvider facebook::react::concreteComponentD template DestinationTimePointT facebook::react::clockCast(SourceTimePointT timePoint); template -T facebook::react::convertRawProp(const facebook::react::PropsParserContext& context, const facebook::react::RawProps& rawProps, const char* name, const T& sourceValue, const U& defaultValue); +T facebook::react::convertRawProp(const facebook::react::PropsParserContext& context, const facebook::react::RawProps& rawProps, facebook::react::RawPropName name, const T& sourceValue, const U& defaultValue); template folly::dynamic facebook::react::toDynamic(const std::vector& arrayValue); template @@ -2129,6 +2129,12 @@ class facebook::react::PullToRefreshViewProps : public facebook::react::HostPlat public virtual folly::dynamic getDiffProps(const facebook::react::Props* prevProps) const override; } +class facebook::react::RawPropName { + public constexpr std::string_view view() const noexcept; + template + public consteval RawPropName(const char(&name)[Size]); +} + class facebook::react::RawProps { public RawProps(); public RawProps(const facebook::react::RawProps& other) noexcept; @@ -2136,8 +2142,9 @@ class facebook::react::RawProps { public RawProps(facebook::react::RawProps&& other) noexcept = default; public RawProps(folly::dynamic dynamic) noexcept; public bool isEmpty() const noexcept; - public const facebook::react::RawValue* at(const char* name) const noexcept; public const facebook::react::RawValue* at(const char* name, const char* prefix, const char* suffix) const noexcept; + public const facebook::react::RawValue* at(facebook::react::RawPropName name) const noexcept; + public const facebook::react::RawValue* atRuntime(std::string_view name) const noexcept; public const folly::dynamic* getDynamic() const noexcept; public facebook::react::RawProps& operator=(const facebook::react::RawProps& other) noexcept = delete; public facebook::react::RawProps& operator=(facebook::react::RawProps&& other) noexcept = delete; diff --git a/scripts/cxx-api/api-snapshots/ReactAppleDebugCxx.api b/scripts/cxx-api/api-snapshots/ReactAppleDebugCxx.api index 6189f1f82908..6c4799416d8c 100644 --- a/scripts/cxx-api/api-snapshots/ReactAppleDebugCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactAppleDebugCxx.api @@ -3296,7 +3296,7 @@ DestinationTimePointT facebook::react::clockCast(SourceTimePointT timePoint); template RCTManagedPointer* facebook::react::managedPointer(P initializer); template -T facebook::react::convertRawProp(const facebook::react::PropsParserContext& context, const facebook::react::RawProps& rawProps, const char* name, const T& sourceValue, const U& defaultValue); +T facebook::react::convertRawProp(const facebook::react::PropsParserContext& context, const facebook::react::RawProps& rawProps, facebook::react::RawPropName name, const T& sourceValue, const U& defaultValue); template facebook::react::ModuleConstants facebook::react::typedConstants(typename T::Builder::Input&& value); template @@ -4382,6 +4382,12 @@ class facebook::react::RCTMessageThread : public facebook::react::MessageQueueTh public ~RCTMessageThread() override; } +class facebook::react::RawPropName { + public constexpr std::string_view view() const noexcept; + template + public consteval RawPropName(const char(&name)[Size]); +} + class facebook::react::RawProps { public RawProps(); public RawProps(const facebook::react::RawProps& other) noexcept; @@ -4389,8 +4395,9 @@ class facebook::react::RawProps { public RawProps(facebook::react::RawProps&& other) noexcept = default; public RawProps(folly::dynamic dynamic) noexcept; public bool isEmpty() const noexcept; - public const facebook::react::RawValue* at(const char* name) const noexcept; public const facebook::react::RawValue* at(const char* name, const char* prefix, const char* suffix) const noexcept; + public const facebook::react::RawValue* at(facebook::react::RawPropName name) const noexcept; + public const facebook::react::RawValue* atRuntime(std::string_view name) const noexcept; public const folly::dynamic* getDynamic() const noexcept; public facebook::react::RawProps& operator=(const facebook::react::RawProps& other) noexcept = delete; public facebook::react::RawProps& operator=(facebook::react::RawProps&& other) noexcept = delete; diff --git a/scripts/cxx-api/api-snapshots/ReactAppleFrameworksCxx.api b/scripts/cxx-api/api-snapshots/ReactAppleFrameworksCxx.api index 85668b7d3ccc..1b0978cdea17 100644 --- a/scripts/cxx-api/api-snapshots/ReactAppleFrameworksCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactAppleFrameworksCxx.api @@ -3604,7 +3604,7 @@ DestinationTimePointT facebook::react::clockCast(SourceTimePointT timePoint); template RCTManagedPointer* facebook::react::managedPointer(P initializer); template -T facebook::react::convertRawProp(const facebook::react::PropsParserContext& context, const facebook::react::RawProps& rawProps, const char* name, const T& sourceValue, const U& defaultValue); +T facebook::react::convertRawProp(const facebook::react::PropsParserContext& context, const facebook::react::RawProps& rawProps, facebook::react::RawPropName name, const T& sourceValue, const U& defaultValue); template T facebook::react::get(const facebook::react::AnimatedPropBase& animatedProp); template @@ -5476,6 +5476,12 @@ class facebook::react::RCTMessageThread : public facebook::react::MessageQueueTh public ~RCTMessageThread() override; } +class facebook::react::RawPropName { + public constexpr std::string_view view() const noexcept; + template + public consteval RawPropName(const char(&name)[Size]); +} + class facebook::react::RawProps { public RawProps(); public RawProps(const facebook::react::RawProps& other) noexcept; @@ -5483,8 +5489,9 @@ class facebook::react::RawProps { public RawProps(facebook::react::RawProps&& other) noexcept = default; public RawProps(folly::dynamic dynamic) noexcept; public bool isEmpty() const noexcept; - public const facebook::react::RawValue* at(const char* name) const noexcept; public const facebook::react::RawValue* at(const char* name, const char* prefix, const char* suffix) const noexcept; + public const facebook::react::RawValue* at(facebook::react::RawPropName name) const noexcept; + public const facebook::react::RawValue* atRuntime(std::string_view name) const noexcept; public const folly::dynamic* getDynamic() const noexcept; public facebook::react::RawProps& operator=(const facebook::react::RawProps& other) noexcept = delete; public facebook::react::RawProps& operator=(facebook::react::RawProps&& other) noexcept = delete; diff --git a/scripts/cxx-api/api-snapshots/ReactAppleNewarchCxx.api b/scripts/cxx-api/api-snapshots/ReactAppleNewarchCxx.api index df4f68c31155..e589a93fcf69 100644 --- a/scripts/cxx-api/api-snapshots/ReactAppleNewarchCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactAppleNewarchCxx.api @@ -3289,7 +3289,7 @@ DestinationTimePointT facebook::react::clockCast(SourceTimePointT timePoint); template RCTManagedPointer* facebook::react::managedPointer(P initializer); template -T facebook::react::convertRawProp(const facebook::react::PropsParserContext& context, const facebook::react::RawProps& rawProps, const char* name, const T& sourceValue, const U& defaultValue); +T facebook::react::convertRawProp(const facebook::react::PropsParserContext& context, const facebook::react::RawProps& rawProps, facebook::react::RawPropName name, const T& sourceValue, const U& defaultValue); template facebook::react::ModuleConstants facebook::react::typedConstants(typename T::Builder::Input&& value); template @@ -4374,6 +4374,12 @@ class facebook::react::RCTMessageThread : public facebook::react::MessageQueueTh public ~RCTMessageThread() override; } +class facebook::react::RawPropName { + public constexpr std::string_view view() const noexcept; + template + public consteval RawPropName(const char(&name)[Size]); +} + class facebook::react::RawProps { public RawProps(); public RawProps(const facebook::react::RawProps& other) noexcept; @@ -4381,8 +4387,9 @@ class facebook::react::RawProps { public RawProps(facebook::react::RawProps&& other) noexcept = default; public RawProps(folly::dynamic dynamic) noexcept; public bool isEmpty() const noexcept; - public const facebook::react::RawValue* at(const char* name) const noexcept; public const facebook::react::RawValue* at(const char* name, const char* prefix, const char* suffix) const noexcept; + public const facebook::react::RawValue* at(facebook::react::RawPropName name) const noexcept; + public const facebook::react::RawValue* atRuntime(std::string_view name) const noexcept; public const folly::dynamic* getDynamic() const noexcept; public facebook::react::RawProps& operator=(const facebook::react::RawProps& other) noexcept = delete; public facebook::react::RawProps& operator=(facebook::react::RawProps&& other) noexcept = delete; diff --git a/scripts/cxx-api/api-snapshots/ReactAppleReleaseCxx.api b/scripts/cxx-api/api-snapshots/ReactAppleReleaseCxx.api index 64b0e2327e07..3440874e2a93 100644 --- a/scripts/cxx-api/api-snapshots/ReactAppleReleaseCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactAppleReleaseCxx.api @@ -3296,7 +3296,7 @@ DestinationTimePointT facebook::react::clockCast(SourceTimePointT timePoint); template RCTManagedPointer* facebook::react::managedPointer(P initializer); template -T facebook::react::convertRawProp(const facebook::react::PropsParserContext& context, const facebook::react::RawProps& rawProps, const char* name, const T& sourceValue, const U& defaultValue); +T facebook::react::convertRawProp(const facebook::react::PropsParserContext& context, const facebook::react::RawProps& rawProps, facebook::react::RawPropName name, const T& sourceValue, const U& defaultValue); template facebook::react::ModuleConstants facebook::react::typedConstants(typename T::Builder::Input&& value); template @@ -4381,6 +4381,12 @@ class facebook::react::RCTMessageThread : public facebook::react::MessageQueueTh public ~RCTMessageThread() override; } +class facebook::react::RawPropName { + public constexpr std::string_view view() const noexcept; + template + public consteval RawPropName(const char(&name)[Size]); +} + class facebook::react::RawProps { public RawProps(); public RawProps(const facebook::react::RawProps& other) noexcept; @@ -4388,8 +4394,9 @@ class facebook::react::RawProps { public RawProps(facebook::react::RawProps&& other) noexcept = default; public RawProps(folly::dynamic dynamic) noexcept; public bool isEmpty() const noexcept; - public const facebook::react::RawValue* at(const char* name) const noexcept; public const facebook::react::RawValue* at(const char* name, const char* prefix, const char* suffix) const noexcept; + public const facebook::react::RawValue* at(facebook::react::RawPropName name) const noexcept; + public const facebook::react::RawValue* atRuntime(std::string_view name) const noexcept; public const folly::dynamic* getDynamic() const noexcept; public facebook::react::RawProps& operator=(const facebook::react::RawProps& other) noexcept = delete; public facebook::react::RawProps& operator=(facebook::react::RawProps&& other) noexcept = delete; diff --git a/scripts/cxx-api/api-snapshots/ReactCommonDebugCxx.api b/scripts/cxx-api/api-snapshots/ReactCommonDebugCxx.api index 2d39e71b808c..77971f95515a 100644 --- a/scripts/cxx-api/api-snapshots/ReactCommonDebugCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactCommonDebugCxx.api @@ -216,7 +216,7 @@ facebook::react::ComponentDescriptorProvider facebook::react::concreteComponentD template DestinationTimePointT facebook::react::clockCast(SourceTimePointT timePoint); template -T facebook::react::convertRawProp(const facebook::react::PropsParserContext& context, const facebook::react::RawProps& rawProps, const char* name, const T& sourceValue, const U& defaultValue); +T facebook::react::convertRawProp(const facebook::react::PropsParserContext& context, const facebook::react::RawProps& rawProps, facebook::react::RawPropName name, const T& sourceValue, const U& defaultValue); template void facebook::react::fromRawValue(const facebook::react::PropsParserContext& context, const facebook::react::RawValue& rawValue, T& result, T defaultValue); template @@ -950,6 +950,12 @@ class facebook::react::Props : public virtual facebook::react::Sealable, public public void setProp(const facebook::react::PropsParserContext& context, facebook::react::RawPropsPropNameHash hash, const char* propName, const facebook::react::RawValue& value); } +class facebook::react::RawPropName { + public constexpr std::string_view view() const noexcept; + template + public consteval RawPropName(const char(&name)[Size]); +} + class facebook::react::RawProps { public RawProps(); public RawProps(const facebook::react::RawProps& other) noexcept; @@ -957,8 +963,9 @@ class facebook::react::RawProps { public RawProps(facebook::react::RawProps&& other) noexcept = default; public RawProps(folly::dynamic dynamic) noexcept; public bool isEmpty() const noexcept; - public const facebook::react::RawValue* at(const char* name) const noexcept; public const facebook::react::RawValue* at(const char* name, const char* prefix, const char* suffix) const noexcept; + public const facebook::react::RawValue* at(facebook::react::RawPropName name) const noexcept; + public const facebook::react::RawValue* atRuntime(std::string_view name) const noexcept; public const folly::dynamic* getDynamic() const noexcept; public facebook::react::RawProps& operator=(const facebook::react::RawProps& other) noexcept = delete; public facebook::react::RawProps& operator=(facebook::react::RawProps&& other) noexcept = delete; diff --git a/scripts/cxx-api/api-snapshots/ReactCommonFrameworksCxx.api b/scripts/cxx-api/api-snapshots/ReactCommonFrameworksCxx.api index f68615e9118b..dabdfa65d474 100644 --- a/scripts/cxx-api/api-snapshots/ReactCommonFrameworksCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactCommonFrameworksCxx.api @@ -420,7 +420,7 @@ facebook::react::ComponentDescriptorProvider facebook::react::concreteComponentD template DestinationTimePointT facebook::react::clockCast(SourceTimePointT timePoint); template -T facebook::react::convertRawProp(const facebook::react::PropsParserContext& context, const facebook::react::RawProps& rawProps, const char* name, const T& sourceValue, const U& defaultValue); +T facebook::react::convertRawProp(const facebook::react::PropsParserContext& context, const facebook::react::RawProps& rawProps, facebook::react::RawPropName name, const T& sourceValue, const U& defaultValue); template T facebook::react::get(const facebook::react::AnimatedPropBase& animatedProp); template @@ -1889,6 +1889,12 @@ class facebook::react::Props : public virtual facebook::react::Sealable, public public void setProp(const facebook::react::PropsParserContext& context, facebook::react::RawPropsPropNameHash hash, const char* propName, const facebook::react::RawValue& value); } +class facebook::react::RawPropName { + public constexpr std::string_view view() const noexcept; + template + public consteval RawPropName(const char(&name)[Size]); +} + class facebook::react::RawProps { public RawProps(); public RawProps(const facebook::react::RawProps& other) noexcept; @@ -1896,8 +1902,9 @@ class facebook::react::RawProps { public RawProps(facebook::react::RawProps&& other) noexcept = default; public RawProps(folly::dynamic dynamic) noexcept; public bool isEmpty() const noexcept; - public const facebook::react::RawValue* at(const char* name) const noexcept; public const facebook::react::RawValue* at(const char* name, const char* prefix, const char* suffix) const noexcept; + public const facebook::react::RawValue* at(facebook::react::RawPropName name) const noexcept; + public const facebook::react::RawValue* atRuntime(std::string_view name) const noexcept; public const folly::dynamic* getDynamic() const noexcept; public facebook::react::RawProps& operator=(const facebook::react::RawProps& other) noexcept = delete; public facebook::react::RawProps& operator=(facebook::react::RawProps&& other) noexcept = delete; diff --git a/scripts/cxx-api/api-snapshots/ReactCommonNewarchCxx.api b/scripts/cxx-api/api-snapshots/ReactCommonNewarchCxx.api index 5ff99aabf8c6..a196d8799548 100644 --- a/scripts/cxx-api/api-snapshots/ReactCommonNewarchCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactCommonNewarchCxx.api @@ -216,7 +216,7 @@ facebook::react::ComponentDescriptorProvider facebook::react::concreteComponentD template DestinationTimePointT facebook::react::clockCast(SourceTimePointT timePoint); template -T facebook::react::convertRawProp(const facebook::react::PropsParserContext& context, const facebook::react::RawProps& rawProps, const char* name, const T& sourceValue, const U& defaultValue); +T facebook::react::convertRawProp(const facebook::react::PropsParserContext& context, const facebook::react::RawProps& rawProps, facebook::react::RawPropName name, const T& sourceValue, const U& defaultValue); template void facebook::react::fromRawValue(const facebook::react::PropsParserContext& context, const facebook::react::RawValue& rawValue, T& result, T defaultValue); template @@ -949,6 +949,12 @@ class facebook::react::Props : public virtual facebook::react::Sealable, public public void setProp(const facebook::react::PropsParserContext& context, facebook::react::RawPropsPropNameHash hash, const char* propName, const facebook::react::RawValue& value); } +class facebook::react::RawPropName { + public constexpr std::string_view view() const noexcept; + template + public consteval RawPropName(const char(&name)[Size]); +} + class facebook::react::RawProps { public RawProps(); public RawProps(const facebook::react::RawProps& other) noexcept; @@ -956,8 +962,9 @@ class facebook::react::RawProps { public RawProps(facebook::react::RawProps&& other) noexcept = default; public RawProps(folly::dynamic dynamic) noexcept; public bool isEmpty() const noexcept; - public const facebook::react::RawValue* at(const char* name) const noexcept; public const facebook::react::RawValue* at(const char* name, const char* prefix, const char* suffix) const noexcept; + public const facebook::react::RawValue* at(facebook::react::RawPropName name) const noexcept; + public const facebook::react::RawValue* atRuntime(std::string_view name) const noexcept; public const folly::dynamic* getDynamic() const noexcept; public facebook::react::RawProps& operator=(const facebook::react::RawProps& other) noexcept = delete; public facebook::react::RawProps& operator=(facebook::react::RawProps&& other) noexcept = delete; diff --git a/scripts/cxx-api/api-snapshots/ReactCommonReleaseCxx.api b/scripts/cxx-api/api-snapshots/ReactCommonReleaseCxx.api index 5ff99aabf8c6..a196d8799548 100644 --- a/scripts/cxx-api/api-snapshots/ReactCommonReleaseCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactCommonReleaseCxx.api @@ -216,7 +216,7 @@ facebook::react::ComponentDescriptorProvider facebook::react::concreteComponentD template DestinationTimePointT facebook::react::clockCast(SourceTimePointT timePoint); template -T facebook::react::convertRawProp(const facebook::react::PropsParserContext& context, const facebook::react::RawProps& rawProps, const char* name, const T& sourceValue, const U& defaultValue); +T facebook::react::convertRawProp(const facebook::react::PropsParserContext& context, const facebook::react::RawProps& rawProps, facebook::react::RawPropName name, const T& sourceValue, const U& defaultValue); template void facebook::react::fromRawValue(const facebook::react::PropsParserContext& context, const facebook::react::RawValue& rawValue, T& result, T defaultValue); template @@ -949,6 +949,12 @@ class facebook::react::Props : public virtual facebook::react::Sealable, public public void setProp(const facebook::react::PropsParserContext& context, facebook::react::RawPropsPropNameHash hash, const char* propName, const facebook::react::RawValue& value); } +class facebook::react::RawPropName { + public constexpr std::string_view view() const noexcept; + template + public consteval RawPropName(const char(&name)[Size]); +} + class facebook::react::RawProps { public RawProps(); public RawProps(const facebook::react::RawProps& other) noexcept; @@ -956,8 +962,9 @@ class facebook::react::RawProps { public RawProps(facebook::react::RawProps&& other) noexcept = default; public RawProps(folly::dynamic dynamic) noexcept; public bool isEmpty() const noexcept; - public const facebook::react::RawValue* at(const char* name) const noexcept; public const facebook::react::RawValue* at(const char* name, const char* prefix, const char* suffix) const noexcept; + public const facebook::react::RawValue* at(facebook::react::RawPropName name) const noexcept; + public const facebook::react::RawValue* atRuntime(std::string_view name) const noexcept; public const folly::dynamic* getDynamic() const noexcept; public facebook::react::RawProps& operator=(const facebook::react::RawProps& other) noexcept = delete; public facebook::react::RawProps& operator=(facebook::react::RawProps&& other) noexcept = delete;