Delete RawProps assignment operators (#49030)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49030

Overwriting another RawProps object via `operator=` is rarely what we want, and these objects should be considered immutable once constructed.

This will catch issues such as D68633985

Changelog: [General][Changed] Removed `RawProps::operator=`

Reviewed By: sammy-SC

Differential Revision: D68797484

fbshipit-source-id: 766a65db1dbf4485c78007f8f69cc9426d27a943
This commit is contained in:
Pieter De Baets
2025-01-29 06:16:20 -08:00
committed by Facebook GitHub Bot
parent 5d7fedacd0
commit e4d1cf8ce9
2 changed files with 6 additions and 21 deletions
@@ -104,10 +104,6 @@ inline bool isYogaStyleProp(const std::string& prop) {
}
} // namespace
RawProps::RawProps() {
mode_ = Mode::Empty;
}
/*
* Creates an object with given `runtime` and `value`.
*/
@@ -149,18 +145,6 @@ RawProps::RawProps(const RawProps& other) noexcept {
ignoreYogaStyleProps_ = other.ignoreYogaStyleProps_;
}
RawProps& RawProps::operator=(const RawProps& other) noexcept {
mode_ = other.mode_;
if (mode_ == Mode::JSI) {
runtime_ = other.runtime_;
value_ = jsi::Value(*runtime_, other.value_);
} else if (mode_ == Mode::Dynamic) {
dynamic_ = other.dynamic_;
}
ignoreYogaStyleProps_ = other.ignoreYogaStyleProps_;
return *this;
}
void RawProps::parse(const RawPropsParser& parser) noexcept {
react_native_assert(parser_ == nullptr && "A parser was already assigned.");
parser_ = &parser;
@@ -43,7 +43,7 @@ class RawProps final {
/*
* Creates empty RawProps objects.
*/
RawProps();
RawProps() : mode_(Mode::Empty) {}
/*
* Creates an object with given `runtime` and `value`.
@@ -51,10 +51,10 @@ class RawProps final {
RawProps(jsi::Runtime& runtime, const jsi::Value& value) noexcept;
explicit RawProps(const RawProps& rawProps) noexcept;
RawProps& operator=(const RawProps& other) noexcept;
RawProps(RawProps&& other) noexcept = default;
RawProps& operator=(RawProps&& other) noexcept = default;
RawProps& operator=(const RawProps& other) noexcept = delete;
RawProps& operator=(RawProps&& other) noexcept = delete;
/*
* Creates an object with given `folly::dynamic` object.
@@ -112,8 +112,9 @@ class RawProps final {
/*
* Source artefacts:
*/
// Mode
mutable Mode mode_;
Mode mode_;
// Case 1: Source data is represented as `jsi::Object`.
jsi::Runtime* runtime_{};