Skip to content

Commit

Permalink
Fix compilation warnings related to YogaShadowNode
Browse files Browse the repository at this point in the history
Summary:
## Changelog:
[Internal] -

These pop up when compiling with `/Wall`, fixes two legitimate warnings around using YogaShadowNode/Props in RN.

The `suggestedIndex` in `ShadowNode::replaceChild` (and the overriden one in `YogaLayoutableShadowNode`) is used in a way around the code that suggests that it **is** expected to be negative (checking for non-negativity, assigning -1 as default etc), so having it as a `size_t` type argument both makes things confusing and generates the warning.

I believe it's a good idea to be consistent and use the same type for the index throughout. In majority of the cases it's `int32_t` as of now.

Differential Revision: D48059620

fbshipit-source-id: 884c7296cf0b48eb7a6c569b151fc133dcb66d51
  • Loading branch information
rshest authored and facebook-github-bot committed Aug 4, 2023
1 parent c27e9e6 commit 0b2c23e
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ void YogaLayoutableShadowNode::appendChild(
void YogaLayoutableShadowNode::replaceChild(
ShadowNode const &oldChild,
ShadowNode::Shared const &newChild,
size_t suggestedIndex) {
int32_t suggestedIndex) {
LayoutableShadowNode::replaceChild(oldChild, newChild, suggestedIndex);

ensureUnsealed();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class YogaLayoutableShadowNode : public LayoutableShadowNode {
void replaceChild(
ShadowNode const &oldChild,
ShadowNode::Shared const &newChild,
size_t suggestedIndex = -1) override;
int32_t suggestedIndex = -1) override;

void updateYogaChildren();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ void YogaStylableProps::setProp(
const char *propName,
RawValue const &value) {
static const auto ygDefaults = YGStyle{};
static const auto defaults = YogaStylableProps{};

Props::setProp(context, hash, propName, value);

Expand Down Expand Up @@ -133,8 +134,6 @@ void YogaStylableProps::setProp(
REBUILD_FIELD_YG_EDGES(padding, "padding", "");
REBUILD_FIELD_YG_EDGES(border, "border", "Width");

static const auto defaults = YogaStylableProps{};

// Aliases
RAW_SET_PROP_SWITCH_CASE(inset, "inset");
RAW_SET_PROP_SWITCH_CASE(insetBlock, "insetBlock");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ void ShadowNode::appendChild(const ShadowNode::Shared &child) {
void ShadowNode::replaceChild(
ShadowNode const &oldChild,
ShadowNode::Shared const &newChild,
size_t suggestedIndex) {
int32_t suggestedIndex) {
ensureUnsealed();

cloneChildrenIfShared();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class ShadowNode : public Sealable,
virtual void replaceChild(
ShadowNode const &oldChild,
Shared const &newChild,
size_t suggestedIndex = -1);
int32_t suggestedIndex = -1);

/*
* Performs all side effects associated with mounting/unmounting in one place.
Expand Down

0 comments on commit 0b2c23e

Please sign in to comment.